UNPKG

@commercetools-frontend/permissions

Version:
50 lines (49 loc) 1.97 kB
import { ComponentType, ReactNode } from 'react'; import type { TNormalizedPermissions, TNormalizedActionRights, TNormalizedDataFences } from '@commercetools-frontend/application-shell-connectors'; type TPermissionName = string; type TActionRightName = string; type TActionRightGroup = string; type TDemandedActionRight = { group: TActionRightGroup; name: TActionRightName; }; type TDemandedDataFence = { group: string; name: string; type: string; }; type TSelectDataFenceData = (demandedDataFenceWithActualValues: TDemandedDataFence & { actualDataFenceValues: string[]; }) => string[] | null; type TProjectPermissions = { permissions: TNormalizedPermissions | null; actionRights: TNormalizedActionRights | null; dataFences: TNormalizedDataFences | null; }; type Props = { demandedPermissions: TPermissionName[]; demandedActionRights?: TDemandedActionRight[]; demandedDataFences?: TDemandedDataFence[]; shouldMatchSomePermissions?: boolean; selectDataFenceData?: TSelectDataFenceData; projectPermissions?: TProjectPermissions; render: (isAuthorized: boolean) => ReactNode; children?: never; }; declare const Authorized: { ({ shouldMatchSomePermissions, ...props }: Props): import("@emotion/react/jsx-runtime").JSX.Element; displayName: string; }; type TInjectAuthorizedOptions<OwnProps extends {}> = { shouldMatchSomePermissions?: boolean; actionRights?: TDemandedActionRight[]; dataFences?: TDemandedDataFence[]; getSelectDataFenceData?: (ownProps: OwnProps) => TSelectDataFenceData; }; declare const injectAuthorized: <OwnProps extends { isAuthorized?: boolean; }, InjectedProps extends OwnProps & { [key: string]: boolean; }>(demandedPermissions: TPermissionName[], options?: TInjectAuthorizedOptions<OwnProps>, propName?: string) => (Component: ComponentType<OwnProps>) => ComponentType<OwnProps & InjectedProps>; export default Authorized; export { injectAuthorized };