@strapi/content-manager 0.0.0-experimental.f75e3c6d67cc47c64ab37479efdbb7b43be50b78 → 5.0.0-beta.10

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 (95) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-by0e_kNd.js → ComponentConfigurationPage-BNrZY1Rt.js} +3 -3
  2. package/dist/_chunks/{ComponentConfigurationPage-by0e_kNd.js.map → ComponentConfigurationPage-BNrZY1Rt.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-CuWgXugY.mjs → ComponentConfigurationPage-DF4KsgJw.mjs} +3 -3
  4. package/dist/_chunks/{ComponentConfigurationPage-CuWgXugY.mjs.map → ComponentConfigurationPage-DF4KsgJw.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-CqBeCPGH.js → EditConfigurationPage-CzBCnSlY.js} +3 -3
  6. package/dist/_chunks/{EditConfigurationPage-CqBeCPGH.js.map → EditConfigurationPage-CzBCnSlY.js.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-DbI4KMyz.mjs → EditConfigurationPage-Dn7sFfOu.mjs} +3 -3
  8. package/dist/_chunks/{EditConfigurationPage-DbI4KMyz.mjs.map → EditConfigurationPage-Dn7sFfOu.mjs.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-ChgloMyO.js → EditViewPage-CEemNwSu.js} +45 -45
  10. package/dist/_chunks/EditViewPage-CEemNwSu.js.map +1 -0
  11. package/dist/_chunks/{EditViewPage-dFPBya9U.mjs → EditViewPage-D2uq2uZS.mjs} +46 -46
  12. package/dist/_chunks/EditViewPage-D2uq2uZS.mjs.map +1 -0
  13. package/dist/_chunks/{Field-C1nUKcdS.mjs → Field-DvB4ig_f.mjs} +373 -118
  14. package/dist/_chunks/Field-DvB4ig_f.mjs.map +1 -0
  15. package/dist/_chunks/{Field-dLk-vgLL.js → Field-KHBYihjn.js} +372 -117
  16. package/dist/_chunks/Field-KHBYihjn.js.map +1 -0
  17. package/dist/_chunks/{Form-DOlpi7Js.mjs → Form-BGmF27Mb.mjs} +27 -28
  18. package/dist/_chunks/Form-BGmF27Mb.mjs.map +1 -0
  19. package/dist/_chunks/{Form-CbXtmHC_.js → Form-De_O8dNp.js} +25 -26
  20. package/dist/_chunks/Form-De_O8dNp.js.map +1 -0
  21. package/dist/_chunks/{History-BFNUAiGc.mjs → History-Cqq6Csvj.mjs} +103 -23
  22. package/dist/_chunks/History-Cqq6Csvj.mjs.map +1 -0
  23. package/dist/_chunks/{History-BjDfohBr.js → History-aALwb_34.js} +102 -22
  24. package/dist/_chunks/History-aALwb_34.js.map +1 -0
  25. package/dist/_chunks/{ListConfigurationPage-DDi0KqFm.mjs → ListConfigurationPage-Bke2024Z.mjs} +43 -45
  26. package/dist/_chunks/ListConfigurationPage-Bke2024Z.mjs.map +1 -0
  27. package/dist/_chunks/{ListConfigurationPage-IQBgWTaa.js → ListConfigurationPage-DimG1pln.js} +42 -43
  28. package/dist/_chunks/ListConfigurationPage-DimG1pln.js.map +1 -0
  29. package/dist/_chunks/{ListViewPage-CZYGqlvF.js → ListViewPage-BO-JvrUA.js} +60 -65
  30. package/dist/_chunks/ListViewPage-BO-JvrUA.js.map +1 -0
  31. package/dist/_chunks/{ListViewPage-BPjljUsH.mjs → ListViewPage-Cjbh5jyY.mjs} +62 -67
  32. package/dist/_chunks/ListViewPage-Cjbh5jyY.mjs.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-BOAI6VZ1.js → NoContentTypePage-S-R1DXX2.js} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-BOAI6VZ1.js.map → NoContentTypePage-S-R1DXX2.js.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-DaWw67K-.mjs → NoContentTypePage-m6_m6mFn.mjs} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-DaWw67K-.mjs.map → NoContentTypePage-m6_m6mFn.mjs.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-CZrJH00p.mjs → NoPermissionsPage-CCMchuOR.mjs} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-CZrJH00p.mjs.map → NoPermissionsPage-CCMchuOR.mjs.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-cYEtLc_e.js → NoPermissionsPage-wFEMKcdV.js} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-cYEtLc_e.js.map → NoPermissionsPage-wFEMKcdV.js.map} +1 -1
  41. package/dist/_chunks/{Relations-DU6B7irU.js → Relations-PjEVbLqZ.js} +4 -4
  42. package/dist/_chunks/{Relations-DU6B7irU.js.map → Relations-PjEVbLqZ.js.map} +1 -1
  43. package/dist/_chunks/{Relations-DTowyge2.mjs → Relations-i8F_imXr.mjs} +4 -4
  44. package/dist/_chunks/{Relations-DTowyge2.mjs.map → Relations-i8F_imXr.mjs.map} +1 -1
  45. package/dist/_chunks/{en-GCOTL6jR.mjs → en-Ux26r5pl.mjs} +5 -1
  46. package/dist/_chunks/{en-GCOTL6jR.mjs.map → en-Ux26r5pl.mjs.map} +1 -1
  47. package/dist/_chunks/{en-DTULi5-d.js → en-fbKQxLGn.js} +5 -1
  48. package/dist/_chunks/{en-DTULi5-d.js.map → en-fbKQxLGn.js.map} +1 -1
  49. package/dist/_chunks/{index-CCJeB7Rw.js → index-B4Gj2Oe9.js} +1239 -947
  50. package/dist/_chunks/index-B4Gj2Oe9.js.map +1 -0
  51. package/dist/_chunks/{index-BaGHmIir.mjs → index-BAGok3Xa.mjs} +1257 -965
  52. package/dist/_chunks/index-BAGok3Xa.mjs.map +1 -0
  53. package/dist/_chunks/{layout-BinjszSQ.mjs → layout-BybbePH7.mjs} +17 -12
  54. package/dist/_chunks/layout-BybbePH7.mjs.map +1 -0
  55. package/dist/_chunks/{layout-ni_L9kT1.js → layout-aK6fNSLK.js} +17 -12
  56. package/dist/_chunks/layout-aK6fNSLK.js.map +1 -0
  57. package/dist/_chunks/{relations-c91ji5eR.mjs → relations-BZicUuRc.mjs} +2 -2
  58. package/dist/_chunks/{relations-c91ji5eR.mjs.map → relations-BZicUuRc.mjs.map} +1 -1
  59. package/dist/_chunks/{relations-CeJAJc5I.js → relations-yBDEAWeN.js} +2 -2
  60. package/dist/_chunks/{relations-CeJAJc5I.js.map → relations-yBDEAWeN.js.map} +1 -1
  61. package/dist/admin/index.js +1 -1
  62. package/dist/admin/index.mjs +5 -5
  63. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
  64. package/dist/admin/src/hooks/useDocumentActions.d.ts +1 -1
  65. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +7 -3
  66. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
  67. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +2 -10
  68. package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
  69. package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
  70. package/dist/admin/src/pages/ListView/components/BulkActions/PublishAction.d.ts +14 -0
  71. package/dist/server/index.js +20 -15
  72. package/dist/server/index.js.map +1 -1
  73. package/dist/server/index.mjs +20 -15
  74. package/dist/server/index.mjs.map +1 -1
  75. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  76. package/dist/server/src/controllers/single-types.d.ts.map +1 -1
  77. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  78. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  79. package/package.json +8 -8
  80. package/dist/_chunks/EditViewPage-ChgloMyO.js.map +0 -1
  81. package/dist/_chunks/EditViewPage-dFPBya9U.mjs.map +0 -1
  82. package/dist/_chunks/Field-C1nUKcdS.mjs.map +0 -1
  83. package/dist/_chunks/Field-dLk-vgLL.js.map +0 -1
  84. package/dist/_chunks/Form-CbXtmHC_.js.map +0 -1
  85. package/dist/_chunks/Form-DOlpi7Js.mjs.map +0 -1
  86. package/dist/_chunks/History-BFNUAiGc.mjs.map +0 -1
  87. package/dist/_chunks/History-BjDfohBr.js.map +0 -1
  88. package/dist/_chunks/ListConfigurationPage-DDi0KqFm.mjs.map +0 -1
  89. package/dist/_chunks/ListConfigurationPage-IQBgWTaa.js.map +0 -1
  90. package/dist/_chunks/ListViewPage-BPjljUsH.mjs.map +0 -1
  91. package/dist/_chunks/ListViewPage-CZYGqlvF.js.map +0 -1
  92. package/dist/_chunks/index-BaGHmIir.mjs.map +0 -1
  93. package/dist/_chunks/index-CCJeB7Rw.js.map +0 -1
  94. package/dist/_chunks/layout-BinjszSQ.mjs.map +0 -1
  95. package/dist/_chunks/layout-ni_L9kT1.js.map +0 -1
@@ -219,6 +219,7 @@ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
219
219
  ]
220
220
  });
221
221
  const documentApi = contentManagerApi.injectEndpoints({
222
+ overrideExisting: true,
222
223
  endpoints: (builder) => ({
223
224
  autoCloneDocument: builder.mutation({
224
225
  query: ({ model, sourceId, query }) => ({
@@ -948,12 +949,13 @@ const useDocumentActions = () => {
948
949
  );
949
950
  const [discardDocument] = useDiscardDocumentMutation();
950
951
  const discard = React__namespace.useCallback(
951
- async ({ collectionType, model, documentId }) => {
952
+ async ({ collectionType, model, documentId, params }) => {
952
953
  try {
953
954
  const res = await discardDocument({
954
955
  collectionType,
955
956
  model,
956
- documentId
957
+ documentId,
958
+ params
957
959
  });
958
960
  if ("error" in res) {
959
961
  toggleNotification({
@@ -1285,7 +1287,7 @@ const useDocumentActions = () => {
1285
1287
  };
1286
1288
  };
1287
1289
  const ProtectedHistoryPage = React.lazy(
1288
- () => Promise.resolve().then(() => require("./History-BjDfohBr.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1290
+ () => Promise.resolve().then(() => require("./History-aALwb_34.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1289
1291
  );
1290
1292
  const routes$1 = [
1291
1293
  {
@@ -1298,31 +1300,31 @@ const routes$1 = [
1298
1300
  }
1299
1301
  ];
1300
1302
  const ProtectedEditViewPage = React.lazy(
1301
- () => Promise.resolve().then(() => require("./EditViewPage-ChgloMyO.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1303
+ () => Promise.resolve().then(() => require("./EditViewPage-CEemNwSu.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1302
1304
  );
1303
1305
  const ProtectedListViewPage = React.lazy(
1304
- () => Promise.resolve().then(() => require("./ListViewPage-CZYGqlvF.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1306
+ () => Promise.resolve().then(() => require("./ListViewPage-BO-JvrUA.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1305
1307
  );
1306
1308
  const ProtectedListConfiguration = React.lazy(
1307
- () => Promise.resolve().then(() => require("./ListConfigurationPage-IQBgWTaa.js")).then((mod) => ({
1309
+ () => Promise.resolve().then(() => require("./ListConfigurationPage-DimG1pln.js")).then((mod) => ({
1308
1310
  default: mod.ProtectedListConfiguration
1309
1311
  }))
1310
1312
  );
1311
1313
  const ProtectedEditConfigurationPage = React.lazy(
1312
- () => Promise.resolve().then(() => require("./EditConfigurationPage-CqBeCPGH.js")).then((mod) => ({
1314
+ () => Promise.resolve().then(() => require("./EditConfigurationPage-CzBCnSlY.js")).then((mod) => ({
1313
1315
  default: mod.ProtectedEditConfigurationPage
1314
1316
  }))
1315
1317
  );
1316
1318
  const ProtectedComponentConfigurationPage = React.lazy(
1317
- () => Promise.resolve().then(() => require("./ComponentConfigurationPage-by0e_kNd.js")).then((mod) => ({
1319
+ () => Promise.resolve().then(() => require("./ComponentConfigurationPage-BNrZY1Rt.js")).then((mod) => ({
1318
1320
  default: mod.ProtectedComponentConfigurationPage
1319
1321
  }))
1320
1322
  );
1321
1323
  const NoPermissions = React.lazy(
1322
- () => Promise.resolve().then(() => require("./NoPermissionsPage-cYEtLc_e.js")).then((mod) => ({ default: mod.NoPermissions }))
1324
+ () => Promise.resolve().then(() => require("./NoPermissionsPage-wFEMKcdV.js")).then((mod) => ({ default: mod.NoPermissions }))
1323
1325
  );
1324
1326
  const NoContentType = React.lazy(
1325
- () => Promise.resolve().then(() => require("./NoContentTypePage-BOAI6VZ1.js")).then((mod) => ({ default: mod.NoContentType }))
1327
+ () => Promise.resolve().then(() => require("./NoContentTypePage-S-R1DXX2.js")).then((mod) => ({ default: mod.NoContentType }))
1326
1328
  );
1327
1329
  const CollectionTypePages = () => {
1328
1330
  const { collectionType } = reactRouterDom.useParams();
@@ -1529,7 +1531,7 @@ const DocumentActionsMenu = ({
1529
1531
  display: "block",
1530
1532
  children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: [
1531
1533
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { color: convertActionVariantToColor(action.variant), gap: 2, tag: "span", children: [
1532
- action.icon,
1534
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "span", color: convertActionVariantToIconColor(action.variant), children: action.icon }),
1533
1535
  action.label
1534
1536
  ] }),
1535
1537
  action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsxRuntime.jsx(
@@ -1590,6 +1592,18 @@ const convertActionVariantToColor = (variant = "secondary") => {
1590
1592
  return "primary600";
1591
1593
  }
1592
1594
  };
1595
+ const convertActionVariantToIconColor = (variant = "secondary") => {
1596
+ switch (variant) {
1597
+ case "danger":
1598
+ return "danger600";
1599
+ case "secondary":
1600
+ return "neutral500";
1601
+ case "success":
1602
+ return "success600";
1603
+ default:
1604
+ return "primary600";
1605
+ }
1606
+ };
1593
1607
  const DocumentActionConfirmDialog = ({
1594
1608
  onClose,
1595
1609
  onCancel,
@@ -1612,22 +1626,20 @@ const DocumentActionConfirmDialog = ({
1612
1626
  }
1613
1627
  onClose();
1614
1628
  };
1615
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog, { isOpen, title, onClose: handleClose, children: [
1616
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.DialogBody, { children: content }),
1617
- /* @__PURE__ */ jsxRuntime.jsx(
1618
- designSystem.DialogFooter,
1619
- {
1620
- startAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleClose, variant: "tertiary", children: formatMessage({
1621
- id: "app.components.Button.cancel",
1622
- defaultMessage: "Cancel"
1623
- }) }),
1624
- endAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
1625
- id: "app.components.Button.confirm",
1626
- defaultMessage: "Confirm"
1627
- }) })
1628
- }
1629
- )
1630
- ] });
1629
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
1630
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
1631
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
1632
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
1633
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
1634
+ id: "app.components.Button.cancel",
1635
+ defaultMessage: "Cancel"
1636
+ }) }) }),
1637
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
1638
+ id: "app.components.Button.confirm",
1639
+ defaultMessage: "Confirm"
1640
+ }) })
1641
+ ] })
1642
+ ] }) });
1631
1643
  };
1632
1644
  const DocumentActionModal = ({
1633
1645
  isOpen,
@@ -1637,36 +1649,19 @@ const DocumentActionModal = ({
1637
1649
  content: Content,
1638
1650
  onModalClose
1639
1651
  }) => {
1640
- const id = React__namespace.useId();
1641
- if (!isOpen) {
1642
- return null;
1643
- }
1644
1652
  const handleClose = () => {
1645
1653
  if (onClose) {
1646
1654
  onClose();
1647
1655
  }
1648
1656
  onModalClose();
1649
1657
  };
1650
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.ModalLayout, { borderRadius: "4px", overflow: "hidden", onClose: handleClose, labelledBy: id, children: [
1651
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral800", tag: "h2", id, children: title }) }),
1652
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalBody, { children: typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content }),
1653
- /* @__PURE__ */ jsxRuntime.jsx(
1654
- designSystem.Box,
1655
- {
1656
- paddingTop: 4,
1657
- paddingBottom: 4,
1658
- paddingLeft: 5,
1659
- paddingRight: 5,
1660
- borderWidth: "1px 0 0 0",
1661
- borderStyle: "solid",
1662
- borderColor: "neutral150",
1663
- background: "neutral100",
1664
- children: typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
1665
- }
1666
- )
1667
- ] });
1658
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
1659
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title }) }),
1660
+ typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: Content }),
1661
+ typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
1662
+ ] }) });
1668
1663
  };
1669
- const PublishAction = ({
1664
+ const PublishAction$1 = ({
1670
1665
  activeTab,
1671
1666
  documentId,
1672
1667
  model,
@@ -1751,7 +1746,7 @@ const PublishAction = ({
1751
1746
  }
1752
1747
  };
1753
1748
  };
1754
- PublishAction.type = "publish";
1749
+ PublishAction$1.type = "publish";
1755
1750
  const UpdateAction = ({
1756
1751
  activeTab,
1757
1752
  documentId,
@@ -1882,10 +1877,8 @@ const UnpublishAction$1 = ({
1882
1877
  const { toggleNotification } = strapiAdmin.useNotification();
1883
1878
  const [shouldKeepDraft, setShouldKeepDraft] = React__namespace.useState(true);
1884
1879
  const isDocumentModified = document?.status === "modified";
1885
- const handleChange = (e) => {
1886
- if ("value" in e.target) {
1887
- setShouldKeepDraft(e.target.value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
1888
- }
1880
+ const handleChange = (value) => {
1881
+ setShouldKeepDraft(value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
1889
1882
  };
1890
1883
  if (!schema?.options?.draftAndPublish) {
1891
1884
  return null;
@@ -1935,40 +1928,24 @@ const UnpublishAction$1 = ({
1935
1928
  }) })
1936
1929
  ] }),
1937
1930
  /* @__PURE__ */ jsxRuntime.jsxs(
1938
- designSystem.Flex,
1931
+ designSystem.Radio.Group,
1939
1932
  {
1940
- onChange: handleChange,
1941
- direction: "column",
1942
- alignItems: "flex-start",
1943
- tag: "fieldset",
1944
- borderWidth: 0,
1945
- gap: 3,
1933
+ defaultValue: UNPUBLISH_DRAFT_OPTIONS.KEEP,
1934
+ name: "discard-options",
1935
+ "aria-label": formatMessage({
1936
+ id: "content-manager.actions.unpublish.dialog.radio-label",
1937
+ defaultMessage: "Choose an option to unpublish the document."
1938
+ }),
1939
+ onValueChange: handleChange,
1946
1940
  children: [
1947
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "legend" }),
1948
- /* @__PURE__ */ jsxRuntime.jsx(
1949
- designSystem.Radio,
1950
- {
1951
- checked: shouldKeepDraft,
1952
- value: UNPUBLISH_DRAFT_OPTIONS.KEEP,
1953
- name: "discard-options",
1954
- children: formatMessage({
1955
- id: "content-manager.actions.unpublish.dialog.option.keep-draft",
1956
- defaultMessage: "Keep draft"
1957
- })
1958
- }
1959
- ),
1960
- /* @__PURE__ */ jsxRuntime.jsx(
1961
- designSystem.Radio,
1962
- {
1963
- checked: !shouldKeepDraft,
1964
- value: UNPUBLISH_DRAFT_OPTIONS.DISCARD,
1965
- name: "discard-options",
1966
- children: formatMessage({
1967
- id: "content-manager.actions.unpublish.dialog.option.replace-draft",
1968
- defaultMessage: "Replace draft"
1969
- })
1970
- }
1971
- )
1941
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.KEEP, children: formatMessage({
1942
+ id: "content-manager.actions.unpublish.dialog.option.keep-draft",
1943
+ defaultMessage: "Keep draft"
1944
+ }) }),
1945
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: !shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.DISCARD, children: formatMessage({
1946
+ id: "content-manager.actions.unpublish.dialog.option.replace-draft",
1947
+ defaultMessage: "Replace draft"
1948
+ }) })
1972
1949
  ]
1973
1950
  }
1974
1951
  )
@@ -2057,7 +2034,7 @@ const StyledCrossCircle = styledComponents.styled(Icons.CrossCircle)`
2057
2034
  fill: currentColor;
2058
2035
  }
2059
2036
  `;
2060
- const DEFAULT_ACTIONS = [PublishAction, UpdateAction, UnpublishAction$1, DiscardAction];
2037
+ const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
2061
2038
  const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
2062
2039
  const RelativeTime = React__namespace.forwardRef(
2063
2040
  ({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {
@@ -2512,910 +2489,1225 @@ const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
2512
2489
  }
2513
2490
  );
2514
2491
  });
2515
- const BulkActionsRenderer = () => {
2516
- const plugins = strapiAdmin.useStrapiApp("BulkActionsRenderer", (state) => state.plugins);
2517
- const { model, collectionType } = useDoc();
2518
- const { selectedRows } = strapiAdmin.useTable("BulkActionsRenderer", (state) => state);
2519
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
2520
- strapiAdmin.DescriptionComponentRenderer,
2521
- {
2522
- props: {
2523
- model,
2524
- collectionType,
2525
- documents: selectedRows
2526
- },
2527
- descriptions: plugins["content-manager"].apis.getBulkActions(),
2528
- children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsxRuntime.jsx(BulkActionAction, { ...action }, action.id))
2529
- }
2530
- ) });
2531
- };
2532
- const BulkActionAction = (action) => {
2533
- const [dialogId, setDialogId] = React__namespace.useState(null);
2534
- const { toggleNotification } = strapiAdmin.useNotification();
2535
- const handleClick = (action2) => (e) => {
2536
- const { onClick, dialog, id } = action2;
2537
- if (onClick) {
2538
- onClick(e);
2539
- }
2540
- if (dialog) {
2541
- switch (dialog.type) {
2542
- case "notification":
2543
- toggleNotification({
2544
- title: dialog.title,
2545
- message: dialog.content,
2546
- type: dialog.status,
2547
- timeout: dialog.timeout,
2548
- onClose: dialog.onClose
2549
- });
2550
- break;
2551
- case "dialog":
2552
- case "modal": {
2553
- e.preventDefault();
2554
- setDialogId(id);
2555
- }
2556
- }
2557
- }
2558
- };
2559
- const handleClose = () => {
2560
- setDialogId(null);
2561
- if (action.dialog?.type === "modal" && action.dialog?.onClose) {
2562
- action.dialog.onClose();
2563
- }
2564
- };
2565
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2566
- /* @__PURE__ */ jsxRuntime.jsx(
2567
- designSystem.Button,
2568
- {
2569
- disabled: action.disabled,
2570
- startIcon: action.icon,
2571
- variant: action.variant,
2572
- onClick: handleClick(action),
2573
- children: action.label
2574
- }
2575
- ),
2576
- action.dialog?.type === "dialog" ? /* @__PURE__ */ jsxRuntime.jsx(
2577
- BulkActionConfirmDialog,
2578
- {
2579
- ...action.dialog,
2580
- variant: action.variant,
2581
- isOpen: dialogId === action.id,
2582
- onClose: handleClose
2583
- }
2584
- ) : null,
2585
- action.dialog?.type === "modal" ? /* @__PURE__ */ jsxRuntime.jsx(
2586
- BulkActionModal,
2587
- {
2588
- ...action.dialog,
2589
- onModalClose: handleClose,
2590
- isOpen: dialogId === action.id
2591
- }
2592
- ) : null
2593
- ] });
2492
+ const HOOKS = {
2493
+ /**
2494
+ * Hook that allows to mutate the displayed headers of the list view table
2495
+ * @constant
2496
+ * @type {string}
2497
+ */
2498
+ INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
2499
+ /**
2500
+ * Hook that allows to mutate the CM's collection types links pre-set filters
2501
+ * @constant
2502
+ * @type {string}
2503
+ */
2504
+ MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
2505
+ /**
2506
+ * Hook that allows to mutate the CM's edit view layout
2507
+ * @constant
2508
+ * @type {string}
2509
+ */
2510
+ MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
2511
+ /**
2512
+ * Hook that allows to mutate the CM's single types links pre-set filters
2513
+ * @constant
2514
+ * @type {string}
2515
+ */
2516
+ MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
2594
2517
  };
2595
- const BulkActionConfirmDialog = ({
2596
- onClose,
2597
- onCancel,
2598
- onConfirm,
2599
- title,
2600
- content,
2601
- confirmButton,
2602
- isOpen,
2603
- variant = "secondary"
2604
- }) => {
2605
- const { formatMessage } = reactIntl.useIntl();
2606
- const handleClose = async () => {
2607
- if (onCancel) {
2608
- await onCancel();
2609
- }
2610
- onClose();
2611
- };
2612
- const handleConfirm = async () => {
2613
- if (onConfirm) {
2614
- await onConfirm();
2615
- }
2616
- onClose();
2617
- };
2618
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog, { isOpen, title, onClose: handleClose, children: [
2619
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.DialogBody, { icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, {}), children: content }),
2620
- /* @__PURE__ */ jsxRuntime.jsx(
2621
- designSystem.DialogFooter,
2622
- {
2623
- startAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleClose, variant: "tertiary", children: formatMessage({
2624
- id: "app.components.Button.cancel",
2625
- defaultMessage: "Cancel"
2626
- }) }),
2627
- endAction: /* @__PURE__ */ jsxRuntime.jsx(
2628
- designSystem.Button,
2629
- {
2630
- onClick: handleConfirm,
2631
- variant: variant === "danger-light" ? variant : "secondary",
2632
- startIcon: variant === "danger-light" ? /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}) : /* @__PURE__ */ jsxRuntime.jsx(Icons.Check, {}),
2633
- children: confirmButton ? confirmButton : formatMessage({
2634
- id: "app.components.Button.confirm",
2635
- defaultMessage: "Confirm"
2636
- })
2637
- }
2638
- )
2639
- }
2640
- )
2641
- ] });
2518
+ const contentTypesApi = contentManagerApi.injectEndpoints({
2519
+ endpoints: (builder) => ({
2520
+ getContentTypeConfiguration: builder.query({
2521
+ query: (uid) => ({
2522
+ url: `/content-manager/content-types/${uid}/configuration`,
2523
+ method: "GET"
2524
+ }),
2525
+ transformResponse: (response) => response.data,
2526
+ providesTags: (_result, _error, uid) => [
2527
+ { type: "ContentTypesConfiguration", id: uid },
2528
+ { type: "ContentTypeSettings", id: "LIST" }
2529
+ ]
2530
+ }),
2531
+ getAllContentTypeSettings: builder.query({
2532
+ query: () => "/content-manager/content-types-settings",
2533
+ transformResponse: (response) => response.data,
2534
+ providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
2535
+ }),
2536
+ updateContentTypeConfiguration: builder.mutation({
2537
+ query: ({ uid, ...body }) => ({
2538
+ url: `/content-manager/content-types/${uid}/configuration`,
2539
+ method: "PUT",
2540
+ data: body
2541
+ }),
2542
+ transformResponse: (response) => response.data,
2543
+ invalidatesTags: (_result, _error, { uid }) => [
2544
+ { type: "ContentTypesConfiguration", id: uid },
2545
+ { type: "ContentTypeSettings", id: "LIST" },
2546
+ // Is this necessary?
2547
+ { type: "InitialData" }
2548
+ ]
2549
+ })
2550
+ })
2551
+ });
2552
+ const {
2553
+ useGetContentTypeConfigurationQuery,
2554
+ useGetAllContentTypeSettingsQuery,
2555
+ useUpdateContentTypeConfigurationMutation
2556
+ } = contentTypesApi;
2557
+ const checkIfAttributeIsDisplayable = (attribute) => {
2558
+ const { type } = attribute;
2559
+ if (type === "relation") {
2560
+ return !attribute.relation.toLowerCase().includes("morph");
2561
+ }
2562
+ return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
2642
2563
  };
2643
- const BulkActionModal = ({
2644
- isOpen,
2645
- title,
2646
- onClose,
2647
- content: Content,
2648
- onModalClose
2649
- }) => {
2650
- const id = React__namespace.useId();
2651
- if (!isOpen) {
2652
- return null;
2564
+ const getMainField = (attribute, mainFieldName, { schemas, components }) => {
2565
+ if (!mainFieldName) {
2566
+ return void 0;
2653
2567
  }
2654
- const handleClose = () => {
2655
- if (onClose) {
2656
- onClose();
2657
- }
2658
- onModalClose();
2568
+ const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
2569
+ // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
2570
+ schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
2571
+ );
2572
+ return {
2573
+ name: mainFieldName,
2574
+ type: mainFieldType ?? "string"
2659
2575
  };
2660
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.ModalLayout, { borderRadius: "4px", overflow: "hidden", onClose: handleClose, labelledBy: id, children: [
2661
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral800", tag: "h2", id, children: title }) }),
2662
- /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose })
2663
- ] });
2664
2576
  };
2665
- const DeleteAction = ({ documents, model }) => {
2666
- const { formatMessage } = reactIntl.useIntl();
2667
- const { schema: contentType } = useDoc();
2668
- const selectRow = strapiAdmin.useTable("DeleteAction", (state) => state.selectRow);
2669
- const hasI18nEnabled = Boolean(contentType?.pluginOptions?.i18n);
2577
+ const DEFAULT_SETTINGS = {
2578
+ bulkable: false,
2579
+ filterable: false,
2580
+ searchable: false,
2581
+ pagination: false,
2582
+ defaultSortBy: "",
2583
+ defaultSortOrder: "asc",
2584
+ mainField: "id",
2585
+ pageSize: 10
2586
+ };
2587
+ const useDocumentLayout = (model) => {
2588
+ const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
2670
2589
  const [{ query }] = strapiAdmin.useQueryParams();
2671
- const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
2672
- const hasDeletePermission = useDocumentRBAC("deleteAction", (state) => state.canDelete);
2673
- const { deleteMany: bulkDeleteAction } = useDocumentActions();
2674
- const documentIds = documents.map(({ documentId }) => documentId);
2675
- const handleConfirmBulkDelete = async () => {
2676
- const res = await bulkDeleteAction({
2677
- documentIds,
2678
- model,
2679
- params
2680
- });
2681
- if (!("error" in res)) {
2682
- selectRow([]);
2683
- }
2684
- };
2685
- if (!hasDeletePermission)
2686
- return null;
2687
- return {
2688
- variant: "danger-light",
2689
- label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
2690
- dialog: {
2691
- type: "dialog",
2692
- title: formatMessage({
2693
- id: "app.components.ConfirmDialog.title",
2694
- defaultMessage: "Confirmation"
2695
- }),
2696
- content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
2697
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
2698
- id: "popUpWarning.bodyMessage.contentType.delete.all",
2699
- defaultMessage: "Are you sure you want to delete these entries?"
2700
- }) }),
2701
- hasI18nEnabled && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { textAlign: "center", padding: 3, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", children: formatMessage(
2702
- {
2703
- id: getTranslation("Settings.list.actions.deleteAdditionalInfos"),
2704
- defaultMessage: "This will delete the active locale versions <em>(from Internationalization)</em>"
2705
- },
2706
- {
2707
- em: Emphasis
2708
- }
2709
- ) }) })
2710
- ] }),
2711
- onConfirm: handleConfirmBulkDelete
2590
+ const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
2591
+ const { toggleNotification } = strapiAdmin.useNotification();
2592
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
2593
+ const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
2594
+ const {
2595
+ data,
2596
+ isLoading: isLoadingConfigs,
2597
+ error,
2598
+ isFetching: isFetchingConfigs
2599
+ } = useGetContentTypeConfigurationQuery(model);
2600
+ const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
2601
+ React__namespace.useEffect(() => {
2602
+ if (error) {
2603
+ toggleNotification({
2604
+ type: "danger",
2605
+ message: formatAPIError(error)
2606
+ });
2712
2607
  }
2608
+ }, [error, formatAPIError, toggleNotification]);
2609
+ const editLayout = React__namespace.useMemo(
2610
+ () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
2611
+ layout: [],
2612
+ components: {},
2613
+ metadatas: {},
2614
+ options: {},
2615
+ settings: DEFAULT_SETTINGS
2616
+ },
2617
+ [data, isLoading, schemas, schema, components]
2618
+ );
2619
+ const listLayout = React__namespace.useMemo(() => {
2620
+ return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
2621
+ layout: [],
2622
+ metadatas: {},
2623
+ options: {},
2624
+ settings: DEFAULT_SETTINGS
2625
+ };
2626
+ }, [data, isLoading, schemas, schema, components]);
2627
+ const { layout: edit } = React__namespace.useMemo(
2628
+ () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
2629
+ layout: editLayout,
2630
+ query
2631
+ }),
2632
+ [editLayout, query, runHookWaterfall]
2633
+ );
2634
+ return {
2635
+ error,
2636
+ isLoading,
2637
+ edit,
2638
+ list: listLayout
2713
2639
  };
2714
2640
  };
2715
- DeleteAction.type = "delete";
2716
- const UnpublishAction = ({ documents, model }) => {
2717
- const { formatMessage } = reactIntl.useIntl();
2718
- const { schema } = useDoc();
2719
- const selectRow = strapiAdmin.useTable("UnpublishAction", (state) => state.selectRow);
2720
- const hasPublishPermission = useDocumentRBAC("unpublishAction", (state) => state.canPublish);
2721
- const hasI18nEnabled = Boolean(schema?.pluginOptions?.i18n);
2722
- const hasDraftAndPublishEnabled = Boolean(schema?.options?.draftAndPublish);
2723
- const { unpublishMany: bulkUnpublishAction } = useDocumentActions();
2724
- const documentIds = documents.map(({ documentId }) => documentId);
2725
- const [{ query }] = strapiAdmin.useQueryParams();
2726
- const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
2727
- const handleConfirmBulkUnpublish = async () => {
2728
- const data = await bulkUnpublishAction({ documentIds, model, params });
2729
- if (!("error" in data)) {
2730
- selectRow([]);
2641
+ const useDocLayout = () => {
2642
+ const { model } = useDoc();
2643
+ return useDocumentLayout(model);
2644
+ };
2645
+ const formatEditLayout = (data, {
2646
+ schemas,
2647
+ schema,
2648
+ components
2649
+ }) => {
2650
+ let currentPanelIndex = 0;
2651
+ const panelledEditAttributes = convertEditLayoutToFieldLayouts(
2652
+ data.contentType.layouts.edit,
2653
+ schema?.attributes,
2654
+ data.contentType.metadatas,
2655
+ { configurations: data.components, schemas: components },
2656
+ schemas
2657
+ ).reduce((panels, row) => {
2658
+ if (row.some((field) => field.type === "dynamiczone")) {
2659
+ panels.push([row]);
2660
+ currentPanelIndex += 2;
2661
+ } else {
2662
+ if (!panels[currentPanelIndex]) {
2663
+ panels.push([]);
2664
+ }
2665
+ panels[currentPanelIndex].push(row);
2666
+ }
2667
+ return panels;
2668
+ }, []);
2669
+ const componentEditAttributes = Object.entries(data.components).reduce(
2670
+ (acc, [uid, configuration]) => {
2671
+ acc[uid] = {
2672
+ layout: convertEditLayoutToFieldLayouts(
2673
+ configuration.layouts.edit,
2674
+ components[uid].attributes,
2675
+ configuration.metadatas
2676
+ ),
2677
+ settings: {
2678
+ ...configuration.settings,
2679
+ icon: components[uid].info.icon,
2680
+ displayName: components[uid].info.displayName
2681
+ }
2682
+ };
2683
+ return acc;
2684
+ },
2685
+ {}
2686
+ );
2687
+ const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
2688
+ (acc, [attribute, metadata]) => {
2689
+ return {
2690
+ ...acc,
2691
+ [attribute]: metadata.edit
2692
+ };
2693
+ },
2694
+ {}
2695
+ );
2696
+ return {
2697
+ layout: panelledEditAttributes,
2698
+ components: componentEditAttributes,
2699
+ metadatas: editMetadatas,
2700
+ settings: {
2701
+ ...data.contentType.settings,
2702
+ displayName: schema?.info.displayName
2703
+ },
2704
+ options: {
2705
+ ...schema?.options,
2706
+ ...schema?.pluginOptions,
2707
+ ...data.contentType.options
2731
2708
  }
2732
2709
  };
2733
- const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published");
2734
- if (!showUnpublishButton)
2735
- return null;
2710
+ };
2711
+ const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
2712
+ return rows.map(
2713
+ (row) => row.map((field) => {
2714
+ const attribute = attributes[field.name];
2715
+ if (!attribute) {
2716
+ return null;
2717
+ }
2718
+ const { edit: metadata } = metadatas[field.name];
2719
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2720
+ return {
2721
+ attribute,
2722
+ disabled: !metadata.editable,
2723
+ hint: metadata.description,
2724
+ label: metadata.label ?? "",
2725
+ name: field.name,
2726
+ // @ts-expect-error – mainField does exist on the metadata for a relation.
2727
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2728
+ schemas,
2729
+ components: components?.schemas ?? {}
2730
+ }),
2731
+ placeholder: metadata.placeholder ?? "",
2732
+ required: attribute.required ?? false,
2733
+ size: field.size,
2734
+ unique: "unique" in attribute ? attribute.unique : false,
2735
+ visible: metadata.visible ?? true,
2736
+ type: attribute.type
2737
+ };
2738
+ }).filter((field) => field !== null)
2739
+ );
2740
+ };
2741
+ const formatListLayout = (data, {
2742
+ schemas,
2743
+ schema,
2744
+ components
2745
+ }) => {
2746
+ const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
2747
+ (acc, [attribute, metadata]) => {
2748
+ return {
2749
+ ...acc,
2750
+ [attribute]: metadata.list
2751
+ };
2752
+ },
2753
+ {}
2754
+ );
2755
+ const listAttributes = convertListLayoutToFieldLayouts(
2756
+ data.contentType.layouts.list,
2757
+ schema?.attributes,
2758
+ listMetadatas,
2759
+ { configurations: data.components, schemas: components },
2760
+ schemas
2761
+ );
2736
2762
  return {
2737
- variant: "tertiary",
2738
- label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
2739
- dialog: {
2740
- type: "dialog",
2741
- title: formatMessage({
2742
- id: "app.components.ConfirmDialog.title",
2743
- defaultMessage: "Confirmation"
2744
- }),
2745
- content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
2746
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
2747
- id: "popUpWarning.bodyMessage.contentType.unpublish.all",
2748
- defaultMessage: "Are you sure you want to unpublish these entries?"
2749
- }) }),
2750
- hasI18nEnabled && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { textAlign: "center", padding: 3, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", children: formatMessage(
2751
- {
2752
- id: getTranslation("Settings.list.actions.unpublishAdditionalInfos"),
2753
- defaultMessage: "This will unpublish the active locale versions <em>(from Internationalization)</em>"
2754
- },
2755
- {
2756
- em: Emphasis
2757
- }
2758
- ) }) })
2759
- ] }),
2760
- confirmButton: formatMessage({
2761
- id: "app.utils.unpublish",
2762
- defaultMessage: "Unpublish"
2763
- }),
2764
- onConfirm: handleConfirmBulkUnpublish
2763
+ layout: listAttributes,
2764
+ settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
2765
+ metadatas: listMetadatas,
2766
+ options: {
2767
+ ...schema?.options,
2768
+ ...schema?.pluginOptions,
2769
+ ...data.contentType.options
2765
2770
  }
2766
2771
  };
2767
2772
  };
2768
- UnpublishAction.type = "unpublish";
2769
- const Emphasis = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", textColor: "danger500", children: chunks });
2770
- const DEFAULT_BULK_ACTIONS = [UnpublishAction, DeleteAction];
2771
- const AutoCloneFailureModalBody = ({ prohibitedFields }) => {
2772
- const { formatMessage } = reactIntl.useIntl();
2773
- const getDefaultErrorMessage = (reason) => {
2774
- switch (reason) {
2775
- case "relation":
2776
- return "Duplicating the relation could remove it from the original entry.";
2777
- case "unique":
2778
- return "Identical values in a unique field are not allowed";
2779
- default:
2780
- return reason;
2781
- }
2782
- };
2783
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2784
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: formatMessage({
2785
- id: getTranslation("containers.list.autoCloneModal.title"),
2786
- defaultMessage: "This entry can't be duplicated directly."
2787
- }) }),
2788
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({
2789
- id: getTranslation("containers.list.autoCloneModal.description"),
2790
- defaultMessage: "A new entry will be created with the same content, but you'll have to change the following fields to save it."
2791
- }) }) }),
2792
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { marginTop: 6, gap: 2, direction: "column", alignItems: "stretch", children: prohibitedFields.map(([fieldPath, reason]) => /* @__PURE__ */ jsxRuntime.jsxs(
2793
- designSystem.Flex,
2794
- {
2795
- direction: "column",
2796
- gap: 2,
2797
- alignItems: "flex-start",
2798
- borderColor: "neutral200",
2799
- hasRadius: true,
2800
- padding: 6,
2801
- children: [
2802
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "row", tag: "ol", children: fieldPath.map((pathSegment, index2) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { fontWeight: "semiBold", tag: "li", children: [
2803
- pathSegment,
2804
- index2 !== fieldPath.length - 1 && /* @__PURE__ */ jsxRuntime.jsx(
2805
- Icons.ChevronRight,
2806
- {
2807
- fill: "neutral500",
2808
- height: "0.8rem",
2809
- width: "0.8rem",
2810
- style: { margin: "0 0.8rem" }
2811
- }
2812
- )
2813
- ] }, index2)) }),
2814
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", textColor: "neutral600", children: formatMessage({
2815
- id: getTranslation(`containers.list.autoCloneModal.error.${reason}`),
2816
- defaultMessage: getDefaultErrorMessage(reason)
2817
- }) })
2818
- ]
2819
- },
2820
- fieldPath.join()
2821
- )) })
2822
- ] });
2823
- };
2824
- const TableActions = ({ document }) => {
2825
- const { formatMessage } = reactIntl.useIntl();
2826
- const { model, collectionType } = useDoc();
2827
- const plugins = strapiAdmin.useStrapiApp("TableActions", (state) => state.plugins);
2828
- const props = {
2829
- activeTab: null,
2830
- model,
2831
- documentId: document.documentId,
2832
- collectionType,
2833
- document
2834
- };
2835
- return /* @__PURE__ */ jsxRuntime.jsx(
2836
- strapiAdmin.DescriptionComponentRenderer,
2837
- {
2838
- props,
2839
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
2840
- children: (actions2) => {
2841
- const tableRowActions = actions2.filter((action) => {
2842
- const positions = Array.isArray(action.position) ? action.position : [action.position];
2843
- return positions.includes("table-row");
2844
- });
2845
- return /* @__PURE__ */ jsxRuntime.jsx(
2846
- DocumentActionsMenu,
2847
- {
2848
- actions: tableRowActions,
2849
- label: formatMessage({
2850
- id: "content-manager.containers.list.table.row-actions",
2851
- defaultMessage: "Row action"
2852
- }),
2853
- variant: "ghost"
2854
- }
2855
- );
2856
- }
2857
- }
2858
- );
2859
- };
2860
- const EditAction = ({ documentId }) => {
2861
- const navigate = reactRouterDom.useNavigate();
2862
- const { formatMessage } = reactIntl.useIntl();
2863
- const { canRead } = useDocumentRBAC("EditAction", ({ canRead: canRead2 }) => ({ canRead: canRead2 }));
2864
- const { toggleNotification } = strapiAdmin.useNotification();
2865
- const [{ query }] = strapiAdmin.useQueryParams();
2866
- return {
2867
- disabled: !canRead,
2868
- icon: /* @__PURE__ */ jsxRuntime.jsx(StyledPencil, {}),
2869
- label: formatMessage({
2870
- id: "content-manager.actions.edit.label",
2871
- defaultMessage: "Edit"
2872
- }),
2873
- position: "table-row",
2874
- onClick: async () => {
2875
- if (!documentId) {
2876
- console.error(
2877
- "You're trying to edit a document without an id, this is likely a bug with Strapi. Please open an issue."
2878
- );
2879
- toggleNotification({
2880
- message: formatMessage({
2881
- id: "content-manager.actions.edit.error",
2882
- defaultMessage: "An error occurred while trying to edit the document."
2883
- }),
2884
- type: "danger"
2885
- });
2886
- return;
2887
- }
2888
- navigate({
2889
- pathname: documentId,
2890
- search: qs.stringify({
2891
- plugins: query.plugins
2892
- })
2893
- });
2894
- }
2895
- };
2896
- };
2897
- EditAction.type = "edit";
2898
- const StyledPencil = styledComponents.styled(Icons.Pencil)`
2899
- path {
2900
- fill: currentColor;
2901
- }
2902
- `;
2903
- const CloneAction = ({ model, documentId }) => {
2904
- const navigate = reactRouterDom.useNavigate();
2905
- const { formatMessage } = reactIntl.useIntl();
2906
- const { canCreate } = useDocumentRBAC("CloneAction", ({ canCreate: canCreate2 }) => ({ canCreate: canCreate2 }));
2907
- const { toggleNotification } = strapiAdmin.useNotification();
2908
- const { autoClone } = useDocumentActions();
2909
- const [prohibitedFields, setProhibitedFields] = React__namespace.useState([]);
2910
- return {
2911
- disabled: !canCreate,
2912
- icon: /* @__PURE__ */ jsxRuntime.jsx(StyledDuplicate, {}),
2913
- label: formatMessage({
2914
- id: "content-manager.actions.clone.label",
2915
- defaultMessage: "Duplicate"
2916
- }),
2917
- position: "table-row",
2918
- onClick: async () => {
2919
- if (!documentId) {
2920
- console.error(
2921
- "You're trying to clone a document in the table without an id, this is likely a bug with Strapi. Please open an issue."
2922
- );
2923
- toggleNotification({
2924
- message: formatMessage({
2925
- id: "content-manager.actions.clone.error",
2926
- defaultMessage: "An error occurred while trying to clone the document."
2927
- }),
2928
- type: "danger"
2929
- });
2930
- return;
2931
- }
2932
- const res = await autoClone({ model, sourceId: documentId });
2933
- if ("data" in res) {
2934
- navigate(res.data.documentId);
2935
- return true;
2936
- }
2937
- if (isBaseQueryError(res.error) && res.error.details && typeof res.error.details === "object" && "prohibitedFields" in res.error.details && Array.isArray(res.error.details.prohibitedFields)) {
2938
- const prohibitedFields2 = res.error.details.prohibitedFields;
2939
- setProhibitedFields(prohibitedFields2);
2940
- }
2941
- },
2942
- dialog: {
2943
- type: "modal",
2944
- title: formatMessage({
2945
- id: "content-manager.containers.list.autoCloneModal.header",
2946
- defaultMessage: "Duplicate"
2947
- }),
2948
- content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
2949
- footer: ({ onClose }) => {
2950
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
2951
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
2952
- id: "cancel",
2953
- defaultMessage: "Cancel"
2954
- }) }),
2955
- /* @__PURE__ */ jsxRuntime.jsx(
2956
- designSystem.LinkButton,
2957
- {
2958
- tag: reactRouterDom.NavLink,
2959
- to: {
2960
- pathname: `clone/${documentId}`
2961
- },
2962
- children: formatMessage({
2963
- id: "content-manager.containers.list.autoCloneModal.create",
2964
- defaultMessage: "Create"
2965
- })
2966
- }
2967
- )
2968
- ] });
2969
- }
2970
- }
2971
- };
2972
- };
2973
- CloneAction.type = "clone";
2974
- const StyledDuplicate = styledComponents.styled(Icons.Duplicate)`
2975
- path {
2976
- fill: currentColor;
2977
- }
2978
- `;
2979
- const DEFAULT_TABLE_ROW_ACTIONS = [EditAction, CloneAction];
2980
- class ContentManagerPlugin {
2981
- /**
2982
- * The following properties are the stored ones provided by any plugins registering with
2983
- * the content-manager. The function calls however, need to be called at runtime in the
2984
- * application, so instead we collate them and run them later with the complete list incl.
2985
- * ones already registered & the context of the view.
2986
- */
2987
- bulkActions = [...DEFAULT_BULK_ACTIONS];
2988
- documentActions = [
2989
- ...DEFAULT_ACTIONS,
2990
- ...DEFAULT_TABLE_ROW_ACTIONS,
2991
- ...DEFAULT_HEADER_ACTIONS,
2992
- HistoryAction
2993
- ];
2994
- editViewSidePanels = [ActionsPanel];
2995
- headerActions = [];
2996
- constructor() {
2997
- }
2998
- addEditViewSidePanel(panels) {
2999
- if (Array.isArray(panels)) {
3000
- this.editViewSidePanels = [...this.editViewSidePanels, ...panels];
3001
- } else if (typeof panels === "function") {
3002
- this.editViewSidePanels = panels(this.editViewSidePanels);
3003
- } else {
3004
- throw new Error(
3005
- `Expected the \`panels\` passed to \`addEditViewSidePanel\` to be an array or a function, but received ${getPrintableType(
3006
- panels
3007
- )}`
3008
- );
3009
- }
3010
- }
3011
- addDocumentAction(actions2) {
3012
- if (Array.isArray(actions2)) {
3013
- this.documentActions = [...this.documentActions, ...actions2];
3014
- } else if (typeof actions2 === "function") {
3015
- this.documentActions = actions2(this.documentActions);
3016
- } else {
3017
- throw new Error(
3018
- `Expected the \`actions\` passed to \`addDocumentAction\` to be an array or a function, but received ${getPrintableType(
3019
- actions2
3020
- )}`
3021
- );
3022
- }
3023
- }
3024
- addDocumentHeaderAction(actions2) {
3025
- if (Array.isArray(actions2)) {
3026
- this.headerActions = [...this.headerActions, ...actions2];
3027
- } else if (typeof actions2 === "function") {
3028
- this.headerActions = actions2(this.headerActions);
3029
- } else {
3030
- throw new Error(
3031
- `Expected the \`actions\` passed to \`addDocumentHeaderAction\` to be an array or a function, but received ${getPrintableType(
3032
- actions2
3033
- )}`
3034
- );
3035
- }
3036
- }
3037
- addBulkAction(actions2) {
3038
- if (Array.isArray(actions2)) {
3039
- this.bulkActions = [...this.bulkActions, ...actions2];
3040
- } else if (typeof actions2 === "function") {
3041
- this.bulkActions = actions2(this.bulkActions);
3042
- } else {
3043
- throw new Error(
3044
- `Expected the \`actions\` passed to \`addBulkAction\` to be an array or a function, but received ${getPrintableType(
3045
- actions2
3046
- )}`
3047
- );
2773
+ const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
2774
+ return columns.map((name) => {
2775
+ const attribute = attributes[name];
2776
+ if (!attribute) {
2777
+ return null;
3048
2778
  }
3049
- }
3050
- get config() {
2779
+ const metadata = metadatas[name];
2780
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
3051
2781
  return {
3052
- id: PLUGIN_ID,
3053
- name: "Content Manager",
3054
- injectionZones: INJECTION_ZONES,
3055
- apis: {
3056
- addBulkAction: this.addBulkAction.bind(this),
3057
- addDocumentAction: this.addDocumentAction.bind(this),
3058
- addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
3059
- addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
3060
- getBulkActions: () => this.bulkActions,
3061
- getDocumentActions: () => this.documentActions,
3062
- getEditViewSidePanels: () => this.editViewSidePanels,
3063
- getHeaderActions: () => this.headerActions
3064
- }
3065
- };
3066
- }
3067
- }
3068
- const getPrintableType = (value) => {
3069
- const nativeType = typeof value;
3070
- if (nativeType === "object") {
3071
- if (value === null)
3072
- return "null";
3073
- if (Array.isArray(value))
3074
- return "array";
3075
- if (value instanceof Object && value.constructor.name !== "Object") {
3076
- return value.constructor.name;
3077
- }
3078
- }
3079
- return nativeType;
3080
- };
3081
- const initialState = {
3082
- collectionTypeLinks: [],
3083
- components: [],
3084
- fieldSizes: {},
3085
- models: [],
3086
- singleTypeLinks: [],
3087
- isLoading: true
3088
- };
3089
- const appSlice = toolkit.createSlice({
3090
- name: "app",
3091
- initialState,
3092
- reducers: {
3093
- setInitialData(state, action) {
3094
- const {
3095
- authorizedCollectionTypeLinks,
3096
- authorizedSingleTypeLinks,
3097
- components,
3098
- contentTypeSchemas,
3099
- fieldSizes
3100
- } = action.payload;
3101
- state.collectionTypeLinks = authorizedCollectionTypeLinks.filter(
3102
- ({ isDisplayed }) => isDisplayed
3103
- );
3104
- state.singleTypeLinks = authorizedSingleTypeLinks.filter(({ isDisplayed }) => isDisplayed);
3105
- state.components = components;
3106
- state.models = contentTypeSchemas;
3107
- state.fieldSizes = fieldSizes;
3108
- state.isLoading = false;
3109
- }
3110
- }
3111
- });
3112
- const { actions, reducer: reducer$1 } = appSlice;
3113
- const { setInitialData } = actions;
3114
- const reducer = toolkit.combineReducers({
3115
- app: reducer$1
3116
- });
3117
- const HOOKS = {
3118
- /**
3119
- * Hook that allows to mutate the displayed headers of the list view table
3120
- * @constant
3121
- * @type {string}
3122
- */
3123
- INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
3124
- /**
3125
- * Hook that allows to mutate the CM's collection types links pre-set filters
3126
- * @constant
3127
- * @type {string}
3128
- */
3129
- MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
3130
- /**
3131
- * Hook that allows to mutate the CM's edit view layout
3132
- * @constant
3133
- * @type {string}
3134
- */
3135
- MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
3136
- /**
3137
- * Hook that allows to mutate the CM's single types links pre-set filters
3138
- * @constant
3139
- * @type {string}
3140
- */
3141
- MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
3142
- };
3143
- const contentTypesApi = contentManagerApi.injectEndpoints({
3144
- endpoints: (builder) => ({
3145
- getContentTypeConfiguration: builder.query({
3146
- query: (uid) => ({
3147
- url: `/content-manager/content-types/${uid}/configuration`,
3148
- method: "GET"
3149
- }),
3150
- transformResponse: (response) => response.data,
3151
- providesTags: (_result, _error, uid) => [
3152
- { type: "ContentTypesConfiguration", id: uid },
3153
- { type: "ContentTypeSettings", id: "LIST" }
3154
- ]
3155
- }),
3156
- getAllContentTypeSettings: builder.query({
3157
- query: () => "/content-manager/content-types-settings",
3158
- transformResponse: (response) => response.data,
3159
- providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
3160
- }),
3161
- updateContentTypeConfiguration: builder.mutation({
3162
- query: ({ uid, ...body }) => ({
3163
- url: `/content-manager/content-types/${uid}/configuration`,
3164
- method: "PUT",
3165
- data: body
2782
+ attribute,
2783
+ label: metadata.label ?? "",
2784
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2785
+ schemas,
2786
+ components: components?.schemas ?? {}
3166
2787
  }),
3167
- transformResponse: (response) => response.data,
3168
- invalidatesTags: (_result, _error, { uid }) => [
3169
- { type: "ContentTypesConfiguration", id: uid },
3170
- { type: "ContentTypeSettings", id: "LIST" },
3171
- // Is this necessary?
3172
- { type: "InitialData" }
3173
- ]
3174
- })
3175
- })
3176
- });
3177
- const {
3178
- useGetContentTypeConfigurationQuery,
3179
- useGetAllContentTypeSettingsQuery,
3180
- useUpdateContentTypeConfigurationMutation
3181
- } = contentTypesApi;
3182
- const checkIfAttributeIsDisplayable = (attribute) => {
3183
- const { type } = attribute;
3184
- if (type === "relation") {
3185
- return !attribute.relation.toLowerCase().includes("morph");
3186
- }
3187
- return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
3188
- };
3189
- const getMainField = (attribute, mainFieldName, { schemas, components }) => {
3190
- if (!mainFieldName) {
3191
- return void 0;
3192
- }
3193
- const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
3194
- // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
3195
- schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
3196
- );
3197
- return {
3198
- name: mainFieldName,
3199
- type: mainFieldType ?? "string"
3200
- };
3201
- };
3202
- const DEFAULT_SETTINGS = {
3203
- bulkable: false,
3204
- filterable: false,
3205
- searchable: false,
3206
- pagination: false,
3207
- defaultSortBy: "",
3208
- defaultSortOrder: "asc",
3209
- mainField: "id",
3210
- pageSize: 10
3211
- };
3212
- const useDocumentLayout = (model) => {
3213
- const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
3214
- const [{ query }] = strapiAdmin.useQueryParams();
3215
- const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
2788
+ name,
2789
+ searchable: metadata.searchable ?? true,
2790
+ sortable: metadata.sortable ?? true
2791
+ };
2792
+ }).filter((field) => field !== null);
2793
+ };
2794
+ const ConfirmBulkActionDialog = ({
2795
+ onToggleDialog,
2796
+ isOpen = false,
2797
+ dialogBody,
2798
+ endAction
2799
+ }) => {
2800
+ const { formatMessage } = reactIntl.useIntl();
2801
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { onOpenChange: onToggleDialog, open: isOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
2802
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage({
2803
+ id: "app.components.ConfirmDialog.title",
2804
+ defaultMessage: "Confirmation"
2805
+ }) }),
2806
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
2807
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
2808
+ dialogBody
2809
+ ] }) }),
2810
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
2811
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
2812
+ id: "app.components.Button.cancel",
2813
+ defaultMessage: "Cancel"
2814
+ }) }) }),
2815
+ endAction
2816
+ ] })
2817
+ ] }) });
2818
+ };
2819
+ const BoldChunk$1 = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
2820
+ const ConfirmDialogPublishAll = ({
2821
+ isOpen,
2822
+ onToggleDialog,
2823
+ isConfirmButtonLoading = false,
2824
+ onConfirm
2825
+ }) => {
2826
+ const { formatMessage } = reactIntl.useIntl();
2827
+ const selectedEntries = strapiAdmin.useTable("ConfirmDialogPublishAll", (state) => state.selectedRows);
3216
2828
  const { toggleNotification } = strapiAdmin.useNotification();
3217
- const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
3218
- const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
2829
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler(getTranslation);
2830
+ const { model, schema } = useDoc();
2831
+ const [{ query }] = strapiAdmin.useQueryParams();
3219
2832
  const {
3220
- data,
3221
- isLoading: isLoadingConfigs,
3222
- error,
3223
- isFetching: isFetchingConfigs
3224
- } = useGetContentTypeConfigurationQuery(model);
3225
- const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
2833
+ data: countDraftRelations = 0,
2834
+ isLoading,
2835
+ error
2836
+ } = useGetManyDraftRelationCountQuery(
2837
+ {
2838
+ model,
2839
+ documentIds: selectedEntries.map((entry) => entry.documentId),
2840
+ locale: query?.plugins?.i18n?.locale
2841
+ },
2842
+ {
2843
+ skip: selectedEntries.length === 0
2844
+ }
2845
+ );
3226
2846
  React__namespace.useEffect(() => {
3227
2847
  if (error) {
3228
- toggleNotification({
3229
- type: "danger",
3230
- message: formatAPIError(error)
3231
- });
2848
+ toggleNotification({ type: "danger", message: formatAPIError(error) });
3232
2849
  }
3233
2850
  }, [error, formatAPIError, toggleNotification]);
3234
- const editLayout = React__namespace.useMemo(
3235
- () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
3236
- layout: [],
3237
- components: {},
3238
- metadatas: {},
3239
- options: {},
3240
- settings: DEFAULT_SETTINGS
2851
+ if (error) {
2852
+ return null;
2853
+ }
2854
+ return /* @__PURE__ */ jsxRuntime.jsx(
2855
+ ConfirmBulkActionDialog,
2856
+ {
2857
+ isOpen: isOpen && !isLoading,
2858
+ onToggleDialog,
2859
+ dialogBody: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2860
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: [
2861
+ countDraftRelations > 0 && formatMessage(
2862
+ {
2863
+ id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
2864
+ defaultMessage: "<b>{count} {count, plural, one { relation } other { relations } } out of {entities} { entities, plural, one { entry } other { entries } } {count, plural, one { is } other { are } }</b> not published yet and might lead to unexpected behavior. "
2865
+ },
2866
+ {
2867
+ b: BoldChunk$1,
2868
+ count: countDraftRelations,
2869
+ entities: selectedEntries.length
2870
+ }
2871
+ ),
2872
+ formatMessage({
2873
+ id: getTranslation("popUpWarning.bodyMessage.contentType.publish.all"),
2874
+ defaultMessage: "Are you sure you want to publish these entries?"
2875
+ })
2876
+ ] }),
2877
+ schema?.pluginOptions && "i18n" in schema.pluginOptions && schema?.pluginOptions.i18n && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", textAlign: "center", children: formatMessage(
2878
+ {
2879
+ id: getTranslation("Settings.list.actions.publishAdditionalInfos"),
2880
+ defaultMessage: "This will publish the active locale versions <em>(from Internationalization)</em>"
2881
+ },
2882
+ {
2883
+ em: Emphasis
2884
+ }
2885
+ ) })
2886
+ ] }),
2887
+ endAction: /* @__PURE__ */ jsxRuntime.jsx(
2888
+ designSystem.Button,
2889
+ {
2890
+ onClick: onConfirm,
2891
+ variant: "secondary",
2892
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Check, {}),
2893
+ loading: isConfirmButtonLoading,
2894
+ children: formatMessage({
2895
+ id: "app.utils.publish",
2896
+ defaultMessage: "Publish"
2897
+ })
2898
+ }
2899
+ )
2900
+ }
2901
+ );
2902
+ };
2903
+ const TypographyMaxWidth = styledComponents.styled(designSystem.Typography)`
2904
+ max-width: 300px;
2905
+ `;
2906
+ const formatErrorMessages = (errors, parentKey, formatMessage) => {
2907
+ const messages = [];
2908
+ Object.entries(errors).forEach(([key, value]) => {
2909
+ const currentKey = parentKey ? `${parentKey}.${key}` : key;
2910
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
2911
+ if ("id" in value && "defaultMessage" in value) {
2912
+ messages.push(
2913
+ formatMessage(
2914
+ {
2915
+ id: `${value.id}.withField`,
2916
+ defaultMessage: value.defaultMessage
2917
+ },
2918
+ { field: currentKey }
2919
+ )
2920
+ );
2921
+ } else {
2922
+ messages.push(...formatErrorMessages(value, currentKey, formatMessage));
2923
+ }
2924
+ } else {
2925
+ messages.push(
2926
+ formatMessage(
2927
+ {
2928
+ id: `${value}.withField`,
2929
+ defaultMessage: value
2930
+ },
2931
+ { field: currentKey }
2932
+ )
2933
+ );
2934
+ }
2935
+ });
2936
+ return messages;
2937
+ };
2938
+ const EntryValidationText = ({ validationErrors, status }) => {
2939
+ const { formatMessage } = reactIntl.useIntl();
2940
+ if (validationErrors) {
2941
+ const validationErrorsMessages = formatErrorMessages(validationErrors, "", formatMessage).join(
2942
+ " "
2943
+ );
2944
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
2945
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.CrossCircle, { fill: "danger600" }),
2946
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { description: validationErrorsMessages, children: /* @__PURE__ */ jsxRuntime.jsx(TypographyMaxWidth, { textColor: "danger600", variant: "omega", fontWeight: "semiBold", ellipsis: true, children: validationErrorsMessages }) })
2947
+ ] });
2948
+ }
2949
+ if (status === "published") {
2950
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
2951
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.CheckCircle, { fill: "success600" }),
2952
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "success600", fontWeight: "bold", children: formatMessage({
2953
+ id: "content-manager.bulk-publish.already-published",
2954
+ defaultMessage: "Already Published"
2955
+ }) })
2956
+ ] });
2957
+ }
2958
+ if (status === "modified") {
2959
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
2960
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.ArrowsCounterClockwise, { fill: "alternative600" }),
2961
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
2962
+ id: "content-manager.bulk-publish.modified",
2963
+ defaultMessage: "Ready to publish changes"
2964
+ }) })
2965
+ ] });
2966
+ }
2967
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
2968
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.CheckCircle, { fill: "success600" }),
2969
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
2970
+ id: "app.utils.ready-to-publish",
2971
+ defaultMessage: "Ready to publish"
2972
+ }) })
2973
+ ] });
2974
+ };
2975
+ const TABLE_HEADERS = [
2976
+ { name: "id", label: "id" },
2977
+ { name: "name", label: "name" },
2978
+ { name: "status", label: "status" },
2979
+ { name: "publicationStatus", label: "Publication status" }
2980
+ ];
2981
+ const SelectedEntriesTableContent = ({
2982
+ isPublishing,
2983
+ rowsToDisplay = [],
2984
+ entriesToPublish = [],
2985
+ validationErrors = {}
2986
+ }) => {
2987
+ const { pathname } = reactRouterDom.useLocation();
2988
+ const { formatMessage } = reactIntl.useIntl();
2989
+ const {
2990
+ list: {
2991
+ settings: { mainField }
2992
+ }
2993
+ } = useDocLayout();
2994
+ const shouldDisplayMainField = mainField != null && mainField !== "id";
2995
+ return /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Content, { children: [
2996
+ /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Head, { children: [
2997
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.HeaderCheckboxCell, {}),
2998
+ TABLE_HEADERS.filter((head) => head.name !== "name" || shouldDisplayMainField).map(
2999
+ (head) => /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.HeaderCell, { ...head }, head.name)
3000
+ )
3001
+ ] }),
3002
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Loading, {}),
3003
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Body, { children: rowsToDisplay.map((row, index2) => /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Row, { children: [
3004
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.CheckboxCell, { id: row.id }),
3005
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: row.id }) }),
3006
+ shouldDisplayMainField && /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: row[mainField] }) }),
3007
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: row.status, maxWidth: "min-content" }) }),
3008
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: isPublishing && entriesToPublish.includes(row.documentId) ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
3009
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
3010
+ id: "content-manager.success.record.publishing",
3011
+ defaultMessage: "Publishing..."
3012
+ }) }),
3013
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true })
3014
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(
3015
+ EntryValidationText,
3016
+ {
3017
+ validationErrors: validationErrors[row.documentId],
3018
+ status: row.status
3019
+ }
3020
+ ) }),
3021
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
3022
+ designSystem.IconButton,
3023
+ {
3024
+ tag: reactRouterDom.Link,
3025
+ to: {
3026
+ pathname: `${pathname}/${row.documentId}`,
3027
+ search: row.locale && `?plugins[i18n][locale]=${row.locale}`
3028
+ },
3029
+ state: { from: pathname },
3030
+ label: formatMessage(
3031
+ { id: "app.component.HelperPluginTable.edit", defaultMessage: "Edit {target}" },
3032
+ {
3033
+ target: formatMessage(
3034
+ {
3035
+ id: "content-manager.components.ListViewHelperPluginTable.row-line",
3036
+ defaultMessage: "item line {number}"
3037
+ },
3038
+ { number: index2 + 1 }
3039
+ )
3040
+ }
3041
+ ),
3042
+ target: "_blank",
3043
+ marginLeft: "auto",
3044
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {})
3045
+ }
3046
+ ) })
3047
+ ] }, row.id)) })
3048
+ ] });
3049
+ };
3050
+ const BoldChunk = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
3051
+ const SelectedEntriesModalContent = ({
3052
+ listViewSelectedEntries,
3053
+ toggleModal,
3054
+ setListViewSelectedDocuments,
3055
+ model
3056
+ }) => {
3057
+ const { formatMessage } = reactIntl.useIntl();
3058
+ const { schema, components } = useContentTypeSchema(model);
3059
+ const documentIds = listViewSelectedEntries.map(({ documentId }) => documentId);
3060
+ const [{ query }] = strapiAdmin.useQueryParams();
3061
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
3062
+ const { data, isLoading, isFetching, refetch } = useGetAllDocumentsQuery(
3063
+ {
3064
+ model,
3065
+ params: {
3066
+ page: "1",
3067
+ pageSize: documentIds.length.toString(),
3068
+ sort: query.sort,
3069
+ filters: {
3070
+ documentId: {
3071
+ $in: documentIds
3072
+ }
3073
+ },
3074
+ locale: query.plugins?.i18n?.locale
3075
+ }
3241
3076
  },
3242
- [data, isLoading, schemas, schema, components]
3077
+ {
3078
+ selectFromResult: ({ data: data2, ...restRes }) => ({ data: data2?.results ?? [], ...restRes })
3079
+ }
3243
3080
  );
3244
- const listLayout = React__namespace.useMemo(() => {
3245
- return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
3246
- layout: [],
3247
- metadatas: {},
3248
- options: {},
3249
- settings: DEFAULT_SETTINGS
3081
+ const { rows, validationErrors } = React__namespace.useMemo(() => {
3082
+ if (data.length > 0 && schema) {
3083
+ const validate = createYupSchema(schema.attributes, components);
3084
+ const validationErrors2 = {};
3085
+ const rows2 = data.map((entry) => {
3086
+ try {
3087
+ validate.validateSync(entry, { abortEarly: false });
3088
+ return entry;
3089
+ } catch (e) {
3090
+ if (e instanceof yup.ValidationError) {
3091
+ validationErrors2[entry.documentId] = strapiAdmin.getYupValidationErrors(e);
3092
+ }
3093
+ return entry;
3094
+ }
3095
+ });
3096
+ return { rows: rows2, validationErrors: validationErrors2 };
3097
+ }
3098
+ return {
3099
+ rows: [],
3100
+ validationErrors: {}
3250
3101
  };
3251
- }, [data, isLoading, schemas, schema, components]);
3252
- const { layout: edit } = React__namespace.useMemo(
3253
- () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
3254
- layout: editLayout,
3255
- query
3256
- }),
3257
- [editLayout, query, runHookWaterfall]
3102
+ }, [components, data, schema]);
3103
+ const [publishedCount, setPublishedCount] = React__namespace.useState(0);
3104
+ const [isDialogOpen, setIsDialogOpen] = React__namespace.useState(false);
3105
+ const { publishMany: bulkPublishAction } = useDocumentActions();
3106
+ const [, { isLoading: isSubmittingForm }] = usePublishManyDocumentsMutation();
3107
+ const selectedRows = strapiAdmin.useTable("publishAction", (state) => state.selectedRows);
3108
+ const selectedEntries = rows.filter(
3109
+ (entry) => selectedRows.some((selectedEntry) => selectedEntry.documentId === entry.documentId)
3258
3110
  );
3111
+ const entriesToPublish = selectedEntries.filter((entry) => !validationErrors[entry.documentId]).map((entry) => entry.documentId);
3112
+ const selectedEntriesWithErrorsCount = selectedEntries.filter(
3113
+ ({ documentId }) => validationErrors[documentId]
3114
+ ).length;
3115
+ const selectedEntriesPublished = selectedEntries.filter(
3116
+ ({ status }) => status === "published"
3117
+ ).length;
3118
+ const selectedEntriesWithNoErrorsCount = selectedEntries.length - selectedEntriesWithErrorsCount - selectedEntriesPublished;
3119
+ const toggleDialog = () => setIsDialogOpen((prev) => !prev);
3120
+ const handleConfirmBulkPublish = async () => {
3121
+ toggleDialog();
3122
+ const res = await bulkPublishAction({ model, documentIds: entriesToPublish, params });
3123
+ if (!("error" in res)) {
3124
+ setPublishedCount(res.count);
3125
+ const unpublishedEntries = rows.filter((row) => {
3126
+ return !entriesToPublish.includes(row.documentId);
3127
+ });
3128
+ setListViewSelectedDocuments(unpublishedEntries);
3129
+ }
3130
+ };
3131
+ const getFormattedCountMessage = () => {
3132
+ if (publishedCount) {
3133
+ return formatMessage(
3134
+ {
3135
+ id: getTranslation("containers.list.selectedEntriesModal.publishedCount"),
3136
+ defaultMessage: "<b>{publishedCount}</b> {publishedCount, plural, =0 {entries} one {entry} other {entries}} published. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action."
3137
+ },
3138
+ {
3139
+ publishedCount,
3140
+ withErrorsCount: selectedEntriesWithErrorsCount,
3141
+ b: BoldChunk
3142
+ }
3143
+ );
3144
+ }
3145
+ return formatMessage(
3146
+ {
3147
+ id: getTranslation("containers.list.selectedEntriesModal.selectedCount"),
3148
+ defaultMessage: "<b>{alreadyPublishedCount}</b> {alreadyPublishedCount, plural, =0 {entries} one {entry} other {entries}} already published. <b>{readyToPublishCount}</b> {readyToPublishCount, plural, =0 {entries} one {entry} other {entries}} ready to publish. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action."
3149
+ },
3150
+ {
3151
+ readyToPublishCount: selectedEntriesWithNoErrorsCount,
3152
+ withErrorsCount: selectedEntriesWithErrorsCount,
3153
+ alreadyPublishedCount: selectedEntriesPublished,
3154
+ b: BoldChunk
3155
+ }
3156
+ );
3157
+ };
3158
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3159
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Body, { children: [
3160
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: getFormattedCountMessage() }),
3161
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
3162
+ SelectedEntriesTableContent,
3163
+ {
3164
+ isPublishing: isSubmittingForm,
3165
+ rowsToDisplay: rows,
3166
+ entriesToPublish,
3167
+ validationErrors
3168
+ }
3169
+ ) })
3170
+ ] }),
3171
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
3172
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
3173
+ id: "app.components.Button.cancel",
3174
+ defaultMessage: "Cancel"
3175
+ }) }),
3176
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
3177
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
3178
+ /* @__PURE__ */ jsxRuntime.jsx(
3179
+ designSystem.Button,
3180
+ {
3181
+ onClick: toggleDialog,
3182
+ disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublished === selectedEntries.length || isLoading,
3183
+ loading: isSubmittingForm,
3184
+ children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
3185
+ }
3186
+ )
3187
+ ] })
3188
+ ] }),
3189
+ /* @__PURE__ */ jsxRuntime.jsx(
3190
+ ConfirmDialogPublishAll,
3191
+ {
3192
+ isOpen: isDialogOpen,
3193
+ onToggleDialog: toggleDialog,
3194
+ isConfirmButtonLoading: isSubmittingForm,
3195
+ onConfirm: handleConfirmBulkPublish
3196
+ }
3197
+ )
3198
+ ] });
3199
+ };
3200
+ const PublishAction = ({ documents, model }) => {
3201
+ const { formatMessage } = reactIntl.useIntl();
3202
+ const hasPublishPermission = useDocumentRBAC("unpublishAction", (state) => state.canPublish);
3203
+ const showPublishButton = hasPublishPermission && documents.some(({ status }) => status !== "published");
3204
+ const setListViewSelectedDocuments = strapiAdmin.useTable("publishAction", (state) => state.selectRow);
3205
+ const refetchList = () => {
3206
+ contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
3207
+ };
3208
+ if (!showPublishButton)
3209
+ return null;
3210
+ return {
3211
+ actionType: "publish",
3212
+ variant: "tertiary",
3213
+ label: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" }),
3214
+ dialog: {
3215
+ type: "modal",
3216
+ title: formatMessage({
3217
+ id: getTranslation("containers.ListPage.selectedEntriesModal.title"),
3218
+ defaultMessage: "Publish entries"
3219
+ }),
3220
+ content: ({ onClose }) => {
3221
+ return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Root, { rows: documents, defaultSelectedRows: documents, headers: TABLE_HEADERS, children: /* @__PURE__ */ jsxRuntime.jsx(
3222
+ SelectedEntriesModalContent,
3223
+ {
3224
+ listViewSelectedEntries: documents,
3225
+ toggleModal: () => {
3226
+ onClose();
3227
+ refetchList();
3228
+ },
3229
+ setListViewSelectedDocuments,
3230
+ model
3231
+ }
3232
+ ) });
3233
+ },
3234
+ onClose: () => {
3235
+ refetchList();
3236
+ }
3237
+ }
3238
+ };
3239
+ };
3240
+ const BulkActionsRenderer = () => {
3241
+ const plugins = strapiAdmin.useStrapiApp("BulkActionsRenderer", (state) => state.plugins);
3242
+ const { model, collectionType } = useDoc();
3243
+ const { selectedRows } = strapiAdmin.useTable("BulkActionsRenderer", (state) => state);
3244
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
3245
+ strapiAdmin.DescriptionComponentRenderer,
3246
+ {
3247
+ props: {
3248
+ model,
3249
+ collectionType,
3250
+ documents: selectedRows
3251
+ },
3252
+ descriptions: plugins["content-manager"].apis.getBulkActions(),
3253
+ children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActionButton, { ...action }, action.id))
3254
+ }
3255
+ ) });
3256
+ };
3257
+ const DeleteAction = ({ documents, model }) => {
3258
+ const { formatMessage } = reactIntl.useIntl();
3259
+ const { schema: contentType } = useDoc();
3260
+ const selectRow = strapiAdmin.useTable("DeleteAction", (state) => state.selectRow);
3261
+ const hasI18nEnabled = Boolean(contentType?.pluginOptions?.i18n);
3262
+ const [{ query }] = strapiAdmin.useQueryParams();
3263
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
3264
+ const hasDeletePermission = useDocumentRBAC("deleteAction", (state) => state.canDelete);
3265
+ const { deleteMany: bulkDeleteAction } = useDocumentActions();
3266
+ const documentIds = documents.map(({ documentId }) => documentId);
3267
+ const handleConfirmBulkDelete = async () => {
3268
+ const res = await bulkDeleteAction({
3269
+ documentIds,
3270
+ model,
3271
+ params
3272
+ });
3273
+ if (!("error" in res)) {
3274
+ selectRow([]);
3275
+ }
3276
+ };
3277
+ if (!hasDeletePermission)
3278
+ return null;
3279
+ return {
3280
+ variant: "danger-light",
3281
+ label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
3282
+ dialog: {
3283
+ type: "dialog",
3284
+ title: formatMessage({
3285
+ id: "app.components.ConfirmDialog.title",
3286
+ defaultMessage: "Confirmation"
3287
+ }),
3288
+ content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
3289
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
3290
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
3291
+ id: "popUpWarning.bodyMessage.contentType.delete.all",
3292
+ defaultMessage: "Are you sure you want to delete these entries?"
3293
+ }) }),
3294
+ hasI18nEnabled && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { textAlign: "center", padding: 3, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", children: formatMessage(
3295
+ {
3296
+ id: getTranslation("Settings.list.actions.deleteAdditionalInfos"),
3297
+ defaultMessage: "This will delete the active locale versions <em>(from Internationalization)</em>"
3298
+ },
3299
+ {
3300
+ em: Emphasis
3301
+ }
3302
+ ) }) })
3303
+ ] }),
3304
+ onConfirm: handleConfirmBulkDelete
3305
+ }
3306
+ };
3307
+ };
3308
+ DeleteAction.type = "delete";
3309
+ const UnpublishAction = ({ documents, model }) => {
3310
+ const { formatMessage } = reactIntl.useIntl();
3311
+ const { schema } = useDoc();
3312
+ const selectRow = strapiAdmin.useTable("UnpublishAction", (state) => state.selectRow);
3313
+ const hasPublishPermission = useDocumentRBAC("unpublishAction", (state) => state.canPublish);
3314
+ const hasI18nEnabled = Boolean(schema?.pluginOptions?.i18n);
3315
+ const hasDraftAndPublishEnabled = Boolean(schema?.options?.draftAndPublish);
3316
+ const { unpublishMany: bulkUnpublishAction } = useDocumentActions();
3317
+ const documentIds = documents.map(({ documentId }) => documentId);
3318
+ const [{ query }] = strapiAdmin.useQueryParams();
3319
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
3320
+ const handleConfirmBulkUnpublish = async () => {
3321
+ const data = await bulkUnpublishAction({ documentIds, model, params });
3322
+ if (!("error" in data)) {
3323
+ selectRow([]);
3324
+ }
3325
+ };
3326
+ const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
3327
+ if (!showUnpublishButton)
3328
+ return null;
3259
3329
  return {
3260
- error,
3261
- isLoading,
3262
- edit,
3263
- list: listLayout
3330
+ variant: "tertiary",
3331
+ label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
3332
+ dialog: {
3333
+ type: "dialog",
3334
+ title: formatMessage({
3335
+ id: "app.components.ConfirmDialog.title",
3336
+ defaultMessage: "Confirmation"
3337
+ }),
3338
+ content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
3339
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
3340
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
3341
+ id: "popUpWarning.bodyMessage.contentType.unpublish.all",
3342
+ defaultMessage: "Are you sure you want to unpublish these entries?"
3343
+ }) }),
3344
+ hasI18nEnabled && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { textAlign: "center", padding: 3, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", children: formatMessage(
3345
+ {
3346
+ id: getTranslation("Settings.list.actions.unpublishAdditionalInfos"),
3347
+ defaultMessage: "This will unpublish the active locale versions <em>(from Internationalization)</em>"
3348
+ },
3349
+ {
3350
+ em: Emphasis
3351
+ }
3352
+ ) }) })
3353
+ ] }),
3354
+ confirmButton: formatMessage({
3355
+ id: "app.utils.unpublish",
3356
+ defaultMessage: "Unpublish"
3357
+ }),
3358
+ onConfirm: handleConfirmBulkUnpublish
3359
+ }
3264
3360
  };
3265
3361
  };
3266
- const useDocLayout = () => {
3267
- const { model } = useDoc();
3268
- return useDocumentLayout(model);
3362
+ UnpublishAction.type = "unpublish";
3363
+ const Emphasis = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", textColor: "danger500", children: chunks });
3364
+ const DEFAULT_BULK_ACTIONS = [PublishAction, UnpublishAction, DeleteAction];
3365
+ const AutoCloneFailureModalBody = ({ prohibitedFields }) => {
3366
+ const { formatMessage } = reactIntl.useIntl();
3367
+ const getDefaultErrorMessage = (reason) => {
3368
+ switch (reason) {
3369
+ case "relation":
3370
+ return "Duplicating the relation could remove it from the original entry.";
3371
+ case "unique":
3372
+ return "Identical values in a unique field are not allowed";
3373
+ default:
3374
+ return reason;
3375
+ }
3376
+ };
3377
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3378
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: formatMessage({
3379
+ id: getTranslation("containers.list.autoCloneModal.title"),
3380
+ defaultMessage: "This entry can't be duplicated directly."
3381
+ }) }),
3382
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({
3383
+ id: getTranslation("containers.list.autoCloneModal.description"),
3384
+ defaultMessage: "A new entry will be created with the same content, but you'll have to change the following fields to save it."
3385
+ }) }) }),
3386
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { marginTop: 6, gap: 2, direction: "column", alignItems: "stretch", children: prohibitedFields.map(([fieldPath, reason]) => /* @__PURE__ */ jsxRuntime.jsxs(
3387
+ designSystem.Flex,
3388
+ {
3389
+ direction: "column",
3390
+ gap: 2,
3391
+ alignItems: "flex-start",
3392
+ borderColor: "neutral200",
3393
+ hasRadius: true,
3394
+ padding: 6,
3395
+ children: [
3396
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "row", tag: "ol", children: fieldPath.map((pathSegment, index2) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { fontWeight: "semiBold", tag: "li", children: [
3397
+ pathSegment,
3398
+ index2 !== fieldPath.length - 1 && /* @__PURE__ */ jsxRuntime.jsx(
3399
+ Icons.ChevronRight,
3400
+ {
3401
+ fill: "neutral500",
3402
+ height: "0.8rem",
3403
+ width: "0.8rem",
3404
+ style: { margin: "0 0.8rem" }
3405
+ }
3406
+ )
3407
+ ] }, index2)) }),
3408
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", textColor: "neutral600", children: formatMessage({
3409
+ id: getTranslation(`containers.list.autoCloneModal.error.${reason}`),
3410
+ defaultMessage: getDefaultErrorMessage(reason)
3411
+ }) })
3412
+ ]
3413
+ },
3414
+ fieldPath.join()
3415
+ )) })
3416
+ ] });
3269
3417
  };
3270
- const formatEditLayout = (data, {
3271
- schemas,
3272
- schema,
3273
- components
3274
- }) => {
3275
- let currentPanelIndex = 0;
3276
- const panelledEditAttributes = convertEditLayoutToFieldLayouts(
3277
- data.contentType.layouts.edit,
3278
- schema?.attributes,
3279
- data.contentType.metadatas,
3280
- { configurations: data.components, schemas: components },
3281
- schemas
3282
- ).reduce((panels, row) => {
3283
- if (row.some((field) => field.type === "dynamiczone")) {
3284
- panels.push([row]);
3285
- currentPanelIndex += 2;
3286
- } else {
3287
- if (!panels[currentPanelIndex]) {
3288
- panels.push([]);
3418
+ const TableActions = ({ document }) => {
3419
+ const { formatMessage } = reactIntl.useIntl();
3420
+ const { model, collectionType } = useDoc();
3421
+ const plugins = strapiAdmin.useStrapiApp("TableActions", (state) => state.plugins);
3422
+ const props = {
3423
+ activeTab: null,
3424
+ model,
3425
+ documentId: document.documentId,
3426
+ collectionType,
3427
+ document
3428
+ };
3429
+ return /* @__PURE__ */ jsxRuntime.jsx(
3430
+ strapiAdmin.DescriptionComponentRenderer,
3431
+ {
3432
+ props,
3433
+ descriptions: plugins["content-manager"].apis.getDocumentActions(),
3434
+ children: (actions2) => {
3435
+ const tableRowActions = actions2.filter((action) => {
3436
+ const positions = Array.isArray(action.position) ? action.position : [action.position];
3437
+ return positions.includes("table-row");
3438
+ });
3439
+ return /* @__PURE__ */ jsxRuntime.jsx(
3440
+ DocumentActionsMenu,
3441
+ {
3442
+ actions: tableRowActions,
3443
+ label: formatMessage({
3444
+ id: "content-manager.containers.list.table.row-actions",
3445
+ defaultMessage: "Row action"
3446
+ }),
3447
+ variant: "ghost"
3448
+ }
3449
+ );
3289
3450
  }
3290
- panels[currentPanelIndex].push(row);
3291
3451
  }
3292
- return panels;
3293
- }, []);
3294
- const componentEditAttributes = Object.entries(data.components).reduce(
3295
- (acc, [uid, configuration]) => {
3296
- acc[uid] = {
3297
- layout: convertEditLayoutToFieldLayouts(
3298
- configuration.layouts.edit,
3299
- components[uid].attributes,
3300
- configuration.metadatas
3301
- ),
3302
- settings: {
3303
- ...configuration.settings,
3304
- icon: components[uid].info.icon,
3305
- displayName: components[uid].info.displayName
3306
- }
3307
- };
3308
- return acc;
3309
- },
3310
- {}
3311
- );
3312
- const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
3313
- (acc, [attribute, metadata]) => {
3314
- return {
3315
- ...acc,
3316
- [attribute]: metadata.edit
3317
- };
3318
- },
3319
- {}
3320
3452
  );
3453
+ };
3454
+ const EditAction = ({ documentId }) => {
3455
+ const navigate = reactRouterDom.useNavigate();
3456
+ const { formatMessage } = reactIntl.useIntl();
3457
+ const { canRead } = useDocumentRBAC("EditAction", ({ canRead: canRead2 }) => ({ canRead: canRead2 }));
3458
+ const { toggleNotification } = strapiAdmin.useNotification();
3459
+ const [{ query }] = strapiAdmin.useQueryParams();
3321
3460
  return {
3322
- layout: panelledEditAttributes,
3323
- components: componentEditAttributes,
3324
- metadatas: editMetadatas,
3325
- settings: {
3326
- ...data.contentType.settings,
3327
- displayName: schema?.info.displayName
3328
- },
3329
- options: {
3330
- ...schema?.options,
3331
- ...schema?.pluginOptions,
3332
- ...data.contentType.options
3461
+ disabled: !canRead,
3462
+ icon: /* @__PURE__ */ jsxRuntime.jsx(StyledPencil, {}),
3463
+ label: formatMessage({
3464
+ id: "content-manager.actions.edit.label",
3465
+ defaultMessage: "Edit"
3466
+ }),
3467
+ position: "table-row",
3468
+ onClick: async () => {
3469
+ if (!documentId) {
3470
+ console.error(
3471
+ "You're trying to edit a document without an id, this is likely a bug with Strapi. Please open an issue."
3472
+ );
3473
+ toggleNotification({
3474
+ message: formatMessage({
3475
+ id: "content-manager.actions.edit.error",
3476
+ defaultMessage: "An error occurred while trying to edit the document."
3477
+ }),
3478
+ type: "danger"
3479
+ });
3480
+ return;
3481
+ }
3482
+ navigate({
3483
+ pathname: documentId,
3484
+ search: qs.stringify({
3485
+ plugins: query.plugins
3486
+ })
3487
+ });
3333
3488
  }
3334
3489
  };
3335
3490
  };
3336
- const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
3337
- return rows.map(
3338
- (row) => row.map((field) => {
3339
- const attribute = attributes[field.name];
3340
- if (!attribute) {
3341
- return null;
3491
+ EditAction.type = "edit";
3492
+ const StyledPencil = styledComponents.styled(Icons.Pencil)`
3493
+ path {
3494
+ fill: currentColor;
3495
+ }
3496
+ `;
3497
+ const CloneAction = ({ model, documentId }) => {
3498
+ const navigate = reactRouterDom.useNavigate();
3499
+ const { formatMessage } = reactIntl.useIntl();
3500
+ const { canCreate } = useDocumentRBAC("CloneAction", ({ canCreate: canCreate2 }) => ({ canCreate: canCreate2 }));
3501
+ const { toggleNotification } = strapiAdmin.useNotification();
3502
+ const { autoClone } = useDocumentActions();
3503
+ const [prohibitedFields, setProhibitedFields] = React__namespace.useState([]);
3504
+ return {
3505
+ disabled: !canCreate,
3506
+ icon: /* @__PURE__ */ jsxRuntime.jsx(StyledDuplicate, {}),
3507
+ label: formatMessage({
3508
+ id: "content-manager.actions.clone.label",
3509
+ defaultMessage: "Duplicate"
3510
+ }),
3511
+ position: "table-row",
3512
+ onClick: async () => {
3513
+ if (!documentId) {
3514
+ console.error(
3515
+ "You're trying to clone a document in the table without an id, this is likely a bug with Strapi. Please open an issue."
3516
+ );
3517
+ toggleNotification({
3518
+ message: formatMessage({
3519
+ id: "content-manager.actions.clone.error",
3520
+ defaultMessage: "An error occurred while trying to clone the document."
3521
+ }),
3522
+ type: "danger"
3523
+ });
3524
+ return;
3525
+ }
3526
+ const res = await autoClone({ model, sourceId: documentId });
3527
+ if ("data" in res) {
3528
+ navigate(res.data.documentId);
3529
+ return true;
3530
+ }
3531
+ if (isBaseQueryError(res.error) && res.error.details && typeof res.error.details === "object" && "prohibitedFields" in res.error.details && Array.isArray(res.error.details.prohibitedFields)) {
3532
+ const prohibitedFields2 = res.error.details.prohibitedFields;
3533
+ setProhibitedFields(prohibitedFields2);
3342
3534
  }
3343
- const { edit: metadata } = metadatas[field.name];
3344
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
3345
- return {
3346
- attribute,
3347
- disabled: !metadata.editable,
3348
- hint: metadata.description,
3349
- label: metadata.label ?? "",
3350
- name: field.name,
3351
- // @ts-expect-error – mainField does exist on the metadata for a relation.
3352
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
3353
- schemas,
3354
- components: components?.schemas ?? {}
3355
- }),
3356
- placeholder: metadata.placeholder ?? "",
3357
- required: attribute.required ?? false,
3358
- size: field.size,
3359
- unique: "unique" in attribute ? attribute.unique : false,
3360
- visible: metadata.visible ?? true,
3361
- type: attribute.type
3362
- };
3363
- }).filter((field) => field !== null)
3364
- );
3365
- };
3366
- const formatListLayout = (data, {
3367
- schemas,
3368
- schema,
3369
- components
3370
- }) => {
3371
- const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
3372
- (acc, [attribute, metadata]) => {
3373
- return {
3374
- ...acc,
3375
- [attribute]: metadata.list
3376
- };
3377
3535
  },
3378
- {}
3379
- );
3380
- const listAttributes = convertListLayoutToFieldLayouts(
3381
- data.contentType.layouts.list,
3382
- schema?.attributes,
3383
- listMetadatas,
3384
- { configurations: data.components, schemas: components },
3385
- schemas
3386
- );
3387
- return {
3388
- layout: listAttributes,
3389
- settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
3390
- metadatas: listMetadatas,
3391
- options: {
3392
- ...schema?.options,
3393
- ...schema?.pluginOptions,
3394
- ...data.contentType.options
3536
+ dialog: {
3537
+ type: "modal",
3538
+ title: formatMessage({
3539
+ id: "content-manager.containers.list.autoCloneModal.header",
3540
+ defaultMessage: "Duplicate"
3541
+ }),
3542
+ content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
3543
+ footer: ({ onClose }) => {
3544
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
3545
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
3546
+ id: "cancel",
3547
+ defaultMessage: "Cancel"
3548
+ }) }),
3549
+ /* @__PURE__ */ jsxRuntime.jsx(
3550
+ designSystem.LinkButton,
3551
+ {
3552
+ tag: reactRouterDom.NavLink,
3553
+ to: {
3554
+ pathname: `clone/${documentId}`
3555
+ },
3556
+ children: formatMessage({
3557
+ id: "content-manager.containers.list.autoCloneModal.create",
3558
+ defaultMessage: "Create"
3559
+ })
3560
+ }
3561
+ )
3562
+ ] });
3563
+ }
3395
3564
  }
3396
3565
  };
3397
3566
  };
3398
- const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
3399
- return columns.map((name) => {
3400
- const attribute = attributes[name];
3401
- if (!attribute) {
3402
- return null;
3567
+ CloneAction.type = "clone";
3568
+ const StyledDuplicate = styledComponents.styled(Icons.Duplicate)`
3569
+ path {
3570
+ fill: currentColor;
3571
+ }
3572
+ `;
3573
+ const DEFAULT_TABLE_ROW_ACTIONS = [EditAction, CloneAction];
3574
+ class ContentManagerPlugin {
3575
+ /**
3576
+ * The following properties are the stored ones provided by any plugins registering with
3577
+ * the content-manager. The function calls however, need to be called at runtime in the
3578
+ * application, so instead we collate them and run them later with the complete list incl.
3579
+ * ones already registered & the context of the view.
3580
+ */
3581
+ bulkActions = [...DEFAULT_BULK_ACTIONS];
3582
+ documentActions = [
3583
+ ...DEFAULT_ACTIONS,
3584
+ ...DEFAULT_TABLE_ROW_ACTIONS,
3585
+ ...DEFAULT_HEADER_ACTIONS,
3586
+ HistoryAction
3587
+ ];
3588
+ editViewSidePanels = [ActionsPanel];
3589
+ headerActions = [];
3590
+ constructor() {
3591
+ }
3592
+ addEditViewSidePanel(panels) {
3593
+ if (Array.isArray(panels)) {
3594
+ this.editViewSidePanels = [...this.editViewSidePanels, ...panels];
3595
+ } else if (typeof panels === "function") {
3596
+ this.editViewSidePanels = panels(this.editViewSidePanels);
3597
+ } else {
3598
+ throw new Error(
3599
+ `Expected the \`panels\` passed to \`addEditViewSidePanel\` to be an array or a function, but received ${getPrintableType(
3600
+ panels
3601
+ )}`
3602
+ );
3403
3603
  }
3404
- const metadata = metadatas[name];
3405
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
3604
+ }
3605
+ addDocumentAction(actions2) {
3606
+ if (Array.isArray(actions2)) {
3607
+ this.documentActions = [...this.documentActions, ...actions2];
3608
+ } else if (typeof actions2 === "function") {
3609
+ this.documentActions = actions2(this.documentActions);
3610
+ } else {
3611
+ throw new Error(
3612
+ `Expected the \`actions\` passed to \`addDocumentAction\` to be an array or a function, but received ${getPrintableType(
3613
+ actions2
3614
+ )}`
3615
+ );
3616
+ }
3617
+ }
3618
+ addDocumentHeaderAction(actions2) {
3619
+ if (Array.isArray(actions2)) {
3620
+ this.headerActions = [...this.headerActions, ...actions2];
3621
+ } else if (typeof actions2 === "function") {
3622
+ this.headerActions = actions2(this.headerActions);
3623
+ } else {
3624
+ throw new Error(
3625
+ `Expected the \`actions\` passed to \`addDocumentHeaderAction\` to be an array or a function, but received ${getPrintableType(
3626
+ actions2
3627
+ )}`
3628
+ );
3629
+ }
3630
+ }
3631
+ addBulkAction(actions2) {
3632
+ if (Array.isArray(actions2)) {
3633
+ this.bulkActions = [...this.bulkActions, ...actions2];
3634
+ } else if (typeof actions2 === "function") {
3635
+ this.bulkActions = actions2(this.bulkActions);
3636
+ } else {
3637
+ throw new Error(
3638
+ `Expected the \`actions\` passed to \`addBulkAction\` to be an array or a function, but received ${getPrintableType(
3639
+ actions2
3640
+ )}`
3641
+ );
3642
+ }
3643
+ }
3644
+ get config() {
3406
3645
  return {
3407
- attribute,
3408
- label: metadata.label ?? "",
3409
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
3410
- schemas,
3411
- components: components?.schemas ?? {}
3412
- }),
3413
- name,
3414
- searchable: metadata.searchable ?? true,
3415
- sortable: metadata.sortable ?? true
3646
+ id: PLUGIN_ID,
3647
+ name: "Content Manager",
3648
+ injectionZones: INJECTION_ZONES,
3649
+ apis: {
3650
+ addBulkAction: this.addBulkAction.bind(this),
3651
+ addDocumentAction: this.addDocumentAction.bind(this),
3652
+ addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
3653
+ addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
3654
+ getBulkActions: () => this.bulkActions,
3655
+ getDocumentActions: () => this.documentActions,
3656
+ getEditViewSidePanels: () => this.editViewSidePanels,
3657
+ getHeaderActions: () => this.headerActions
3658
+ }
3416
3659
  };
3417
- }).filter((field) => field !== null);
3660
+ }
3661
+ }
3662
+ const getPrintableType = (value) => {
3663
+ const nativeType = typeof value;
3664
+ if (nativeType === "object") {
3665
+ if (value === null)
3666
+ return "null";
3667
+ if (Array.isArray(value))
3668
+ return "array";
3669
+ if (value instanceof Object && value.constructor.name !== "Object") {
3670
+ return value.constructor.name;
3671
+ }
3672
+ }
3673
+ return nativeType;
3674
+ };
3675
+ const initialState = {
3676
+ collectionTypeLinks: [],
3677
+ components: [],
3678
+ fieldSizes: {},
3679
+ models: [],
3680
+ singleTypeLinks: [],
3681
+ isLoading: true
3418
3682
  };
3683
+ const appSlice = toolkit.createSlice({
3684
+ name: "app",
3685
+ initialState,
3686
+ reducers: {
3687
+ setInitialData(state, action) {
3688
+ const {
3689
+ authorizedCollectionTypeLinks,
3690
+ authorizedSingleTypeLinks,
3691
+ components,
3692
+ contentTypeSchemas,
3693
+ fieldSizes
3694
+ } = action.payload;
3695
+ state.collectionTypeLinks = authorizedCollectionTypeLinks.filter(
3696
+ ({ isDisplayed }) => isDisplayed
3697
+ );
3698
+ state.singleTypeLinks = authorizedSingleTypeLinks.filter(({ isDisplayed }) => isDisplayed);
3699
+ state.components = components;
3700
+ state.models = contentTypeSchemas;
3701
+ state.fieldSizes = fieldSizes;
3702
+ state.isLoading = false;
3703
+ }
3704
+ }
3705
+ });
3706
+ const { actions, reducer: reducer$1 } = appSlice;
3707
+ const { setInitialData } = actions;
3708
+ const reducer = toolkit.combineReducers({
3709
+ app: reducer$1
3710
+ });
3419
3711
  const index = {
3420
3712
  register(app) {
3421
3713
  const cm = new ContentManagerPlugin();
@@ -3430,7 +3722,7 @@ const index = {
3430
3722
  defaultMessage: "Content Manager"
3431
3723
  },
3432
3724
  permissions: [],
3433
- Component: () => Promise.resolve().then(() => require("./layout-ni_L9kT1.js")).then((mod) => ({ default: mod.Layout })),
3725
+ Component: () => Promise.resolve().then(() => require("./layout-aK6fNSLK.js")).then((mod) => ({ default: mod.Layout })),
3434
3726
  position: 1
3435
3727
  });
3436
3728
  app.registerPlugin(cm.config);
@@ -3438,7 +3730,7 @@ const index = {
3438
3730
  async registerTrads({ locales }) {
3439
3731
  const importedTrads = await Promise.all(
3440
3732
  locales.map((locale) => {
3441
- 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-DTULi5-d.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 }) => {
3733
+ 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 }) => {
3442
3734
  return {
3443
3735
  data: prefixPluginTranslations(data, PLUGIN_ID),
3444
3736
  locale
@@ -3496,4 +3788,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
3496
3788
  exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
3497
3789
  exports.useGetInitialDataQuery = useGetInitialDataQuery;
3498
3790
  exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
3499
- //# sourceMappingURL=index-CCJeB7Rw.js.map
3791
+ //# sourceMappingURL=index-B4Gj2Oe9.js.map