@commercetools-frontend/permissions
Version:
React components to declaratively handle MC permissions
42 lines (41 loc) • 1.43 kB
TypeScript
import { ReactNode, ComponentType } 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 TRenderProp = (props: {
isAuthorized: boolean;
}) => ReactNode;
type Props = {
shouldMatchSomePermissions?: boolean;
permissions: TPermissionName[];
actionRights?: TDemandedActionRight[];
dataFences?: TDemandedDataFence[];
selectDataFenceData?: TSelectDataFenceData;
unauthorizedComponent?: ComponentType;
projectPermissions?: TProjectPermissions;
render?: TRenderProp;
children?: TRenderProp | ReactNode;
};
declare const RestrictedByPermissions: {
(props: Props): import("@emotion/react/jsx-runtime").JSX.Element;
displayName: string;
};
export default RestrictedByPermissions;