add useOwnedEntites to catalog-react
Signed-off-by: mufaddal motiwala <mufaddalmm.52@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-react': minor
|
||||
---
|
||||
|
||||
added useOwnedEntities hook to get the list of entities of the logged-in user
|
||||
@@ -9,6 +9,7 @@ import { ApiRef } from '@backstage/core-plugin-api';
|
||||
import { AsyncState } from 'react-use/lib/useAsync';
|
||||
import { CATALOG_FILTER_EXISTS } from '@backstage/catalog-client';
|
||||
import { CatalogApi } from '@backstage/catalog-client';
|
||||
import { CatalogListResponse } from '@backstage/catalog-client';
|
||||
import { ComponentEntity } from '@backstage/catalog-model';
|
||||
import { ComponentProps } from 'react';
|
||||
import { Context } from 'react';
|
||||
@@ -847,6 +848,12 @@ export function useEntityOwnership(): {
|
||||
// @public
|
||||
export function useEntityTypeFilter(): EntityTypeReturn;
|
||||
|
||||
// @public
|
||||
export function useOwnedEntities(allowedKinds?: string[]): {
|
||||
loading: boolean;
|
||||
ownedEntities: CatalogListResponse<Entity> | undefined;
|
||||
};
|
||||
|
||||
// Warning: (ae-missing-release-tag) "useOwnUser" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public
|
||||
|
||||
@@ -42,3 +42,4 @@ export {
|
||||
useEntityOwnership,
|
||||
loadIdentityOwnerRefs,
|
||||
} from './useEntityOwnership';
|
||||
export { useOwnedEntities } from './useOwnedEntities';
|
||||
|
||||
+13
-2
@@ -13,17 +13,27 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { catalogApiRef } from './../api';
|
||||
import {
|
||||
catalogApiRef,
|
||||
loadCatalogOwnerRefs,
|
||||
loadIdentityOwnerRefs,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
} from './useEntityOwnership';
|
||||
import { identityApiRef, useApi } from '@backstage/core-plugin-api';
|
||||
import { Entity, RELATION_OWNED_BY } from '@backstage/catalog-model';
|
||||
import { CatalogListResponse } from '@backstage/catalog-client';
|
||||
import { useAsync } from 'react-use';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
/**
|
||||
* Takes the relevant parts of the Backstage identity, and translates them into
|
||||
* a list of entities which are owned by the user. Takes an optional parameter
|
||||
* to filter the entities based on allowedKinds
|
||||
*
|
||||
* @public
|
||||
*
|
||||
* @param allowedKinds - Array of allowed kinds to filter the entities
|
||||
* @returns CatalogListResponse<Entity>
|
||||
*/
|
||||
export function useOwnedEntities(allowedKinds?: string[]): {
|
||||
loading: boolean;
|
||||
ownedEntities: CatalogListResponse<Entity> | undefined;
|
||||
@@ -52,6 +62,7 @@ export function useOwnedEntities(allowedKinds?: string[]): {
|
||||
);
|
||||
return catalogs;
|
||||
}, []);
|
||||
|
||||
const ownedEntities = useMemo(() => {
|
||||
return refs;
|
||||
}, [refs]);
|
||||
@@ -13,13 +13,15 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { formatEntityRefTitle } from '@backstage/plugin-catalog-react';
|
||||
import {
|
||||
formatEntityRefTitle,
|
||||
useOwnedEntities,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { TextField } from '@material-ui/core';
|
||||
import FormControl from '@material-ui/core/FormControl';
|
||||
import Autocomplete from '@material-ui/lab/Autocomplete';
|
||||
import { FieldProps } from '@rjsf/core';
|
||||
import React from 'react';
|
||||
import { useOwnedEntities } from './useOwnedEntities';
|
||||
|
||||
export const OwnedEntityPicker = ({
|
||||
onChange,
|
||||
|
||||
Reference in New Issue
Block a user