Merge pull request #9937 from backstage/blam/is-owner-of
🧹 `isOwnerOf` to `@alpha` and documenting limitations
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-react': patch
|
||||
---
|
||||
|
||||
- **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.
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user