From 8cb7acd781aa2a424cfa7870065b53d43ffd36d5 Mon Sep 17 00:00:00 2001 From: Mike Lewis Date: Fri, 11 Mar 2022 09:21:58 +0000 Subject: [PATCH] catalog-react: stop using CatalogEntityPermission convenience type There's currently an issue with importing alpha exports from other packages in the monorepo. This works around the issue for now by skipping the use of the `CatalogEntityPermission` convenience type, using `ResourcePermission<'catalog-entity'>` directly instead. cf. https://github.com/backstage/backstage/pull/10128 Signed-off-by: Mike Lewis --- .changeset/clever-donuts-teach.md | 2 +- plugins/catalog-react/api-report.md | 6 ++++-- plugins/catalog-react/src/hooks/useEntityPermission.ts | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.changeset/clever-donuts-teach.md b/.changeset/clever-donuts-teach.md index eb828dfa4e..2304de1137 100644 --- a/.changeset/clever-donuts-teach.md +++ b/.changeset/clever-donuts-teach.md @@ -2,4 +2,4 @@ '@backstage/plugin-catalog-react': patch --- -Prevent permissions with types other than `CatalogEntityPermission` from being used with the `useEntityPermission` hook. +Prevent permissions with types other than `ResourcePermission<'catalog-entity'>` from being used with the `useEntityPermission` hook. diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index e25c3c92bd..71ba6452da 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -8,7 +8,6 @@ import { ApiRef } from '@backstage/core-plugin-api'; import { CATALOG_FILTER_EXISTS } from '@backstage/catalog-client'; import { CatalogApi } from '@backstage/catalog-client'; -import { CatalogEntityPermission } from '@backstage/plugin-catalog-common'; import { ComponentEntity } from '@backstage/catalog-model'; import { ComponentProps } from 'react'; import { CompoundEntityRef } from '@backstage/catalog-model'; @@ -20,6 +19,7 @@ import { Overrides } from '@material-ui/core/styles/overrides'; import { PropsWithChildren } from 'react'; import { default as React_2 } from 'react'; import { ReactNode } from 'react'; +import { ResourcePermission } from '@backstage/plugin-permission-common'; import { RouteRef } from '@backstage/core-plugin-api'; import { ScmIntegrationRegistry } from '@backstage/integration'; import { StyleRules } from '@material-ui/core/styles/withStyles'; @@ -489,7 +489,9 @@ export function useEntityOwnership(): { }; // @alpha -export function useEntityPermission(permission: CatalogEntityPermission): { +export function useEntityPermission( + permission: ResourcePermission<'catalog-entity'>, +): { loading: boolean; allowed: boolean; error?: Error; diff --git a/plugins/catalog-react/src/hooks/useEntityPermission.ts b/plugins/catalog-react/src/hooks/useEntityPermission.ts index bd8f565ecb..e9fdbaaa6a 100644 --- a/plugins/catalog-react/src/hooks/useEntityPermission.ts +++ b/plugins/catalog-react/src/hooks/useEntityPermission.ts @@ -15,7 +15,7 @@ */ import { stringifyEntityRef } from '@backstage/catalog-model'; -import { CatalogEntityPermission } from '@backstage/plugin-catalog-common'; +import { ResourcePermission } from '@backstage/plugin-permission-common'; import { usePermission } from '@backstage/plugin-permission-react'; import { useAsyncEntity } from './useEntity'; @@ -30,7 +30,9 @@ import { useAsyncEntity } from './useEntity'; * `usePermission` hook directly. * @alpha */ -export function useEntityPermission(permission: CatalogEntityPermission): { +export function useEntityPermission( + permission: ResourcePermission<'catalog-entity'>, +): { loading: boolean; allowed: boolean; error?: Error;