@strapi/admin 5.52.0 → 5.52.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -149,15 +149,16 @@ const PageMain = ({ children, ...restProps })=>{
149
149
  /**
150
150
  * @public
151
151
  * @description A wrapper component that should be used to protect a page. It will check the permissions
152
- * you pass to it and render the children if the user has the required permissions. If a user does not have ALL
153
- * the required permissions, it will redirect the user to the home page. Whilst these checks happen it will render
154
- * the loading component and should the check fail it will render the error component with a notification.
152
+ * you pass to it and render the children if any of the user's matching permissions grants access. If none do,
153
+ * it renders the NoPermissions component. Whilst these checks happen it will render the loading component
154
+ * and should the check fail it will render the error component with a notification.
155
155
  */ const Protect = ({ permissions = [], children })=>{
156
156
  const userPermissions = Auth.useAuth('Protect', (state)=>state.permissions);
157
157
  const { toggleNotification } = Notifications.useNotification();
158
158
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler.useAPIErrorHandler();
159
159
  const matchingPermissions = (userPermissions || []).filter((permission)=>permissions.findIndex((perm)=>perm.action === permission.action && perm.subject === permission.subject) >= 0);
160
- const shouldCheckConditions = matchingPermissions.some((perm)=>Array.isArray(perm.conditions) && perm.conditions.length > 0);
160
+ const hasConditions = (permission)=>Array.isArray(permission.conditions) && permission.conditions.length > 0;
161
+ const shouldCheckConditions = matchingPermissions.some(hasConditions);
161
162
  const { isLoading, error, data } = auth.useCheckPermissionsQuery({
162
163
  permissions: matchingPermissions.map((perm)=>({
163
164
  action: perm.action,
@@ -185,7 +186,8 @@ const PageMain = ({ children, ...restProps })=>{
185
186
  return /*#__PURE__*/ jsxRuntime.jsx(Error, {});
186
187
  }
187
188
  const { data: permissionsData } = data || {};
188
- const canAccess = shouldCheckConditions && permissionsData ? !permissionsData.includes(false) : matchingPermissions.length > 0;
189
+ const hasUnconditionedPermission = matchingPermissions.some((permission)=>!hasConditions(permission));
190
+ const canAccess = hasUnconditionedPermission || (permissionsData ?? []).some((perm)=>perm === true);
189
191
  if (!canAccess) {
190
192
  return /*#__PURE__*/ jsxRuntime.jsx(NoPermissions, {});
191
193
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PageHelpers.js","sources":["../../../../../admin/src/components/PageHelpers.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Box,\n EmptyStateLayout,\n type EmptyStateLayoutProps,\n Flex,\n Loader,\n Main,\n MainProps,\n} from '@strapi/design-system';\nimport { WarningCircle } from '@strapi/icons';\nimport { EmptyPermissions, EmptyDocuments } from '@strapi/icons/symbols';\nimport { useIntl } from 'react-intl';\n\nimport { useAuth, Permission } from '../features/Auth';\nimport { useNotification } from '../features/Notifications';\nimport { useAPIErrorHandler } from '../hooks/useAPIErrorHandler';\nimport { useCheckPermissionsQuery } from '../services/auth';\n\n/* -------------------------------------------------------------------------------------------------\n * Main\n * -----------------------------------------------------------------------------------------------*/\ninterface PageMainProps extends MainProps {\n children: React.ReactNode;\n}\n\nconst PageMain = ({ children, ...restProps }: PageMainProps) => {\n return <Main {...restProps}>{children}</Main>;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Loading\n * -----------------------------------------------------------------------------------------------*/\ninterface LoadingProps {\n /**\n * @default 'Loading content.'\n */\n children?: React.ReactNode;\n}\n\n/**\n * @public\n * @description A loading component that should be rendered as the page\n * whilst you load the content for the aforementioned page.\n */\nconst Loading = ({ children = 'Loading content.' }: LoadingProps) => {\n return (\n <PageMain height=\"100dvh\" aria-busy={true}>\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\">\n <Loader>{children}</Loader>\n </Flex>\n </PageMain>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Error\n * -----------------------------------------------------------------------------------------------*/\ninterface ErrorProps extends Partial<EmptyStateLayoutProps> {}\n\n/**\n * TODO: should we start passing our errors here so they're persisted on the screen?\n * This could follow something similar to how the global app error works...?\n */\n\n/**\n * @public\n * @description An error component that should be rendered as the page\n * when an error occurs.\n */\nconst Error = (props: ErrorProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <PageMain height=\"100%\">\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\">\n <EmptyStateLayout\n icon={<WarningCircle width=\"16rem\" />}\n content={formatMessage({\n id: 'anErrorOccurred',\n defaultMessage: 'Whoops! Something went wrong. Please, try again.',\n })}\n {...props}\n />\n </Flex>\n </PageMain>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * NoPermissions\n * -----------------------------------------------------------------------------------------------*/\ninterface NoPermissionsProps extends Partial<EmptyStateLayoutProps> {}\n\n/**\n * @public\n * @description A component that should be rendered as the page\n * when the user does not have the permissions to access the content.\n * This component does not check any permissions, it's up to you to decide\n * when it should be rendered.\n */\nconst NoPermissions = (props: NoPermissionsProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <PageMain height=\"100%\">\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\">\n <Box minWidth=\"50%\">\n <EmptyStateLayout\n icon={<EmptyPermissions width=\"16rem\" />}\n content={formatMessage({\n id: 'app.components.EmptyStateLayout.content-permissions',\n defaultMessage: \"You don't have the permissions to access that content\",\n })}\n {...props}\n />\n </Box>\n </Flex>\n </PageMain>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * NoData\n * -----------------------------------------------------------------------------------------------*/\ninterface NoDataProps extends Partial<EmptyStateLayoutProps> {}\n\n/**\n * @public\n * @description A component that should be rendered as the page\n * when there is no data available to display.\n * This component does not check any permissions, it's up to you to decide\n * when it should be rendered.\n */\nconst NoData = (props: NoDataProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <PageMain height=\"100%\" background=\"neutral100\">\n <Flex alignItems=\"center\" height=\"100%\" width=\"100%\" justifyContent=\"center\">\n <Box minWidth=\"50%\">\n <EmptyStateLayout\n icon={<EmptyDocuments width=\"16rem\" />}\n action={props.action}\n content={formatMessage({\n id: 'app.components.EmptyStateLayout.content-document',\n defaultMessage: 'No content found',\n })}\n {...props}\n />\n </Box>\n </Flex>\n </PageMain>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Protect\n * -----------------------------------------------------------------------------------------------*/\nexport interface ProtectProps {\n /**\n * The children to render if the user has the required permissions.\n * If providing a function, it will be called with an object containing\n * the permissions the user has based on the array you passed to the component.\n */\n children: React.ReactNode | ((args: { permissions: Permission[] }) => React.ReactNode);\n /**\n * The permissions the user needs to have to access the content.\n */\n permissions?: Array<Omit<Partial<Permission>, 'action'> & Pick<Permission, 'action'>>;\n}\n\n/**\n * @public\n * @description A wrapper component that should be used to protect a page. It will check the permissions\n * you pass to it and render the children if the user has the required permissions. If a user does not have ALL\n * the required permissions, it will redirect the user to the home page. Whilst these checks happen it will render\n * the loading component and should the check fail it will render the error component with a notification.\n */\nconst Protect = ({ permissions = [], children }: ProtectProps) => {\n const userPermissions = useAuth('Protect', (state) => state.permissions);\n const { toggleNotification } = useNotification();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n\n const matchingPermissions = (userPermissions || []).filter(\n (permission) =>\n permissions.findIndex(\n (perm) => perm.action === permission.action && perm.subject === permission.subject\n ) >= 0\n );\n\n const shouldCheckConditions = matchingPermissions.some(\n (perm) => Array.isArray(perm.conditions) && perm.conditions.length > 0\n );\n\n const { isLoading, error, data } = useCheckPermissionsQuery(\n {\n permissions: matchingPermissions.map((perm) => ({\n action: perm.action,\n subject: perm.subject,\n })),\n },\n {\n skip: !shouldCheckConditions,\n }\n );\n\n React.useEffect(() => {\n if (error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(error),\n });\n }\n }, [error, formatAPIError, toggleNotification]);\n\n if (isLoading) {\n return <Loading />;\n }\n\n if (error) {\n return <Error />;\n }\n\n const { data: permissionsData } = data || {};\n\n const canAccess =\n shouldCheckConditions && permissionsData\n ? !permissionsData.includes(false)\n : matchingPermissions.length > 0;\n\n if (!canAccess) {\n return <NoPermissions />;\n }\n\n return (\n <>\n {typeof children === 'function' ? children({ permissions: matchingPermissions }) : children}\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Title\n * -----------------------------------------------------------------------------------------------*/\nexport interface TitleProps {\n children: string;\n}\n\n/**\n * @public\n * @description This component takes the children (must be a string) and sets\n * it as the title of the html.\n */\nconst Title = ({ children: title }: TitleProps) => {\n React.useEffect(() => {\n document.title = `${title} | Strapi`;\n }, [title]);\n\n return null;\n};\n\nconst Page = {\n Error,\n Loading,\n NoPermissions,\n Protect,\n NoData,\n Main: PageMain,\n Title,\n};\n\nexport { Page };\nexport type { ErrorProps, LoadingProps, NoPermissionsProps, PageMainProps as MainProps };\n"],"names":["PageMain","children","restProps","_jsx","Main","Loading","height","aria-busy","Flex","alignItems","justifyContent","Loader","Error","props","formatMessage","useIntl","EmptyStateLayout","icon","WarningCircle","width","content","id","defaultMessage","NoPermissions","Box","minWidth","EmptyPermissions","NoData","background","EmptyDocuments","action","Protect","permissions","userPermissions","useAuth","state","toggleNotification","useNotification","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","matchingPermissions","filter","permission","findIndex","perm","subject","shouldCheckConditions","some","Array","isArray","conditions","length","isLoading","error","data","useCheckPermissionsQuery","map","skip","React","useEffect","type","message","permissionsData","canAccess","includes","_Fragment","Title","title","document","Page"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAMA,WAAW,CAAC,EAAEC,QAAQ,EAAE,GAAGC,SAAAA,EAA0B,GAAA;AACzD,IAAA,qBAAOC,cAAA,CAACC,iBAAAA,EAAAA;AAAM,QAAA,GAAGF,SAAS;AAAGD,QAAAA,QAAAA,EAAAA;;AAC/B,CAAA;AAYA;;;;AAIC,IACD,MAAMI,OAAAA,GAAU,CAAC,EAAEJ,QAAAA,GAAW,kBAAkB,EAAgB,GAAA;AAC9D,IAAA,qBACEE,cAAA,CAACH,QAAAA,EAAAA;QAASM,MAAAA,EAAO,QAAA;QAASC,WAAAA,EAAW,IAAA;AACnC,QAAA,QAAA,gBAAAJ,cAAA,CAACK,iBAAAA,EAAAA;YAAKC,U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EAAAA,CAAAA;AACV,IAAA;AAEA,IAAA,IAAIiD,KAAAA,EAAO;AACT,QAAA,qBAAOnD,cAAA,CAACS,KAAAA,EAAAA,EAAAA,CAAAA;AACV,IAAA;AAEA,IAAA,MAAM,EAAE2C,IAAAA,EAAMQ,eAAe,EAAE,GAAGR,QAAQ,EAAC;IAE3C,MAAMS,SAAAA,GACJjB,qBAAAA,IAAyBgB,eAAAA,GACrB,CAACA,eAAAA,CAAgBE,QAAQ,CAAC,KAAA,CAAA,GAC1BxB,mBAAAA,CAAoBW,MAAM,GAAG,CAAA;AAEnC,IAAA,IAAI,CAACY,SAAAA,EAAW;AACd,QAAA,qBAAO7D,cAAA,CAACoB,aAAAA,EAAAA,EAAAA,CAAAA;AACV,IAAA;IAEA,qBACEpB,cAAA,CAAA+D,mBAAA,EAAA;kBACG,OAAOjE,QAAAA,KAAa,aAAaA,QAAAA,CAAS;YAAE+B,WAAAA,EAAaS;SAAoB,CAAA,GAAKxC;;AAGzF,CAAA;AASA;;;;AAIC,IACD,MAAMkE,KAAAA,GAAQ,CAAC,EAAElE,QAAAA,EAAUmE,KAAK,EAAc,GAAA;AAC5CT,IAAAA,gBAAAA,CAAMC,SAAS,CAAC,IAAA;AACdS,QAAAA,QAAAA,CAASD,KAAK,GAAG,CAAA,EAAGA,KAAAA,CAAM,SAAS,CAAC;IACtC,CAAA,EAAG;AAACA,QAAAA;AAAM,KAAA,CAAA;IAEV,OAAO,IAAA;AACT,CAAA;AAEA,MAAME,IAAAA,GAAO;AACX1D,IAAAA,KAAAA;AACAP,IAAAA,OAAAA;AACAkB,IAAAA,aAAAA;AACAQ,IAAAA,OAAAA;AACAJ,IAAAA,MAAAA;IACAvB,IAAAA,EAAMJ,QAAAA;AACNmE,IAAAA;AACF;;;;"}
1
+ {"version":3,"file":"PageHelpers.js","sources":["../../../../../admin/src/components/PageHelpers.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Box,\n EmptyStateLayout,\n type EmptyStateLayoutProps,\n Flex,\n Loader,\n Main,\n MainProps,\n} from '@strapi/design-system';\nimport { WarningCircle } from '@strapi/icons';\nimport { EmptyPermissions, EmptyDocuments } from '@strapi/icons/symbols';\nimport { useIntl } from 'react-intl';\n\nimport { useAuth, Permission } from '../features/Auth';\nimport { useNotification } from '../features/Notifications';\nimport { useAPIErrorHandler } from '../hooks/useAPIErrorHandler';\nimport { useCheckPermissionsQuery } from '../services/auth';\n\n/* -------------------------------------------------------------------------------------------------\n * Main\n * -----------------------------------------------------------------------------------------------*/\ninterface PageMainProps extends MainProps {\n children: React.ReactNode;\n}\n\nconst PageMain = ({ children, ...restProps }: PageMainProps) => {\n return <Main {...restProps}>{children}</Main>;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Loading\n * -----------------------------------------------------------------------------------------------*/\ninterface LoadingProps {\n /**\n * @default 'Loading content.'\n */\n children?: React.ReactNode;\n}\n\n/**\n * @public\n * @description A loading component that should be rendered as the page\n * whilst you load the content for the aforementioned page.\n */\nconst Loading = ({ children = 'Loading content.' }: LoadingProps) => {\n return (\n <PageMain height=\"100dvh\" aria-busy={true}>\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\">\n <Loader>{children}</Loader>\n </Flex>\n </PageMain>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Error\n * -----------------------------------------------------------------------------------------------*/\ninterface ErrorProps extends Partial<EmptyStateLayoutProps> {}\n\n/**\n * TODO: should we start passing our errors here so they're persisted on the screen?\n * This could follow something similar to how the global app error works...?\n */\n\n/**\n * @public\n * @description An error component that should be rendered as the page\n * when an error occurs.\n */\nconst Error = (props: ErrorProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <PageMain height=\"100%\">\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\">\n <EmptyStateLayout\n icon={<WarningCircle width=\"16rem\" />}\n content={formatMessage({\n id: 'anErrorOccurred',\n defaultMessage: 'Whoops! Something went wrong. Please, try again.',\n })}\n {...props}\n />\n </Flex>\n </PageMain>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * NoPermissions\n * -----------------------------------------------------------------------------------------------*/\ninterface NoPermissionsProps extends Partial<EmptyStateLayoutProps> {}\n\n/**\n * @public\n * @description A component that should be rendered as the page\n * when the user does not have the permissions to access the content.\n * This component does not check any permissions, it's up to you to decide\n * when it should be rendered.\n */\nconst NoPermissions = (props: NoPermissionsProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <PageMain height=\"100%\">\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\">\n <Box minWidth=\"50%\">\n <EmptyStateLayout\n icon={<EmptyPermissions width=\"16rem\" />}\n content={formatMessage({\n id: 'app.components.EmptyStateLayout.content-permissions',\n defaultMessage: \"You don't have the permissions to access that content\",\n })}\n {...props}\n />\n </Box>\n </Flex>\n </PageMain>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * NoData\n * -----------------------------------------------------------------------------------------------*/\ninterface NoDataProps extends Partial<EmptyStateLayoutProps> {}\n\n/**\n * @public\n * @description A component that should be rendered as the page\n * when there is no data available to display.\n * This component does not check any permissions, it's up to you to decide\n * when it should be rendered.\n */\nconst NoData = (props: NoDataProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <PageMain height=\"100%\" background=\"neutral100\">\n <Flex alignItems=\"center\" height=\"100%\" width=\"100%\" justifyContent=\"center\">\n <Box minWidth=\"50%\">\n <EmptyStateLayout\n icon={<EmptyDocuments width=\"16rem\" />}\n action={props.action}\n content={formatMessage({\n id: 'app.components.EmptyStateLayout.content-document',\n defaultMessage: 'No content found',\n })}\n {...props}\n />\n </Box>\n </Flex>\n </PageMain>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Protect\n * -----------------------------------------------------------------------------------------------*/\nexport interface ProtectProps {\n /**\n * The children to render if the user has the required permissions.\n * If providing a function, it will be called with an object containing\n * the permissions the user has based on the array you passed to the component.\n */\n children: React.ReactNode | ((args: { permissions: Permission[] }) => React.ReactNode);\n /**\n * The permissions the user needs to have to access the content.\n */\n permissions?: Array<Omit<Partial<Permission>, 'action'> & Pick<Permission, 'action'>>;\n}\n\n/**\n * @public\n * @description A wrapper component that should be used to protect a page. It will check the permissions\n * you pass to it and render the children if any of the user's matching permissions grants access. If none do,\n * it renders the NoPermissions component. Whilst these checks happen it will render the loading component\n * and should the check fail it will render the error component with a notification.\n */\nconst Protect = ({ permissions = [], children }: ProtectProps) => {\n const userPermissions = useAuth('Protect', (state) => state.permissions);\n const { toggleNotification } = useNotification();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n\n const matchingPermissions = (userPermissions || []).filter(\n (permission) =>\n permissions.findIndex(\n (perm) => perm.action === permission.action && perm.subject === permission.subject\n ) >= 0\n );\n\n const hasConditions = (permission: Permission) =>\n Array.isArray(permission.conditions) && permission.conditions.length > 0;\n\n const shouldCheckConditions = matchingPermissions.some(hasConditions);\n\n const { isLoading, error, data } = useCheckPermissionsQuery(\n {\n permissions: matchingPermissions.map((perm) => ({\n action: perm.action,\n subject: perm.subject,\n })),\n },\n {\n skip: !shouldCheckConditions,\n }\n );\n\n React.useEffect(() => {\n if (error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(error),\n });\n }\n }, [error, formatAPIError, toggleNotification]);\n\n if (isLoading) {\n return <Loading />;\n }\n\n if (error) {\n return <Error />;\n }\n\n const { data: permissionsData } = data || {};\n\n const hasUnconditionedPermission = matchingPermissions.some(\n (permission) => !hasConditions(permission)\n );\n\n const canAccess =\n hasUnconditionedPermission || (permissionsData ?? []).some((perm) => perm === true);\n\n if (!canAccess) {\n return <NoPermissions />;\n }\n\n return (\n <>\n {typeof children === 'function' ? children({ permissions: matchingPermissions }) : children}\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Title\n * -----------------------------------------------------------------------------------------------*/\nexport interface TitleProps {\n children: string;\n}\n\n/**\n * @public\n * @description This component takes the children (must be a string) and sets\n * it as the title of the html.\n */\nconst Title = ({ children: title }: TitleProps) => {\n React.useEffect(() => {\n document.title = `${title} | Strapi`;\n }, [title]);\n\n return null;\n};\n\nconst Page = {\n Error,\n Loading,\n NoPermissions,\n Protect,\n NoData,\n Main: PageMain,\n Title,\n};\n\nexport { Page };\nexport type { ErrorProps, LoadingProps, NoPermissionsProps, PageMainProps as MainProps };\n"],"names":["PageMain","children","restProps","_jsx","Main","Loading","height","aria-busy","Flex","alignItems","justifyContent","Loader","Error","props","formatMessage","useIntl","EmptyStateLayout","icon","WarningCircle","width","content","id","defaultMessage","NoPermissions","Box","minWidth","EmptyPermissions","NoData","background","EmptyDocuments","action","Protect","permissions","userPermissions","useAuth","state","toggleNotification","useNotification","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","matchingPermissions","filter","permission","findIndex","perm","subject","hasConditions","Array","isArray","conditions","length","shouldCheckConditions","some","isLoading","error","data","useCheckPermissionsQuery","map","skip","React","useEffect","type","message","permissionsData","hasUnconditionedPermission","canAccess","_Fragment","Title","title","document","Page"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAMA,WAAW,CAAC,EAAEC,QAAQ,EAAE,GAAGC,SAAAA,EAA0B,GAAA;AACzD,IAAA,qBAAOC,cAAA,CAACC,iBAAAA,EAAAA;AAAM,QAAA,GAAGF,SAAS;AAAGD,QAAAA,QAAAA,EAAAA;;AAC/B,CAAA;AAYA;;;;AAIC,IACD,MAAMI,OAAAA,GAAU,CAAC,EAAEJ,QAAAA,GAAW,kBAAkB,EAAgB,GAAA;AAC9D,IAAA,qBACEE,cAAA,CAACH,QAAAA,EAAAA;QAASM,MAAAA,EAAO,QAAA;QAASC,WAAAA,EAAW,IAAA;AACnC,QAAA,QAAA,gBAAAJ,cAAA,CAACK,iBAAAA,EAAAA;YAAKC,UAAAA,EAAW,QAAA;YAASH,MAAAA,EAAO,MAAA;YAAOI,cAAAA,EAAe,QAAA;AACrD,YAAA,QAAA,gBAAAP,cAAA,CAACQ,mBAAAA,EAAAA;AAAQV,gBAAAA,Q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A,CAACS,KAAAA,EAAAA,EAAAA,CAAAA;AACV,IAAA;AAEA,IAAA,MAAM,EAAE4C,IAAAA,EAAMQ,eAAe,EAAE,GAAGR,QAAQ,EAAC;AAE3C,IAAA,MAAMS,6BAA6BxB,mBAAAA,CAAoBY,IAAI,CACzD,CAACV,UAAAA,GAAe,CAACI,aAAAA,CAAcJ,UAAAA,CAAAA,CAAAA;AAGjC,IAAA,MAAMuB,SAAAA,GACJD,0BAAAA,IAA8B,CAACD,eAAAA,IAAmB,EAAE,EAAEX,IAAI,CAAC,CAACR,IAAAA,GAASA,IAAAA,KAAS,IAAA,CAAA;AAEhF,IAAA,IAAI,CAACqB,SAAAA,EAAW;AACd,QAAA,qBAAO/D,cAAA,CAACoB,aAAAA,EAAAA,EAAAA,CAAAA;AACV,IAAA;IAEA,qBACEpB,cAAA,CAAAgE,mBAAA,EAAA;kBACG,OAAOlE,QAAAA,KAAa,aAAaA,QAAAA,CAAS;YAAE+B,WAAAA,EAAaS;SAAoB,CAAA,GAAKxC;;AAGzF,CAAA;AASA;;;;AAIC,IACD,MAAMmE,KAAAA,GAAQ,CAAC,EAAEnE,QAAAA,EAAUoE,KAAK,EAAc,GAAA;AAC5CT,IAAAA,gBAAAA,CAAMC,SAAS,CAAC,IAAA;AACdS,QAAAA,QAAAA,CAASD,KAAK,GAAG,CAAA,EAAGA,KAAAA,CAAM,SAAS,CAAC;IACtC,CAAA,EAAG;AAACA,QAAAA;AAAM,KAAA,CAAA;IAEV,OAAO,IAAA;AACT,CAAA;AAEA,MAAME,IAAAA,GAAO;AACX3D,IAAAA,KAAAA;AACAP,IAAAA,OAAAA;AACAkB,IAAAA,aAAAA;AACAQ,IAAAA,OAAAA;AACAJ,IAAAA,MAAAA;IACAvB,IAAAA,EAAMJ,QAAAA;AACNoE,IAAAA;AACF;;;;"}
@@ -127,15 +127,16 @@ const PageMain = ({ children, ...restProps })=>{
127
127
  /**
128
128
  * @public
129
129
  * @description A wrapper component that should be used to protect a page. It will check the permissions
130
- * you pass to it and render the children if the user has the required permissions. If a user does not have ALL
131
- * the required permissions, it will redirect the user to the home page. Whilst these checks happen it will render
132
- * the loading component and should the check fail it will render the error component with a notification.
130
+ * you pass to it and render the children if any of the user's matching permissions grants access. If none do,
131
+ * it renders the NoPermissions component. Whilst these checks happen it will render the loading component
132
+ * and should the check fail it will render the error component with a notification.
133
133
  */ const Protect = ({ permissions = [], children })=>{
134
134
  const userPermissions = useAuth('Protect', (state)=>state.permissions);
135
135
  const { toggleNotification } = useNotification();
136
136
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
137
137
  const matchingPermissions = (userPermissions || []).filter((permission)=>permissions.findIndex((perm)=>perm.action === permission.action && perm.subject === permission.subject) >= 0);
138
- const shouldCheckConditions = matchingPermissions.some((perm)=>Array.isArray(perm.conditions) && perm.conditions.length > 0);
138
+ const hasConditions = (permission)=>Array.isArray(permission.conditions) && permission.conditions.length > 0;
139
+ const shouldCheckConditions = matchingPermissions.some(hasConditions);
139
140
  const { isLoading, error, data } = useCheckPermissionsQuery({
140
141
  permissions: matchingPermissions.map((perm)=>({
141
142
  action: perm.action,
@@ -163,7 +164,8 @@ const PageMain = ({ children, ...restProps })=>{
163
164
  return /*#__PURE__*/ jsx(Error, {});
164
165
  }
165
166
  const { data: permissionsData } = data || {};
166
- const canAccess = shouldCheckConditions && permissionsData ? !permissionsData.includes(false) : matchingPermissions.length > 0;
167
+ const hasUnconditionedPermission = matchingPermissions.some((permission)=>!hasConditions(permission));
168
+ const canAccess = hasUnconditionedPermission || (permissionsData ?? []).some((perm)=>perm === true);
167
169
  if (!canAccess) {
168
170
  return /*#__PURE__*/ jsx(NoPermissions, {});
169
171
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PageHelpers.mjs","sources":["../../../../../admin/src/components/PageHelpers.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Box,\n EmptyStateLayout,\n type EmptyStateLayoutProps,\n Flex,\n Loader,\n Main,\n MainProps,\n} from '@strapi/design-system';\nimport { WarningCircle } from '@strapi/icons';\nimport { EmptyPermissions, EmptyDocuments } from '@strapi/icons/symbols';\nimport { useIntl } from 'react-intl';\n\nimport { useAuth, Permission } from '../features/Auth';\nimport { useNotification } from '../features/Notifications';\nimport { useAPIErrorHandler } from '../hooks/useAPIErrorHandler';\nimport { useCheckPermissionsQuery } from '../services/auth';\n\n/* -------------------------------------------------------------------------------------------------\n * Main\n * -----------------------------------------------------------------------------------------------*/\ninterface PageMainProps extends MainProps {\n children: React.ReactNode;\n}\n\nconst PageMain = ({ children, ...restProps }: PageMainProps) => {\n return <Main {...restProps}>{children}</Main>;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Loading\n * -----------------------------------------------------------------------------------------------*/\ninterface LoadingProps {\n /**\n * @default 'Loading content.'\n */\n children?: React.ReactNode;\n}\n\n/**\n * @public\n * @description A loading component that should be rendered as the page\n * whilst you load the content for the aforementioned page.\n */\nconst Loading = ({ children = 'Loading content.' }: LoadingProps) => {\n return (\n <PageMain height=\"100dvh\" aria-busy={true}>\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\">\n <Loader>{children}</Loader>\n </Flex>\n </PageMain>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Error\n * -----------------------------------------------------------------------------------------------*/\ninterface ErrorProps extends Partial<EmptyStateLayoutProps> {}\n\n/**\n * TODO: should we start passing our errors here so they're persisted on the screen?\n * This could follow something similar to how the global app error works...?\n */\n\n/**\n * @public\n * @description An error component that should be rendered as the page\n * when an error occurs.\n */\nconst Error = (props: ErrorProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <PageMain height=\"100%\">\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\">\n <EmptyStateLayout\n icon={<WarningCircle width=\"16rem\" />}\n content={formatMessage({\n id: 'anErrorOccurred',\n defaultMessage: 'Whoops! Something went wrong. Please, try again.',\n })}\n {...props}\n />\n </Flex>\n </PageMain>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * NoPermissions\n * -----------------------------------------------------------------------------------------------*/\ninterface NoPermissionsProps extends Partial<EmptyStateLayoutProps> {}\n\n/**\n * @public\n * @description A component that should be rendered as the page\n * when the user does not have the permissions to access the content.\n * This component does not check any permissions, it's up to you to decide\n * when it should be rendered.\n */\nconst NoPermissions = (props: NoPermissionsProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <PageMain height=\"100%\">\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\">\n <Box minWidth=\"50%\">\n <EmptyStateLayout\n icon={<EmptyPermissions width=\"16rem\" />}\n content={formatMessage({\n id: 'app.components.EmptyStateLayout.content-permissions',\n defaultMessage: \"You don't have the permissions to access that content\",\n })}\n {...props}\n />\n </Box>\n </Flex>\n </PageMain>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * NoData\n * -----------------------------------------------------------------------------------------------*/\ninterface NoDataProps extends Partial<EmptyStateLayoutProps> {}\n\n/**\n * @public\n * @description A component that should be rendered as the page\n * when there is no data available to display.\n * This component does not check any permissions, it's up to you to decide\n * when it should be rendered.\n */\nconst NoData = (props: NoDataProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <PageMain height=\"100%\" background=\"neutral100\">\n <Flex alignItems=\"center\" height=\"100%\" width=\"100%\" justifyContent=\"center\">\n <Box minWidth=\"50%\">\n <EmptyStateLayout\n icon={<EmptyDocuments width=\"16rem\" />}\n action={props.action}\n content={formatMessage({\n id: 'app.components.EmptyStateLayout.content-document',\n defaultMessage: 'No content found',\n })}\n {...props}\n />\n </Box>\n </Flex>\n </PageMain>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Protect\n * -----------------------------------------------------------------------------------------------*/\nexport interface ProtectProps {\n /**\n * The children to render if the user has the required permissions.\n * If providing a function, it will be called with an object containing\n * the permissions the user has based on the array you passed to the component.\n */\n children: React.ReactNode | ((args: { permissions: Permission[] }) => React.ReactNode);\n /**\n * The permissions the user needs to have to access the content.\n */\n permissions?: Array<Omit<Partial<Permission>, 'action'> & Pick<Permission, 'action'>>;\n}\n\n/**\n * @public\n * @description A wrapper component that should be used to protect a page. It will check the permissions\n * you pass to it and render the children if the user has the required permissions. If a user does not have ALL\n * the required permissions, it will redirect the user to the home page. Whilst these checks happen it will render\n * the loading component and should the check fail it will render the error component with a notification.\n */\nconst Protect = ({ permissions = [], children }: ProtectProps) => {\n const userPermissions = useAuth('Protect', (state) => state.permissions);\n const { toggleNotification } = useNotification();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n\n const matchingPermissions = (userPermissions || []).filter(\n (permission) =>\n permissions.findIndex(\n (perm) => perm.action === permission.action && perm.subject === permission.subject\n ) >= 0\n );\n\n const shouldCheckConditions = matchingPermissions.some(\n (perm) => Array.isArray(perm.conditions) && perm.conditions.length > 0\n );\n\n const { isLoading, error, data } = useCheckPermissionsQuery(\n {\n permissions: matchingPermissions.map((perm) => ({\n action: perm.action,\n subject: perm.subject,\n })),\n },\n {\n skip: !shouldCheckConditions,\n }\n );\n\n React.useEffect(() => {\n if (error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(error),\n });\n }\n }, [error, formatAPIError, toggleNotification]);\n\n if (isLoading) {\n return <Loading />;\n }\n\n if (error) {\n return <Error />;\n }\n\n const { data: permissionsData } = data || {};\n\n const canAccess =\n shouldCheckConditions && permissionsData\n ? !permissionsData.includes(false)\n : matchingPermissions.length > 0;\n\n if (!canAccess) {\n return <NoPermissions />;\n }\n\n return (\n <>\n {typeof children === 'function' ? children({ permissions: matchingPermissions }) : children}\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Title\n * -----------------------------------------------------------------------------------------------*/\nexport interface TitleProps {\n children: string;\n}\n\n/**\n * @public\n * @description This component takes the children (must be a string) and sets\n * it as the title of the html.\n */\nconst Title = ({ children: title }: TitleProps) => {\n React.useEffect(() => {\n document.title = `${title} | Strapi`;\n }, [title]);\n\n return null;\n};\n\nconst Page = {\n Error,\n Loading,\n NoPermissions,\n Protect,\n NoData,\n Main: PageMain,\n Title,\n};\n\nexport { Page };\nexport type { ErrorProps, LoadingProps, NoPermissionsProps, PageMainProps as MainProps };\n"],"names":["PageMain","children","restProps","_jsx","Main","Loading","height","aria-busy","Flex","alignItems","justifyContent","Loader","Error","props","formatMessage","useIntl","EmptyStateLayout","icon","WarningCircle","width","content","id","defaultMessage","NoPermissions","Box","minWidth","EmptyPermissions","NoData","background","EmptyDocuments","action","Protect","permissions","userPermissions","useAuth","state","toggleNotification","useNotification","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","matchingPermissions","filter","permission","findIndex","perm","subject","shouldCheckConditions","some","Array","isArray","conditions","length","isLoading","error","data","useCheckPermissionsQuery","map","skip","React","useEffect","type","message","permissionsData","canAccess","includes","_Fragment","Title","title","document","Page"],"mappings":";;;;;;;;;;;AA2BA,MAAMA,WAAW,CAAC,EAAEC,QAAQ,EAAE,GAAGC,SAAAA,EAA0B,GAAA;AACzD,IAAA,qBAAOC,GAAA,CAACC,IAAAA,EAAAA;AAAM,QAAA,GAAGF,SAAS;AAAGD,QAAAA,QAAAA,EAAAA;;AAC/B,CAAA;AAYA;;;;AAIC,IACD,MAAMI,OAAAA,GAAU,CAAC,EAAEJ,QAAAA,GAAW,kBAAkB,EAAgB,GAAA;AAC9D,IAAA,qBACEE,GAAA,CAACH,QAAAA,EAAAA;QAASM,MAAAA,EAAO,QAAA;QAASC,WAAAA,EAAW,IAAA;AACnC,QAAA,QAAA,gBAAAJ,GAAA,CAACK,IAAAA,EAAAA;YAAKC,UAAAA,EAAW,QAAA;YAASH,MAAAA,EAAO,MAAA;YAAOI,cAAAA,EAAe,QAAA;AACrD,YAAA,QAAA,gBAAAP,GAAA,CAACQ,MAAAA,EAAAA;AAAQV,gBAAAA,QAAAA,EAAAA;;;;AAIjB,CAAA;AAOA;;;;;;;IAUA,MAAMW,QAAQ,CAACC,KAAAA,GAAAA;IACb,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAE1B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C,KAAA,CAAA,GAC1BxB,mBAAAA,CAAoBW,MAAM,GAAG,CAAA;AAEnC,IAAA,IAAI,CAACY,SAAAA,EAAW;AACd,QAAA,qBAAO7D,GAAA,CAACoB,aAAAA,EAAAA,EAAAA,CAAAA;AACV,IAAA;IAEA,qBACEpB,GAAA,CAAA+D,QAAA,EAAA;kBACG,OAAOjE,QAAAA,KAAa,aAAaA,QAAAA,CAAS;YAAE+B,WAAAA,EAAaS;SAAoB,CAAA,GAAKxC;;AAGzF,CAAA;AASA;;;;AAIC,IACD,MAAMkE,KAAAA,GAAQ,CAAC,EAAElE,QAAAA,EAAUmE,KAAK,EAAc,GAAA;AAC5CT,IAAAA,KAAAA,CAAMC,SAAS,CAAC,IAAA;AACdS,QAAAA,QAAAA,CAASD,KAAK,GAAG,CAAA,EAAGA,KAAAA,CAAM,SAAS,CAAC;IACtC,CAAA,EAAG;AAACA,QAAAA;AAAM,KAAA,CAAA;IAEV,OAAO,IAAA;AACT,CAAA;AAEA,MAAME,IAAAA,GAAO;AACX1D,IAAAA,KAAAA;AACAP,IAAAA,OAAAA;AACAkB,IAAAA,aAAAA;AACAQ,IAAAA,OAAAA;AACAJ,IAAAA,MAAAA;IACAvB,IAAAA,EAAMJ,QAAAA;AACNmE,IAAAA;AACF;;;;"}
1
+ {"version":3,"file":"PageHelpers.mjs","sources":["../../../../../admin/src/components/PageHelpers.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Box,\n EmptyStateLayout,\n type EmptyStateLayoutProps,\n Flex,\n Loader,\n Main,\n MainProps,\n} from '@strapi/design-system';\nimport { WarningCircle } from '@strapi/icons';\nimport { EmptyPermissions, EmptyDocuments } from '@strapi/icons/symbols';\nimport { useIntl } from 'react-intl';\n\nimport { useAuth, Permission } from '../features/Auth';\nimport { useNotification } from '../features/Notifications';\nimport { useAPIErrorHandler } from '../hooks/useAPIErrorHandler';\nimport { useCheckPermissionsQuery } from '../services/auth';\n\n/* -------------------------------------------------------------------------------------------------\n * Main\n * -----------------------------------------------------------------------------------------------*/\ninterface PageMainProps extends MainProps {\n children: React.ReactNode;\n}\n\nconst PageMain = ({ children, ...restProps }: PageMainProps) => {\n return <Main {...restProps}>{children}</Main>;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Loading\n * -----------------------------------------------------------------------------------------------*/\ninterface LoadingProps {\n /**\n * @default 'Loading content.'\n */\n children?: React.ReactNode;\n}\n\n/**\n * @public\n * @description A loading component that should be rendered as the page\n * whilst you load the content for the aforementioned page.\n */\nconst Loading = ({ children = 'Loading content.' }: LoadingProps) => {\n return (\n <PageMain height=\"100dvh\" aria-busy={true}>\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\">\n <Loader>{children}</Loader>\n </Flex>\n </PageMain>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Error\n * -----------------------------------------------------------------------------------------------*/\ninterface ErrorProps extends Partial<EmptyStateLayoutProps> {}\n\n/**\n * TODO: should we start passing our errors here so they're persisted on the screen?\n * This could follow something similar to how the global app error works...?\n */\n\n/**\n * @public\n * @description An error component that should be rendered as the page\n * when an error occurs.\n */\nconst Error = (props: ErrorProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <PageMain height=\"100%\">\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\">\n <EmptyStateLayout\n icon={<WarningCircle width=\"16rem\" />}\n content={formatMessage({\n id: 'anErrorOccurred',\n defaultMessage: 'Whoops! Something went wrong. Please, try again.',\n })}\n {...props}\n />\n </Flex>\n </PageMain>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * NoPermissions\n * -----------------------------------------------------------------------------------------------*/\ninterface NoPermissionsProps extends Partial<EmptyStateLayoutProps> {}\n\n/**\n * @public\n * @description A component that should be rendered as the page\n * when the user does not have the permissions to access the content.\n * This component does not check any permissions, it's up to you to decide\n * when it should be rendered.\n */\nconst NoPermissions = (props: NoPermissionsProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <PageMain height=\"100%\">\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\">\n <Box minWidth=\"50%\">\n <EmptyStateLayout\n icon={<EmptyPermissions width=\"16rem\" />}\n content={formatMessage({\n id: 'app.components.EmptyStateLayout.content-permissions',\n defaultMessage: \"You don't have the permissions to access that content\",\n })}\n {...props}\n />\n </Box>\n </Flex>\n </PageMain>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * NoData\n * -----------------------------------------------------------------------------------------------*/\ninterface NoDataProps extends Partial<EmptyStateLayoutProps> {}\n\n/**\n * @public\n * @description A component that should be rendered as the page\n * when there is no data available to display.\n * This component does not check any permissions, it's up to you to decide\n * when it should be rendered.\n */\nconst NoData = (props: NoDataProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <PageMain height=\"100%\" background=\"neutral100\">\n <Flex alignItems=\"center\" height=\"100%\" width=\"100%\" justifyContent=\"center\">\n <Box minWidth=\"50%\">\n <EmptyStateLayout\n icon={<EmptyDocuments width=\"16rem\" />}\n action={props.action}\n content={formatMessage({\n id: 'app.components.EmptyStateLayout.content-document',\n defaultMessage: 'No content found',\n })}\n {...props}\n />\n </Box>\n </Flex>\n </PageMain>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Protect\n * -----------------------------------------------------------------------------------------------*/\nexport interface ProtectProps {\n /**\n * The children to render if the user has the required permissions.\n * If providing a function, it will be called with an object containing\n * the permissions the user has based on the array you passed to the component.\n */\n children: React.ReactNode | ((args: { permissions: Permission[] }) => React.ReactNode);\n /**\n * The permissions the user needs to have to access the content.\n */\n permissions?: Array<Omit<Partial<Permission>, 'action'> & Pick<Permission, 'action'>>;\n}\n\n/**\n * @public\n * @description A wrapper component that should be used to protect a page. It will check the permissions\n * you pass to it and render the children if any of the user's matching permissions grants access. If none do,\n * it renders the NoPermissions component. Whilst these checks happen it will render the loading component\n * and should the check fail it will render the error component with a notification.\n */\nconst Protect = ({ permissions = [], children }: ProtectProps) => {\n const userPermissions = useAuth('Protect', (state) => state.permissions);\n const { toggleNotification } = useNotification();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n\n const matchingPermissions = (userPermissions || []).filter(\n (permission) =>\n permissions.findIndex(\n (perm) => perm.action === permission.action && perm.subject === permission.subject\n ) >= 0\n );\n\n const hasConditions = (permission: Permission) =>\n Array.isArray(permission.conditions) && permission.conditions.length > 0;\n\n const shouldCheckConditions = matchingPermissions.some(hasConditions);\n\n const { isLoading, error, data } = useCheckPermissionsQuery(\n {\n permissions: matchingPermissions.map((perm) => ({\n action: perm.action,\n subject: perm.subject,\n })),\n },\n {\n skip: !shouldCheckConditions,\n }\n );\n\n React.useEffect(() => {\n if (error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(error),\n });\n }\n }, [error, formatAPIError, toggleNotification]);\n\n if (isLoading) {\n return <Loading />;\n }\n\n if (error) {\n return <Error />;\n }\n\n const { data: permissionsData } = data || {};\n\n const hasUnconditionedPermission = matchingPermissions.some(\n (permission) => !hasConditions(permission)\n );\n\n const canAccess =\n hasUnconditionedPermission || (permissionsData ?? []).some((perm) => perm === true);\n\n if (!canAccess) {\n return <NoPermissions />;\n }\n\n return (\n <>\n {typeof children === 'function' ? children({ permissions: matchingPermissions }) : children}\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Title\n * -----------------------------------------------------------------------------------------------*/\nexport interface TitleProps {\n children: string;\n}\n\n/**\n * @public\n * @description This component takes the children (must be a string) and sets\n * it as the title of the html.\n */\nconst Title = ({ children: title }: TitleProps) => {\n React.useEffect(() => {\n document.title = `${title} | Strapi`;\n }, [title]);\n\n return null;\n};\n\nconst Page = {\n Error,\n Loading,\n NoPermissions,\n Protect,\n NoData,\n Main: PageMain,\n Title,\n};\n\nexport { Page };\nexport type { ErrorProps, LoadingProps, NoPermissionsProps, PageMainProps as MainProps };\n"],"names":["PageMain","children","restProps","_jsx","Main","Loading","height","aria-busy","Flex","alignItems","justifyContent","Loader","Error","props","formatMessage","useIntl","EmptyStateLayout","icon","WarningCircle","width","content","id","defaultMessage","NoPermissions","Box","minWidth","EmptyPermissions","NoData","background","EmptyDocuments","action","Protect","permissions","userPermissions","useAuth","state","toggleNotification","useNotification","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","matchingPermissions","filter","permission","findIndex","perm","subject","hasConditions","Array","isArray","conditions","length","shouldCheckConditions","some","isLoading","error","data","useCheckPermissionsQuery","map","skip","React","useEffect","type","message","permissionsData","hasUnconditionedPermission","canAccess","_Fragment","Title","title","document","Page"],"mappings":";;;;;;;;;;;AA2BA,MAAMA,WAAW,CAAC,EAAEC,QAAQ,EAAE,GAAGC,SAAAA,EAA0B,GAAA;AACzD,IAAA,qBAAOC,GAAA,CAACC,IAAAA,EAAAA;AAAM,QAAA,GAAGF,SAAS;AAAGD,QAAAA,QAAAA,EAAAA;;AAC/B,CAAA;AAYA;;;;AAIC,IACD,MAAMI,OAAAA,GAAU,CAAC,EAAEJ,QAAAA,GAAW,kBAAkB,EAAgB,GAAA;AAC9D,IAAA,qBACEE,GAAA,CAACH,QAAAA,EAAAA;QAASM,MAAAA,EAAO,QAAA;QAASC,WAAAA,EAAW,IAAA;AACnC,QAAA,QAAA,gBAAAJ,GAAA,CAACK,IAAAA,EAAAA;YAAKC,UAAAA,EAAW,QAAA;YAASH,MAAAA,EAAO,MAAA;YAAOI,cAAAA,EAAe,QAAA;AACrD,YAAA,QAAA,gBAAAP,GAAA,CAACQ,MAAAA,EAAAA;AAAQV,gBAAAA,QAAAA,EAAAA;;;;AAIjB,CAAA;AAOA;;;;;;;IAUA,MAAMW,QAAQ,CAACC,KAAAA,GAAAA;IACb,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAE1B,IAAA,qBACEZ,GAAA,CAACH,QAAAA,EAAAA;QAASM,MAAAA,EAAO,MAAA;AACf,QAAA,QAAA,gBAAAH,GAAA,CAACK,IAAAA,EAAAA;YAAKC,UAAAA,EAAW,QAAA;YAASH,MAAAA,EAAO,MAAA;YAAOI,cAAAA,E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AACR,IAAAA,GAASA,IAAAA,KAAS,IAAA,CAAA;AAEhF,IAAA,IAAI,CAACqB,SAAAA,EAAW;AACd,QAAA,qBAAO/D,GAAA,CAACoB,aAAAA,EAAAA,EAAAA,CAAAA;AACV,IAAA;IAEA,qBACEpB,GAAA,CAAAgE,QAAA,EAAA;kBACG,OAAOlE,QAAAA,KAAa,aAAaA,QAAAA,CAAS;YAAE+B,WAAAA,EAAaS;SAAoB,CAAA,GAAKxC;;AAGzF,CAAA;AASA;;;;AAIC,IACD,MAAMmE,KAAAA,GAAQ,CAAC,EAAEnE,QAAAA,EAAUoE,KAAK,EAAc,GAAA;AAC5CT,IAAAA,KAAAA,CAAMC,SAAS,CAAC,IAAA;AACdS,QAAAA,QAAAA,CAASD,KAAK,GAAG,CAAA,EAAGA,KAAAA,CAAM,SAAS,CAAC;IACtC,CAAA,EAAG;AAACA,QAAAA;AAAM,KAAA,CAAA;IAEV,OAAO,IAAA;AACT,CAAA;AAEA,MAAME,IAAAA,GAAO;AACX3D,IAAAA,KAAAA;AACAP,IAAAA,OAAAA;AACAkB,IAAAA,aAAAA;AACAQ,IAAAA,OAAAA;AACAJ,IAAAA,MAAAA;IACAvB,IAAAA,EAAMJ,QAAAA;AACNoE,IAAAA;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/admin",
3
- "version": "5.52.0",
3
+ "version": "5.52.1",
4
4
  "description": "Strapi Admin",
5
5
  "homepage": "https://strapi.io",
6
6
  "bugs": {
@@ -91,10 +91,10 @@
91
91
  "@reduxjs/toolkit": "1.9.7",
92
92
  "@strapi/design-system": "2.2.4",
93
93
  "@strapi/icons": "2.2.4",
94
- "@strapi/permissions": "5.52.0",
95
- "@strapi/types": "5.52.0",
96
- "@strapi/typescript-utils": "5.52.0",
97
- "@strapi/utils": "5.52.0",
94
+ "@strapi/permissions": "5.52.1",
95
+ "@strapi/types": "5.52.1",
96
+ "@strapi/typescript-utils": "5.52.1",
97
+ "@strapi/utils": "5.52.1",
98
98
  "@testing-library/dom": "10.4.1",
99
99
  "@testing-library/react": "16.3.2",
100
100
  "@testing-library/user-event": "14.6.1",
@@ -148,8 +148,8 @@
148
148
  "zod": "3.25.76"
149
149
  },
150
150
  "devDependencies": {
151
- "@strapi/admin-test-utils": "5.52.0",
152
- "@strapi/data-transfer": "5.52.0",
151
+ "@strapi/admin-test-utils": "5.52.1",
152
+ "@strapi/data-transfer": "5.52.1",
153
153
  "@testing-library/jest-dom": "6.9.1",
154
154
  "@types/codemirror5": "npm:@types/codemirror@^5.60.15",
155
155
  "@types/fs-extra": "11.0.4",