@strapi/content-manager 5.59.0 → 5.61.0
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.
- package/dist/admin/constants/customOrder.js +14 -0
- package/dist/admin/constants/customOrder.js.map +1 -0
- package/dist/admin/constants/customOrder.mjs +10 -0
- package/dist/admin/constants/customOrder.mjs.map +1 -0
- package/dist/admin/history/components/VersionInputRenderer.js +2 -1
- package/dist/admin/history/components/VersionInputRenderer.js.map +1 -1
- package/dist/admin/history/components/VersionInputRenderer.mjs +2 -1
- package/dist/admin/history/components/VersionInputRenderer.mjs.map +1 -1
- package/dist/admin/hooks/useDocument.js +22 -11
- package/dist/admin/hooks/useDocument.js.map +1 -1
- package/dist/admin/hooks/useDocument.mjs +22 -11
- package/dist/admin/hooks/useDocument.mjs.map +1 -1
- package/dist/admin/hooks/useDocumentLayout.js.map +1 -1
- package/dist/admin/hooks/useDocumentLayout.mjs.map +1 -1
- package/dist/admin/hooks/useHasBeenNearViewport.js +70 -0
- package/dist/admin/hooks/useHasBeenNearViewport.js.map +1 -0
- package/dist/admin/hooks/useHasBeenNearViewport.mjs +46 -0
- package/dist/admin/hooks/useHasBeenNearViewport.mjs.map +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.js +102 -32
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.mjs +104 -35
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.js +20 -17
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.mjs +20 -17
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js +15 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs +17 -3
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.js +21 -0
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.mjs +22 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +2 -0
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +2 -0
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +4 -7
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +4 -7
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +46 -10
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +47 -11
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormLayout.js +201 -50
- package/dist/admin/pages/EditView/components/FormLayout.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormLayout.mjs +202 -52
- package/dist/admin/pages/EditView/components/FormLayout.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.js +3 -1
- package/dist/admin/pages/EditView/components/InputRenderer.js.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.mjs +3 -1
- package/dist/admin/pages/EditView/components/InputRenderer.mjs.map +1 -1
- package/dist/admin/pages/ListConfiguration/components/Settings.js +31 -2
- package/dist/admin/pages/ListConfiguration/components/Settings.js.map +1 -1
- package/dist/admin/pages/ListConfiguration/components/Settings.mjs +31 -2
- package/dist/admin/pages/ListConfiguration/components/Settings.mjs.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.js +196 -132
- package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.mjs +196 -132
- package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/CustomOrder.js +571 -0
- package/dist/admin/pages/ListView/components/CustomOrder.js.map +1 -0
- package/dist/admin/pages/ListView/components/CustomOrder.mjs +546 -0
- package/dist/admin/pages/ListView/components/CustomOrder.mjs.map +1 -0
- package/dist/admin/pages/ListView/components/TableActions.js +4 -1
- package/dist/admin/pages/ListView/components/TableActions.js.map +1 -1
- package/dist/admin/pages/ListView/components/TableActions.mjs +4 -1
- package/dist/admin/pages/ListView/components/TableActions.mjs.map +1 -1
- package/dist/admin/preview/components/PreviewSidePanel.js +2 -1
- package/dist/admin/preview/components/PreviewSidePanel.js.map +1 -1
- package/dist/admin/preview/components/PreviewSidePanel.mjs +2 -1
- package/dist/admin/preview/components/PreviewSidePanel.mjs.map +1 -1
- package/dist/admin/preview/utils/getPreviewUrlStatus.js +17 -0
- package/dist/admin/preview/utils/getPreviewUrlStatus.js.map +1 -0
- package/dist/admin/preview/utils/getPreviewUrlStatus.mjs +15 -0
- package/dist/admin/preview/utils/getPreviewUrlStatus.mjs.map +1 -0
- package/dist/admin/services/documents.js +22 -1
- package/dist/admin/services/documents.js.map +1 -1
- package/dist/admin/services/documents.mjs +21 -2
- package/dist/admin/services/documents.mjs.map +1 -1
- package/dist/admin/src/constants/customOrder.d.ts +8 -0
- package/dist/admin/src/exports.d.ts +1 -1
- package/dist/admin/src/history/components/VersionInputRenderer.d.ts +3 -1
- package/dist/admin/src/hooks/useDocument.d.ts +4 -0
- package/dist/admin/src/hooks/useDocumentLayout.d.ts +6 -2
- package/dist/admin/src/hooks/useHasBeenNearViewport.d.ts +13 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.d.ts +13 -1
- package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +11 -1
- package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +2 -0
- package/dist/admin/src/pages/ListView/components/CustomOrder.d.ts +72 -0
- package/dist/admin/src/preview/utils/getPreviewUrlStatus.d.ts +6 -0
- package/dist/admin/src/services/documents.d.ts +10 -2
- package/dist/admin/translations/en.json.js +9 -0
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +9 -0
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/server/audit-logs.js +36 -0
- package/dist/server/audit-logs.js.map +1 -0
- package/dist/server/audit-logs.mjs +33 -0
- package/dist/server/audit-logs.mjs.map +1 -0
- package/dist/server/bootstrap.js +8 -0
- package/dist/server/bootstrap.js.map +1 -1
- package/dist/server/bootstrap.mjs +8 -0
- package/dist/server/bootstrap.mjs.map +1 -1
- package/dist/server/controllers/collection-types.js +8 -0
- package/dist/server/controllers/collection-types.js.map +1 -1
- package/dist/server/controllers/collection-types.mjs +8 -0
- package/dist/server/controllers/collection-types.mjs.map +1 -1
- package/dist/server/controllers/content-types.js +15 -0
- package/dist/server/controllers/content-types.js.map +1 -1
- package/dist/server/controllers/content-types.mjs +16 -1
- package/dist/server/controllers/content-types.mjs.map +1 -1
- package/dist/server/controllers/index.js +3 -1
- package/dist/server/controllers/index.js.map +1 -1
- package/dist/server/controllers/index.mjs +2 -0
- package/dist/server/controllers/index.mjs.map +1 -1
- package/dist/server/controllers/relations.js +53 -17
- package/dist/server/controllers/relations.js.map +1 -1
- package/dist/server/controllers/relations.mjs +54 -18
- package/dist/server/controllers/relations.mjs.map +1 -1
- package/dist/server/controllers/single-types.js +10 -1
- package/dist/server/controllers/single-types.js.map +1 -1
- package/dist/server/controllers/single-types.mjs +10 -1
- package/dist/server/controllers/single-types.mjs.map +1 -1
- package/dist/server/controllers/validation/model-configuration.js +2 -1
- package/dist/server/controllers/validation/model-configuration.js.map +1 -1
- package/dist/server/controllers/validation/model-configuration.mjs +2 -1
- package/dist/server/controllers/validation/model-configuration.mjs.map +1 -1
- package/dist/server/custom-order/constants.js +21 -0
- package/dist/server/custom-order/constants.js.map +1 -0
- package/dist/server/custom-order/constants.mjs +17 -0
- package/dist/server/custom-order/constants.mjs.map +1 -0
- package/dist/server/custom-order/controllers/custom-order.js +77 -0
- package/dist/server/custom-order/controllers/custom-order.js.map +1 -0
- package/dist/server/custom-order/controllers/custom-order.mjs +75 -0
- package/dist/server/custom-order/controllers/custom-order.mjs.map +1 -0
- package/dist/server/custom-order/controllers/index.js +10 -0
- package/dist/server/custom-order/controllers/index.js.map +1 -0
- package/dist/server/custom-order/controllers/index.mjs +8 -0
- package/dist/server/custom-order/controllers/index.mjs.map +1 -0
- package/dist/server/custom-order/index.js +71 -0
- package/dist/server/custom-order/index.js.map +1 -0
- package/dist/server/custom-order/index.mjs +69 -0
- package/dist/server/custom-order/index.mjs.map +1 -0
- package/dist/server/custom-order/routes/custom-order.js +38 -0
- package/dist/server/custom-order/routes/custom-order.js.map +1 -0
- package/dist/server/custom-order/routes/custom-order.mjs +36 -0
- package/dist/server/custom-order/routes/custom-order.mjs.map +1 -0
- package/dist/server/custom-order/routes/index.js +13 -0
- package/dist/server/custom-order/routes/index.js.map +1 -0
- package/dist/server/custom-order/routes/index.mjs +11 -0
- package/dist/server/custom-order/routes/index.mjs.map +1 -0
- package/dist/server/custom-order/services/custom-order.js +286 -0
- package/dist/server/custom-order/services/custom-order.js.map +1 -0
- package/dist/server/custom-order/services/custom-order.mjs +284 -0
- package/dist/server/custom-order/services/custom-order.mjs.map +1 -0
- package/dist/server/custom-order/services/document-middleware.js +83 -0
- package/dist/server/custom-order/services/document-middleware.js.map +1 -0
- package/dist/server/custom-order/services/document-middleware.mjs +81 -0
- package/dist/server/custom-order/services/document-middleware.mjs.map +1 -0
- package/dist/server/custom-order/services/index.js +10 -0
- package/dist/server/custom-order/services/index.js.map +1 -0
- package/dist/server/custom-order/services/index.mjs +8 -0
- package/dist/server/custom-order/services/index.mjs.map +1 -0
- package/dist/server/custom-order/services/utils.js +152 -0
- package/dist/server/custom-order/services/utils.js.map +1 -0
- package/dist/server/custom-order/services/utils.mjs +148 -0
- package/dist/server/custom-order/services/utils.mjs.map +1 -0
- package/dist/server/custom-order/utils.js +13 -0
- package/dist/server/custom-order/utils.js.map +1 -0
- package/dist/server/custom-order/utils.mjs +10 -0
- package/dist/server/custom-order/utils.mjs.map +1 -0
- package/dist/server/history/constants.js +2 -1
- package/dist/server/history/constants.js.map +1 -1
- package/dist/server/history/constants.mjs +2 -1
- package/dist/server/history/constants.mjs.map +1 -1
- package/dist/server/history/controllers/history-version.js +6 -2
- package/dist/server/history/controllers/history-version.js.map +1 -1
- package/dist/server/history/controllers/history-version.mjs +6 -2
- package/dist/server/history/controllers/history-version.mjs.map +1 -1
- package/dist/server/history/services/history.js +24 -7
- package/dist/server/history/services/history.js.map +1 -1
- package/dist/server/history/services/history.mjs +25 -8
- package/dist/server/history/services/history.mjs.map +1 -1
- package/dist/server/history/services/lifecycles.js +2 -16
- package/dist/server/history/services/lifecycles.js.map +1 -1
- package/dist/server/history/services/lifecycles.mjs +2 -16
- package/dist/server/history/services/lifecycles.mjs.map +1 -1
- package/dist/server/mcp/schemas/filters-schema.js +10 -2
- package/dist/server/mcp/schemas/filters-schema.js.map +1 -1
- package/dist/server/mcp/schemas/filters-schema.mjs +10 -2
- package/dist/server/mcp/schemas/filters-schema.mjs.map +1 -1
- package/dist/server/preview/controllers/validation/preview.js +1 -1
- package/dist/server/preview/controllers/validation/preview.js.map +1 -1
- package/dist/server/preview/controllers/validation/preview.mjs +2 -2
- package/dist/server/preview/controllers/validation/preview.mjs.map +1 -1
- package/dist/server/register.js +4 -0
- package/dist/server/register.js.map +1 -1
- package/dist/server/register.mjs +4 -0
- package/dist/server/register.mjs.map +1 -1
- package/dist/server/routes/index.js +3 -1
- package/dist/server/routes/index.js.map +1 -1
- package/dist/server/routes/index.mjs +2 -0
- package/dist/server/routes/index.mjs.map +1 -1
- package/dist/server/services/content-types.js +2 -2
- package/dist/server/services/content-types.js.map +1 -1
- package/dist/server/services/content-types.mjs +2 -2
- package/dist/server/services/content-types.mjs.map +1 -1
- package/dist/server/services/document-manager.js +13 -0
- package/dist/server/services/document-manager.js.map +1 -1
- package/dist/server/services/document-manager.mjs +14 -1
- package/dist/server/services/document-manager.mjs.map +1 -1
- package/dist/server/services/document-metadata.js +1 -1
- package/dist/server/services/document-metadata.js.map +1 -1
- package/dist/server/services/document-metadata.mjs +1 -1
- package/dist/server/services/document-metadata.mjs.map +1 -1
- package/dist/server/services/index.js +3 -1
- package/dist/server/services/index.js.map +1 -1
- package/dist/server/services/index.mjs +2 -0
- package/dist/server/services/index.mjs.map +1 -1
- package/dist/server/services/utils/configuration/settings.js +2 -1
- package/dist/server/services/utils/configuration/settings.js.map +1 -1
- package/dist/server/services/utils/configuration/settings.mjs +2 -1
- package/dist/server/services/utils/configuration/settings.mjs.map +1 -1
- package/dist/server/src/audit-logs.d.ts +40 -0
- package/dist/server/src/audit-logs.d.ts.map +1 -0
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/content-types.d.ts.map +1 -1
- package/dist/server/src/controllers/index.d.ts +21 -3
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/relations.d.ts +19 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/controllers/single-types.d.ts +1 -1
- package/dist/server/src/controllers/single-types.d.ts.map +1 -1
- package/dist/server/src/custom-order/constants.d.ts +18 -0
- package/dist/server/src/custom-order/constants.d.ts.map +1 -0
- package/dist/server/src/custom-order/controllers/custom-order.d.ts +8 -0
- package/dist/server/src/custom-order/controllers/custom-order.d.ts.map +1 -0
- package/dist/server/src/custom-order/controllers/index.d.ts +3 -0
- package/dist/server/src/custom-order/controllers/index.d.ts.map +1 -0
- package/dist/server/src/custom-order/index.d.ts +8 -0
- package/dist/server/src/custom-order/index.d.ts.map +1 -0
- package/dist/server/src/custom-order/routes/custom-order.d.ts +4 -0
- package/dist/server/src/custom-order/routes/custom-order.d.ts.map +1 -0
- package/dist/server/src/custom-order/routes/index.d.ts +10 -0
- package/dist/server/src/custom-order/routes/index.d.ts.map +1 -0
- package/dist/server/src/custom-order/services/custom-order.d.ts +43 -0
- package/dist/server/src/custom-order/services/custom-order.d.ts.map +1 -0
- package/dist/server/src/custom-order/services/document-middleware.d.ts +16 -0
- package/dist/server/src/custom-order/services/document-middleware.d.ts.map +1 -0
- package/dist/server/src/custom-order/services/index.d.ts +24 -0
- package/dist/server/src/custom-order/services/index.d.ts.map +1 -0
- package/dist/server/src/custom-order/services/utils.d.ts +34 -0
- package/dist/server/src/custom-order/services/utils.d.ts.map +1 -0
- package/dist/server/src/custom-order/utils.d.ts +6 -0
- package/dist/server/src/custom-order/utils.d.ts.map +1 -0
- package/dist/server/src/history/constants.d.ts.map +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +22 -6
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/mcp/schemas/filters-schema.d.ts.map +1 -1
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/dist/server/src/services/content-types.d.ts +1 -3
- package/dist/server/src/services/content-types.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +1 -3
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/utils/configuration/settings.d.ts.map +1 -1
- package/dist/shared/contracts/content-types.d.ts +5 -0
- package/dist/shared/contracts/content-types.d.ts.map +1 -1
- package/dist/shared/contracts/custom-order.d.ts +33 -0
- package/dist/shared/contracts/custom-order.d.ts.map +1 -0
- package/dist/shared/contracts/custom-order.js +3 -0
- package/dist/shared/contracts/custom-order.js.map +1 -0
- package/dist/shared/contracts/custom-order.mjs +2 -0
- package/dist/shared/contracts/custom-order.mjs.map +1 -0
- package/dist/shared/contracts/history-versions.d.ts +0 -1
- package/dist/shared/contracts/history-versions.d.ts.map +1 -1
- package/dist/shared/contracts/index.d.ts +1 -0
- package/dist/shared/contracts/index.d.ts.map +1 -1
- package/dist/shared/contracts/index.js +2 -0
- package/dist/shared/contracts/index.js.map +1 -1
- package/dist/shared/contracts/index.mjs +2 -0
- package/dist/shared/contracts/index.mjs.map +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationModal.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n ConfirmDialog,\n DescriptionComponentRenderer,\n Form as FormContext,\n useRBAC,\n useStrapiApp,\n createContext,\n useForm,\n useQueryParams,\n type StrapiAppContextValue,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Dialog,\n EmptyStateLayout,\n Flex,\n IconButton,\n Loader,\n Modal,\n Typography,\n TextButton,\n} from '@strapi/design-system';\nimport { ArrowLeft, ArrowsOut, WarningCircle } from '@strapi/icons';\nimport { generateNKeysBetween } from 'fractional-indexing';\nimport { useIntl } from 'react-intl';\nimport { Link as RouterLink, useLocation, useNavigate } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { COLLECTION_TYPES, SINGLE_TYPES } from '../../../../../constants/collections';\nimport { PERMISSIONS } from '../../../../../constants/plugin';\nimport { buildValidParams } from '../../../../../exports';\nimport { DocumentRBAC, useDocumentRBAC } from '../../../../../features/DocumentRBAC';\nimport { useDoc, useDocument, type UseDocument } from '../../../../../hooks/useDocument';\nimport { type DocumentMeta } from '../../../../../hooks/useDocumentContext';\nimport { useDocumentLayout } from '../../../../../hooks/useDocumentLayout';\nimport { useLazyGetDocumentQuery } from '../../../../../services/documents';\nimport { setIn } from '../../../../../utils/objects';\nimport { createYupSchema } from '../../../../../utils/validation';\nimport { DocumentActionButton } from '../../../components/DocumentActions';\nimport { DocumentStatus } from '../../DocumentStatus';\nimport { FormLayout, type FormLayoutProps } from '../../FormLayout';\nimport { ComponentProvider } from '../ComponentContext';\n\nimport type { RelationOpenMode } from '../../../../../../../shared/contracts/content-types';\nimport type { ContentManagerPlugin, DocumentActionProps } from '../../../../../content-manager';\nimport type { AnyData } from '../../../utils/data';\n\nexport function getCollectionType(url: string) {\n const regex = new RegExp(`(${COLLECTION_TYPES}|${SINGLE_TYPES})`);\n const match = url.match(regex);\n return match ? match[1] : undefined;\n}\n\nconst StyledModalContent = styled(Modal.Content)`\n width: 90%;\n max-width: 100%;\n height: 90%;\n max-height: 100%;\n`;\n\nconst getFullPageUrl = (currentDocumentMeta: DocumentMeta): string => {\n const isSingleType = currentDocumentMeta.collectionType === SINGLE_TYPES;\n const queryParams = currentDocumentMeta.params?.locale\n ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}`\n : '';\n\n return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}${isSingleType ? '' : '/' + currentDocumentMeta.documentId}${queryParams}`;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * RelationModalRenderer\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * A local \"connect\" edit waiting to be applied to a document that isn't the modal's current one.\n * Needed because every level of a nested relation-on-the-fly chain (root document aside) shares\n * one Form instance whose values get wholesale-replaced by fresh initialValues on every\n * `documentHistory` navigation — writing the field directly while a different level is current\n * would land on the wrong document and then immediately be discarded. Instead the patch is stashed\n * here, keyed by the target document, and merged back into that document's initialValues once it\n * becomes current again (see `RelationModal`'s `initialValues` below).\n */\ninterface PendingConnectPatch {\n fieldToConnect: string;\n relationValue: AnyData;\n componentUIDPath?: string;\n componentUID?: string;\n}\n\nconst getDocumentHistoryKey = (meta: Pick<DocumentMeta, 'model' | 'documentId'>) =>\n `${meta.model}::${meta.documentId}`;\n\nconst EMPTY_PENDING_CONNECTS: PendingConnectPatch[] = [];\n\ninterface State {\n documentHistory: DocumentMeta[];\n confirmDialogIntent:\n | null // No dialog\n | 'close' // Close the modal\n | 'back' // Go back one document in the modal's history\n | 'navigate' // Open the document in the edit view instead of in the modal\n | DocumentMeta; // Open a specific document in the modal\n isModalOpen: boolean;\n hasUnsavedChanges: boolean;\n fieldToConnect?: string;\n fieldToConnectUID?: string;\n getParentFormValues?: () => AnyData;\n // Sets a field directly on the parent's own (live, unsaved) form state, so connecting a\n // newly-created relation doesn't require persisting the whole parent document to the server.\n setParentFormValue?: (path: string, value: unknown) => void;\n pendingConnects: Record<string, PendingConnectPatch[]>;\n}\n\ntype Action =\n | {\n type: 'GO_TO_RELATION';\n payload: {\n document: DocumentMeta;\n shouldBypassConfirmation: boolean;\n fieldToConnect?: string;\n fieldToConnectUID?: string;\n getParentFormValues?: () => AnyData;\n setParentFormValue?: (path: string, value: unknown) => void;\n };\n }\n | {\n type: 'GO_BACK';\n payload: { shouldBypassConfirmation: boolean };\n }\n | {\n type: 'GO_FULL_PAGE';\n }\n | {\n type: 'GO_TO_CREATED_RELATION';\n payload: {\n document: DocumentMeta;\n shouldBypassConfirmation: boolean;\n // Present when the document being connected belongs to a NESTED parent (one still further\n // up `documentHistory`, not the root document) — see `pendingConnects` on `State`.\n connectPatch?: PendingConnectPatch;\n };\n }\n | {\n type: 'CANCEL_CONFIRM_DIALOG';\n }\n | {\n type: 'CLOSE_MODAL';\n payload: { shouldBypassConfirmation: boolean };\n }\n | {\n type: 'SET_HAS_UNSAVED_CHANGES';\n payload: { hasUnsavedChanges: boolean };\n }\n | {\n type: 'CLEAR_PENDING_CONNECTS';\n payload: { documentMeta: Pick<DocumentMeta, 'model' | 'documentId'> };\n };\n\nfunction reducer(state: State, action: Action): State {\n switch (action.type) {\n case 'GO_TO_RELATION':\n if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {\n return {\n ...state,\n confirmDialogIntent: action.payload.document,\n fieldToConnect: action.payload.fieldToConnect,\n fieldToConnectUID: action.payload.fieldToConnectUID,\n getParentFormValues: action.payload.getParentFormValues,\n setParentFormValue: action.payload.setParentFormValue,\n };\n }\n\n const lastItemDocumentHistory = state.documentHistory.at(-1);\n const hasToResetDocumentHistory =\n lastItemDocumentHistory && !lastItemDocumentHistory.documentId;\n return {\n ...state,\n // Reset document history if the last item has documentId undefined\n documentHistory: hasToResetDocumentHistory\n ? [action.payload.document]\n : [...state.documentHistory, action.payload.document],\n confirmDialogIntent: null,\n isModalOpen: true,\n fieldToConnect: hasToResetDocumentHistory ? undefined : action.payload.fieldToConnect,\n fieldToConnectUID: hasToResetDocumentHistory ? undefined : action.payload.fieldToConnectUID,\n getParentFormValues: hasToResetDocumentHistory\n ? undefined\n : action.payload.getParentFormValues,\n setParentFormValue: hasToResetDocumentHistory\n ? undefined\n : action.payload.setParentFormValue,\n };\n case 'GO_BACK':\n if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {\n return { ...state, confirmDialogIntent: 'back' };\n }\n\n return {\n ...state,\n documentHistory: state.documentHistory.slice(0, -1),\n confirmDialogIntent: null,\n };\n case 'GO_FULL_PAGE':\n if (state.hasUnsavedChanges) {\n return { ...state, confirmDialogIntent: 'navigate' };\n }\n\n return {\n ...state,\n documentHistory: [],\n hasUnsavedChanges: false,\n isModalOpen: false,\n confirmDialogIntent: null,\n pendingConnects: {},\n };\n case 'GO_TO_CREATED_RELATION': {\n // Anything beyond the second-to-last history entry is a nested parent still open further up\n // the stack — the root document (outside documentHistory entirely) is handled directly via\n // setParentFormValue instead, since its Form never gets replaced by modal navigation.\n const nestedParentMeta =\n state.documentHistory.length >= 2 ? state.documentHistory.at(-2) : undefined;\n const pendingConnects =\n nestedParentMeta && action.payload.connectPatch\n ? {\n ...state.pendingConnects,\n [getDocumentHistoryKey(nestedParentMeta)]: [\n ...(state.pendingConnects[getDocumentHistoryKey(nestedParentMeta)] ?? []),\n action.payload.connectPatch,\n ],\n }\n : state.pendingConnects;\n\n return {\n ...state,\n // Reset document history if the last item has documentId undefined\n documentHistory: state.documentHistory\n ? [...state.documentHistory.slice(0, -1), action.payload.document]\n : [action.payload.document],\n confirmDialogIntent: null,\n isModalOpen: true,\n fieldToConnect: undefined,\n fieldToConnectUID: undefined,\n getParentFormValues: undefined,\n setParentFormValue: undefined,\n pendingConnects,\n };\n }\n case 'CANCEL_CONFIRM_DIALOG':\n return {\n ...state,\n confirmDialogIntent: null,\n };\n case 'CLOSE_MODAL':\n if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {\n return { ...state, confirmDialogIntent: 'close' };\n }\n\n return {\n ...state,\n documentHistory: [],\n confirmDialogIntent: null,\n hasUnsavedChanges: false,\n isModalOpen: false,\n fieldToConnect: undefined,\n fieldToConnectUID: undefined,\n getParentFormValues: undefined,\n setParentFormValue: undefined,\n pendingConnects: {},\n };\n case 'SET_HAS_UNSAVED_CHANGES':\n return {\n ...state,\n hasUnsavedChanges: action.payload.hasUnsavedChanges,\n };\n case 'CLEAR_PENDING_CONNECTS': {\n const key = getDocumentHistoryKey(action.payload.documentMeta);\n\n if (!(key in state.pendingConnects)) {\n return state;\n }\n\n const pendingConnects = { ...state.pendingConnects };\n delete pendingConnects[key];\n\n return { ...state, pendingConnects };\n }\n default:\n return state;\n }\n}\n\n/**\n * Whether any relation-on-the-fly modal is currently open, anywhere on the page.\n *\n * The modal's React context (`RelationModalProvider`, below) only reaches the modal's own subtree\n * (the relation field that renders it), so components mounted outside that subtree — like the\n * background entry's save/publish buttons in the side panel — can't read `state.isModalOpen` from\n * context. This module-level counter is the cross-tree signal those components use instead, so\n * they can tell a relation modal is open and suppress their own keyboard shortcuts while it is.\n */\nlet openRelationModalCount = 0;\n\nconst isAnyRelationModalOpen = () => openRelationModalCount > 0;\n\ninterface RelationModalContextValue {\n state: State;\n dispatch: React.Dispatch<Action>;\n rootDocumentMeta: DocumentMeta;\n currentDocumentMeta: DocumentMeta;\n currentDocument: ReturnType<UseDocument>;\n onPreview?: () => void;\n isCreating: boolean;\n relationOpenMode: RelationOpenMode;\n}\n\nconst [RelationModalProvider, useRelationModal] =\n createContext<RelationModalContextValue>('RelationModal');\n\nfunction isRenderProp(\n children: RelationModalRendererProps['children']\n): children is (props: {\n dispatch: (action: Action) => void;\n relationOpenMode: RelationOpenMode;\n}) => React.ReactNode {\n return typeof children === 'function';\n}\n\ntype RelationModalRendererProps =\n // Is editing\n | {\n relation: DocumentMeta;\n children: React.ReactNode;\n }\n // Is creating\n | {\n relation?: never;\n children: (props: {\n dispatch: (action: Action) => void;\n relationOpenMode: RelationOpenMode;\n }) => React.ReactNode;\n };\n\nconst RootRelationRenderer = (props: RelationModalRendererProps) => {\n const { children } = props;\n\n const [state, dispatch] = React.useReducer(reducer, {\n documentHistory: [],\n confirmDialogIntent: null,\n isModalOpen: false,\n hasUnsavedChanges: false,\n fieldToConnect: undefined,\n pendingConnects: {},\n });\n\n const rootDocument = useDoc();\n const [{ query }] = useQueryParams();\n const params = React.useMemo(() => buildValidParams(query ?? {}), [query]);\n\n const rootDocumentMeta: DocumentMeta = {\n documentId: rootDocument.document?.documentId || '',\n model: rootDocument.model,\n collectionType: rootDocument.collectionType,\n params,\n };\n\n // Get the relationOpenMode setting from the current document's layout configuration\n const documentLayoutResponse = useDocumentLayout(rootDocument.model);\n const relationOpenMode: RelationOpenMode =\n documentLayoutResponse.edit?.settings?.relationOpenMode ?? 'modal';\n\n const currentDocumentMeta = state.documentHistory.at(-1) ?? rootDocumentMeta;\n const currentDocument = useDocument(currentDocumentMeta);\n // TODO: check if we can remove the single type check\n const isSingleType = currentDocumentMeta.collectionType === SINGLE_TYPES;\n const isCreating = !currentDocumentMeta.documentId && !isSingleType;\n\n const { isModalOpen } = state;\n React.useEffect(() => {\n if (!isModalOpen) {\n return;\n }\n\n openRelationModalCount += 1;\n\n return () => {\n openRelationModalCount -= 1;\n };\n }, [isModalOpen]);\n\n /**\n * There is no parent relation, so the relation modal doesn't exist. Create it and set up all the\n * pieces that will be used by potential child relations: the context, header, form, and footer.\n */\n return (\n <RelationModalProvider\n state={state}\n dispatch={dispatch}\n rootDocumentMeta={rootDocumentMeta}\n currentDocumentMeta={currentDocumentMeta}\n currentDocument={currentDocument}\n isCreating={isCreating}\n relationOpenMode={relationOpenMode}\n >\n <RelationModal>\n {isRenderProp(children)\n ? children({ dispatch, relationOpenMode })\n : props.relation && (\n <RelationModalTrigger relation={props.relation}>{children}</RelationModalTrigger>\n )}\n </RelationModal>\n </RelationModalProvider>\n );\n};\n\nconst NestedRelationRenderer = (props: RelationModalRendererProps) => {\n const { children } = props;\n const dispatch = useRelationModal('NestedRelation', (state) => state.dispatch);\n const relationOpenMode = useRelationModal('NestedRelation', (state) => state.relationOpenMode);\n\n return isRenderProp(children)\n ? children({ dispatch, relationOpenMode })\n : props.relation && (\n <RelationModalTrigger relation={props.relation}>{children}</RelationModalTrigger>\n ); /* This is the trigger that will be rendered in the parent relation */\n};\n\n/**\n * Component responsible for rendering its children wrapped in a modal, form and context if needed\n */\nconst RelationModalRenderer = (props: RelationModalRendererProps) => {\n // We're in a nested relation if the relation modal context is not undefined\n const isNested = useRelationModal('RelationContextWrapper', (state) => state != undefined, false);\n\n return isNested ? <NestedRelationRenderer {...props} /> : <RootRelationRenderer {...props} />;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * RelationModal\n * -----------------------------------------------------------------------------------------------*/\nconst generateCreateUrl = (currentDocumentMeta: DocumentMeta) => {\n return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}/create${\n currentDocumentMeta.params?.locale\n ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}`\n : ''\n }`;\n};\n\n/**\n * Pre-fill the inverse relation with the parent that opened create-on-the-fly.\n * One-way relations have no inverse; unsaved parents have no documentId.\n */\nconst prefillParentRelation = ({\n initialValues,\n fieldToConnect,\n childSchema,\n parentDocument,\n parentModel,\n}: {\n initialValues?: AnyData;\n fieldToConnect?: string;\n childSchema?: { attributes?: Record<string, unknown> };\n parentDocument?: Record<string, unknown>;\n parentModel?: string;\n}): AnyData | undefined => {\n const documentId = parentDocument?.documentId;\n // mappedBy/inversedBy names a top-level attribute, not a component path.\n const parentFieldName = fieldToConnect;\n\n if (!initialValues || typeof documentId !== 'string' || !documentId || !parentFieldName) {\n return initialValues;\n }\n\n const inverseField = Object.entries(childSchema?.attributes ?? {}).find(([, attribute]) => {\n const relation = attribute as {\n type?: string;\n target?: string;\n inversedBy?: string;\n mappedBy?: string;\n };\n\n return (\n relation.type === 'relation' &&\n relation.target === parentModel &&\n (relation.inversedBy === parentFieldName || relation.mappedBy === parentFieldName)\n );\n })?.[0];\n\n if (!inverseField) {\n return initialValues;\n }\n\n const id = parentDocument.id ?? documentId;\n\n return {\n ...initialValues,\n [inverseField]: {\n connect: [\n {\n ...Object.fromEntries(\n Object.entries(parentDocument).filter(\n ([, value]) =>\n value === null || ['string', 'number', 'boolean'].includes(typeof value)\n )\n ),\n id,\n documentId,\n apiData: {\n id,\n documentId,\n locale: parentDocument.locale,\n isTemporary: true,\n },\n __temp_key__: generateNKeysBetween(null, null, 1)[0],\n },\n ],\n disconnect: [],\n },\n };\n};\n\nconst RelationModal = ({ children }: { children: React.ReactNode }) => {\n const { formatMessage } = useIntl();\n const navigate = useNavigate();\n const state = useRelationModal('RelationModalForm', (state) => state.state);\n const dispatch = useRelationModal('RelationModalForm', (state) => state.dispatch);\n const currentDocumentMeta = useRelationModal(\n 'RelationModalForm',\n (state) => state.currentDocumentMeta\n );\n const currentDocument = useRelationModal('RelationModalForm', (state) => state.currentDocument);\n const isCreating = useRelationModal('RelationModalForm', (state) => state.isCreating);\n const rootDocumentMeta = useRelationModal('RelationModalForm', (state) => state.rootDocumentMeta);\n const parentDocumentMeta = state.documentHistory.at(-2) ?? rootDocumentMeta;\n const parentDocument = useDocument(parentDocumentMeta, {\n skip: !isCreating || !state.fieldToConnect,\n });\n\n const pendingConnectsForCurrent =\n useRelationModal(\n 'RelationModalForm',\n (state) => state.state.pendingConnects[getDocumentHistoryKey(currentDocumentMeta)],\n false\n ) ?? EMPTY_PENDING_CONNECTS;\n\n // Re-apply any local \"connect\" edits recorded for this document while a nested child was open,\n // since navigating here just replaced the Form's values with a fresh, patch-less snapshot.\n const initialValues = React.useMemo(() => {\n const baseInitialValues = prefillParentRelation({\n initialValues: currentDocument.getInitialFormValues(isCreating),\n fieldToConnect: isCreating ? state.fieldToConnect : undefined,\n childSchema: currentDocument.schema,\n parentDocument: parentDocument.document,\n parentModel: parentDocumentMeta.model,\n });\n\n // The document (and its default values) may still be loading, e.g. right after navigating\n // back to a document that now has a real documentId. Let the loading guard below handle it\n // instead of trying to patch a value that doesn't exist yet.\n if (!baseInitialValues) {\n return baseInitialValues;\n }\n\n return pendingConnectsForCurrent.reduce((values, patch) => {\n const withRelation = setIn(values, patch.fieldToConnect, patch.relationValue);\n\n return patch.componentUIDPath && patch.componentUID !== undefined\n ? setIn(withRelation, patch.componentUIDPath, patch.componentUID)\n : withRelation;\n }, baseInitialValues);\n }, [\n currentDocument,\n isCreating,\n state.fieldToConnect,\n parentDocument.document,\n parentDocumentMeta.model,\n pendingConnectsForCurrent,\n ]);\n\n /*\n * We must wrap the modal window with Component Provider with reset values\n * to avoid inheriting id and uid from the root document and having weird\n * behaviors with simple relationships..\n */\n return (\n <ComponentProvider id={undefined} level={-1} uid={undefined} type={undefined}>\n <Modal.Root\n open={state.isModalOpen}\n onOpenChange={(open) => {\n if (!open) {\n dispatch({\n type: 'CLOSE_MODAL',\n payload: { shouldBypassConfirmation: false },\n });\n }\n }}\n >\n {children}\n <StyledModalContent>\n <Modal.Header gap={2}>\n <Flex justifyContent=\"space-between\" alignItems=\"center\" width=\"100%\">\n <Flex gap={2}>\n <IconButton\n withTooltip={false}\n label={formatMessage({ id: 'global.back', defaultMessage: 'Back' })}\n variant=\"ghost\"\n disabled={state.documentHistory.length < 2}\n onClick={() => {\n dispatch({\n type: 'GO_BACK',\n payload: { shouldBypassConfirmation: false },\n });\n }}\n marginRight={1}\n >\n <ArrowLeft />\n </IconButton>\n <Typography tag=\"span\" fontWeight={600}>\n {isCreating\n ? formatMessage({\n id: 'content-manager.relation.create',\n defaultMessage: 'Create a relation',\n })\n : formatMessage({\n id: 'content-manager.components.RelationInputModal.modal-title',\n defaultMessage: 'Edit a relation',\n })}\n </Typography>\n </Flex>\n <IconButton\n onClick={() => {\n dispatch({\n type: 'GO_FULL_PAGE',\n });\n if (!state.hasUnsavedChanges) {\n if (isCreating) {\n navigate(generateCreateUrl(currentDocumentMeta));\n } else {\n navigate(getFullPageUrl(currentDocumentMeta));\n }\n }\n }}\n variant=\"tertiary\"\n label={formatMessage({\n id: 'content-manager.components.RelationInputModal.button-fullpage',\n defaultMessage: 'Go to entry',\n })}\n >\n <ArrowsOut />\n </IconButton>\n </Flex>\n </Modal.Header>\n <Modal.Body>\n <FormContext\n method={isCreating ? 'POST' : 'PUT'}\n initialValues={initialValues}\n validate={(values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(\n currentDocument.schema?.attributes,\n currentDocument.components,\n {\n status: currentDocument.document?.status,\n ...options,\n }\n );\n\n return yupSchema.validate(values, { abortEarly: false });\n }}\n >\n <RelationModalBody />\n </FormContext>\n </Modal.Body>\n </StyledModalContent>\n </Modal.Root>\n </ComponentProvider>\n );\n};\n/**\n * All the main content (not header and footer) of the relation modal, plus the confirmation dialog.\n * Will be wrapped in a Modal.Body by the RelationModal component.\n * Cannot be moved directly inside RelationModal because it needs access to the context via hooks.\n */\nconst RelationModalBody = () => {\n const navigate = useNavigate();\n const { pathname, search } = useLocation();\n const { formatMessage } = useIntl();\n\n const [triggerRefetchDocument] = useLazyGetDocumentQuery();\n\n const state = useRelationModal('RelationModalForm', (state) => state.state);\n const dispatch = useRelationModal('RelationModalForm', (state) => state.dispatch);\n const rootDocumentMeta = useRelationModal('RelationModalForm', (state) => state.rootDocumentMeta);\n const currentDocumentMeta = useRelationModal(\n 'RelationModalForm',\n (state) => state.currentDocumentMeta\n );\n const isCreating = useRelationModal('RelationModalForm', (state) => state.isCreating);\n\n /**\n * One-way sync the modified state from the form to the modal state.\n * It is needed because we need to consume state from the form context in order to lift it up\n * into the modal context. It is not possible otherwise because the modal needs the form state,\n * but it must be a parent of the form.\n */\n const modified = useForm('FormWatcher', (state) => state.modified);\n const isSubmitting = useForm('FormWatcher', (state) => state.isSubmitting);\n const hasUnsavedChanges = modified && !isSubmitting;\n React.useEffect(() => {\n dispatch({ type: 'SET_HAS_UNSAVED_CHANGES', payload: { hasUnsavedChanges } });\n }, [hasUnsavedChanges, dispatch]);\n\n const handleCloseModal = (shouldBypassConfirmation: boolean) => {\n dispatch({ type: 'CLOSE_MODAL', payload: { shouldBypassConfirmation } });\n\n if (shouldBypassConfirmation || !state.hasUnsavedChanges) {\n // TODO: check if we can avoid this by relying on RTK invalidatesTags.\n // If so we can delete this function and dispatch the events directly\n triggerRefetchDocument(\n // TODO check if params should be removed (as they were before)\n rootDocumentMeta,\n // Favor the cache\n true\n );\n }\n };\n\n const handleRedirection = () => {\n const editViewUrl = `${pathname}${search}`;\n const fullPageUrl = getFullPageUrl(currentDocumentMeta);\n const isRootDocumentUrl = editViewUrl.includes(fullPageUrl);\n\n if (isRootDocumentUrl) {\n handleCloseModal(true);\n } else {\n if (isCreating) {\n navigate(generateCreateUrl(currentDocumentMeta));\n } else {\n navigate(fullPageUrl);\n }\n }\n };\n\n const handleConfirm = () => {\n if (state.confirmDialogIntent === null) {\n return;\n }\n if (state.confirmDialogIntent === 'navigate') {\n handleRedirection();\n } else if (state.confirmDialogIntent === 'back') {\n dispatch({ type: 'GO_BACK', payload: { shouldBypassConfirmation: true } });\n } else if (state.confirmDialogIntent === 'close') {\n handleCloseModal(true);\n } else if ('documentId' in state.confirmDialogIntent) {\n dispatch({\n type: 'GO_TO_RELATION',\n payload: {\n document: state.confirmDialogIntent,\n shouldBypassConfirmation: true,\n fieldToConnect: state.fieldToConnect,\n fieldToConnectUID: state.fieldToConnectUID,\n getParentFormValues: state.getParentFormValues,\n setParentFormValue: state.setParentFormValue,\n },\n });\n }\n };\n\n return (\n <>\n <RelationModalForm />\n <Dialog.Root open={state.confirmDialogIntent != null}>\n <ConfirmDialog\n onConfirm={() => handleConfirm()}\n onCancel={() => dispatch({ type: 'CANCEL_CONFIRM_DIALOG' })}\n variant=\"danger\"\n >\n {formatMessage({\n id: 'content-manager.components.RelationInputModal.confirmation-message',\n defaultMessage:\n 'Some changes were not saved. Are you sure you want to close this relation? All changes that were not saved will be lost.',\n })}\n </ConfirmDialog>\n </Dialog.Root>\n </>\n );\n};\n\nconst RelationModalTrigger = ({\n children,\n relation,\n}: {\n children: React.ReactNode;\n relation: DocumentMeta;\n}) => {\n const dispatch = useRelationModal('ModalTrigger', (state) => state.dispatch);\n const relationOpenMode = useRelationModal('ModalTrigger', (state) => state.relationOpenMode);\n\n const fullPageUrl = getFullPageUrl(relation);\n\n if (relationOpenMode === 'newTab') {\n return (\n <StyledRelationLink to={fullPageUrl} target=\"_blank\" rel=\"noopener noreferrer\">\n {children}\n </StyledRelationLink>\n );\n }\n\n if (relationOpenMode === 'page') {\n return <StyledRelationLink to={fullPageUrl}>{children}</StyledRelationLink>;\n }\n\n return (\n <StyledTextButton\n onClick={() =>\n dispatch({\n type: 'GO_TO_RELATION',\n payload: { document: relation, shouldBypassConfirmation: false },\n })\n }\n >\n {children}\n </StyledTextButton>\n );\n};\n\nconst StyledTextButton = styled(TextButton)`\n max-width: 100%;\n & > span {\n font-size: ${({ theme }) => theme.fontSizes[2]};\n width: inherit;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n`;\n\nconst StyledRelationLink = styled(RouterLink)`\n max-width: 100%;\n font-size: ${({ theme }) => theme.fontSizes[2]};\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n display: block;\n color: ${({ theme }) => theme.colors.primary600};\n text-decoration: none;\n\n &:hover,\n &:focus {\n color: ${({ theme }) => theme.colors.primary700};\n text-decoration: underline;\n }\n`;\n\n/**\n * The mini edit view for a relation that is displayed inside a modal.\n * It's complete with its header, document actions and form layout.\n */\nconst RelationModalForm = () => {\n const { formatMessage } = useIntl();\n\n const currentDocumentMeta = useRelationModal(\n 'RelationModalForm',\n (state) => state.currentDocumentMeta\n );\n const isCreating = useRelationModal('RelationModalForm', (state) => state.isCreating);\n const currentDocument = useRelationModal('RelationModalForm', (state) => state.currentDocument);\n const documentLayoutResponse = useDocumentLayout(currentDocumentMeta.model);\n const plugins = useStrapiApp('RelationModalForm', (state) => state.plugins);\n\n const initialValues = isCreating\n ? currentDocument.getInitialFormValues(isCreating)\n : currentDocument.getInitialFormValues();\n\n const {\n permissions = [],\n isLoading: isLoadingPermissions,\n error,\n } = useRBAC(\n PERMISSIONS.map((action) => ({\n action,\n subject: currentDocumentMeta.model,\n }))\n );\n\n const isLoading =\n isLoadingPermissions || documentLayoutResponse.isLoading || currentDocument.isLoading;\n\n if (isLoading && !currentDocument.document?.documentId) {\n return (\n <Loader small>\n {formatMessage({\n id: 'content-manager.ListViewTable.relation-loading',\n defaultMessage: 'Relations are loading',\n })}\n </Loader>\n );\n }\n\n if (\n error ||\n !currentDocumentMeta.model ||\n documentLayoutResponse.error ||\n (!isCreating && !currentDocument.document) ||\n (!isCreating && !currentDocument.meta) ||\n !currentDocument.schema ||\n !initialValues\n ) {\n return (\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 />\n </Flex>\n );\n }\n\n const documentTitle = currentDocument.getTitle(documentLayoutResponse.edit.settings.mainField);\n const hasDraftAndPublished = currentDocument.schema?.options?.draftAndPublish ?? false;\n\n const props = {\n activeTab: 'draft',\n collectionType: currentDocumentMeta.collectionType,\n model: currentDocumentMeta.model,\n documentId: currentDocumentMeta.documentId,\n document: currentDocument.document,\n meta: currentDocument.meta,\n } satisfies DocumentActionProps;\n\n return (\n <DocumentRBAC permissions={permissions} model={currentDocumentMeta.model}>\n <RelationModalFormBody\n currentDocument={currentDocument}\n documentTitle={documentTitle}\n hasDraftAndPublished={hasDraftAndPublished}\n layout={documentLayoutResponse.edit.layout}\n plugins={plugins}\n props={props}\n />\n </DocumentRBAC>\n );\n};\n\ninterface RelationModalFormBodyProps {\n currentDocument: ReturnType<UseDocument>;\n documentTitle: string;\n hasDraftAndPublished: boolean;\n layout: FormLayoutProps['layout'];\n plugins: StrapiAppContextValue['plugins'];\n props: DocumentActionProps;\n}\n\n/**\n * Rendered as the child of `DocumentRBAC` so it can wait on `useDocumentRBAC`'s `isLoading`\n * before showing the document actions and form — otherwise fields briefly render as\n * not-allowed while permissions are still resolving.\n */\nconst RelationModalFormBody = ({\n currentDocument,\n documentTitle,\n hasDraftAndPublished,\n layout,\n plugins,\n props,\n}: RelationModalFormBodyProps) => {\n const { formatMessage } = useIntl();\n const isLoadingActionsRBAC = useDocumentRBAC('RelationModalFormBody', (state) => state.isLoading);\n\n if (isLoadingActionsRBAC) {\n return (\n <Loader small>\n {formatMessage({\n id: 'content-manager.ListViewTable.relation-loading',\n defaultMessage: 'Relations are loading',\n })}\n </Loader>\n );\n }\n\n return (\n <>\n <Flex alignItems=\"flex-start\" direction=\"column\" gap={2}>\n <Flex width=\"100%\" justifyContent=\"space-between\" gap={2}>\n <Typography tag=\"h2\" variant=\"alpha\">\n {documentTitle}\n </Typography>\n <Flex gap={2}>\n <DescriptionComponentRenderer\n props={props}\n descriptions={(\n plugins['content-manager'].apis as ContentManagerPlugin['config']['apis']\n ).getDocumentActions('relation-modal')}\n >\n {(actions) => {\n const filteredActions = actions.filter((action) => {\n return [action.position].flat().includes('relation-modal');\n });\n const [primaryAction, secondaryAction] = filteredActions;\n\n if (!primaryAction && !secondaryAction) return null;\n\n // Both actions are available when draft and publish enabled\n if (primaryAction && secondaryAction) {\n return (\n <>\n {/* Save */}\n <DocumentActionButton\n {...secondaryAction}\n variant={secondaryAction.variant || 'secondary'}\n />\n {/* Publish */}\n <DocumentActionButton\n {...primaryAction}\n variant={primaryAction.variant || 'default'}\n />\n </>\n );\n }\n\n // Otherwise we just have the save action\n return (\n <DocumentActionButton\n {...primaryAction}\n variant={primaryAction.variant || 'secondary'}\n />\n );\n }}\n </DescriptionComponentRenderer>\n </Flex>\n </Flex>\n {hasDraftAndPublished ? (\n <Box>\n <DocumentStatus status={currentDocument.document?.status} />\n </Box>\n ) : null}\n </Flex>\n\n <Flex flex={1} overflow=\"auto\" alignItems=\"stretch\" paddingTop={7}>\n <Box overflow=\"auto\" flex={1}>\n <FormLayout layout={layout} document={currentDocument} hasBackground={false} />\n </Box>\n </Flex>\n </>\n );\n};\n\nexport {\n reducer,\n RelationModalRenderer,\n useRelationModal,\n isAnyRelationModalOpen,\n getFullPageUrl,\n generateCreateUrl,\n prefillParentRelation,\n RelationModalFormBody,\n};\nexport type { State, Action, RelationOpenMode, PendingConnectPatch, RelationModalFormBodyProps };\n"],"names":["getCollectionType","url","regex","RegExp","COLLECTION_TYPES","SINGLE_TYPES","match","undefined","StyledModalContent","styled","Modal","Content","getFullPageUrl","currentDocumentMeta","isSingleType","collectionType","queryParams","params","locale","model","documentId","getDocumentHistoryKey","meta","EMPTY_PENDING_CONNECTS","reducer","state","action","type","hasUnsavedChanges","payload","shouldBypassConfirmation","confirmDialogIntent","document","fieldToConnect","fieldToConnectUID","getParentFormValues","setParentFormValue","lastItemDocumentHistory","documentHistory","at","hasToResetDocumentHistory","isModalOpen","slice","pendingConnects","nestedParentMeta","length","connectPatch","key","documentMeta","openRelationModalCount","isAnyRelationModalOpen","RelationModalProvider","useRelationModal","createContext","isRenderProp","children","RootRelationRenderer","props","dispatch","React","useReducer","rootDocument","useDoc","query","useQueryParams","useMemo","buildValidParams","rootDocumentMeta","documentLayoutResponse","useDocumentLayout","relationOpenMode","edit","settings","currentDocument","useDocument","isCreating","useEffect","_jsx","RelationModal","relation","RelationModalTrigger","NestedRelationRenderer","RelationModalRenderer","isNested","generateCreateUrl","prefillParentRelation","initialValues","childSchema","parentDocument","parentModel","parentFieldName","inverseField","Object","entries","attributes","find","attribute","target","inversedBy","mappedBy","id","connect","fromEntries","filter","value","includes","apiData","isTemporary","__temp_key__","generateNKeysBetween","disconnect","formatMessage","useIntl","navigate","useNavigate","parentDocumentMeta","skip","pendingConnectsForCurrent","baseInitialValues","getInitialFormValues","schema","reduce","values","patch","withRelation","setIn","relationValue","componentUIDPath","componentUID","ComponentProvider","level","uid","_jsxs","Root","open","onOpenChange","Header","gap","Flex","justifyContent","alignItems","width","IconButton","withTooltip","label","defaultMessage","variant","disabled","onClick","marginRight","ArrowLeft","Typography","tag","fontWeight","ArrowsOut","Body","FormContext","method","validate","options","yupSchema","createYupSchema","components","status","abortEarly","RelationModalBody","pathname","search","useLocation","triggerRefetchDocument","useLazyGetDocumentQuery","modified","useForm","isSubmitting","handleCloseModal","handleRedirection","editViewUrl","fullPageUrl","isRootDocumentUrl","handleConfirm","_Fragment","RelationModalForm","Dialog","ConfirmDialog","onConfirm","onCancel","StyledRelationLink","to","rel","StyledTextButton","TextButton","theme","fontSizes","RouterLink","colors","primary600","primary700","plugins","useStrapiApp","permissions","isLoading","isLoadingPermissions","error","useRBAC","PERMISSIONS","map","subject","Loader","small","height","EmptyStateLayout","icon","WarningCircle","content","documentTitle","getTitle","mainField","hasDraftAndPublished","draftAndPublish","activeTab","DocumentRBAC","RelationModalFormBody","layout","isLoadingActionsRBAC","useDocumentRBAC","direction","DescriptionComponentRenderer","descriptions","apis","getDocumentActions","actions","filteredActions","position","flat","primaryAction","secondaryAction","DocumentActionButton","Box","DocumentStatus","flex","overflow","paddingTop","FormLayout","hasBackground"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiDO,SAASA,kBAAkBC,GAAW,EAAA;IAC3C,MAAMC,KAAAA,GAAQ,IAAIC,MAAAA,CAAO,CAAC,CAAC,EAAEC,gBAAAA,CAAiB,CAAC,EAAEC,YAAAA,CAAa,CAAC,CAAC,CAAA;IAChE,MAAMC,KAAAA,GAAQL,GAAAA,CAAIK,KAAK,CAACJ,KAAAA,CAAAA;AACxB,IAAA,OAAOI,KAAAA,GAAQA,KAAK,CAAC,CAAA,CAAE,GAAGC,SAAAA;AAC5B;AAEA,MAAMC,kBAAAA,GAAqBC,MAAAA,CAAOC,KAAAA,CAAMC,OAAO,CAAC;;;;;AAKhD,CAAC;AAED,MAAMC,iBAAiB,CAACC,mBAAAA,GAAAA;IACtB,MAAMC,YAAAA,GAAeD,mBAAAA,CAAoBE,cAAc,KAAKV,YAAAA;AAC5D,IAAA,MAAMW,WAAAA,GAAcH,mBAAAA,CAAoBI,MAAM,E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AY,CAAA;AAC9D,gBAAA,QAAA,gBAAApK,GAAA,CAACgK,GAAAA,EAAAA;oBAAIG,QAAAA,EAAS,MAAA;oBAAOD,IAAAA,EAAM,CAAA;AACzB,oBAAA,QAAA,gBAAAlK,GAAA,CAACqK,UAAAA,EAAAA;wBAAWpB,MAAAA,EAAQA,MAAAA;wBAAQ9L,QAAAA,EAAUyC,eAAAA;wBAAiB0K,aAAAA,EAAe;;;;;;AAKhF;;;;"}
|
|
1
|
+
{"version":3,"file":"RelationModal.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n ConfirmDialog,\n DescriptionComponentRenderer,\n Form as FormContext,\n useRBAC,\n useStrapiApp,\n createContext,\n useForm,\n useQueryParams,\n type StrapiAppContextValue,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Dialog,\n EmptyStateLayout,\n Flex,\n IconButton,\n Loader,\n Modal,\n Typography,\n TextButton,\n} from '@strapi/design-system';\nimport { ArrowLeft, ArrowsOut, WarningCircle } from '@strapi/icons';\nimport { generateNKeysBetween } from 'fractional-indexing';\nimport { useIntl } from 'react-intl';\nimport { Link as RouterLink, useLocation, useNavigate } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { COLLECTION_TYPES, SINGLE_TYPES } from '../../../../../constants/collections';\nimport { PERMISSIONS } from '../../../../../constants/plugin';\nimport { DocumentRBAC, useDocumentRBAC } from '../../../../../features/DocumentRBAC';\nimport { useDoc, useDocument, type UseDocument } from '../../../../../hooks/useDocument';\nimport { type DocumentMeta } from '../../../../../hooks/useDocumentContext';\nimport { useDocumentLayout } from '../../../../../hooks/useDocumentLayout';\nimport { useLazyGetDocumentQuery } from '../../../../../services/documents';\nimport { buildValidParams } from '../../../../../utils/api';\nimport { setIn } from '../../../../../utils/objects';\nimport { createYupSchema } from '../../../../../utils/validation';\nimport { DocumentActionButton } from '../../../components/DocumentActions';\nimport { DocumentStatus } from '../../DocumentStatus';\nimport { FormLayout, type FormLayoutProps } from '../../FormLayout';\nimport { ComponentProvider } from '../ComponentContext';\n\nimport type { RelationOpenMode } from '../../../../../../../shared/contracts/content-types';\nimport type { ContentManagerPlugin, DocumentActionProps } from '../../../../../content-manager';\nimport type { AnyData } from '../../../utils/data';\n\nexport function getCollectionType(url: string) {\n const regex = new RegExp(`(${COLLECTION_TYPES}|${SINGLE_TYPES})`);\n const match = url.match(regex);\n return match ? match[1] : undefined;\n}\n\nconst StyledModalContent = styled(Modal.Content)`\n width: 90%;\n max-width: 100%;\n height: 90%;\n max-height: 100%;\n`;\n\nconst getFullPageUrl = (currentDocumentMeta: DocumentMeta): string => {\n const isSingleType = currentDocumentMeta.collectionType === SINGLE_TYPES;\n const queryParams = currentDocumentMeta.params?.locale\n ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}`\n : '';\n\n return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}${isSingleType ? '' : '/' + currentDocumentMeta.documentId}${queryParams}`;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * RelationModalRenderer\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * A local \"connect\" edit waiting to be applied to a document that isn't the modal's current one.\n * Needed because every level of a nested relation-on-the-fly chain (root document aside) shares\n * one Form instance whose values get wholesale-replaced by fresh initialValues on every\n * `documentHistory` navigation — writing the field directly while a different level is current\n * would land on the wrong document and then immediately be discarded. Instead the patch is stashed\n * here, keyed by the target document, and merged back into that document's initialValues once it\n * becomes current again (see `RelationModal`'s `initialValues` below).\n */\ninterface PendingConnectPatch {\n fieldToConnect: string;\n relationValue: AnyData;\n componentUIDPath?: string;\n componentUID?: string;\n}\n\nconst getDocumentHistoryKey = (meta: Pick<DocumentMeta, 'model' | 'documentId'>) =>\n `${meta.model}::${meta.documentId}`;\n\nconst EMPTY_PENDING_CONNECTS: PendingConnectPatch[] = [];\n\ninterface State {\n documentHistory: DocumentMeta[];\n confirmDialogIntent:\n | null // No dialog\n | 'close' // Close the modal\n | 'back' // Go back one document in the modal's history\n | 'navigate' // Open the document in the edit view instead of in the modal\n | DocumentMeta; // Open a specific document in the modal\n isModalOpen: boolean;\n hasUnsavedChanges: boolean;\n fieldToConnect?: string;\n fieldToConnectUID?: string;\n getParentFormValues?: () => AnyData;\n // Sets a field directly on the parent's own (live, unsaved) form state, so connecting a\n // newly-created relation doesn't require persisting the whole parent document to the server.\n setParentFormValue?: (path: string, value: unknown) => void;\n pendingConnects: Record<string, PendingConnectPatch[]>;\n}\n\ntype Action =\n | {\n type: 'GO_TO_RELATION';\n payload: {\n document: DocumentMeta;\n shouldBypassConfirmation: boolean;\n fieldToConnect?: string;\n fieldToConnectUID?: string;\n getParentFormValues?: () => AnyData;\n setParentFormValue?: (path: string, value: unknown) => void;\n };\n }\n | {\n type: 'GO_BACK';\n payload: { shouldBypassConfirmation: boolean };\n }\n | {\n type: 'GO_FULL_PAGE';\n }\n | {\n type: 'GO_TO_CREATED_RELATION';\n payload: {\n document: DocumentMeta;\n shouldBypassConfirmation: boolean;\n // Present when the document being connected belongs to a NESTED parent (one still further\n // up `documentHistory`, not the root document) — see `pendingConnects` on `State`.\n connectPatch?: PendingConnectPatch;\n };\n }\n | {\n type: 'CANCEL_CONFIRM_DIALOG';\n }\n | {\n type: 'CLOSE_MODAL';\n payload: { shouldBypassConfirmation: boolean };\n }\n | {\n type: 'SET_HAS_UNSAVED_CHANGES';\n payload: { hasUnsavedChanges: boolean };\n }\n | {\n type: 'CLEAR_PENDING_CONNECTS';\n payload: { documentMeta: Pick<DocumentMeta, 'model' | 'documentId'> };\n };\n\nfunction reducer(state: State, action: Action): State {\n switch (action.type) {\n case 'GO_TO_RELATION':\n if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {\n return {\n ...state,\n confirmDialogIntent: action.payload.document,\n fieldToConnect: action.payload.fieldToConnect,\n fieldToConnectUID: action.payload.fieldToConnectUID,\n getParentFormValues: action.payload.getParentFormValues,\n setParentFormValue: action.payload.setParentFormValue,\n };\n }\n\n const lastItemDocumentHistory = state.documentHistory.at(-1);\n const hasToResetDocumentHistory =\n lastItemDocumentHistory && !lastItemDocumentHistory.documentId;\n return {\n ...state,\n // Reset document history if the last item has documentId undefined\n documentHistory: hasToResetDocumentHistory\n ? [action.payload.document]\n : [...state.documentHistory, action.payload.document],\n confirmDialogIntent: null,\n isModalOpen: true,\n fieldToConnect: hasToResetDocumentHistory ? undefined : action.payload.fieldToConnect,\n fieldToConnectUID: hasToResetDocumentHistory ? undefined : action.payload.fieldToConnectUID,\n getParentFormValues: hasToResetDocumentHistory\n ? undefined\n : action.payload.getParentFormValues,\n setParentFormValue: hasToResetDocumentHistory\n ? undefined\n : action.payload.setParentFormValue,\n };\n case 'GO_BACK':\n if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {\n return { ...state, confirmDialogIntent: 'back' };\n }\n\n return {\n ...state,\n documentHistory: state.documentHistory.slice(0, -1),\n confirmDialogIntent: null,\n };\n case 'GO_FULL_PAGE':\n if (state.hasUnsavedChanges) {\n return { ...state, confirmDialogIntent: 'navigate' };\n }\n\n return {\n ...state,\n documentHistory: [],\n hasUnsavedChanges: false,\n isModalOpen: false,\n confirmDialogIntent: null,\n pendingConnects: {},\n };\n case 'GO_TO_CREATED_RELATION': {\n // Anything beyond the second-to-last history entry is a nested parent still open further up\n // the stack — the root document (outside documentHistory entirely) is handled directly via\n // setParentFormValue instead, since its Form never gets replaced by modal navigation.\n const nestedParentMeta =\n state.documentHistory.length >= 2 ? state.documentHistory.at(-2) : undefined;\n const pendingConnects =\n nestedParentMeta && action.payload.connectPatch\n ? {\n ...state.pendingConnects,\n [getDocumentHistoryKey(nestedParentMeta)]: [\n ...(state.pendingConnects[getDocumentHistoryKey(nestedParentMeta)] ?? []),\n action.payload.connectPatch,\n ],\n }\n : state.pendingConnects;\n\n return {\n ...state,\n // Reset document history if the last item has documentId undefined\n documentHistory: state.documentHistory\n ? [...state.documentHistory.slice(0, -1), action.payload.document]\n : [action.payload.document],\n confirmDialogIntent: null,\n isModalOpen: true,\n fieldToConnect: undefined,\n fieldToConnectUID: undefined,\n getParentFormValues: undefined,\n setParentFormValue: undefined,\n pendingConnects,\n };\n }\n case 'CANCEL_CONFIRM_DIALOG':\n return {\n ...state,\n confirmDialogIntent: null,\n };\n case 'CLOSE_MODAL':\n if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {\n return { ...state, confirmDialogIntent: 'close' };\n }\n\n return {\n ...state,\n documentHistory: [],\n confirmDialogIntent: null,\n hasUnsavedChanges: false,\n isModalOpen: false,\n fieldToConnect: undefined,\n fieldToConnectUID: undefined,\n getParentFormValues: undefined,\n setParentFormValue: undefined,\n pendingConnects: {},\n };\n case 'SET_HAS_UNSAVED_CHANGES':\n return {\n ...state,\n hasUnsavedChanges: action.payload.hasUnsavedChanges,\n };\n case 'CLEAR_PENDING_CONNECTS': {\n const key = getDocumentHistoryKey(action.payload.documentMeta);\n\n if (!(key in state.pendingConnects)) {\n return state;\n }\n\n const pendingConnects = { ...state.pendingConnects };\n delete pendingConnects[key];\n\n return { ...state, pendingConnects };\n }\n default:\n return state;\n }\n}\n\n/**\n * Whether any relation-on-the-fly modal is currently open, anywhere on the page.\n *\n * The modal's React context (`RelationModalProvider`, below) only reaches the modal's own subtree\n * (the relation field that renders it), so components mounted outside that subtree — like the\n * background entry's save/publish buttons in the side panel — can't read `state.isModalOpen` from\n * context. This module-level counter is the cross-tree signal those components use instead, so\n * they can tell a relation modal is open and suppress their own keyboard shortcuts while it is.\n */\nlet openRelationModalCount = 0;\n\nconst isAnyRelationModalOpen = () => openRelationModalCount > 0;\n\ninterface RelationModalContextValue {\n state: State;\n dispatch: React.Dispatch<Action>;\n rootDocumentMeta: DocumentMeta;\n currentDocumentMeta: DocumentMeta;\n currentDocument: ReturnType<UseDocument>;\n onPreview?: () => void;\n isCreating: boolean;\n relationOpenMode: RelationOpenMode;\n}\n\nconst [RelationModalProvider, useRelationModal] =\n createContext<RelationModalContextValue>('RelationModal');\n\nfunction isRenderProp(\n children: RelationModalRendererProps['children']\n): children is (props: {\n dispatch: (action: Action) => void;\n relationOpenMode: RelationOpenMode;\n}) => React.ReactNode {\n return typeof children === 'function';\n}\n\ntype RelationModalRendererProps =\n // Is editing\n | {\n relation: DocumentMeta;\n children: React.ReactNode;\n }\n // Is creating\n | {\n relation?: never;\n children: (props: {\n dispatch: (action: Action) => void;\n relationOpenMode: RelationOpenMode;\n }) => React.ReactNode;\n };\n\nconst RootRelationRenderer = (props: RelationModalRendererProps) => {\n const { children } = props;\n\n const [state, dispatch] = React.useReducer(reducer, {\n documentHistory: [],\n confirmDialogIntent: null,\n isModalOpen: false,\n hasUnsavedChanges: false,\n fieldToConnect: undefined,\n pendingConnects: {},\n });\n\n const rootDocument = useDoc();\n const [{ query }] = useQueryParams();\n const params = React.useMemo(() => buildValidParams(query ?? {}), [query]);\n\n const rootDocumentMeta: DocumentMeta = {\n documentId: rootDocument.document?.documentId || '',\n model: rootDocument.model,\n collectionType: rootDocument.collectionType,\n params,\n };\n\n // Get the relationOpenMode setting from the current document's layout configuration\n const documentLayoutResponse = useDocumentLayout(rootDocument.model);\n const relationOpenMode: RelationOpenMode =\n documentLayoutResponse.edit?.settings?.relationOpenMode ?? 'modal';\n\n const currentDocumentMeta = state.documentHistory.at(-1) ?? rootDocumentMeta;\n const currentDocument = useDocument(currentDocumentMeta);\n // TODO: check if we can remove the single type check\n const isSingleType = currentDocumentMeta.collectionType === SINGLE_TYPES;\n const isCreating = !currentDocumentMeta.documentId && !isSingleType;\n\n const { isModalOpen } = state;\n React.useEffect(() => {\n if (!isModalOpen) {\n return;\n }\n\n openRelationModalCount += 1;\n\n return () => {\n openRelationModalCount -= 1;\n };\n }, [isModalOpen]);\n\n /**\n * There is no parent relation, so the relation modal doesn't exist. Create it and set up all the\n * pieces that will be used by potential child relations: the context, header, form, and footer.\n */\n return (\n <RelationModalProvider\n state={state}\n dispatch={dispatch}\n rootDocumentMeta={rootDocumentMeta}\n currentDocumentMeta={currentDocumentMeta}\n currentDocument={currentDocument}\n isCreating={isCreating}\n relationOpenMode={relationOpenMode}\n >\n <RelationModal>\n {isRenderProp(children)\n ? children({ dispatch, relationOpenMode })\n : props.relation && (\n <RelationModalTrigger relation={props.relation}>{children}</RelationModalTrigger>\n )}\n </RelationModal>\n </RelationModalProvider>\n );\n};\n\nconst NestedRelationRenderer = (props: RelationModalRendererProps) => {\n const { children } = props;\n const dispatch = useRelationModal('NestedRelation', (state) => state.dispatch);\n const relationOpenMode = useRelationModal('NestedRelation', (state) => state.relationOpenMode);\n\n return isRenderProp(children)\n ? children({ dispatch, relationOpenMode })\n : props.relation && (\n <RelationModalTrigger relation={props.relation}>{children}</RelationModalTrigger>\n ); /* This is the trigger that will be rendered in the parent relation */\n};\n\n/**\n * Component responsible for rendering its children wrapped in a modal, form and context if needed\n */\nconst RelationModalRenderer = (props: RelationModalRendererProps) => {\n // We're in a nested relation if the relation modal context is not undefined\n const isNested = useRelationModal('RelationContextWrapper', (state) => state != undefined, false);\n\n return isNested ? <NestedRelationRenderer {...props} /> : <RootRelationRenderer {...props} />;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * RelationModal\n * -----------------------------------------------------------------------------------------------*/\nconst generateCreateUrl = (currentDocumentMeta: DocumentMeta) => {\n return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}/create${\n currentDocumentMeta.params?.locale\n ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}`\n : ''\n }`;\n};\n\n/**\n * Pre-fill the inverse relation with the parent that opened create-on-the-fly.\n * One-way relations have no inverse; unsaved parents have no documentId.\n */\nconst prefillParentRelation = ({\n initialValues,\n fieldToConnect,\n childSchema,\n parentDocument,\n parentModel,\n}: {\n initialValues?: AnyData;\n fieldToConnect?: string;\n childSchema?: { attributes?: Record<string, unknown> };\n parentDocument?: Record<string, unknown>;\n parentModel?: string;\n}): AnyData | undefined => {\n const documentId = parentDocument?.documentId;\n // mappedBy/inversedBy names a top-level attribute, not a component path.\n const parentFieldName = fieldToConnect;\n\n if (!initialValues || typeof documentId !== 'string' || !documentId || !parentFieldName) {\n return initialValues;\n }\n\n const inverseField = Object.entries(childSchema?.attributes ?? {}).find(([, attribute]) => {\n const relation = attribute as {\n type?: string;\n target?: string;\n inversedBy?: string;\n mappedBy?: string;\n };\n\n return (\n relation.type === 'relation' &&\n relation.target === parentModel &&\n (relation.inversedBy === parentFieldName || relation.mappedBy === parentFieldName)\n );\n })?.[0];\n\n if (!inverseField) {\n return initialValues;\n }\n\n const id = parentDocument.id ?? documentId;\n\n return {\n ...initialValues,\n [inverseField]: {\n connect: [\n {\n ...Object.fromEntries(\n Object.entries(parentDocument).filter(\n ([, value]) =>\n value === null || ['string', 'number', 'boolean'].includes(typeof value)\n )\n ),\n id,\n documentId,\n apiData: {\n id,\n documentId,\n locale: parentDocument.locale,\n isTemporary: true,\n },\n __temp_key__: generateNKeysBetween(null, null, 1)[0],\n },\n ],\n disconnect: [],\n },\n };\n};\n\nconst RelationModal = ({ children }: { children: React.ReactNode }) => {\n const { formatMessage } = useIntl();\n const navigate = useNavigate();\n const state = useRelationModal('RelationModalForm', (state) => state.state);\n const dispatch = useRelationModal('RelationModalForm', (state) => state.dispatch);\n const currentDocumentMeta = useRelationModal(\n 'RelationModalForm',\n (state) => state.currentDocumentMeta\n );\n const currentDocument = useRelationModal('RelationModalForm', (state) => state.currentDocument);\n const isCreating = useRelationModal('RelationModalForm', (state) => state.isCreating);\n const rootDocumentMeta = useRelationModal('RelationModalForm', (state) => state.rootDocumentMeta);\n const parentDocumentMeta = state.documentHistory.at(-2) ?? rootDocumentMeta;\n const parentDocument = useDocument(parentDocumentMeta, {\n skip: !isCreating || !state.fieldToConnect,\n });\n\n const pendingConnectsForCurrent =\n useRelationModal(\n 'RelationModalForm',\n (state) => state.state.pendingConnects[getDocumentHistoryKey(currentDocumentMeta)],\n false\n ) ?? EMPTY_PENDING_CONNECTS;\n\n // Re-apply any local \"connect\" edits recorded for this document while a nested child was open,\n // since navigating here just replaced the Form's values with a fresh, patch-less snapshot.\n const initialValues = React.useMemo(() => {\n const baseInitialValues = prefillParentRelation({\n initialValues: currentDocument.getInitialFormValues(isCreating),\n fieldToConnect: isCreating ? state.fieldToConnect : undefined,\n childSchema: currentDocument.schema,\n parentDocument: parentDocument.document,\n parentModel: parentDocumentMeta.model,\n });\n\n // The document (and its default values) may still be loading, e.g. right after navigating\n // back to a document that now has a real documentId. Let the loading guard below handle it\n // instead of trying to patch a value that doesn't exist yet.\n if (!baseInitialValues) {\n return baseInitialValues;\n }\n\n return pendingConnectsForCurrent.reduce((values, patch) => {\n const withRelation = setIn(values, patch.fieldToConnect, patch.relationValue);\n\n return patch.componentUIDPath && patch.componentUID !== undefined\n ? setIn(withRelation, patch.componentUIDPath, patch.componentUID)\n : withRelation;\n }, baseInitialValues);\n }, [\n currentDocument,\n isCreating,\n state.fieldToConnect,\n parentDocument.document,\n parentDocumentMeta.model,\n pendingConnectsForCurrent,\n ]);\n\n /*\n * We must wrap the modal window with Component Provider with reset values\n * to avoid inheriting id and uid from the root document and having weird\n * behaviors with simple relationships..\n */\n return (\n <ComponentProvider id={undefined} level={-1} uid={undefined} type={undefined}>\n <Modal.Root\n open={state.isModalOpen}\n onOpenChange={(open) => {\n if (!open) {\n dispatch({\n type: 'CLOSE_MODAL',\n payload: { shouldBypassConfirmation: false },\n });\n }\n }}\n >\n {children}\n <StyledModalContent>\n <Modal.Header gap={2}>\n <Flex justifyContent=\"space-between\" alignItems=\"center\" width=\"100%\">\n <Flex gap={2}>\n <IconButton\n withTooltip={false}\n label={formatMessage({ id: 'global.back', defaultMessage: 'Back' })}\n variant=\"ghost\"\n disabled={state.documentHistory.length < 2}\n onClick={() => {\n dispatch({\n type: 'GO_BACK',\n payload: { shouldBypassConfirmation: false },\n });\n }}\n marginRight={1}\n >\n <ArrowLeft />\n </IconButton>\n <Typography tag=\"span\" fontWeight={600}>\n {isCreating\n ? formatMessage({\n id: 'content-manager.relation.create',\n defaultMessage: 'Create a relation',\n })\n : formatMessage({\n id: 'content-manager.components.RelationInputModal.modal-title',\n defaultMessage: 'Edit a relation',\n })}\n </Typography>\n </Flex>\n <IconButton\n onClick={() => {\n dispatch({\n type: 'GO_FULL_PAGE',\n });\n if (!state.hasUnsavedChanges) {\n if (isCreating) {\n navigate(generateCreateUrl(currentDocumentMeta));\n } else {\n navigate(getFullPageUrl(currentDocumentMeta));\n }\n }\n }}\n variant=\"tertiary\"\n label={formatMessage({\n id: 'content-manager.components.RelationInputModal.button-fullpage',\n defaultMessage: 'Go to entry',\n })}\n >\n <ArrowsOut />\n </IconButton>\n </Flex>\n </Modal.Header>\n <Modal.Body>\n <FormContext\n method={isCreating ? 'POST' : 'PUT'}\n initialValues={initialValues}\n validate={(values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(\n currentDocument.schema?.attributes,\n currentDocument.components,\n {\n status: currentDocument.document?.status,\n ...options,\n }\n );\n\n return yupSchema.validate(values, { abortEarly: false });\n }}\n >\n <RelationModalBody />\n </FormContext>\n </Modal.Body>\n </StyledModalContent>\n </Modal.Root>\n </ComponentProvider>\n );\n};\n/**\n * All the main content (not header and footer) of the relation modal, plus the confirmation dialog.\n * Will be wrapped in a Modal.Body by the RelationModal component.\n * Cannot be moved directly inside RelationModal because it needs access to the context via hooks.\n */\nconst RelationModalBody = () => {\n const navigate = useNavigate();\n const { pathname, search } = useLocation();\n const { formatMessage } = useIntl();\n\n const [triggerRefetchDocument] = useLazyGetDocumentQuery();\n\n const state = useRelationModal('RelationModalForm', (state) => state.state);\n const dispatch = useRelationModal('RelationModalForm', (state) => state.dispatch);\n const rootDocumentMeta = useRelationModal('RelationModalForm', (state) => state.rootDocumentMeta);\n const currentDocumentMeta = useRelationModal(\n 'RelationModalForm',\n (state) => state.currentDocumentMeta\n );\n const isCreating = useRelationModal('RelationModalForm', (state) => state.isCreating);\n\n /**\n * One-way sync the modified state from the form to the modal state.\n * It is needed because we need to consume state from the form context in order to lift it up\n * into the modal context. It is not possible otherwise because the modal needs the form state,\n * but it must be a parent of the form.\n */\n const modified = useForm('FormWatcher', (state) => state.modified);\n const isSubmitting = useForm('FormWatcher', (state) => state.isSubmitting);\n const hasUnsavedChanges = modified && !isSubmitting;\n React.useEffect(() => {\n dispatch({ type: 'SET_HAS_UNSAVED_CHANGES', payload: { hasUnsavedChanges } });\n }, [hasUnsavedChanges, dispatch]);\n\n const handleCloseModal = (shouldBypassConfirmation: boolean) => {\n dispatch({ type: 'CLOSE_MODAL', payload: { shouldBypassConfirmation } });\n\n if (shouldBypassConfirmation || !state.hasUnsavedChanges) {\n // TODO: check if we can avoid this by relying on RTK invalidatesTags.\n // If so we can delete this function and dispatch the events directly\n triggerRefetchDocument(\n // TODO check if params should be removed (as they were before)\n rootDocumentMeta,\n // Favor the cache\n true\n );\n }\n };\n\n const handleRedirection = () => {\n const editViewUrl = `${pathname}${search}`;\n const fullPageUrl = getFullPageUrl(currentDocumentMeta);\n const isRootDocumentUrl = editViewUrl.includes(fullPageUrl);\n\n if (isRootDocumentUrl) {\n handleCloseModal(true);\n } else {\n if (isCreating) {\n navigate(generateCreateUrl(currentDocumentMeta));\n } else {\n navigate(fullPageUrl);\n }\n }\n };\n\n const handleConfirm = () => {\n if (state.confirmDialogIntent === null) {\n return;\n }\n if (state.confirmDialogIntent === 'navigate') {\n handleRedirection();\n } else if (state.confirmDialogIntent === 'back') {\n dispatch({ type: 'GO_BACK', payload: { shouldBypassConfirmation: true } });\n } else if (state.confirmDialogIntent === 'close') {\n handleCloseModal(true);\n } else if ('documentId' in state.confirmDialogIntent) {\n dispatch({\n type: 'GO_TO_RELATION',\n payload: {\n document: state.confirmDialogIntent,\n shouldBypassConfirmation: true,\n fieldToConnect: state.fieldToConnect,\n fieldToConnectUID: state.fieldToConnectUID,\n getParentFormValues: state.getParentFormValues,\n setParentFormValue: state.setParentFormValue,\n },\n });\n }\n };\n\n return (\n <>\n <RelationModalForm />\n <Dialog.Root open={state.confirmDialogIntent != null}>\n <ConfirmDialog\n onConfirm={() => handleConfirm()}\n onCancel={() => dispatch({ type: 'CANCEL_CONFIRM_DIALOG' })}\n variant=\"danger\"\n >\n {formatMessage({\n id: 'content-manager.components.RelationInputModal.confirmation-message',\n defaultMessage:\n 'Some changes were not saved. Are you sure you want to close this relation? All changes that were not saved will be lost.',\n })}\n </ConfirmDialog>\n </Dialog.Root>\n </>\n );\n};\n\nconst RelationModalTrigger = ({\n children,\n relation,\n}: {\n children: React.ReactNode;\n relation: DocumentMeta;\n}) => {\n const dispatch = useRelationModal('ModalTrigger', (state) => state.dispatch);\n const relationOpenMode = useRelationModal('ModalTrigger', (state) => state.relationOpenMode);\n\n const fullPageUrl = getFullPageUrl(relation);\n\n if (relationOpenMode === 'newTab') {\n return (\n <StyledRelationLink to={fullPageUrl} target=\"_blank\" rel=\"noopener noreferrer\">\n {children}\n </StyledRelationLink>\n );\n }\n\n if (relationOpenMode === 'page') {\n return <StyledRelationLink to={fullPageUrl}>{children}</StyledRelationLink>;\n }\n\n return (\n <StyledTextButton\n onClick={() =>\n dispatch({\n type: 'GO_TO_RELATION',\n payload: { document: relation, shouldBypassConfirmation: false },\n })\n }\n >\n {children}\n </StyledTextButton>\n );\n};\n\nconst StyledTextButton = styled(TextButton)`\n max-width: 100%;\n & > span {\n font-size: ${({ theme }) => theme.fontSizes[2]};\n width: inherit;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n`;\n\nconst StyledRelationLink = styled(RouterLink)`\n max-width: 100%;\n font-size: ${({ theme }) => theme.fontSizes[2]};\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n display: block;\n color: ${({ theme }) => theme.colors.primary600};\n text-decoration: none;\n\n &:hover,\n &:focus {\n color: ${({ theme }) => theme.colors.primary700};\n text-decoration: underline;\n }\n`;\n\n/**\n * The mini edit view for a relation that is displayed inside a modal.\n * It's complete with its header, document actions and form layout.\n */\nconst RelationModalForm = () => {\n const { formatMessage } = useIntl();\n\n const currentDocumentMeta = useRelationModal(\n 'RelationModalForm',\n (state) => state.currentDocumentMeta\n );\n const isCreating = useRelationModal('RelationModalForm', (state) => state.isCreating);\n const currentDocument = useRelationModal('RelationModalForm', (state) => state.currentDocument);\n const documentLayoutResponse = useDocumentLayout(currentDocumentMeta.model);\n const plugins = useStrapiApp('RelationModalForm', (state) => state.plugins);\n\n const initialValues = isCreating\n ? currentDocument.getInitialFormValues(isCreating)\n : currentDocument.getInitialFormValues();\n\n const {\n permissions = [],\n isLoading: isLoadingPermissions,\n error,\n } = useRBAC(\n PERMISSIONS.map((action) => ({\n action,\n subject: currentDocumentMeta.model,\n }))\n );\n\n const isLoading =\n isLoadingPermissions || documentLayoutResponse.isLoading || currentDocument.isLoading;\n\n if (isLoading && !currentDocument.document?.documentId) {\n return (\n <Loader small>\n {formatMessage({\n id: 'content-manager.ListViewTable.relation-loading',\n defaultMessage: 'Relations are loading',\n })}\n </Loader>\n );\n }\n\n if (\n error ||\n !currentDocumentMeta.model ||\n documentLayoutResponse.error ||\n (!isCreating && !currentDocument.document) ||\n (!isCreating && !currentDocument.meta) ||\n !currentDocument.schema ||\n !initialValues\n ) {\n return (\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 />\n </Flex>\n );\n }\n\n const documentTitle = currentDocument.getTitle(documentLayoutResponse.edit.settings.mainField);\n const hasDraftAndPublished = currentDocument.schema?.options?.draftAndPublish ?? false;\n\n const props = {\n activeTab: 'draft',\n collectionType: currentDocumentMeta.collectionType,\n model: currentDocumentMeta.model,\n documentId: currentDocumentMeta.documentId,\n document: currentDocument.document,\n meta: currentDocument.meta,\n } satisfies DocumentActionProps;\n\n return (\n <DocumentRBAC permissions={permissions} model={currentDocumentMeta.model}>\n <RelationModalFormBody\n currentDocument={currentDocument}\n documentTitle={documentTitle}\n hasDraftAndPublished={hasDraftAndPublished}\n layout={documentLayoutResponse.edit.layout}\n plugins={plugins}\n props={props}\n />\n </DocumentRBAC>\n );\n};\n\ninterface RelationModalFormBodyProps {\n currentDocument: ReturnType<UseDocument>;\n documentTitle: string;\n hasDraftAndPublished: boolean;\n layout: FormLayoutProps['layout'];\n plugins: StrapiAppContextValue['plugins'];\n props: DocumentActionProps;\n}\n\n/**\n * Rendered as the child of `DocumentRBAC` so it can wait on `useDocumentRBAC`'s `isLoading`\n * before showing the document actions and form — otherwise fields briefly render as\n * not-allowed while permissions are still resolving.\n */\nconst RelationModalFormBody = ({\n currentDocument,\n documentTitle,\n hasDraftAndPublished,\n layout,\n plugins,\n props,\n}: RelationModalFormBodyProps) => {\n const { formatMessage } = useIntl();\n const isLoadingActionsRBAC = useDocumentRBAC('RelationModalFormBody', (state) => state.isLoading);\n\n if (isLoadingActionsRBAC) {\n return (\n <Loader small>\n {formatMessage({\n id: 'content-manager.ListViewTable.relation-loading',\n defaultMessage: 'Relations are loading',\n })}\n </Loader>\n );\n }\n\n return (\n <>\n <Flex alignItems=\"flex-start\" direction=\"column\" gap={2}>\n <Flex width=\"100%\" justifyContent=\"space-between\" gap={2}>\n <Typography tag=\"h2\" variant=\"alpha\">\n {documentTitle}\n </Typography>\n <Flex gap={2}>\n <DescriptionComponentRenderer\n props={props}\n descriptions={(\n plugins['content-manager'].apis as ContentManagerPlugin['config']['apis']\n ).getDocumentActions('relation-modal')}\n >\n {(actions) => {\n const filteredActions = actions.filter((action) => {\n return [action.position].flat().includes('relation-modal');\n });\n const [primaryAction, secondaryAction] = filteredActions;\n\n if (!primaryAction && !secondaryAction) return null;\n\n // Both actions are available when draft and publish enabled\n if (primaryAction && secondaryAction) {\n return (\n <>\n {/* Save */}\n <DocumentActionButton\n {...secondaryAction}\n variant={secondaryAction.variant || 'secondary'}\n />\n {/* Publish */}\n <DocumentActionButton\n {...primaryAction}\n variant={primaryAction.variant || 'default'}\n />\n </>\n );\n }\n\n // Otherwise we just have the save action\n return (\n <DocumentActionButton\n {...primaryAction}\n variant={primaryAction.variant || 'secondary'}\n />\n );\n }}\n </DescriptionComponentRenderer>\n </Flex>\n </Flex>\n {hasDraftAndPublished ? (\n <Box>\n <DocumentStatus status={currentDocument.document?.status} />\n </Box>\n ) : null}\n </Flex>\n\n <Flex flex={1} overflow=\"auto\" alignItems=\"stretch\" paddingTop={7}>\n <Box overflow=\"auto\" flex={1}>\n <FormLayout layout={layout} document={currentDocument} hasBackground={false} />\n </Box>\n </Flex>\n </>\n );\n};\n\nexport {\n reducer,\n RelationModalRenderer,\n useRelationModal,\n isAnyRelationModalOpen,\n getFullPageUrl,\n generateCreateUrl,\n prefillParentRelation,\n RelationModalFormBody,\n};\nexport type { State, Action, RelationOpenMode, PendingConnectPatch, RelationModalFormBodyProps };\n"],"names":["getCollectionType","url","regex","RegExp","COLLECTION_TYPES","SINGLE_TYPES","match","undefined","StyledModalContent","styled","Modal","Content","getFullPageUrl","currentDocumentMeta","isSingleType","collectionType","queryParams","params","locale","model","documentId","getDocumentHistoryKey","meta","EMPTY_PENDING_CONNECTS","reducer","state","action","type","hasUnsavedChanges","payload","shouldBypassConfirmation","confirmDialogIntent","document","fieldToConnect","fieldToConnectUID","getParentFormValues","setParentFormValue","lastItemDocumentHistory","documentHistory","at","hasToResetDocumentHistory","isModalOpen","slice","pendingConnects","nestedParentMeta","length","connectPatch","key","documentMeta","openRelationModalCount","isAnyRelationModalOpen","RelationModalProvider","useRelationModal","createContext","isRenderProp","children","RootRelationRenderer","props","dispatch","React","useReducer","rootDocument","useDoc","query","useQueryParams","useMemo","buildValidParams","rootDocumentMeta","documentLayoutResponse","useDocumentLayout","relationOpenMode","edit","settings","currentDocument","useDocument","isCreating","useEffect","_jsx","RelationModal","relation","RelationModalTrigger","NestedRelationRenderer","RelationModalRenderer","isNested","generateCreateUrl","prefillParentRelation","initialValues","childSchema","parentDocument","parentModel","parentFieldName","inverseField","Object","entries","attributes","find","attribute","target","inversedBy","mappedBy","id","connect","fromEntries","filter","value","includes","apiData","isTemporary","__temp_key__","generateNKeysBetween","disconnect","formatMessage","useIntl","navigate","useNavigate","parentDocumentMeta","skip","pendingConnectsForCurrent","baseInitialValues","getInitialFormValues","schema","reduce","values","patch","withRelation","setIn","relationValue","componentUIDPath","componentUID","ComponentProvider","level","uid","_jsxs","Root","open","onOpenChange","Header","gap","Flex","justifyContent","alignItems","width","IconButton","withTooltip","label","defaultMessage","variant","disabled","onClick","marginRight","ArrowLeft","Typography","tag","fontWeight","ArrowsOut","Body","FormContext","method","validate","options","yupSchema","createYupSchema","components","status","abortEarly","RelationModalBody","pathname","search","useLocation","triggerRefetchDocument","useLazyGetDocumentQuery","modified","useForm","isSubmitting","handleCloseModal","handleRedirection","editViewUrl","fullPageUrl","isRootDocumentUrl","handleConfirm","_Fragment","RelationModalForm","Dialog","ConfirmDialog","onConfirm","onCancel","StyledRelationLink","to","rel","StyledTextButton","TextButton","theme","fontSizes","RouterLink","colors","primary600","primary700","plugins","useStrapiApp","permissions","isLoading","isLoadingPermissions","error","useRBAC","PERMISSIONS","map","subject","Loader","small","height","EmptyStateLayout","icon","WarningCircle","content","documentTitle","getTitle","mainField","hasDraftAndPublished","draftAndPublish","activeTab","DocumentRBAC","RelationModalFormBody","layout","isLoadingActionsRBAC","useDocumentRBAC","direction","DescriptionComponentRenderer","descriptions","apis","getDocumentActions","actions","filteredActions","position","flat","primaryAction","secondaryAction","DocumentActionButton","Box","DocumentStatus","flex","overflow","paddingTop","FormLayout","hasBackground"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAiDO,SAASA,kBAAkBC,GAAW,EAAA;IAC3C,MAAMC,KAAAA,GAAQ,IAAIC,MAAAA,CAAO,CAAC,CAAC,EAAEC,gBAAAA,CAAiB,CAAC,EAAEC,YAAAA,CAAa,CAAC,CAAC,CAAA;IAChE,MAAMC,KAAAA,GAAQL,GAAAA,CAAIK,KAAK,CAACJ,KAAAA,C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,oBAAAA,oBAAAA,iBACC5I,GAAA,CAACgK,GAAAA,EAAAA;AACC,wBAAA,QAAA,gBAAAhK,GAAA,CAACiK,cAAAA,EAAAA;4BAAe3E,MAAAA,EAAQ1F,eAAAA,CAAgBzC,QAAQ,EAAEmI;;AAElD,qBAAA,CAAA,GAAA;;;0BAGNtF,GAAA,CAAC6D,IAAAA,EAAAA;gBAAKqG,IAAAA,EAAM,CAAA;gBAAGC,QAAAA,EAAS,MAAA;gBAAOpG,UAAAA,EAAW,SAAA;gBAAUqG,UAAAA,EAAY,CAAA;AAC9D,gBAAA,QAAA,gBAAApK,GAAA,CAACgK,GAAAA,EAAAA;oBAAIG,QAAAA,EAAS,MAAA;oBAAOD,IAAAA,EAAM,CAAA;AACzB,oBAAA,QAAA,gBAAAlK,GAAA,CAACqK,UAAAA,EAAAA;wBAAWpB,MAAAA,EAAQA,MAAAA;wBAAQ9L,QAAAA,EAAUyC,eAAAA;wBAAiB0K,aAAAA,EAAe;;;;;;AAKhF;;;;"}
|
|
@@ -19,6 +19,7 @@ var useDebounce = require('../../../../../hooks/useDebounce.js');
|
|
|
19
19
|
var useDocument = require('../../../../../hooks/useDocument.js');
|
|
20
20
|
var useDocumentContext = require('../../../../../hooks/useDocumentContext.js');
|
|
21
21
|
var useDragAndDrop = require('../../../../../hooks/useDragAndDrop.js');
|
|
22
|
+
var useHasBeenNearViewport = require('../../../../../hooks/useHasBeenNearViewport.js');
|
|
22
23
|
var relations = require('../../../../../services/relations.js');
|
|
23
24
|
var objects = require('../../../../../utils/objects.js');
|
|
24
25
|
var relations$1 = require('../../../../../utils/relations.js');
|
|
@@ -147,6 +148,13 @@ const EMPTY_RELATION_RESULTS = [];
|
|
|
147
148
|
* Since relations can exist in a modal on top of the root document,
|
|
148
149
|
* we need to ensure we are fetching relations for the correct document (root document vs related document),
|
|
149
150
|
*/ const isRelatedToCurrentDocument = Object.values(schemaAttributes).filter((attribute)=>attribute.type === 'relation' && 'target' in attribute && 'target' in props.attribute && attribute.target === props.attribute.target).length > 0;
|
|
151
|
+
const fieldRef = React__namespace.useRef(null);
|
|
152
|
+
const composedRefs = designSystem.useComposedRefs(ref, fieldRef);
|
|
153
|
+
/**
|
|
154
|
+
* A large content type can have hundreds of relation fields. Only fetch the relations of the
|
|
155
|
+
* fields the user can see (or is about to), instead of all of them on load and again after
|
|
156
|
+
* every save.
|
|
157
|
+
*/ const hasBeenNearViewport = useHasBeenNearViewport.useHasBeenNearViewport(fieldRef);
|
|
150
158
|
const { data, isLoading, isFetching, isError, refetch } = relations.useGetRelationsQuery({
|
|
151
159
|
model,
|
|
152
160
|
targetField,
|
|
@@ -159,8 +167,13 @@ const EMPTY_RELATION_RESULTS = [];
|
|
|
159
167
|
}
|
|
160
168
|
}, {
|
|
161
169
|
refetchOnMountOrArgChange: true,
|
|
162
|
-
skip: !id || !isRelatedToCurrentDocument
|
|
170
|
+
skip: !id || !isRelatedToCurrentDocument || !hasBeenNearViewport
|
|
163
171
|
});
|
|
172
|
+
/**
|
|
173
|
+
* Choosing a new entry for a single relation replaces the saved one, which `handleConnect`
|
|
174
|
+
* can only disconnect once it is loaded. Until then, the combobox stays disabled.
|
|
175
|
+
*/ const shouldLoadSavedRelations = Boolean(id) && isRelatedToCurrentDocument;
|
|
176
|
+
const isWaitingForSavedRelation = ONE_WAY_RELATIONS.has(props.attribute.relation) && shouldLoadSavedRelations && !data;
|
|
164
177
|
const handleLoadMore = ()=>{
|
|
165
178
|
/**
|
|
166
179
|
* The relations cache is shared by every instance of this field that targets the same
|
|
@@ -282,7 +295,7 @@ const EMPTY_RELATION_RESULTS = [];
|
|
|
282
295
|
targetModel
|
|
283
296
|
]);
|
|
284
297
|
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
|
285
|
-
ref:
|
|
298
|
+
ref: composedRefs,
|
|
286
299
|
direction: "column",
|
|
287
300
|
gap: 3,
|
|
288
301
|
justifyContent: "space-between",
|
|
@@ -296,7 +309,7 @@ const EMPTY_RELATION_RESULTS = [];
|
|
|
296
309
|
width: "100%",
|
|
297
310
|
children: [
|
|
298
311
|
/*#__PURE__*/ jsxRuntime.jsx(MemoizedRelationsComboboxInput, {
|
|
299
|
-
disabled: isDisabled,
|
|
312
|
+
disabled: isDisabled || isWaitingForSavedRelation,
|
|
300
313
|
// NOTE: we should not default to using the documentId if the component is being created (componentUID is undefined)
|
|
301
314
|
id: id,
|
|
302
315
|
label: `${label} ${relationsCount > 0 ? `(${relationsCount})` : ''}`,
|
|
@@ -391,10 +404,31 @@ const EMPTY_RELATION_RESULTS = [];
|
|
|
391
404
|
// @ts-expect-error – `targetModel` exists on supported non-morph relations (morph is disabled).
|
|
392
405
|
const targetModel = props.attribute.targetModel;
|
|
393
406
|
const searchParamsDebounced = useDebounce.useDebounce(searchParams, 300);
|
|
394
|
-
const [searchForTrigger, { data, isLoading, isError }] = relations.useLazySearchRelationsQuery();
|
|
407
|
+
const [searchForTrigger, { data, isLoading, isFetching, isError, error: searchError }] = relations.useLazySearchRelationsQuery();
|
|
408
|
+
// Refetching a failed search reports `isError: false` and `isLoading: true` until it settles.
|
|
409
|
+
// Keep showing the previous error meanwhile instead of flashing the loading state.
|
|
410
|
+
const isRetryingFailedSearch = isFetching && searchError !== undefined;
|
|
411
|
+
/**
|
|
412
|
+
* The options are only needed once the combobox has been opened. Searching when the field
|
|
413
|
+
* mounts would send one request per relation field of the document on load.
|
|
414
|
+
*/ const [hasBeenOpened, setHasBeenOpened] = React__namespace.useState(false);
|
|
415
|
+
const handleOpen = React__namespace.useCallback((search)=>{
|
|
416
|
+
if (!hasBeenOpened) {
|
|
417
|
+
// Enabling the search sends it: searching again here would send the same request twice.
|
|
418
|
+
setHasBeenOpened(true);
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
setSearchParams((params)=>({
|
|
422
|
+
...params,
|
|
423
|
+
_q: search,
|
|
424
|
+
page: 1
|
|
425
|
+
}));
|
|
426
|
+
}, [
|
|
427
|
+
hasBeenOpened
|
|
428
|
+
]);
|
|
395
429
|
/**
|
|
396
430
|
* Because we're using a lazy query, we need to trigger the search
|
|
397
|
-
* when the
|
|
431
|
+
* when the combobox is first opened and when the search params change.
|
|
398
432
|
* We also need to trigger the search when the field value changes
|
|
399
433
|
* so that we can filter out the relations that are already connected.
|
|
400
434
|
*/ React__namespace.useEffect(()=>{
|
|
@@ -405,7 +439,7 @@ const EMPTY_RELATION_RESULTS = [];
|
|
|
405
439
|
* individual components. Therefore we split the string and take the last item.
|
|
406
440
|
*/ const [targetField] = name.split('.').slice(-1);
|
|
407
441
|
// Return early if there is no relation to the document
|
|
408
|
-
if (!isRelatedToCurrentDocument) return;
|
|
442
|
+
if (!isRelatedToCurrentDocument || !hasBeenOpened) return;
|
|
409
443
|
searchForTrigger({
|
|
410
444
|
model,
|
|
411
445
|
targetField,
|
|
@@ -427,6 +461,7 @@ const EMPTY_RELATION_RESULTS = [];
|
|
|
427
461
|
searchForTrigger,
|
|
428
462
|
searchParamsDebounced,
|
|
429
463
|
isRelatedToCurrentDocument,
|
|
464
|
+
hasBeenOpened,
|
|
430
465
|
currentDocumentMeta.params
|
|
431
466
|
]);
|
|
432
467
|
const hasNextPage = data?.pagination ? data.pagination.page < data.pagination.pageCount : false;
|
|
@@ -513,10 +548,11 @@ const EMPTY_RELATION_RESULTS = [];
|
|
|
513
548
|
placeholder: placeholder,
|
|
514
549
|
hasNextPage: hasNextPage,
|
|
515
550
|
isLoadingPermissions: isLoadingPermissions,
|
|
516
|
-
isLoadingSearchRelations: isLoading,
|
|
517
|
-
isSearchRelationsError: isError,
|
|
551
|
+
isLoadingSearchRelations: isLoading && !isRetryingFailedSearch,
|
|
552
|
+
isSearchRelationsError: isError || isRetryingFailedSearch,
|
|
518
553
|
handleChange: handleChange,
|
|
519
554
|
setSearchParams: setSearchParams,
|
|
555
|
+
onOpen: handleOpen,
|
|
520
556
|
data: data,
|
|
521
557
|
mainField: mainField,
|
|
522
558
|
fieldValue: field.value,
|
|
@@ -529,7 +565,7 @@ const EMPTY_RELATION_RESULTS = [];
|
|
|
529
565
|
});
|
|
530
566
|
};
|
|
531
567
|
const MemoizedRelationsComboboxInput = /*#__PURE__*/ React__namespace.memo(RelationsInput);
|
|
532
|
-
const RelationModalWithContext = ({ relation, name, placeholder, hasNextPage, isLoadingSearchRelations, isSearchRelationsError, isLoadingPermissions, handleChange, mainField, setSearchParams, fieldValue, data, ...props })=>{
|
|
568
|
+
const RelationModalWithContext = ({ relation, name, placeholder, hasNextPage, isLoadingSearchRelations, isSearchRelationsError, isLoadingPermissions, handleChange, mainField, setSearchParams, onOpen, fieldValue, data, ...props })=>{
|
|
533
569
|
const [textValue, setTextValue] = React__namespace.useState('');
|
|
534
570
|
const { formatMessage } = reactIntl.useIntl();
|
|
535
571
|
const emptyLabel = formatMessage({
|
|
@@ -611,7 +647,7 @@ const RelationModalWithContext = ({ relation, name, placeholder, hasNextPage, is
|
|
|
611
647
|
// Selecting an option closes the list while `textValue` still holds its label.
|
|
612
648
|
// Searching on close would omit that option and cache an empty result.
|
|
613
649
|
if (isOpen) {
|
|
614
|
-
|
|
650
|
+
onOpen(textValue ?? '');
|
|
615
651
|
}
|
|
616
652
|
},
|
|
617
653
|
noOptionsMessage: ()=>isSearchRelationsError ? formatMessage({
|