diff --git a/.changeset/smart-penguins-compete.md b/.changeset/smart-penguins-compete.md new file mode 100644 index 0000000000..d3518600a6 --- /dev/null +++ b/.changeset/smart-penguins-compete.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-react': patch +--- + +export `loadIdentityOwnerRefs` and `loadCatalogOwnerRefs` all the way diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index bf8295a8b5..c4aa254226 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -15,6 +15,7 @@ import { Context } from 'react'; import { Entity } from '@backstage/catalog-model'; import { EntityName } from '@backstage/catalog-model'; import { IconButton } from '@material-ui/core'; +import { IdentityApi } from '@backstage/core-plugin-api'; import { LinkProps } from '@backstage/core-components'; import { Observable } from '@backstage/types'; import { PropsWithChildren } from 'react'; @@ -736,6 +737,17 @@ export function getEntitySourceLocation( // @public export function isOwnerOf(owner: Entity, owned: Entity): boolean; +// @public +export function loadCatalogOwnerRefs( + catalogApi: CatalogApi, + identityOwnerRefs: string[], +): Promise; + +// @public +export function loadIdentityOwnerRefs( + identityApi: IdentityApi, +): Promise; + // Warning: (ae-missing-release-tag) "MockEntityListContextProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -823,8 +835,6 @@ export function useEntityListProvider< EntityFilters extends DefaultEntityFilters = DefaultEntityFilters, >(): EntityListContextProps; -// Warning: (ae-missing-release-tag) "useEntityOwnership" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public export function useEntityOwnership(): { loading: boolean; diff --git a/plugins/catalog-react/src/hooks/index.ts b/plugins/catalog-react/src/hooks/index.ts index 38fc58222d..bbbca3a501 100644 --- a/plugins/catalog-react/src/hooks/index.ts +++ b/plugins/catalog-react/src/hooks/index.ts @@ -37,4 +37,8 @@ export { useOwnUser } from './useOwnUser'; export { useRelatedEntities } from './useRelatedEntities'; export { useStarredEntities } from './useStarredEntities'; export { useStarredEntity } from './useStarredEntity'; -export { useEntityOwnership } from './useEntityOwnership'; +export { + loadCatalogOwnerRefs, + useEntityOwnership, + loadIdentityOwnerRefs, +} from './useEntityOwnership'; diff --git a/plugins/catalog-react/src/hooks/useEntityOwnership.ts b/plugins/catalog-react/src/hooks/useEntityOwnership.ts index aee903603a..54e9e0ff99 100644 --- a/plugins/catalog-react/src/hooks/useEntityOwnership.ts +++ b/plugins/catalog-react/src/hooks/useEntityOwnership.ts @@ -49,9 +49,16 @@ function extendUserId(id: string): string { } } -// Takes the relevant parts of the Backstage identity, and translates them into -// a list of entity refs on string form that represent the user's ownership -// connections. +/** + * Takes the relevant parts of the Backstage identity, and translates them into + * a list of entity refs on string form that represent the user's ownership + * connections. + * + * @public + * + * @param identityApi - The IdentityApi implementation + * @returns IdentityOwner refs as a string array + */ export async function loadIdentityOwnerRefs( identityApi: IdentityApi, ): Promise { @@ -81,9 +88,17 @@ export async function loadIdentityOwnerRefs( return result; } -// Takes the relevant parts of the User entity corresponding to the Backstage -// identity, and translates them into a list of entity refs on string form that -// represent the user's ownership connections. +/** + * Takes the relevant parts of the User entity corresponding to the Backstage + * identity, and translates them into a list of entity refs on string form that + * represent the user's ownership connections. + * + * @public + * + * @param catalogApi - The Catalog API implementation + * @param identityOwnerRefs - List of identity owner refs as strings + * @returns OwnerRefs as a string array + */ export async function loadCatalogOwnerRefs( catalogApi: CatalogApi, identityOwnerRefs: string[], @@ -113,6 +128,10 @@ export async function loadCatalogOwnerRefs( * owner of a given entity. When the hook is initially mounted, the loading * flag will be true and the results returned from the function will always be * false. + * + * @public + * + * @returns a function that checks if the signed in user owns an entity */ export function useEntityOwnership(): { loading: boolean;