From 03b47a476dadb895b0b9d36628ac7ec1759f86d1 Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Tue, 26 Oct 2021 14:01:32 +0200 Subject: [PATCH 1/4] catalog-react: export loadIdentityOwnerRefs and loadCatalogOwnerRefs all the way Signed-off-by: Himanshu Mishra --- .changeset/smart-penguins-compete.md | 5 +++++ plugins/catalog-react/api-report.md | 16 ++++++++++++++++ plugins/catalog-react/src/hooks/index.ts | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .changeset/smart-penguins-compete.md 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 06dccf4b7f..07a924bfa3 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'; @@ -726,6 +727,21 @@ export function getEntitySourceLocation( // @public export function isOwnerOf(owner: Entity, owned: Entity): boolean; +// Warning: (ae-missing-release-tag) "loadCatalogOwnerRefs" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export function loadCatalogOwnerRefs( + catalogApi: CatalogApi, + identityOwnerRefs: string[], +): Promise; + +// Warning: (ae-missing-release-tag) "loadIdentityOwnerRefs" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +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) diff --git a/plugins/catalog-react/src/hooks/index.ts b/plugins/catalog-react/src/hooks/index.ts index 38fc58222d..17c15e4ebb 100644 --- a/plugins/catalog-react/src/hooks/index.ts +++ b/plugins/catalog-react/src/hooks/index.ts @@ -37,4 +37,4 @@ export { useOwnUser } from './useOwnUser'; export { useRelatedEntities } from './useRelatedEntities'; export { useStarredEntities } from './useStarredEntities'; export { useStarredEntity } from './useStarredEntity'; -export { useEntityOwnership } from './useEntityOwnership'; +export * from './useEntityOwnership'; From 064297ea19eeecb12e8a54ac6d8d503bcd85379a Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 8 Nov 2021 10:57:58 +0100 Subject: [PATCH 2/4] chore: adding some documentation for exported things Signed-off-by: blam --- .../src/hooks/useEntityOwnership.ts | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) 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; From 0aec087ee6422bc896b9c33c4b6a9cff6b26e9e9 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 8 Nov 2021 11:00:30 +0100 Subject: [PATCH 3/4] chore: updating API report Signed-off-by: blam --- plugins/catalog-react/api-report.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index 07a924bfa3..19a4dfd930 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -727,17 +727,13 @@ export function getEntitySourceLocation( // @public export function isOwnerOf(owner: Entity, owned: Entity): boolean; -// Warning: (ae-missing-release-tag) "loadCatalogOwnerRefs" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) +// @public export function loadCatalogOwnerRefs( catalogApi: CatalogApi, identityOwnerRefs: string[], ): Promise; -// Warning: (ae-missing-release-tag) "loadIdentityOwnerRefs" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) +// @public export function loadIdentityOwnerRefs( identityApi: IdentityApi, ): Promise; @@ -829,8 +825,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; From 4c780d86514c0b4354357cda21ffead175202a4b Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 8 Nov 2021 15:14:38 +0100 Subject: [PATCH 4/4] chore: use named exports instead Signed-off-by: blam --- plugins/catalog-react/src/hooks/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/catalog-react/src/hooks/index.ts b/plugins/catalog-react/src/hooks/index.ts index 17c15e4ebb..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 * from './useEntityOwnership'; +export { + loadCatalogOwnerRefs, + useEntityOwnership, + loadIdentityOwnerRefs, +} from './useEntityOwnership';