@strapi/content-manager 5.13.0-beta.1 → 5.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/admin/components/LeftMenu.js +30 -34
  2. package/dist/admin/components/LeftMenu.js.map +1 -1
  3. package/dist/admin/components/LeftMenu.mjs +32 -36
  4. package/dist/admin/components/LeftMenu.mjs.map +1 -1
  5. package/dist/admin/hooks/useDocumentActions.js +5 -1
  6. package/dist/admin/hooks/useDocumentActions.js.map +1 -1
  7. package/dist/admin/hooks/useDocumentActions.mjs +5 -1
  8. package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
  9. package/dist/admin/hooks/useDocumentContext.js.map +1 -1
  10. package/dist/admin/hooks/useDocumentContext.mjs.map +1 -1
  11. package/dist/admin/index.js +1 -3
  12. package/dist/admin/index.js.map +1 -1
  13. package/dist/admin/pages/EditView/components/DocumentActions.js +206 -21
  14. package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
  15. package/dist/admin/pages/EditView/components/DocumentActions.mjs +208 -23
  16. package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
  17. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +128 -55
  18. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
  19. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +128 -55
  20. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
  21. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +89 -50
  22. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
  23. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +91 -52
  24. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
  25. package/dist/admin/pages/EditView/components/FormLayout.js +3 -3
  26. package/dist/admin/pages/EditView/components/FormLayout.js.map +1 -1
  27. package/dist/admin/pages/EditView/components/FormLayout.mjs +3 -3
  28. package/dist/admin/pages/EditView/components/FormLayout.mjs.map +1 -1
  29. package/dist/admin/pages/ListView/ListViewPage.js +0 -77
  30. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  31. package/dist/admin/pages/ListView/ListViewPage.mjs +1 -78
  32. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  33. package/dist/admin/src/hooks/useDocumentContext.d.ts +1 -1
  34. package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +26 -5
  35. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +0 -1
  36. package/dist/admin/translations/en.json.js +2 -1
  37. package/dist/admin/translations/en.json.js.map +1 -1
  38. package/dist/admin/translations/en.json.mjs +2 -1
  39. package/dist/admin/translations/en.json.mjs.map +1 -1
  40. package/dist/admin/translations/ru.json.js +235 -226
  41. package/dist/admin/translations/ru.json.js.map +1 -1
  42. package/dist/admin/translations/ru.json.mjs +230 -226
  43. package/dist/admin/translations/ru.json.mjs.map +1 -1
  44. package/dist/server/src/index.d.ts +0 -1
  45. package/dist/server/src/index.d.ts.map +1 -1
  46. package/dist/server/src/services/data-mapper.d.ts +0 -1
  47. package/dist/server/src/services/data-mapper.d.ts.map +1 -1
  48. package/dist/server/src/services/index.d.ts +0 -1
  49. package/dist/server/src/services/index.d.ts.map +1 -1
  50. package/package.json +5 -5
  51. package/dist/server/src/services/homepage.d.ts +0 -11
  52. package/dist/server/src/services/homepage.d.ts.map +0 -1
@@ -18,6 +18,7 @@ import { DocumentRBAC } from '../../../../../features/DocumentRBAC.mjs';
18
18
  import { createYupSchema } from '../../../../../utils/validation.mjs';
19
19
  import { DocumentActionButton } from '../../DocumentActions.mjs';
20
20
  import { FormLayout } from '../../FormLayout.mjs';
21
+ import { ComponentProvider } from '../ComponentContext.mjs';
21
22
 
22
23
  function getCollectionType(url) {
23
24
  const regex = new RegExp(`(${COLLECTION_TYPES}|${SINGLE_TYPES})`);
@@ -30,23 +31,37 @@ const StyledModalContent = styled(Modal.Content)`
30
31
  height: 90%;
31
32
  max-height: 100%;
32
33
  `;
34
+ const getFullPageUrl = (currentDocumentMeta)=>{
35
+ const isSingleType = currentDocumentMeta.collectionType === SINGLE_TYPES;
36
+ const queryParams = currentDocumentMeta.params?.locale ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}` : '';
37
+ return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}${isSingleType ? '' : '/' + currentDocumentMeta.documentId}${queryParams}`;
38
+ };
33
39
  function reducer(state, action) {
34
40
  switch(action.type){
35
41
  case 'GO_TO_RELATION':
36
42
  if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {
37
43
  return {
38
44
  ...state,
39
- confirmDialogIntent: action.payload.document
45
+ confirmDialogIntent: action.payload.document,
46
+ fieldToConnect: action.payload.fieldToConnect,
47
+ fieldToConnectUID: action.payload.fieldToConnectUID
40
48
  };
41
49
  }
50
+ const lastItemDocumentHistory = state.documentHistory.at(-1);
51
+ const hasToResetDocumentHistory = lastItemDocumentHistory && !lastItemDocumentHistory.documentId;
42
52
  return {
43
53
  ...state,
44
- documentHistory: [
54
+ // Reset document history if the last item has documentId undefined
55
+ documentHistory: hasToResetDocumentHistory ? [
56
+ action.payload.document
57
+ ] : [
45
58
  ...state.documentHistory,
46
59
  action.payload.document
47
60
  ],
48
61
  confirmDialogIntent: null,
49
- isModalOpen: true
62
+ isModalOpen: true,
63
+ fieldToConnect: hasToResetDocumentHistory ? undefined : action.payload.fieldToConnect,
64
+ fieldToConnectUID: hasToResetDocumentHistory ? undefined : action.payload.fieldToConnectUID
50
65
  };
51
66
  case 'GO_BACK':
52
67
  if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {
@@ -74,6 +89,21 @@ function reducer(state, action) {
74
89
  isModalOpen: false,
75
90
  confirmDialogIntent: null
76
91
  };
92
+ case 'GO_TO_CREATED_RELATION':
93
+ return {
94
+ ...state,
95
+ // Reset document history if the last item has documentId undefined
96
+ documentHistory: state.documentHistory ? [
97
+ ...state.documentHistory.slice(0, -1),
98
+ action.payload.document
99
+ ] : [
100
+ action.payload.document
101
+ ],
102
+ confirmDialogIntent: null,
103
+ isModalOpen: true,
104
+ fieldToConnect: undefined,
105
+ fieldToConnectUID: undefined
106
+ };
77
107
  case 'CANCEL_CONFIRM_DIALOG':
78
108
  return {
79
109
  ...state,
@@ -103,21 +133,17 @@ function reducer(state, action) {
103
133
  }
104
134
  }
105
135
  const [RelationModalProvider, useRelationModal] = createContext('RelationModal');
106
- const getFullPageUrl = (currentDocumentMeta)=>{
107
- const isSingleType = currentDocumentMeta.collectionType === SINGLE_TYPES;
108
- const queryParams = currentDocumentMeta.params?.locale ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}` : '';
109
- return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}${isSingleType ? '' : '/' + currentDocumentMeta.documentId}${queryParams}`;
110
- };
111
- /**
112
- * Component responsible of rendering its children wrapped in a modal, form and context if needed
113
- */ const RelationModalRenderer = ({ children, trigger, relation })=>{
114
- const { formatMessage } = useIntl();
115
- const navigate = useNavigate();
136
+ function isRenderProp(children) {
137
+ return typeof children === 'function';
138
+ }
139
+ const RootRelationRenderer = (props)=>{
140
+ const { children } = props;
116
141
  const [state, dispatch] = React.useReducer(reducer, {
117
142
  documentHistory: [],
118
143
  confirmDialogIntent: null,
119
144
  isModalOpen: false,
120
- hasUnsavedChanges: false
145
+ hasUnsavedChanges: false,
146
+ fieldToConnect: undefined
121
147
  });
122
148
  const rootDocument = useDoc();
123
149
  const [{ query }] = useQueryParams();
@@ -132,11 +158,9 @@ const getFullPageUrl = (currentDocumentMeta)=>{
132
158
  };
133
159
  const currentDocumentMeta = state.documentHistory.at(-1) ?? rootDocumentMeta;
134
160
  const currentDocument = useDocument(currentDocumentMeta);
135
- const parentContextValue = useRelationModal('RelationContextWrapper', (state)=>state, false);
136
- // A parent relation is already rendering a modal. In this case simply render the trigger
137
- if (parentContextValue) {
138
- return trigger;
139
- }
161
+ // TODO: check if we can remove the single type check
162
+ const isSingleType = currentDocumentMeta.collectionType === SINGLE_TYPES;
163
+ const isCreating = !currentDocumentMeta.documentId && !isSingleType;
140
164
  /**
141
165
  * There is no parent relation, so the relation modal doesn't exist. Create it and set up all the
142
166
  * pieces that will be used by potential child relations: the context, header, form, and footer.
@@ -146,18 +170,64 @@ const getFullPageUrl = (currentDocumentMeta)=>{
146
170
  rootDocumentMeta: rootDocumentMeta,
147
171
  currentDocumentMeta: currentDocumentMeta,
148
172
  currentDocument: currentDocument,
173
+ isCreating: isCreating,
174
+ children: /*#__PURE__*/ jsx(RelationModal, {
175
+ children: isRenderProp(children) ? children({
176
+ dispatch
177
+ }) : props.relation && /*#__PURE__*/ jsx(RelationModalTrigger, {
178
+ relation: props.relation,
179
+ children: children
180
+ })
181
+ })
182
+ });
183
+ };
184
+ const NestedRelationRenderer = (props)=>{
185
+ const { children } = props;
186
+ const dispatch = useRelationModal('NestedRelation', (state)=>state.dispatch);
187
+ return isRenderProp(children) ? children({
188
+ dispatch
189
+ }) : props.relation && /*#__PURE__*/ jsx(RelationModalTrigger, {
190
+ relation: props.relation,
191
+ children: children
192
+ }); /* This is the trigger that will be rendered in the parent relation */
193
+ };
194
+ /**
195
+ * Component responsible for rendering its children wrapped in a modal, form and context if needed
196
+ */ const RelationModalRenderer = (props)=>{
197
+ // We're in a nested relation if the relation modal context is not undefined
198
+ const isNested = useRelationModal('RelationContextWrapper', (state)=>state != undefined, false);
199
+ return isNested ? /*#__PURE__*/ jsx(NestedRelationRenderer, {
200
+ ...props
201
+ }) : /*#__PURE__*/ jsx(RootRelationRenderer, {
202
+ ...props
203
+ });
204
+ };
205
+ /* -------------------------------------------------------------------------------------------------
206
+ * RelationModal
207
+ * -----------------------------------------------------------------------------------------------*/ const generateCreateUrl = (currentDocumentMeta)=>{
208
+ return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}/create${currentDocumentMeta.params?.locale ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}` : ''}`;
209
+ };
210
+ const RelationModal = ({ children })=>{
211
+ const { formatMessage } = useIntl();
212
+ const navigate = useNavigate();
213
+ const state = useRelationModal('RelationModalForm', (state)=>state.state);
214
+ const dispatch = useRelationModal('RelationModalForm', (state)=>state.dispatch);
215
+ const currentDocumentMeta = useRelationModal('RelationModalForm', (state)=>state.currentDocumentMeta);
216
+ const currentDocument = useRelationModal('RelationModalForm', (state)=>state.currentDocument);
217
+ const isCreating = useRelationModal('RelationModalForm', (state)=>state.isCreating);
218
+ /*
219
+ * We must wrap the modal window with Component Provider with reset values
220
+ * to avoid inheriting id and uid from the root document and having weird
221
+ * behaviors with simple relationships..
222
+ */ return /*#__PURE__*/ jsx(ComponentProvider, {
223
+ id: undefined,
224
+ level: -1,
225
+ uid: undefined,
226
+ type: undefined,
149
227
  children: /*#__PURE__*/ jsxs(Modal.Root, {
150
228
  open: state.isModalOpen,
151
229
  onOpenChange: (open)=>{
152
- if (open) {
153
- dispatch({
154
- type: 'GO_TO_RELATION',
155
- payload: {
156
- document: relation,
157
- shouldBypassConfirmation: false
158
- }
159
- });
160
- } else {
230
+ if (!open) {
161
231
  dispatch({
162
232
  type: 'CLOSE_MODAL',
163
233
  payload: {
@@ -167,7 +237,7 @@ const getFullPageUrl = (currentDocumentMeta)=>{
167
237
  }
168
238
  },
169
239
  children: [
170
- trigger,
240
+ children,
171
241
  /*#__PURE__*/ jsxs(StyledModalContent, {
172
242
  children: [
173
243
  /*#__PURE__*/ jsx(Modal.Header, {
@@ -202,7 +272,10 @@ const getFullPageUrl = (currentDocumentMeta)=>{
202
272
  /*#__PURE__*/ jsx(Typography, {
203
273
  tag: "span",
204
274
  fontWeight: 600,
205
- children: formatMessage({
275
+ children: isCreating ? formatMessage({
276
+ id: 'content-manager.relation.create',
277
+ defaultMessage: 'Create a relation'
278
+ }) : formatMessage({
206
279
  id: 'content-manager.components.RelationInputModal.modal-title',
207
280
  defaultMessage: 'Edit a relation'
208
281
  })
@@ -215,7 +288,11 @@ const getFullPageUrl = (currentDocumentMeta)=>{
215
288
  type: 'GO_FULL_PAGE'
216
289
  });
217
290
  if (!state.hasUnsavedChanges) {
218
- navigate(getFullPageUrl(currentDocumentMeta));
291
+ if (isCreating) {
292
+ navigate(generateCreateUrl(currentDocumentMeta));
293
+ } else {
294
+ navigate(getFullPageUrl(currentDocumentMeta));
295
+ }
219
296
  }
220
297
  },
221
298
  variant: "tertiary",
@@ -230,8 +307,8 @@ const getFullPageUrl = (currentDocumentMeta)=>{
230
307
  }),
231
308
  /*#__PURE__*/ jsx(Modal.Body, {
232
309
  children: /*#__PURE__*/ jsx(Form, {
233
- method: "PUT",
234
- initialValues: currentDocument.getInitialFormValues(),
310
+ method: isCreating ? 'POST' : 'PUT',
311
+ initialValues: currentDocument.getInitialFormValues(isCreating),
235
312
  validate: (values, options)=>{
236
313
  const yupSchema = createYupSchema(currentDocument.schema?.attributes, currentDocument.components, {
237
314
  status: currentDocument.document?.status,
@@ -241,7 +318,7 @@ const getFullPageUrl = (currentDocumentMeta)=>{
241
318
  abortEarly: false
242
319
  });
243
320
  },
244
- children: children
321
+ children: /*#__PURE__*/ jsx(RelationModalBody, {})
245
322
  })
246
323
  })
247
324
  ]
@@ -252,7 +329,7 @@ const getFullPageUrl = (currentDocumentMeta)=>{
252
329
  };
253
330
  /**
254
331
  * All the main content (not header and footer) of the relation modal, plus the confirmation dialog.
255
- * Will be wrapped in a Modal.Body by the RelationModalRenderer.
332
+ * Will be wrapped in a Modal.Body by the RelationModal component.
256
333
  * Cannot be moved directly inside RelationModal because it needs access to the context via hooks.
257
334
  */ const RelationModalBody = ()=>{
258
335
  const navigate = useNavigate();
@@ -263,6 +340,7 @@ const getFullPageUrl = (currentDocumentMeta)=>{
263
340
  const dispatch = useRelationModal('RelationModalForm', (state)=>state.dispatch);
264
341
  const rootDocumentMeta = useRelationModal('RelationModalForm', (state)=>state.rootDocumentMeta);
265
342
  const currentDocumentMeta = useRelationModal('RelationModalForm', (state)=>state.currentDocumentMeta);
343
+ const isCreating = useRelationModal('RelationModalForm', (state)=>state.isCreating);
266
344
  /**
267
345
  * One-way sync the modified state from the form to the modal state.
268
346
  * It is needed because we need to consume state from the form context in order to lift it up
@@ -304,7 +382,11 @@ const getFullPageUrl = (currentDocumentMeta)=>{
304
382
  if (isRootDocumentUrl) {
305
383
  handleCloseModal(true);
306
384
  } else {
307
- navigate(fullPageUrl);
385
+ if (isCreating) {
386
+ navigate(generateCreateUrl(currentDocumentMeta));
387
+ } else {
388
+ navigate(fullPageUrl);
389
+ }
308
390
  }
309
391
  };
310
392
  const handleConfirm = ()=>{
@@ -334,7 +416,7 @@ const getFullPageUrl = (currentDocumentMeta)=>{
334
416
  };
335
417
  return /*#__PURE__*/ jsxs(Fragment, {
336
418
  children: [
337
- /*#__PURE__*/ jsx(RelationEditView, {}),
419
+ /*#__PURE__*/ jsx(RelationModalForm, {}),
338
420
  /*#__PURE__*/ jsx(Dialog.Root, {
339
421
  open: state.confirmDialogIntent != null,
340
422
  children: /*#__PURE__*/ jsx(ConfirmDialog, {
@@ -352,7 +434,7 @@ const getFullPageUrl = (currentDocumentMeta)=>{
352
434
  ]
353
435
  });
354
436
  };
355
- const ModalTrigger = ({ children, relation })=>{
437
+ const RelationModalTrigger = ({ children, relation })=>{
356
438
  const dispatch = useRelationModal('ModalTrigger', (state)=>state.dispatch);
357
439
  return /*#__PURE__*/ jsx(StyledTextButton, {
358
440
  onClick: ()=>{
@@ -367,16 +449,6 @@ const ModalTrigger = ({ children, relation })=>{
367
449
  children: children
368
450
  });
369
451
  };
370
- const RelationModal = /*#__PURE__*/ React.memo(({ relation, children })=>{
371
- return /*#__PURE__*/ jsx(RelationModalRenderer, {
372
- relation: relation,
373
- trigger: /*#__PURE__*/ jsx(ModalTrigger, {
374
- relation: relation,
375
- children: children
376
- }),
377
- children: /*#__PURE__*/ jsx(RelationModalBody, {})
378
- });
379
- });
380
452
  const StyledTextButton = styled(TextButton)`
381
453
  max-width: 100%;
382
454
  & > span {
@@ -390,13 +462,14 @@ const StyledTextButton = styled(TextButton)`
390
462
  /**
391
463
  * The mini edit view for a relation that is displayed inside a modal.
392
464
  * It's complete with its header, document actions and form layout.
393
- */ const RelationEditView = ()=>{
465
+ */ const RelationModalForm = ()=>{
394
466
  const { formatMessage } = useIntl();
395
- const currentDocumentMeta = useRelationModal('RelationModalBody', (state)=>state.currentDocumentMeta);
396
- const currentDocument = useRelationModal('RelationModalBody', (state)=>state.currentDocument);
467
+ const currentDocumentMeta = useRelationModal('RelationModalForm', (state)=>state.currentDocumentMeta);
468
+ const isCreating = useRelationModal('RelationModalForm', (state)=>state.isCreating);
469
+ const currentDocument = useRelationModal('RelationModalForm', (state)=>state.currentDocument);
397
470
  const documentLayoutResponse = useDocumentLayout(currentDocumentMeta.model);
398
- const plugins = useStrapiApp('RelationModalBody', (state)=>state.plugins);
399
- const initialValues = currentDocument.getInitialFormValues();
471
+ const plugins = useStrapiApp('RelationModalForm', (state)=>state.plugins);
472
+ const initialValues = isCreating ? currentDocument.getInitialFormValues(isCreating) : currentDocument.getInitialFormValues();
400
473
  const { permissions = [], isLoading: isLoadingPermissions, error } = useRBAC(PERMISSIONS.map((action)=>({
401
474
  action,
402
475
  subject: currentDocumentMeta.model
@@ -411,7 +484,7 @@ const StyledTextButton = styled(TextButton)`
411
484
  })
412
485
  });
413
486
  }
414
- if (error || !currentDocumentMeta.model || documentLayoutResponse.error || !currentDocument.document || !currentDocument.meta || !currentDocument.schema || !initialValues) {
487
+ if (error || !currentDocumentMeta.model || documentLayoutResponse.error || !isCreating && !currentDocument.document || !isCreating && !currentDocument.meta || !currentDocument.schema || !initialValues) {
415
488
  return /*#__PURE__*/ jsx(Flex, {
416
489
  alignItems: "center",
417
490
  height: "100%",
@@ -520,5 +593,5 @@ const StyledTextButton = styled(TextButton)`
520
593
  });
521
594
  };
522
595
 
523
- export { RelationModal, getCollectionType, reducer, useRelationModal };
596
+ export { RelationModalRenderer, getCollectionType, reducer, useRelationModal };
524
597
  //# sourceMappingURL=RelationModal.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"RelationModal.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n ConfirmDialog,\n DescriptionComponentRenderer,\n Form as FormContext,\n useRBAC,\n useStrapiApp,\n createContext,\n useForm,\n useQueryParams,\n} 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 { useIntl } from 'react-intl';\nimport { 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';\n\nimport type { ContentManagerPlugin, DocumentActionProps } from '../../../../../content-manager';\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\n/* -------------------------------------------------------------------------------------------------\n * RelationContextWrapper\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}\n\ntype Action =\n | {\n type: 'GO_TO_RELATION';\n payload: {\n document: DocumentMeta;\n shouldBypassConfirmation: boolean;\n };\n }\n | {\n type: 'GO_BACK';\n payload: { shouldBypassConfirmation: boolean };\n }\n | {\n type: 'GO_FULL_PAGE';\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 { ...state, confirmDialogIntent: action.payload.document };\n }\n\n return {\n ...state,\n documentHistory: [...state.documentHistory, action.payload.document],\n confirmDialogIntent: null,\n isModalOpen: true,\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 '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 };\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}\n\nconst [RelationModalProvider, useRelationModal] =\n createContext<RelationModalContextValue>('RelationModal');\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 * Component responsible of rendering its children wrapped in a modal, form and context if needed\n */\nconst RelationModalRenderer = ({\n children,\n trigger,\n relation,\n}: {\n children: React.ReactNode;\n trigger: React.ReactNode;\n relation: DocumentMeta;\n}) => {\n const { formatMessage } = useIntl();\n const navigate = useNavigate();\n\n const [state, dispatch] = React.useReducer(reducer, {\n documentHistory: [],\n confirmDialogIntent: null,\n isModalOpen: false,\n hasUnsavedChanges: false,\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 const currentDocumentMeta = state.documentHistory.at(-1) ?? rootDocumentMeta;\n const currentDocument = useDocument(currentDocumentMeta);\n\n const parentContextValue = useRelationModal('RelationContextWrapper', (state) => state, false);\n\n // A parent relation is already rendering a modal. In this case simply render the trigger\n if (parentContextValue) {\n return trigger;\n }\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 >\n <Modal.Root\n open={state.isModalOpen}\n onOpenChange={(open) => {\n if (open) {\n dispatch({\n type: 'GO_TO_RELATION',\n payload: { document: relation, shouldBypassConfirmation: false },\n });\n } else {\n dispatch({\n type: 'CLOSE_MODAL',\n payload: { shouldBypassConfirmation: false },\n });\n }\n }}\n >\n {trigger}\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 {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 navigate(getFullPageUrl(currentDocumentMeta));\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=\"PUT\"\n initialValues={currentDocument.getInitialFormValues()}\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 {children}\n </FormContext>\n </Modal.Body>\n </StyledModalContent>\n </Modal.Root>\n </RelationModalProvider>\n );\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 RelationModalRenderer.\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\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 navigate(fullPageUrl);\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: { document: state.confirmDialogIntent, shouldBypassConfirmation: true },\n });\n }\n };\n\n return (\n <>\n <RelationEditView />\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 ModalTrigger = ({\n children,\n relation,\n}: {\n children: React.ReactNode;\n relation: DocumentMeta;\n}) => {\n const dispatch = useRelationModal('ModalTrigger', (state) => state.dispatch);\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\ninterface RelationModalProps {\n children: React.ReactNode;\n relation: DocumentMeta;\n}\n\nconst RelationModal = React.memo(({ relation, children }: RelationModalProps) => {\n return (\n <RelationModalRenderer\n relation={relation}\n trigger={<ModalTrigger relation={relation}>{children}</ModalTrigger>}\n >\n <RelationModalBody />\n </RelationModalRenderer>\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\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 RelationEditView = () => {\n const { formatMessage } = useIntl();\n\n const currentDocumentMeta = useRelationModal(\n 'RelationModalBody',\n (state) => state.currentDocumentMeta\n );\n const currentDocument = useRelationModal('RelationModalBody', (state) => state.currentDocument);\n const documentLayoutResponse = useDocumentLayout(currentDocumentMeta.model);\n const plugins = useStrapiApp('RelationModalBody', (state) => state.plugins);\n\n const initialValues = 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 !currentDocument.document ||\n !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 { RelationModal, reducer, useRelationModal };\nexport type { State, Action };\n"],"names":["getCollectionType","url","regex","RegExp","COLLECTION_TYPES","SINGLE_TYPES","match","undefined","StyledModalContent","styled","Modal","Content","reducer","state","action","type","hasUnsavedChanges","payload","shouldBypassConfirmation","confirmDialogIntent","document","documentHistory","isModalOpen","slice","RelationModalProvider","useRelationModal","createContext","getFullPageUrl","currentDocumentMeta","isSingleType","collectionType","queryParams","params","locale","model","documentId","RelationModalRenderer","children","trigger","relation","formatMessage","useIntl","navigate","useNavigate","dispatch","React","useReducer","rootDocument","useDoc","query","useQueryParams","useMemo","buildValidParams","rootDocumentMeta","at","currentDocument","useDocument","parentContextValue","_jsx","_jsxs","Root","open","onOpenChange","Header","gap","Flex","justifyContent","alignItems","width","IconButton","withTooltip","label","id","defaultMessage","variant","disabled","length","onClick","marginRight","ArrowLeft","Typography","tag","fontWeight","ArrowsOut","Body","FormContext","method","initialValues","getInitialFormValues","validate","values","options","yupSchema","createYupSchema","schema","attributes","components","status","abortEarly","RelationModalBody","pathname","search","useLocation","triggerRefetchDocument","useLazyGetDocumentQuery","modified","useForm","isSubmitting","useEffect","handleCloseModal","handleRedirection","editViewUrl","fullPageUrl","isRootDocumentUrl","includes","handleConfirm","_Fragment","RelationEditView","Dialog","ConfirmDialog","onConfirm","onCancel","ModalTrigger","StyledTextButton","RelationModal","memo","TextButton","theme","fontSizes","documentLayoutResponse","useDocumentLayout","plugins","useStrapiApp","permissions","isLoading","isLoadingPermissions","error","useRBAC","PERMISSIONS","map","subject","Loader","small","meta","height","EmptyStateLayout","icon","WarningCircle","content","documentTitle","getTitle","edit","settings","mainField","hasDraftAndPublished","draftAndPublish","props","activeTab","DocumentRBAC","direction","DescriptionComponentRenderer","descriptions","apis","getDocumentActions","actions","filteredActions","filter","position","flat","primaryAction","secondaryAction","DocumentActionButton","Box","DocumentStatus","flex","overflow","paddingTop","FormLayout","layout","hasBackground"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2CO,SAASA,kBAAkBC,GAAW,EAAA;IAC3C,MAAMC,KAAAA,GAAQ,IAAIC,MAAAA,CAAO,CAAC,CAAC,EAAEC,gBAAAA,CAAiB,CAAC,EAAEC,YAAa,CAAA,CAAC,CAAC,CAAA;IAChE,MAAMC,KAAAA,GAAQL,GAAIK,CAAAA,KAAK,CAACJ,KAAAA,CAAAA;AACxB,IAAA,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AAA;AACzB,oBAAA,QAAA,gBAAApH,GAACuH,CAAAA,UAAAA,EAAAA;wBACCC,MAAQjD,EAAAA,sBAAAA,CAAuBsB,IAAI,CAAC2B,MAAM;wBAC1C9J,QAAUmC,EAAAA,eAAAA;wBACV4H,aAAe,EAAA;;;;;;AAM3B,CAAA;;;;"}
1
+ {"version":3,"file":"RelationModal.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n ConfirmDialog,\n DescriptionComponentRenderer,\n Form as FormContext,\n useRBAC,\n useStrapiApp,\n createContext,\n useForm,\n useQueryParams,\n} 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 { useIntl } from 'react-intl';\nimport { 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 { ContentManagerPlugin, DocumentActionProps } from '../../../../../content-manager';\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}\n\ntype Action =\n | {\n type: 'GO_TO_RELATION';\n payload: {\n document: DocumentMeta;\n shouldBypassConfirmation: boolean;\n fieldToConnect?: string;\n fieldToConnectUID?: string;\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 };\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 };\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 };\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 };\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 };\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}\n\nconst [RelationModalProvider, useRelationModal] =\n createContext<RelationModalContextValue>('RelationModal');\n\nfunction isRenderProp(\n children: RelationModalRendererProps['children']\n): children is (props: { dispatch: (action: Action) => void }) => 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: { dispatch: (action: Action) => void }) => 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 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 >\n <RelationModal>\n {isRenderProp(children)\n ? children({ dispatch })\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\n return isRenderProp(children)\n ? children({ dispatch })\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\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\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={currentDocument.getInitialFormValues(isCreating)}\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: { document: state.confirmDialogIntent, shouldBypassConfirmation: true },\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\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\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 { reducer, RelationModalRenderer, useRelationModal };\nexport type { State, Action };\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","lastItemDocumentHistory","documentHistory","at","hasToResetDocumentHistory","isModalOpen","slice","RelationModalProvider","useRelationModal","createContext","isRenderProp","children","RootRelationRenderer","props","dispatch","React","useReducer","rootDocument","useDoc","query","useQueryParams","useMemo","buildValidParams","rootDocumentMeta","currentDocument","useDocument","isCreating","_jsx","RelationModal","relation","RelationModalTrigger","NestedRelationRenderer","RelationModalRenderer","isNested","generateCreateUrl","formatMessage","useIntl","navigate","useNavigate","ComponentProvider","id","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","initialValues","getInitialFormValues","validate","values","options","yupSchema","createYupSchema","schema","attributes","components","status","abortEarly","RelationModalBody","pathname","search","useLocation","triggerRefetchDocument","useLazyGetDocumentQuery","modified","useForm","isSubmitting","useEffect","handleCloseModal","handleRedirection","editViewUrl","fullPageUrl","isRootDocumentUrl","includes","handleConfirm","_Fragment","RelationModalForm","Dialog","ConfirmDialog","onConfirm","onCancel","StyledTextButton","TextButton","theme","fontSizes","documentLayoutResponse","useDocumentLayout","plugins","useStrapiApp","permissions","isLoading","isLoadingPermissions","error","useRBAC","PERMISSIONS","map","subject","Loader","small","meta","height","EmptyStateLayout","icon","WarningCircle","content","documentTitle","getTitle","edit","settings","mainField","hasDraftAndPublished","draftAndPublish","activeTab","DocumentRBAC","direction","DescriptionComponentRenderer","descriptions","apis","getDocumentActions","actions","filteredActions","filter","position","flat","primaryAction","secondaryAction","DocumentActionButton","Box","DocumentStatus","flex","overflow","paddingTop","FormLayout","layout","hasBackground"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4CO,SAASA,kBAAkBC,GAAW,EAAA;IAC3C,MAAMC,KAAAA,GAAQ,IAAIC,MAAAA,CAAO,CAAC,CAAC,EAAEC,gBAAAA,CAAiB,CAAC,EAAEC,YAAa,CAAA,CAAC,CAAC,CAAA;IAChE,MAAMC,KAAAA,GAAQL,GAAIK,CAAAA,KAAK,CAACJ,KAAAA,CAAAA;AACxB,IAAA,OAAOI,KAAQA,GAAAA,KAAK,CAAC,CAAA,CAAE,GAAGC,SAAAA;AAC5B;AAEA,MAAMC,kBAAqBC,GAAAA,MAAAA,CAAOC,KAAMC,CAAAA,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