@strapi/content-manager 5.55.1 → 5.56.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/pages/EditView/components/DocumentActions.js +133 -129
- package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.mjs +137 -133
- package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +113 -28
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +113 -29
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +8 -3
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +8 -3
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +27 -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/server/controllers/relations.js +4 -0
- package/dist/server/controllers/relations.js.map +1 -1
- package/dist/server/controllers/relations.mjs +4 -0
- package/dist/server/controllers/relations.mjs.map +1 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -20,6 +20,7 @@ require('../../../../../preview/pages/Preview.js');
|
|
|
20
20
|
var documents = require('../../../../../services/documents.js');
|
|
21
21
|
var useDocumentLayout = require('../../../../../hooks/useDocumentLayout.js');
|
|
22
22
|
var DocumentRBAC = require('../../../../../features/DocumentRBAC.js');
|
|
23
|
+
var objects = require('../../../../../utils/objects.js');
|
|
23
24
|
var validation = require('../../../../../utils/validation.js');
|
|
24
25
|
var DocumentActions = require('../../DocumentActions.js');
|
|
25
26
|
var FormLayout = require('../../FormLayout.js');
|
|
@@ -61,6 +62,8 @@ const getFullPageUrl = (currentDocumentMeta)=>{
|
|
|
61
62
|
const queryParams = currentDocumentMeta.params?.locale ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}` : '';
|
|
62
63
|
return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}${isSingleType ? '' : '/' + currentDocumentMeta.documentId}${queryParams}`;
|
|
63
64
|
};
|
|
65
|
+
const getDocumentHistoryKey = (meta)=>`${meta.model}::${meta.documentId}`;
|
|
66
|
+
const EMPTY_PENDING_CONNECTS = [];
|
|
64
67
|
function reducer(state, action) {
|
|
65
68
|
switch(action.type){
|
|
66
69
|
case 'GO_TO_RELATION':
|
|
@@ -70,7 +73,8 @@ function reducer(state, action) {
|
|
|
70
73
|
confirmDialogIntent: action.payload.document,
|
|
71
74
|
fieldToConnect: action.payload.fieldToConnect,
|
|
72
75
|
fieldToConnectUID: action.payload.fieldToConnectUID,
|
|
73
|
-
getParentFormValues: action.payload.getParentFormValues
|
|
76
|
+
getParentFormValues: action.payload.getParentFormValues,
|
|
77
|
+
setParentFormValue: action.payload.setParentFormValue
|
|
74
78
|
};
|
|
75
79
|
}
|
|
76
80
|
const lastItemDocumentHistory = state.documentHistory.at(-1);
|
|
@@ -88,7 +92,8 @@ function reducer(state, action) {
|
|
|
88
92
|
isModalOpen: true,
|
|
89
93
|
fieldToConnect: hasToResetDocumentHistory ? undefined : action.payload.fieldToConnect,
|
|
90
94
|
fieldToConnectUID: hasToResetDocumentHistory ? undefined : action.payload.fieldToConnectUID,
|
|
91
|
-
getParentFormValues: hasToResetDocumentHistory ? undefined : action.payload.getParentFormValues
|
|
95
|
+
getParentFormValues: hasToResetDocumentHistory ? undefined : action.payload.getParentFormValues,
|
|
96
|
+
setParentFormValue: hasToResetDocumentHistory ? undefined : action.payload.setParentFormValue
|
|
92
97
|
};
|
|
93
98
|
case 'GO_BACK':
|
|
94
99
|
if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {
|
|
@@ -114,24 +119,40 @@ function reducer(state, action) {
|
|
|
114
119
|
documentHistory: [],
|
|
115
120
|
hasUnsavedChanges: false,
|
|
116
121
|
isModalOpen: false,
|
|
117
|
-
confirmDialogIntent: null
|
|
118
|
-
};
|
|
119
|
-
case 'GO_TO_CREATED_RELATION':
|
|
120
|
-
return {
|
|
121
|
-
...state,
|
|
122
|
-
// Reset document history if the last item has documentId undefined
|
|
123
|
-
documentHistory: state.documentHistory ? [
|
|
124
|
-
...state.documentHistory.slice(0, -1),
|
|
125
|
-
action.payload.document
|
|
126
|
-
] : [
|
|
127
|
-
action.payload.document
|
|
128
|
-
],
|
|
129
122
|
confirmDialogIntent: null,
|
|
130
|
-
|
|
131
|
-
fieldToConnect: undefined,
|
|
132
|
-
fieldToConnectUID: undefined,
|
|
133
|
-
getParentFormValues: undefined
|
|
123
|
+
pendingConnects: {}
|
|
134
124
|
};
|
|
125
|
+
case 'GO_TO_CREATED_RELATION':
|
|
126
|
+
{
|
|
127
|
+
// Anything beyond the second-to-last history entry is a nested parent still open further up
|
|
128
|
+
// the stack — the root document (outside documentHistory entirely) is handled directly via
|
|
129
|
+
// setParentFormValue instead, since its Form never gets replaced by modal navigation.
|
|
130
|
+
const nestedParentMeta = state.documentHistory.length >= 2 ? state.documentHistory.at(-2) : undefined;
|
|
131
|
+
const pendingConnects = nestedParentMeta && action.payload.connectPatch ? {
|
|
132
|
+
...state.pendingConnects,
|
|
133
|
+
[getDocumentHistoryKey(nestedParentMeta)]: [
|
|
134
|
+
...state.pendingConnects[getDocumentHistoryKey(nestedParentMeta)] ?? [],
|
|
135
|
+
action.payload.connectPatch
|
|
136
|
+
]
|
|
137
|
+
} : state.pendingConnects;
|
|
138
|
+
return {
|
|
139
|
+
...state,
|
|
140
|
+
// Reset document history if the last item has documentId undefined
|
|
141
|
+
documentHistory: state.documentHistory ? [
|
|
142
|
+
...state.documentHistory.slice(0, -1),
|
|
143
|
+
action.payload.document
|
|
144
|
+
] : [
|
|
145
|
+
action.payload.document
|
|
146
|
+
],
|
|
147
|
+
confirmDialogIntent: null,
|
|
148
|
+
isModalOpen: true,
|
|
149
|
+
fieldToConnect: undefined,
|
|
150
|
+
fieldToConnectUID: undefined,
|
|
151
|
+
getParentFormValues: undefined,
|
|
152
|
+
setParentFormValue: undefined,
|
|
153
|
+
pendingConnects
|
|
154
|
+
};
|
|
155
|
+
}
|
|
135
156
|
case 'CANCEL_CONFIRM_DIALOG':
|
|
136
157
|
return {
|
|
137
158
|
...state,
|
|
@@ -152,17 +173,44 @@ function reducer(state, action) {
|
|
|
152
173
|
isModalOpen: false,
|
|
153
174
|
fieldToConnect: undefined,
|
|
154
175
|
fieldToConnectUID: undefined,
|
|
155
|
-
getParentFormValues: undefined
|
|
176
|
+
getParentFormValues: undefined,
|
|
177
|
+
setParentFormValue: undefined,
|
|
178
|
+
pendingConnects: {}
|
|
156
179
|
};
|
|
157
180
|
case 'SET_HAS_UNSAVED_CHANGES':
|
|
158
181
|
return {
|
|
159
182
|
...state,
|
|
160
183
|
hasUnsavedChanges: action.payload.hasUnsavedChanges
|
|
161
184
|
};
|
|
185
|
+
case 'CLEAR_PENDING_CONNECTS':
|
|
186
|
+
{
|
|
187
|
+
const key = getDocumentHistoryKey(action.payload.documentMeta);
|
|
188
|
+
if (!(key in state.pendingConnects)) {
|
|
189
|
+
return state;
|
|
190
|
+
}
|
|
191
|
+
const pendingConnects = {
|
|
192
|
+
...state.pendingConnects
|
|
193
|
+
};
|
|
194
|
+
delete pendingConnects[key];
|
|
195
|
+
return {
|
|
196
|
+
...state,
|
|
197
|
+
pendingConnects
|
|
198
|
+
};
|
|
199
|
+
}
|
|
162
200
|
default:
|
|
163
201
|
return state;
|
|
164
202
|
}
|
|
165
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Whether any relation-on-the-fly modal is currently open, anywhere on the page.
|
|
206
|
+
*
|
|
207
|
+
* The modal's React context (`RelationModalProvider`, below) only reaches the modal's own subtree
|
|
208
|
+
* (the relation field that renders it), so components mounted outside that subtree — like the
|
|
209
|
+
* background entry's save/publish buttons in the side panel — can't read `state.isModalOpen` from
|
|
210
|
+
* context. This module-level counter is the cross-tree signal those components use instead, so
|
|
211
|
+
* they can tell a relation modal is open and suppress their own keyboard shortcuts while it is.
|
|
212
|
+
*/ let openRelationModalCount = 0;
|
|
213
|
+
const isAnyRelationModalOpen = ()=>openRelationModalCount > 0;
|
|
166
214
|
const [RelationModalProvider, useRelationModal] = strapiAdmin.createContext('RelationModal');
|
|
167
215
|
function isRenderProp(children) {
|
|
168
216
|
return typeof children === 'function';
|
|
@@ -174,7 +222,8 @@ const RootRelationRenderer = (props)=>{
|
|
|
174
222
|
confirmDialogIntent: null,
|
|
175
223
|
isModalOpen: false,
|
|
176
224
|
hasUnsavedChanges: false,
|
|
177
|
-
fieldToConnect: undefined
|
|
225
|
+
fieldToConnect: undefined,
|
|
226
|
+
pendingConnects: {}
|
|
178
227
|
});
|
|
179
228
|
const rootDocument = useDocument.useDoc();
|
|
180
229
|
const [{ query }] = strapiAdmin.useQueryParams();
|
|
@@ -195,6 +244,18 @@ const RootRelationRenderer = (props)=>{
|
|
|
195
244
|
// TODO: check if we can remove the single type check
|
|
196
245
|
const isSingleType = currentDocumentMeta.collectionType === collections.SINGLE_TYPES;
|
|
197
246
|
const isCreating = !currentDocumentMeta.documentId && !isSingleType;
|
|
247
|
+
const { isModalOpen } = state;
|
|
248
|
+
React__namespace.useEffect(()=>{
|
|
249
|
+
if (!isModalOpen) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
openRelationModalCount += 1;
|
|
253
|
+
return ()=>{
|
|
254
|
+
openRelationModalCount -= 1;
|
|
255
|
+
};
|
|
256
|
+
}, [
|
|
257
|
+
isModalOpen
|
|
258
|
+
]);
|
|
198
259
|
/**
|
|
199
260
|
* There is no parent relation, so the relation modal doesn't exist. Create it and set up all the
|
|
200
261
|
* pieces that will be used by potential child relations: the context, header, form, and footer.
|
|
@@ -301,13 +362,35 @@ const RelationModal = ({ children })=>{
|
|
|
301
362
|
const parentDocument = useDocument.useDocument(parentDocumentMeta, {
|
|
302
363
|
skip: !isCreating || !state.fieldToConnect
|
|
303
364
|
});
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
365
|
+
const pendingConnectsForCurrent = useRelationModal('RelationModalForm', (state)=>state.state.pendingConnects[getDocumentHistoryKey(currentDocumentMeta)], false) ?? EMPTY_PENDING_CONNECTS;
|
|
366
|
+
// Re-apply any local "connect" edits recorded for this document while a nested child was open,
|
|
367
|
+
// since navigating here just replaced the Form's values with a fresh, patch-less snapshot.
|
|
368
|
+
const initialValues = React__namespace.useMemo(()=>{
|
|
369
|
+
const baseInitialValues = prefillParentRelation({
|
|
370
|
+
initialValues: currentDocument.getInitialFormValues(isCreating),
|
|
371
|
+
fieldToConnect: isCreating ? state.fieldToConnect : undefined,
|
|
372
|
+
childSchema: currentDocument.schema,
|
|
373
|
+
parentDocument: parentDocument.document,
|
|
374
|
+
parentModel: parentDocumentMeta.model
|
|
375
|
+
});
|
|
376
|
+
// The document (and its default values) may still be loading, e.g. right after navigating
|
|
377
|
+
// back to a document that now has a real documentId. Let the loading guard below handle it
|
|
378
|
+
// instead of trying to patch a value that doesn't exist yet.
|
|
379
|
+
if (!baseInitialValues) {
|
|
380
|
+
return baseInitialValues;
|
|
381
|
+
}
|
|
382
|
+
return pendingConnectsForCurrent.reduce((values, patch)=>{
|
|
383
|
+
const withRelation = objects.setIn(values, patch.fieldToConnect, patch.relationValue);
|
|
384
|
+
return patch.componentUIDPath && patch.componentUID !== undefined ? objects.setIn(withRelation, patch.componentUIDPath, patch.componentUID) : withRelation;
|
|
385
|
+
}, baseInitialValues);
|
|
386
|
+
}, [
|
|
387
|
+
currentDocument,
|
|
388
|
+
isCreating,
|
|
389
|
+
state.fieldToConnect,
|
|
390
|
+
parentDocument.document,
|
|
391
|
+
parentDocumentMeta.model,
|
|
392
|
+
pendingConnectsForCurrent
|
|
393
|
+
]);
|
|
311
394
|
/*
|
|
312
395
|
* We must wrap the modal window with Component Provider with reset values
|
|
313
396
|
* to avoid inheriting id and uid from the root document and having weird
|
|
@@ -505,7 +588,8 @@ const RelationModal = ({ children })=>{
|
|
|
505
588
|
shouldBypassConfirmation: true,
|
|
506
589
|
fieldToConnect: state.fieldToConnect,
|
|
507
590
|
fieldToConnectUID: state.fieldToConnectUID,
|
|
508
|
-
getParentFormValues: state.getParentFormValues
|
|
591
|
+
getParentFormValues: state.getParentFormValues,
|
|
592
|
+
setParentFormValue: state.setParentFormValue
|
|
509
593
|
}
|
|
510
594
|
});
|
|
511
595
|
}
|
|
@@ -723,6 +807,7 @@ exports.RelationModalRenderer = RelationModalRenderer;
|
|
|
723
807
|
exports.generateCreateUrl = generateCreateUrl;
|
|
724
808
|
exports.getCollectionType = getCollectionType;
|
|
725
809
|
exports.getFullPageUrl = getFullPageUrl;
|
|
810
|
+
exports.isAnyRelationModalOpen = isAnyRelationModalOpen;
|
|
726
811
|
exports.prefillParentRelation = prefillParentRelation;
|
|
727
812
|
exports.reducer = reducer;
|
|
728
813
|
exports.useRelationModal = useRelationModal;
|
|
@@ -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,GAAcH,mBAAAA,CAAoBI,MAAM,EAAEC,MAAAA,GAC5C,CAAC,uBAAuB,EAAEL,mBAAAA,CAAoBI,MAAM,CAACC,MAAM,EAAE,GAC7D,EAAA;AAEJ,IAA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BACCC,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} 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 { setIn } from '../../../../../utils/objects';\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\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 <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 isAnyRelationModalOpen,\n getFullPageUrl,\n generateCreateUrl,\n prefillParentRelation,\n};\nexport type { State, Action, RelationOpenMode, PendingConnectPatch };\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","direction","DescriptionComponentRenderer","descriptions","apis","getDocumentActions","actions","filteredActions","position","flat","primaryAction","secondaryAction","DocumentActionButton","Box","DocumentStatus","fl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