import * as React from "react"; import { EntityOperationType, EntityAttrPermissionValue } from "@cuba-platform/rest"; export interface AccessControlProps { /** * Requirements that shall be fulfilled in order for access-controlled components to be rendered. * If missing - access-controlled components will always be rendered. */ displayReqs?: AccessControlRequirements; /** * Requirements that shall be fulfilled in order for rendered access-controlled components to be modifiable * (i.e. to not be disabled). * If missing - access-controlled components will never be disabled. */ modifyReqs?: AccessControlRequirements; /** * The name of the prop that will be passed to `children` if {@link modifyReqs} * are not fulfilled. Defaults to `disabled`. */ disabledPropName?: string; /** * The value of the prop that will be passed to `children` if {@link modifyReqs} * are not fulfilled. Defaults to `true`. */ disabledPropValue?: any; /** * Render prop. If not provided, component's `children` will be used instead. * * @param disabled indicates whether the access-controlled components shall be disabled. */ render?: (disabled: boolean) => React.ReactNode; } export interface AccessControlRequirements { /** * Required entity operation permissions. */ entityReqs?: EntityPermissionRequirement[]; /** * Required entity attribute permissions. */ attrReqs?: AttributePermissionRequirement[]; /** * Required specific permissions. */ specificReqs?: string[]; /** * A function that can be used to implement custom conditions / complex logic. */ customReqs?: () => boolean; } export interface EntityPermissionRequirement { entityName: string; /** * Required operation permission. Defaults to `read`. */ operation?: EntityOperationType; } export interface AttributePermissionRequirement { entityName: string; attrName: string; /** * Required attribute permission. */ requiredAttrPerm: Exclude; } /** * This component can be used to conditionally render other components (which we call access-controlled components) * based on user permissions and other conditions. * * This component is intended to be used in complex cases (such as when requirements includes multiple types of permissions, * e.g. an entity permission and a specific permission). * In most cases simpler components should be used instead: * {@link EntityPermAccessControl} when condition involves a single entity CRUD permission, * {@link AttrPermAccessControl} when condition involves a single entity attribute permission * and {@link SpecificPermAccessControl} when condition involves one or more specific permissions. * * @param props */ export declare const AccessControl: (props: React.PropsWithChildren) => JSX.Element | null;