@strapi/content-manager 0.0.0-experimental.a9a5a36dd73072c19eadeff5f387e8286b2a4d22 → 0.0.0-experimental.ae69a6ec6a65b1061cd6a00b2608abeeff436042

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 (147) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-B1bIXVuX.mjs → ComponentConfigurationPage-DH3rgf1K.mjs} +4 -4
  2. package/dist/_chunks/{ComponentConfigurationPage-B1bIXVuX.mjs.map → ComponentConfigurationPage-DH3rgf1K.mjs.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-Bqgx7Mes.js → ComponentConfigurationPage-DRh2GoZx.js} +4 -4
  4. package/dist/_chunks/{ComponentConfigurationPage-Bqgx7Mes.js.map → ComponentConfigurationPage-DRh2GoZx.js.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-BFEwvdMW.js → EditConfigurationPage-BOAqRJUV.js} +4 -4
  6. package/dist/_chunks/{EditConfigurationPage-BFEwvdMW.js.map → EditConfigurationPage-BOAqRJUV.js.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-ZO0vOO8q.mjs → EditConfigurationPage-C1HHivAz.mjs} +4 -4
  8. package/dist/_chunks/{EditConfigurationPage-ZO0vOO8q.mjs.map → EditConfigurationPage-C1HHivAz.mjs.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-DA95Ha6J.js → EditViewPage-CgfL33yw.js} +30 -9
  10. package/dist/_chunks/EditViewPage-CgfL33yw.js.map +1 -0
  11. package/dist/_chunks/{EditViewPage-DlLEyUL6.mjs → EditViewPage-DBV7CZVf.mjs} +30 -9
  12. package/dist/_chunks/EditViewPage-DBV7CZVf.mjs.map +1 -0
  13. package/dist/_chunks/{Field-Dq7bDnuh.mjs → Field-BQFK_H87.mjs} +178 -106
  14. package/dist/_chunks/Field-BQFK_H87.mjs.map +1 -0
  15. package/dist/_chunks/{Field-CnK8dO8N.js → Field-C647fIuP.js} +180 -108
  16. package/dist/_chunks/Field-C647fIuP.js.map +1 -0
  17. package/dist/_chunks/{Form-B_JE0dbz.mjs → Form--31reETM.mjs} +36 -17
  18. package/dist/_chunks/Form--31reETM.mjs.map +1 -0
  19. package/dist/_chunks/{Form-BpiR4piS.js → Form-CsYUrVEA.js} +36 -17
  20. package/dist/_chunks/Form-CsYUrVEA.js.map +1 -0
  21. package/dist/_chunks/{History-CBNGU7a-.mjs → History-8tQaor_-.mjs} +42 -19
  22. package/dist/_chunks/History-8tQaor_-.mjs.map +1 -0
  23. package/dist/_chunks/{History-DdIstl8b.js → History-Dl6wOm0V.js} +41 -18
  24. package/dist/_chunks/History-Dl6wOm0V.js.map +1 -0
  25. package/dist/_chunks/{ListConfigurationPage-DkKRparB.js → ListConfigurationPage-BedUJnmo.js} +15 -5
  26. package/dist/_chunks/ListConfigurationPage-BedUJnmo.js.map +1 -0
  27. package/dist/_chunks/{ListConfigurationPage-5dr4qpue.mjs → ListConfigurationPage-_WWIGpVT.mjs} +15 -5
  28. package/dist/_chunks/ListConfigurationPage-_WWIGpVT.mjs.map +1 -0
  29. package/dist/_chunks/{ListViewPage-wE0lXqoD.js → ListViewPage-5QzoAtAo.js} +61 -41
  30. package/dist/_chunks/ListViewPage-5QzoAtAo.js.map +1 -0
  31. package/dist/_chunks/{ListViewPage-DecLrYV6.mjs → ListViewPage-CZfw9OW9.mjs} +59 -39
  32. package/dist/_chunks/ListViewPage-CZfw9OW9.mjs.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-CiIcfYsd.mjs → NoContentTypePage-D-RqshUI.mjs} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-CiIcfYsd.mjs.map → NoContentTypePage-D-RqshUI.mjs.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-DEKR6tf9.js → NoContentTypePage-DBIyA7hd.js} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-DEKR6tf9.js.map → NoContentTypePage-DBIyA7hd.js.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-DmNfF2Bb.js → NoPermissionsPage-CCAreseM.js} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-DmNfF2Bb.js.map → NoPermissionsPage-CCAreseM.js.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-CM5UD8ee.mjs → NoPermissionsPage-m7GAd26r.mjs} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-CM5UD8ee.mjs.map → NoPermissionsPage-m7GAd26r.mjs.map} +1 -1
  41. package/dist/_chunks/{Relations-Dqz0C1fz.mjs → Relations-Dq52hb_u.mjs} +70 -37
  42. package/dist/_chunks/Relations-Dq52hb_u.mjs.map +1 -0
  43. package/dist/_chunks/{Relations-L0xYRoSQ.js → Relations-SRwPhmo7.js} +69 -36
  44. package/dist/_chunks/Relations-SRwPhmo7.js.map +1 -0
  45. package/dist/_chunks/{en-uOUIxfcQ.js → en-Bm0D0IWz.js} +13 -12
  46. package/dist/_chunks/{en-uOUIxfcQ.js.map → en-Bm0D0IWz.js.map} +1 -1
  47. package/dist/_chunks/{en-BrCTWlZv.mjs → en-DKV44jRb.mjs} +13 -12
  48. package/dist/_chunks/{en-BrCTWlZv.mjs.map → en-DKV44jRb.mjs.map} +1 -1
  49. package/dist/_chunks/{index-BSn97i8U.mjs → index-1Bdj-6ls.mjs} +914 -710
  50. package/dist/_chunks/index-1Bdj-6ls.mjs.map +1 -0
  51. package/dist/_chunks/{index-DyvUPg1a.js → index-CsrCnNa3.js} +895 -690
  52. package/dist/_chunks/index-CsrCnNa3.js.map +1 -0
  53. package/dist/_chunks/{layout-TPqF2oJ5.js → layout-B33V9Tdu.js} +21 -8
  54. package/dist/_chunks/layout-B33V9Tdu.js.map +1 -0
  55. package/dist/_chunks/{layout-DPaHUusj.mjs → layout-ByD1cQSW.mjs} +22 -9
  56. package/dist/_chunks/layout-ByD1cQSW.mjs.map +1 -0
  57. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  58. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  59. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  60. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  61. package/dist/_chunks/{relations-BWYS9gkn.js → relations-BBHlo3qQ.js} +3 -7
  62. package/dist/_chunks/relations-BBHlo3qQ.js.map +1 -0
  63. package/dist/_chunks/{relations-Ck7-ecDT.mjs → relations-DFwbNLZ0.mjs} +3 -7
  64. package/dist/_chunks/relations-DFwbNLZ0.mjs.map +1 -0
  65. package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
  66. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
  67. package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
  68. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
  69. package/dist/admin/index.js +2 -1
  70. package/dist/admin/index.js.map +1 -1
  71. package/dist/admin/index.mjs +5 -4
  72. package/dist/admin/src/exports.d.ts +1 -1
  73. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  74. package/dist/admin/src/hooks/useDocument.d.ts +32 -1
  75. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
  76. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  77. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +4 -48
  78. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  79. package/dist/admin/src/preview/constants.d.ts +1 -0
  80. package/dist/admin/src/preview/index.d.ts +4 -0
  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 +256 -134
  90. package/dist/server/index.js.map +1 -1
  91. package/dist/server/index.mjs +257 -135
  92. package/dist/server/index.mjs.map +1 -1
  93. package/dist/server/src/bootstrap.d.ts.map +1 -1
  94. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  95. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  96. package/dist/server/src/controllers/uid.d.ts.map +1 -1
  97. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  98. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  99. package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
  100. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
  101. package/dist/server/src/history/services/history.d.ts.map +1 -1
  102. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  103. package/dist/server/src/history/services/utils.d.ts +2 -1
  104. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  105. package/dist/server/src/index.d.ts +4 -4
  106. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  107. package/dist/server/src/preview/constants.d.ts +2 -0
  108. package/dist/server/src/preview/constants.d.ts.map +1 -0
  109. package/dist/server/src/preview/index.d.ts +4 -0
  110. package/dist/server/src/preview/index.d.ts.map +1 -0
  111. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  112. package/dist/server/src/services/document-metadata.d.ts +8 -8
  113. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  114. package/dist/server/src/services/index.d.ts +4 -4
  115. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  116. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  117. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  118. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  119. package/dist/server/src/utils/index.d.ts +2 -0
  120. package/dist/server/src/utils/index.d.ts.map +1 -1
  121. package/dist/shared/contracts/collection-types.d.ts +3 -1
  122. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  123. package/package.json +13 -13
  124. package/dist/_chunks/EditViewPage-DA95Ha6J.js.map +0 -1
  125. package/dist/_chunks/EditViewPage-DlLEyUL6.mjs.map +0 -1
  126. package/dist/_chunks/Field-CnK8dO8N.js.map +0 -1
  127. package/dist/_chunks/Field-Dq7bDnuh.mjs.map +0 -1
  128. package/dist/_chunks/Form-B_JE0dbz.mjs.map +0 -1
  129. package/dist/_chunks/Form-BpiR4piS.js.map +0 -1
  130. package/dist/_chunks/History-CBNGU7a-.mjs.map +0 -1
  131. package/dist/_chunks/History-DdIstl8b.js.map +0 -1
  132. package/dist/_chunks/ListConfigurationPage-5dr4qpue.mjs.map +0 -1
  133. package/dist/_chunks/ListConfigurationPage-DkKRparB.js.map +0 -1
  134. package/dist/_chunks/ListViewPage-DecLrYV6.mjs.map +0 -1
  135. package/dist/_chunks/ListViewPage-wE0lXqoD.js.map +0 -1
  136. package/dist/_chunks/Relations-Dqz0C1fz.mjs.map +0 -1
  137. package/dist/_chunks/Relations-L0xYRoSQ.js.map +0 -1
  138. package/dist/_chunks/index-BSn97i8U.mjs.map +0 -1
  139. package/dist/_chunks/index-DyvUPg1a.js.map +0 -1
  140. package/dist/_chunks/layout-DPaHUusj.mjs.map +0 -1
  141. package/dist/_chunks/layout-TPqF2oJ5.js.map +0 -1
  142. package/dist/_chunks/relations-BWYS9gkn.js.map +0 -1
  143. package/dist/_chunks/relations-Ck7-ecDT.mjs.map +0 -1
  144. package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
  145. package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
  146. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
  147. package/strapi-server.js +0 -3
@@ -4,12 +4,13 @@ const jsxRuntime = require("react/jsx-runtime");
4
4
  const strapiAdmin = require("@strapi/admin/strapi-admin");
5
5
  const React = require("react");
6
6
  const designSystem = require("@strapi/design-system");
7
+ const mapValues = require("lodash/fp/mapValues");
7
8
  const reactIntl = require("react-intl");
8
9
  const reactRouterDom = require("react-router-dom");
9
- const styledComponents = require("styled-components");
10
10
  const yup = require("yup");
11
11
  const pipe = require("lodash/fp/pipe");
12
12
  const dateFns = require("date-fns");
13
+ const styledComponents = require("styled-components");
13
14
  const qs = require("qs");
14
15
  const toolkit = require("@reduxjs/toolkit");
15
16
  const _interopDefault = (e) => e && e.__esModule ? e : { default: 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) => {
@@ -121,6 +123,7 @@ const DocumentRBAC = ({ children, permissions }) => {
121
123
  if (!slug) {
122
124
  throw new Error("Cannot find the slug param in the URL");
123
125
  }
126
+ const [{ rawQuery }] = strapiAdmin.useQueryParams();
124
127
  const userPermissions = strapiAdmin.useAuth("DocumentRBAC", (state) => state.permissions);
125
128
  const contentTypePermissions = React__namespace.useMemo(() => {
126
129
  const contentTypePermissions2 = userPermissions.filter(
@@ -131,7 +134,14 @@ const DocumentRBAC = ({ children, permissions }) => {
131
134
  return { ...acc, [action]: [permission] };
132
135
  }, {});
133
136
  }, [slug, userPermissions]);
134
- 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
+ );
135
145
  const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
136
146
  const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
137
147
  const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
@@ -179,7 +189,8 @@ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
179
189
  "Document",
180
190
  "InitialData",
181
191
  "HistoryVersion",
182
- "Relations"
192
+ "Relations",
193
+ "UidAvailability"
183
194
  ]
184
195
  });
185
196
  const documentApi = contentManagerApi.injectEndpoints({
@@ -193,7 +204,12 @@ const documentApi = contentManagerApi.injectEndpoints({
193
204
  params: query
194
205
  }
195
206
  }),
196
- 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
+ }
197
213
  }),
198
214
  cloneDocument: builder.mutation({
199
215
  query: ({ model, sourceId, data, params }) => ({
@@ -204,7 +220,10 @@ const documentApi = contentManagerApi.injectEndpoints({
204
220
  params
205
221
  }
206
222
  }),
207
- 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
+ ]
208
227
  }),
209
228
  /**
210
229
  * Creates a new collection-type document. This should ONLY be used for collection-types.
@@ -221,7 +240,8 @@ const documentApi = contentManagerApi.injectEndpoints({
221
240
  }),
222
241
  invalidatesTags: (result, _error, { model }) => [
223
242
  { type: "Document", id: `${model}_LIST` },
224
- "Relations"
243
+ "Relations",
244
+ { type: "UidAvailability", id: model }
225
245
  ]
226
246
  }),
227
247
  deleteDocument: builder.mutation({
@@ -262,7 +282,8 @@ const documentApi = contentManagerApi.injectEndpoints({
262
282
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
263
283
  },
264
284
  { type: "Document", id: `${model}_LIST` },
265
- "Relations"
285
+ "Relations",
286
+ { type: "UidAvailability", id: model }
266
287
  ];
267
288
  }
268
289
  }),
@@ -272,7 +293,7 @@ const documentApi = contentManagerApi.injectEndpoints({
272
293
  */
273
294
  getAllDocuments: builder.query({
274
295
  query: ({ model, params }) => ({
275
- url: `/content-manager/collection-types/${model}`,
296
+ url: `/content-manager/collection-types/${model}${params ? `?${params}` : ""}`,
276
297
  method: "GET",
277
298
  config: {
278
299
  params
@@ -280,6 +301,7 @@ const documentApi = contentManagerApi.injectEndpoints({
280
301
  }),
281
302
  providesTags: (result, _error, arg) => {
282
303
  return [
304
+ { type: "Document", id: `ALL_LIST` },
283
305
  { type: "Document", id: `${arg.model}_LIST` },
284
306
  ...result?.results.map(({ documentId }) => ({
285
307
  type: "Document",
@@ -318,6 +340,11 @@ const documentApi = contentManagerApi.injectEndpoints({
318
340
  {
319
341
  type: "Document",
320
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`
321
348
  }
322
349
  ];
323
350
  }
@@ -381,8 +408,21 @@ const documentApi = contentManagerApi.injectEndpoints({
381
408
  type: "Document",
382
409
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
383
410
  },
384
- "Relations"
411
+ "Relations",
412
+ { type: "UidAvailability", id: model }
385
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
+ }
386
426
  }
387
427
  }),
388
428
  unpublishDocument: builder.mutation({
@@ -452,20 +492,39 @@ const buildValidParams = (query) => {
452
492
  const isBaseQueryError = (error) => {
453
493
  return error.name !== void 0;
454
494
  };
455
- 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 }) => {
456
514
  const createModelSchema = (attributes2) => yup__namespace.object().shape(
457
515
  Object.entries(attributes2).reduce((acc, [name, attribute]) => {
458
516
  if (DOCUMENT_META_FIELDS.includes(name)) {
459
517
  return acc;
460
518
  }
461
519
  const validations = [
520
+ addNullableValidation,
462
521
  addRequiredValidation,
463
522
  addMinLengthValidation,
464
523
  addMaxLengthValidation,
465
524
  addMinValidation,
466
525
  addMaxValidation,
467
526
  addRegexValidation
468
- ].map((fn) => fn(attribute));
527
+ ].map((fn) => fn(attribute, options));
469
528
  const transformSchema = pipe__default.default(...validations);
470
529
  switch (attribute.type) {
471
530
  case "component": {
@@ -475,12 +534,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
475
534
  ...acc,
476
535
  [name]: transformSchema(
477
536
  yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
478
- )
537
+ ).test(arrayValidator(attribute, options))
479
538
  };
480
539
  } else {
481
540
  return {
482
541
  ...acc,
483
- [name]: transformSchema(createModelSchema(attributes3))
542
+ [name]: transformSchema(createModelSchema(attributes3).nullable())
484
543
  };
485
544
  }
486
545
  }
@@ -502,7 +561,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
502
561
  }
503
562
  )
504
563
  )
505
- )
564
+ ).test(arrayValidator(attribute, options))
506
565
  };
507
566
  case "relation":
508
567
  return {
@@ -514,7 +573,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
514
573
  } else if (Array.isArray(value)) {
515
574
  return yup__namespace.array().of(
516
575
  yup__namespace.object().shape({
517
- id: yup__namespace.string().required()
576
+ id: yup__namespace.number().required()
518
577
  })
519
578
  );
520
579
  } else if (typeof value === "object") {
@@ -566,6 +625,14 @@ const createAttributeSchema = (attribute) => {
566
625
  if (!value || typeof value === "string" && value.length === 0) {
567
626
  return true;
568
627
  }
628
+ if (typeof value === "object") {
629
+ try {
630
+ JSON.stringify(value);
631
+ return true;
632
+ } catch (err) {
633
+ return false;
634
+ }
635
+ }
569
636
  try {
570
637
  JSON.parse(value);
571
638
  return true;
@@ -584,13 +651,7 @@ const createAttributeSchema = (attribute) => {
584
651
  return yup__namespace.mixed();
585
652
  }
586
653
  };
587
- const addRequiredValidation = (attribute) => (schema) => {
588
- if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
589
- return schema.min(1, strapiAdmin.translatedErrors.required);
590
- }
591
- if (attribute.required && attribute.type !== "relation") {
592
- return schema.required(strapiAdmin.translatedErrors.required);
593
- }
654
+ const nullableSchema = (schema) => {
594
655
  return schema?.nullable ? schema.nullable() : (
595
656
  // In some cases '.nullable' will not be available on the schema.
596
657
  // e.g. when the schema has been built using yup.lazy (e.g. for relations).
@@ -598,7 +659,22 @@ const addRequiredValidation = (attribute) => (schema) => {
598
659
  schema
599
660
  );
600
661
  };
601
- 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
+ }
602
678
  if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
603
679
  return schema.min(attribute.minLength, {
604
680
  ...strapiAdmin.translatedErrors.minLength,
@@ -620,32 +696,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
620
696
  }
621
697
  return schema;
622
698
  };
623
- const addMinValidation = (attribute) => (schema) => {
624
- 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) {
625
704
  const min = toInteger(attribute.min);
626
- if (attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") {
627
- if (!attribute.required && "test" in schema && min) {
628
- return schema.test(
629
- "custom-min",
630
- {
631
- ...strapiAdmin.translatedErrors.min,
632
- values: {
633
- min: attribute.min
634
- }
635
- },
636
- (value) => {
637
- if (!value) {
638
- return true;
639
- }
640
- if (Array.isArray(value) && value.length === 0) {
641
- return true;
642
- }
643
- return value.length >= min;
644
- }
645
- );
646
- }
647
- }
648
- if ("min" in schema && min) {
705
+ if (min) {
649
706
  return schema.min(min, {
650
707
  ...strapiAdmin.translatedErrors.min,
651
708
  values: {
@@ -763,19 +820,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
763
820
  }, {});
764
821
  return componentsByKey;
765
822
  };
766
- 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);
767
922
  const { toggleNotification } = strapiAdmin.useNotification();
768
923
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
924
+ const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
769
925
  const {
770
- currentData: data,
771
- isLoading: isLoadingDocument,
772
- isFetching: isFetchingDocument,
773
- error
774
- } = useGetDocumentQuery(args, {
775
- ...opts,
776
- skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
777
- });
778
- 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;
779
932
  React__namespace.useEffect(() => {
780
933
  if (error) {
781
934
  toggleNotification({
@@ -783,83 +936,338 @@ const useDocument = (args, opts) => {
783
936
  message: formatAPIError(error)
784
937
  });
785
938
  }
786
- }, [toggleNotification, error, formatAPIError, args.collectionType]);
787
- const validationSchema = React__namespace.useMemo(() => {
788
- if (!schema) {
789
- return null;
790
- }
791
- return createYupSchema(schema.attributes, components);
792
- }, [schema, components]);
793
- const validate = React__namespace.useCallback(
794
- (document) => {
795
- if (!validationSchema) {
796
- throw new Error(
797
- "There is no validation schema generated, this is likely due to the schema not being loaded yet."
798
- );
799
- }
800
- try {
801
- validationSchema.validateSync(document, { abortEarly: false, strict: true });
802
- return null;
803
- } catch (error2) {
804
- if (error2 instanceof yup.ValidationError) {
805
- return strapiAdmin.getYupValidationErrors(error2);
806
- }
807
- throw error2;
808
- }
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
809
947
  },
810
- [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]
811
964
  );
812
- const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
813
965
  return {
814
- components,
815
- document: data?.data,
816
- meta: data?.meta,
966
+ error,
817
967
  isLoading,
818
- schema,
819
- validate
820
- };
821
- };
822
- const useDoc = () => {
823
- const { id, slug, collectionType, origin } = reactRouterDom.useParams();
824
- const [{ query }] = strapiAdmin.useQueryParams();
825
- const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
826
- if (!collectionType) {
827
- throw new Error("Could not find collectionType in url params");
828
- }
829
- if (!slug) {
830
- throw new Error("Could not find model in url params");
831
- }
832
- return {
833
- collectionType,
834
- model: slug,
835
- id: origin || id === "create" ? void 0 : id,
836
- ...useDocument(
837
- { documentId: origin || id, model: slug, collectionType, params },
838
- {
839
- skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
840
- }
841
- )
968
+ edit,
969
+ list: listLayout
842
970
  };
843
971
  };
844
- const prefixPluginTranslations = (trad, pluginId) => {
845
- if (!pluginId) {
846
- throw new TypeError("pluginId can't be empty");
847
- }
848
- return Object.keys(trad).reduce((acc, current) => {
849
- acc[`${pluginId}.${current}`] = trad[current];
850
- return acc;
851
- }, {});
852
- };
853
- const getTranslation = (id) => `content-manager.${id}`;
854
- const DEFAULT_UNEXPECTED_ERROR_MSG = {
855
- id: "notification.error",
856
- defaultMessage: "An error occurred, please try again"
972
+ const useDocLayout = () => {
973
+ const { model } = useDoc();
974
+ return useDocumentLayout(model);
857
975
  };
858
- const useDocumentActions = () => {
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) {
1198
+ throw new Error("Could not find model in url params");
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;
1207
+ return {
1208
+ collectionType,
1209
+ model: slug,
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
1251
+ };
1252
+ };
1253
+ const prefixPluginTranslations = (trad, pluginId) => {
1254
+ return Object.keys(trad).reduce((acc, current) => {
1255
+ acc[`${pluginId}.${current}`] = trad[current];
1256
+ return acc;
1257
+ }, {});
1258
+ };
1259
+ const getTranslation = (id) => `content-manager.${id}`;
1260
+ const DEFAULT_UNEXPECTED_ERROR_MSG = {
1261
+ id: "notification.error",
1262
+ defaultMessage: "An error occurred, please try again"
1263
+ };
1264
+ const useDocumentActions = () => {
859
1265
  const { toggleNotification } = strapiAdmin.useNotification();
860
1266
  const { formatMessage } = reactIntl.useIntl();
861
1267
  const { trackUsage } = strapiAdmin.useTracking();
862
1268
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
1269
+ const navigate = reactRouterDom.useNavigate();
1270
+ const setCurrentStep = strapiAdmin.useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
863
1271
  const [deleteDocument] = useDeleteDocumentMutation();
864
1272
  const _delete = React__namespace.useCallback(
865
1273
  async ({ collectionType, model, documentId, params }, trackerProperty) => {
@@ -1174,6 +1582,7 @@ const useDocumentActions = () => {
1174
1582
  defaultMessage: "Saved document"
1175
1583
  })
1176
1584
  });
1585
+ setCurrentStep("contentManager.success");
1177
1586
  return res.data;
1178
1587
  } catch (err) {
1179
1588
  toggleNotification({
@@ -1195,7 +1604,6 @@ const useDocumentActions = () => {
1195
1604
  sourceId
1196
1605
  });
1197
1606
  if ("error" in res) {
1198
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1199
1607
  return { error: res.error };
1200
1608
  }
1201
1609
  toggleNotification({
@@ -1214,7 +1622,7 @@ const useDocumentActions = () => {
1214
1622
  throw err;
1215
1623
  }
1216
1624
  },
1217
- [autoCloneDocument, formatAPIError, formatMessage, toggleNotification]
1625
+ [autoCloneDocument, formatMessage, toggleNotification]
1218
1626
  );
1219
1627
  const [cloneDocument] = useCloneDocumentMutation();
1220
1628
  const clone = React__namespace.useCallback(
@@ -1240,6 +1648,7 @@ const useDocumentActions = () => {
1240
1648
  defaultMessage: "Cloned document"
1241
1649
  })
1242
1650
  });
1651
+ navigate(`../../${res.data.data.documentId}`, { relative: "path" });
1243
1652
  return res.data;
1244
1653
  } catch (err) {
1245
1654
  toggleNotification({
@@ -1250,7 +1659,7 @@ const useDocumentActions = () => {
1250
1659
  throw err;
1251
1660
  }
1252
1661
  },
1253
- [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
1662
+ [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
1254
1663
  );
1255
1664
  const [getDoc] = useLazyGetDocumentQuery();
1256
1665
  const getDocument = React__namespace.useCallback(
@@ -1276,7 +1685,7 @@ const useDocumentActions = () => {
1276
1685
  };
1277
1686
  };
1278
1687
  const ProtectedHistoryPage = React.lazy(
1279
- () => Promise.resolve().then(() => require("./History-DdIstl8b.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1688
+ () => Promise.resolve().then(() => require("./History-Dl6wOm0V.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1280
1689
  );
1281
1690
  const routes$1 = [
1282
1691
  {
@@ -1289,31 +1698,31 @@ const routes$1 = [
1289
1698
  }
1290
1699
  ];
1291
1700
  const ProtectedEditViewPage = React.lazy(
1292
- () => Promise.resolve().then(() => require("./EditViewPage-DA95Ha6J.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1701
+ () => Promise.resolve().then(() => require("./EditViewPage-CgfL33yw.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1293
1702
  );
1294
1703
  const ProtectedListViewPage = React.lazy(
1295
- () => Promise.resolve().then(() => require("./ListViewPage-wE0lXqoD.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1704
+ () => Promise.resolve().then(() => require("./ListViewPage-5QzoAtAo.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1296
1705
  );
1297
1706
  const ProtectedListConfiguration = React.lazy(
1298
- () => Promise.resolve().then(() => require("./ListConfigurationPage-DkKRparB.js")).then((mod) => ({
1707
+ () => Promise.resolve().then(() => require("./ListConfigurationPage-BedUJnmo.js")).then((mod) => ({
1299
1708
  default: mod.ProtectedListConfiguration
1300
1709
  }))
1301
1710
  );
1302
1711
  const ProtectedEditConfigurationPage = React.lazy(
1303
- () => Promise.resolve().then(() => require("./EditConfigurationPage-BFEwvdMW.js")).then((mod) => ({
1712
+ () => Promise.resolve().then(() => require("./EditConfigurationPage-BOAqRJUV.js")).then((mod) => ({
1304
1713
  default: mod.ProtectedEditConfigurationPage
1305
1714
  }))
1306
1715
  );
1307
1716
  const ProtectedComponentConfigurationPage = React.lazy(
1308
- () => Promise.resolve().then(() => require("./ComponentConfigurationPage-Bqgx7Mes.js")).then((mod) => ({
1717
+ () => Promise.resolve().then(() => require("./ComponentConfigurationPage-DRh2GoZx.js")).then((mod) => ({
1309
1718
  default: mod.ProtectedComponentConfigurationPage
1310
1719
  }))
1311
1720
  );
1312
1721
  const NoPermissions = React.lazy(
1313
- () => Promise.resolve().then(() => require("./NoPermissionsPage-DmNfF2Bb.js")).then((mod) => ({ default: mod.NoPermissions }))
1722
+ () => Promise.resolve().then(() => require("./NoPermissionsPage-CCAreseM.js")).then((mod) => ({ default: mod.NoPermissions }))
1314
1723
  );
1315
1724
  const NoContentType = React.lazy(
1316
- () => Promise.resolve().then(() => require("./NoContentTypePage-DEKR6tf9.js")).then((mod) => ({ default: mod.NoContentType }))
1725
+ () => Promise.resolve().then(() => require("./NoContentTypePage-DBIyA7hd.js")).then((mod) => ({ default: mod.NoContentType }))
1317
1726
  );
1318
1727
  const CollectionTypePages = () => {
1319
1728
  const { collectionType } = reactRouterDom.useParams();
@@ -1427,12 +1836,14 @@ const DocumentActionButton = (action) => {
1427
1836
  /* @__PURE__ */ jsxRuntime.jsx(
1428
1837
  designSystem.Button,
1429
1838
  {
1430
- flex: 1,
1839
+ flex: "auto",
1431
1840
  startIcon: action.icon,
1432
1841
  disabled: action.disabled,
1433
1842
  onClick: handleClick(action),
1434
1843
  justifyContent: "center",
1435
1844
  variant: action.variant || "default",
1845
+ paddingTop: "7px",
1846
+ paddingBottom: "7px",
1436
1847
  children: action.label
1437
1848
  }
1438
1849
  ),
@@ -1497,9 +1908,9 @@ const DocumentActionsMenu = ({
1497
1908
  disabled: isDisabled,
1498
1909
  size: "S",
1499
1910
  endIcon: null,
1500
- paddingTop: "7px",
1501
- paddingLeft: "9px",
1502
- paddingRight: "9px",
1911
+ paddingTop: "4px",
1912
+ paddingLeft: "7px",
1913
+ paddingRight: "7px",
1503
1914
  variant,
1504
1915
  children: [
1505
1916
  /* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
@@ -1510,7 +1921,7 @@ const DocumentActionsMenu = ({
1510
1921
  ]
1511
1922
  }
1512
1923
  ),
1513
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { top: "4px", maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1924
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1514
1925
  actions2.map((action) => {
1515
1926
  return /* @__PURE__ */ jsxRuntime.jsx(
1516
1927
  designSystem.Menu.Item,
@@ -1519,14 +1930,29 @@ const DocumentActionsMenu = ({
1519
1930
  onSelect: handleClick(action),
1520
1931
  display: "block",
1521
1932
  children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: [
1522
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { color: convertActionVariantToColor(action.variant), gap: 2, tag: "span", children: [
1523
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "span", color: convertActionVariantToIconColor(action.variant), children: action.icon }),
1524
- action.label
1525
- ] }),
1526
- action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsxRuntime.jsx(
1933
+ /* @__PURE__ */ jsxRuntime.jsxs(
1527
1934
  designSystem.Flex,
1528
1935
  {
1529
- alignItems: "center",
1936
+ color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
1937
+ gap: 2,
1938
+ tag: "span",
1939
+ children: [
1940
+ /* @__PURE__ */ jsxRuntime.jsx(
1941
+ designSystem.Flex,
1942
+ {
1943
+ tag: "span",
1944
+ color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
1945
+ children: action.icon
1946
+ }
1947
+ ),
1948
+ action.label
1949
+ ]
1950
+ }
1951
+ ),
1952
+ action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsxRuntime.jsx(
1953
+ designSystem.Flex,
1954
+ {
1955
+ alignItems: "center",
1530
1956
  background: "alternative100",
1531
1957
  borderStyle: "solid",
1532
1958
  borderColor: "alternative200",
@@ -1619,11 +2045,11 @@ const DocumentActionConfirmDialog = ({
1619
2045
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
1620
2046
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
1621
2047
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
1622
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
2048
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
1623
2049
  id: "app.components.Button.cancel",
1624
2050
  defaultMessage: "Cancel"
1625
2051
  }) }) }),
1626
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
2052
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
1627
2053
  id: "app.components.Button.confirm",
1628
2054
  defaultMessage: "Confirm"
1629
2055
  }) })
@@ -1646,10 +2072,22 @@ const DocumentActionModal = ({
1646
2072
  };
1647
2073
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
1648
2074
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title }) }),
1649
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content }),
1650
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Footer, { children: typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer })
2075
+ typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: Content }),
2076
+ typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
1651
2077
  ] }) });
1652
2078
  };
2079
+ const transformData = (data) => {
2080
+ if (Array.isArray(data)) {
2081
+ return data.map(transformData);
2082
+ }
2083
+ if (typeof data === "object" && data !== null) {
2084
+ if ("apiData" in data) {
2085
+ return data.apiData;
2086
+ }
2087
+ return mapValues__default.default(transformData)(data);
2088
+ }
2089
+ return data;
2090
+ };
1653
2091
  const PublishAction$1 = ({
1654
2092
  activeTab,
1655
2093
  documentId,
@@ -1662,12 +2100,10 @@ const PublishAction$1 = ({
1662
2100
  const navigate = reactRouterDom.useNavigate();
1663
2101
  const { toggleNotification } = strapiAdmin.useNotification();
1664
2102
  const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
2103
+ const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
1665
2104
  const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
1666
2105
  const { formatMessage } = reactIntl.useIntl();
1667
- const { canPublish, canCreate, canUpdate } = useDocumentRBAC(
1668
- "PublishAction",
1669
- ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
1670
- );
2106
+ const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
1671
2107
  const { publish } = useDocumentActions();
1672
2108
  const [
1673
2109
  countDraftRelations,
@@ -1719,24 +2155,25 @@ const PublishAction$1 = ({
1719
2155
  }
1720
2156
  }, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
1721
2157
  React__namespace.useEffect(() => {
1722
- if (documentId) {
1723
- const fetchDraftRelationsCount = async () => {
1724
- const { data, error } = await countDraftRelations({
1725
- collectionType,
1726
- model,
1727
- documentId,
1728
- params
1729
- });
1730
- if (error) {
1731
- throw error;
1732
- }
1733
- if (data) {
1734
- setServerCountOfDraftRelations(data.data);
1735
- }
1736
- };
1737
- fetchDraftRelationsCount();
2158
+ if (!document || !document.documentId || isListView) {
2159
+ return;
1738
2160
  }
1739
- }, [documentId, countDraftRelations, collectionType, model, params]);
2161
+ const fetchDraftRelationsCount = async () => {
2162
+ const { data, error } = await countDraftRelations({
2163
+ collectionType,
2164
+ model,
2165
+ documentId,
2166
+ params
2167
+ });
2168
+ if (error) {
2169
+ throw error;
2170
+ }
2171
+ if (data) {
2172
+ setServerCountOfDraftRelations(data.data);
2173
+ }
2174
+ };
2175
+ fetchDraftRelationsCount();
2176
+ }, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
1740
2177
  const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
1741
2178
  if (!schema?.options?.draftAndPublish) {
1742
2179
  return null;
@@ -1744,7 +2181,9 @@ const PublishAction$1 = ({
1744
2181
  const performPublish = async () => {
1745
2182
  setSubmitting(true);
1746
2183
  try {
1747
- const { errors } = await validate();
2184
+ const { errors } = await validate(true, {
2185
+ status: "published"
2186
+ });
1748
2187
  if (errors) {
1749
2188
  toggleNotification({
1750
2189
  type: "danger",
@@ -1762,7 +2201,7 @@ const PublishAction$1 = ({
1762
2201
  documentId,
1763
2202
  params
1764
2203
  },
1765
- formValues
2204
+ transformData(formValues)
1766
2205
  );
1767
2206
  if ("data" in res && collectionType !== SINGLE_TYPES) {
1768
2207
  navigate({
@@ -1777,7 +2216,8 @@ const PublishAction$1 = ({
1777
2216
  }
1778
2217
  };
1779
2218
  const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
1780
- const hasDraftRelations = totalDraftRelations > 0;
2219
+ const enableDraftRelationsCount = false;
2220
+ const hasDraftRelations = enableDraftRelationsCount;
1781
2221
  return {
1782
2222
  /**
1783
2223
  * Disabled when:
@@ -1787,18 +2227,13 @@ const PublishAction$1 = ({
1787
2227
  * - the document is already published & not modified
1788
2228
  * - the document is being created & not modified
1789
2229
  * - the user doesn't have the permission to publish
1790
- * - the user doesn't have the permission to create a new document
1791
- * - the user doesn't have the permission to update the document
1792
2230
  */
1793
- disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish || Boolean(!document?.documentId && !canCreate || document?.documentId && !canUpdate),
2231
+ disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
1794
2232
  label: formatMessage({
1795
2233
  id: "app.utils.publish",
1796
2234
  defaultMessage: "Publish"
1797
2235
  }),
1798
2236
  onClick: async () => {
1799
- if (hasDraftRelations) {
1800
- return;
1801
- }
1802
2237
  await performPublish();
1803
2238
  },
1804
2239
  dialog: hasDraftRelations ? {
@@ -1837,10 +2272,6 @@ const UpdateAction = ({
1837
2272
  const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
1838
2273
  const isCloning = cloneMatch !== null;
1839
2274
  const { formatMessage } = reactIntl.useIntl();
1840
- const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
1841
- canCreate: canCreate2,
1842
- canUpdate: canUpdate2
1843
- }));
1844
2275
  const { create, update, clone } = useDocumentActions();
1845
2276
  const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
1846
2277
  const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
@@ -1857,10 +2288,8 @@ const UpdateAction = ({
1857
2288
  * - the form is submitting
1858
2289
  * - the document is not modified & we're not cloning (you can save a clone entity straight away)
1859
2290
  * - the active tab is the published tab
1860
- * - the user doesn't have the permission to create a new document
1861
- * - the user doesn't have the permission to update the document
1862
2291
  */
1863
- disabled: isSubmitting || !modified && !isCloning || activeTab === "published" || Boolean(!documentId && !canCreate || documentId && !canUpdate),
2292
+ disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
1864
2293
  label: formatMessage({
1865
2294
  id: "content-manager.containers.Edit.save",
1866
2295
  defaultMessage: "Save"
@@ -1868,7 +2297,9 @@ const UpdateAction = ({
1868
2297
  onClick: async () => {
1869
2298
  setSubmitting(true);
1870
2299
  try {
1871
- const { errors } = await validate();
2300
+ const { errors } = await validate(true, {
2301
+ status: "draft"
2302
+ });
1872
2303
  if (errors) {
1873
2304
  toggleNotification({
1874
2305
  type: "danger",
@@ -1886,13 +2317,16 @@ const UpdateAction = ({
1886
2317
  documentId: cloneMatch.params.origin,
1887
2318
  params
1888
2319
  },
1889
- document
2320
+ transformData(document)
1890
2321
  );
1891
2322
  if ("data" in res) {
1892
- navigate({
1893
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1894
- search: rawQuery
1895
- });
2323
+ navigate(
2324
+ {
2325
+ pathname: `../${res.data.documentId}`,
2326
+ search: rawQuery
2327
+ },
2328
+ { relative: "path" }
2329
+ );
1896
2330
  } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1897
2331
  setErrors(formatValidationErrors(res.error));
1898
2332
  }
@@ -1904,7 +2338,7 @@ const UpdateAction = ({
1904
2338
  documentId,
1905
2339
  params
1906
2340
  },
1907
- document
2341
+ transformData(document)
1908
2342
  );
1909
2343
  if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1910
2344
  setErrors(formatValidationErrors(res.error));
@@ -1917,15 +2351,15 @@ const UpdateAction = ({
1917
2351
  model,
1918
2352
  params
1919
2353
  },
1920
- document
2354
+ transformData(document)
1921
2355
  );
1922
2356
  if ("data" in res && collectionType !== SINGLE_TYPES) {
1923
2357
  navigate(
1924
2358
  {
1925
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
2359
+ pathname: `../${res.data.documentId}`,
1926
2360
  search: rawQuery
1927
2361
  },
1928
- { replace: true }
2362
+ { replace: true, relative: "path" }
1929
2363
  );
1930
2364
  } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1931
2365
  setErrors(formatValidationErrors(res.error));
@@ -1970,7 +2404,7 @@ const UnpublishAction$1 = ({
1970
2404
  id: "app.utils.unpublish",
1971
2405
  defaultMessage: "Unpublish"
1972
2406
  }),
1973
- icon: /* @__PURE__ */ jsxRuntime.jsx(StyledCrossCircle, {}),
2407
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
1974
2408
  onClick: async () => {
1975
2409
  if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
1976
2410
  if (!documentId) {
@@ -2082,7 +2516,7 @@ const DiscardAction = ({
2082
2516
  id: "content-manager.actions.discard.label",
2083
2517
  defaultMessage: "Discard changes"
2084
2518
  }),
2085
- icon: /* @__PURE__ */ jsxRuntime.jsx(StyledCrossCircle, {}),
2519
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
2086
2520
  position: ["panel", "table-row"],
2087
2521
  variant: "danger",
2088
2522
  dialog: {
@@ -2110,11 +2544,6 @@ const DiscardAction = ({
2110
2544
  };
2111
2545
  };
2112
2546
  DiscardAction.type = "discard";
2113
- const StyledCrossCircle = styledComponents.styled(Icons.CrossCircle)`
2114
- path {
2115
- fill: currentColor;
2116
- }
2117
- `;
2118
2547
  const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
2119
2548
  const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
2120
2549
  const RelativeTime = React__namespace.forwardRef(
@@ -2162,7 +2591,7 @@ const getDisplayName = ({
2162
2591
  };
2163
2592
  const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2164
2593
  const DocumentStatus = ({ status = "draft", ...restProps }) => {
2165
- const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
2594
+ const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
2166
2595
  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) }) });
2167
2596
  };
2168
2597
  const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
@@ -2261,12 +2690,12 @@ const Information = ({ activeTab }) => {
2261
2690
  isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2262
2691
  label: formatMessage({
2263
2692
  id: "content-manager.containers.edit.information.last-published.label",
2264
- defaultMessage: "Last published"
2693
+ defaultMessage: "Published"
2265
2694
  }),
2266
2695
  value: formatMessage(
2267
2696
  {
2268
2697
  id: "content-manager.containers.edit.information.last-published.value",
2269
- defaultMessage: `Published {time}{isAnonymous, select, true {} other { by {author}}}`
2698
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2270
2699
  },
2271
2700
  {
2272
2701
  time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
@@ -2279,12 +2708,12 @@ const Information = ({ activeTab }) => {
2279
2708
  isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2280
2709
  label: formatMessage({
2281
2710
  id: "content-manager.containers.edit.information.last-draft.label",
2282
- defaultMessage: "Last draft"
2711
+ defaultMessage: "Updated"
2283
2712
  }),
2284
2713
  value: formatMessage(
2285
2714
  {
2286
2715
  id: "content-manager.containers.edit.information.last-draft.value",
2287
- defaultMessage: `Modified {time}{isAnonymous, select, true {} other { by {author}}}`
2716
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2288
2717
  },
2289
2718
  {
2290
2719
  time: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2302,12 +2731,12 @@ const Information = ({ activeTab }) => {
2302
2731
  isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2303
2732
  label: formatMessage({
2304
2733
  id: "content-manager.containers.edit.information.document.label",
2305
- defaultMessage: "Document"
2734
+ defaultMessage: "Created"
2306
2735
  }),
2307
2736
  value: formatMessage(
2308
2737
  {
2309
2738
  id: "content-manager.containers.edit.information.document.value",
2310
- defaultMessage: `Created {time}{isAnonymous, select, true {} other { by {author}}}`
2739
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2311
2740
  },
2312
2741
  {
2313
2742
  time: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2345,25 +2774,77 @@ const Information = ({ activeTab }) => {
2345
2774
  );
2346
2775
  };
2347
2776
  const HeaderActions = ({ actions: actions2 }) => {
2348
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: actions2.map((action) => {
2349
- if ("options" in action) {
2777
+ const [dialogId, setDialogId] = React__namespace.useState(null);
2778
+ const handleClick = (action) => async (e) => {
2779
+ if (!("options" in action)) {
2780
+ const { onClick = () => false, dialog, id } = action;
2781
+ const muteDialog = await onClick(e);
2782
+ if (dialog && !muteDialog) {
2783
+ e.preventDefault();
2784
+ setDialogId(id);
2785
+ }
2786
+ }
2787
+ };
2788
+ const handleClose = () => {
2789
+ setDialogId(null);
2790
+ };
2791
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, children: actions2.map((action) => {
2792
+ if (action.options) {
2350
2793
  return /* @__PURE__ */ jsxRuntime.jsx(
2351
2794
  designSystem.SingleSelect,
2352
2795
  {
2353
2796
  size: "S",
2354
- disabled: action.disabled,
2355
- "aria-label": action.label,
2356
2797
  onChange: action.onSelect,
2357
- value: action.value,
2798
+ "aria-label": action.label,
2799
+ ...action,
2358
2800
  children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
2359
2801
  },
2360
2802
  action.id
2361
2803
  );
2362
2804
  } else {
2363
- return null;
2805
+ if (action.type === "icon") {
2806
+ return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
2807
+ /* @__PURE__ */ jsxRuntime.jsx(
2808
+ designSystem.IconButton,
2809
+ {
2810
+ disabled: action.disabled,
2811
+ label: action.label,
2812
+ size: "S",
2813
+ onClick: handleClick(action),
2814
+ children: action.icon
2815
+ }
2816
+ ),
2817
+ action.dialog ? /* @__PURE__ */ jsxRuntime.jsx(
2818
+ HeaderActionDialog,
2819
+ {
2820
+ ...action.dialog,
2821
+ isOpen: dialogId === action.id,
2822
+ onClose: handleClose
2823
+ }
2824
+ ) : null
2825
+ ] }, action.id);
2826
+ }
2364
2827
  }
2365
2828
  }) });
2366
2829
  };
2830
+ const HeaderActionDialog = ({
2831
+ onClose,
2832
+ onCancel,
2833
+ title,
2834
+ content: Content,
2835
+ isOpen
2836
+ }) => {
2837
+ const handleClose = async () => {
2838
+ if (onCancel) {
2839
+ await onCancel();
2840
+ }
2841
+ onClose();
2842
+ };
2843
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
2844
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
2845
+ typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content
2846
+ ] }) });
2847
+ };
2367
2848
  const ConfigureTheViewAction = ({ collectionType, model }) => {
2368
2849
  const navigate = reactRouterDom.useNavigate();
2369
2850
  const { formatMessage } = reactIntl.useIntl();
@@ -2388,480 +2869,182 @@ const EditTheModelAction = ({ model }) => {
2388
2869
  id: "content-manager.link-to-ctb",
2389
2870
  defaultMessage: "Edit the model"
2390
2871
  }),
2391
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {}),
2392
- onClick: () => {
2393
- navigate(`/plugins/content-type-builder/content-types/${model}`);
2394
- },
2395
- position: "header"
2396
- };
2397
- };
2398
- EditTheModelAction.type = "edit-the-model";
2399
- const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2400
- const navigate = reactRouterDom.useNavigate();
2401
- const { formatMessage } = reactIntl.useIntl();
2402
- const listViewPathMatch = reactRouterDom.useMatch(LIST_PATH);
2403
- const canDelete = useDocumentRBAC("DeleteAction", (state) => state.canDelete);
2404
- const { delete: deleteAction } = useDocumentActions();
2405
- const { toggleNotification } = strapiAdmin.useNotification();
2406
- const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
2407
- return {
2408
- disabled: !canDelete || !document,
2409
- label: formatMessage({
2410
- id: "content-manager.actions.delete.label",
2411
- defaultMessage: "Delete document"
2412
- }),
2413
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
2414
- dialog: {
2415
- type: "dialog",
2416
- title: formatMessage({
2417
- id: "app.components.ConfirmDialog.title",
2418
- defaultMessage: "Confirmation"
2419
- }),
2420
- content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
2421
- /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
2422
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
2423
- id: "content-manager.actions.delete.dialog.body",
2424
- defaultMessage: "Are you sure?"
2425
- }) })
2426
- ] }),
2427
- onConfirm: async () => {
2428
- if (!listViewPathMatch) {
2429
- setSubmitting(true);
2430
- }
2431
- try {
2432
- if (!documentId && collectionType !== SINGLE_TYPES) {
2433
- console.error(
2434
- "You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue."
2435
- );
2436
- toggleNotification({
2437
- message: formatMessage({
2438
- id: "content-manager.actions.delete.error",
2439
- defaultMessage: "An error occurred while trying to delete the document."
2440
- }),
2441
- type: "danger"
2442
- });
2443
- return;
2444
- }
2445
- const res = await deleteAction({
2446
- documentId,
2447
- model,
2448
- collectionType,
2449
- params: {
2450
- locale: "*"
2451
- }
2452
- });
2453
- if (!("error" in res)) {
2454
- navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
2455
- }
2456
- } finally {
2457
- if (!listViewPathMatch) {
2458
- setSubmitting(false);
2459
- }
2460
- }
2461
- }
2462
- },
2463
- variant: "danger",
2464
- position: ["header", "table-row"]
2465
- };
2466
- };
2467
- DeleteAction$1.type = "delete";
2468
- const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2469
- const Panels = () => {
2470
- const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2471
- const [
2472
- {
2473
- query: { status }
2474
- }
2475
- ] = strapiAdmin.useQueryParams({
2476
- status: "draft"
2477
- });
2478
- const { model, id, document, meta, collectionType } = useDoc();
2479
- const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
2480
- const props = {
2481
- activeTab: status,
2482
- model,
2483
- documentId: id,
2484
- document: isCloning ? void 0 : document,
2485
- meta: isCloning ? void 0 : meta,
2486
- collectionType
2487
- };
2488
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
2489
- strapiAdmin.DescriptionComponentRenderer,
2490
- {
2491
- props,
2492
- descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2493
- children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
2494
- }
2495
- ) });
2496
- };
2497
- const ActionsPanel = () => {
2498
- const { formatMessage } = reactIntl.useIntl();
2499
- return {
2500
- title: formatMessage({
2501
- id: "content-manager.containers.edit.panels.default.title",
2502
- defaultMessage: "Document"
2503
- }),
2504
- content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
2505
- };
2506
- };
2507
- ActionsPanel.type = "actions";
2508
- const ActionsPanelContent = () => {
2509
- const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2510
- const [
2511
- {
2512
- query: { status = "draft" }
2513
- }
2514
- ] = strapiAdmin.useQueryParams();
2515
- const { model, id, document, meta, collectionType } = useDoc();
2516
- const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
2517
- const props = {
2518
- activeTab: status,
2519
- model,
2520
- documentId: id,
2521
- document: isCloning ? void 0 : document,
2522
- meta: isCloning ? void 0 : meta,
2523
- collectionType
2524
- };
2525
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
2526
- /* @__PURE__ */ jsxRuntime.jsx(
2527
- strapiAdmin.DescriptionComponentRenderer,
2528
- {
2529
- props,
2530
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
2531
- children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
2532
- }
2533
- ),
2534
- /* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
2535
- ] });
2536
- };
2537
- const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
2538
- return /* @__PURE__ */ jsxRuntime.jsxs(
2539
- designSystem.Flex,
2540
- {
2541
- ref,
2542
- tag: "aside",
2543
- "aria-labelledby": "additional-information",
2544
- background: "neutral0",
2545
- borderColor: "neutral150",
2546
- hasRadius: true,
2547
- paddingBottom: 4,
2548
- paddingLeft: 4,
2549
- paddingRight: 4,
2550
- paddingTop: 4,
2551
- shadow: "tableShadow",
2552
- gap: 3,
2553
- direction: "column",
2554
- justifyContent: "stretch",
2555
- alignItems: "flex-start",
2556
- children: [
2557
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
2558
- children
2559
- ]
2560
- }
2561
- );
2562
- });
2563
- const HOOKS = {
2564
- /**
2565
- * Hook that allows to mutate the displayed headers of the list view table
2566
- * @constant
2567
- * @type {string}
2568
- */
2569
- INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
2570
- /**
2571
- * Hook that allows to mutate the CM's collection types links pre-set filters
2572
- * @constant
2573
- * @type {string}
2574
- */
2575
- MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
2576
- /**
2577
- * Hook that allows to mutate the CM's edit view layout
2578
- * @constant
2579
- * @type {string}
2580
- */
2581
- MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
2582
- /**
2583
- * Hook that allows to mutate the CM's single types links pre-set filters
2584
- * @constant
2585
- * @type {string}
2586
- */
2587
- MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
2588
- };
2589
- const contentTypesApi = contentManagerApi.injectEndpoints({
2590
- endpoints: (builder) => ({
2591
- getContentTypeConfiguration: builder.query({
2592
- query: (uid) => ({
2593
- url: `/content-manager/content-types/${uid}/configuration`,
2594
- method: "GET"
2595
- }),
2596
- transformResponse: (response) => response.data,
2597
- providesTags: (_result, _error, uid) => [
2598
- { type: "ContentTypesConfiguration", id: uid },
2599
- { type: "ContentTypeSettings", id: "LIST" }
2600
- ]
2601
- }),
2602
- getAllContentTypeSettings: builder.query({
2603
- query: () => "/content-manager/content-types-settings",
2604
- transformResponse: (response) => response.data,
2605
- providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
2606
- }),
2607
- updateContentTypeConfiguration: builder.mutation({
2608
- query: ({ uid, ...body }) => ({
2609
- url: `/content-manager/content-types/${uid}/configuration`,
2610
- method: "PUT",
2611
- data: body
2612
- }),
2613
- transformResponse: (response) => response.data,
2614
- invalidatesTags: (_result, _error, { uid }) => [
2615
- { type: "ContentTypesConfiguration", id: uid },
2616
- { type: "ContentTypeSettings", id: "LIST" },
2617
- // Is this necessary?
2618
- { type: "InitialData" }
2619
- ]
2620
- })
2621
- })
2622
- });
2623
- const {
2624
- useGetContentTypeConfigurationQuery,
2625
- useGetAllContentTypeSettingsQuery,
2626
- useUpdateContentTypeConfigurationMutation
2627
- } = contentTypesApi;
2628
- const checkIfAttributeIsDisplayable = (attribute) => {
2629
- const { type } = attribute;
2630
- if (type === "relation") {
2631
- return !attribute.relation.toLowerCase().includes("morph");
2632
- }
2633
- return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
2634
- };
2635
- const getMainField = (attribute, mainFieldName, { schemas, components }) => {
2636
- if (!mainFieldName) {
2637
- return void 0;
2638
- }
2639
- const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
2640
- // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
2641
- schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
2642
- );
2643
- return {
2644
- name: mainFieldName,
2645
- type: mainFieldType ?? "string"
2646
- };
2647
- };
2648
- const DEFAULT_SETTINGS = {
2649
- bulkable: false,
2650
- filterable: false,
2651
- searchable: false,
2652
- pagination: false,
2653
- defaultSortBy: "",
2654
- defaultSortOrder: "asc",
2655
- mainField: "id",
2656
- pageSize: 10
2657
- };
2658
- const useDocumentLayout = (model) => {
2659
- const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
2660
- const [{ query }] = strapiAdmin.useQueryParams();
2661
- const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
2662
- const { toggleNotification } = strapiAdmin.useNotification();
2663
- const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
2664
- const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
2665
- const {
2666
- data,
2667
- isLoading: isLoadingConfigs,
2668
- error,
2669
- isFetching: isFetchingConfigs
2670
- } = useGetContentTypeConfigurationQuery(model);
2671
- const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
2672
- React__namespace.useEffect(() => {
2673
- if (error) {
2674
- toggleNotification({
2675
- type: "danger",
2676
- message: formatAPIError(error)
2677
- });
2678
- }
2679
- }, [error, formatAPIError, toggleNotification]);
2680
- const editLayout = React__namespace.useMemo(
2681
- () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
2682
- layout: [],
2683
- components: {},
2684
- metadatas: {},
2685
- options: {},
2686
- settings: DEFAULT_SETTINGS
2687
- },
2688
- [data, isLoading, schemas, schema, components]
2689
- );
2690
- const listLayout = React__namespace.useMemo(() => {
2691
- return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
2692
- layout: [],
2693
- metadatas: {},
2694
- options: {},
2695
- settings: DEFAULT_SETTINGS
2696
- };
2697
- }, [data, isLoading, schemas, schema, components]);
2698
- const { layout: edit } = React__namespace.useMemo(
2699
- () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
2700
- layout: editLayout,
2701
- query
2702
- }),
2703
- [editLayout, query, runHookWaterfall]
2704
- );
2705
- return {
2706
- error,
2707
- isLoading,
2708
- edit,
2709
- list: listLayout
2710
- };
2711
- };
2712
- const useDocLayout = () => {
2713
- const { model } = useDoc();
2714
- return useDocumentLayout(model);
2715
- };
2716
- const formatEditLayout = (data, {
2717
- schemas,
2718
- schema,
2719
- components
2720
- }) => {
2721
- let currentPanelIndex = 0;
2722
- const panelledEditAttributes = convertEditLayoutToFieldLayouts(
2723
- data.contentType.layouts.edit,
2724
- schema?.attributes,
2725
- data.contentType.metadatas,
2726
- { configurations: data.components, schemas: components },
2727
- schemas
2728
- ).reduce((panels, row) => {
2729
- if (row.some((field) => field.type === "dynamiczone")) {
2730
- panels.push([row]);
2731
- currentPanelIndex += 2;
2732
- } else {
2733
- if (!panels[currentPanelIndex]) {
2734
- panels.push([]);
2735
- }
2736
- panels[currentPanelIndex].push(row);
2737
- }
2738
- return panels;
2739
- }, []);
2740
- const componentEditAttributes = Object.entries(data.components).reduce(
2741
- (acc, [uid, configuration]) => {
2742
- acc[uid] = {
2743
- layout: convertEditLayoutToFieldLayouts(
2744
- configuration.layouts.edit,
2745
- components[uid].attributes,
2746
- configuration.metadatas
2747
- ),
2748
- settings: {
2749
- ...configuration.settings,
2750
- icon: components[uid].info.icon,
2751
- displayName: components[uid].info.displayName
2752
- }
2753
- };
2754
- return acc;
2755
- },
2756
- {}
2757
- );
2758
- const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
2759
- (acc, [attribute, metadata]) => {
2760
- return {
2761
- ...acc,
2762
- [attribute]: metadata.edit
2763
- };
2872
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {}),
2873
+ onClick: () => {
2874
+ navigate(`/plugins/content-type-builder/content-types/${model}`);
2764
2875
  },
2765
- {}
2766
- );
2876
+ position: "header"
2877
+ };
2878
+ };
2879
+ EditTheModelAction.type = "edit-the-model";
2880
+ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2881
+ const navigate = reactRouterDom.useNavigate();
2882
+ const { formatMessage } = reactIntl.useIntl();
2883
+ const listViewPathMatch = reactRouterDom.useMatch(LIST_PATH);
2884
+ const canDelete = useDocumentRBAC("DeleteAction", (state) => state.canDelete);
2885
+ const { delete: deleteAction } = useDocumentActions();
2886
+ const { toggleNotification } = strapiAdmin.useNotification();
2887
+ const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
2888
+ const isLocalized = document?.locale != null;
2767
2889
  return {
2768
- layout: panelledEditAttributes,
2769
- components: componentEditAttributes,
2770
- metadatas: editMetadatas,
2771
- settings: {
2772
- ...data.contentType.settings,
2773
- displayName: schema?.info.displayName
2890
+ disabled: !canDelete || !document,
2891
+ label: formatMessage(
2892
+ {
2893
+ id: "content-manager.actions.delete.label",
2894
+ defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
2895
+ },
2896
+ { isLocalized }
2897
+ ),
2898
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
2899
+ dialog: {
2900
+ type: "dialog",
2901
+ title: formatMessage({
2902
+ id: "app.components.ConfirmDialog.title",
2903
+ defaultMessage: "Confirmation"
2904
+ }),
2905
+ content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
2906
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
2907
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
2908
+ id: "content-manager.actions.delete.dialog.body",
2909
+ defaultMessage: "Are you sure?"
2910
+ }) })
2911
+ ] }),
2912
+ onConfirm: async () => {
2913
+ if (!listViewPathMatch) {
2914
+ setSubmitting(true);
2915
+ }
2916
+ try {
2917
+ if (!documentId && collectionType !== SINGLE_TYPES) {
2918
+ console.error(
2919
+ "You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue."
2920
+ );
2921
+ toggleNotification({
2922
+ message: formatMessage({
2923
+ id: "content-manager.actions.delete.error",
2924
+ defaultMessage: "An error occurred while trying to delete the document."
2925
+ }),
2926
+ type: "danger"
2927
+ });
2928
+ return;
2929
+ }
2930
+ const res = await deleteAction({
2931
+ documentId,
2932
+ model,
2933
+ collectionType,
2934
+ params: {
2935
+ locale: "*"
2936
+ }
2937
+ });
2938
+ if (!("error" in res)) {
2939
+ navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
2940
+ }
2941
+ } finally {
2942
+ if (!listViewPathMatch) {
2943
+ setSubmitting(false);
2944
+ }
2945
+ }
2946
+ }
2774
2947
  },
2775
- options: {
2776
- ...schema?.options,
2777
- ...schema?.pluginOptions,
2778
- ...data.contentType.options
2779
- }
2948
+ variant: "danger",
2949
+ position: ["header", "table-row"]
2780
2950
  };
2781
2951
  };
2782
- const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
2783
- return rows.map(
2784
- (row) => row.map((field) => {
2785
- const attribute = attributes[field.name];
2786
- if (!attribute) {
2787
- return null;
2788
- }
2789
- const { edit: metadata } = metadatas[field.name];
2790
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2791
- return {
2792
- attribute,
2793
- disabled: !metadata.editable,
2794
- hint: metadata.description,
2795
- label: metadata.label ?? "",
2796
- name: field.name,
2797
- // @ts-expect-error – mainField does exist on the metadata for a relation.
2798
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2799
- schemas,
2800
- components: components?.schemas ?? {}
2801
- }),
2802
- placeholder: metadata.placeholder ?? "",
2803
- required: attribute.required ?? false,
2804
- size: field.size,
2805
- unique: "unique" in attribute ? attribute.unique : false,
2806
- visible: metadata.visible ?? true,
2807
- type: attribute.type
2808
- };
2809
- }).filter((field) => field !== null)
2810
- );
2952
+ DeleteAction$1.type = "delete";
2953
+ const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2954
+ const Panels = () => {
2955
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2956
+ const [
2957
+ {
2958
+ query: { status }
2959
+ }
2960
+ ] = strapiAdmin.useQueryParams({
2961
+ status: "draft"
2962
+ });
2963
+ const { model, id, document, meta, collectionType } = useDoc();
2964
+ const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
2965
+ const props = {
2966
+ activeTab: status,
2967
+ model,
2968
+ documentId: id,
2969
+ document: isCloning ? void 0 : document,
2970
+ meta: isCloning ? void 0 : meta,
2971
+ collectionType
2972
+ };
2973
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
2974
+ strapiAdmin.DescriptionComponentRenderer,
2975
+ {
2976
+ props,
2977
+ descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2978
+ children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
2979
+ }
2980
+ ) });
2811
2981
  };
2812
- const formatListLayout = (data, {
2813
- schemas,
2814
- schema,
2815
- components
2816
- }) => {
2817
- const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
2818
- (acc, [attribute, metadata]) => {
2819
- return {
2820
- ...acc,
2821
- [attribute]: metadata.list
2822
- };
2823
- },
2824
- {}
2825
- );
2826
- const listAttributes = convertListLayoutToFieldLayouts(
2827
- data.contentType.layouts.list,
2828
- schema?.attributes,
2829
- listMetadatas,
2830
- { configurations: data.components, schemas: components },
2831
- schemas
2832
- );
2982
+ const ActionsPanel = () => {
2983
+ const { formatMessage } = reactIntl.useIntl();
2833
2984
  return {
2834
- layout: listAttributes,
2835
- settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
2836
- metadatas: listMetadatas,
2837
- options: {
2838
- ...schema?.options,
2839
- ...schema?.pluginOptions,
2840
- ...data.contentType.options
2841
- }
2985
+ title: formatMessage({
2986
+ id: "content-manager.containers.edit.panels.default.title",
2987
+ defaultMessage: "Entry"
2988
+ }),
2989
+ content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
2842
2990
  };
2843
2991
  };
2844
- const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
2845
- return columns.map((name) => {
2846
- const attribute = attributes[name];
2847
- if (!attribute) {
2848
- return null;
2992
+ ActionsPanel.type = "actions";
2993
+ const ActionsPanelContent = () => {
2994
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2995
+ const [
2996
+ {
2997
+ query: { status = "draft" }
2849
2998
  }
2850
- const metadata = metadatas[name];
2851
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2852
- return {
2853
- attribute,
2854
- label: metadata.label ?? "",
2855
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2856
- schemas,
2857
- components: components?.schemas ?? {}
2858
- }),
2859
- name,
2860
- searchable: metadata.searchable ?? true,
2861
- sortable: metadata.sortable ?? true
2862
- };
2863
- }).filter((field) => field !== null);
2999
+ ] = strapiAdmin.useQueryParams();
3000
+ const { model, id, document, meta, collectionType } = useDoc();
3001
+ const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
3002
+ const props = {
3003
+ activeTab: status,
3004
+ model,
3005
+ documentId: id,
3006
+ document: isCloning ? void 0 : document,
3007
+ meta: isCloning ? void 0 : meta,
3008
+ collectionType
3009
+ };
3010
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
3011
+ /* @__PURE__ */ jsxRuntime.jsx(
3012
+ strapiAdmin.DescriptionComponentRenderer,
3013
+ {
3014
+ props,
3015
+ descriptions: plugins["content-manager"].apis.getDocumentActions(),
3016
+ children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
3017
+ }
3018
+ ),
3019
+ /* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
3020
+ ] });
2864
3021
  };
3022
+ const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
3023
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3024
+ designSystem.Flex,
3025
+ {
3026
+ ref,
3027
+ tag: "aside",
3028
+ "aria-labelledby": "additional-information",
3029
+ background: "neutral0",
3030
+ borderColor: "neutral150",
3031
+ hasRadius: true,
3032
+ paddingBottom: 4,
3033
+ paddingLeft: 4,
3034
+ paddingRight: 4,
3035
+ paddingTop: 4,
3036
+ shadow: "tableShadow",
3037
+ gap: 3,
3038
+ direction: "column",
3039
+ justifyContent: "stretch",
3040
+ alignItems: "flex-start",
3041
+ children: [
3042
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
3043
+ children
3044
+ ]
3045
+ }
3046
+ );
3047
+ });
2865
3048
  const ConfirmBulkActionDialog = ({
2866
3049
  onToggleDialog,
2867
3050
  isOpen = false,
@@ -2900,6 +3083,7 @@ const ConfirmDialogPublishAll = ({
2900
3083
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler(getTranslation);
2901
3084
  const { model, schema } = useDoc();
2902
3085
  const [{ query }] = strapiAdmin.useQueryParams();
3086
+ const enableDraftRelationsCount = false;
2903
3087
  const {
2904
3088
  data: countDraftRelations = 0,
2905
3089
  isLoading,
@@ -2911,7 +3095,7 @@ const ConfirmDialogPublishAll = ({
2911
3095
  locale: query?.plugins?.i18n?.locale
2912
3096
  },
2913
3097
  {
2914
- skip: selectedEntries.length === 0
3098
+ skip: !enableDraftRelationsCount
2915
3099
  }
2916
3100
  );
2917
3101
  React__namespace.useEffect(() => {
@@ -3096,7 +3280,7 @@ const SelectedEntriesTableContent = ({
3096
3280
  status: row.status
3097
3281
  }
3098
3282
  ) }),
3099
- /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
3283
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
3100
3284
  designSystem.IconButton,
3101
3285
  {
3102
3286
  tag: reactRouterDom.Link,
@@ -3119,9 +3303,10 @@ const SelectedEntriesTableContent = ({
3119
3303
  ),
3120
3304
  target: "_blank",
3121
3305
  marginLeft: "auto",
3122
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {})
3306
+ variant: "ghost",
3307
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, { width: "1.6rem", height: "1.6rem" })
3123
3308
  }
3124
- ) })
3309
+ ) }) })
3125
3310
  ] }, row.id)) })
3126
3311
  ] });
3127
3312
  };
@@ -3158,7 +3343,13 @@ const SelectedEntriesModalContent = ({
3158
3343
  );
3159
3344
  const { rows, validationErrors } = React__namespace.useMemo(() => {
3160
3345
  if (data.length > 0 && schema) {
3161
- const validate = createYupSchema(schema.attributes, components);
3346
+ const validate = createYupSchema(
3347
+ schema.attributes,
3348
+ components,
3349
+ // Since this is the "Publish" action, the validation
3350
+ // schema must enforce the rules for published entities
3351
+ { status: "published" }
3352
+ );
3162
3353
  const validationErrors2 = {};
3163
3354
  const rows2 = data.map((entry) => {
3164
3355
  try {
@@ -3508,7 +3699,7 @@ const TableActions = ({ document }) => {
3508
3699
  strapiAdmin.DescriptionComponentRenderer,
3509
3700
  {
3510
3701
  props,
3511
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
3702
+ descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
3512
3703
  children: (actions2) => {
3513
3704
  const tableRowActions = actions2.filter((action) => {
3514
3705
  const positions = Array.isArray(action.position) ? action.position : [action.position];
@@ -3619,7 +3810,7 @@ const CloneAction = ({ model, documentId }) => {
3619
3810
  }),
3620
3811
  content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
3621
3812
  footer: ({ onClose }) => {
3622
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
3813
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
3623
3814
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
3624
3815
  id: "cancel",
3625
3816
  defaultMessage: "Cancel"
@@ -3831,6 +4022,15 @@ const { setInitialData } = actions;
3831
4022
  const reducer = toolkit.combineReducers({
3832
4023
  app: reducer$1
3833
4024
  });
4025
+ const FEATURE_ID = "preview";
4026
+ const previewAdmin = {
4027
+ bootstrap(app) {
4028
+ if (!window.strapi.future.isEnabled(FEATURE_ID)) {
4029
+ return {};
4030
+ }
4031
+ console.log("Bootstrapping preview admin");
4032
+ }
4033
+ };
3834
4034
  const index = {
3835
4035
  register(app) {
3836
4036
  const cm = new ContentManagerPlugin();
@@ -3850,7 +4050,7 @@ const index = {
3850
4050
  app.router.addRoute({
3851
4051
  path: "content-manager/*",
3852
4052
  lazy: async () => {
3853
- const { Layout } = await Promise.resolve().then(() => require("./layout-TPqF2oJ5.js"));
4053
+ const { Layout } = await Promise.resolve().then(() => require("./layout-B33V9Tdu.js"));
3854
4054
  return {
3855
4055
  Component: Layout
3856
4056
  };
@@ -3863,11 +4063,14 @@ const index = {
3863
4063
  if (typeof historyAdmin.bootstrap === "function") {
3864
4064
  historyAdmin.bootstrap(app);
3865
4065
  }
4066
+ if (typeof previewAdmin.bootstrap === "function") {
4067
+ previewAdmin.bootstrap(app);
4068
+ }
3866
4069
  },
3867
4070
  async registerTrads({ locales }) {
3868
4071
  const importedTrads = await Promise.all(
3869
4072
  locales.map((locale) => {
3870
- 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-uOUIxfcQ.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 }) => {
4073
+ 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 }) => {
3871
4074
  return {
3872
4075
  data: prefixPluginTranslations(data, PLUGIN_ID),
3873
4076
  locale
@@ -3885,6 +4088,7 @@ const index = {
3885
4088
  };
3886
4089
  exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
3887
4090
  exports.BulkActionsRenderer = BulkActionsRenderer;
4091
+ exports.CLONE_PATH = CLONE_PATH;
3888
4092
  exports.COLLECTION_TYPES = COLLECTION_TYPES;
3889
4093
  exports.CREATOR_FIELDS = CREATOR_FIELDS;
3890
4094
  exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
@@ -3912,6 +4116,7 @@ exports.getMainField = getMainField;
3912
4116
  exports.getTranslation = getTranslation;
3913
4117
  exports.index = index;
3914
4118
  exports.setInitialData = setInitialData;
4119
+ exports.useContentManagerContext = useContentManagerContext;
3915
4120
  exports.useContentTypeSchema = useContentTypeSchema;
3916
4121
  exports.useDoc = useDoc;
3917
4122
  exports.useDocLayout = useDocLayout;
@@ -3924,4 +4129,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
3924
4129
  exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
3925
4130
  exports.useGetInitialDataQuery = useGetInitialDataQuery;
3926
4131
  exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
3927
- //# sourceMappingURL=index-DyvUPg1a.js.map
4132
+ //# sourceMappingURL=index-CsrCnNa3.js.map