From 9c238ca4c6e5e6c8a70b95d6bad01f9d0c09ae32 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 3 Mar 2022 10:53:27 +0100 Subject: [PATCH 1/3] chore: moving isOwnerOf to alpha and documentation the limitations Signed-off-by: blam --- plugins/catalog-react/api-report.md | 4 ++-- plugins/catalog-react/src/utils/isOwnerOf.ts | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index 75414e3d59..b482bed9a6 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -452,8 +452,8 @@ export function InspectEntityDialog(props: { onClose: () => void; }): JSX.Element | null; -// @public -export function isOwnerOf(owner: Entity, owned: Entity): boolean; +// @alpha +export function isOwnerOf(owner: Entity, entity: Entity): boolean; // @public @deprecated export function loadCatalogOwnerRefs( diff --git a/plugins/catalog-react/src/utils/isOwnerOf.ts b/plugins/catalog-react/src/utils/isOwnerOf.ts index f1ba0fa35f..2b38ace247 100644 --- a/plugins/catalog-react/src/utils/isOwnerOf.ts +++ b/plugins/catalog-react/src/utils/isOwnerOf.ts @@ -24,10 +24,15 @@ import { import { getEntityRelations } from './getEntityRelations'; /** - * Get the related entity references. - * @public + * Returns true if the `owner` argument is a direct owner on the `entity` argument. + * + * @alpha + * @remarks + * + * Note that this ownership is not the same as using the claims in the auth-resolver, it only will take into account ownership as expressed by direct entity relations. + * It doesn't know anything about the additional groups that a user might belong to which the claims contain. */ -export function isOwnerOf(owner: Entity, owned: Entity) { +export function isOwnerOf(owner: Entity, entity: Entity) { const possibleOwners = new Set( [ ...getEntityRelations(owner, RELATION_MEMBER_OF, { kind: 'group' }), @@ -35,7 +40,7 @@ export function isOwnerOf(owner: Entity, owned: Entity) { ].map(stringifyEntityRef), ); - const owners = getEntityRelations(owned, RELATION_OWNED_BY).map( + const owners = getEntityRelations(entity, RELATION_OWNED_BY).map( stringifyEntityRef, ); From 72431d7bedb26787c5b4cf22191fc5673fd0fd0e Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 3 Mar 2022 10:55:08 +0100 Subject: [PATCH 2/3] chore: added changeset Signed-off-by: blam --- .changeset/polite-houses-wink.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/polite-houses-wink.md diff --git a/.changeset/polite-houses-wink.md b/.changeset/polite-houses-wink.md new file mode 100644 index 0000000000..4adceef6ee --- /dev/null +++ b/.changeset/polite-houses-wink.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-react': patch +--- + +- Moving `isOwnerOf` to `@alpha` and documenting the limitations of this function with regards to only supporting direct relations. From 0ca28cc2c702fa403b263bd5750156d54ffabc0e Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 3 Mar 2022 12:41:26 +0100 Subject: [PATCH 3/3] Update polite-houses-wink.md Signed-off-by: Patrik Oldsberg --- .changeset/polite-houses-wink.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/polite-houses-wink.md b/.changeset/polite-houses-wink.md index 4adceef6ee..3e177f5383 100644 --- a/.changeset/polite-houses-wink.md +++ b/.changeset/polite-houses-wink.md @@ -2,4 +2,4 @@ '@backstage/plugin-catalog-react': patch --- -- Moving `isOwnerOf` to `@alpha` and documenting the limitations of this function with regards to only supporting direct relations. +- **BREAKING**: The `isOwnerOf` function has been marked as `@alpha` and is now only available via the `@backstage/plugin-catalog-react/alpha` import. The limitations of this function with regards to only supporting direct relations have also been documented.