Merge pull request #7777 from backstage/orkohunter/export-entity-ref-hooks

catalog-react: export loadIdentityOwnerRefs and loadCatalogOwnerRefs all the way
This commit is contained in:
Ben Lambert
2021-11-08 15:57:14 +01:00
committed by GitHub
4 changed files with 47 additions and 9 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-react': patch
---
export `loadIdentityOwnerRefs` and `loadCatalogOwnerRefs` all the way
+12 -2
View File
@@ -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<string[]>;
// @public
export function loadIdentityOwnerRefs(
identityApi: IdentityApi,
): Promise<string[]>;
// 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<EntityFilters>;
// 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;
+5 -1
View File
@@ -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';
@@ -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<string[]> {
@@ -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;