diff --git a/plugins/permission-react/api-report.md b/plugins/permission-react/api-report.md index 81d9e09743..6b66376cb7 100644 --- a/plugins/permission-react/api-report.md +++ b/plugins/permission-react/api-report.md @@ -60,9 +60,15 @@ export const PermissionedRoute: ( // @public export function usePermission( - ...[permission, resourceRef]: - | [ResourcePermission, string | undefined] - | [Exclude] + input: + | { + permission: Exclude; + resourceRef?: never; + } + | { + permission: ResourcePermission; + resourceRef: string | undefined; + }, ): AsyncPermissionResult; // (No @packageDocumentation comment for this package) diff --git a/plugins/permission-react/src/hooks/usePermission.ts b/plugins/permission-react/src/hooks/usePermission.ts index 6a00e07663..1e7f45129d 100644 --- a/plugins/permission-react/src/hooks/usePermission.ts +++ b/plugins/permission-react/src/hooks/usePermission.ts @@ -32,17 +32,6 @@ export type AsyncPermissionResult = { error?: Error; }; -/** @public */ -export type UsePermissionProps = - | { - permission: Exclude; - resourceRef?: never; - } - | { - permission: ResourcePermission; - resourceRef: string | undefined; - }; - /** * React hook utility for authorization. Given either a non-resource * {@link @backstage/plugin-permission-common#Permission} or a @@ -62,10 +51,18 @@ export type UsePermissionProps = * @public */ export function usePermission( - props: UsePermissionProps, + input: + | { + permission: Exclude; + resourceRef?: never; + } + | { + permission: ResourcePermission; + resourceRef: string | undefined; + }, ): AsyncPermissionResult { const permissionApi = useApi(permissionApiRef); - const { data, error } = useSWR(props, async (args: UsePermissionProps) => { + const { data, error } = useSWR(input, async (args: typeof input) => { // We could make the resourceRef parameter required to avoid this check, but // it would make using this hook difficult in situations where the entity // must be asynchronously loaded, so instead we short-circuit to a deny when