@strapi/content-manager 0.0.0-experimental.59ce88771272039a9d868fba2f7b503edf715c6a → 0.0.0-experimental.5a34dd1236f692f16e40784fcca5c11e0e55dc5a

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 (140) hide show
  1. package/LICENSE +18 -3
  2. package/dist/_chunks/{ComponentConfigurationPage-WRPUXGd6.js → ComponentConfigurationPage-CQDCxI8x.js} +3 -3
  3. package/dist/_chunks/{ComponentConfigurationPage-WRPUXGd6.js.map → ComponentConfigurationPage-CQDCxI8x.js.map} +1 -1
  4. package/dist/_chunks/{ComponentConfigurationPage-gdUj_t-O.mjs → ComponentConfigurationPage-jmWwucg_.mjs} +3 -3
  5. package/dist/_chunks/{ComponentConfigurationPage-gdUj_t-O.mjs.map → ComponentConfigurationPage-jmWwucg_.mjs.map} +1 -1
  6. package/dist/_chunks/{EditConfigurationPage-C1vjMBgy.js → EditConfigurationPage-Ce4bIm4n.js} +3 -3
  7. package/dist/_chunks/{EditConfigurationPage-C1vjMBgy.js.map → EditConfigurationPage-Ce4bIm4n.js.map} +1 -1
  8. package/dist/_chunks/{EditConfigurationPage-BwuIPOJG.mjs → EditConfigurationPage-W07CEdm2.mjs} +3 -3
  9. package/dist/_chunks/{EditConfigurationPage-BwuIPOJG.mjs.map → EditConfigurationPage-W07CEdm2.mjs.map} +1 -1
  10. package/dist/_chunks/{EditViewPage-DbcGfyqK.js → EditViewPage-CqHMM0P0.js} +30 -9
  11. package/dist/_chunks/EditViewPage-CqHMM0P0.js.map +1 -0
  12. package/dist/_chunks/{EditViewPage-0MiFkXa8.mjs → EditViewPage-al5OO1NR.mjs} +30 -9
  13. package/dist/_chunks/EditViewPage-al5OO1NR.mjs.map +1 -0
  14. package/dist/_chunks/{Field-BG1xu38N.js → Field-DSOUlTCm.js} +519 -155
  15. package/dist/_chunks/Field-DSOUlTCm.js.map +1 -0
  16. package/dist/_chunks/{Field-BDMSCcy5.mjs → Field-EeG6NQ7x.mjs} +517 -153
  17. package/dist/_chunks/Field-EeG6NQ7x.mjs.map +1 -0
  18. package/dist/_chunks/{Form-CPVWavB8.mjs → Form-BAo9ANb_.mjs} +40 -18
  19. package/dist/_chunks/Form-BAo9ANb_.mjs.map +1 -0
  20. package/dist/_chunks/{Form-9BnFyUjy.js → Form-DAEfHKzm.js} +40 -18
  21. package/dist/_chunks/Form-DAEfHKzm.js.map +1 -0
  22. package/dist/_chunks/{History-BVpd8LP3.mjs → History-BpLIu67W.mjs} +64 -26
  23. package/dist/_chunks/History-BpLIu67W.mjs.map +1 -0
  24. package/dist/_chunks/{History-BWWxLt2Z.js → History-CTFvy6XH.js} +63 -25
  25. package/dist/_chunks/History-CTFvy6XH.js.map +1 -0
  26. package/dist/_chunks/{ListConfigurationPage-6swzjdAZ.js → ListConfigurationPage-CDzlMBz_.js} +20 -8
  27. package/dist/_chunks/ListConfigurationPage-CDzlMBz_.js.map +1 -0
  28. package/dist/_chunks/{ListConfigurationPage-DozVMKcR.mjs → ListConfigurationPage-DOqj5f8Y.mjs} +20 -8
  29. package/dist/_chunks/ListConfigurationPage-DOqj5f8Y.mjs.map +1 -0
  30. package/dist/_chunks/{ListViewPage-Ds0ulgfG.mjs → ListViewPage-BbXYNI0v.mjs} +59 -41
  31. package/dist/_chunks/ListViewPage-BbXYNI0v.mjs.map +1 -0
  32. package/dist/_chunks/{ListViewPage-BlzfjS2Q.js → ListViewPage-D0fpPYKp.js} +61 -43
  33. package/dist/_chunks/ListViewPage-D0fpPYKp.js.map +1 -0
  34. package/dist/_chunks/{NoContentTypePage-D2nCCWEl.js → NoContentTypePage-DTzkSAV5.js} +2 -2
  35. package/dist/_chunks/{NoContentTypePage-D2nCCWEl.js.map → NoContentTypePage-DTzkSAV5.js.map} +1 -1
  36. package/dist/_chunks/{NoContentTypePage-BH11kaKt.mjs → NoContentTypePage-w2Q0VVOT.mjs} +2 -2
  37. package/dist/_chunks/{NoContentTypePage-BH11kaKt.mjs.map → NoContentTypePage-w2Q0VVOT.mjs.map} +1 -1
  38. package/dist/_chunks/{NoPermissionsPage-DN_JlsU2.js → NoPermissionsPage-BoI2rU68.js} +2 -2
  39. package/dist/_chunks/{NoPermissionsPage-DN_JlsU2.js.map → NoPermissionsPage-BoI2rU68.js.map} +1 -1
  40. package/dist/_chunks/{NoPermissionsPage-BT2Tn0D_.mjs → NoPermissionsPage-Km0Vk5Wp.mjs} +2 -2
  41. package/dist/_chunks/{NoPermissionsPage-BT2Tn0D_.mjs.map → NoPermissionsPage-Km0Vk5Wp.mjs.map} +1 -1
  42. package/dist/_chunks/{Relations-Dnag3fhV.mjs → Relations-C_bpmSuQ.mjs} +51 -29
  43. package/dist/_chunks/Relations-C_bpmSuQ.mjs.map +1 -0
  44. package/dist/_chunks/{Relations-CcgFTcWo.js → Relations-D6Nz5ksc.js} +51 -29
  45. package/dist/_chunks/Relations-D6Nz5ksc.js.map +1 -0
  46. package/dist/_chunks/{en-fbKQxLGn.js → en-Bm0D0IWz.js} +17 -15
  47. package/dist/_chunks/{en-fbKQxLGn.js.map → en-Bm0D0IWz.js.map} +1 -1
  48. package/dist/_chunks/{en-Ux26r5pl.mjs → en-DKV44jRb.mjs} +17 -15
  49. package/dist/_chunks/{en-Ux26r5pl.mjs.map → en-DKV44jRb.mjs.map} +1 -1
  50. package/dist/_chunks/{index-CWpLBSt0.js → index-BsMu2oVP.js} +1004 -659
  51. package/dist/_chunks/index-BsMu2oVP.js.map +1 -0
  52. package/dist/_chunks/{index-JNNNKUHs.mjs → index-DcQ6xogO.mjs} +1015 -671
  53. package/dist/_chunks/index-DcQ6xogO.mjs.map +1 -0
  54. package/dist/_chunks/{layout--iHdZzRk.js → layout-B4aCAdTt.js} +25 -12
  55. package/dist/_chunks/layout-B4aCAdTt.js.map +1 -0
  56. package/dist/_chunks/{layout-DC503LnF.mjs → layout-BavJ6v4B.mjs} +27 -14
  57. package/dist/_chunks/layout-BavJ6v4B.mjs.map +1 -0
  58. package/dist/_chunks/{relations-CTje5t-a.mjs → relations-DMG453Od.mjs} +2 -2
  59. package/dist/_chunks/{relations-CTje5t-a.mjs.map → relations-DMG453Od.mjs.map} +1 -1
  60. package/dist/_chunks/{relations-BbHizA5K.js → relations-Lrm9nz_m.js} +2 -2
  61. package/dist/_chunks/{relations-BbHizA5K.js.map → relations-Lrm9nz_m.js.map} +1 -1
  62. package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
  63. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
  64. package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
  65. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
  66. package/dist/admin/index.js +2 -1
  67. package/dist/admin/index.js.map +1 -1
  68. package/dist/admin/index.mjs +3 -2
  69. package/dist/admin/src/exports.d.ts +1 -1
  70. package/dist/admin/src/history/index.d.ts +3 -0
  71. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  72. package/dist/admin/src/hooks/useDocument.d.ts +32 -1
  73. package/dist/admin/src/index.d.ts +1 -0
  74. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +1 -0
  75. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
  76. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
  77. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
  78. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  79. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +4 -48
  80. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  81. package/dist/admin/src/services/api.d.ts +1 -1
  82. package/dist/admin/src/services/components.d.ts +2 -2
  83. package/dist/admin/src/services/contentTypes.d.ts +3 -3
  84. package/dist/admin/src/services/documents.d.ts +19 -17
  85. package/dist/admin/src/services/init.d.ts +1 -1
  86. package/dist/admin/src/services/relations.d.ts +2 -2
  87. package/dist/admin/src/services/uid.d.ts +3 -3
  88. package/dist/admin/src/utils/validation.d.ts +4 -1
  89. package/dist/server/index.js +248 -137
  90. package/dist/server/index.js.map +1 -1
  91. package/dist/server/index.mjs +249 -138
  92. package/dist/server/index.mjs.map +1 -1
  93. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  94. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  95. package/dist/server/src/controllers/uid.d.ts.map +1 -1
  96. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  97. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  98. package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
  99. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
  100. package/dist/server/src/history/services/history.d.ts.map +1 -1
  101. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  102. package/dist/server/src/history/services/utils.d.ts +2 -1
  103. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  104. package/dist/server/src/index.d.ts +4 -4
  105. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  106. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  107. package/dist/server/src/services/document-metadata.d.ts +8 -8
  108. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  109. package/dist/server/src/services/index.d.ts +4 -4
  110. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  111. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  112. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  113. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  114. package/dist/server/src/utils/index.d.ts +2 -0
  115. package/dist/server/src/utils/index.d.ts.map +1 -1
  116. package/dist/shared/contracts/collection-types.d.ts +3 -1
  117. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  118. package/package.json +12 -12
  119. package/dist/_chunks/EditViewPage-0MiFkXa8.mjs.map +0 -1
  120. package/dist/_chunks/EditViewPage-DbcGfyqK.js.map +0 -1
  121. package/dist/_chunks/Field-BDMSCcy5.mjs.map +0 -1
  122. package/dist/_chunks/Field-BG1xu38N.js.map +0 -1
  123. package/dist/_chunks/Form-9BnFyUjy.js.map +0 -1
  124. package/dist/_chunks/Form-CPVWavB8.mjs.map +0 -1
  125. package/dist/_chunks/History-BVpd8LP3.mjs.map +0 -1
  126. package/dist/_chunks/History-BWWxLt2Z.js.map +0 -1
  127. package/dist/_chunks/ListConfigurationPage-6swzjdAZ.js.map +0 -1
  128. package/dist/_chunks/ListConfigurationPage-DozVMKcR.mjs.map +0 -1
  129. package/dist/_chunks/ListViewPage-BlzfjS2Q.js.map +0 -1
  130. package/dist/_chunks/ListViewPage-Ds0ulgfG.mjs.map +0 -1
  131. package/dist/_chunks/Relations-CcgFTcWo.js.map +0 -1
  132. package/dist/_chunks/Relations-Dnag3fhV.mjs.map +0 -1
  133. package/dist/_chunks/index-CWpLBSt0.js.map +0 -1
  134. package/dist/_chunks/index-JNNNKUHs.mjs.map +0 -1
  135. package/dist/_chunks/layout--iHdZzRk.js.map +0 -1
  136. package/dist/_chunks/layout-DC503LnF.mjs.map +0 -1
  137. package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
  138. package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
  139. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
  140. package/strapi-server.js +0 -3
@@ -2,15 +2,16 @@
2
2
  const Icons = require("@strapi/icons");
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const strapiAdmin = require("@strapi/admin/strapi-admin");
5
- const qs = require("qs");
6
- const reactIntl = require("react-intl");
7
- const reactRouterDom = require("react-router-dom");
8
5
  const React = require("react");
9
6
  const designSystem = require("@strapi/design-system");
10
- const styledComponents = require("styled-components");
7
+ const mapValues = require("lodash/fp/mapValues");
8
+ const reactIntl = require("react-intl");
9
+ const reactRouterDom = require("react-router-dom");
11
10
  const yup = require("yup");
12
11
  const pipe = require("lodash/fp/pipe");
13
12
  const dateFns = require("date-fns");
13
+ const styledComponents = require("styled-components");
14
+ const qs = require("qs");
14
15
  const toolkit = require("@reduxjs/toolkit");
15
16
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
16
17
  function _interopNamespace(e) {
@@ -32,6 +33,7 @@ function _interopNamespace(e) {
32
33
  return Object.freeze(n);
33
34
  }
34
35
  const React__namespace = /* @__PURE__ */ _interopNamespace(React);
36
+ const mapValues__default = /* @__PURE__ */ _interopDefault(mapValues);
35
37
  const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
36
38
  const pipe__default = /* @__PURE__ */ _interopDefault(pipe);
37
39
  const __variableDynamicImportRuntimeHelper = (glob, path) => {
@@ -70,42 +72,6 @@ const useInjectionZone = (area) => {
70
72
  const [page, position] = area.split(".");
71
73
  return contentManagerPlugin.getInjectedComponents(page, position);
72
74
  };
73
- const HistoryAction = ({ model, document }) => {
74
- const { formatMessage } = reactIntl.useIntl();
75
- const [{ query }] = strapiAdmin.useQueryParams();
76
- const navigate = reactRouterDom.useNavigate();
77
- const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
78
- if (!window.strapi.features.isEnabled("cms-content-history")) {
79
- return null;
80
- }
81
- return {
82
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
83
- label: formatMessage({
84
- id: "content-manager.history.document-action",
85
- defaultMessage: "Content History"
86
- }),
87
- onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
88
- disabled: (
89
- /**
90
- * The user is creating a new document.
91
- * It hasn't been saved yet, so there's no history to go to
92
- */
93
- !document || /**
94
- * The document has been created but the current dimension has never been saved.
95
- * For example, the user is creating a new locale in an existing document,
96
- * so there's no history for the document in that locale
97
- */
98
- !document.id || /**
99
- * History is only available for content types created by the user.
100
- * These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
101
- * which start with `admin::` or `plugin::`
102
- */
103
- !model.startsWith("api::")
104
- ),
105
- position: "header"
106
- };
107
- };
108
- HistoryAction.type = "history";
109
75
  const ID = "id";
110
76
  const CREATED_BY_ATTRIBUTE_NAME = "createdBy";
111
77
  const UPDATED_BY_ATTRIBUTE_NAME = "updatedBy";
@@ -157,6 +123,7 @@ const DocumentRBAC = ({ children, permissions }) => {
157
123
  if (!slug) {
158
124
  throw new Error("Cannot find the slug param in the URL");
159
125
  }
126
+ const [{ rawQuery }] = strapiAdmin.useQueryParams();
160
127
  const userPermissions = strapiAdmin.useAuth("DocumentRBAC", (state) => state.permissions);
161
128
  const contentTypePermissions = React__namespace.useMemo(() => {
162
129
  const contentTypePermissions2 = userPermissions.filter(
@@ -167,7 +134,14 @@ const DocumentRBAC = ({ children, permissions }) => {
167
134
  return { ...acc, [action]: [permission] };
168
135
  }, {});
169
136
  }, [slug, userPermissions]);
170
- const { isLoading, allowedActions } = strapiAdmin.useRBAC(contentTypePermissions, permissions ?? void 0);
137
+ const { isLoading, allowedActions } = strapiAdmin.useRBAC(
138
+ contentTypePermissions,
139
+ permissions ?? void 0,
140
+ // TODO: useRBAC context should be typed and built differently
141
+ // We are passing raw query as context to the hook so that it can
142
+ // rely on the locale provided from DocumentRBAC for its permission calculations.
143
+ rawQuery
144
+ );
171
145
  const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
172
146
  const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
173
147
  const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
@@ -215,10 +189,12 @@ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
215
189
  "Document",
216
190
  "InitialData",
217
191
  "HistoryVersion",
218
- "Relations"
192
+ "Relations",
193
+ "UidAvailability"
219
194
  ]
220
195
  });
221
196
  const documentApi = contentManagerApi.injectEndpoints({
197
+ overrideExisting: true,
222
198
  endpoints: (builder) => ({
223
199
  autoCloneDocument: builder.mutation({
224
200
  query: ({ model, sourceId, query }) => ({
@@ -228,7 +204,12 @@ const documentApi = contentManagerApi.injectEndpoints({
228
204
  params: query
229
205
  }
230
206
  }),
231
- invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
207
+ invalidatesTags: (_result, error, { model }) => {
208
+ if (error) {
209
+ return [];
210
+ }
211
+ return [{ type: "Document", id: `${model}_LIST` }];
212
+ }
232
213
  }),
233
214
  cloneDocument: builder.mutation({
234
215
  query: ({ model, sourceId, data, params }) => ({
@@ -239,7 +220,10 @@ const documentApi = contentManagerApi.injectEndpoints({
239
220
  params
240
221
  }
241
222
  }),
242
- invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
223
+ invalidatesTags: (_result, _error, { model }) => [
224
+ { type: "Document", id: `${model}_LIST` },
225
+ { type: "UidAvailability", id: model }
226
+ ]
243
227
  }),
244
228
  /**
245
229
  * Creates a new collection-type document. This should ONLY be used for collection-types.
@@ -256,7 +240,8 @@ const documentApi = contentManagerApi.injectEndpoints({
256
240
  }),
257
241
  invalidatesTags: (result, _error, { model }) => [
258
242
  { type: "Document", id: `${model}_LIST` },
259
- "Relations"
243
+ "Relations",
244
+ { type: "UidAvailability", id: model }
260
245
  ]
261
246
  }),
262
247
  deleteDocument: builder.mutation({
@@ -297,7 +282,8 @@ const documentApi = contentManagerApi.injectEndpoints({
297
282
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
298
283
  },
299
284
  { type: "Document", id: `${model}_LIST` },
300
- "Relations"
285
+ "Relations",
286
+ { type: "UidAvailability", id: model }
301
287
  ];
302
288
  }
303
289
  }),
@@ -315,6 +301,7 @@ const documentApi = contentManagerApi.injectEndpoints({
315
301
  }),
316
302
  providesTags: (result, _error, arg) => {
317
303
  return [
304
+ { type: "Document", id: `ALL_LIST` },
318
305
  { type: "Document", id: `${arg.model}_LIST` },
319
306
  ...result?.results.map(({ documentId }) => ({
320
307
  type: "Document",
@@ -353,6 +340,11 @@ const documentApi = contentManagerApi.injectEndpoints({
353
340
  {
354
341
  type: "Document",
355
342
  id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
343
+ },
344
+ // Make it easy to invalidate all individual documents queries for a model
345
+ {
346
+ type: "Document",
347
+ id: `${model}_ALL_ITEMS`
356
348
  }
357
349
  ];
358
350
  }
@@ -416,8 +408,21 @@ const documentApi = contentManagerApi.injectEndpoints({
416
408
  type: "Document",
417
409
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
418
410
  },
419
- "Relations"
411
+ "Relations",
412
+ { type: "UidAvailability", id: model }
420
413
  ];
414
+ },
415
+ async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
416
+ const patchResult = dispatch(
417
+ documentApi.util.updateQueryData("getDocument", patch, (draft) => {
418
+ Object.assign(draft.data, data);
419
+ })
420
+ );
421
+ try {
422
+ await queryFulfilled;
423
+ } catch {
424
+ patchResult.undo();
425
+ }
421
426
  }
422
427
  }),
423
428
  unpublishDocument: builder.mutation({
@@ -487,20 +492,39 @@ const buildValidParams = (query) => {
487
492
  const isBaseQueryError = (error) => {
488
493
  return error.name !== void 0;
489
494
  };
490
- const createYupSchema = (attributes = {}, components = {}) => {
495
+ const arrayValidator = (attribute, options) => ({
496
+ message: strapiAdmin.translatedErrors.required,
497
+ test(value) {
498
+ if (options.status === "draft") {
499
+ return true;
500
+ }
501
+ if (!attribute.required) {
502
+ return true;
503
+ }
504
+ if (!value) {
505
+ return false;
506
+ }
507
+ if (Array.isArray(value) && value.length === 0) {
508
+ return false;
509
+ }
510
+ return true;
511
+ }
512
+ });
513
+ const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
491
514
  const createModelSchema = (attributes2) => yup__namespace.object().shape(
492
515
  Object.entries(attributes2).reduce((acc, [name, attribute]) => {
493
516
  if (DOCUMENT_META_FIELDS.includes(name)) {
494
517
  return acc;
495
518
  }
496
519
  const validations = [
520
+ addNullableValidation,
497
521
  addRequiredValidation,
498
522
  addMinLengthValidation,
499
523
  addMaxLengthValidation,
500
524
  addMinValidation,
501
525
  addMaxValidation,
502
526
  addRegexValidation
503
- ].map((fn) => fn(attribute));
527
+ ].map((fn) => fn(attribute, options));
504
528
  const transformSchema = pipe__default.default(...validations);
505
529
  switch (attribute.type) {
506
530
  case "component": {
@@ -510,12 +534,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
510
534
  ...acc,
511
535
  [name]: transformSchema(
512
536
  yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
513
- )
537
+ ).test(arrayValidator(attribute, options))
514
538
  };
515
539
  } else {
516
540
  return {
517
541
  ...acc,
518
- [name]: transformSchema(createModelSchema(attributes3))
542
+ [name]: transformSchema(createModelSchema(attributes3).nullable())
519
543
  };
520
544
  }
521
545
  }
@@ -537,7 +561,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
537
561
  }
538
562
  )
539
563
  )
540
- )
564
+ ).test(arrayValidator(attribute, options))
541
565
  };
542
566
  case "relation":
543
567
  return {
@@ -549,7 +573,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
549
573
  } else if (Array.isArray(value)) {
550
574
  return yup__namespace.array().of(
551
575
  yup__namespace.object().shape({
552
- id: yup__namespace.string().required()
576
+ id: yup__namespace.number().required()
553
577
  })
554
578
  );
555
579
  } else if (typeof value === "object") {
@@ -601,6 +625,14 @@ const createAttributeSchema = (attribute) => {
601
625
  if (!value || typeof value === "string" && value.length === 0) {
602
626
  return true;
603
627
  }
628
+ if (typeof value === "object") {
629
+ try {
630
+ JSON.stringify(value);
631
+ return true;
632
+ } catch (err) {
633
+ return false;
634
+ }
635
+ }
604
636
  try {
605
637
  JSON.parse(value);
606
638
  return true;
@@ -619,13 +651,7 @@ const createAttributeSchema = (attribute) => {
619
651
  return yup__namespace.mixed();
620
652
  }
621
653
  };
622
- const addRequiredValidation = (attribute) => (schema) => {
623
- if (attribute.required) {
624
- return schema.required({
625
- id: strapiAdmin.translatedErrors.required.id,
626
- defaultMessage: "This field is required."
627
- });
628
- }
654
+ const nullableSchema = (schema) => {
629
655
  return schema?.nullable ? schema.nullable() : (
630
656
  // In some cases '.nullable' will not be available on the schema.
631
657
  // e.g. when the schema has been built using yup.lazy (e.g. for relations).
@@ -633,7 +659,22 @@ const addRequiredValidation = (attribute) => (schema) => {
633
659
  schema
634
660
  );
635
661
  };
636
- const addMinLengthValidation = (attribute) => (schema) => {
662
+ const addNullableValidation = () => (schema) => {
663
+ return nullableSchema(schema);
664
+ };
665
+ const addRequiredValidation = (attribute, options) => (schema) => {
666
+ if (options.status === "draft" || !attribute.required) {
667
+ return schema;
668
+ }
669
+ if (attribute.required && "required" in schema) {
670
+ return schema.required(strapiAdmin.translatedErrors.required);
671
+ }
672
+ return schema;
673
+ };
674
+ const addMinLengthValidation = (attribute, options) => (schema) => {
675
+ if (options.status === "draft") {
676
+ return schema;
677
+ }
637
678
  if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
638
679
  return schema.min(attribute.minLength, {
639
680
  ...strapiAdmin.translatedErrors.minLength,
@@ -655,10 +696,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
655
696
  }
656
697
  return schema;
657
698
  };
658
- const addMinValidation = (attribute) => (schema) => {
659
- if ("min" in attribute) {
699
+ const addMinValidation = (attribute, options) => (schema) => {
700
+ if (options.status === "draft") {
701
+ return schema;
702
+ }
703
+ if ("min" in attribute && "min" in schema) {
660
704
  const min = toInteger(attribute.min);
661
- if ("min" in schema && min) {
705
+ if (min) {
662
706
  return schema.min(min, {
663
707
  ...strapiAdmin.translatedErrors.min,
664
708
  values: {
@@ -776,16 +820,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
776
820
  }, {});
777
821
  return componentsByKey;
778
822
  };
779
- const useDocument = (args, opts) => {
823
+ const HOOKS = {
824
+ /**
825
+ * Hook that allows to mutate the displayed headers of the list view table
826
+ * @constant
827
+ * @type {string}
828
+ */
829
+ INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
830
+ /**
831
+ * Hook that allows to mutate the CM's collection types links pre-set filters
832
+ * @constant
833
+ * @type {string}
834
+ */
835
+ MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
836
+ /**
837
+ * Hook that allows to mutate the CM's edit view layout
838
+ * @constant
839
+ * @type {string}
840
+ */
841
+ MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
842
+ /**
843
+ * Hook that allows to mutate the CM's single types links pre-set filters
844
+ * @constant
845
+ * @type {string}
846
+ */
847
+ MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
848
+ };
849
+ const contentTypesApi = contentManagerApi.injectEndpoints({
850
+ endpoints: (builder) => ({
851
+ getContentTypeConfiguration: builder.query({
852
+ query: (uid) => ({
853
+ url: `/content-manager/content-types/${uid}/configuration`,
854
+ method: "GET"
855
+ }),
856
+ transformResponse: (response) => response.data,
857
+ providesTags: (_result, _error, uid) => [
858
+ { type: "ContentTypesConfiguration", id: uid },
859
+ { type: "ContentTypeSettings", id: "LIST" }
860
+ ]
861
+ }),
862
+ getAllContentTypeSettings: builder.query({
863
+ query: () => "/content-manager/content-types-settings",
864
+ transformResponse: (response) => response.data,
865
+ providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
866
+ }),
867
+ updateContentTypeConfiguration: builder.mutation({
868
+ query: ({ uid, ...body }) => ({
869
+ url: `/content-manager/content-types/${uid}/configuration`,
870
+ method: "PUT",
871
+ data: body
872
+ }),
873
+ transformResponse: (response) => response.data,
874
+ invalidatesTags: (_result, _error, { uid }) => [
875
+ { type: "ContentTypesConfiguration", id: uid },
876
+ { type: "ContentTypeSettings", id: "LIST" },
877
+ // Is this necessary?
878
+ { type: "InitialData" }
879
+ ]
880
+ })
881
+ })
882
+ });
883
+ const {
884
+ useGetContentTypeConfigurationQuery,
885
+ useGetAllContentTypeSettingsQuery,
886
+ useUpdateContentTypeConfigurationMutation
887
+ } = contentTypesApi;
888
+ const checkIfAttributeIsDisplayable = (attribute) => {
889
+ const { type } = attribute;
890
+ if (type === "relation") {
891
+ return !attribute.relation.toLowerCase().includes("morph");
892
+ }
893
+ return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
894
+ };
895
+ const getMainField = (attribute, mainFieldName, { schemas, components }) => {
896
+ if (!mainFieldName) {
897
+ return void 0;
898
+ }
899
+ const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
900
+ // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
901
+ schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
902
+ );
903
+ return {
904
+ name: mainFieldName,
905
+ type: mainFieldType ?? "string"
906
+ };
907
+ };
908
+ const DEFAULT_SETTINGS = {
909
+ bulkable: false,
910
+ filterable: false,
911
+ searchable: false,
912
+ pagination: false,
913
+ defaultSortBy: "",
914
+ defaultSortOrder: "asc",
915
+ mainField: "id",
916
+ pageSize: 10
917
+ };
918
+ const useDocumentLayout = (model) => {
919
+ const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
920
+ const [{ query }] = strapiAdmin.useQueryParams();
921
+ const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
780
922
  const { toggleNotification } = strapiAdmin.useNotification();
781
923
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
924
+ const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
782
925
  const {
783
- currentData: data,
784
- isLoading: isLoadingDocument,
785
- isFetching: isFetchingDocument,
786
- error
787
- } = useGetDocumentQuery(args, opts);
788
- const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
926
+ data,
927
+ isLoading: isLoadingConfigs,
928
+ error,
929
+ isFetching: isFetchingConfigs
930
+ } = useGetContentTypeConfigurationQuery(model);
931
+ const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
789
932
  React__namespace.useEffect(() => {
790
933
  if (error) {
791
934
  toggleNotification({
@@ -793,62 +936,318 @@ const useDocument = (args, opts) => {
793
936
  message: formatAPIError(error)
794
937
  });
795
938
  }
796
- }, [toggleNotification, error, formatAPIError, args.collectionType]);
797
- const validationSchema = React__namespace.useMemo(() => {
798
- if (!schema) {
799
- return null;
800
- }
801
- return createYupSchema(schema.attributes, components);
802
- }, [schema, components]);
803
- const validate = React__namespace.useCallback(
804
- (document) => {
805
- if (!validationSchema) {
806
- throw new Error(
807
- "There is no validation schema generated, this is likely due to the schema not being loaded yet."
808
- );
809
- }
810
- try {
811
- validationSchema.validateSync(document, { abortEarly: false, strict: true });
812
- return null;
813
- } catch (error2) {
814
- if (error2 instanceof yup.ValidationError) {
815
- return strapiAdmin.getYupValidationErrors(error2);
816
- }
817
- throw error2;
818
- }
939
+ }, [error, formatAPIError, toggleNotification]);
940
+ const editLayout = React__namespace.useMemo(
941
+ () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
942
+ layout: [],
943
+ components: {},
944
+ metadatas: {},
945
+ options: {},
946
+ settings: DEFAULT_SETTINGS
819
947
  },
820
- [validationSchema]
948
+ [data, isLoading, schemas, schema, components]
949
+ );
950
+ const listLayout = React__namespace.useMemo(() => {
951
+ return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
952
+ layout: [],
953
+ metadatas: {},
954
+ options: {},
955
+ settings: DEFAULT_SETTINGS
956
+ };
957
+ }, [data, isLoading, schemas, schema, components]);
958
+ const { layout: edit } = React__namespace.useMemo(
959
+ () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
960
+ layout: editLayout,
961
+ query
962
+ }),
963
+ [editLayout, query, runHookWaterfall]
821
964
  );
822
- const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
823
965
  return {
824
- components,
825
- document: data?.data,
826
- meta: data?.meta,
966
+ error,
827
967
  isLoading,
828
- schema,
829
- validate
968
+ edit,
969
+ list: listLayout
830
970
  };
831
971
  };
832
- const useDoc = () => {
833
- const { id, slug, collectionType, origin } = reactRouterDom.useParams();
834
- const [{ query }] = strapiAdmin.useQueryParams();
835
- const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
836
- if (!collectionType) {
837
- throw new Error("Could not find collectionType in url params");
838
- }
839
- if (!slug) {
972
+ const useDocLayout = () => {
973
+ const { model } = useDoc();
974
+ return useDocumentLayout(model);
975
+ };
976
+ const formatEditLayout = (data, {
977
+ schemas,
978
+ schema,
979
+ components
980
+ }) => {
981
+ let currentPanelIndex = 0;
982
+ const panelledEditAttributes = convertEditLayoutToFieldLayouts(
983
+ data.contentType.layouts.edit,
984
+ schema?.attributes,
985
+ data.contentType.metadatas,
986
+ { configurations: data.components, schemas: components },
987
+ schemas
988
+ ).reduce((panels, row) => {
989
+ if (row.some((field) => field.type === "dynamiczone")) {
990
+ panels.push([row]);
991
+ currentPanelIndex += 2;
992
+ } else {
993
+ if (!panels[currentPanelIndex]) {
994
+ panels.push([]);
995
+ }
996
+ panels[currentPanelIndex].push(row);
997
+ }
998
+ return panels;
999
+ }, []);
1000
+ const componentEditAttributes = Object.entries(data.components).reduce(
1001
+ (acc, [uid, configuration]) => {
1002
+ acc[uid] = {
1003
+ layout: convertEditLayoutToFieldLayouts(
1004
+ configuration.layouts.edit,
1005
+ components[uid].attributes,
1006
+ configuration.metadatas,
1007
+ { configurations: data.components, schemas: components }
1008
+ ),
1009
+ settings: {
1010
+ ...configuration.settings,
1011
+ icon: components[uid].info.icon,
1012
+ displayName: components[uid].info.displayName
1013
+ }
1014
+ };
1015
+ return acc;
1016
+ },
1017
+ {}
1018
+ );
1019
+ const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
1020
+ (acc, [attribute, metadata]) => {
1021
+ return {
1022
+ ...acc,
1023
+ [attribute]: metadata.edit
1024
+ };
1025
+ },
1026
+ {}
1027
+ );
1028
+ return {
1029
+ layout: panelledEditAttributes,
1030
+ components: componentEditAttributes,
1031
+ metadatas: editMetadatas,
1032
+ settings: {
1033
+ ...data.contentType.settings,
1034
+ displayName: schema?.info.displayName
1035
+ },
1036
+ options: {
1037
+ ...schema?.options,
1038
+ ...schema?.pluginOptions,
1039
+ ...data.contentType.options
1040
+ }
1041
+ };
1042
+ };
1043
+ const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
1044
+ return rows.map(
1045
+ (row) => row.map((field) => {
1046
+ const attribute = attributes[field.name];
1047
+ if (!attribute) {
1048
+ return null;
1049
+ }
1050
+ const { edit: metadata } = metadatas[field.name];
1051
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
1052
+ return {
1053
+ attribute,
1054
+ disabled: !metadata.editable,
1055
+ hint: metadata.description,
1056
+ label: metadata.label ?? "",
1057
+ name: field.name,
1058
+ // @ts-expect-error – mainField does exist on the metadata for a relation.
1059
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
1060
+ schemas,
1061
+ components: components?.schemas ?? {}
1062
+ }),
1063
+ placeholder: metadata.placeholder ?? "",
1064
+ required: attribute.required ?? false,
1065
+ size: field.size,
1066
+ unique: "unique" in attribute ? attribute.unique : false,
1067
+ visible: metadata.visible ?? true,
1068
+ type: attribute.type
1069
+ };
1070
+ }).filter((field) => field !== null)
1071
+ );
1072
+ };
1073
+ const formatListLayout = (data, {
1074
+ schemas,
1075
+ schema,
1076
+ components
1077
+ }) => {
1078
+ const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
1079
+ (acc, [attribute, metadata]) => {
1080
+ return {
1081
+ ...acc,
1082
+ [attribute]: metadata.list
1083
+ };
1084
+ },
1085
+ {}
1086
+ );
1087
+ const listAttributes = convertListLayoutToFieldLayouts(
1088
+ data.contentType.layouts.list,
1089
+ schema?.attributes,
1090
+ listMetadatas,
1091
+ { configurations: data.components, schemas: components },
1092
+ schemas
1093
+ );
1094
+ return {
1095
+ layout: listAttributes,
1096
+ settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
1097
+ metadatas: listMetadatas,
1098
+ options: {
1099
+ ...schema?.options,
1100
+ ...schema?.pluginOptions,
1101
+ ...data.contentType.options
1102
+ }
1103
+ };
1104
+ };
1105
+ const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
1106
+ return columns.map((name) => {
1107
+ const attribute = attributes[name];
1108
+ if (!attribute) {
1109
+ return null;
1110
+ }
1111
+ const metadata = metadatas[name];
1112
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
1113
+ return {
1114
+ attribute,
1115
+ label: metadata.label ?? "",
1116
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
1117
+ schemas,
1118
+ components: components?.schemas ?? {}
1119
+ }),
1120
+ name,
1121
+ searchable: metadata.searchable ?? true,
1122
+ sortable: metadata.sortable ?? true
1123
+ };
1124
+ }).filter((field) => field !== null);
1125
+ };
1126
+ const useDocument = (args, opts) => {
1127
+ const { toggleNotification } = strapiAdmin.useNotification();
1128
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
1129
+ const {
1130
+ currentData: data,
1131
+ isLoading: isLoadingDocument,
1132
+ isFetching: isFetchingDocument,
1133
+ error
1134
+ } = useGetDocumentQuery(args, {
1135
+ ...opts,
1136
+ skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
1137
+ });
1138
+ const {
1139
+ components,
1140
+ schema,
1141
+ schemas,
1142
+ isLoading: isLoadingSchema
1143
+ } = useContentTypeSchema(args.model);
1144
+ React__namespace.useEffect(() => {
1145
+ if (error) {
1146
+ toggleNotification({
1147
+ type: "danger",
1148
+ message: formatAPIError(error)
1149
+ });
1150
+ }
1151
+ }, [toggleNotification, error, formatAPIError, args.collectionType]);
1152
+ const validationSchema = React__namespace.useMemo(() => {
1153
+ if (!schema) {
1154
+ return null;
1155
+ }
1156
+ return createYupSchema(schema.attributes, components);
1157
+ }, [schema, components]);
1158
+ const validate = React__namespace.useCallback(
1159
+ (document) => {
1160
+ if (!validationSchema) {
1161
+ throw new Error(
1162
+ "There is no validation schema generated, this is likely due to the schema not being loaded yet."
1163
+ );
1164
+ }
1165
+ try {
1166
+ validationSchema.validateSync(document, { abortEarly: false, strict: true });
1167
+ return null;
1168
+ } catch (error2) {
1169
+ if (error2 instanceof yup.ValidationError) {
1170
+ return strapiAdmin.getYupValidationErrors(error2);
1171
+ }
1172
+ throw error2;
1173
+ }
1174
+ },
1175
+ [validationSchema]
1176
+ );
1177
+ const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
1178
+ const hasError = !!error;
1179
+ return {
1180
+ components,
1181
+ document: data?.data,
1182
+ meta: data?.meta,
1183
+ isLoading,
1184
+ hasError,
1185
+ schema,
1186
+ schemas,
1187
+ validate
1188
+ };
1189
+ };
1190
+ const useDoc = () => {
1191
+ const { id, slug, collectionType, origin } = reactRouterDom.useParams();
1192
+ const [{ query }] = strapiAdmin.useQueryParams();
1193
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
1194
+ if (!collectionType) {
1195
+ throw new Error("Could not find collectionType in url params");
1196
+ }
1197
+ if (!slug) {
840
1198
  throw new Error("Could not find model in url params");
841
1199
  }
1200
+ const document = useDocument(
1201
+ { documentId: origin || id, model: slug, collectionType, params },
1202
+ {
1203
+ skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
1204
+ }
1205
+ );
1206
+ const returnId = origin || id === "create" ? void 0 : id;
842
1207
  return {
843
1208
  collectionType,
844
1209
  model: slug,
845
- id: origin || id === "create" ? void 0 : id,
846
- ...useDocument(
847
- { documentId: origin || id, model: slug, collectionType, params },
848
- {
849
- skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
850
- }
851
- )
1210
+ id: returnId,
1211
+ ...document
1212
+ };
1213
+ };
1214
+ const useContentManagerContext = () => {
1215
+ const {
1216
+ collectionType,
1217
+ model,
1218
+ id,
1219
+ components,
1220
+ isLoading: isLoadingDoc,
1221
+ schema,
1222
+ schemas
1223
+ } = useDoc();
1224
+ const layout = useDocumentLayout(model);
1225
+ const form = strapiAdmin.useForm("useContentManagerContext", (state) => state);
1226
+ const isSingleType = collectionType === SINGLE_TYPES;
1227
+ const slug = model;
1228
+ const isCreatingEntry = id === "create";
1229
+ useContentTypeSchema();
1230
+ const isLoading = isLoadingDoc || layout.isLoading;
1231
+ const error = layout.error;
1232
+ return {
1233
+ error,
1234
+ isLoading,
1235
+ // Base metadata
1236
+ model,
1237
+ collectionType,
1238
+ id,
1239
+ slug,
1240
+ isCreatingEntry,
1241
+ isSingleType,
1242
+ hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
1243
+ // All schema infos
1244
+ components,
1245
+ contentType: schema,
1246
+ contentTypes: schemas,
1247
+ // Form state
1248
+ form,
1249
+ // layout infos
1250
+ layout
852
1251
  };
853
1252
  };
854
1253
  const prefixPluginTranslations = (trad, pluginId) => {
@@ -870,6 +1269,8 @@ const useDocumentActions = () => {
870
1269
  const { formatMessage } = reactIntl.useIntl();
871
1270
  const { trackUsage } = strapiAdmin.useTracking();
872
1271
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
1272
+ const navigate = reactRouterDom.useNavigate();
1273
+ const setCurrentStep = strapiAdmin.useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
873
1274
  const [deleteDocument] = useDeleteDocumentMutation();
874
1275
  const _delete = React__namespace.useCallback(
875
1276
  async ({ collectionType, model, documentId, params }, trackerProperty) => {
@@ -1184,6 +1585,7 @@ const useDocumentActions = () => {
1184
1585
  defaultMessage: "Saved document"
1185
1586
  })
1186
1587
  });
1588
+ setCurrentStep("contentManager.success");
1187
1589
  return res.data;
1188
1590
  } catch (err) {
1189
1591
  toggleNotification({
@@ -1205,7 +1607,6 @@ const useDocumentActions = () => {
1205
1607
  sourceId
1206
1608
  });
1207
1609
  if ("error" in res) {
1208
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1209
1610
  return { error: res.error };
1210
1611
  }
1211
1612
  toggleNotification({
@@ -1224,7 +1625,7 @@ const useDocumentActions = () => {
1224
1625
  throw err;
1225
1626
  }
1226
1627
  },
1227
- [autoCloneDocument, formatAPIError, formatMessage, toggleNotification]
1628
+ [autoCloneDocument, formatMessage, toggleNotification]
1228
1629
  );
1229
1630
  const [cloneDocument] = useCloneDocumentMutation();
1230
1631
  const clone = React__namespace.useCallback(
@@ -1250,6 +1651,7 @@ const useDocumentActions = () => {
1250
1651
  defaultMessage: "Cloned document"
1251
1652
  })
1252
1653
  });
1654
+ navigate(`../../${res.data.data.documentId}`, { relative: "path" });
1253
1655
  return res.data;
1254
1656
  } catch (err) {
1255
1657
  toggleNotification({
@@ -1260,7 +1662,7 @@ const useDocumentActions = () => {
1260
1662
  throw err;
1261
1663
  }
1262
1664
  },
1263
- [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
1665
+ [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
1264
1666
  );
1265
1667
  const [getDoc] = useLazyGetDocumentQuery();
1266
1668
  const getDocument = React__namespace.useCallback(
@@ -1286,7 +1688,7 @@ const useDocumentActions = () => {
1286
1688
  };
1287
1689
  };
1288
1690
  const ProtectedHistoryPage = React.lazy(
1289
- () => Promise.resolve().then(() => require("./History-BWWxLt2Z.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1691
+ () => Promise.resolve().then(() => require("./History-CTFvy6XH.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1290
1692
  );
1291
1693
  const routes$1 = [
1292
1694
  {
@@ -1299,31 +1701,31 @@ const routes$1 = [
1299
1701
  }
1300
1702
  ];
1301
1703
  const ProtectedEditViewPage = React.lazy(
1302
- () => Promise.resolve().then(() => require("./EditViewPage-DbcGfyqK.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1704
+ () => Promise.resolve().then(() => require("./EditViewPage-CqHMM0P0.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1303
1705
  );
1304
1706
  const ProtectedListViewPage = React.lazy(
1305
- () => Promise.resolve().then(() => require("./ListViewPage-BlzfjS2Q.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1707
+ () => Promise.resolve().then(() => require("./ListViewPage-D0fpPYKp.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1306
1708
  );
1307
1709
  const ProtectedListConfiguration = React.lazy(
1308
- () => Promise.resolve().then(() => require("./ListConfigurationPage-6swzjdAZ.js")).then((mod) => ({
1710
+ () => Promise.resolve().then(() => require("./ListConfigurationPage-CDzlMBz_.js")).then((mod) => ({
1309
1711
  default: mod.ProtectedListConfiguration
1310
1712
  }))
1311
1713
  );
1312
1714
  const ProtectedEditConfigurationPage = React.lazy(
1313
- () => Promise.resolve().then(() => require("./EditConfigurationPage-C1vjMBgy.js")).then((mod) => ({
1715
+ () => Promise.resolve().then(() => require("./EditConfigurationPage-Ce4bIm4n.js")).then((mod) => ({
1314
1716
  default: mod.ProtectedEditConfigurationPage
1315
1717
  }))
1316
1718
  );
1317
1719
  const ProtectedComponentConfigurationPage = React.lazy(
1318
- () => Promise.resolve().then(() => require("./ComponentConfigurationPage-WRPUXGd6.js")).then((mod) => ({
1720
+ () => Promise.resolve().then(() => require("./ComponentConfigurationPage-CQDCxI8x.js")).then((mod) => ({
1319
1721
  default: mod.ProtectedComponentConfigurationPage
1320
1722
  }))
1321
1723
  );
1322
1724
  const NoPermissions = React.lazy(
1323
- () => Promise.resolve().then(() => require("./NoPermissionsPage-DN_JlsU2.js")).then((mod) => ({ default: mod.NoPermissions }))
1725
+ () => Promise.resolve().then(() => require("./NoPermissionsPage-BoI2rU68.js")).then((mod) => ({ default: mod.NoPermissions }))
1324
1726
  );
1325
1727
  const NoContentType = React.lazy(
1326
- () => Promise.resolve().then(() => require("./NoContentTypePage-D2nCCWEl.js")).then((mod) => ({ default: mod.NoContentType }))
1728
+ () => Promise.resolve().then(() => require("./NoContentTypePage-DTzkSAV5.js")).then((mod) => ({ default: mod.NoContentType }))
1327
1729
  );
1328
1730
  const CollectionTypePages = () => {
1329
1731
  const { collectionType } = reactRouterDom.useParams();
@@ -1437,12 +1839,14 @@ const DocumentActionButton = (action) => {
1437
1839
  /* @__PURE__ */ jsxRuntime.jsx(
1438
1840
  designSystem.Button,
1439
1841
  {
1440
- flex: 1,
1842
+ flex: "auto",
1441
1843
  startIcon: action.icon,
1442
1844
  disabled: action.disabled,
1443
1845
  onClick: handleClick(action),
1444
1846
  justifyContent: "center",
1445
1847
  variant: action.variant || "default",
1848
+ paddingTop: "7px",
1849
+ paddingBottom: "7px",
1446
1850
  children: action.label
1447
1851
  }
1448
1852
  ),
@@ -1450,7 +1854,7 @@ const DocumentActionButton = (action) => {
1450
1854
  DocumentActionConfirmDialog,
1451
1855
  {
1452
1856
  ...action.dialog,
1453
- variant: action.variant,
1857
+ variant: action.dialog?.variant ?? action.variant,
1454
1858
  isOpen: dialogId === action.id,
1455
1859
  onClose: handleClose
1456
1860
  }
@@ -1507,9 +1911,9 @@ const DocumentActionsMenu = ({
1507
1911
  disabled: isDisabled,
1508
1912
  size: "S",
1509
1913
  endIcon: null,
1510
- paddingTop: "7px",
1511
- paddingLeft: "9px",
1512
- paddingRight: "9px",
1914
+ paddingTop: "4px",
1915
+ paddingLeft: "7px",
1916
+ paddingRight: "7px",
1513
1917
  variant,
1514
1918
  children: [
1515
1919
  /* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
@@ -1520,7 +1924,7 @@ const DocumentActionsMenu = ({
1520
1924
  ]
1521
1925
  }
1522
1926
  ),
1523
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { top: "4px", maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1927
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1524
1928
  actions2.map((action) => {
1525
1929
  return /* @__PURE__ */ jsxRuntime.jsx(
1526
1930
  designSystem.Menu.Item,
@@ -1529,10 +1933,25 @@ const DocumentActionsMenu = ({
1529
1933
  onSelect: handleClick(action),
1530
1934
  display: "block",
1531
1935
  children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: [
1532
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { color: convertActionVariantToColor(action.variant), gap: 2, tag: "span", children: [
1533
- action.icon,
1534
- action.label
1535
- ] }),
1936
+ /* @__PURE__ */ jsxRuntime.jsxs(
1937
+ designSystem.Flex,
1938
+ {
1939
+ color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
1940
+ gap: 2,
1941
+ tag: "span",
1942
+ children: [
1943
+ /* @__PURE__ */ jsxRuntime.jsx(
1944
+ designSystem.Flex,
1945
+ {
1946
+ tag: "span",
1947
+ color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
1948
+ children: action.icon
1949
+ }
1950
+ ),
1951
+ action.label
1952
+ ]
1953
+ }
1954
+ ),
1536
1955
  action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsxRuntime.jsx(
1537
1956
  designSystem.Flex,
1538
1957
  {
@@ -1591,6 +2010,18 @@ const convertActionVariantToColor = (variant = "secondary") => {
1591
2010
  return "primary600";
1592
2011
  }
1593
2012
  };
2013
+ const convertActionVariantToIconColor = (variant = "secondary") => {
2014
+ switch (variant) {
2015
+ case "danger":
2016
+ return "danger600";
2017
+ case "secondary":
2018
+ return "neutral500";
2019
+ case "success":
2020
+ return "success600";
2021
+ default:
2022
+ return "primary600";
2023
+ }
2024
+ };
1594
2025
  const DocumentActionConfirmDialog = ({
1595
2026
  onClose,
1596
2027
  onCancel,
@@ -1617,11 +2048,11 @@ const DocumentActionConfirmDialog = ({
1617
2048
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
1618
2049
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
1619
2050
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
1620
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
2051
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
1621
2052
  id: "app.components.Button.cancel",
1622
2053
  defaultMessage: "Cancel"
1623
2054
  }) }) }),
1624
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
2055
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
1625
2056
  id: "app.components.Button.confirm",
1626
2057
  defaultMessage: "Confirm"
1627
2058
  }) })
@@ -1648,6 +2079,18 @@ const DocumentActionModal = ({
1648
2079
  typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
1649
2080
  ] }) });
1650
2081
  };
2082
+ const transformData = (data) => {
2083
+ if (Array.isArray(data)) {
2084
+ return data.map(transformData);
2085
+ }
2086
+ if (typeof data === "object" && data !== null) {
2087
+ if ("apiData" in data) {
2088
+ return data.apiData;
2089
+ }
2090
+ return mapValues__default.default(transformData)(data);
2091
+ }
2092
+ return data;
2093
+ };
1651
2094
  const PublishAction$1 = ({
1652
2095
  activeTab,
1653
2096
  documentId,
@@ -1660,13 +2103,17 @@ const PublishAction$1 = ({
1660
2103
  const navigate = reactRouterDom.useNavigate();
1661
2104
  const { toggleNotification } = strapiAdmin.useNotification();
1662
2105
  const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
2106
+ const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
1663
2107
  const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
1664
2108
  const { formatMessage } = reactIntl.useIntl();
1665
- const { canPublish, canCreate, canUpdate } = useDocumentRBAC(
1666
- "PublishAction",
1667
- ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
1668
- );
2109
+ const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
1669
2110
  const { publish } = useDocumentActions();
2111
+ const [
2112
+ countDraftRelations,
2113
+ { isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }
2114
+ ] = useLazyGetDraftRelationCountQuery();
2115
+ const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React__namespace.useState(0);
2116
+ const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React__namespace.useState(0);
1670
2117
  const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
1671
2118
  const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
1672
2119
  const modified = strapiAdmin.useForm("PublishAction", ({ modified: modified2 }) => modified2);
@@ -1675,10 +2122,105 @@ const PublishAction$1 = ({
1675
2122
  const validate = strapiAdmin.useForm("PublishAction", (state) => state.validate);
1676
2123
  const setErrors = strapiAdmin.useForm("PublishAction", (state) => state.setErrors);
1677
2124
  const formValues = strapiAdmin.useForm("PublishAction", ({ values }) => values);
2125
+ React__namespace.useEffect(() => {
2126
+ if (isErrorDraftRelations) {
2127
+ toggleNotification({
2128
+ type: "danger",
2129
+ message: formatMessage({
2130
+ id: getTranslation("error.records.fetch-draft-relatons"),
2131
+ defaultMessage: "An error occurred while fetching draft relations on this document."
2132
+ })
2133
+ });
2134
+ }
2135
+ }, [isErrorDraftRelations, toggleNotification, formatMessage]);
2136
+ React__namespace.useEffect(() => {
2137
+ const localDraftRelations = /* @__PURE__ */ new Set();
2138
+ const extractDraftRelations = (data) => {
2139
+ const relations = data.connect || [];
2140
+ relations.forEach((relation) => {
2141
+ if (relation.status === "draft") {
2142
+ localDraftRelations.add(relation.id);
2143
+ }
2144
+ });
2145
+ };
2146
+ const traverseAndExtract = (data) => {
2147
+ Object.entries(data).forEach(([key, value]) => {
2148
+ if (key === "connect" && Array.isArray(value)) {
2149
+ extractDraftRelations({ connect: value });
2150
+ } else if (typeof value === "object" && value !== null) {
2151
+ traverseAndExtract(value);
2152
+ }
2153
+ });
2154
+ };
2155
+ if (!documentId || modified) {
2156
+ traverseAndExtract(formValues);
2157
+ setLocalCountOfDraftRelations(localDraftRelations.size);
2158
+ }
2159
+ }, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
2160
+ React__namespace.useEffect(() => {
2161
+ if (!document || !document.documentId || isListView) {
2162
+ return;
2163
+ }
2164
+ const fetchDraftRelationsCount = async () => {
2165
+ const { data, error } = await countDraftRelations({
2166
+ collectionType,
2167
+ model,
2168
+ documentId,
2169
+ params
2170
+ });
2171
+ if (error) {
2172
+ throw error;
2173
+ }
2174
+ if (data) {
2175
+ setServerCountOfDraftRelations(data.data);
2176
+ }
2177
+ };
2178
+ fetchDraftRelationsCount();
2179
+ }, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
1678
2180
  const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
1679
2181
  if (!schema?.options?.draftAndPublish) {
1680
2182
  return null;
1681
2183
  }
2184
+ const performPublish = async () => {
2185
+ setSubmitting(true);
2186
+ try {
2187
+ const { errors } = await validate(true, {
2188
+ status: "published"
2189
+ });
2190
+ if (errors) {
2191
+ toggleNotification({
2192
+ type: "danger",
2193
+ message: formatMessage({
2194
+ id: "content-manager.validation.error",
2195
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
2196
+ })
2197
+ });
2198
+ return;
2199
+ }
2200
+ const res = await publish(
2201
+ {
2202
+ collectionType,
2203
+ model,
2204
+ documentId,
2205
+ params
2206
+ },
2207
+ transformData(formValues)
2208
+ );
2209
+ if ("data" in res && collectionType !== SINGLE_TYPES) {
2210
+ navigate({
2211
+ pathname: `../${collectionType}/${model}/${res.data.documentId}`,
2212
+ search: rawQuery
2213
+ });
2214
+ } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
2215
+ setErrors(formatValidationErrors(res.error));
2216
+ }
2217
+ } finally {
2218
+ setSubmitting(false);
2219
+ }
2220
+ };
2221
+ const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
2222
+ const enableDraftRelationsCount = false;
2223
+ const hasDraftRelations = enableDraftRelationsCount;
1682
2224
  return {
1683
2225
  /**
1684
2226
  * Disabled when:
@@ -1688,49 +2230,36 @@ const PublishAction$1 = ({
1688
2230
  * - the document is already published & not modified
1689
2231
  * - the document is being created & not modified
1690
2232
  * - the user doesn't have the permission to publish
1691
- * - the user doesn't have the permission to create a new document
1692
- * - the user doesn't have the permission to update the document
1693
2233
  */
1694
- disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish || Boolean(!document?.documentId && !canCreate || document?.documentId && !canUpdate),
2234
+ disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
1695
2235
  label: formatMessage({
1696
2236
  id: "app.utils.publish",
1697
2237
  defaultMessage: "Publish"
1698
2238
  }),
1699
2239
  onClick: async () => {
1700
- setSubmitting(true);
1701
- try {
1702
- const { errors } = await validate();
1703
- if (errors) {
1704
- toggleNotification({
1705
- type: "danger",
1706
- message: formatMessage({
1707
- id: "content-manager.validation.error",
1708
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
1709
- })
1710
- });
1711
- return;
1712
- }
1713
- const res = await publish(
1714
- {
1715
- collectionType,
1716
- model,
1717
- documentId,
1718
- params
1719
- },
1720
- formValues
1721
- );
1722
- if ("data" in res && collectionType !== SINGLE_TYPES) {
1723
- navigate({
1724
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1725
- search: rawQuery
1726
- });
1727
- } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1728
- setErrors(formatValidationErrors(res.error));
2240
+ await performPublish();
2241
+ },
2242
+ dialog: hasDraftRelations ? {
2243
+ type: "dialog",
2244
+ variant: "danger",
2245
+ footer: null,
2246
+ title: formatMessage({
2247
+ id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.title`),
2248
+ defaultMessage: "Confirmation"
2249
+ }),
2250
+ content: formatMessage(
2251
+ {
2252
+ id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
2253
+ defaultMessage: "This entry is related to {count, plural, one {# draft entry} other {# draft entries}}. Publishing it could leave broken links in your app."
2254
+ },
2255
+ {
2256
+ count: totalDraftRelations
1729
2257
  }
1730
- } finally {
1731
- setSubmitting(false);
2258
+ ),
2259
+ onConfirm: async () => {
2260
+ await performPublish();
1732
2261
  }
1733
- }
2262
+ } : void 0
1734
2263
  };
1735
2264
  };
1736
2265
  PublishAction$1.type = "publish";
@@ -1746,10 +2275,6 @@ const UpdateAction = ({
1746
2275
  const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
1747
2276
  const isCloning = cloneMatch !== null;
1748
2277
  const { formatMessage } = reactIntl.useIntl();
1749
- const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
1750
- canCreate: canCreate2,
1751
- canUpdate: canUpdate2
1752
- }));
1753
2278
  const { create, update, clone } = useDocumentActions();
1754
2279
  const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
1755
2280
  const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
@@ -1766,10 +2291,8 @@ const UpdateAction = ({
1766
2291
  * - the form is submitting
1767
2292
  * - the document is not modified & we're not cloning (you can save a clone entity straight away)
1768
2293
  * - the active tab is the published tab
1769
- * - the user doesn't have the permission to create a new document
1770
- * - the user doesn't have the permission to update the document
1771
2294
  */
1772
- disabled: isSubmitting || !modified && !isCloning || activeTab === "published" || Boolean(!documentId && !canCreate || documentId && !canUpdate),
2295
+ disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
1773
2296
  label: formatMessage({
1774
2297
  id: "content-manager.containers.Edit.save",
1775
2298
  defaultMessage: "Save"
@@ -1777,7 +2300,9 @@ const UpdateAction = ({
1777
2300
  onClick: async () => {
1778
2301
  setSubmitting(true);
1779
2302
  try {
1780
- const { errors } = await validate();
2303
+ const { errors } = await validate(true, {
2304
+ status: "draft"
2305
+ });
1781
2306
  if (errors) {
1782
2307
  toggleNotification({
1783
2308
  type: "danger",
@@ -1795,13 +2320,16 @@ const UpdateAction = ({
1795
2320
  documentId: cloneMatch.params.origin,
1796
2321
  params
1797
2322
  },
1798
- document
2323
+ transformData(document)
1799
2324
  );
1800
2325
  if ("data" in res) {
1801
- navigate({
1802
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1803
- search: rawQuery
1804
- });
2326
+ navigate(
2327
+ {
2328
+ pathname: `../${res.data.documentId}`,
2329
+ search: rawQuery
2330
+ },
2331
+ { relative: "path" }
2332
+ );
1805
2333
  } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1806
2334
  setErrors(formatValidationErrors(res.error));
1807
2335
  }
@@ -1813,7 +2341,7 @@ const UpdateAction = ({
1813
2341
  documentId,
1814
2342
  params
1815
2343
  },
1816
- document
2344
+ transformData(document)
1817
2345
  );
1818
2346
  if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1819
2347
  setErrors(formatValidationErrors(res.error));
@@ -1826,13 +2354,16 @@ const UpdateAction = ({
1826
2354
  model,
1827
2355
  params
1828
2356
  },
1829
- document
2357
+ transformData(document)
1830
2358
  );
1831
2359
  if ("data" in res && collectionType !== SINGLE_TYPES) {
1832
- navigate({
1833
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1834
- search: rawQuery
1835
- });
2360
+ navigate(
2361
+ {
2362
+ pathname: `../${res.data.documentId}`,
2363
+ search: rawQuery
2364
+ },
2365
+ { replace: true, relative: "path" }
2366
+ );
1836
2367
  } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1837
2368
  setErrors(formatValidationErrors(res.error));
1838
2369
  }
@@ -1876,7 +2407,7 @@ const UnpublishAction$1 = ({
1876
2407
  id: "app.utils.unpublish",
1877
2408
  defaultMessage: "Unpublish"
1878
2409
  }),
1879
- icon: /* @__PURE__ */ jsxRuntime.jsx(StyledCrossCircle, {}),
2410
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
1880
2411
  onClick: async () => {
1881
2412
  if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
1882
2413
  if (!documentId) {
@@ -1988,7 +2519,7 @@ const DiscardAction = ({
1988
2519
  id: "content-manager.actions.discard.label",
1989
2520
  defaultMessage: "Discard changes"
1990
2521
  }),
1991
- icon: /* @__PURE__ */ jsxRuntime.jsx(StyledCrossCircle, {}),
2522
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
1992
2523
  position: ["panel", "table-row"],
1993
2524
  variant: "danger",
1994
2525
  dialog: {
@@ -2016,11 +2547,6 @@ const DiscardAction = ({
2016
2547
  };
2017
2548
  };
2018
2549
  DiscardAction.type = "discard";
2019
- const StyledCrossCircle = styledComponents.styled(Icons.CrossCircle)`
2020
- path {
2021
- fill: currentColor;
2022
- }
2023
- `;
2024
2550
  const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
2025
2551
  const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
2026
2552
  const RelativeTime = React__namespace.forwardRef(
@@ -2068,7 +2594,7 @@ const getDisplayName = ({
2068
2594
  };
2069
2595
  const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2070
2596
  const DocumentStatus = ({ status = "draft", ...restProps }) => {
2071
- const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
2597
+ const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
2072
2598
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, showBullet: false, size: "S", variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: capitalise(status) }) });
2073
2599
  };
2074
2600
  const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
@@ -2078,23 +2604,13 @@ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
2078
2604
  id: "content-manager.containers.edit.title.new",
2079
2605
  defaultMessage: "Create an entry"
2080
2606
  }) : documentTitle;
2081
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 8, paddingBottom: 4, gap: 3, children: [
2607
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
2082
2608
  /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.BackButton, {}),
2083
- /* @__PURE__ */ jsxRuntime.jsxs(
2084
- designSystem.Flex,
2085
- {
2086
- width: "100%",
2087
- justifyContent: "space-between",
2088
- paddingTop: 1,
2089
- gap: "80px",
2090
- alignItems: "flex-start",
2091
- children: [
2092
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
2093
- /* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
2094
- ]
2095
- }
2096
- ),
2097
- status ? /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) : null
2609
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
2610
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
2611
+ /* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
2612
+ ] }),
2613
+ status ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
2098
2614
  ] });
2099
2615
  };
2100
2616
  const HeaderToolbar = () => {
@@ -2177,12 +2693,12 @@ const Information = ({ activeTab }) => {
2177
2693
  isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2178
2694
  label: formatMessage({
2179
2695
  id: "content-manager.containers.edit.information.last-published.label",
2180
- defaultMessage: "Last published"
2696
+ defaultMessage: "Published"
2181
2697
  }),
2182
2698
  value: formatMessage(
2183
2699
  {
2184
2700
  id: "content-manager.containers.edit.information.last-published.value",
2185
- defaultMessage: `Published {time}{isAnonymous, select, true {} other { by {author}}}`
2701
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2186
2702
  },
2187
2703
  {
2188
2704
  time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
@@ -2195,12 +2711,12 @@ const Information = ({ activeTab }) => {
2195
2711
  isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2196
2712
  label: formatMessage({
2197
2713
  id: "content-manager.containers.edit.information.last-draft.label",
2198
- defaultMessage: "Last draft"
2714
+ defaultMessage: "Updated"
2199
2715
  }),
2200
2716
  value: formatMessage(
2201
2717
  {
2202
2718
  id: "content-manager.containers.edit.information.last-draft.value",
2203
- defaultMessage: `Modified {time}{isAnonymous, select, true {} other { by {author}}}`
2719
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2204
2720
  },
2205
2721
  {
2206
2722
  time: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2218,12 +2734,12 @@ const Information = ({ activeTab }) => {
2218
2734
  isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2219
2735
  label: formatMessage({
2220
2736
  id: "content-manager.containers.edit.information.document.label",
2221
- defaultMessage: "Document"
2737
+ defaultMessage: "Created"
2222
2738
  }),
2223
2739
  value: formatMessage(
2224
2740
  {
2225
2741
  id: "content-manager.containers.edit.information.document.value",
2226
- defaultMessage: `Created {time}{isAnonymous, select, true {} other { by {author}}}`
2742
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2227
2743
  },
2228
2744
  {
2229
2745
  time: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2261,25 +2777,77 @@ const Information = ({ activeTab }) => {
2261
2777
  );
2262
2778
  };
2263
2779
  const HeaderActions = ({ actions: actions2 }) => {
2264
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: actions2.map((action) => {
2265
- if ("options" in action) {
2780
+ const [dialogId, setDialogId] = React__namespace.useState(null);
2781
+ const handleClick = (action) => async (e) => {
2782
+ if (!("options" in action)) {
2783
+ const { onClick = () => false, dialog, id } = action;
2784
+ const muteDialog = await onClick(e);
2785
+ if (dialog && !muteDialog) {
2786
+ e.preventDefault();
2787
+ setDialogId(id);
2788
+ }
2789
+ }
2790
+ };
2791
+ const handleClose = () => {
2792
+ setDialogId(null);
2793
+ };
2794
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, children: actions2.map((action) => {
2795
+ if (action.options) {
2266
2796
  return /* @__PURE__ */ jsxRuntime.jsx(
2267
2797
  designSystem.SingleSelect,
2268
2798
  {
2269
2799
  size: "S",
2270
- disabled: action.disabled,
2271
- "aria-label": action.label,
2272
2800
  onChange: action.onSelect,
2273
- value: action.value,
2801
+ "aria-label": action.label,
2802
+ ...action,
2274
2803
  children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
2275
2804
  },
2276
2805
  action.id
2277
2806
  );
2278
2807
  } else {
2279
- return null;
2808
+ if (action.type === "icon") {
2809
+ return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
2810
+ /* @__PURE__ */ jsxRuntime.jsx(
2811
+ designSystem.IconButton,
2812
+ {
2813
+ disabled: action.disabled,
2814
+ label: action.label,
2815
+ size: "S",
2816
+ onClick: handleClick(action),
2817
+ children: action.icon
2818
+ }
2819
+ ),
2820
+ action.dialog ? /* @__PURE__ */ jsxRuntime.jsx(
2821
+ HeaderActionDialog,
2822
+ {
2823
+ ...action.dialog,
2824
+ isOpen: dialogId === action.id,
2825
+ onClose: handleClose
2826
+ }
2827
+ ) : null
2828
+ ] }, action.id);
2829
+ }
2280
2830
  }
2281
2831
  }) });
2282
2832
  };
2833
+ const HeaderActionDialog = ({
2834
+ onClose,
2835
+ onCancel,
2836
+ title,
2837
+ content: Content,
2838
+ isOpen
2839
+ }) => {
2840
+ const handleClose = async () => {
2841
+ if (onCancel) {
2842
+ await onCancel();
2843
+ }
2844
+ onClose();
2845
+ };
2846
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
2847
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
2848
+ typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content
2849
+ ] }) });
2850
+ };
2283
2851
  const ConfigureTheViewAction = ({ collectionType, model }) => {
2284
2852
  const navigate = reactRouterDom.useNavigate();
2285
2853
  const { formatMessage } = reactIntl.useIntl();
@@ -2320,12 +2888,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2320
2888
  const { delete: deleteAction } = useDocumentActions();
2321
2889
  const { toggleNotification } = strapiAdmin.useNotification();
2322
2890
  const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
2891
+ const isLocalized = document?.locale != null;
2323
2892
  return {
2324
2893
  disabled: !canDelete || !document,
2325
- label: formatMessage({
2326
- id: "content-manager.actions.delete.label",
2327
- defaultMessage: "Delete document"
2328
- }),
2894
+ label: formatMessage(
2895
+ {
2896
+ id: "content-manager.actions.delete.label",
2897
+ defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
2898
+ },
2899
+ { isLocalized }
2900
+ ),
2329
2901
  icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
2330
2902
  dialog: {
2331
2903
  type: "dialog",
@@ -2361,423 +2933,121 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2361
2933
  const res = await deleteAction({
2362
2934
  documentId,
2363
2935
  model,
2364
- collectionType,
2365
- params: {
2366
- locale: "*"
2367
- }
2368
- });
2369
- if (!("error" in res)) {
2370
- navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
2371
- }
2372
- } finally {
2373
- if (!listViewPathMatch) {
2374
- setSubmitting(false);
2375
- }
2376
- }
2377
- }
2378
- },
2379
- variant: "danger",
2380
- position: ["header", "table-row"]
2381
- };
2382
- };
2383
- DeleteAction$1.type = "delete";
2384
- const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2385
- const Panels = () => {
2386
- const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2387
- const [
2388
- {
2389
- query: { status }
2390
- }
2391
- ] = strapiAdmin.useQueryParams({
2392
- status: "draft"
2393
- });
2394
- const { model, id, document, meta, collectionType } = useDoc();
2395
- const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
2396
- const props = {
2397
- activeTab: status,
2398
- model,
2399
- documentId: id,
2400
- document: isCloning ? void 0 : document,
2401
- meta: isCloning ? void 0 : meta,
2402
- collectionType
2403
- };
2404
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
2405
- strapiAdmin.DescriptionComponentRenderer,
2406
- {
2407
- props,
2408
- descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2409
- children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
2410
- }
2411
- ) });
2412
- };
2413
- const ActionsPanel = () => {
2414
- const { formatMessage } = reactIntl.useIntl();
2415
- return {
2416
- title: formatMessage({
2417
- id: "content-manager.containers.edit.panels.default.title",
2418
- defaultMessage: "Document"
2419
- }),
2420
- content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
2421
- };
2422
- };
2423
- ActionsPanel.type = "actions";
2424
- const ActionsPanelContent = () => {
2425
- const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2426
- const [
2427
- {
2428
- query: { status = "draft" }
2429
- }
2430
- ] = strapiAdmin.useQueryParams();
2431
- const { model, id, document, meta, collectionType } = useDoc();
2432
- const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
2433
- const props = {
2434
- activeTab: status,
2435
- model,
2436
- documentId: id,
2437
- document: isCloning ? void 0 : document,
2438
- meta: isCloning ? void 0 : meta,
2439
- collectionType
2440
- };
2441
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
2442
- /* @__PURE__ */ jsxRuntime.jsx(
2443
- strapiAdmin.DescriptionComponentRenderer,
2444
- {
2445
- props,
2446
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
2447
- children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
2448
- }
2449
- ),
2450
- /* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
2451
- ] });
2452
- };
2453
- const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
2454
- return /* @__PURE__ */ jsxRuntime.jsxs(
2455
- designSystem.Flex,
2456
- {
2457
- ref,
2458
- tag: "aside",
2459
- "aria-labelledby": "additional-information",
2460
- background: "neutral0",
2461
- borderColor: "neutral150",
2462
- hasRadius: true,
2463
- paddingBottom: 4,
2464
- paddingLeft: 4,
2465
- paddingRight: 4,
2466
- paddingTop: 4,
2467
- shadow: "tableShadow",
2468
- gap: 3,
2469
- direction: "column",
2470
- justifyContent: "stretch",
2471
- alignItems: "flex-start",
2472
- children: [
2473
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
2474
- children
2475
- ]
2476
- }
2477
- );
2478
- });
2479
- const HOOKS = {
2480
- /**
2481
- * Hook that allows to mutate the displayed headers of the list view table
2482
- * @constant
2483
- * @type {string}
2484
- */
2485
- INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
2486
- /**
2487
- * Hook that allows to mutate the CM's collection types links pre-set filters
2488
- * @constant
2489
- * @type {string}
2490
- */
2491
- MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
2492
- /**
2493
- * Hook that allows to mutate the CM's edit view layout
2494
- * @constant
2495
- * @type {string}
2496
- */
2497
- MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
2498
- /**
2499
- * Hook that allows to mutate the CM's single types links pre-set filters
2500
- * @constant
2501
- * @type {string}
2502
- */
2503
- MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
2504
- };
2505
- const contentTypesApi = contentManagerApi.injectEndpoints({
2506
- endpoints: (builder) => ({
2507
- getContentTypeConfiguration: builder.query({
2508
- query: (uid) => ({
2509
- url: `/content-manager/content-types/${uid}/configuration`,
2510
- method: "GET"
2511
- }),
2512
- transformResponse: (response) => response.data,
2513
- providesTags: (_result, _error, uid) => [
2514
- { type: "ContentTypesConfiguration", id: uid },
2515
- { type: "ContentTypeSettings", id: "LIST" }
2516
- ]
2517
- }),
2518
- getAllContentTypeSettings: builder.query({
2519
- query: () => "/content-manager/content-types-settings",
2520
- transformResponse: (response) => response.data,
2521
- providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
2522
- }),
2523
- updateContentTypeConfiguration: builder.mutation({
2524
- query: ({ uid, ...body }) => ({
2525
- url: `/content-manager/content-types/${uid}/configuration`,
2526
- method: "PUT",
2527
- data: body
2528
- }),
2529
- transformResponse: (response) => response.data,
2530
- invalidatesTags: (_result, _error, { uid }) => [
2531
- { type: "ContentTypesConfiguration", id: uid },
2532
- { type: "ContentTypeSettings", id: "LIST" },
2533
- // Is this necessary?
2534
- { type: "InitialData" }
2535
- ]
2536
- })
2537
- })
2538
- });
2539
- const {
2540
- useGetContentTypeConfigurationQuery,
2541
- useGetAllContentTypeSettingsQuery,
2542
- useUpdateContentTypeConfigurationMutation
2543
- } = contentTypesApi;
2544
- const checkIfAttributeIsDisplayable = (attribute) => {
2545
- const { type } = attribute;
2546
- if (type === "relation") {
2547
- return !attribute.relation.toLowerCase().includes("morph");
2548
- }
2549
- return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
2550
- };
2551
- const getMainField = (attribute, mainFieldName, { schemas, components }) => {
2552
- if (!mainFieldName) {
2553
- return void 0;
2554
- }
2555
- const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
2556
- // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
2557
- schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
2558
- );
2559
- return {
2560
- name: mainFieldName,
2561
- type: mainFieldType ?? "string"
2562
- };
2563
- };
2564
- const DEFAULT_SETTINGS = {
2565
- bulkable: false,
2566
- filterable: false,
2567
- searchable: false,
2568
- pagination: false,
2569
- defaultSortBy: "",
2570
- defaultSortOrder: "asc",
2571
- mainField: "id",
2572
- pageSize: 10
2573
- };
2574
- const useDocumentLayout = (model) => {
2575
- const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
2576
- const [{ query }] = strapiAdmin.useQueryParams();
2577
- const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
2578
- const { toggleNotification } = strapiAdmin.useNotification();
2579
- const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
2580
- const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
2581
- const {
2582
- data,
2583
- isLoading: isLoadingConfigs,
2584
- error,
2585
- isFetching: isFetchingConfigs
2586
- } = useGetContentTypeConfigurationQuery(model);
2587
- const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
2588
- React__namespace.useEffect(() => {
2589
- if (error) {
2590
- toggleNotification({
2591
- type: "danger",
2592
- message: formatAPIError(error)
2593
- });
2594
- }
2595
- }, [error, formatAPIError, toggleNotification]);
2596
- const editLayout = React__namespace.useMemo(
2597
- () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
2598
- layout: [],
2599
- components: {},
2600
- metadatas: {},
2601
- options: {},
2602
- settings: DEFAULT_SETTINGS
2603
- },
2604
- [data, isLoading, schemas, schema, components]
2605
- );
2606
- const listLayout = React__namespace.useMemo(() => {
2607
- return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
2608
- layout: [],
2609
- metadatas: {},
2610
- options: {},
2611
- settings: DEFAULT_SETTINGS
2612
- };
2613
- }, [data, isLoading, schemas, schema, components]);
2614
- const { layout: edit } = React__namespace.useMemo(
2615
- () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
2616
- layout: editLayout,
2617
- query
2618
- }),
2619
- [editLayout, query, runHookWaterfall]
2620
- );
2621
- return {
2622
- error,
2623
- isLoading,
2624
- edit,
2625
- list: listLayout
2626
- };
2627
- };
2628
- const useDocLayout = () => {
2629
- const { model } = useDoc();
2630
- return useDocumentLayout(model);
2631
- };
2632
- const formatEditLayout = (data, {
2633
- schemas,
2634
- schema,
2635
- components
2636
- }) => {
2637
- let currentPanelIndex = 0;
2638
- const panelledEditAttributes = convertEditLayoutToFieldLayouts(
2639
- data.contentType.layouts.edit,
2640
- schema?.attributes,
2641
- data.contentType.metadatas,
2642
- { configurations: data.components, schemas: components },
2643
- schemas
2644
- ).reduce((panels, row) => {
2645
- if (row.some((field) => field.type === "dynamiczone")) {
2646
- panels.push([row]);
2647
- currentPanelIndex += 2;
2648
- } else {
2649
- if (!panels[currentPanelIndex]) {
2650
- panels.push([]);
2651
- }
2652
- panels[currentPanelIndex].push(row);
2653
- }
2654
- return panels;
2655
- }, []);
2656
- const componentEditAttributes = Object.entries(data.components).reduce(
2657
- (acc, [uid, configuration]) => {
2658
- acc[uid] = {
2659
- layout: convertEditLayoutToFieldLayouts(
2660
- configuration.layouts.edit,
2661
- components[uid].attributes,
2662
- configuration.metadatas
2663
- ),
2664
- settings: {
2665
- ...configuration.settings,
2666
- icon: components[uid].info.icon,
2667
- displayName: components[uid].info.displayName
2936
+ collectionType,
2937
+ params: {
2938
+ locale: "*"
2939
+ }
2940
+ });
2941
+ if (!("error" in res)) {
2942
+ navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
2943
+ }
2944
+ } finally {
2945
+ if (!listViewPathMatch) {
2946
+ setSubmitting(false);
2947
+ }
2668
2948
  }
2669
- };
2670
- return acc;
2671
- },
2672
- {}
2673
- );
2674
- const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
2675
- (acc, [attribute, metadata]) => {
2676
- return {
2677
- ...acc,
2678
- [attribute]: metadata.edit
2679
- };
2680
- },
2681
- {}
2682
- );
2683
- return {
2684
- layout: panelledEditAttributes,
2685
- components: componentEditAttributes,
2686
- metadatas: editMetadatas,
2687
- settings: {
2688
- ...data.contentType.settings,
2689
- displayName: schema?.info.displayName
2949
+ }
2690
2950
  },
2691
- options: {
2692
- ...schema?.options,
2693
- ...schema?.pluginOptions,
2694
- ...data.contentType.options
2695
- }
2951
+ variant: "danger",
2952
+ position: ["header", "table-row"]
2696
2953
  };
2697
2954
  };
2698
- const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
2699
- return rows.map(
2700
- (row) => row.map((field) => {
2701
- const attribute = attributes[field.name];
2702
- if (!attribute) {
2703
- return null;
2704
- }
2705
- const { edit: metadata } = metadatas[field.name];
2706
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2707
- return {
2708
- attribute,
2709
- disabled: !metadata.editable,
2710
- hint: metadata.description,
2711
- label: metadata.label ?? "",
2712
- name: field.name,
2713
- // @ts-expect-error – mainField does exist on the metadata for a relation.
2714
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2715
- schemas,
2716
- components: components?.schemas ?? {}
2717
- }),
2718
- placeholder: metadata.placeholder ?? "",
2719
- required: attribute.required ?? false,
2720
- size: field.size,
2721
- unique: "unique" in attribute ? attribute.unique : false,
2722
- visible: metadata.visible ?? true,
2723
- type: attribute.type
2724
- };
2725
- }).filter((field) => field !== null)
2726
- );
2955
+ DeleteAction$1.type = "delete";
2956
+ const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2957
+ const Panels = () => {
2958
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2959
+ const [
2960
+ {
2961
+ query: { status }
2962
+ }
2963
+ ] = strapiAdmin.useQueryParams({
2964
+ status: "draft"
2965
+ });
2966
+ const { model, id, document, meta, collectionType } = useDoc();
2967
+ const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
2968
+ const props = {
2969
+ activeTab: status,
2970
+ model,
2971
+ documentId: id,
2972
+ document: isCloning ? void 0 : document,
2973
+ meta: isCloning ? void 0 : meta,
2974
+ collectionType
2975
+ };
2976
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
2977
+ strapiAdmin.DescriptionComponentRenderer,
2978
+ {
2979
+ props,
2980
+ descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2981
+ children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
2982
+ }
2983
+ ) });
2727
2984
  };
2728
- const formatListLayout = (data, {
2729
- schemas,
2730
- schema,
2731
- components
2732
- }) => {
2733
- const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
2734
- (acc, [attribute, metadata]) => {
2735
- return {
2736
- ...acc,
2737
- [attribute]: metadata.list
2738
- };
2739
- },
2740
- {}
2741
- );
2742
- const listAttributes = convertListLayoutToFieldLayouts(
2743
- data.contentType.layouts.list,
2744
- schema?.attributes,
2745
- listMetadatas,
2746
- { configurations: data.components, schemas: components },
2747
- schemas
2748
- );
2985
+ const ActionsPanel = () => {
2986
+ const { formatMessage } = reactIntl.useIntl();
2749
2987
  return {
2750
- layout: listAttributes,
2751
- settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
2752
- metadatas: listMetadatas,
2753
- options: {
2754
- ...schema?.options,
2755
- ...schema?.pluginOptions,
2756
- ...data.contentType.options
2757
- }
2988
+ title: formatMessage({
2989
+ id: "content-manager.containers.edit.panels.default.title",
2990
+ defaultMessage: "Entry"
2991
+ }),
2992
+ content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
2758
2993
  };
2759
2994
  };
2760
- const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
2761
- return columns.map((name) => {
2762
- const attribute = attributes[name];
2763
- if (!attribute) {
2764
- return null;
2995
+ ActionsPanel.type = "actions";
2996
+ const ActionsPanelContent = () => {
2997
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2998
+ const [
2999
+ {
3000
+ query: { status = "draft" }
2765
3001
  }
2766
- const metadata = metadatas[name];
2767
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2768
- return {
2769
- attribute,
2770
- label: metadata.label ?? "",
2771
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2772
- schemas,
2773
- components: components?.schemas ?? {}
2774
- }),
2775
- name,
2776
- searchable: metadata.searchable ?? true,
2777
- sortable: metadata.sortable ?? true
2778
- };
2779
- }).filter((field) => field !== null);
3002
+ ] = strapiAdmin.useQueryParams();
3003
+ const { model, id, document, meta, collectionType } = useDoc();
3004
+ const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
3005
+ const props = {
3006
+ activeTab: status,
3007
+ model,
3008
+ documentId: id,
3009
+ document: isCloning ? void 0 : document,
3010
+ meta: isCloning ? void 0 : meta,
3011
+ collectionType
3012
+ };
3013
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
3014
+ /* @__PURE__ */ jsxRuntime.jsx(
3015
+ strapiAdmin.DescriptionComponentRenderer,
3016
+ {
3017
+ props,
3018
+ descriptions: plugins["content-manager"].apis.getDocumentActions(),
3019
+ children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
3020
+ }
3021
+ ),
3022
+ /* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
3023
+ ] });
2780
3024
  };
3025
+ const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
3026
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3027
+ designSystem.Flex,
3028
+ {
3029
+ ref,
3030
+ tag: "aside",
3031
+ "aria-labelledby": "additional-information",
3032
+ background: "neutral0",
3033
+ borderColor: "neutral150",
3034
+ hasRadius: true,
3035
+ paddingBottom: 4,
3036
+ paddingLeft: 4,
3037
+ paddingRight: 4,
3038
+ paddingTop: 4,
3039
+ shadow: "tableShadow",
3040
+ gap: 3,
3041
+ direction: "column",
3042
+ justifyContent: "stretch",
3043
+ alignItems: "flex-start",
3044
+ children: [
3045
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
3046
+ children
3047
+ ]
3048
+ }
3049
+ );
3050
+ });
2781
3051
  const ConfirmBulkActionDialog = ({
2782
3052
  onToggleDialog,
2783
3053
  isOpen = false,
@@ -2785,7 +3055,7 @@ const ConfirmBulkActionDialog = ({
2785
3055
  endAction
2786
3056
  }) => {
2787
3057
  const { formatMessage } = reactIntl.useIntl();
2788
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { onOpenChange: onToggleDialog, open: isOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
3058
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
2789
3059
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage({
2790
3060
  id: "app.components.ConfirmDialog.title",
2791
3061
  defaultMessage: "Confirmation"
@@ -2816,6 +3086,7 @@ const ConfirmDialogPublishAll = ({
2816
3086
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler(getTranslation);
2817
3087
  const { model, schema } = useDoc();
2818
3088
  const [{ query }] = strapiAdmin.useQueryParams();
3089
+ const enableDraftRelationsCount = false;
2819
3090
  const {
2820
3091
  data: countDraftRelations = 0,
2821
3092
  isLoading,
@@ -2827,7 +3098,7 @@ const ConfirmDialogPublishAll = ({
2827
3098
  locale: query?.plugins?.i18n?.locale
2828
3099
  },
2829
3100
  {
2830
- skip: selectedEntries.length === 0
3101
+ skip: !enableDraftRelationsCount
2831
3102
  }
2832
3103
  );
2833
3104
  React__namespace.useEffect(() => {
@@ -2906,7 +3177,14 @@ const formatErrorMessages = (errors, parentKey, formatMessage) => {
2906
3177
  )
2907
3178
  );
2908
3179
  } else {
2909
- messages.push(...formatErrorMessages(value, currentKey, formatMessage));
3180
+ messages.push(
3181
+ ...formatErrorMessages(
3182
+ // @ts-expect-error TODO: check why value is not compatible with FormErrors
3183
+ value,
3184
+ currentKey,
3185
+ formatMessage
3186
+ )
3187
+ );
2910
3188
  }
2911
3189
  } else {
2912
3190
  messages.push(
@@ -3005,7 +3283,7 @@ const SelectedEntriesTableContent = ({
3005
3283
  status: row.status
3006
3284
  }
3007
3285
  ) }),
3008
- /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
3286
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
3009
3287
  designSystem.IconButton,
3010
3288
  {
3011
3289
  tag: reactRouterDom.Link,
@@ -3028,9 +3306,10 @@ const SelectedEntriesTableContent = ({
3028
3306
  ),
3029
3307
  target: "_blank",
3030
3308
  marginLeft: "auto",
3031
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {})
3309
+ variant: "ghost",
3310
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, { width: "1.6rem", height: "1.6rem" })
3032
3311
  }
3033
- ) })
3312
+ ) }) })
3034
3313
  ] }, row.id)) })
3035
3314
  ] });
3036
3315
  };
@@ -3067,7 +3346,13 @@ const SelectedEntriesModalContent = ({
3067
3346
  );
3068
3347
  const { rows, validationErrors } = React__namespace.useMemo(() => {
3069
3348
  if (data.length > 0 && schema) {
3070
- const validate = createYupSchema(schema.attributes, components);
3349
+ const validate = createYupSchema(
3350
+ schema.attributes,
3351
+ components,
3352
+ // Since this is the "Publish" action, the validation
3353
+ // schema must enforce the rules for published entities
3354
+ { status: "published" }
3355
+ );
3071
3356
  const validationErrors2 = {};
3072
3357
  const rows2 = data.map((entry) => {
3073
3358
  try {
@@ -3417,7 +3702,7 @@ const TableActions = ({ document }) => {
3417
3702
  strapiAdmin.DescriptionComponentRenderer,
3418
3703
  {
3419
3704
  props,
3420
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
3705
+ descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
3421
3706
  children: (actions2) => {
3422
3707
  const tableRowActions = actions2.filter((action) => {
3423
3708
  const positions = Array.isArray(action.position) ? action.position : [action.position];
@@ -3528,7 +3813,7 @@ const CloneAction = ({ model, documentId }) => {
3528
3813
  }),
3529
3814
  content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
3530
3815
  footer: ({ onClose }) => {
3531
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
3816
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
3532
3817
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
3533
3818
  id: "cancel",
3534
3819
  defaultMessage: "Cancel"
@@ -3569,8 +3854,7 @@ class ContentManagerPlugin {
3569
3854
  documentActions = [
3570
3855
  ...DEFAULT_ACTIONS,
3571
3856
  ...DEFAULT_TABLE_ROW_ACTIONS,
3572
- ...DEFAULT_HEADER_ACTIONS,
3573
- HistoryAction
3857
+ ...DEFAULT_HEADER_ACTIONS
3574
3858
  ];
3575
3859
  editViewSidePanels = [ActionsPanel];
3576
3860
  headerActions = [];
@@ -3659,6 +3943,52 @@ const getPrintableType = (value) => {
3659
3943
  }
3660
3944
  return nativeType;
3661
3945
  };
3946
+ const HistoryAction = ({ model, document }) => {
3947
+ const { formatMessage } = reactIntl.useIntl();
3948
+ const [{ query }] = strapiAdmin.useQueryParams();
3949
+ const navigate = reactRouterDom.useNavigate();
3950
+ const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
3951
+ if (!window.strapi.features.isEnabled("cms-content-history")) {
3952
+ return null;
3953
+ }
3954
+ return {
3955
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
3956
+ label: formatMessage({
3957
+ id: "content-manager.history.document-action",
3958
+ defaultMessage: "Content History"
3959
+ }),
3960
+ onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
3961
+ disabled: (
3962
+ /**
3963
+ * The user is creating a new document.
3964
+ * It hasn't been saved yet, so there's no history to go to
3965
+ */
3966
+ !document || /**
3967
+ * The document has been created but the current dimension has never been saved.
3968
+ * For example, the user is creating a new locale in an existing document,
3969
+ * so there's no history for the document in that locale
3970
+ */
3971
+ !document.id || /**
3972
+ * History is only available for content types created by the user.
3973
+ * These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
3974
+ * which start with `admin::` or `plugin::`
3975
+ */
3976
+ !model.startsWith("api::")
3977
+ ),
3978
+ position: "header"
3979
+ };
3980
+ };
3981
+ HistoryAction.type = "history";
3982
+ const historyAdmin = {
3983
+ bootstrap(app) {
3984
+ const { addDocumentAction } = app.getPlugin("content-manager").apis;
3985
+ addDocumentAction((actions2) => {
3986
+ const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
3987
+ actions2.splice(indexOfDeleteAction, 0, HistoryAction);
3988
+ return actions2;
3989
+ });
3990
+ }
3991
+ };
3662
3992
  const initialState = {
3663
3993
  collectionTypeLinks: [],
3664
3994
  components: [],
@@ -3709,15 +4039,29 @@ const index = {
3709
4039
  defaultMessage: "Content Manager"
3710
4040
  },
3711
4041
  permissions: [],
3712
- Component: () => Promise.resolve().then(() => require("./layout--iHdZzRk.js")).then((mod) => ({ default: mod.Layout })),
3713
4042
  position: 1
3714
4043
  });
4044
+ app.router.addRoute({
4045
+ path: "content-manager/*",
4046
+ lazy: async () => {
4047
+ const { Layout } = await Promise.resolve().then(() => require("./layout-B4aCAdTt.js"));
4048
+ return {
4049
+ Component: Layout
4050
+ };
4051
+ },
4052
+ children: routes
4053
+ });
3715
4054
  app.registerPlugin(cm.config);
3716
4055
  },
4056
+ bootstrap(app) {
4057
+ if (typeof historyAdmin.bootstrap === "function") {
4058
+ historyAdmin.bootstrap(app);
4059
+ }
4060
+ },
3717
4061
  async registerTrads({ locales }) {
3718
4062
  const importedTrads = await Promise.all(
3719
4063
  locales.map((locale) => {
3720
- return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-fbKQxLGn.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-EUonQTon.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-B7kGGg3E.js")), "./translations/gu.json": () => Promise.resolve().then(() => require("./gu-BRmF601H.js")), "./translations/hi.json": () => Promise.resolve().then(() => require("./hi-CCJBptSq.js")), "./translations/hu.json": () => Promise.resolve().then(() => require("./hu-sNV_yLYy.js")), "./translations/id.json": () => Promise.resolve().then(() => require("./id-B5Ser98A.js")), "./translations/it.json": () => Promise.resolve().then(() => require("./it-DkBIs7vD.js")), "./translations/ja.json": () => Promise.resolve().then(() => require("./ja-CcFe8diO.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-woFZPmLk.js")), "./translations/ml.json": () => Promise.resolve().then(() => require("./ml-C2W8N8k1.js")), "./translations/ms.json": () => Promise.resolve().then(() => require("./ms-BuFotyP_.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-bbEOHChV.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-uzwG-hk7.js")), "./translations/pt-BR.json": () => Promise.resolve().then(() => require("./pt-BR-BiOz37D9.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-CeXQuq50.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BT3ybNny.js")), "./translations/sa.json": () => Promise.resolve().then(() => require("./sa-CcvkYInH.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-CvY09Xjv.js")), "./translations/sv.json": () => Promise.resolve().then(() => require("./sv-MYDuzgvT.js")), "./translations/th.json": () => Promise.resolve().then(() => require("./th-D9_GfAjc.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-D9UH-O_R.js")), "./translations/uk.json": () => Promise.resolve().then(() => require("./uk-C8EiqJY7.js")), "./translations/vi.json": () => Promise.resolve().then(() => require("./vi-CJlYDheJ.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-9kOncHGw.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CQQfszqR.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
4064
+ return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-Bm0D0IWz.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-EUonQTon.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-B7kGGg3E.js")), "./translations/gu.json": () => Promise.resolve().then(() => require("./gu-BRmF601H.js")), "./translations/hi.json": () => Promise.resolve().then(() => require("./hi-CCJBptSq.js")), "./translations/hu.json": () => Promise.resolve().then(() => require("./hu-sNV_yLYy.js")), "./translations/id.json": () => Promise.resolve().then(() => require("./id-B5Ser98A.js")), "./translations/it.json": () => Promise.resolve().then(() => require("./it-DkBIs7vD.js")), "./translations/ja.json": () => Promise.resolve().then(() => require("./ja-CcFe8diO.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-woFZPmLk.js")), "./translations/ml.json": () => Promise.resolve().then(() => require("./ml-C2W8N8k1.js")), "./translations/ms.json": () => Promise.resolve().then(() => require("./ms-BuFotyP_.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-bbEOHChV.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-uzwG-hk7.js")), "./translations/pt-BR.json": () => Promise.resolve().then(() => require("./pt-BR-BiOz37D9.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-CeXQuq50.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BT3ybNny.js")), "./translations/sa.json": () => Promise.resolve().then(() => require("./sa-CcvkYInH.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-CvY09Xjv.js")), "./translations/sv.json": () => Promise.resolve().then(() => require("./sv-MYDuzgvT.js")), "./translations/th.json": () => Promise.resolve().then(() => require("./th-D9_GfAjc.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-D9UH-O_R.js")), "./translations/uk.json": () => Promise.resolve().then(() => require("./uk-C8EiqJY7.js")), "./translations/vi.json": () => Promise.resolve().then(() => require("./vi-CJlYDheJ.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-9kOncHGw.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CQQfszqR.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
3721
4065
  return {
3722
4066
  data: prefixPluginTranslations(data, PLUGIN_ID),
3723
4067
  locale
@@ -3735,6 +4079,7 @@ const index = {
3735
4079
  };
3736
4080
  exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
3737
4081
  exports.BulkActionsRenderer = BulkActionsRenderer;
4082
+ exports.CLONE_PATH = CLONE_PATH;
3738
4083
  exports.COLLECTION_TYPES = COLLECTION_TYPES;
3739
4084
  exports.CREATOR_FIELDS = CREATOR_FIELDS;
3740
4085
  exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
@@ -3761,8 +4106,8 @@ exports.getDisplayName = getDisplayName;
3761
4106
  exports.getMainField = getMainField;
3762
4107
  exports.getTranslation = getTranslation;
3763
4108
  exports.index = index;
3764
- exports.routes = routes;
3765
4109
  exports.setInitialData = setInitialData;
4110
+ exports.useContentManagerContext = useContentManagerContext;
3766
4111
  exports.useContentTypeSchema = useContentTypeSchema;
3767
4112
  exports.useDoc = useDoc;
3768
4113
  exports.useDocLayout = useDocLayout;
@@ -3775,4 +4120,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
3775
4120
  exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
3776
4121
  exports.useGetInitialDataQuery = useGetInitialDataQuery;
3777
4122
  exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
3778
- //# sourceMappingURL=index-CWpLBSt0.js.map
4123
+ //# sourceMappingURL=index-BsMu2oVP.js.map