@strapi/content-manager 5.55.1 → 5.57.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/components/ConfigurationForm/Form.js +3 -3
- package/dist/admin/components/ConfigurationForm/Form.js.map +1 -1
- package/dist/admin/components/ConfigurationForm/Form.mjs +2 -2
- package/dist/admin/components/ConfigurationForm/Form.mjs.map +1 -1
- package/dist/admin/components/RelativeTime.js +9 -0
- package/dist/admin/components/RelativeTime.js.map +1 -1
- package/dist/admin/components/RelativeTime.mjs +10 -1
- package/dist/admin/components/RelativeTime.mjs.map +1 -1
- package/dist/admin/features/DocumentRBAC.js +0 -3
- package/dist/admin/features/DocumentRBAC.js.map +1 -1
- package/dist/admin/features/DocumentRBAC.mjs +1 -4
- package/dist/admin/features/DocumentRBAC.mjs.map +1 -1
- package/dist/admin/history/components/VersionContent.js +3 -3
- package/dist/admin/history/components/VersionContent.js.map +1 -1
- package/dist/admin/history/components/VersionContent.mjs +2 -2
- package/dist/admin/history/components/VersionContent.mjs.map +1 -1
- package/dist/admin/history/pages/History.js +2 -1
- package/dist/admin/history/pages/History.js.map +1 -1
- package/dist/admin/history/pages/History.mjs +3 -2
- package/dist/admin/history/pages/History.mjs.map +1 -1
- package/dist/admin/pages/EditView/EditViewPage.js +2 -2
- package/dist/admin/pages/EditView/EditViewPage.js.map +1 -1
- package/dist/admin/pages/EditView/EditViewPage.mjs +2 -2
- package/dist/admin/pages/EditView/EditViewPage.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.js +170 -131
- package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.mjs +173 -135
- package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js +3 -3
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +143 -30
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +143 -32
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +22 -5
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +22 -5
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
- package/dist/admin/pages/EditView/utils/data.js +3 -3
- package/dist/admin/pages/EditView/utils/data.js.map +1 -1
- package/dist/admin/pages/EditView/utils/data.mjs +2 -2
- package/dist/admin/pages/EditView/utils/data.mjs.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.js +4 -3
- package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.mjs +4 -3
- package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
- package/dist/admin/preview/pages/Preview.js +2 -1
- package/dist/admin/preview/pages/Preview.js.map +1 -1
- package/dist/admin/preview/pages/Preview.mjs +3 -2
- package/dist/admin/preview/pages/Preview.mjs.map +1 -1
- package/dist/admin/services/documents.js +3 -2
- package/dist/admin/services/documents.js.map +1 -1
- package/dist/admin/services/documents.mjs +2 -2
- package/dist/admin/services/documents.mjs.map +1 -1
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +2 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +44 -5
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +4 -4
- package/dist/admin/src/services/documents.d.ts +10 -2
- package/dist/admin/translations/en.json.js +2 -0
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +2 -0
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/admin/utils/validation.js +3 -3
- package/dist/admin/utils/validation.js.map +1 -1
- package/dist/admin/utils/validation.mjs +2 -2
- package/dist/admin/utils/validation.mjs.map +1 -1
- package/dist/server/controllers/collection-types.js +4 -4
- package/dist/server/controllers/collection-types.js.map +1 -1
- package/dist/server/controllers/collection-types.mjs +4 -4
- package/dist/server/controllers/collection-types.mjs.map +1 -1
- package/dist/server/controllers/content-types.js +5 -7
- package/dist/server/controllers/content-types.js.map +1 -1
- package/dist/server/controllers/content-types.mjs +5 -7
- package/dist/server/controllers/content-types.mjs.map +1 -1
- package/dist/server/controllers/relations.js +22 -14
- package/dist/server/controllers/relations.js.map +1 -1
- package/dist/server/controllers/relations.mjs +21 -13
- package/dist/server/controllers/relations.mjs.map +1 -1
- package/dist/server/controllers/utils/clone.js +3 -4
- package/dist/server/controllers/utils/clone.js.map +1 -1
- package/dist/server/controllers/utils/clone.mjs +4 -5
- package/dist/server/controllers/utils/clone.mjs.map +1 -1
- package/dist/server/controllers/validation/index.js +1 -1
- package/dist/server/controllers/validation/index.mjs +1 -1
- package/dist/server/history/controllers/history-version.js +3 -3
- package/dist/server/history/controllers/history-version.js.map +1 -1
- package/dist/server/history/controllers/history-version.mjs +3 -3
- package/dist/server/history/controllers/history-version.mjs.map +1 -1
- package/dist/server/history/services/history.js +4 -4
- package/dist/server/history/services/history.js.map +1 -1
- package/dist/server/history/services/history.mjs +4 -4
- package/dist/server/history/services/history.mjs.map +1 -1
- package/dist/server/history/services/lifecycles.js +8 -8
- package/dist/server/history/services/lifecycles.js.map +1 -1
- package/dist/server/history/services/lifecycles.mjs +3 -3
- package/dist/server/history/services/lifecycles.mjs.map +1 -1
- package/dist/server/history/services/utils.js +7 -10
- package/dist/server/history/services/utils.js.map +1 -1
- package/dist/server/history/services/utils.mjs +5 -8
- package/dist/server/history/services/utils.mjs.map +1 -1
- package/dist/server/mcp/permissions.js +2 -2
- package/dist/server/mcp/permissions.js.map +1 -1
- package/dist/server/mcp/permissions.mjs +2 -2
- package/dist/server/mcp/permissions.mjs.map +1 -1
- package/dist/server/mcp/register-content-manager-mcp-tools.js +7 -5
- package/dist/server/mcp/register-content-manager-mcp-tools.js.map +1 -1
- package/dist/server/mcp/register-content-manager-mcp-tools.mjs +7 -5
- package/dist/server/mcp/register-content-manager-mcp-tools.mjs.map +1 -1
- package/dist/server/preview/controllers/previewScript.js +30 -15
- package/dist/server/preview/controllers/validation/preview.js +3 -3
- package/dist/server/preview/controllers/validation/preview.js.map +1 -1
- package/dist/server/preview/controllers/validation/preview.mjs +3 -3
- package/dist/server/preview/controllers/validation/preview.mjs.map +1 -1
- package/dist/server/services/components.js +3 -3
- package/dist/server/services/components.js.map +1 -1
- package/dist/server/services/components.mjs +3 -3
- package/dist/server/services/components.mjs.map +1 -1
- package/dist/server/services/content-structure.js +2 -2
- package/dist/server/services/content-structure.js.map +1 -1
- package/dist/server/services/content-structure.mjs +2 -2
- package/dist/server/services/content-structure.mjs.map +1 -1
- package/dist/server/services/content-types.js +3 -3
- package/dist/server/services/content-types.js.map +1 -1
- package/dist/server/services/content-types.mjs +3 -3
- package/dist/server/services/content-types.mjs.map +1 -1
- package/dist/server/services/data-mapper.js +3 -3
- package/dist/server/services/data-mapper.js.map +1 -1
- package/dist/server/services/data-mapper.mjs +3 -3
- package/dist/server/services/data-mapper.mjs.map +1 -1
- package/dist/server/services/document-manager.js +6 -6
- package/dist/server/services/document-manager.js.map +1 -1
- package/dist/server/services/document-manager.mjs +6 -6
- package/dist/server/services/document-manager.mjs.map +1 -1
- package/dist/server/services/document-metadata.js +29 -31
- package/dist/server/services/document-metadata.js.map +1 -1
- package/dist/server/services/document-metadata.mjs +29 -31
- package/dist/server/services/document-metadata.mjs.map +1 -1
- package/dist/server/services/metrics.js +3 -3
- package/dist/server/services/metrics.js.map +1 -1
- package/dist/server/services/metrics.mjs +3 -3
- package/dist/server/services/metrics.mjs.map +1 -1
- package/dist/server/services/permission-checker.js +2 -2
- package/dist/server/services/permission-checker.js.map +1 -1
- package/dist/server/services/permission-checker.mjs +1 -1
- package/dist/server/services/permission-checker.mjs.map +1 -1
- package/dist/server/services/permission.js +2 -3
- package/dist/server/services/permission.js.map +1 -1
- package/dist/server/services/permission.mjs +2 -3
- package/dist/server/services/permission.mjs.map +1 -1
- package/dist/server/services/populate-builder.js +4 -4
- package/dist/server/services/populate-builder.js.map +1 -1
- package/dist/server/services/populate-builder.mjs +4 -4
- package/dist/server/services/populate-builder.mjs.map +1 -1
- package/dist/server/services/utils/configuration/attributes.js +1 -2
- package/dist/server/services/utils/configuration/attributes.js.map +1 -1
- package/dist/server/services/utils/configuration/attributes.mjs +2 -3
- package/dist/server/services/utils/configuration/attributes.mjs.map +1 -1
- package/dist/server/services/utils/configuration/settings.js +4 -7
- package/dist/server/services/utils/configuration/settings.js.map +1 -1
- package/dist/server/services/utils/configuration/settings.mjs +2 -5
- package/dist/server/services/utils/configuration/settings.mjs.map +1 -1
- package/dist/server/services/utils/draft.js +8 -7
- package/dist/server/services/utils/draft.js.map +1 -1
- package/dist/server/services/utils/draft.mjs +6 -5
- package/dist/server/services/utils/draft.mjs.map +1 -1
- package/dist/server/services/utils/populate.js +10 -11
- package/dist/server/services/utils/populate.js.map +1 -1
- package/dist/server/services/utils/populate.mjs +9 -10
- package/dist/server/services/utils/populate.mjs.map +1 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +2 -2
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +1 -1
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/mcp/permissions.d.ts +1 -1
- package/dist/server/src/mcp/permissions.d.ts.map +1 -1
- package/dist/server/src/mcp/register-content-manager-mcp-tools.d.ts +3 -1
- package/dist/server/src/mcp/register-content-manager-mcp-tools.d.ts.map +1 -1
- package/dist/server/src/mcp/types.d.ts +2 -2
- package/dist/server/src/services/content-types.d.ts.map +1 -1
- package/dist/server/src/services/data-mapper.d.ts +1 -1
- package/dist/server/src/services/data-mapper.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +1 -1
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/metrics.d.ts.map +1 -1
- package/dist/server/src/services/permission-checker.d.ts.map +1 -1
- package/dist/server/src/services/permission.d.ts.map +1 -1
- package/dist/server/src/services/populate-builder.d.ts.map +1 -1
- package/dist/server/src/services/utils/configuration/index.d.ts +10 -1
- package/dist/server/src/services/utils/configuration/index.d.ts.map +1 -1
- package/dist/server/src/services/utils/configuration/settings.d.ts +10 -1
- package/dist/server/src/services/utils/configuration/settings.d.ts.map +1 -1
- package/dist/server/src/services/utils/draft.d.ts.map +1 -1
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationModal.js","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} 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 } 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 { createYupSchema } from '../../../../../utils/validation';\nimport { DocumentActionButton } from '../../../components/DocumentActions';\nimport { DocumentStatus } from '../../DocumentStatus';\nimport { FormLayout } 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\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}\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 };\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 fieldToConnect?: string;\n fieldToConnectUID?: string;\n getParentFormValues?: () => AnyData;\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\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 };\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 };\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 };\n case 'GO_TO_CREATED_RELATION':\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 };\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 };\n case 'SET_HAS_UNSAVED_CHANGES':\n return {\n ...state,\n hasUnsavedChanges: action.payload.hasUnsavedChanges,\n };\n default:\n return state;\n }\n}\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 });\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 * 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 const initialValues = 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 /*\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 },\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 <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\n layout={documentLayoutResponse.edit.layout}\n document={currentDocument}\n hasBackground={false}\n />\n </Box>\n </Flex>\n </DocumentRBAC>\n );\n};\n\nexport {\n reducer,\n RelationModalRenderer,\n useRelationModal,\n getFullPageUrl,\n generateCreateUrl,\n prefillParentRelation,\n};\nexport type { State, Action, RelationOpenMode };\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","reducer","state","action","type","hasUnsavedChanges","payload","shouldBypassConfirmation","confirmDialogIntent","document","fieldToConnect","fieldToConnectUID","getParentFormValues","lastItemDocumentHistory","documentHistory","at","hasToResetDocumentHistory","isModalOpen","slice","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","_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","getInitialFormValues","schema","ComponentProvider","level","uid","_jsxs","Root","open","onOpenChange","Header","gap","Flex","justifyContent","alignItems","width","IconButton","withTooltip","label","defaultMessage","variant","disabled","length","onClick","marginRight","ArrowLeft","Typography","tag","fontWeight","ArrowsOut","Body","FormContext","method","validate","values","options","yupSchema","createYupSchema","components","status","abortEarly","RelationModalBody","pathname","search","useLocation","triggerRefetchDocument","useLazyGetDocumentQuery","modified","useForm","isSubmitting","useEffect","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","meta","height","EmptyStateLayout","icon","WarningCircle","content","documentTitle","getTitle","mainField","hasDraftAndPublished","draftAndPublish","activeTab","DocumentRBAC","direction","DescriptionComponentRenderer","descriptions","apis","getDocumentActions","actions","filteredActions","position","flat","primaryAction","secondaryAction","DocumentActionButton","Box","DocumentStatus","flex","overflow","paddingTop","FormLayout","layout","hasBackground"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CO,SAASA,kBAAkBC,GAAW,EAAA;IAC3C,MAAMC,KAAAA,GAAQ,IAAIC,MAAAA,CAAO,CAAC,CAAC,EAAEC,4BAAAA,CAAiB,CAAC,EAAEC,wBAAAA,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,uBAAAA,CAAOC,kBAAAA,CAAMC,OAAO,CAAC;;;;;AAKhD,CAAC;AAED,MAAMC,iBAAiB,CAACC,mBAAAA,GAAAA;IACtB,MAAMC,YAAAA,GAAeD,mBAAAA,CAAoBE,cAAc,KAAKV,wBAAAA;AAC5D,IAAA,MAAMW,WAAAA,GA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J,gBAAAA,EAAAA;oBAAIG,QAAAA,EAAS,MAAA;oBAAOD,IAAAA,EAAM,CAAA;AACzB,oBAAA,QAAA,gBAAAxJ,cAAA,CAAC2J,qBAAAA,EAAAA;wBACCC,MAAAA,EAAQpK,sBAAAA,CAAuBG,IAAI,CAACiK,MAAM;wBAC1C/L,QAAAA,EAAUgC,eAAAA;wBACVgK,aAAAA,EAAe;;;;;;AAM3B,CAAA;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"RelationModal.js","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,4BAAAA,CAAiB,CAAC,EAAEC,wBAAAA,CAAa,CAAC,CAAC,CAAA;IAChE,MAAMC,KAAAA,GAAQL,GAAAA,CAAIK,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F,aAAa;4CACjBxF,OAAAA,EAASwF,aAAAA,CAAcxF,OAAO,IAAI;;AAGxC,oCAAA;;;;;AAILuE,oBAAAA,oBAAAA,iBACC5I,cAAA,CAACgK,gBAAAA,EAAAA;AACC,wBAAA,QAAA,gBAAAhK,cAAA,CAACiK,6BAAAA,EAAAA;4BAAe3E,MAAAA,EAAQ1F,eAAAA,CAAgBzC,QAAQ,EAAEmI;;AAElD,qBAAA,CAAA,GAAA;;;0BAGNtF,cAAA,CAAC6D,iBAAAA,EAAAA;gBAAKqG,IAAAA,EAAM,CAAA;gBAAGC,QAAAA,EAAS,MAAA;gBAAOpG,UAAAA,EAAW,SAAA;gBAAUqG,UAAAA,EAAY,CAAA;AAC9D,gBAAA,QAAA,gBAAApK,cAAA,CAACgK,gBAAAA,EAAAA;oBAAIG,QAAAA,EAAS,MAAA;oBAAOD,IAAAA,EAAM,CAAA;AACzB,oBAAA,QAAA,gBAAAlK,cAAA,CAACqK,qBAAAA,EAAAA;wBAAWpB,MAAAA,EAAQA,MAAAA;wBAAQ9L,QAAAA,EAAUyC,eAAAA;wBAAiB0K,aAAAA,EAAe;;;;;;AAKhF;;;;;;;;;;;;"}
|
|
@@ -17,7 +17,8 @@ import '@strapi/admin/strapi-admin/ee';
|
|
|
17
17
|
import '../../../../../preview/pages/Preview.mjs';
|
|
18
18
|
import { useLazyGetDocumentQuery } from '../../../../../services/documents.mjs';
|
|
19
19
|
import { useDocumentLayout } from '../../../../../hooks/useDocumentLayout.mjs';
|
|
20
|
-
import { DocumentRBAC } from '../../../../../features/DocumentRBAC.mjs';
|
|
20
|
+
import { DocumentRBAC, useDocumentRBAC } from '../../../../../features/DocumentRBAC.mjs';
|
|
21
|
+
import { setIn } from '../../../../../utils/objects.mjs';
|
|
21
22
|
import { createYupSchema } from '../../../../../utils/validation.mjs';
|
|
22
23
|
import { DocumentActionButton } from '../../DocumentActions.mjs';
|
|
23
24
|
import { FormLayout } from '../../FormLayout.mjs';
|
|
@@ -39,6 +40,8 @@ const getFullPageUrl = (currentDocumentMeta)=>{
|
|
|
39
40
|
const queryParams = currentDocumentMeta.params?.locale ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}` : '';
|
|
40
41
|
return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}${isSingleType ? '' : '/' + currentDocumentMeta.documentId}${queryParams}`;
|
|
41
42
|
};
|
|
43
|
+
const getDocumentHistoryKey = (meta)=>`${meta.model}::${meta.documentId}`;
|
|
44
|
+
const EMPTY_PENDING_CONNECTS = [];
|
|
42
45
|
function reducer(state, action) {
|
|
43
46
|
switch(action.type){
|
|
44
47
|
case 'GO_TO_RELATION':
|
|
@@ -48,7 +51,8 @@ function reducer(state, action) {
|
|
|
48
51
|
confirmDialogIntent: action.payload.document,
|
|
49
52
|
fieldToConnect: action.payload.fieldToConnect,
|
|
50
53
|
fieldToConnectUID: action.payload.fieldToConnectUID,
|
|
51
|
-
getParentFormValues: action.payload.getParentFormValues
|
|
54
|
+
getParentFormValues: action.payload.getParentFormValues,
|
|
55
|
+
setParentFormValue: action.payload.setParentFormValue
|
|
52
56
|
};
|
|
53
57
|
}
|
|
54
58
|
const lastItemDocumentHistory = state.documentHistory.at(-1);
|
|
@@ -66,7 +70,8 @@ function reducer(state, action) {
|
|
|
66
70
|
isModalOpen: true,
|
|
67
71
|
fieldToConnect: hasToResetDocumentHistory ? undefined : action.payload.fieldToConnect,
|
|
68
72
|
fieldToConnectUID: hasToResetDocumentHistory ? undefined : action.payload.fieldToConnectUID,
|
|
69
|
-
getParentFormValues: hasToResetDocumentHistory ? undefined : action.payload.getParentFormValues
|
|
73
|
+
getParentFormValues: hasToResetDocumentHistory ? undefined : action.payload.getParentFormValues,
|
|
74
|
+
setParentFormValue: hasToResetDocumentHistory ? undefined : action.payload.setParentFormValue
|
|
70
75
|
};
|
|
71
76
|
case 'GO_BACK':
|
|
72
77
|
if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {
|
|
@@ -92,24 +97,40 @@ function reducer(state, action) {
|
|
|
92
97
|
documentHistory: [],
|
|
93
98
|
hasUnsavedChanges: false,
|
|
94
99
|
isModalOpen: false,
|
|
95
|
-
confirmDialogIntent: null
|
|
96
|
-
};
|
|
97
|
-
case 'GO_TO_CREATED_RELATION':
|
|
98
|
-
return {
|
|
99
|
-
...state,
|
|
100
|
-
// Reset document history if the last item has documentId undefined
|
|
101
|
-
documentHistory: state.documentHistory ? [
|
|
102
|
-
...state.documentHistory.slice(0, -1),
|
|
103
|
-
action.payload.document
|
|
104
|
-
] : [
|
|
105
|
-
action.payload.document
|
|
106
|
-
],
|
|
107
100
|
confirmDialogIntent: null,
|
|
108
|
-
|
|
109
|
-
fieldToConnect: undefined,
|
|
110
|
-
fieldToConnectUID: undefined,
|
|
111
|
-
getParentFormValues: undefined
|
|
101
|
+
pendingConnects: {}
|
|
112
102
|
};
|
|
103
|
+
case 'GO_TO_CREATED_RELATION':
|
|
104
|
+
{
|
|
105
|
+
// Anything beyond the second-to-last history entry is a nested parent still open further up
|
|
106
|
+
// the stack — the root document (outside documentHistory entirely) is handled directly via
|
|
107
|
+
// setParentFormValue instead, since its Form never gets replaced by modal navigation.
|
|
108
|
+
const nestedParentMeta = state.documentHistory.length >= 2 ? state.documentHistory.at(-2) : undefined;
|
|
109
|
+
const pendingConnects = nestedParentMeta && action.payload.connectPatch ? {
|
|
110
|
+
...state.pendingConnects,
|
|
111
|
+
[getDocumentHistoryKey(nestedParentMeta)]: [
|
|
112
|
+
...state.pendingConnects[getDocumentHistoryKey(nestedParentMeta)] ?? [],
|
|
113
|
+
action.payload.connectPatch
|
|
114
|
+
]
|
|
115
|
+
} : state.pendingConnects;
|
|
116
|
+
return {
|
|
117
|
+
...state,
|
|
118
|
+
// Reset document history if the last item has documentId undefined
|
|
119
|
+
documentHistory: state.documentHistory ? [
|
|
120
|
+
...state.documentHistory.slice(0, -1),
|
|
121
|
+
action.payload.document
|
|
122
|
+
] : [
|
|
123
|
+
action.payload.document
|
|
124
|
+
],
|
|
125
|
+
confirmDialogIntent: null,
|
|
126
|
+
isModalOpen: true,
|
|
127
|
+
fieldToConnect: undefined,
|
|
128
|
+
fieldToConnectUID: undefined,
|
|
129
|
+
getParentFormValues: undefined,
|
|
130
|
+
setParentFormValue: undefined,
|
|
131
|
+
pendingConnects
|
|
132
|
+
};
|
|
133
|
+
}
|
|
113
134
|
case 'CANCEL_CONFIRM_DIALOG':
|
|
114
135
|
return {
|
|
115
136
|
...state,
|
|
@@ -130,17 +151,44 @@ function reducer(state, action) {
|
|
|
130
151
|
isModalOpen: false,
|
|
131
152
|
fieldToConnect: undefined,
|
|
132
153
|
fieldToConnectUID: undefined,
|
|
133
|
-
getParentFormValues: undefined
|
|
154
|
+
getParentFormValues: undefined,
|
|
155
|
+
setParentFormValue: undefined,
|
|
156
|
+
pendingConnects: {}
|
|
134
157
|
};
|
|
135
158
|
case 'SET_HAS_UNSAVED_CHANGES':
|
|
136
159
|
return {
|
|
137
160
|
...state,
|
|
138
161
|
hasUnsavedChanges: action.payload.hasUnsavedChanges
|
|
139
162
|
};
|
|
163
|
+
case 'CLEAR_PENDING_CONNECTS':
|
|
164
|
+
{
|
|
165
|
+
const key = getDocumentHistoryKey(action.payload.documentMeta);
|
|
166
|
+
if (!(key in state.pendingConnects)) {
|
|
167
|
+
return state;
|
|
168
|
+
}
|
|
169
|
+
const pendingConnects = {
|
|
170
|
+
...state.pendingConnects
|
|
171
|
+
};
|
|
172
|
+
delete pendingConnects[key];
|
|
173
|
+
return {
|
|
174
|
+
...state,
|
|
175
|
+
pendingConnects
|
|
176
|
+
};
|
|
177
|
+
}
|
|
140
178
|
default:
|
|
141
179
|
return state;
|
|
142
180
|
}
|
|
143
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Whether any relation-on-the-fly modal is currently open, anywhere on the page.
|
|
184
|
+
*
|
|
185
|
+
* The modal's React context (`RelationModalProvider`, below) only reaches the modal's own subtree
|
|
186
|
+
* (the relation field that renders it), so components mounted outside that subtree — like the
|
|
187
|
+
* background entry's save/publish buttons in the side panel — can't read `state.isModalOpen` from
|
|
188
|
+
* context. This module-level counter is the cross-tree signal those components use instead, so
|
|
189
|
+
* they can tell a relation modal is open and suppress their own keyboard shortcuts while it is.
|
|
190
|
+
*/ let openRelationModalCount = 0;
|
|
191
|
+
const isAnyRelationModalOpen = ()=>openRelationModalCount > 0;
|
|
144
192
|
const [RelationModalProvider, useRelationModal] = createContext('RelationModal');
|
|
145
193
|
function isRenderProp(children) {
|
|
146
194
|
return typeof children === 'function';
|
|
@@ -152,7 +200,8 @@ const RootRelationRenderer = (props)=>{
|
|
|
152
200
|
confirmDialogIntent: null,
|
|
153
201
|
isModalOpen: false,
|
|
154
202
|
hasUnsavedChanges: false,
|
|
155
|
-
fieldToConnect: undefined
|
|
203
|
+
fieldToConnect: undefined,
|
|
204
|
+
pendingConnects: {}
|
|
156
205
|
});
|
|
157
206
|
const rootDocument = useDoc();
|
|
158
207
|
const [{ query }] = useQueryParams();
|
|
@@ -173,6 +222,18 @@ const RootRelationRenderer = (props)=>{
|
|
|
173
222
|
// TODO: check if we can remove the single type check
|
|
174
223
|
const isSingleType = currentDocumentMeta.collectionType === SINGLE_TYPES;
|
|
175
224
|
const isCreating = !currentDocumentMeta.documentId && !isSingleType;
|
|
225
|
+
const { isModalOpen } = state;
|
|
226
|
+
React.useEffect(()=>{
|
|
227
|
+
if (!isModalOpen) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
openRelationModalCount += 1;
|
|
231
|
+
return ()=>{
|
|
232
|
+
openRelationModalCount -= 1;
|
|
233
|
+
};
|
|
234
|
+
}, [
|
|
235
|
+
isModalOpen
|
|
236
|
+
]);
|
|
176
237
|
/**
|
|
177
238
|
* There is no parent relation, so the relation modal doesn't exist. Create it and set up all the
|
|
178
239
|
* pieces that will be used by potential child relations: the context, header, form, and footer.
|
|
@@ -279,13 +340,35 @@ const RelationModal = ({ children })=>{
|
|
|
279
340
|
const parentDocument = useDocument(parentDocumentMeta, {
|
|
280
341
|
skip: !isCreating || !state.fieldToConnect
|
|
281
342
|
});
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
343
|
+
const pendingConnectsForCurrent = useRelationModal('RelationModalForm', (state)=>state.state.pendingConnects[getDocumentHistoryKey(currentDocumentMeta)], false) ?? EMPTY_PENDING_CONNECTS;
|
|
344
|
+
// Re-apply any local "connect" edits recorded for this document while a nested child was open,
|
|
345
|
+
// since navigating here just replaced the Form's values with a fresh, patch-less snapshot.
|
|
346
|
+
const initialValues = React.useMemo(()=>{
|
|
347
|
+
const baseInitialValues = prefillParentRelation({
|
|
348
|
+
initialValues: currentDocument.getInitialFormValues(isCreating),
|
|
349
|
+
fieldToConnect: isCreating ? state.fieldToConnect : undefined,
|
|
350
|
+
childSchema: currentDocument.schema,
|
|
351
|
+
parentDocument: parentDocument.document,
|
|
352
|
+
parentModel: parentDocumentMeta.model
|
|
353
|
+
});
|
|
354
|
+
// The document (and its default values) may still be loading, e.g. right after navigating
|
|
355
|
+
// back to a document that now has a real documentId. Let the loading guard below handle it
|
|
356
|
+
// instead of trying to patch a value that doesn't exist yet.
|
|
357
|
+
if (!baseInitialValues) {
|
|
358
|
+
return baseInitialValues;
|
|
359
|
+
}
|
|
360
|
+
return pendingConnectsForCurrent.reduce((values, patch)=>{
|
|
361
|
+
const withRelation = setIn(values, patch.fieldToConnect, patch.relationValue);
|
|
362
|
+
return patch.componentUIDPath && patch.componentUID !== undefined ? setIn(withRelation, patch.componentUIDPath, patch.componentUID) : withRelation;
|
|
363
|
+
}, baseInitialValues);
|
|
364
|
+
}, [
|
|
365
|
+
currentDocument,
|
|
366
|
+
isCreating,
|
|
367
|
+
state.fieldToConnect,
|
|
368
|
+
parentDocument.document,
|
|
369
|
+
parentDocumentMeta.model,
|
|
370
|
+
pendingConnectsForCurrent
|
|
371
|
+
]);
|
|
289
372
|
/*
|
|
290
373
|
* We must wrap the modal window with Component Provider with reset values
|
|
291
374
|
* to avoid inheriting id and uid from the root document and having weird
|
|
@@ -483,7 +566,8 @@ const RelationModal = ({ children })=>{
|
|
|
483
566
|
shouldBypassConfirmation: true,
|
|
484
567
|
fieldToConnect: state.fieldToConnect,
|
|
485
568
|
fieldToConnectUID: state.fieldToConnectUID,
|
|
486
|
-
getParentFormValues: state.getParentFormValues
|
|
569
|
+
getParentFormValues: state.getParentFormValues,
|
|
570
|
+
setParentFormValue: state.setParentFormValue
|
|
487
571
|
}
|
|
488
572
|
});
|
|
489
573
|
}
|
|
@@ -614,9 +698,36 @@ const StyledRelationLink = styled(Link)`
|
|
|
614
698
|
document: currentDocument.document,
|
|
615
699
|
meta: currentDocument.meta
|
|
616
700
|
};
|
|
617
|
-
return /*#__PURE__*/
|
|
701
|
+
return /*#__PURE__*/ jsx(DocumentRBAC, {
|
|
618
702
|
permissions: permissions,
|
|
619
703
|
model: currentDocumentMeta.model,
|
|
704
|
+
children: /*#__PURE__*/ jsx(RelationModalFormBody, {
|
|
705
|
+
currentDocument: currentDocument,
|
|
706
|
+
documentTitle: documentTitle,
|
|
707
|
+
hasDraftAndPublished: hasDraftAndPublished,
|
|
708
|
+
layout: documentLayoutResponse.edit.layout,
|
|
709
|
+
plugins: plugins,
|
|
710
|
+
props: props
|
|
711
|
+
})
|
|
712
|
+
});
|
|
713
|
+
};
|
|
714
|
+
/**
|
|
715
|
+
* Rendered as the child of `DocumentRBAC` so it can wait on `useDocumentRBAC`'s `isLoading`
|
|
716
|
+
* before showing the document actions and form — otherwise fields briefly render as
|
|
717
|
+
* not-allowed while permissions are still resolving.
|
|
718
|
+
*/ const RelationModalFormBody = ({ currentDocument, documentTitle, hasDraftAndPublished, layout, plugins, props })=>{
|
|
719
|
+
const { formatMessage } = useIntl();
|
|
720
|
+
const isLoadingActionsRBAC = useDocumentRBAC('RelationModalFormBody', (state)=>state.isLoading);
|
|
721
|
+
if (isLoadingActionsRBAC) {
|
|
722
|
+
return /*#__PURE__*/ jsx(Loader, {
|
|
723
|
+
small: true,
|
|
724
|
+
children: formatMessage({
|
|
725
|
+
id: 'content-manager.ListViewTable.relation-loading',
|
|
726
|
+
defaultMessage: 'Relations are loading'
|
|
727
|
+
})
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
620
731
|
children: [
|
|
621
732
|
/*#__PURE__*/ jsxs(Flex, {
|
|
622
733
|
alignItems: "flex-start",
|
|
@@ -687,7 +798,7 @@ const StyledRelationLink = styled(Link)`
|
|
|
687
798
|
overflow: "auto",
|
|
688
799
|
flex: 1,
|
|
689
800
|
children: /*#__PURE__*/ jsx(FormLayout, {
|
|
690
|
-
layout:
|
|
801
|
+
layout: layout,
|
|
691
802
|
document: currentDocument,
|
|
692
803
|
hasBackground: false
|
|
693
804
|
})
|
|
@@ -697,5 +808,5 @@ const StyledRelationLink = styled(Link)`
|
|
|
697
808
|
});
|
|
698
809
|
};
|
|
699
810
|
|
|
700
|
-
export { RelationModalRenderer, generateCreateUrl, getCollectionType, getFullPageUrl, prefillParentRelation, reducer, useRelationModal };
|
|
811
|
+
export { RelationModalFormBody, RelationModalRenderer, generateCreateUrl, getCollectionType, getFullPageUrl, isAnyRelationModalOpen, prefillParentRelation, reducer, useRelationModal };
|
|
701
812
|
//# sourceMappingURL=RelationModal.mjs.map
|