@strapi/content-manager 0.0.0-experimental.62ce06180fe9a772eaeb3d43d238b26644f39f7c → 0.0.0-experimental.779667bd163026468f566293decf331a0246fff9

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 (96) hide show
  1. package/LICENSE +18 -3
  2. package/dist/_chunks/{ComponentConfigurationPage-DErJQEVW.mjs → ComponentConfigurationPage-B1bIXVuX.mjs} +3 -3
  3. package/dist/_chunks/{ComponentConfigurationPage-DErJQEVW.mjs.map → ComponentConfigurationPage-B1bIXVuX.mjs.map} +1 -1
  4. package/dist/_chunks/{ComponentConfigurationPage-Cl7eB3s4.js → ComponentConfigurationPage-Bqgx7Mes.js} +3 -3
  5. package/dist/_chunks/{ComponentConfigurationPage-Cl7eB3s4.js.map → ComponentConfigurationPage-Bqgx7Mes.js.map} +1 -1
  6. package/dist/_chunks/{EditConfigurationPage-CyfFvH6-.js → EditConfigurationPage-BFEwvdMW.js} +3 -3
  7. package/dist/_chunks/{EditConfigurationPage-CyfFvH6-.js.map → EditConfigurationPage-BFEwvdMW.js.map} +1 -1
  8. package/dist/_chunks/{EditConfigurationPage-CBosWqQ7.mjs → EditConfigurationPage-ZO0vOO8q.mjs} +3 -3
  9. package/dist/_chunks/{EditConfigurationPage-CBosWqQ7.mjs.map → EditConfigurationPage-ZO0vOO8q.mjs.map} +1 -1
  10. package/dist/_chunks/{EditViewPage-DxyAOItK.js → EditViewPage-DA95Ha6J.js} +3 -3
  11. package/dist/_chunks/{EditViewPage-DxyAOItK.js.map → EditViewPage-DA95Ha6J.js.map} +1 -1
  12. package/dist/_chunks/{EditViewPage-ClIueJnM.mjs → EditViewPage-DlLEyUL6.mjs} +3 -3
  13. package/dist/_chunks/{EditViewPage-ClIueJnM.mjs.map → EditViewPage-DlLEyUL6.mjs.map} +1 -1
  14. package/dist/_chunks/{Field-C0Y_SR9e.js → Field-CnK8dO8N.js} +343 -51
  15. package/dist/_chunks/Field-CnK8dO8N.js.map +1 -0
  16. package/dist/_chunks/{Field-BZBYmvaf.mjs → Field-Dq7bDnuh.mjs} +344 -52
  17. package/dist/_chunks/Field-Dq7bDnuh.mjs.map +1 -0
  18. package/dist/_chunks/{Form-jwRSC2kV.mjs → Form-B_JE0dbz.mjs} +2 -2
  19. package/dist/_chunks/{Form-jwRSC2kV.mjs.map → Form-B_JE0dbz.mjs.map} +1 -1
  20. package/dist/_chunks/{Form-DwvGnISS.js → Form-BpiR4piS.js} +2 -2
  21. package/dist/_chunks/{Form-DwvGnISS.js.map → Form-BpiR4piS.js.map} +1 -1
  22. package/dist/_chunks/{History-BgzAIj0G.mjs → History-CBNGU7a-.mjs} +27 -12
  23. package/dist/_chunks/History-CBNGU7a-.mjs.map +1 -0
  24. package/dist/_chunks/{History-Cda0Yjzz.js → History-DdIstl8b.js} +27 -12
  25. package/dist/_chunks/History-DdIstl8b.js.map +1 -0
  26. package/dist/_chunks/{ListConfigurationPage-GH55qfoT.mjs → ListConfigurationPage-5dr4qpue.mjs} +8 -6
  27. package/dist/_chunks/ListConfigurationPage-5dr4qpue.mjs.map +1 -0
  28. package/dist/_chunks/{ListConfigurationPage-C29EF97r.js → ListConfigurationPage-DkKRparB.js} +8 -6
  29. package/dist/_chunks/ListConfigurationPage-DkKRparB.js.map +1 -0
  30. package/dist/_chunks/{ListViewPage-QU03PFj1.mjs → ListViewPage-DecLrYV6.mjs} +15 -6
  31. package/dist/_chunks/ListViewPage-DecLrYV6.mjs.map +1 -0
  32. package/dist/_chunks/{ListViewPage-CnRt0UT7.js → ListViewPage-wE0lXqoD.js} +15 -6
  33. package/dist/_chunks/ListViewPage-wE0lXqoD.js.map +1 -0
  34. package/dist/_chunks/{NoContentTypePage-CPs2CnzH.mjs → NoContentTypePage-CiIcfYsd.mjs} +2 -2
  35. package/dist/_chunks/{NoContentTypePage-CPs2CnzH.mjs.map → NoContentTypePage-CiIcfYsd.mjs.map} +1 -1
  36. package/dist/_chunks/{NoContentTypePage-DFDjxByI.js → NoContentTypePage-DEKR6tf9.js} +2 -2
  37. package/dist/_chunks/{NoContentTypePage-DFDjxByI.js.map → NoContentTypePage-DEKR6tf9.js.map} +1 -1
  38. package/dist/_chunks/{NoPermissionsPage-ct58lcY0.mjs → NoPermissionsPage-CM5UD8ee.mjs} +2 -2
  39. package/dist/_chunks/{NoPermissionsPage-ct58lcY0.mjs.map → NoPermissionsPage-CM5UD8ee.mjs.map} +1 -1
  40. package/dist/_chunks/{NoPermissionsPage-BVHI-jv5.js → NoPermissionsPage-DmNfF2Bb.js} +2 -2
  41. package/dist/_chunks/{NoPermissionsPage-BVHI-jv5.js.map → NoPermissionsPage-DmNfF2Bb.js.map} +1 -1
  42. package/dist/_chunks/{Relations-KMf5qEN0.mjs → Relations-Dqz0C1fz.mjs} +3 -3
  43. package/dist/_chunks/Relations-Dqz0C1fz.mjs.map +1 -0
  44. package/dist/_chunks/{Relations-BjpPPCKp.js → Relations-L0xYRoSQ.js} +3 -3
  45. package/dist/_chunks/Relations-L0xYRoSQ.js.map +1 -0
  46. package/dist/_chunks/{en-Ux26r5pl.mjs → en-BrCTWlZv.mjs} +5 -4
  47. package/dist/_chunks/{en-Ux26r5pl.mjs.map → en-BrCTWlZv.mjs.map} +1 -1
  48. package/dist/_chunks/{en-fbKQxLGn.js → en-uOUIxfcQ.js} +5 -4
  49. package/dist/_chunks/{en-fbKQxLGn.js.map → en-uOUIxfcQ.js.map} +1 -1
  50. package/dist/_chunks/{index-6kKXK7y8.mjs → index-BSn97i8U.mjs} +272 -148
  51. package/dist/_chunks/index-BSn97i8U.mjs.map +1 -0
  52. package/dist/_chunks/{index-D9ZwczCV.js → index-DyvUPg1a.js} +258 -134
  53. package/dist/_chunks/index-DyvUPg1a.js.map +1 -0
  54. package/dist/_chunks/{layout-B1Z-9koY.mjs → layout-DPaHUusj.mjs} +8 -8
  55. package/dist/_chunks/layout-DPaHUusj.mjs.map +1 -0
  56. package/dist/_chunks/{layout-BJfBoBiF.js → layout-TPqF2oJ5.js} +7 -7
  57. package/dist/_chunks/layout-TPqF2oJ5.js.map +1 -0
  58. package/dist/_chunks/{relations-CMvjzyU3.js → relations-BWYS9gkn.js} +2 -2
  59. package/dist/_chunks/{relations-CMvjzyU3.js.map → relations-BWYS9gkn.js.map} +1 -1
  60. package/dist/_chunks/{relations-CgZg7Pyx.mjs → relations-Ck7-ecDT.mjs} +2 -2
  61. package/dist/_chunks/{relations-CgZg7Pyx.mjs.map → relations-Ck7-ecDT.mjs.map} +1 -1
  62. package/dist/admin/index.js +1 -1
  63. package/dist/admin/index.mjs +4 -4
  64. package/dist/admin/src/history/index.d.ts +3 -0
  65. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  66. package/dist/admin/src/index.d.ts +1 -0
  67. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +1 -0
  68. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
  69. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
  70. package/dist/admin/src/services/api.d.ts +1 -1
  71. package/dist/admin/src/services/components.d.ts +2 -2
  72. package/dist/admin/src/services/contentTypes.d.ts +3 -3
  73. package/dist/admin/src/services/documents.d.ts +16 -16
  74. package/dist/admin/src/services/init.d.ts +1 -1
  75. package/dist/admin/src/services/relations.d.ts +2 -2
  76. package/dist/admin/src/services/uid.d.ts +3 -3
  77. package/dist/server/index.js +4 -0
  78. package/dist/server/index.js.map +1 -1
  79. package/dist/server/index.mjs +4 -0
  80. package/dist/server/index.mjs.map +1 -1
  81. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  82. package/package.json +6 -6
  83. package/dist/_chunks/Field-BZBYmvaf.mjs.map +0 -1
  84. package/dist/_chunks/Field-C0Y_SR9e.js.map +0 -1
  85. package/dist/_chunks/History-BgzAIj0G.mjs.map +0 -1
  86. package/dist/_chunks/History-Cda0Yjzz.js.map +0 -1
  87. package/dist/_chunks/ListConfigurationPage-C29EF97r.js.map +0 -1
  88. package/dist/_chunks/ListConfigurationPage-GH55qfoT.mjs.map +0 -1
  89. package/dist/_chunks/ListViewPage-CnRt0UT7.js.map +0 -1
  90. package/dist/_chunks/ListViewPage-QU03PFj1.mjs.map +0 -1
  91. package/dist/_chunks/Relations-BjpPPCKp.js.map +0 -1
  92. package/dist/_chunks/Relations-KMf5qEN0.mjs.map +0 -1
  93. package/dist/_chunks/index-6kKXK7y8.mjs.map +0 -1
  94. package/dist/_chunks/index-D9ZwczCV.js.map +0 -1
  95. package/dist/_chunks/layout-B1Z-9koY.mjs.map +0 -1
  96. package/dist/_chunks/layout-BJfBoBiF.js.map +0 -1
@@ -2,15 +2,15 @@
2
2
  const Icons = require("@strapi/icons");
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const strapiAdmin = require("@strapi/admin/strapi-admin");
5
- const qs = require("qs");
6
- const reactIntl = require("react-intl");
7
- const reactRouterDom = require("react-router-dom");
8
5
  const React = require("react");
9
6
  const designSystem = require("@strapi/design-system");
7
+ const reactIntl = require("react-intl");
8
+ const reactRouterDom = require("react-router-dom");
10
9
  const styledComponents = require("styled-components");
11
10
  const yup = require("yup");
12
11
  const pipe = require("lodash/fp/pipe");
13
12
  const dateFns = require("date-fns");
13
+ const qs = require("qs");
14
14
  const toolkit = require("@reduxjs/toolkit");
15
15
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
16
16
  function _interopNamespace(e) {
@@ -70,42 +70,6 @@ const useInjectionZone = (area) => {
70
70
  const [page, position] = area.split(".");
71
71
  return contentManagerPlugin.getInjectedComponents(page, position);
72
72
  };
73
- const HistoryAction = ({ model, document }) => {
74
- const { formatMessage } = reactIntl.useIntl();
75
- const [{ query }] = strapiAdmin.useQueryParams();
76
- const navigate = reactRouterDom.useNavigate();
77
- const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
78
- if (!window.strapi.features.isEnabled("cms-content-history")) {
79
- return null;
80
- }
81
- return {
82
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
83
- label: formatMessage({
84
- id: "content-manager.history.document-action",
85
- defaultMessage: "Content History"
86
- }),
87
- onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
88
- disabled: (
89
- /**
90
- * The user is creating a new document.
91
- * It hasn't been saved yet, so there's no history to go to
92
- */
93
- !document || /**
94
- * The document has been created but the current dimension has never been saved.
95
- * For example, the user is creating a new locale in an existing document,
96
- * so there's no history for the document in that locale
97
- */
98
- !document.id || /**
99
- * History is only available for content types created by the user.
100
- * These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
101
- * which start with `admin::` or `plugin::`
102
- */
103
- !model.startsWith("api::")
104
- ),
105
- position: "header"
106
- };
107
- };
108
- HistoryAction.type = "history";
109
73
  const ID = "id";
110
74
  const CREATED_BY_ATTRIBUTE_NAME = "createdBy";
111
75
  const UPDATED_BY_ATTRIBUTE_NAME = "updatedBy";
@@ -215,9 +179,7 @@ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
215
179
  "Document",
216
180
  "InitialData",
217
181
  "HistoryVersion",
218
- "Relations",
219
- "Release",
220
- "ReleaseAction"
182
+ "Relations"
221
183
  ]
222
184
  });
223
185
  const documentApi = contentManagerApi.injectEndpoints({
@@ -271,9 +233,7 @@ const documentApi = contentManagerApi.injectEndpoints({
271
233
  }
272
234
  }),
273
235
  invalidatesTags: (_result, _error, { collectionType, model }) => [
274
- { type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model },
275
- { type: "Release", id: "LIST" },
276
- { type: "ReleaseAction", id: "LIST" }
236
+ { type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model }
277
237
  ]
278
238
  }),
279
239
  deleteManyDocuments: builder.mutation({
@@ -285,11 +245,7 @@ const documentApi = contentManagerApi.injectEndpoints({
285
245
  params
286
246
  }
287
247
  }),
288
- invalidatesTags: (_res, _error, { model }) => [
289
- { type: "Document", id: `${model}_LIST` },
290
- { type: "Release", id: "LIST" },
291
- { type: "ReleaseAction", id: "LIST" }
292
- ]
248
+ invalidatesTags: (_res, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
293
249
  }),
294
250
  discardDocument: builder.mutation({
295
251
  query: ({ collectionType, model, documentId, params }) => ({
@@ -306,9 +262,7 @@ const documentApi = contentManagerApi.injectEndpoints({
306
262
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
307
263
  },
308
264
  { type: "Document", id: `${model}_LIST` },
309
- "Relations",
310
- { type: "Release", id: "LIST" },
311
- { type: "ReleaseAction", id: "LIST" }
265
+ "Relations"
312
266
  ];
313
267
  }
314
268
  }),
@@ -427,9 +381,7 @@ const documentApi = contentManagerApi.injectEndpoints({
427
381
  type: "Document",
428
382
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
429
383
  },
430
- "Relations",
431
- { type: "Release", id: "LIST" },
432
- { type: "ReleaseAction", id: "LIST" }
384
+ "Relations"
433
385
  ];
434
386
  }
435
387
  }),
@@ -633,11 +585,11 @@ const createAttributeSchema = (attribute) => {
633
585
  }
634
586
  };
635
587
  const addRequiredValidation = (attribute) => (schema) => {
636
- if (attribute.required) {
637
- return schema.required({
638
- id: strapiAdmin.translatedErrors.required.id,
639
- defaultMessage: "This field is required."
640
- });
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);
641
593
  }
642
594
  return schema?.nullable ? schema.nullable() : (
643
595
  // In some cases '.nullable' will not be available on the schema.
@@ -671,6 +623,28 @@ const addMaxLengthValidation = (attribute) => (schema) => {
671
623
  const addMinValidation = (attribute) => (schema) => {
672
624
  if ("min" in attribute) {
673
625
  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
+ }
674
648
  if ("min" in schema && min) {
675
649
  return schema.min(min, {
676
650
  ...strapiAdmin.translatedErrors.min,
@@ -797,7 +771,10 @@ const useDocument = (args, opts) => {
797
771
  isLoading: isLoadingDocument,
798
772
  isFetching: isFetchingDocument,
799
773
  error
800
- } = useGetDocumentQuery(args, opts);
774
+ } = useGetDocumentQuery(args, {
775
+ ...opts,
776
+ skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
777
+ });
801
778
  const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
802
779
  React__namespace.useEffect(() => {
803
780
  if (error) {
@@ -1299,7 +1276,7 @@ const useDocumentActions = () => {
1299
1276
  };
1300
1277
  };
1301
1278
  const ProtectedHistoryPage = React.lazy(
1302
- () => Promise.resolve().then(() => require("./History-Cda0Yjzz.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1279
+ () => Promise.resolve().then(() => require("./History-DdIstl8b.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1303
1280
  );
1304
1281
  const routes$1 = [
1305
1282
  {
@@ -1312,31 +1289,31 @@ const routes$1 = [
1312
1289
  }
1313
1290
  ];
1314
1291
  const ProtectedEditViewPage = React.lazy(
1315
- () => Promise.resolve().then(() => require("./EditViewPage-DxyAOItK.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1292
+ () => Promise.resolve().then(() => require("./EditViewPage-DA95Ha6J.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1316
1293
  );
1317
1294
  const ProtectedListViewPage = React.lazy(
1318
- () => Promise.resolve().then(() => require("./ListViewPage-CnRt0UT7.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1295
+ () => Promise.resolve().then(() => require("./ListViewPage-wE0lXqoD.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1319
1296
  );
1320
1297
  const ProtectedListConfiguration = React.lazy(
1321
- () => Promise.resolve().then(() => require("./ListConfigurationPage-C29EF97r.js")).then((mod) => ({
1298
+ () => Promise.resolve().then(() => require("./ListConfigurationPage-DkKRparB.js")).then((mod) => ({
1322
1299
  default: mod.ProtectedListConfiguration
1323
1300
  }))
1324
1301
  );
1325
1302
  const ProtectedEditConfigurationPage = React.lazy(
1326
- () => Promise.resolve().then(() => require("./EditConfigurationPage-CyfFvH6-.js")).then((mod) => ({
1303
+ () => Promise.resolve().then(() => require("./EditConfigurationPage-BFEwvdMW.js")).then((mod) => ({
1327
1304
  default: mod.ProtectedEditConfigurationPage
1328
1305
  }))
1329
1306
  );
1330
1307
  const ProtectedComponentConfigurationPage = React.lazy(
1331
- () => Promise.resolve().then(() => require("./ComponentConfigurationPage-Cl7eB3s4.js")).then((mod) => ({
1308
+ () => Promise.resolve().then(() => require("./ComponentConfigurationPage-Bqgx7Mes.js")).then((mod) => ({
1332
1309
  default: mod.ProtectedComponentConfigurationPage
1333
1310
  }))
1334
1311
  );
1335
1312
  const NoPermissions = React.lazy(
1336
- () => Promise.resolve().then(() => require("./NoPermissionsPage-BVHI-jv5.js")).then((mod) => ({ default: mod.NoPermissions }))
1313
+ () => Promise.resolve().then(() => require("./NoPermissionsPage-DmNfF2Bb.js")).then((mod) => ({ default: mod.NoPermissions }))
1337
1314
  );
1338
1315
  const NoContentType = React.lazy(
1339
- () => Promise.resolve().then(() => require("./NoContentTypePage-DFDjxByI.js")).then((mod) => ({ default: mod.NoContentType }))
1316
+ () => Promise.resolve().then(() => require("./NoContentTypePage-DEKR6tf9.js")).then((mod) => ({ default: mod.NoContentType }))
1340
1317
  );
1341
1318
  const CollectionTypePages = () => {
1342
1319
  const { collectionType } = reactRouterDom.useParams();
@@ -1463,7 +1440,7 @@ const DocumentActionButton = (action) => {
1463
1440
  DocumentActionConfirmDialog,
1464
1441
  {
1465
1442
  ...action.dialog,
1466
- variant: action.variant,
1443
+ variant: action.dialog?.variant ?? action.variant,
1467
1444
  isOpen: dialogId === action.id,
1468
1445
  onClose: handleClose
1469
1446
  }
@@ -1669,8 +1646,8 @@ const DocumentActionModal = ({
1669
1646
  };
1670
1647
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
1671
1648
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title }) }),
1672
- typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: Content }),
1673
- typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
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 })
1674
1651
  ] }) });
1675
1652
  };
1676
1653
  const PublishAction$1 = ({
@@ -1692,6 +1669,12 @@ const PublishAction$1 = ({
1692
1669
  ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
1693
1670
  );
1694
1671
  const { publish } = useDocumentActions();
1672
+ const [
1673
+ countDraftRelations,
1674
+ { isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }
1675
+ ] = useLazyGetDraftRelationCountQuery();
1676
+ const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React__namespace.useState(0);
1677
+ const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React__namespace.useState(0);
1695
1678
  const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
1696
1679
  const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
1697
1680
  const modified = strapiAdmin.useForm("PublishAction", ({ modified: modified2 }) => modified2);
@@ -1700,10 +1683,101 @@ const PublishAction$1 = ({
1700
1683
  const validate = strapiAdmin.useForm("PublishAction", (state) => state.validate);
1701
1684
  const setErrors = strapiAdmin.useForm("PublishAction", (state) => state.setErrors);
1702
1685
  const formValues = strapiAdmin.useForm("PublishAction", ({ values }) => values);
1686
+ React__namespace.useEffect(() => {
1687
+ if (isErrorDraftRelations) {
1688
+ toggleNotification({
1689
+ type: "danger",
1690
+ message: formatMessage({
1691
+ id: getTranslation("error.records.fetch-draft-relatons"),
1692
+ defaultMessage: "An error occurred while fetching draft relations on this document."
1693
+ })
1694
+ });
1695
+ }
1696
+ }, [isErrorDraftRelations, toggleNotification, formatMessage]);
1697
+ React__namespace.useEffect(() => {
1698
+ const localDraftRelations = /* @__PURE__ */ new Set();
1699
+ const extractDraftRelations = (data) => {
1700
+ const relations = data.connect || [];
1701
+ relations.forEach((relation) => {
1702
+ if (relation.status === "draft") {
1703
+ localDraftRelations.add(relation.id);
1704
+ }
1705
+ });
1706
+ };
1707
+ const traverseAndExtract = (data) => {
1708
+ Object.entries(data).forEach(([key, value]) => {
1709
+ if (key === "connect" && Array.isArray(value)) {
1710
+ extractDraftRelations({ connect: value });
1711
+ } else if (typeof value === "object" && value !== null) {
1712
+ traverseAndExtract(value);
1713
+ }
1714
+ });
1715
+ };
1716
+ if (!documentId || modified) {
1717
+ traverseAndExtract(formValues);
1718
+ setLocalCountOfDraftRelations(localDraftRelations.size);
1719
+ }
1720
+ }, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
1721
+ 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();
1738
+ }
1739
+ }, [documentId, countDraftRelations, collectionType, model, params]);
1703
1740
  const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
1704
1741
  if (!schema?.options?.draftAndPublish) {
1705
1742
  return null;
1706
1743
  }
1744
+ const performPublish = async () => {
1745
+ setSubmitting(true);
1746
+ try {
1747
+ const { errors } = await validate();
1748
+ if (errors) {
1749
+ toggleNotification({
1750
+ type: "danger",
1751
+ message: formatMessage({
1752
+ id: "content-manager.validation.error",
1753
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
1754
+ })
1755
+ });
1756
+ return;
1757
+ }
1758
+ const res = await publish(
1759
+ {
1760
+ collectionType,
1761
+ model,
1762
+ documentId,
1763
+ params
1764
+ },
1765
+ formValues
1766
+ );
1767
+ if ("data" in res && collectionType !== SINGLE_TYPES) {
1768
+ navigate({
1769
+ pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1770
+ search: rawQuery
1771
+ });
1772
+ } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1773
+ setErrors(formatValidationErrors(res.error));
1774
+ }
1775
+ } finally {
1776
+ setSubmitting(false);
1777
+ }
1778
+ };
1779
+ const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
1780
+ const hasDraftRelations = totalDraftRelations > 0;
1707
1781
  return {
1708
1782
  /**
1709
1783
  * Disabled when:
@@ -1716,46 +1790,38 @@ const PublishAction$1 = ({
1716
1790
  * - the user doesn't have the permission to create a new document
1717
1791
  * - the user doesn't have the permission to update the document
1718
1792
  */
1719
- disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish || Boolean(!document?.documentId && !canCreate || document?.documentId && !canUpdate),
1793
+ disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish || Boolean(!document?.documentId && !canCreate || document?.documentId && !canUpdate),
1720
1794
  label: formatMessage({
1721
1795
  id: "app.utils.publish",
1722
1796
  defaultMessage: "Publish"
1723
1797
  }),
1724
1798
  onClick: async () => {
1725
- setSubmitting(true);
1726
- try {
1727
- const { errors } = await validate();
1728
- if (errors) {
1729
- toggleNotification({
1730
- type: "danger",
1731
- message: formatMessage({
1732
- id: "content-manager.validation.error",
1733
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
1734
- })
1735
- });
1736
- return;
1737
- }
1738
- const res = await publish(
1739
- {
1740
- collectionType,
1741
- model,
1742
- documentId,
1743
- params
1744
- },
1745
- formValues
1746
- );
1747
- if ("data" in res && collectionType !== SINGLE_TYPES) {
1748
- navigate({
1749
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1750
- search: rawQuery
1751
- });
1752
- } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1753
- setErrors(formatValidationErrors(res.error));
1799
+ if (hasDraftRelations) {
1800
+ return;
1801
+ }
1802
+ await performPublish();
1803
+ },
1804
+ dialog: hasDraftRelations ? {
1805
+ type: "dialog",
1806
+ variant: "danger",
1807
+ footer: null,
1808
+ title: formatMessage({
1809
+ id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.title`),
1810
+ defaultMessage: "Confirmation"
1811
+ }),
1812
+ content: formatMessage(
1813
+ {
1814
+ id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
1815
+ defaultMessage: "This entry is related to {count, plural, one {# draft entry} other {# draft entries}}. Publishing it could leave broken links in your app."
1816
+ },
1817
+ {
1818
+ count: totalDraftRelations
1754
1819
  }
1755
- } finally {
1756
- setSubmitting(false);
1820
+ ),
1821
+ onConfirm: async () => {
1822
+ await performPublish();
1757
1823
  }
1758
- }
1824
+ } : void 0
1759
1825
  };
1760
1826
  };
1761
1827
  PublishAction$1.type = "publish";
@@ -1854,10 +1920,13 @@ const UpdateAction = ({
1854
1920
  document
1855
1921
  );
1856
1922
  if ("data" in res && collectionType !== SINGLE_TYPES) {
1857
- navigate({
1858
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1859
- search: rawQuery
1860
- });
1923
+ navigate(
1924
+ {
1925
+ pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1926
+ search: rawQuery
1927
+ },
1928
+ { replace: true }
1929
+ );
1861
1930
  } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1862
1931
  setErrors(formatValidationErrors(res.error));
1863
1932
  }
@@ -2103,23 +2172,13 @@ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
2103
2172
  id: "content-manager.containers.edit.title.new",
2104
2173
  defaultMessage: "Create an entry"
2105
2174
  }) : documentTitle;
2106
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 8, paddingBottom: 4, gap: 3, children: [
2175
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
2107
2176
  /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.BackButton, {}),
2108
- /* @__PURE__ */ jsxRuntime.jsxs(
2109
- designSystem.Flex,
2110
- {
2111
- width: "100%",
2112
- justifyContent: "space-between",
2113
- paddingTop: 1,
2114
- gap: "80px",
2115
- alignItems: "flex-start",
2116
- children: [
2117
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
2118
- /* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
2119
- ]
2120
- }
2121
- ),
2122
- status ? /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) : null
2177
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
2178
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
2179
+ /* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
2180
+ ] }),
2181
+ status ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
2123
2182
  ] });
2124
2183
  };
2125
2184
  const HeaderToolbar = () => {
@@ -2810,7 +2869,7 @@ const ConfirmBulkActionDialog = ({
2810
2869
  endAction
2811
2870
  }) => {
2812
2871
  const { formatMessage } = reactIntl.useIntl();
2813
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { onOpenChange: onToggleDialog, open: isOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
2872
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
2814
2873
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage({
2815
2874
  id: "app.components.ConfirmDialog.title",
2816
2875
  defaultMessage: "Confirmation"
@@ -2931,7 +2990,14 @@ const formatErrorMessages = (errors, parentKey, formatMessage) => {
2931
2990
  )
2932
2991
  );
2933
2992
  } else {
2934
- messages.push(...formatErrorMessages(value, currentKey, formatMessage));
2993
+ messages.push(
2994
+ ...formatErrorMessages(
2995
+ // @ts-expect-error TODO: check why value is not compatible with FormErrors
2996
+ value,
2997
+ currentKey,
2998
+ formatMessage
2999
+ )
3000
+ );
2935
3001
  }
2936
3002
  } else {
2937
3003
  messages.push(
@@ -3594,8 +3660,7 @@ class ContentManagerPlugin {
3594
3660
  documentActions = [
3595
3661
  ...DEFAULT_ACTIONS,
3596
3662
  ...DEFAULT_TABLE_ROW_ACTIONS,
3597
- ...DEFAULT_HEADER_ACTIONS,
3598
- HistoryAction
3663
+ ...DEFAULT_HEADER_ACTIONS
3599
3664
  ];
3600
3665
  editViewSidePanels = [ActionsPanel];
3601
3666
  headerActions = [];
@@ -3684,6 +3749,52 @@ const getPrintableType = (value) => {
3684
3749
  }
3685
3750
  return nativeType;
3686
3751
  };
3752
+ const HistoryAction = ({ model, document }) => {
3753
+ const { formatMessage } = reactIntl.useIntl();
3754
+ const [{ query }] = strapiAdmin.useQueryParams();
3755
+ const navigate = reactRouterDom.useNavigate();
3756
+ const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
3757
+ if (!window.strapi.features.isEnabled("cms-content-history")) {
3758
+ return null;
3759
+ }
3760
+ return {
3761
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
3762
+ label: formatMessage({
3763
+ id: "content-manager.history.document-action",
3764
+ defaultMessage: "Content History"
3765
+ }),
3766
+ onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
3767
+ disabled: (
3768
+ /**
3769
+ * The user is creating a new document.
3770
+ * It hasn't been saved yet, so there's no history to go to
3771
+ */
3772
+ !document || /**
3773
+ * The document has been created but the current dimension has never been saved.
3774
+ * For example, the user is creating a new locale in an existing document,
3775
+ * so there's no history for the document in that locale
3776
+ */
3777
+ !document.id || /**
3778
+ * History is only available for content types created by the user.
3779
+ * These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
3780
+ * which start with `admin::` or `plugin::`
3781
+ */
3782
+ !model.startsWith("api::")
3783
+ ),
3784
+ position: "header"
3785
+ };
3786
+ };
3787
+ HistoryAction.type = "history";
3788
+ const historyAdmin = {
3789
+ bootstrap(app) {
3790
+ const { addDocumentAction } = app.getPlugin("content-manager").apis;
3791
+ addDocumentAction((actions2) => {
3792
+ const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
3793
+ actions2.splice(indexOfDeleteAction, 0, HistoryAction);
3794
+ return actions2;
3795
+ });
3796
+ }
3797
+ };
3687
3798
  const initialState = {
3688
3799
  collectionTypeLinks: [],
3689
3800
  components: [],
@@ -3734,15 +3845,29 @@ const index = {
3734
3845
  defaultMessage: "Content Manager"
3735
3846
  },
3736
3847
  permissions: [],
3737
- Component: () => Promise.resolve().then(() => require("./layout-BJfBoBiF.js")).then((mod) => ({ default: mod.Layout })),
3738
3848
  position: 1
3739
3849
  });
3850
+ app.router.addRoute({
3851
+ path: "content-manager/*",
3852
+ lazy: async () => {
3853
+ const { Layout } = await Promise.resolve().then(() => require("./layout-TPqF2oJ5.js"));
3854
+ return {
3855
+ Component: Layout
3856
+ };
3857
+ },
3858
+ children: routes
3859
+ });
3740
3860
  app.registerPlugin(cm.config);
3741
3861
  },
3862
+ bootstrap(app) {
3863
+ if (typeof historyAdmin.bootstrap === "function") {
3864
+ historyAdmin.bootstrap(app);
3865
+ }
3866
+ },
3742
3867
  async registerTrads({ locales }) {
3743
3868
  const importedTrads = await Promise.all(
3744
3869
  locales.map((locale) => {
3745
- return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-fbKQxLGn.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-EUonQTon.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-B7kGGg3E.js")), "./translations/gu.json": () => Promise.resolve().then(() => require("./gu-BRmF601H.js")), "./translations/hi.json": () => Promise.resolve().then(() => require("./hi-CCJBptSq.js")), "./translations/hu.json": () => Promise.resolve().then(() => require("./hu-sNV_yLYy.js")), "./translations/id.json": () => Promise.resolve().then(() => require("./id-B5Ser98A.js")), "./translations/it.json": () => Promise.resolve().then(() => require("./it-DkBIs7vD.js")), "./translations/ja.json": () => Promise.resolve().then(() => require("./ja-CcFe8diO.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-woFZPmLk.js")), "./translations/ml.json": () => Promise.resolve().then(() => require("./ml-C2W8N8k1.js")), "./translations/ms.json": () => Promise.resolve().then(() => require("./ms-BuFotyP_.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-bbEOHChV.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-uzwG-hk7.js")), "./translations/pt-BR.json": () => Promise.resolve().then(() => require("./pt-BR-BiOz37D9.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-CeXQuq50.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BT3ybNny.js")), "./translations/sa.json": () => Promise.resolve().then(() => require("./sa-CcvkYInH.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-CvY09Xjv.js")), "./translations/sv.json": () => Promise.resolve().then(() => require("./sv-MYDuzgvT.js")), "./translations/th.json": () => Promise.resolve().then(() => require("./th-D9_GfAjc.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-D9UH-O_R.js")), "./translations/uk.json": () => Promise.resolve().then(() => require("./uk-C8EiqJY7.js")), "./translations/vi.json": () => Promise.resolve().then(() => require("./vi-CJlYDheJ.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-9kOncHGw.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CQQfszqR.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
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 }) => {
3746
3871
  return {
3747
3872
  data: prefixPluginTranslations(data, PLUGIN_ID),
3748
3873
  locale
@@ -3786,7 +3911,6 @@ exports.getDisplayName = getDisplayName;
3786
3911
  exports.getMainField = getMainField;
3787
3912
  exports.getTranslation = getTranslation;
3788
3913
  exports.index = index;
3789
- exports.routes = routes;
3790
3914
  exports.setInitialData = setInitialData;
3791
3915
  exports.useContentTypeSchema = useContentTypeSchema;
3792
3916
  exports.useDoc = useDoc;
@@ -3800,4 +3924,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
3800
3924
  exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
3801
3925
  exports.useGetInitialDataQuery = useGetInitialDataQuery;
3802
3926
  exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
3803
- //# sourceMappingURL=index-D9ZwczCV.js.map
3927
+ //# sourceMappingURL=index-DyvUPg1a.js.map