@strapi/content-manager 0.0.0-experimental.826f263c58b6886b849d3f03b81f7a530bc51c91 → 0.0.0-experimental.82afe56cecefd0078d534e25909834ecf5fdd404
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.
- package/LICENSE +18 -3
- package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -1
- package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-DJcn1DrO.js → ComponentConfigurationPage-DMxUlNOo.js} +5 -6
- package/dist/_chunks/{ComponentConfigurationPage-DJcn1DrO.js.map → ComponentConfigurationPage-DMxUlNOo.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-CR5XdR33.mjs → ComponentConfigurationPage-baEkO-OV.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-CR5XdR33.mjs.map → ComponentConfigurationPage-baEkO-OV.mjs.map} +1 -1
- package/dist/_chunks/{ComponentIcon-BXdiCGQp.js → ComponentIcon-CRbtQEUV.js} +2 -3
- package/dist/_chunks/{ComponentIcon-BXdiCGQp.js.map → ComponentIcon-CRbtQEUV.js.map} +1 -1
- package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -1
- package/dist/_chunks/{EditConfigurationPage-tDtWj7R2.js → EditConfigurationPage-CXxV7mKn.js} +5 -6
- package/dist/_chunks/{EditConfigurationPage-tDtWj7R2.js.map → EditConfigurationPage-CXxV7mKn.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-DmCIb4kD.mjs → EditConfigurationPage-YR8-4VCS.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-DmCIb4kD.mjs.map → EditConfigurationPage-YR8-4VCS.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-CoQEnFlC.js → EditViewPage-BfR6jAR6.js} +71 -84
- package/dist/_chunks/EditViewPage-BfR6jAR6.js.map +1 -0
- package/dist/_chunks/EditViewPage-DFF7c27p.mjs +191 -0
- package/dist/_chunks/EditViewPage-DFF7c27p.mjs.map +1 -0
- package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
- package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
- package/dist/_chunks/{Form-Bpig5rch.js → Form-CjcMRP5A.js} +55 -38
- package/dist/_chunks/Form-CjcMRP5A.js.map +1 -0
- package/dist/_chunks/{Form-Dxmihyw8.mjs → Form-MSOSfGGN.mjs} +55 -37
- package/dist/_chunks/Form-MSOSfGGN.mjs.map +1 -0
- package/dist/_chunks/{History-BfX6XmZK.js → History-BgZ7gVuF.js} +208 -138
- package/dist/_chunks/History-BgZ7gVuF.js.map +1 -0
- package/dist/_chunks/{History-BZP8n7KT.mjs → History-WOQNVho-.mjs} +201 -130
- package/dist/_chunks/History-WOQNVho-.mjs.map +1 -0
- package/dist/_chunks/{Field-Cz_J9551.mjs → Input-BkKwZ6Qt.mjs} +1757 -1383
- package/dist/_chunks/Input-BkKwZ6Qt.mjs.map +1 -0
- package/dist/_chunks/{Field-ZdrmmQ4Y.js → Input-BwOibhc3.js} +1748 -1374
- package/dist/_chunks/Input-BwOibhc3.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DxKuVkKz.mjs → ListConfigurationPage-BeXfr6uW.mjs} +63 -52
- package/dist/_chunks/ListConfigurationPage-BeXfr6uW.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-B3CXj8PY.js → ListConfigurationPage-DnJ3nbwL.js} +62 -51
- package/dist/_chunks/ListConfigurationPage-DnJ3nbwL.js.map +1 -0
- package/dist/_chunks/{ListViewPage-Bk9VO__I.js → ListViewPage-CJFDudKl.js} +155 -129
- package/dist/_chunks/ListViewPage-CJFDudKl.js.map +1 -0
- package/dist/_chunks/{ListViewPage-D5D3tVPq.mjs → ListViewPage-VK2v44Q1.mjs} +156 -129
- package/dist/_chunks/ListViewPage-VK2v44Q1.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DnMeuQCj.mjs → NoContentTypePage-T8ttty6K.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-DnMeuQCj.mjs.map → NoContentTypePage-T8ttty6K.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-DsB2F7Z1.js → NoContentTypePage-en2PwWgI.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-DsB2F7Z1.js.map → NoContentTypePage-en2PwWgI.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-BQDM64_b.js → NoPermissionsPage-CcjILry3.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-BQDM64_b.js.map → NoPermissionsPage-CcjILry3.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-OyoME_Tf.mjs → NoPermissionsPage-CokBHhhy.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-OyoME_Tf.mjs.map → NoPermissionsPage-CokBHhhy.mjs.map} +1 -1
- package/dist/_chunks/Preview-BF81YhRj.mjs +287 -0
- package/dist/_chunks/Preview-BF81YhRj.mjs.map +1 -0
- package/dist/_chunks/Preview-DgzAuzWQ.js +305 -0
- package/dist/_chunks/Preview-DgzAuzWQ.js.map +1 -0
- package/dist/_chunks/{Relations-B6B3A3mb.js → Relations-1O-JcM4t.js} +76 -43
- package/dist/_chunks/Relations-1O-JcM4t.js.map +1 -0
- package/dist/_chunks/{Relations-BOYZmuWy.mjs → Relations-BncdhGCd.mjs} +76 -42
- package/dist/_chunks/Relations-BncdhGCd.mjs.map +1 -0
- package/dist/_chunks/{en-Dzv55oQw.mjs → en-BZaUty0m.mjs} +41 -18
- package/dist/_chunks/{en-Dzv55oQw.mjs.map → en-BZaUty0m.mjs.map} +1 -1
- package/dist/_chunks/{en-BN1bvFK7.js → en-CzCnBk4S.js} +41 -18
- package/dist/_chunks/{en-BN1bvFK7.js.map → en-CzCnBk4S.js.map} +1 -1
- package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
- package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
- package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
- package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
- package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
- package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
- package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
- package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
- package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
- package/dist/_chunks/{index-VHviNMeW.mjs → index-DiluOUp6.mjs} +1469 -966
- package/dist/_chunks/index-DiluOUp6.mjs.map +1 -0
- package/dist/_chunks/{index-DzN3kBgx.js → index-EXJvmn4t.js} +1439 -936
- package/dist/_chunks/index-EXJvmn4t.js.map +1 -0
- package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
- package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
- package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
- package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
- package/dist/_chunks/{layout-b91XRlD2.js → layout-4TbKVax8.js} +41 -24
- package/dist/_chunks/layout-4TbKVax8.js.map +1 -0
- package/dist/_chunks/{layout-CPn1PM6x.mjs → layout-mSwsYzxv.mjs} +42 -24
- package/dist/_chunks/layout-mSwsYzxv.mjs.map +1 -0
- package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
- package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
- package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
- package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
- package/dist/_chunks/{relations-BsqxS6tR.mjs → relations--YOvQBqv.mjs} +6 -7
- package/dist/_chunks/relations--YOvQBqv.mjs.map +1 -0
- package/dist/_chunks/{relations-CA7IYmcP.js → relations-Ai6Izh7h.js} +6 -7
- package/dist/_chunks/relations-Ai6Izh7h.js.map +1 -0
- package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
- package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
- package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
- package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
- package/dist/_chunks/usePrev-CZGy2Vjf.mjs +29 -0
- package/dist/_chunks/usePrev-CZGy2Vjf.mjs.map +1 -0
- package/dist/_chunks/{usePrev-B9w_-eYc.js → usePrev-D5J_2fEu.js} +14 -1
- package/dist/_chunks/usePrev-D5J_2fEu.js.map +1 -0
- package/dist/admin/index.js +3 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +10 -8
- package/dist/admin/src/content-manager.d.ts +3 -2
- package/dist/admin/src/exports.d.ts +2 -1
- package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
- package/dist/admin/src/history/index.d.ts +3 -0
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +49 -1
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +9 -4
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +3 -3
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +5 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +6 -58
- package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +27 -0
- package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
- package/dist/admin/src/pages/EditView/utils/data.d.ts +1 -0
- package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
- package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
- package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
- package/dist/admin/src/preview/index.d.ts +4 -0
- package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
- package/dist/admin/src/preview/routes.d.ts +3 -0
- package/dist/admin/src/preview/services/preview.d.ts +3 -0
- package/dist/admin/src/router.d.ts +1 -1
- package/dist/admin/src/services/api.d.ts +1 -1
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +3 -3
- package/dist/admin/src/services/documents.d.ts +19 -20
- package/dist/admin/src/services/init.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +2 -2
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/admin/src/utils/validation.d.ts +4 -1
- package/dist/server/index.js +765 -434
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +766 -434
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/controllers/uid.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +16 -1
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
- package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
- package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts +3 -3
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +8 -12
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +7 -6
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
- package/dist/server/src/preview/controllers/index.d.ts +2 -0
- package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/preview.d.ts +13 -0
- package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
- package/dist/server/src/preview/index.d.ts +4 -0
- package/dist/server/src/preview/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/index.d.ts +8 -0
- package/dist/server/src/preview/routes/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/preview.d.ts +4 -0
- package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
- package/dist/server/src/preview/services/index.d.ts +16 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts +32 -0
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview.d.ts +12 -0
- package/dist/server/src/preview/services/preview.d.ts.map +1 -0
- package/dist/server/src/preview/utils.d.ts +19 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -0
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +12 -10
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +7 -6
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/permission-checker.d.ts.map +1 -1
- package/dist/server/src/services/utils/populate.d.ts +2 -2
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts +2 -0
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/shared/contracts/collection-types.d.ts +3 -1
- package/dist/shared/contracts/collection-types.d.ts.map +1 -1
- package/dist/shared/contracts/index.d.ts +1 -0
- package/dist/shared/contracts/index.d.ts.map +1 -1
- package/dist/shared/contracts/preview.d.ts +27 -0
- package/dist/shared/contracts/preview.d.ts.map +1 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +4 -0
- package/dist/shared/index.mjs.map +1 -1
- package/package.json +17 -16
- package/dist/_chunks/EditViewPage-CoQEnFlC.js.map +0 -1
- package/dist/_chunks/EditViewPage-DvaV7U9b.mjs +0 -203
- package/dist/_chunks/EditViewPage-DvaV7U9b.mjs.map +0 -1
- package/dist/_chunks/Field-Cz_J9551.mjs.map +0 -1
- package/dist/_chunks/Field-ZdrmmQ4Y.js.map +0 -1
- package/dist/_chunks/Form-Bpig5rch.js.map +0 -1
- package/dist/_chunks/Form-Dxmihyw8.mjs.map +0 -1
- package/dist/_chunks/History-BZP8n7KT.mjs.map +0 -1
- package/dist/_chunks/History-BfX6XmZK.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-B3CXj8PY.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DxKuVkKz.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-Bk9VO__I.js.map +0 -1
- package/dist/_chunks/ListViewPage-D5D3tVPq.mjs.map +0 -1
- package/dist/_chunks/Relations-B6B3A3mb.js.map +0 -1
- package/dist/_chunks/Relations-BOYZmuWy.mjs.map +0 -1
- package/dist/_chunks/index-DzN3kBgx.js.map +0 -1
- package/dist/_chunks/index-VHviNMeW.mjs.map +0 -1
- package/dist/_chunks/layout-CPn1PM6x.mjs.map +0 -1
- package/dist/_chunks/layout-b91XRlD2.js.map +0 -1
- package/dist/_chunks/relations-BsqxS6tR.mjs.map +0 -1
- package/dist/_chunks/relations-CA7IYmcP.js.map +0 -1
- package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
- package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
- package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
- package/strapi-server.js +0 -3
@@ -2,20 +2,21 @@
|
|
2
2
|
const Icons = require("@strapi/icons");
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
4
4
|
const strapiAdmin = require("@strapi/admin/strapi-admin");
|
5
|
-
const qs = require("qs");
|
6
|
-
const reactIntl = require("react-intl");
|
7
|
-
const reactRouterDom = require("react-router-dom");
|
8
5
|
const React = require("react");
|
9
6
|
const designSystem = require("@strapi/design-system");
|
7
|
+
const mapValues = require("lodash/fp/mapValues");
|
8
|
+
const reactIntl = require("react-intl");
|
9
|
+
const reactRouterDom = require("react-router-dom");
|
10
10
|
const styledComponents = require("styled-components");
|
11
11
|
const yup = require("yup");
|
12
|
+
const fractionalIndexing = require("fractional-indexing");
|
12
13
|
const pipe = require("lodash/fp/pipe");
|
14
|
+
const qs = require("qs");
|
13
15
|
const dateFns = require("date-fns");
|
14
16
|
const toolkit = require("@reduxjs/toolkit");
|
15
17
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
16
18
|
function _interopNamespace(e) {
|
17
|
-
if (e && e.__esModule)
|
18
|
-
return e;
|
19
|
+
if (e && e.__esModule) return e;
|
19
20
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
20
21
|
if (e) {
|
21
22
|
for (const k in e) {
|
@@ -32,15 +33,23 @@ function _interopNamespace(e) {
|
|
32
33
|
return Object.freeze(n);
|
33
34
|
}
|
34
35
|
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
36
|
+
const mapValues__default = /* @__PURE__ */ _interopDefault(mapValues);
|
35
37
|
const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
|
36
38
|
const pipe__default = /* @__PURE__ */ _interopDefault(pipe);
|
37
|
-
const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
39
|
+
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
38
40
|
const v = glob[path];
|
39
41
|
if (v) {
|
40
42
|
return typeof v === "function" ? v() : Promise.resolve(v);
|
41
43
|
}
|
42
44
|
return new Promise((_, reject) => {
|
43
|
-
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
45
|
+
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
46
|
+
reject.bind(
|
47
|
+
null,
|
48
|
+
new Error(
|
49
|
+
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
50
|
+
)
|
51
|
+
)
|
52
|
+
);
|
44
53
|
});
|
45
54
|
};
|
46
55
|
const PLUGIN_ID = "content-manager";
|
@@ -70,42 +79,6 @@ const useInjectionZone = (area) => {
|
|
70
79
|
const [page, position] = area.split(".");
|
71
80
|
return contentManagerPlugin.getInjectedComponents(page, position);
|
72
81
|
};
|
73
|
-
const HistoryAction = ({ model, document }) => {
|
74
|
-
const { formatMessage } = reactIntl.useIntl();
|
75
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
76
|
-
const navigate = reactRouterDom.useNavigate();
|
77
|
-
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
78
|
-
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
79
|
-
return null;
|
80
|
-
}
|
81
|
-
return {
|
82
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
83
|
-
label: formatMessage({
|
84
|
-
id: "content-manager.history.document-action",
|
85
|
-
defaultMessage: "Content History"
|
86
|
-
}),
|
87
|
-
onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
|
88
|
-
disabled: (
|
89
|
-
/**
|
90
|
-
* The user is creating a new document.
|
91
|
-
* It hasn't been saved yet, so there's no history to go to
|
92
|
-
*/
|
93
|
-
!document || /**
|
94
|
-
* The document has been created but the current dimension has never been saved.
|
95
|
-
* For example, the user is creating a new locale in an existing document,
|
96
|
-
* so there's no history for the document in that locale
|
97
|
-
*/
|
98
|
-
!document.id || /**
|
99
|
-
* History is only available for content types created by the user.
|
100
|
-
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
101
|
-
* which start with `admin::` or `plugin::`
|
102
|
-
*/
|
103
|
-
!model.startsWith("api::")
|
104
|
-
),
|
105
|
-
position: "header"
|
106
|
-
};
|
107
|
-
};
|
108
|
-
HistoryAction.type = "history";
|
109
82
|
const ID = "id";
|
110
83
|
const CREATED_BY_ATTRIBUTE_NAME = "createdBy";
|
111
84
|
const UPDATED_BY_ATTRIBUTE_NAME = "updatedBy";
|
@@ -157,6 +130,7 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
157
130
|
if (!slug) {
|
158
131
|
throw new Error("Cannot find the slug param in the URL");
|
159
132
|
}
|
133
|
+
const [{ rawQuery }] = strapiAdmin.useQueryParams();
|
160
134
|
const userPermissions = strapiAdmin.useAuth("DocumentRBAC", (state) => state.permissions);
|
161
135
|
const contentTypePermissions = React__namespace.useMemo(() => {
|
162
136
|
const contentTypePermissions2 = userPermissions.filter(
|
@@ -167,7 +141,14 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
167
141
|
return { ...acc, [action]: [permission] };
|
168
142
|
}, {});
|
169
143
|
}, [slug, userPermissions]);
|
170
|
-
const { isLoading, allowedActions } = strapiAdmin.useRBAC(
|
144
|
+
const { isLoading, allowedActions } = strapiAdmin.useRBAC(
|
145
|
+
contentTypePermissions,
|
146
|
+
permissions ?? void 0,
|
147
|
+
// TODO: useRBAC context should be typed and built differently
|
148
|
+
// We are passing raw query as context to the hook so that it can
|
149
|
+
// rely on the locale provided from DocumentRBAC for its permission calculations.
|
150
|
+
rawQuery
|
151
|
+
);
|
171
152
|
const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
|
172
153
|
const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
|
173
154
|
const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
|
@@ -207,6 +188,113 @@ const extractAndDedupeFields = (permissions = []) => permissions.flatMap((permis
|
|
207
188
|
(field, index2, arr) => arr.indexOf(field) === index2 && typeof field === "string"
|
208
189
|
);
|
209
190
|
const removeNumericalStrings = (arr) => arr.filter((item) => isNaN(Number(item)));
|
191
|
+
const BLOCK_LIST_ATTRIBUTE_KEYS = ["__component", "__temp_key__"];
|
192
|
+
const traverseData = (predicate, transform) => (schema, components = {}) => (data = {}) => {
|
193
|
+
const traverse = (datum, attributes) => {
|
194
|
+
return Object.entries(datum).reduce((acc, [key, value]) => {
|
195
|
+
const attribute = attributes[key];
|
196
|
+
if (BLOCK_LIST_ATTRIBUTE_KEYS.includes(key) || value === null || value === void 0) {
|
197
|
+
acc[key] = value;
|
198
|
+
return acc;
|
199
|
+
}
|
200
|
+
if (attribute.type === "component") {
|
201
|
+
if (attribute.repeatable) {
|
202
|
+
const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
|
203
|
+
acc[key] = componentValue.map(
|
204
|
+
(componentData) => traverse(componentData, components[attribute.component]?.attributes ?? {})
|
205
|
+
);
|
206
|
+
} else {
|
207
|
+
const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
|
208
|
+
acc[key] = traverse(componentValue, components[attribute.component]?.attributes ?? {});
|
209
|
+
}
|
210
|
+
} else if (attribute.type === "dynamiczone") {
|
211
|
+
const dynamicZoneValue = predicate(attribute, value) ? transform(value, attribute) : value;
|
212
|
+
acc[key] = dynamicZoneValue.map(
|
213
|
+
(componentData) => traverse(componentData, components[componentData.__component]?.attributes ?? {})
|
214
|
+
);
|
215
|
+
} else if (predicate(attribute, value)) {
|
216
|
+
acc[key] = transform(value, attribute);
|
217
|
+
} else {
|
218
|
+
acc[key] = value;
|
219
|
+
}
|
220
|
+
return acc;
|
221
|
+
}, {});
|
222
|
+
};
|
223
|
+
return traverse(data, schema.attributes);
|
224
|
+
};
|
225
|
+
const removeProhibitedFields = (prohibitedFields) => traverseData(
|
226
|
+
(attribute) => prohibitedFields.includes(attribute.type),
|
227
|
+
() => ""
|
228
|
+
);
|
229
|
+
const prepareRelations = traverseData(
|
230
|
+
(attribute) => attribute.type === "relation",
|
231
|
+
() => ({
|
232
|
+
connect: [],
|
233
|
+
disconnect: []
|
234
|
+
})
|
235
|
+
);
|
236
|
+
const prepareTempKeys = traverseData(
|
237
|
+
(attribute) => attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone",
|
238
|
+
(data) => {
|
239
|
+
if (Array.isArray(data) && data.length > 0) {
|
240
|
+
const keys = fractionalIndexing.generateNKeysBetween(void 0, void 0, data.length);
|
241
|
+
return data.map((datum, index2) => ({
|
242
|
+
...datum,
|
243
|
+
__temp_key__: keys[index2]
|
244
|
+
}));
|
245
|
+
}
|
246
|
+
return data;
|
247
|
+
}
|
248
|
+
);
|
249
|
+
const removeFieldsThatDontExistOnSchema = (schema) => (data) => {
|
250
|
+
const schemaKeys = Object.keys(schema.attributes);
|
251
|
+
const dataKeys = Object.keys(data);
|
252
|
+
const keysToRemove = dataKeys.filter((key) => !schemaKeys.includes(key));
|
253
|
+
const revisedData = [...keysToRemove, ...DOCUMENT_META_FIELDS].reduce((acc, key) => {
|
254
|
+
delete acc[key];
|
255
|
+
return acc;
|
256
|
+
}, structuredClone(data));
|
257
|
+
return revisedData;
|
258
|
+
};
|
259
|
+
const removeNullValues = (data) => {
|
260
|
+
return Object.entries(data).reduce((acc, [key, value]) => {
|
261
|
+
if (value === null) {
|
262
|
+
return acc;
|
263
|
+
}
|
264
|
+
acc[key] = value;
|
265
|
+
return acc;
|
266
|
+
}, {});
|
267
|
+
};
|
268
|
+
const transformDocument = (schema, components = {}) => (document) => {
|
269
|
+
const transformations = pipe__default.default(
|
270
|
+
removeFieldsThatDontExistOnSchema(schema),
|
271
|
+
removeProhibitedFields(["password"])(schema, components),
|
272
|
+
removeNullValues,
|
273
|
+
prepareRelations(schema, components),
|
274
|
+
prepareTempKeys(schema, components)
|
275
|
+
);
|
276
|
+
return transformations(document);
|
277
|
+
};
|
278
|
+
const createDefaultForm = (contentType, components = {}) => {
|
279
|
+
const traverseSchema = (attributes) => {
|
280
|
+
return Object.entries(attributes).reduce((acc, [key, attribute]) => {
|
281
|
+
if ("default" in attribute) {
|
282
|
+
acc[key] = attribute.default;
|
283
|
+
} else if (attribute.type === "component" && attribute.required) {
|
284
|
+
const defaultComponentForm = traverseSchema(components[attribute.component].attributes);
|
285
|
+
if (attribute.repeatable) {
|
286
|
+
acc[key] = attribute.min ? [...Array(attribute.min).fill(defaultComponentForm)] : [];
|
287
|
+
} else {
|
288
|
+
acc[key] = defaultComponentForm;
|
289
|
+
}
|
290
|
+
} else if (attribute.type === "dynamiczone" && attribute.required) {
|
291
|
+
acc[key] = [];
|
292
|
+
}
|
293
|
+
return acc;
|
294
|
+
}, {});
|
295
|
+
};
|
296
|
+
return traverseSchema(contentType.attributes);
|
297
|
+
};
|
210
298
|
const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
|
211
299
|
addTagTypes: [
|
212
300
|
"ComponentConfiguration",
|
@@ -215,10 +303,13 @@ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
|
|
215
303
|
"Document",
|
216
304
|
"InitialData",
|
217
305
|
"HistoryVersion",
|
218
|
-
"Relations"
|
306
|
+
"Relations",
|
307
|
+
"UidAvailability",
|
308
|
+
"RecentDocumentList"
|
219
309
|
]
|
220
310
|
});
|
221
311
|
const documentApi = contentManagerApi.injectEndpoints({
|
312
|
+
overrideExisting: true,
|
222
313
|
endpoints: (builder) => ({
|
223
314
|
autoCloneDocument: builder.mutation({
|
224
315
|
query: ({ model, sourceId, query }) => ({
|
@@ -228,7 +319,12 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
228
319
|
params: query
|
229
320
|
}
|
230
321
|
}),
|
231
|
-
invalidatesTags: (_result,
|
322
|
+
invalidatesTags: (_result, error, { model }) => {
|
323
|
+
if (error) {
|
324
|
+
return [];
|
325
|
+
}
|
326
|
+
return [{ type: "Document", id: `${model}_LIST` }, "RecentDocumentList"];
|
327
|
+
}
|
232
328
|
}),
|
233
329
|
cloneDocument: builder.mutation({
|
234
330
|
query: ({ model, sourceId, data, params }) => ({
|
@@ -239,7 +335,11 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
239
335
|
params
|
240
336
|
}
|
241
337
|
}),
|
242
|
-
invalidatesTags: (_result, _error, { model }) => [
|
338
|
+
invalidatesTags: (_result, _error, { model }) => [
|
339
|
+
{ type: "Document", id: `${model}_LIST` },
|
340
|
+
{ type: "UidAvailability", id: model },
|
341
|
+
"RecentDocumentList"
|
342
|
+
]
|
243
343
|
}),
|
244
344
|
/**
|
245
345
|
* Creates a new collection-type document. This should ONLY be used for collection-types.
|
@@ -256,8 +356,22 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
256
356
|
}),
|
257
357
|
invalidatesTags: (result, _error, { model }) => [
|
258
358
|
{ type: "Document", id: `${model}_LIST` },
|
259
|
-
"Relations"
|
260
|
-
|
359
|
+
"Relations",
|
360
|
+
{ type: "UidAvailability", id: model },
|
361
|
+
"RecentDocumentList"
|
362
|
+
],
|
363
|
+
transformResponse: (response, meta, arg) => {
|
364
|
+
if (!("data" in response) && arg.model === "plugin::users-permissions.user") {
|
365
|
+
return {
|
366
|
+
data: response,
|
367
|
+
meta: {
|
368
|
+
availableStatus: [],
|
369
|
+
availableLocales: []
|
370
|
+
}
|
371
|
+
};
|
372
|
+
}
|
373
|
+
return response;
|
374
|
+
}
|
261
375
|
}),
|
262
376
|
deleteDocument: builder.mutation({
|
263
377
|
query: ({ collectionType, model, documentId, params }) => ({
|
@@ -268,7 +382,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
268
382
|
}
|
269
383
|
}),
|
270
384
|
invalidatesTags: (_result, _error, { collectionType, model }) => [
|
271
|
-
{ type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model }
|
385
|
+
{ type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model },
|
386
|
+
"RecentDocumentList"
|
272
387
|
]
|
273
388
|
}),
|
274
389
|
deleteManyDocuments: builder.mutation({
|
@@ -280,7 +395,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
280
395
|
params
|
281
396
|
}
|
282
397
|
}),
|
283
|
-
invalidatesTags: (_res, _error, { model }) => [
|
398
|
+
invalidatesTags: (_res, _error, { model }) => [
|
399
|
+
{ type: "Document", id: `${model}_LIST` },
|
400
|
+
"RecentDocumentList"
|
401
|
+
]
|
284
402
|
}),
|
285
403
|
discardDocument: builder.mutation({
|
286
404
|
query: ({ collectionType, model, documentId, params }) => ({
|
@@ -297,7 +415,9 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
297
415
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
298
416
|
},
|
299
417
|
{ type: "Document", id: `${model}_LIST` },
|
300
|
-
"Relations"
|
418
|
+
"Relations",
|
419
|
+
{ type: "UidAvailability", id: model },
|
420
|
+
"RecentDocumentList"
|
301
421
|
];
|
302
422
|
}
|
303
423
|
}),
|
@@ -310,11 +430,12 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
310
430
|
url: `/content-manager/collection-types/${model}`,
|
311
431
|
method: "GET",
|
312
432
|
config: {
|
313
|
-
params
|
433
|
+
params: qs.stringify(params, { encode: true })
|
314
434
|
}
|
315
435
|
}),
|
316
436
|
providesTags: (result, _error, arg) => {
|
317
437
|
return [
|
438
|
+
{ type: "Document", id: `ALL_LIST` },
|
318
439
|
{ type: "Document", id: `${arg.model}_LIST` },
|
319
440
|
...result?.results.map(({ documentId }) => ({
|
320
441
|
type: "Document",
|
@@ -353,6 +474,11 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
353
474
|
{
|
354
475
|
type: "Document",
|
355
476
|
id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
|
477
|
+
},
|
478
|
+
// Make it easy to invalidate all individual documents queries for a model
|
479
|
+
{
|
480
|
+
type: "Document",
|
481
|
+
id: `${model}_ALL_ITEMS`
|
356
482
|
}
|
357
483
|
];
|
358
484
|
}
|
@@ -386,7 +512,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
386
512
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
387
513
|
},
|
388
514
|
{ type: "Document", id: `${model}_LIST` },
|
389
|
-
"Relations"
|
515
|
+
"Relations",
|
516
|
+
"RecentDocumentList"
|
390
517
|
];
|
391
518
|
}
|
392
519
|
}),
|
@@ -416,8 +543,23 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
416
543
|
type: "Document",
|
417
544
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
418
545
|
},
|
419
|
-
"Relations"
|
546
|
+
"Relations",
|
547
|
+
{ type: "UidAvailability", id: model },
|
548
|
+
"RecentDocumentList",
|
549
|
+
"RecentDocumentList"
|
420
550
|
];
|
551
|
+
},
|
552
|
+
async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
|
553
|
+
const patchResult = dispatch(
|
554
|
+
documentApi.util.updateQueryData("getDocument", patch, (draft) => {
|
555
|
+
Object.assign(draft.data, data);
|
556
|
+
})
|
557
|
+
);
|
558
|
+
try {
|
559
|
+
await queryFulfilled;
|
560
|
+
} catch {
|
561
|
+
patchResult.undo();
|
562
|
+
}
|
421
563
|
}
|
422
564
|
}),
|
423
565
|
unpublishDocument: builder.mutation({
|
@@ -434,7 +576,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
434
576
|
{
|
435
577
|
type: "Document",
|
436
578
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
437
|
-
}
|
579
|
+
},
|
580
|
+
"RecentDocumentList"
|
438
581
|
];
|
439
582
|
}
|
440
583
|
}),
|
@@ -447,7 +590,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
447
590
|
params
|
448
591
|
}
|
449
592
|
}),
|
450
|
-
invalidatesTags: (_res, _error, { model, documentIds }) =>
|
593
|
+
invalidatesTags: (_res, _error, { model, documentIds }) => [
|
594
|
+
...documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` })),
|
595
|
+
"RecentDocumentList"
|
596
|
+
]
|
451
597
|
})
|
452
598
|
})
|
453
599
|
});
|
@@ -470,8 +616,7 @@ const {
|
|
470
616
|
useUnpublishManyDocumentsMutation
|
471
617
|
} = documentApi;
|
472
618
|
const buildValidParams = (query) => {
|
473
|
-
if (!query)
|
474
|
-
return query;
|
619
|
+
if (!query) return query;
|
475
620
|
const { plugins: _, ...validQueryParams } = {
|
476
621
|
...query,
|
477
622
|
...Object.values(query?.plugins ?? {}).reduce(
|
@@ -479,28 +624,44 @@ const buildValidParams = (query) => {
|
|
479
624
|
{}
|
480
625
|
)
|
481
626
|
};
|
482
|
-
if ("_q" in validQueryParams) {
|
483
|
-
validQueryParams._q = encodeURIComponent(validQueryParams._q);
|
484
|
-
}
|
485
627
|
return validQueryParams;
|
486
628
|
};
|
487
629
|
const isBaseQueryError = (error) => {
|
488
630
|
return error.name !== void 0;
|
489
631
|
};
|
490
|
-
const
|
632
|
+
const arrayValidator = (attribute, options) => ({
|
633
|
+
message: strapiAdmin.translatedErrors.required,
|
634
|
+
test(value) {
|
635
|
+
if (options.status === "draft") {
|
636
|
+
return true;
|
637
|
+
}
|
638
|
+
if (!attribute.required) {
|
639
|
+
return true;
|
640
|
+
}
|
641
|
+
if (!value) {
|
642
|
+
return false;
|
643
|
+
}
|
644
|
+
if (Array.isArray(value) && value.length === 0) {
|
645
|
+
return false;
|
646
|
+
}
|
647
|
+
return true;
|
648
|
+
}
|
649
|
+
});
|
650
|
+
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
491
651
|
const createModelSchema = (attributes2) => yup__namespace.object().shape(
|
492
652
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
493
653
|
if (DOCUMENT_META_FIELDS.includes(name)) {
|
494
654
|
return acc;
|
495
655
|
}
|
496
656
|
const validations = [
|
657
|
+
addNullableValidation,
|
497
658
|
addRequiredValidation,
|
498
659
|
addMinLengthValidation,
|
499
660
|
addMaxLengthValidation,
|
500
661
|
addMinValidation,
|
501
662
|
addMaxValidation,
|
502
663
|
addRegexValidation
|
503
|
-
].map((fn) => fn(attribute));
|
664
|
+
].map((fn) => fn(attribute, options));
|
504
665
|
const transformSchema = pipe__default.default(...validations);
|
505
666
|
switch (attribute.type) {
|
506
667
|
case "component": {
|
@@ -510,12 +671,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
510
671
|
...acc,
|
511
672
|
[name]: transformSchema(
|
512
673
|
yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
|
513
|
-
)
|
674
|
+
).test(arrayValidator(attribute, options))
|
514
675
|
};
|
515
676
|
} else {
|
516
677
|
return {
|
517
678
|
...acc,
|
518
|
-
[name]: transformSchema(createModelSchema(attributes3))
|
679
|
+
[name]: transformSchema(createModelSchema(attributes3).nullable())
|
519
680
|
};
|
520
681
|
}
|
521
682
|
}
|
@@ -537,7 +698,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
537
698
|
}
|
538
699
|
)
|
539
700
|
)
|
540
|
-
)
|
701
|
+
).test(arrayValidator(attribute, options))
|
541
702
|
};
|
542
703
|
case "relation":
|
543
704
|
return {
|
@@ -549,7 +710,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
549
710
|
} else if (Array.isArray(value)) {
|
550
711
|
return yup__namespace.array().of(
|
551
712
|
yup__namespace.object().shape({
|
552
|
-
id: yup__namespace.
|
713
|
+
id: yup__namespace.number().required()
|
553
714
|
})
|
554
715
|
);
|
555
716
|
} else if (typeof value === "object") {
|
@@ -601,6 +762,14 @@ const createAttributeSchema = (attribute) => {
|
|
601
762
|
if (!value || typeof value === "string" && value.length === 0) {
|
602
763
|
return true;
|
603
764
|
}
|
765
|
+
if (typeof value === "object") {
|
766
|
+
try {
|
767
|
+
JSON.stringify(value);
|
768
|
+
return true;
|
769
|
+
} catch (err) {
|
770
|
+
return false;
|
771
|
+
}
|
772
|
+
}
|
604
773
|
try {
|
605
774
|
JSON.parse(value);
|
606
775
|
return true;
|
@@ -619,13 +788,7 @@ const createAttributeSchema = (attribute) => {
|
|
619
788
|
return yup__namespace.mixed();
|
620
789
|
}
|
621
790
|
};
|
622
|
-
const
|
623
|
-
if (attribute.required) {
|
624
|
-
return schema.required({
|
625
|
-
id: strapiAdmin.translatedErrors.required.id,
|
626
|
-
defaultMessage: "This field is required."
|
627
|
-
});
|
628
|
-
}
|
791
|
+
const nullableSchema = (schema) => {
|
629
792
|
return schema?.nullable ? schema.nullable() : (
|
630
793
|
// In some cases '.nullable' will not be available on the schema.
|
631
794
|
// e.g. when the schema has been built using yup.lazy (e.g. for relations).
|
@@ -633,7 +796,22 @@ const addRequiredValidation = (attribute) => (schema) => {
|
|
633
796
|
schema
|
634
797
|
);
|
635
798
|
};
|
636
|
-
const
|
799
|
+
const addNullableValidation = () => (schema) => {
|
800
|
+
return nullableSchema(schema);
|
801
|
+
};
|
802
|
+
const addRequiredValidation = (attribute, options) => (schema) => {
|
803
|
+
if (options.status === "draft" || !attribute.required) {
|
804
|
+
return schema;
|
805
|
+
}
|
806
|
+
if (attribute.required && "required" in schema) {
|
807
|
+
return schema.required(strapiAdmin.translatedErrors.required);
|
808
|
+
}
|
809
|
+
return schema;
|
810
|
+
};
|
811
|
+
const addMinLengthValidation = (attribute, options) => (schema) => {
|
812
|
+
if (options.status === "draft") {
|
813
|
+
return schema;
|
814
|
+
}
|
637
815
|
if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
|
638
816
|
return schema.min(attribute.minLength, {
|
639
817
|
...strapiAdmin.translatedErrors.minLength,
|
@@ -655,10 +833,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
655
833
|
}
|
656
834
|
return schema;
|
657
835
|
};
|
658
|
-
const addMinValidation = (attribute) => (schema) => {
|
659
|
-
if ("
|
836
|
+
const addMinValidation = (attribute, options) => (schema) => {
|
837
|
+
if (options.status === "draft") {
|
838
|
+
return schema;
|
839
|
+
}
|
840
|
+
if ("min" in attribute && "min" in schema) {
|
660
841
|
const min = toInteger(attribute.min);
|
661
|
-
if (
|
842
|
+
if (min) {
|
662
843
|
return schema.min(min, {
|
663
844
|
...strapiAdmin.translatedErrors.min,
|
664
845
|
values: {
|
@@ -776,16 +957,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
|
|
776
957
|
}, {});
|
777
958
|
return componentsByKey;
|
778
959
|
};
|
779
|
-
const
|
960
|
+
const HOOKS = {
|
961
|
+
/**
|
962
|
+
* Hook that allows to mutate the displayed headers of the list view table
|
963
|
+
* @constant
|
964
|
+
* @type {string}
|
965
|
+
*/
|
966
|
+
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
967
|
+
/**
|
968
|
+
* Hook that allows to mutate the CM's collection types links pre-set filters
|
969
|
+
* @constant
|
970
|
+
* @type {string}
|
971
|
+
*/
|
972
|
+
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
973
|
+
/**
|
974
|
+
* Hook that allows to mutate the CM's edit view layout
|
975
|
+
* @constant
|
976
|
+
* @type {string}
|
977
|
+
*/
|
978
|
+
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
979
|
+
/**
|
980
|
+
* Hook that allows to mutate the CM's single types links pre-set filters
|
981
|
+
* @constant
|
982
|
+
* @type {string}
|
983
|
+
*/
|
984
|
+
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
985
|
+
};
|
986
|
+
const contentTypesApi = contentManagerApi.injectEndpoints({
|
987
|
+
endpoints: (builder) => ({
|
988
|
+
getContentTypeConfiguration: builder.query({
|
989
|
+
query: (uid) => ({
|
990
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
991
|
+
method: "GET"
|
992
|
+
}),
|
993
|
+
transformResponse: (response) => response.data,
|
994
|
+
providesTags: (_result, _error, uid) => [
|
995
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
996
|
+
{ type: "ContentTypeSettings", id: "LIST" }
|
997
|
+
]
|
998
|
+
}),
|
999
|
+
getAllContentTypeSettings: builder.query({
|
1000
|
+
query: () => "/content-manager/content-types-settings",
|
1001
|
+
transformResponse: (response) => response.data,
|
1002
|
+
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
1003
|
+
}),
|
1004
|
+
updateContentTypeConfiguration: builder.mutation({
|
1005
|
+
query: ({ uid, ...body }) => ({
|
1006
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
1007
|
+
method: "PUT",
|
1008
|
+
data: body
|
1009
|
+
}),
|
1010
|
+
transformResponse: (response) => response.data,
|
1011
|
+
invalidatesTags: (_result, _error, { uid }) => [
|
1012
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
1013
|
+
{ type: "ContentTypeSettings", id: "LIST" },
|
1014
|
+
// Is this necessary?
|
1015
|
+
{ type: "InitialData" }
|
1016
|
+
]
|
1017
|
+
})
|
1018
|
+
})
|
1019
|
+
});
|
1020
|
+
const {
|
1021
|
+
useGetContentTypeConfigurationQuery,
|
1022
|
+
useGetAllContentTypeSettingsQuery,
|
1023
|
+
useUpdateContentTypeConfigurationMutation
|
1024
|
+
} = contentTypesApi;
|
1025
|
+
const checkIfAttributeIsDisplayable = (attribute) => {
|
1026
|
+
const { type } = attribute;
|
1027
|
+
if (type === "relation") {
|
1028
|
+
return !attribute.relation.toLowerCase().includes("morph");
|
1029
|
+
}
|
1030
|
+
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
1031
|
+
};
|
1032
|
+
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
1033
|
+
if (!mainFieldName) {
|
1034
|
+
return void 0;
|
1035
|
+
}
|
1036
|
+
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
1037
|
+
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
1038
|
+
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
1039
|
+
);
|
1040
|
+
return {
|
1041
|
+
name: mainFieldName,
|
1042
|
+
type: mainFieldType ?? "string"
|
1043
|
+
};
|
1044
|
+
};
|
1045
|
+
const DEFAULT_SETTINGS = {
|
1046
|
+
bulkable: false,
|
1047
|
+
filterable: false,
|
1048
|
+
searchable: false,
|
1049
|
+
pagination: false,
|
1050
|
+
defaultSortBy: "",
|
1051
|
+
defaultSortOrder: "asc",
|
1052
|
+
mainField: "id",
|
1053
|
+
pageSize: 10
|
1054
|
+
};
|
1055
|
+
const useDocumentLayout = (model) => {
|
1056
|
+
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
1057
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
1058
|
+
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
780
1059
|
const { toggleNotification } = strapiAdmin.useNotification();
|
781
1060
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1061
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
782
1062
|
const {
|
783
|
-
|
784
|
-
isLoading:
|
785
|
-
|
786
|
-
|
787
|
-
} =
|
788
|
-
const
|
1063
|
+
data,
|
1064
|
+
isLoading: isLoadingConfigs,
|
1065
|
+
error,
|
1066
|
+
isFetching: isFetchingConfigs
|
1067
|
+
} = useGetContentTypeConfigurationQuery(model);
|
1068
|
+
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
789
1069
|
React__namespace.useEffect(() => {
|
790
1070
|
if (error) {
|
791
1071
|
toggleNotification({
|
@@ -793,25 +1073,254 @@ const useDocument = (args, opts) => {
|
|
793
1073
|
message: formatAPIError(error)
|
794
1074
|
});
|
795
1075
|
}
|
796
|
-
}, [
|
797
|
-
const
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
1076
|
+
}, [error, formatAPIError, toggleNotification]);
|
1077
|
+
const editLayout = React__namespace.useMemo(
|
1078
|
+
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
1079
|
+
layout: [],
|
1080
|
+
components: {},
|
1081
|
+
metadatas: {},
|
1082
|
+
options: {},
|
1083
|
+
settings: DEFAULT_SETTINGS
|
1084
|
+
},
|
1085
|
+
[data, isLoading, schemas, schema, components]
|
1086
|
+
);
|
1087
|
+
const listLayout = React__namespace.useMemo(() => {
|
1088
|
+
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
1089
|
+
layout: [],
|
1090
|
+
metadatas: {},
|
1091
|
+
options: {},
|
1092
|
+
settings: DEFAULT_SETTINGS
|
1093
|
+
};
|
1094
|
+
}, [data, isLoading, schemas, schema, components]);
|
1095
|
+
const { layout: edit } = React__namespace.useMemo(
|
1096
|
+
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
1097
|
+
layout: editLayout,
|
1098
|
+
query
|
1099
|
+
}),
|
1100
|
+
[editLayout, query, runHookWaterfall]
|
1101
|
+
);
|
1102
|
+
return {
|
1103
|
+
error,
|
1104
|
+
isLoading,
|
1105
|
+
edit,
|
1106
|
+
list: listLayout
|
1107
|
+
};
|
1108
|
+
};
|
1109
|
+
const useDocLayout = () => {
|
1110
|
+
const { model } = useDoc();
|
1111
|
+
return useDocumentLayout(model);
|
1112
|
+
};
|
1113
|
+
const formatEditLayout = (data, {
|
1114
|
+
schemas,
|
1115
|
+
schema,
|
1116
|
+
components
|
1117
|
+
}) => {
|
1118
|
+
let currentPanelIndex = 0;
|
1119
|
+
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
1120
|
+
data.contentType.layouts.edit,
|
1121
|
+
schema?.attributes,
|
1122
|
+
data.contentType.metadatas,
|
1123
|
+
{ configurations: data.components, schemas: components },
|
1124
|
+
schemas
|
1125
|
+
).reduce((panels, row) => {
|
1126
|
+
if (row.some((field) => field.type === "dynamiczone")) {
|
1127
|
+
panels.push([row]);
|
1128
|
+
currentPanelIndex += 2;
|
1129
|
+
} else {
|
1130
|
+
if (!panels[currentPanelIndex]) {
|
1131
|
+
panels.push([row]);
|
1132
|
+
} else {
|
1133
|
+
panels[currentPanelIndex].push(row);
|
1134
|
+
}
|
1135
|
+
}
|
1136
|
+
return panels;
|
1137
|
+
}, []);
|
1138
|
+
const componentEditAttributes = Object.entries(data.components).reduce(
|
1139
|
+
(acc, [uid, configuration]) => {
|
1140
|
+
acc[uid] = {
|
1141
|
+
layout: convertEditLayoutToFieldLayouts(
|
1142
|
+
configuration.layouts.edit,
|
1143
|
+
components[uid].attributes,
|
1144
|
+
configuration.metadatas,
|
1145
|
+
{ configurations: data.components, schemas: components }
|
1146
|
+
),
|
1147
|
+
settings: {
|
1148
|
+
...configuration.settings,
|
1149
|
+
icon: components[uid].info.icon,
|
1150
|
+
displayName: components[uid].info.displayName
|
1151
|
+
}
|
1152
|
+
};
|
1153
|
+
return acc;
|
1154
|
+
},
|
1155
|
+
{}
|
1156
|
+
);
|
1157
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1158
|
+
(acc, [attribute, metadata]) => {
|
1159
|
+
return {
|
1160
|
+
...acc,
|
1161
|
+
[attribute]: metadata.edit
|
1162
|
+
};
|
1163
|
+
},
|
1164
|
+
{}
|
1165
|
+
);
|
1166
|
+
return {
|
1167
|
+
layout: panelledEditAttributes,
|
1168
|
+
components: componentEditAttributes,
|
1169
|
+
metadatas: editMetadatas,
|
1170
|
+
settings: {
|
1171
|
+
...data.contentType.settings,
|
1172
|
+
displayName: schema?.info.displayName
|
1173
|
+
},
|
1174
|
+
options: {
|
1175
|
+
...schema?.options,
|
1176
|
+
...schema?.pluginOptions,
|
1177
|
+
...data.contentType.options
|
1178
|
+
}
|
1179
|
+
};
|
1180
|
+
};
|
1181
|
+
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
1182
|
+
return rows.map(
|
1183
|
+
(row) => row.map((field) => {
|
1184
|
+
const attribute = attributes[field.name];
|
1185
|
+
if (!attribute) {
|
1186
|
+
return null;
|
1187
|
+
}
|
1188
|
+
const { edit: metadata } = metadatas[field.name];
|
1189
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1190
|
+
return {
|
1191
|
+
attribute,
|
1192
|
+
disabled: !metadata.editable,
|
1193
|
+
hint: metadata.description,
|
1194
|
+
label: metadata.label ?? "",
|
1195
|
+
name: field.name,
|
1196
|
+
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
1197
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1198
|
+
schemas,
|
1199
|
+
components: components?.schemas ?? {}
|
1200
|
+
}),
|
1201
|
+
placeholder: metadata.placeholder ?? "",
|
1202
|
+
required: attribute.required ?? false,
|
1203
|
+
size: field.size,
|
1204
|
+
unique: "unique" in attribute ? attribute.unique : false,
|
1205
|
+
visible: metadata.visible ?? true,
|
1206
|
+
type: attribute.type
|
1207
|
+
};
|
1208
|
+
}).filter((field) => field !== null)
|
1209
|
+
);
|
1210
|
+
};
|
1211
|
+
const formatListLayout = (data, {
|
1212
|
+
schemas,
|
1213
|
+
schema,
|
1214
|
+
components
|
1215
|
+
}) => {
|
1216
|
+
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1217
|
+
(acc, [attribute, metadata]) => {
|
1218
|
+
return {
|
1219
|
+
...acc,
|
1220
|
+
[attribute]: metadata.list
|
1221
|
+
};
|
1222
|
+
},
|
1223
|
+
{}
|
1224
|
+
);
|
1225
|
+
const listAttributes = convertListLayoutToFieldLayouts(
|
1226
|
+
data.contentType.layouts.list,
|
1227
|
+
schema?.attributes,
|
1228
|
+
listMetadatas,
|
1229
|
+
{ configurations: data.components, schemas: components },
|
1230
|
+
schemas
|
1231
|
+
);
|
1232
|
+
return {
|
1233
|
+
layout: listAttributes,
|
1234
|
+
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
1235
|
+
metadatas: listMetadatas,
|
1236
|
+
options: {
|
1237
|
+
...schema?.options,
|
1238
|
+
...schema?.pluginOptions,
|
1239
|
+
...data.contentType.options
|
1240
|
+
}
|
1241
|
+
};
|
1242
|
+
};
|
1243
|
+
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
1244
|
+
return columns.map((name) => {
|
1245
|
+
const attribute = attributes[name];
|
1246
|
+
if (!attribute) {
|
1247
|
+
return null;
|
1248
|
+
}
|
1249
|
+
const metadata = metadatas[name];
|
1250
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1251
|
+
return {
|
1252
|
+
attribute,
|
1253
|
+
label: metadata.label ?? "",
|
1254
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1255
|
+
schemas,
|
1256
|
+
components: components?.schemas ?? {}
|
1257
|
+
}),
|
1258
|
+
name,
|
1259
|
+
searchable: metadata.searchable ?? true,
|
1260
|
+
sortable: metadata.sortable ?? true
|
1261
|
+
};
|
1262
|
+
}).filter((field) => field !== null);
|
1263
|
+
};
|
1264
|
+
const useDocument = (args, opts) => {
|
1265
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
1266
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1267
|
+
const { formatMessage } = reactIntl.useIntl();
|
1268
|
+
const {
|
1269
|
+
currentData: data,
|
1270
|
+
isLoading: isLoadingDocument,
|
1271
|
+
isFetching: isFetchingDocument,
|
1272
|
+
error
|
1273
|
+
} = useGetDocumentQuery(args, {
|
1274
|
+
...opts,
|
1275
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
1276
|
+
});
|
1277
|
+
const document = data?.data;
|
1278
|
+
const meta = data?.meta;
|
1279
|
+
const {
|
1280
|
+
components,
|
1281
|
+
schema,
|
1282
|
+
schemas,
|
1283
|
+
isLoading: isLoadingSchema
|
1284
|
+
} = useContentTypeSchema(args.model);
|
1285
|
+
const isSingleType = schema?.kind === "singleType";
|
1286
|
+
const getTitle = (mainField) => {
|
1287
|
+
if (mainField !== "id" && document?.[mainField]) {
|
1288
|
+
return document[mainField];
|
1289
|
+
}
|
1290
|
+
if (isSingleType && schema?.info.displayName) {
|
1291
|
+
return schema.info.displayName;
|
1292
|
+
}
|
1293
|
+
return formatMessage({
|
1294
|
+
id: "content-manager.containers.untitled",
|
1295
|
+
defaultMessage: "Untitled"
|
1296
|
+
});
|
1297
|
+
};
|
1298
|
+
React__namespace.useEffect(() => {
|
1299
|
+
if (error) {
|
1300
|
+
toggleNotification({
|
1301
|
+
type: "danger",
|
1302
|
+
message: formatAPIError(error)
|
1303
|
+
});
|
1304
|
+
}
|
1305
|
+
}, [toggleNotification, error, formatAPIError, args.collectionType]);
|
1306
|
+
const validationSchema = React__namespace.useMemo(() => {
|
1307
|
+
if (!schema) {
|
1308
|
+
return null;
|
1309
|
+
}
|
1310
|
+
return createYupSchema(schema.attributes, components);
|
1311
|
+
}, [schema, components]);
|
1312
|
+
const validate = React__namespace.useCallback(
|
1313
|
+
(document2) => {
|
1314
|
+
if (!validationSchema) {
|
1315
|
+
throw new Error(
|
1316
|
+
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
1317
|
+
);
|
1318
|
+
}
|
1319
|
+
try {
|
1320
|
+
validationSchema.validateSync(document2, { abortEarly: false, strict: true });
|
1321
|
+
return null;
|
1322
|
+
} catch (error2) {
|
1323
|
+
if (error2 instanceof yup.ValidationError) {
|
815
1324
|
return strapiAdmin.getYupValidationErrors(error2);
|
816
1325
|
}
|
817
1326
|
throw error2;
|
@@ -819,14 +1328,29 @@ const useDocument = (args, opts) => {
|
|
819
1328
|
},
|
820
1329
|
[validationSchema]
|
821
1330
|
);
|
1331
|
+
const getInitialFormValues = React__namespace.useCallback(
|
1332
|
+
(isCreatingDocument = false) => {
|
1333
|
+
if (!document && !isCreatingDocument && !isSingleType || !schema) {
|
1334
|
+
return void 0;
|
1335
|
+
}
|
1336
|
+
const form = document?.id ? document : createDefaultForm(schema, components);
|
1337
|
+
return transformDocument(schema, components)(form);
|
1338
|
+
},
|
1339
|
+
[document, isSingleType, schema, components]
|
1340
|
+
);
|
822
1341
|
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
1342
|
+
const hasError = !!error;
|
823
1343
|
return {
|
824
1344
|
components,
|
825
|
-
document
|
826
|
-
meta
|
1345
|
+
document,
|
1346
|
+
meta,
|
827
1347
|
isLoading,
|
1348
|
+
hasError,
|
828
1349
|
schema,
|
829
|
-
|
1350
|
+
schemas,
|
1351
|
+
validate,
|
1352
|
+
getTitle,
|
1353
|
+
getInitialFormValues
|
830
1354
|
};
|
831
1355
|
};
|
832
1356
|
const useDoc = () => {
|
@@ -839,22 +1363,60 @@ const useDoc = () => {
|
|
839
1363
|
if (!slug) {
|
840
1364
|
throw new Error("Could not find model in url params");
|
841
1365
|
}
|
1366
|
+
const document = useDocument(
|
1367
|
+
{ documentId: origin || id, model: slug, collectionType, params },
|
1368
|
+
{
|
1369
|
+
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
1370
|
+
}
|
1371
|
+
);
|
1372
|
+
const returnId = origin || id === "create" ? void 0 : id;
|
842
1373
|
return {
|
843
1374
|
collectionType,
|
844
1375
|
model: slug,
|
845
|
-
id:
|
846
|
-
...
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
1376
|
+
id: returnId,
|
1377
|
+
...document
|
1378
|
+
};
|
1379
|
+
};
|
1380
|
+
const useContentManagerContext = () => {
|
1381
|
+
const {
|
1382
|
+
collectionType,
|
1383
|
+
model,
|
1384
|
+
id,
|
1385
|
+
components,
|
1386
|
+
isLoading: isLoadingDoc,
|
1387
|
+
schema,
|
1388
|
+
schemas
|
1389
|
+
} = useDoc();
|
1390
|
+
const layout = useDocumentLayout(model);
|
1391
|
+
const form = strapiAdmin.useForm("useContentManagerContext", (state) => state);
|
1392
|
+
const isSingleType = collectionType === SINGLE_TYPES;
|
1393
|
+
const slug = model;
|
1394
|
+
const isCreatingEntry = id === "create";
|
1395
|
+
useContentTypeSchema();
|
1396
|
+
const isLoading = isLoadingDoc || layout.isLoading;
|
1397
|
+
const error = layout.error;
|
1398
|
+
return {
|
1399
|
+
error,
|
1400
|
+
isLoading,
|
1401
|
+
// Base metadata
|
1402
|
+
model,
|
1403
|
+
collectionType,
|
1404
|
+
id,
|
1405
|
+
slug,
|
1406
|
+
isCreatingEntry,
|
1407
|
+
isSingleType,
|
1408
|
+
hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
|
1409
|
+
// All schema infos
|
1410
|
+
components,
|
1411
|
+
contentType: schema,
|
1412
|
+
contentTypes: schemas,
|
1413
|
+
// Form state
|
1414
|
+
form,
|
1415
|
+
// layout infos
|
1416
|
+
layout
|
852
1417
|
};
|
853
1418
|
};
|
854
1419
|
const prefixPluginTranslations = (trad, pluginId) => {
|
855
|
-
if (!pluginId) {
|
856
|
-
throw new TypeError("pluginId can't be empty");
|
857
|
-
}
|
858
1420
|
return Object.keys(trad).reduce((acc, current) => {
|
859
1421
|
acc[`${pluginId}.${current}`] = trad[current];
|
860
1422
|
return acc;
|
@@ -870,6 +1432,8 @@ const useDocumentActions = () => {
|
|
870
1432
|
const { formatMessage } = reactIntl.useIntl();
|
871
1433
|
const { trackUsage } = strapiAdmin.useTracking();
|
872
1434
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1435
|
+
const navigate = reactRouterDom.useNavigate();
|
1436
|
+
const setCurrentStep = strapiAdmin.useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
|
873
1437
|
const [deleteDocument] = useDeleteDocumentMutation();
|
874
1438
|
const _delete = React__namespace.useCallback(
|
875
1439
|
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
@@ -948,12 +1512,13 @@ const useDocumentActions = () => {
|
|
948
1512
|
);
|
949
1513
|
const [discardDocument] = useDiscardDocumentMutation();
|
950
1514
|
const discard = React__namespace.useCallback(
|
951
|
-
async ({ collectionType, model, documentId }) => {
|
1515
|
+
async ({ collectionType, model, documentId, params }) => {
|
952
1516
|
try {
|
953
1517
|
const res = await discardDocument({
|
954
1518
|
collectionType,
|
955
1519
|
model,
|
956
|
-
documentId
|
1520
|
+
documentId,
|
1521
|
+
params
|
957
1522
|
});
|
958
1523
|
if ("error" in res) {
|
959
1524
|
toggleNotification({
|
@@ -1183,6 +1748,7 @@ const useDocumentActions = () => {
|
|
1183
1748
|
defaultMessage: "Saved document"
|
1184
1749
|
})
|
1185
1750
|
});
|
1751
|
+
setCurrentStep("contentManager.success");
|
1186
1752
|
return res.data;
|
1187
1753
|
} catch (err) {
|
1188
1754
|
toggleNotification({
|
@@ -1204,7 +1770,6 @@ const useDocumentActions = () => {
|
|
1204
1770
|
sourceId
|
1205
1771
|
});
|
1206
1772
|
if ("error" in res) {
|
1207
|
-
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1208
1773
|
return { error: res.error };
|
1209
1774
|
}
|
1210
1775
|
toggleNotification({
|
@@ -1223,7 +1788,7 @@ const useDocumentActions = () => {
|
|
1223
1788
|
throw err;
|
1224
1789
|
}
|
1225
1790
|
},
|
1226
|
-
[autoCloneDocument,
|
1791
|
+
[autoCloneDocument, formatMessage, toggleNotification]
|
1227
1792
|
);
|
1228
1793
|
const [cloneDocument] = useCloneDocumentMutation();
|
1229
1794
|
const clone = React__namespace.useCallback(
|
@@ -1249,6 +1814,7 @@ const useDocumentActions = () => {
|
|
1249
1814
|
defaultMessage: "Cloned document"
|
1250
1815
|
})
|
1251
1816
|
});
|
1817
|
+
navigate(`../../${res.data.data.documentId}`, { relative: "path" });
|
1252
1818
|
return res.data;
|
1253
1819
|
} catch (err) {
|
1254
1820
|
toggleNotification({
|
@@ -1259,7 +1825,7 @@ const useDocumentActions = () => {
|
|
1259
1825
|
throw err;
|
1260
1826
|
}
|
1261
1827
|
},
|
1262
|
-
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
|
1828
|
+
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
|
1263
1829
|
);
|
1264
1830
|
const [getDoc] = useLazyGetDocumentQuery();
|
1265
1831
|
const getDocument = React__namespace.useCallback(
|
@@ -1284,10 +1850,10 @@ const useDocumentActions = () => {
|
|
1284
1850
|
update
|
1285
1851
|
};
|
1286
1852
|
};
|
1287
|
-
const ProtectedHistoryPage =
|
1288
|
-
() => Promise.resolve().then(() => require("./History-
|
1853
|
+
const ProtectedHistoryPage = React__namespace.lazy(
|
1854
|
+
() => Promise.resolve().then(() => require("./History-BgZ7gVuF.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1289
1855
|
);
|
1290
|
-
const routes$
|
1856
|
+
const routes$2 = [
|
1291
1857
|
{
|
1292
1858
|
path: ":collectionType/:slug/:id/history",
|
1293
1859
|
Component: ProtectedHistoryPage
|
@@ -1297,32 +1863,45 @@ const routes$1 = [
|
|
1297
1863
|
Component: ProtectedHistoryPage
|
1298
1864
|
}
|
1299
1865
|
];
|
1300
|
-
const
|
1301
|
-
() => Promise.resolve().then(() => require("./
|
1866
|
+
const ProtectedPreviewPage = React__namespace.lazy(
|
1867
|
+
() => Promise.resolve().then(() => require("./Preview-DgzAuzWQ.js")).then((mod) => ({ default: mod.ProtectedPreviewPage }))
|
1868
|
+
);
|
1869
|
+
const routes$1 = [
|
1870
|
+
{
|
1871
|
+
path: ":collectionType/:slug/:id/preview",
|
1872
|
+
Component: ProtectedPreviewPage
|
1873
|
+
},
|
1874
|
+
{
|
1875
|
+
path: ":collectionType/:slug/preview",
|
1876
|
+
Component: ProtectedPreviewPage
|
1877
|
+
}
|
1878
|
+
];
|
1879
|
+
const ProtectedEditViewPage = React.lazy(
|
1880
|
+
() => Promise.resolve().then(() => require("./EditViewPage-BfR6jAR6.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1302
1881
|
);
|
1303
1882
|
const ProtectedListViewPage = React.lazy(
|
1304
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1883
|
+
() => Promise.resolve().then(() => require("./ListViewPage-CJFDudKl.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1305
1884
|
);
|
1306
1885
|
const ProtectedListConfiguration = React.lazy(
|
1307
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1886
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-DnJ3nbwL.js")).then((mod) => ({
|
1308
1887
|
default: mod.ProtectedListConfiguration
|
1309
1888
|
}))
|
1310
1889
|
);
|
1311
1890
|
const ProtectedEditConfigurationPage = React.lazy(
|
1312
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1891
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-CXxV7mKn.js")).then((mod) => ({
|
1313
1892
|
default: mod.ProtectedEditConfigurationPage
|
1314
1893
|
}))
|
1315
1894
|
);
|
1316
1895
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1317
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1896
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-DMxUlNOo.js")).then((mod) => ({
|
1318
1897
|
default: mod.ProtectedComponentConfigurationPage
|
1319
1898
|
}))
|
1320
1899
|
);
|
1321
1900
|
const NoPermissions = React.lazy(
|
1322
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1901
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-CcjILry3.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1323
1902
|
);
|
1324
1903
|
const NoContentType = React.lazy(
|
1325
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1904
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-en2PwWgI.js")).then((mod) => ({ default: mod.NoContentType }))
|
1326
1905
|
);
|
1327
1906
|
const CollectionTypePages = () => {
|
1328
1907
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1334,7 +1913,7 @@ const CollectionTypePages = () => {
|
|
1334
1913
|
const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
|
1335
1914
|
const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
|
1336
1915
|
const LIST_RELATIVE_PATH = ":collectionType/:slug";
|
1337
|
-
const LIST_PATH = `/content-manager
|
1916
|
+
const LIST_PATH = `/content-manager/collection-types/:slug`;
|
1338
1917
|
const routes = [
|
1339
1918
|
{
|
1340
1919
|
path: LIST_RELATIVE_PATH,
|
@@ -1368,6 +1947,7 @@ const routes = [
|
|
1368
1947
|
path: "no-content-types",
|
1369
1948
|
Component: NoContentType
|
1370
1949
|
},
|
1950
|
+
...routes$2,
|
1371
1951
|
...routes$1
|
1372
1952
|
];
|
1373
1953
|
const DocumentActions = ({ actions: actions2 }) => {
|
@@ -1436,12 +2016,14 @@ const DocumentActionButton = (action) => {
|
|
1436
2016
|
/* @__PURE__ */ jsxRuntime.jsx(
|
1437
2017
|
designSystem.Button,
|
1438
2018
|
{
|
1439
|
-
flex:
|
2019
|
+
flex: "auto",
|
1440
2020
|
startIcon: action.icon,
|
1441
2021
|
disabled: action.disabled,
|
1442
2022
|
onClick: handleClick(action),
|
1443
2023
|
justifyContent: "center",
|
1444
2024
|
variant: action.variant || "default",
|
2025
|
+
paddingTop: "7px",
|
2026
|
+
paddingBottom: "7px",
|
1445
2027
|
children: action.label
|
1446
2028
|
}
|
1447
2029
|
),
|
@@ -1449,7 +2031,7 @@ const DocumentActionButton = (action) => {
|
|
1449
2031
|
DocumentActionConfirmDialog,
|
1450
2032
|
{
|
1451
2033
|
...action.dialog,
|
1452
|
-
variant: action.variant,
|
2034
|
+
variant: action.dialog?.variant ?? action.variant,
|
1453
2035
|
isOpen: dialogId === action.id,
|
1454
2036
|
onClose: handleClose
|
1455
2037
|
}
|
@@ -1464,6 +2046,11 @@ const DocumentActionButton = (action) => {
|
|
1464
2046
|
) : null
|
1465
2047
|
] });
|
1466
2048
|
};
|
2049
|
+
const MenuItem = styledComponents.styled(designSystem.Menu.Item)`
|
2050
|
+
&:hover {
|
2051
|
+
background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
|
2052
|
+
}
|
2053
|
+
`;
|
1467
2054
|
const DocumentActionsMenu = ({
|
1468
2055
|
actions: actions2,
|
1469
2056
|
children,
|
@@ -1506,9 +2093,9 @@ const DocumentActionsMenu = ({
|
|
1506
2093
|
disabled: isDisabled,
|
1507
2094
|
size: "S",
|
1508
2095
|
endIcon: null,
|
1509
|
-
paddingTop: "
|
1510
|
-
paddingLeft: "
|
1511
|
-
paddingRight: "
|
2096
|
+
paddingTop: "4px",
|
2097
|
+
paddingLeft: "7px",
|
2098
|
+
paddingRight: "7px",
|
1512
2099
|
variant,
|
1513
2100
|
children: [
|
1514
2101
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
|
@@ -1519,36 +2106,35 @@ const DocumentActionsMenu = ({
|
|
1519
2106
|
]
|
1520
2107
|
}
|
1521
2108
|
),
|
1522
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, {
|
2109
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
|
1523
2110
|
actions2.map((action) => {
|
1524
2111
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
1525
|
-
|
2112
|
+
MenuItem,
|
1526
2113
|
{
|
1527
2114
|
disabled: action.disabled,
|
1528
2115
|
onSelect: handleClick(action),
|
1529
2116
|
display: "block",
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
] })
|
2117
|
+
isVariantDanger: action.variant === "danger",
|
2118
|
+
isDisabled: action.disabled,
|
2119
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
2120
|
+
designSystem.Flex,
|
2121
|
+
{
|
2122
|
+
color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
|
2123
|
+
gap: 2,
|
2124
|
+
tag: "span",
|
2125
|
+
children: [
|
2126
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2127
|
+
designSystem.Flex,
|
2128
|
+
{
|
2129
|
+
tag: "span",
|
2130
|
+
color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
|
2131
|
+
children: action.icon
|
2132
|
+
}
|
2133
|
+
),
|
2134
|
+
action.label
|
2135
|
+
]
|
2136
|
+
}
|
2137
|
+
) })
|
1552
2138
|
},
|
1553
2139
|
action.id
|
1554
2140
|
);
|
@@ -1590,6 +2176,18 @@ const convertActionVariantToColor = (variant = "secondary") => {
|
|
1590
2176
|
return "primary600";
|
1591
2177
|
}
|
1592
2178
|
};
|
2179
|
+
const convertActionVariantToIconColor = (variant = "secondary") => {
|
2180
|
+
switch (variant) {
|
2181
|
+
case "danger":
|
2182
|
+
return "danger600";
|
2183
|
+
case "secondary":
|
2184
|
+
return "neutral500";
|
2185
|
+
case "success":
|
2186
|
+
return "success600";
|
2187
|
+
default:
|
2188
|
+
return "primary600";
|
2189
|
+
}
|
2190
|
+
};
|
1593
2191
|
const DocumentActionConfirmDialog = ({
|
1594
2192
|
onClose,
|
1595
2193
|
onCancel,
|
@@ -1612,22 +2210,20 @@ const DocumentActionConfirmDialog = ({
|
|
1612
2210
|
}
|
1613
2211
|
onClose();
|
1614
2212
|
};
|
1615
|
-
return /* @__PURE__ */ jsxRuntime.
|
1616
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1617
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1618
|
-
|
1619
|
-
{
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
)
|
1630
|
-
] });
|
2213
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2214
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
2215
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
|
2216
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
2217
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
|
2218
|
+
id: "app.components.Button.cancel",
|
2219
|
+
defaultMessage: "Cancel"
|
2220
|
+
}) }) }),
|
2221
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
|
2222
|
+
id: "app.components.Button.confirm",
|
2223
|
+
defaultMessage: "Confirm"
|
2224
|
+
}) })
|
2225
|
+
] })
|
2226
|
+
] }) });
|
1631
2227
|
};
|
1632
2228
|
const DocumentActionModal = ({
|
1633
2229
|
isOpen,
|
@@ -1637,34 +2233,29 @@ const DocumentActionModal = ({
|
|
1637
2233
|
content: Content,
|
1638
2234
|
onModalClose
|
1639
2235
|
}) => {
|
1640
|
-
const id = React__namespace.useId();
|
1641
|
-
if (!isOpen) {
|
1642
|
-
return null;
|
1643
|
-
}
|
1644
2236
|
const handleClose = () => {
|
1645
2237
|
if (onClose) {
|
1646
2238
|
onClose();
|
1647
2239
|
}
|
1648
2240
|
onModalClose();
|
1649
2241
|
};
|
1650
|
-
return /* @__PURE__ */ jsxRuntime.
|
1651
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1652
|
-
|
1653
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
] });
|
2242
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
|
2243
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title }) }),
|
2244
|
+
typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: Content }),
|
2245
|
+
typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
|
2246
|
+
] }) });
|
2247
|
+
};
|
2248
|
+
const transformData = (data) => {
|
2249
|
+
if (Array.isArray(data)) {
|
2250
|
+
return data.map(transformData);
|
2251
|
+
}
|
2252
|
+
if (typeof data === "object" && data !== null) {
|
2253
|
+
if ("apiData" in data) {
|
2254
|
+
return data.apiData;
|
2255
|
+
}
|
2256
|
+
return mapValues__default.default(transformData)(data);
|
2257
|
+
}
|
2258
|
+
return data;
|
1668
2259
|
};
|
1669
2260
|
const PublishAction$1 = ({
|
1670
2261
|
activeTab,
|
@@ -1678,13 +2269,18 @@ const PublishAction$1 = ({
|
|
1678
2269
|
const navigate = reactRouterDom.useNavigate();
|
1679
2270
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1680
2271
|
const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
|
2272
|
+
const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
|
1681
2273
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2274
|
+
const { id } = reactRouterDom.useParams();
|
1682
2275
|
const { formatMessage } = reactIntl.useIntl();
|
1683
|
-
const { canPublish
|
1684
|
-
"PublishAction",
|
1685
|
-
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1686
|
-
);
|
2276
|
+
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
1687
2277
|
const { publish } = useDocumentActions();
|
2278
|
+
const [
|
2279
|
+
countDraftRelations,
|
2280
|
+
{ isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }
|
2281
|
+
] = useLazyGetDraftRelationCountQuery();
|
2282
|
+
const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React__namespace.useState(0);
|
2283
|
+
const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React__namespace.useState(0);
|
1688
2284
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1689
2285
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
1690
2286
|
const modified = strapiAdmin.useForm("PublishAction", ({ modified: modified2 }) => modified2);
|
@@ -1693,10 +2289,107 @@ const PublishAction$1 = ({
|
|
1693
2289
|
const validate = strapiAdmin.useForm("PublishAction", (state) => state.validate);
|
1694
2290
|
const setErrors = strapiAdmin.useForm("PublishAction", (state) => state.setErrors);
|
1695
2291
|
const formValues = strapiAdmin.useForm("PublishAction", ({ values }) => values);
|
2292
|
+
React__namespace.useEffect(() => {
|
2293
|
+
if (isErrorDraftRelations) {
|
2294
|
+
toggleNotification({
|
2295
|
+
type: "danger",
|
2296
|
+
message: formatMessage({
|
2297
|
+
id: getTranslation("error.records.fetch-draft-relatons"),
|
2298
|
+
defaultMessage: "An error occurred while fetching draft relations on this document."
|
2299
|
+
})
|
2300
|
+
});
|
2301
|
+
}
|
2302
|
+
}, [isErrorDraftRelations, toggleNotification, formatMessage]);
|
2303
|
+
React__namespace.useEffect(() => {
|
2304
|
+
const localDraftRelations = /* @__PURE__ */ new Set();
|
2305
|
+
const extractDraftRelations = (data) => {
|
2306
|
+
const relations = data.connect || [];
|
2307
|
+
relations.forEach((relation) => {
|
2308
|
+
if (relation.status === "draft") {
|
2309
|
+
localDraftRelations.add(relation.id);
|
2310
|
+
}
|
2311
|
+
});
|
2312
|
+
};
|
2313
|
+
const traverseAndExtract = (data) => {
|
2314
|
+
Object.entries(data).forEach(([key, value]) => {
|
2315
|
+
if (key === "connect" && Array.isArray(value)) {
|
2316
|
+
extractDraftRelations({ connect: value });
|
2317
|
+
} else if (typeof value === "object" && value !== null) {
|
2318
|
+
traverseAndExtract(value);
|
2319
|
+
}
|
2320
|
+
});
|
2321
|
+
};
|
2322
|
+
if (!documentId || modified) {
|
2323
|
+
traverseAndExtract(formValues);
|
2324
|
+
setLocalCountOfDraftRelations(localDraftRelations.size);
|
2325
|
+
}
|
2326
|
+
}, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
|
2327
|
+
React__namespace.useEffect(() => {
|
2328
|
+
if (!document || !document.documentId || isListView) {
|
2329
|
+
return;
|
2330
|
+
}
|
2331
|
+
const fetchDraftRelationsCount = async () => {
|
2332
|
+
const { data, error } = await countDraftRelations({
|
2333
|
+
collectionType,
|
2334
|
+
model,
|
2335
|
+
documentId,
|
2336
|
+
params
|
2337
|
+
});
|
2338
|
+
if (error) {
|
2339
|
+
throw error;
|
2340
|
+
}
|
2341
|
+
if (data) {
|
2342
|
+
setServerCountOfDraftRelations(data.data);
|
2343
|
+
}
|
2344
|
+
};
|
2345
|
+
fetchDraftRelationsCount();
|
2346
|
+
}, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
|
1696
2347
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1697
2348
|
if (!schema?.options?.draftAndPublish) {
|
1698
2349
|
return null;
|
1699
2350
|
}
|
2351
|
+
const performPublish = async () => {
|
2352
|
+
setSubmitting(true);
|
2353
|
+
try {
|
2354
|
+
const { errors } = await validate(true, {
|
2355
|
+
status: "published"
|
2356
|
+
});
|
2357
|
+
if (errors) {
|
2358
|
+
toggleNotification({
|
2359
|
+
type: "danger",
|
2360
|
+
message: formatMessage({
|
2361
|
+
id: "content-manager.validation.error",
|
2362
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
2363
|
+
})
|
2364
|
+
});
|
2365
|
+
return;
|
2366
|
+
}
|
2367
|
+
const res = await publish(
|
2368
|
+
{
|
2369
|
+
collectionType,
|
2370
|
+
model,
|
2371
|
+
documentId,
|
2372
|
+
params
|
2373
|
+
},
|
2374
|
+
transformData(formValues)
|
2375
|
+
);
|
2376
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
2377
|
+
if (id === "create") {
|
2378
|
+
navigate({
|
2379
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
2380
|
+
search: rawQuery
|
2381
|
+
});
|
2382
|
+
}
|
2383
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2384
|
+
setErrors(formatValidationErrors(res.error));
|
2385
|
+
}
|
2386
|
+
} finally {
|
2387
|
+
setSubmitting(false);
|
2388
|
+
}
|
2389
|
+
};
|
2390
|
+
const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
|
2391
|
+
const enableDraftRelationsCount = false;
|
2392
|
+
const hasDraftRelations = enableDraftRelationsCount;
|
1700
2393
|
return {
|
1701
2394
|
/**
|
1702
2395
|
* Disabled when:
|
@@ -1706,52 +2399,40 @@ const PublishAction$1 = ({
|
|
1706
2399
|
* - the document is already published & not modified
|
1707
2400
|
* - the document is being created & not modified
|
1708
2401
|
* - the user doesn't have the permission to publish
|
1709
|
-
* - the user doesn't have the permission to create a new document
|
1710
|
-
* - the user doesn't have the permission to update the document
|
1711
2402
|
*/
|
1712
|
-
disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish
|
2403
|
+
disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
|
1713
2404
|
label: formatMessage({
|
1714
2405
|
id: "app.utils.publish",
|
1715
2406
|
defaultMessage: "Publish"
|
1716
2407
|
}),
|
1717
2408
|
onClick: async () => {
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
documentId,
|
1736
|
-
params
|
1737
|
-
},
|
1738
|
-
formValues
|
1739
|
-
);
|
1740
|
-
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1741
|
-
navigate({
|
1742
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1743
|
-
search: rawQuery
|
1744
|
-
});
|
1745
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1746
|
-
setErrors(formatValidationErrors(res.error));
|
2409
|
+
await performPublish();
|
2410
|
+
},
|
2411
|
+
dialog: hasDraftRelations ? {
|
2412
|
+
type: "dialog",
|
2413
|
+
variant: "danger",
|
2414
|
+
footer: null,
|
2415
|
+
title: formatMessage({
|
2416
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.title`),
|
2417
|
+
defaultMessage: "Confirmation"
|
2418
|
+
}),
|
2419
|
+
content: formatMessage(
|
2420
|
+
{
|
2421
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
|
2422
|
+
defaultMessage: "This entry is related to {count, plural, one {# draft entry} other {# draft entries}}. Publishing it could leave broken links in your app."
|
2423
|
+
},
|
2424
|
+
{
|
2425
|
+
count: totalDraftRelations
|
1747
2426
|
}
|
1748
|
-
|
1749
|
-
|
2427
|
+
),
|
2428
|
+
onConfirm: async () => {
|
2429
|
+
await performPublish();
|
1750
2430
|
}
|
1751
|
-
}
|
2431
|
+
} : void 0
|
1752
2432
|
};
|
1753
2433
|
};
|
1754
2434
|
PublishAction$1.type = "publish";
|
2435
|
+
PublishAction$1.position = "panel";
|
1755
2436
|
const UpdateAction = ({
|
1756
2437
|
activeTab,
|
1757
2438
|
documentId,
|
@@ -1764,10 +2445,6 @@ const UpdateAction = ({
|
|
1764
2445
|
const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
|
1765
2446
|
const isCloning = cloneMatch !== null;
|
1766
2447
|
const { formatMessage } = reactIntl.useIntl();
|
1767
|
-
const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
|
1768
|
-
canCreate: canCreate2,
|
1769
|
-
canUpdate: canUpdate2
|
1770
|
-
}));
|
1771
2448
|
const { create, update, clone } = useDocumentActions();
|
1772
2449
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1773
2450
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
@@ -1778,90 +2455,134 @@ const UpdateAction = ({
|
|
1778
2455
|
const validate = strapiAdmin.useForm("UpdateAction", (state) => state.validate);
|
1779
2456
|
const setErrors = strapiAdmin.useForm("UpdateAction", (state) => state.setErrors);
|
1780
2457
|
const resetForm = strapiAdmin.useForm("PublishAction", ({ resetForm: resetForm2 }) => resetForm2);
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
}
|
1807
|
-
|
1808
|
-
|
1809
|
-
if (
|
1810
|
-
|
2458
|
+
const handleUpdate = React__namespace.useCallback(async () => {
|
2459
|
+
setSubmitting(true);
|
2460
|
+
try {
|
2461
|
+
if (!modified) {
|
2462
|
+
return;
|
2463
|
+
}
|
2464
|
+
const { errors } = await validate(true, {
|
2465
|
+
status: "draft"
|
2466
|
+
});
|
2467
|
+
if (errors) {
|
2468
|
+
toggleNotification({
|
2469
|
+
type: "danger",
|
2470
|
+
message: formatMessage({
|
2471
|
+
id: "content-manager.validation.error",
|
2472
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
2473
|
+
})
|
2474
|
+
});
|
2475
|
+
return;
|
2476
|
+
}
|
2477
|
+
if (isCloning) {
|
2478
|
+
const res = await clone(
|
2479
|
+
{
|
2480
|
+
model,
|
2481
|
+
documentId: cloneMatch.params.origin,
|
2482
|
+
params
|
2483
|
+
},
|
2484
|
+
transformData(document)
|
2485
|
+
);
|
2486
|
+
if ("data" in res) {
|
2487
|
+
navigate(
|
1811
2488
|
{
|
1812
|
-
|
1813
|
-
documentId: cloneMatch.params.origin,
|
1814
|
-
params
|
1815
|
-
},
|
1816
|
-
document
|
1817
|
-
);
|
1818
|
-
if ("data" in res) {
|
1819
|
-
navigate({
|
1820
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
2489
|
+
pathname: `../${res.data.documentId}`,
|
1821
2490
|
search: rawQuery
|
1822
|
-
});
|
1823
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1824
|
-
setErrors(formatValidationErrors(res.error));
|
1825
|
-
}
|
1826
|
-
} else if (documentId || collectionType === SINGLE_TYPES) {
|
1827
|
-
const res = await update(
|
1828
|
-
{
|
1829
|
-
collectionType,
|
1830
|
-
model,
|
1831
|
-
documentId,
|
1832
|
-
params
|
1833
2491
|
},
|
1834
|
-
|
2492
|
+
{ relative: "path" }
|
1835
2493
|
);
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
2494
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2495
|
+
setErrors(formatValidationErrors(res.error));
|
2496
|
+
}
|
2497
|
+
} else if (documentId || collectionType === SINGLE_TYPES) {
|
2498
|
+
const res = await update(
|
2499
|
+
{
|
2500
|
+
collectionType,
|
2501
|
+
model,
|
2502
|
+
documentId,
|
2503
|
+
params
|
2504
|
+
},
|
2505
|
+
transformData(document)
|
2506
|
+
);
|
2507
|
+
if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2508
|
+
setErrors(formatValidationErrors(res.error));
|
1841
2509
|
} else {
|
1842
|
-
|
2510
|
+
resetForm();
|
2511
|
+
}
|
2512
|
+
} else {
|
2513
|
+
const res = await create(
|
2514
|
+
{
|
2515
|
+
model,
|
2516
|
+
params
|
2517
|
+
},
|
2518
|
+
transformData(document)
|
2519
|
+
);
|
2520
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
2521
|
+
navigate(
|
1843
2522
|
{
|
1844
|
-
|
1845
|
-
|
2523
|
+
pathname: `../${res.data.documentId}`,
|
2524
|
+
search: rawQuery
|
1846
2525
|
},
|
1847
|
-
|
2526
|
+
{ replace: true, relative: "path" }
|
1848
2527
|
);
|
1849
|
-
|
1850
|
-
|
1851
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1852
|
-
search: rawQuery
|
1853
|
-
});
|
1854
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1855
|
-
setErrors(formatValidationErrors(res.error));
|
1856
|
-
}
|
2528
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2529
|
+
setErrors(formatValidationErrors(res.error));
|
1857
2530
|
}
|
1858
|
-
} finally {
|
1859
|
-
setSubmitting(false);
|
1860
2531
|
}
|
2532
|
+
} finally {
|
2533
|
+
setSubmitting(false);
|
1861
2534
|
}
|
2535
|
+
}, [
|
2536
|
+
clone,
|
2537
|
+
cloneMatch?.params.origin,
|
2538
|
+
collectionType,
|
2539
|
+
create,
|
2540
|
+
document,
|
2541
|
+
documentId,
|
2542
|
+
formatMessage,
|
2543
|
+
formatValidationErrors,
|
2544
|
+
isCloning,
|
2545
|
+
model,
|
2546
|
+
modified,
|
2547
|
+
navigate,
|
2548
|
+
params,
|
2549
|
+
rawQuery,
|
2550
|
+
resetForm,
|
2551
|
+
setErrors,
|
2552
|
+
setSubmitting,
|
2553
|
+
toggleNotification,
|
2554
|
+
update,
|
2555
|
+
validate
|
2556
|
+
]);
|
2557
|
+
React__namespace.useEffect(() => {
|
2558
|
+
const handleKeyDown = (e) => {
|
2559
|
+
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
2560
|
+
e.preventDefault();
|
2561
|
+
handleUpdate();
|
2562
|
+
}
|
2563
|
+
};
|
2564
|
+
window.addEventListener("keydown", handleKeyDown);
|
2565
|
+
return () => {
|
2566
|
+
window.removeEventListener("keydown", handleKeyDown);
|
2567
|
+
};
|
2568
|
+
}, [handleUpdate]);
|
2569
|
+
return {
|
2570
|
+
/**
|
2571
|
+
* Disabled when:
|
2572
|
+
* - the form is submitting
|
2573
|
+
* - the document is not modified & we're not cloning (you can save a clone entity straight away)
|
2574
|
+
* - the active tab is the published tab
|
2575
|
+
*/
|
2576
|
+
disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
|
2577
|
+
label: formatMessage({
|
2578
|
+
id: "global.save",
|
2579
|
+
defaultMessage: "Save"
|
2580
|
+
}),
|
2581
|
+
onClick: handleUpdate
|
1862
2582
|
};
|
1863
2583
|
};
|
1864
2584
|
UpdateAction.type = "update";
|
2585
|
+
UpdateAction.position = "panel";
|
1865
2586
|
const UNPUBLISH_DRAFT_OPTIONS = {
|
1866
2587
|
KEEP: "keep",
|
1867
2588
|
DISCARD: "discard"
|
@@ -1882,10 +2603,8 @@ const UnpublishAction$1 = ({
|
|
1882
2603
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1883
2604
|
const [shouldKeepDraft, setShouldKeepDraft] = React__namespace.useState(true);
|
1884
2605
|
const isDocumentModified = document?.status === "modified";
|
1885
|
-
const handleChange = (
|
1886
|
-
|
1887
|
-
setShouldKeepDraft(e.target.value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1888
|
-
}
|
2606
|
+
const handleChange = (value) => {
|
2607
|
+
setShouldKeepDraft(value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1889
2608
|
};
|
1890
2609
|
if (!schema?.options?.draftAndPublish) {
|
1891
2610
|
return null;
|
@@ -1896,7 +2615,7 @@ const UnpublishAction$1 = ({
|
|
1896
2615
|
id: "app.utils.unpublish",
|
1897
2616
|
defaultMessage: "Unpublish"
|
1898
2617
|
}),
|
1899
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2618
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
|
1900
2619
|
onClick: async () => {
|
1901
2620
|
if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
|
1902
2621
|
if (!documentId) {
|
@@ -1935,40 +2654,24 @@ const UnpublishAction$1 = ({
|
|
1935
2654
|
}) })
|
1936
2655
|
] }),
|
1937
2656
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
1938
|
-
designSystem.
|
2657
|
+
designSystem.Radio.Group,
|
1939
2658
|
{
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
2659
|
+
defaultValue: UNPUBLISH_DRAFT_OPTIONS.KEEP,
|
2660
|
+
name: "discard-options",
|
2661
|
+
"aria-label": formatMessage({
|
2662
|
+
id: "content-manager.actions.unpublish.dialog.radio-label",
|
2663
|
+
defaultMessage: "Choose an option to unpublish the document."
|
2664
|
+
}),
|
2665
|
+
onValueChange: handleChange,
|
1946
2666
|
children: [
|
1947
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
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
|
-
)
|
2667
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.KEEP, children: formatMessage({
|
2668
|
+
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
2669
|
+
defaultMessage: "Keep draft"
|
2670
|
+
}) }),
|
2671
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: !shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.DISCARD, children: formatMessage({
|
2672
|
+
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
2673
|
+
defaultMessage: "Replace draft"
|
2674
|
+
}) })
|
1972
2675
|
]
|
1973
2676
|
}
|
1974
2677
|
)
|
@@ -2002,6 +2705,7 @@ const UnpublishAction$1 = ({
|
|
2002
2705
|
};
|
2003
2706
|
};
|
2004
2707
|
UnpublishAction$1.type = "unpublish";
|
2708
|
+
UnpublishAction$1.position = "panel";
|
2005
2709
|
const DiscardAction = ({
|
2006
2710
|
activeTab,
|
2007
2711
|
documentId,
|
@@ -2024,7 +2728,7 @@ const DiscardAction = ({
|
|
2024
2728
|
id: "content-manager.actions.discard.label",
|
2025
2729
|
defaultMessage: "Discard changes"
|
2026
2730
|
}),
|
2027
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2731
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
|
2028
2732
|
position: ["panel", "table-row"],
|
2029
2733
|
variant: "danger",
|
2030
2734
|
dialog: {
|
@@ -2052,11 +2756,7 @@ const DiscardAction = ({
|
|
2052
2756
|
};
|
2053
2757
|
};
|
2054
2758
|
DiscardAction.type = "discard";
|
2055
|
-
|
2056
|
-
path {
|
2057
|
-
fill: currentColor;
|
2058
|
-
}
|
2059
|
-
`;
|
2759
|
+
DiscardAction.position = "panel";
|
2060
2760
|
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
2061
2761
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
2062
2762
|
const RelativeTime = React__namespace.forwardRef(
|
@@ -2069,7 +2769,7 @@ const RelativeTime = React__namespace.forwardRef(
|
|
2069
2769
|
});
|
2070
2770
|
const unit = intervals.find((intervalUnit) => {
|
2071
2771
|
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
|
2072
|
-
});
|
2772
|
+
}) ?? "seconds";
|
2073
2773
|
const relativeTime = dateFns.isPast(timestamp) ? -interval[unit] : interval[unit];
|
2074
2774
|
const customInterval = customIntervals.find(
|
2075
2775
|
(custom) => interval[custom.unit] < custom.threshold
|
@@ -2103,34 +2803,34 @@ const getDisplayName = ({
|
|
2103
2803
|
return email ?? "";
|
2104
2804
|
};
|
2105
2805
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2106
|
-
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2107
|
-
const statusVariant = status === "draft" ? "
|
2108
|
-
|
2806
|
+
const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
|
2807
|
+
const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
|
2808
|
+
const { formatMessage } = reactIntl.useIntl();
|
2809
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
|
2810
|
+
id: `content-manager.containers.List.${status}`,
|
2811
|
+
defaultMessage: capitalise(status)
|
2812
|
+
}) }) });
|
2109
2813
|
};
|
2110
2814
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
2111
2815
|
const { formatMessage } = reactIntl.useIntl();
|
2112
2816
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2817
|
+
const params = reactRouterDom.useParams();
|
2113
2818
|
const title = isCreating ? formatMessage({
|
2114
2819
|
id: "content-manager.containers.edit.title.new",
|
2115
2820
|
defaultMessage: "Create an entry"
|
2116
2821
|
}) : documentTitle;
|
2117
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop:
|
2118
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
2119
|
-
|
2120
|
-
designSystem.Flex,
|
2822
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2823
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2824
|
+
strapiAdmin.BackButton,
|
2121
2825
|
{
|
2122
|
-
|
2123
|
-
justifyContent: "space-between",
|
2124
|
-
paddingTop: 1,
|
2125
|
-
gap: "80px",
|
2126
|
-
alignItems: "flex-start",
|
2127
|
-
children: [
|
2128
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2129
|
-
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2130
|
-
]
|
2826
|
+
fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
|
2131
2827
|
}
|
2132
2828
|
),
|
2133
|
-
|
2829
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2830
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2831
|
+
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
2832
|
+
] }),
|
2833
|
+
status ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
|
2134
2834
|
] });
|
2135
2835
|
};
|
2136
2836
|
const HeaderToolbar = () => {
|
@@ -2176,7 +2876,7 @@ const HeaderToolbar = () => {
|
|
2176
2876
|
meta: isCloning ? void 0 : meta,
|
2177
2877
|
collectionType
|
2178
2878
|
},
|
2179
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2879
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("header"),
|
2180
2880
|
children: (actions2) => {
|
2181
2881
|
const headerActions = actions2.filter((action) => {
|
2182
2882
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -2213,12 +2913,12 @@ const Information = ({ activeTab }) => {
|
|
2213
2913
|
isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
|
2214
2914
|
label: formatMessage({
|
2215
2915
|
id: "content-manager.containers.edit.information.last-published.label",
|
2216
|
-
defaultMessage: "
|
2916
|
+
defaultMessage: "Published"
|
2217
2917
|
}),
|
2218
2918
|
value: formatMessage(
|
2219
2919
|
{
|
2220
2920
|
id: "content-manager.containers.edit.information.last-published.value",
|
2221
|
-
defaultMessage: `
|
2921
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2222
2922
|
},
|
2223
2923
|
{
|
2224
2924
|
time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
|
@@ -2231,12 +2931,12 @@ const Information = ({ activeTab }) => {
|
|
2231
2931
|
isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
|
2232
2932
|
label: formatMessage({
|
2233
2933
|
id: "content-manager.containers.edit.information.last-draft.label",
|
2234
|
-
defaultMessage: "
|
2934
|
+
defaultMessage: "Updated"
|
2235
2935
|
}),
|
2236
2936
|
value: formatMessage(
|
2237
2937
|
{
|
2238
2938
|
id: "content-manager.containers.edit.information.last-draft.value",
|
2239
|
-
defaultMessage: `
|
2939
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2240
2940
|
},
|
2241
2941
|
{
|
2242
2942
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2254,12 +2954,12 @@ const Information = ({ activeTab }) => {
|
|
2254
2954
|
isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
|
2255
2955
|
label: formatMessage({
|
2256
2956
|
id: "content-manager.containers.edit.information.document.label",
|
2257
|
-
defaultMessage: "
|
2957
|
+
defaultMessage: "Created"
|
2258
2958
|
}),
|
2259
2959
|
value: formatMessage(
|
2260
2960
|
{
|
2261
2961
|
id: "content-manager.containers.edit.information.document.value",
|
2262
|
-
defaultMessage: `
|
2962
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2263
2963
|
},
|
2264
2964
|
{
|
2265
2965
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2297,41 +2997,94 @@ const Information = ({ activeTab }) => {
|
|
2297
2997
|
);
|
2298
2998
|
};
|
2299
2999
|
const HeaderActions = ({ actions: actions2 }) => {
|
2300
|
-
|
2301
|
-
|
3000
|
+
const [dialogId, setDialogId] = React__namespace.useState(null);
|
3001
|
+
const handleClick = (action) => async (e) => {
|
3002
|
+
if (!("options" in action)) {
|
3003
|
+
const { onClick = () => false, dialog, id } = action;
|
3004
|
+
const muteDialog = await onClick(e);
|
3005
|
+
if (dialog && !muteDialog) {
|
3006
|
+
e.preventDefault();
|
3007
|
+
setDialogId(id);
|
3008
|
+
}
|
3009
|
+
}
|
3010
|
+
};
|
3011
|
+
const handleClose = () => {
|
3012
|
+
setDialogId(null);
|
3013
|
+
};
|
3014
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, children: actions2.map((action) => {
|
3015
|
+
if (action.options) {
|
2302
3016
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
2303
3017
|
designSystem.SingleSelect,
|
2304
3018
|
{
|
2305
3019
|
size: "S",
|
2306
|
-
disabled: action.disabled,
|
2307
|
-
"aria-label": action.label,
|
2308
3020
|
onChange: action.onSelect,
|
2309
|
-
|
3021
|
+
"aria-label": action.label,
|
3022
|
+
...action,
|
2310
3023
|
children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
|
2311
3024
|
},
|
2312
3025
|
action.id
|
2313
3026
|
);
|
2314
3027
|
} else {
|
2315
|
-
|
3028
|
+
if (action.type === "icon") {
|
3029
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
|
3030
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3031
|
+
designSystem.IconButton,
|
3032
|
+
{
|
3033
|
+
disabled: action.disabled,
|
3034
|
+
label: action.label,
|
3035
|
+
size: "S",
|
3036
|
+
onClick: handleClick(action),
|
3037
|
+
children: action.icon
|
3038
|
+
}
|
3039
|
+
),
|
3040
|
+
action.dialog ? /* @__PURE__ */ jsxRuntime.jsx(
|
3041
|
+
HeaderActionDialog,
|
3042
|
+
{
|
3043
|
+
...action.dialog,
|
3044
|
+
isOpen: dialogId === action.id,
|
3045
|
+
onClose: handleClose
|
3046
|
+
}
|
3047
|
+
) : null
|
3048
|
+
] }, action.id);
|
3049
|
+
}
|
2316
3050
|
}
|
2317
3051
|
}) });
|
2318
3052
|
};
|
2319
|
-
const
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
3053
|
+
const HeaderActionDialog = ({
|
3054
|
+
onClose,
|
3055
|
+
onCancel,
|
3056
|
+
title,
|
3057
|
+
content: Content,
|
3058
|
+
isOpen
|
3059
|
+
}) => {
|
3060
|
+
const handleClose = async () => {
|
3061
|
+
if (onCancel) {
|
3062
|
+
await onCancel();
|
3063
|
+
}
|
3064
|
+
onClose();
|
3065
|
+
};
|
3066
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
3067
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
3068
|
+
typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content
|
3069
|
+
] }) });
|
3070
|
+
};
|
3071
|
+
const ConfigureTheViewAction = ({ collectionType, model }) => {
|
3072
|
+
const navigate = reactRouterDom.useNavigate();
|
3073
|
+
const { formatMessage } = reactIntl.useIntl();
|
3074
|
+
return {
|
3075
|
+
label: formatMessage({
|
3076
|
+
id: "app.links.configure-view",
|
3077
|
+
defaultMessage: "Configure the view"
|
3078
|
+
}),
|
3079
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ListPlus, {}),
|
3080
|
+
onClick: () => {
|
2329
3081
|
navigate(`../${collectionType}/${model}/configurations/edit`);
|
2330
3082
|
},
|
2331
3083
|
position: "header"
|
2332
3084
|
};
|
2333
3085
|
};
|
2334
3086
|
ConfigureTheViewAction.type = "configure-the-view";
|
3087
|
+
ConfigureTheViewAction.position = "header";
|
2335
3088
|
const EditTheModelAction = ({ model }) => {
|
2336
3089
|
const navigate = reactRouterDom.useNavigate();
|
2337
3090
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2348,6 +3101,7 @@ const EditTheModelAction = ({ model }) => {
|
|
2348
3101
|
};
|
2349
3102
|
};
|
2350
3103
|
EditTheModelAction.type = "edit-the-model";
|
3104
|
+
EditTheModelAction.position = "header";
|
2351
3105
|
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2352
3106
|
const navigate = reactRouterDom.useNavigate();
|
2353
3107
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2356,12 +3110,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2356
3110
|
const { delete: deleteAction } = useDocumentActions();
|
2357
3111
|
const { toggleNotification } = strapiAdmin.useNotification();
|
2358
3112
|
const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
|
3113
|
+
const isLocalized = document?.locale != null;
|
2359
3114
|
return {
|
2360
3115
|
disabled: !canDelete || !document,
|
2361
|
-
label: formatMessage(
|
2362
|
-
|
2363
|
-
|
2364
|
-
|
3116
|
+
label: formatMessage(
|
3117
|
+
{
|
3118
|
+
id: "content-manager.actions.delete.label",
|
3119
|
+
defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
|
3120
|
+
},
|
3121
|
+
{ isLocalized }
|
3122
|
+
),
|
2365
3123
|
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
|
2366
3124
|
dialog: {
|
2367
3125
|
type: "dialog",
|
@@ -2417,6 +3175,7 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2417
3175
|
};
|
2418
3176
|
};
|
2419
3177
|
DeleteAction$1.type = "delete";
|
3178
|
+
DeleteAction$1.position = ["header", "table-row"];
|
2420
3179
|
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2421
3180
|
const Panels = () => {
|
2422
3181
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
@@ -2451,7 +3210,7 @@ const ActionsPanel = () => {
|
|
2451
3210
|
return {
|
2452
3211
|
title: formatMessage({
|
2453
3212
|
id: "content-manager.containers.edit.panels.default.title",
|
2454
|
-
defaultMessage: "
|
3213
|
+
defaultMessage: "Entry"
|
2455
3214
|
}),
|
2456
3215
|
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2457
3216
|
};
|
@@ -2479,7 +3238,7 @@ const ActionsPanelContent = () => {
|
|
2479
3238
|
strapiAdmin.DescriptionComponentRenderer,
|
2480
3239
|
{
|
2481
3240
|
props,
|
2482
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3241
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("panel"),
|
2483
3242
|
children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
|
2484
3243
|
}
|
2485
3244
|
),
|
@@ -2506,314 +3265,12 @@ const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
|
2506
3265
|
justifyContent: "stretch",
|
2507
3266
|
alignItems: "flex-start",
|
2508
3267
|
children: [
|
2509
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
|
3268
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
|
2510
3269
|
children
|
2511
|
-
]
|
2512
|
-
}
|
2513
|
-
);
|
2514
|
-
});
|
2515
|
-
const HOOKS = {
|
2516
|
-
/**
|
2517
|
-
* Hook that allows to mutate the displayed headers of the list view table
|
2518
|
-
* @constant
|
2519
|
-
* @type {string}
|
2520
|
-
*/
|
2521
|
-
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
2522
|
-
/**
|
2523
|
-
* Hook that allows to mutate the CM's collection types links pre-set filters
|
2524
|
-
* @constant
|
2525
|
-
* @type {string}
|
2526
|
-
*/
|
2527
|
-
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
2528
|
-
/**
|
2529
|
-
* Hook that allows to mutate the CM's edit view layout
|
2530
|
-
* @constant
|
2531
|
-
* @type {string}
|
2532
|
-
*/
|
2533
|
-
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
2534
|
-
/**
|
2535
|
-
* Hook that allows to mutate the CM's single types links pre-set filters
|
2536
|
-
* @constant
|
2537
|
-
* @type {string}
|
2538
|
-
*/
|
2539
|
-
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
2540
|
-
};
|
2541
|
-
const contentTypesApi = contentManagerApi.injectEndpoints({
|
2542
|
-
endpoints: (builder) => ({
|
2543
|
-
getContentTypeConfiguration: builder.query({
|
2544
|
-
query: (uid) => ({
|
2545
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2546
|
-
method: "GET"
|
2547
|
-
}),
|
2548
|
-
transformResponse: (response) => response.data,
|
2549
|
-
providesTags: (_result, _error, uid) => [
|
2550
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2551
|
-
{ type: "ContentTypeSettings", id: "LIST" }
|
2552
|
-
]
|
2553
|
-
}),
|
2554
|
-
getAllContentTypeSettings: builder.query({
|
2555
|
-
query: () => "/content-manager/content-types-settings",
|
2556
|
-
transformResponse: (response) => response.data,
|
2557
|
-
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
2558
|
-
}),
|
2559
|
-
updateContentTypeConfiguration: builder.mutation({
|
2560
|
-
query: ({ uid, ...body }) => ({
|
2561
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2562
|
-
method: "PUT",
|
2563
|
-
data: body
|
2564
|
-
}),
|
2565
|
-
transformResponse: (response) => response.data,
|
2566
|
-
invalidatesTags: (_result, _error, { uid }) => [
|
2567
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2568
|
-
{ type: "ContentTypeSettings", id: "LIST" },
|
2569
|
-
// Is this necessary?
|
2570
|
-
{ type: "InitialData" }
|
2571
|
-
]
|
2572
|
-
})
|
2573
|
-
})
|
2574
|
-
});
|
2575
|
-
const {
|
2576
|
-
useGetContentTypeConfigurationQuery,
|
2577
|
-
useGetAllContentTypeSettingsQuery,
|
2578
|
-
useUpdateContentTypeConfigurationMutation
|
2579
|
-
} = contentTypesApi;
|
2580
|
-
const checkIfAttributeIsDisplayable = (attribute) => {
|
2581
|
-
const { type } = attribute;
|
2582
|
-
if (type === "relation") {
|
2583
|
-
return !attribute.relation.toLowerCase().includes("morph");
|
2584
|
-
}
|
2585
|
-
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
2586
|
-
};
|
2587
|
-
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
2588
|
-
if (!mainFieldName) {
|
2589
|
-
return void 0;
|
2590
|
-
}
|
2591
|
-
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
2592
|
-
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
2593
|
-
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2594
|
-
);
|
2595
|
-
return {
|
2596
|
-
name: mainFieldName,
|
2597
|
-
type: mainFieldType ?? "string"
|
2598
|
-
};
|
2599
|
-
};
|
2600
|
-
const DEFAULT_SETTINGS = {
|
2601
|
-
bulkable: false,
|
2602
|
-
filterable: false,
|
2603
|
-
searchable: false,
|
2604
|
-
pagination: false,
|
2605
|
-
defaultSortBy: "",
|
2606
|
-
defaultSortOrder: "asc",
|
2607
|
-
mainField: "id",
|
2608
|
-
pageSize: 10
|
2609
|
-
};
|
2610
|
-
const useDocumentLayout = (model) => {
|
2611
|
-
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
2612
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
2613
|
-
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
2614
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
2615
|
-
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
2616
|
-
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
2617
|
-
const {
|
2618
|
-
data,
|
2619
|
-
isLoading: isLoadingConfigs,
|
2620
|
-
error,
|
2621
|
-
isFetching: isFetchingConfigs
|
2622
|
-
} = useGetContentTypeConfigurationQuery(model);
|
2623
|
-
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
2624
|
-
React__namespace.useEffect(() => {
|
2625
|
-
if (error) {
|
2626
|
-
toggleNotification({
|
2627
|
-
type: "danger",
|
2628
|
-
message: formatAPIError(error)
|
2629
|
-
});
|
2630
|
-
}
|
2631
|
-
}, [error, formatAPIError, toggleNotification]);
|
2632
|
-
const editLayout = React__namespace.useMemo(
|
2633
|
-
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
2634
|
-
layout: [],
|
2635
|
-
components: {},
|
2636
|
-
metadatas: {},
|
2637
|
-
options: {},
|
2638
|
-
settings: DEFAULT_SETTINGS
|
2639
|
-
},
|
2640
|
-
[data, isLoading, schemas, schema, components]
|
2641
|
-
);
|
2642
|
-
const listLayout = React__namespace.useMemo(() => {
|
2643
|
-
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
2644
|
-
layout: [],
|
2645
|
-
metadatas: {},
|
2646
|
-
options: {},
|
2647
|
-
settings: DEFAULT_SETTINGS
|
2648
|
-
};
|
2649
|
-
}, [data, isLoading, schemas, schema, components]);
|
2650
|
-
const { layout: edit } = React__namespace.useMemo(
|
2651
|
-
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
2652
|
-
layout: editLayout,
|
2653
|
-
query
|
2654
|
-
}),
|
2655
|
-
[editLayout, query, runHookWaterfall]
|
2656
|
-
);
|
2657
|
-
return {
|
2658
|
-
error,
|
2659
|
-
isLoading,
|
2660
|
-
edit,
|
2661
|
-
list: listLayout
|
2662
|
-
};
|
2663
|
-
};
|
2664
|
-
const useDocLayout = () => {
|
2665
|
-
const { model } = useDoc();
|
2666
|
-
return useDocumentLayout(model);
|
2667
|
-
};
|
2668
|
-
const formatEditLayout = (data, {
|
2669
|
-
schemas,
|
2670
|
-
schema,
|
2671
|
-
components
|
2672
|
-
}) => {
|
2673
|
-
let currentPanelIndex = 0;
|
2674
|
-
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
2675
|
-
data.contentType.layouts.edit,
|
2676
|
-
schema?.attributes,
|
2677
|
-
data.contentType.metadatas,
|
2678
|
-
{ configurations: data.components, schemas: components },
|
2679
|
-
schemas
|
2680
|
-
).reduce((panels, row) => {
|
2681
|
-
if (row.some((field) => field.type === "dynamiczone")) {
|
2682
|
-
panels.push([row]);
|
2683
|
-
currentPanelIndex += 2;
|
2684
|
-
} else {
|
2685
|
-
if (!panels[currentPanelIndex]) {
|
2686
|
-
panels.push([]);
|
2687
|
-
}
|
2688
|
-
panels[currentPanelIndex].push(row);
|
2689
|
-
}
|
2690
|
-
return panels;
|
2691
|
-
}, []);
|
2692
|
-
const componentEditAttributes = Object.entries(data.components).reduce(
|
2693
|
-
(acc, [uid, configuration]) => {
|
2694
|
-
acc[uid] = {
|
2695
|
-
layout: convertEditLayoutToFieldLayouts(
|
2696
|
-
configuration.layouts.edit,
|
2697
|
-
components[uid].attributes,
|
2698
|
-
configuration.metadatas
|
2699
|
-
),
|
2700
|
-
settings: {
|
2701
|
-
...configuration.settings,
|
2702
|
-
icon: components[uid].info.icon,
|
2703
|
-
displayName: components[uid].info.displayName
|
2704
|
-
}
|
2705
|
-
};
|
2706
|
-
return acc;
|
2707
|
-
},
|
2708
|
-
{}
|
2709
|
-
);
|
2710
|
-
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2711
|
-
(acc, [attribute, metadata]) => {
|
2712
|
-
return {
|
2713
|
-
...acc,
|
2714
|
-
[attribute]: metadata.edit
|
2715
|
-
};
|
2716
|
-
},
|
2717
|
-
{}
|
2718
|
-
);
|
2719
|
-
return {
|
2720
|
-
layout: panelledEditAttributes,
|
2721
|
-
components: componentEditAttributes,
|
2722
|
-
metadatas: editMetadatas,
|
2723
|
-
settings: {
|
2724
|
-
...data.contentType.settings,
|
2725
|
-
displayName: schema?.info.displayName
|
2726
|
-
},
|
2727
|
-
options: {
|
2728
|
-
...schema?.options,
|
2729
|
-
...schema?.pluginOptions,
|
2730
|
-
...data.contentType.options
|
2731
|
-
}
|
2732
|
-
};
|
2733
|
-
};
|
2734
|
-
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
2735
|
-
return rows.map(
|
2736
|
-
(row) => row.map((field) => {
|
2737
|
-
const attribute = attributes[field.name];
|
2738
|
-
if (!attribute) {
|
2739
|
-
return null;
|
2740
|
-
}
|
2741
|
-
const { edit: metadata } = metadatas[field.name];
|
2742
|
-
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
2743
|
-
return {
|
2744
|
-
attribute,
|
2745
|
-
disabled: !metadata.editable,
|
2746
|
-
hint: metadata.description,
|
2747
|
-
label: metadata.label ?? "",
|
2748
|
-
name: field.name,
|
2749
|
-
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
2750
|
-
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
2751
|
-
schemas,
|
2752
|
-
components: components?.schemas ?? {}
|
2753
|
-
}),
|
2754
|
-
placeholder: metadata.placeholder ?? "",
|
2755
|
-
required: attribute.required ?? false,
|
2756
|
-
size: field.size,
|
2757
|
-
unique: "unique" in attribute ? attribute.unique : false,
|
2758
|
-
visible: metadata.visible ?? true,
|
2759
|
-
type: attribute.type
|
2760
|
-
};
|
2761
|
-
}).filter((field) => field !== null)
|
2762
|
-
);
|
2763
|
-
};
|
2764
|
-
const formatListLayout = (data, {
|
2765
|
-
schemas,
|
2766
|
-
schema,
|
2767
|
-
components
|
2768
|
-
}) => {
|
2769
|
-
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2770
|
-
(acc, [attribute, metadata]) => {
|
2771
|
-
return {
|
2772
|
-
...acc,
|
2773
|
-
[attribute]: metadata.list
|
2774
|
-
};
|
2775
|
-
},
|
2776
|
-
{}
|
2777
|
-
);
|
2778
|
-
const listAttributes = convertListLayoutToFieldLayouts(
|
2779
|
-
data.contentType.layouts.list,
|
2780
|
-
schema?.attributes,
|
2781
|
-
listMetadatas,
|
2782
|
-
{ configurations: data.components, schemas: components },
|
2783
|
-
schemas
|
2784
|
-
);
|
2785
|
-
return {
|
2786
|
-
layout: listAttributes,
|
2787
|
-
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
2788
|
-
metadatas: listMetadatas,
|
2789
|
-
options: {
|
2790
|
-
...schema?.options,
|
2791
|
-
...schema?.pluginOptions,
|
2792
|
-
...data.contentType.options
|
2793
|
-
}
|
2794
|
-
};
|
2795
|
-
};
|
2796
|
-
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
2797
|
-
return columns.map((name) => {
|
2798
|
-
const attribute = attributes[name];
|
2799
|
-
if (!attribute) {
|
2800
|
-
return null;
|
3270
|
+
]
|
2801
3271
|
}
|
2802
|
-
|
2803
|
-
|
2804
|
-
return {
|
2805
|
-
attribute,
|
2806
|
-
label: metadata.label ?? "",
|
2807
|
-
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
2808
|
-
schemas,
|
2809
|
-
components: components?.schemas ?? {}
|
2810
|
-
}),
|
2811
|
-
name,
|
2812
|
-
searchable: metadata.searchable ?? true,
|
2813
|
-
sortable: metadata.sortable ?? true
|
2814
|
-
};
|
2815
|
-
}).filter((field) => field !== null);
|
2816
|
-
};
|
3272
|
+
);
|
3273
|
+
});
|
2817
3274
|
const ConfirmBulkActionDialog = ({
|
2818
3275
|
onToggleDialog,
|
2819
3276
|
isOpen = false,
|
@@ -2821,30 +3278,23 @@ const ConfirmBulkActionDialog = ({
|
|
2821
3278
|
endAction
|
2822
3279
|
}) => {
|
2823
3280
|
const { formatMessage } = reactIntl.useIntl();
|
2824
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
2825
|
-
designSystem.Dialog,
|
2826
|
-
|
2827
|
-
|
2828
|
-
|
2829
|
-
|
2830
|
-
|
2831
|
-
|
2832
|
-
|
2833
|
-
|
2834
|
-
|
2835
|
-
|
2836
|
-
|
2837
|
-
|
2838
|
-
|
2839
|
-
|
2840
|
-
|
2841
|
-
}) }),
|
2842
|
-
endAction
|
2843
|
-
}
|
2844
|
-
)
|
2845
|
-
]
|
2846
|
-
}
|
2847
|
-
);
|
3281
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
3282
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage({
|
3283
|
+
id: "app.components.ConfirmDialog.title",
|
3284
|
+
defaultMessage: "Confirmation"
|
3285
|
+
}) }),
|
3286
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3287
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3288
|
+
dialogBody
|
3289
|
+
] }) }),
|
3290
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
3291
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
|
3292
|
+
id: "app.components.Button.cancel",
|
3293
|
+
defaultMessage: "Cancel"
|
3294
|
+
}) }) }),
|
3295
|
+
endAction
|
3296
|
+
] })
|
3297
|
+
] }) });
|
2848
3298
|
};
|
2849
3299
|
const BoldChunk$1 = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
|
2850
3300
|
const ConfirmDialogPublishAll = ({
|
@@ -2859,6 +3309,7 @@ const ConfirmDialogPublishAll = ({
|
|
2859
3309
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler(getTranslation);
|
2860
3310
|
const { model, schema } = useDoc();
|
2861
3311
|
const [{ query }] = strapiAdmin.useQueryParams();
|
3312
|
+
const enableDraftRelationsCount = false;
|
2862
3313
|
const {
|
2863
3314
|
data: countDraftRelations = 0,
|
2864
3315
|
isLoading,
|
@@ -2870,7 +3321,7 @@ const ConfirmDialogPublishAll = ({
|
|
2870
3321
|
locale: query?.plugins?.i18n?.locale
|
2871
3322
|
},
|
2872
3323
|
{
|
2873
|
-
skip:
|
3324
|
+
skip: !enableDraftRelationsCount
|
2874
3325
|
}
|
2875
3326
|
);
|
2876
3327
|
React__namespace.useEffect(() => {
|
@@ -2949,16 +3400,30 @@ const formatErrorMessages = (errors, parentKey, formatMessage) => {
|
|
2949
3400
|
)
|
2950
3401
|
);
|
2951
3402
|
} else {
|
2952
|
-
messages.push(
|
3403
|
+
messages.push(
|
3404
|
+
...formatErrorMessages(
|
3405
|
+
// @ts-expect-error TODO: check why value is not compatible with FormErrors
|
3406
|
+
value,
|
3407
|
+
currentKey,
|
3408
|
+
formatMessage
|
3409
|
+
)
|
3410
|
+
);
|
2953
3411
|
}
|
3412
|
+
} else {
|
3413
|
+
messages.push(
|
3414
|
+
formatMessage(
|
3415
|
+
{
|
3416
|
+
id: `${value}.withField`,
|
3417
|
+
defaultMessage: value
|
3418
|
+
},
|
3419
|
+
{ field: currentKey }
|
3420
|
+
)
|
3421
|
+
);
|
2954
3422
|
}
|
2955
3423
|
});
|
2956
3424
|
return messages;
|
2957
3425
|
};
|
2958
|
-
const EntryValidationText = ({
|
2959
|
-
validationErrors,
|
2960
|
-
isPublished = false
|
2961
|
-
}) => {
|
3426
|
+
const EntryValidationText = ({ validationErrors, status }) => {
|
2962
3427
|
const { formatMessage } = reactIntl.useIntl();
|
2963
3428
|
if (validationErrors) {
|
2964
3429
|
const validationErrorsMessages = formatErrorMessages(validationErrors, "", formatMessage).join(
|
@@ -2969,7 +3434,7 @@ const EntryValidationText = ({
|
|
2969
3434
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { description: validationErrorsMessages, children: /* @__PURE__ */ jsxRuntime.jsx(TypographyMaxWidth, { textColor: "danger600", variant: "omega", fontWeight: "semiBold", ellipsis: true, children: validationErrorsMessages }) })
|
2970
3435
|
] });
|
2971
3436
|
}
|
2972
|
-
if (
|
3437
|
+
if (status === "published") {
|
2973
3438
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
2974
3439
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.CheckCircle, { fill: "success600" }),
|
2975
3440
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "success600", fontWeight: "bold", children: formatMessage({
|
@@ -2978,6 +3443,15 @@ const EntryValidationText = ({
|
|
2978
3443
|
}) })
|
2979
3444
|
] });
|
2980
3445
|
}
|
3446
|
+
if (status === "modified") {
|
3447
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
3448
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icons.ArrowsCounterClockwise, { fill: "alternative600" }),
|
3449
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
|
3450
|
+
id: "content-manager.bulk-publish.modified",
|
3451
|
+
defaultMessage: "Ready to publish changes"
|
3452
|
+
}) })
|
3453
|
+
] });
|
3454
|
+
}
|
2981
3455
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
2982
3456
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.CheckCircle, { fill: "success600" }),
|
2983
3457
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
|
@@ -3029,10 +3503,10 @@ const SelectedEntriesTableContent = ({
|
|
3029
3503
|
EntryValidationText,
|
3030
3504
|
{
|
3031
3505
|
validationErrors: validationErrors[row.documentId],
|
3032
|
-
|
3506
|
+
status: row.status
|
3033
3507
|
}
|
3034
3508
|
) }),
|
3035
|
-
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3509
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3036
3510
|
designSystem.IconButton,
|
3037
3511
|
{
|
3038
3512
|
tag: reactRouterDom.Link,
|
@@ -3041,23 +3515,16 @@ const SelectedEntriesTableContent = ({
|
|
3041
3515
|
search: row.locale && `?plugins[i18n][locale]=${row.locale}`
|
3042
3516
|
},
|
3043
3517
|
state: { from: pathname },
|
3044
|
-
label: formatMessage(
|
3045
|
-
|
3046
|
-
|
3047
|
-
|
3048
|
-
{
|
3049
|
-
id: "content-manager.components.ListViewHelperPluginTable.row-line",
|
3050
|
-
defaultMessage: "item line {number}"
|
3051
|
-
},
|
3052
|
-
{ number: index2 + 1 }
|
3053
|
-
)
|
3054
|
-
}
|
3055
|
-
),
|
3518
|
+
label: formatMessage({
|
3519
|
+
id: "content-manager.bulk-publish.edit",
|
3520
|
+
defaultMessage: "Edit"
|
3521
|
+
}),
|
3056
3522
|
target: "_blank",
|
3057
3523
|
marginLeft: "auto",
|
3058
|
-
|
3524
|
+
variant: "ghost",
|
3525
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, { width: "1.6rem", height: "1.6rem" })
|
3059
3526
|
}
|
3060
|
-
) })
|
3527
|
+
) }) })
|
3061
3528
|
] }, row.id)) })
|
3062
3529
|
] });
|
3063
3530
|
};
|
@@ -3094,7 +3561,13 @@ const SelectedEntriesModalContent = ({
|
|
3094
3561
|
);
|
3095
3562
|
const { rows, validationErrors } = React__namespace.useMemo(() => {
|
3096
3563
|
if (data.length > 0 && schema) {
|
3097
|
-
const validate = createYupSchema(
|
3564
|
+
const validate = createYupSchema(
|
3565
|
+
schema.attributes,
|
3566
|
+
components,
|
3567
|
+
// Since this is the "Publish" action, the validation
|
3568
|
+
// schema must enforce the rules for published entities
|
3569
|
+
{ status: "published" }
|
3570
|
+
);
|
3098
3571
|
const validationErrors2 = {};
|
3099
3572
|
const rows2 = data.map((entry) => {
|
3100
3573
|
try {
|
@@ -3170,7 +3643,7 @@ const SelectedEntriesModalContent = ({
|
|
3170
3643
|
);
|
3171
3644
|
};
|
3172
3645
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
3173
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
3646
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Body, { children: [
|
3174
3647
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: getFormattedCountMessage() }),
|
3175
3648
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
|
3176
3649
|
SelectedEntriesTableContent,
|
@@ -3182,27 +3655,24 @@ const SelectedEntriesModalContent = ({
|
|
3182
3655
|
}
|
3183
3656
|
) })
|
3184
3657
|
] }),
|
3185
|
-
/* @__PURE__ */ jsxRuntime.
|
3186
|
-
designSystem.
|
3187
|
-
|
3188
|
-
|
3189
|
-
|
3190
|
-
|
3191
|
-
}) }),
|
3192
|
-
|
3193
|
-
|
3194
|
-
|
3195
|
-
|
3196
|
-
|
3197
|
-
|
3198
|
-
|
3199
|
-
|
3200
|
-
|
3201
|
-
|
3202
|
-
|
3203
|
-
] })
|
3204
|
-
}
|
3205
|
-
),
|
3658
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
3659
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
|
3660
|
+
id: "app.components.Button.cancel",
|
3661
|
+
defaultMessage: "Cancel"
|
3662
|
+
}) }),
|
3663
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
3664
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
|
3665
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3666
|
+
designSystem.Button,
|
3667
|
+
{
|
3668
|
+
onClick: toggleDialog,
|
3669
|
+
disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublished === selectedEntries.length || isLoading,
|
3670
|
+
loading: isSubmittingForm,
|
3671
|
+
children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
|
3672
|
+
}
|
3673
|
+
)
|
3674
|
+
] })
|
3675
|
+
] }),
|
3206
3676
|
/* @__PURE__ */ jsxRuntime.jsx(
|
3207
3677
|
ConfirmDialogPublishAll,
|
3208
3678
|
{
|
@@ -3222,8 +3692,7 @@ const PublishAction = ({ documents, model }) => {
|
|
3222
3692
|
const refetchList = () => {
|
3223
3693
|
contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
|
3224
3694
|
};
|
3225
|
-
if (!showPublishButton)
|
3226
|
-
return null;
|
3695
|
+
if (!showPublishButton) return null;
|
3227
3696
|
return {
|
3228
3697
|
actionType: "publish",
|
3229
3698
|
variant: "tertiary",
|
@@ -3267,143 +3736,10 @@ const BulkActionsRenderer = () => {
|
|
3267
3736
|
documents: selectedRows
|
3268
3737
|
},
|
3269
3738
|
descriptions: plugins["content-manager"].apis.getBulkActions(),
|
3270
|
-
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsxRuntime.jsx(
|
3739
|
+
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActionButton, { ...action }, action.id))
|
3271
3740
|
}
|
3272
3741
|
) });
|
3273
3742
|
};
|
3274
|
-
const BulkActionAction = (action) => {
|
3275
|
-
const [dialogId, setDialogId] = React__namespace.useState(null);
|
3276
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
3277
|
-
const handleClick = (action2) => (e) => {
|
3278
|
-
const { onClick, dialog, id } = action2;
|
3279
|
-
if (onClick) {
|
3280
|
-
onClick(e);
|
3281
|
-
}
|
3282
|
-
if (dialog) {
|
3283
|
-
switch (dialog.type) {
|
3284
|
-
case "notification":
|
3285
|
-
toggleNotification({
|
3286
|
-
title: dialog.title,
|
3287
|
-
message: dialog.content,
|
3288
|
-
type: dialog.status,
|
3289
|
-
timeout: dialog.timeout,
|
3290
|
-
onClose: dialog.onClose
|
3291
|
-
});
|
3292
|
-
break;
|
3293
|
-
case "dialog":
|
3294
|
-
case "modal": {
|
3295
|
-
e.preventDefault();
|
3296
|
-
setDialogId(id);
|
3297
|
-
}
|
3298
|
-
}
|
3299
|
-
}
|
3300
|
-
};
|
3301
|
-
const handleClose = () => {
|
3302
|
-
setDialogId(null);
|
3303
|
-
if (action.dialog?.type === "modal" && action.dialog?.onClose) {
|
3304
|
-
action.dialog.onClose();
|
3305
|
-
}
|
3306
|
-
};
|
3307
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
3308
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
3309
|
-
designSystem.Button,
|
3310
|
-
{
|
3311
|
-
disabled: action.disabled,
|
3312
|
-
startIcon: action.icon,
|
3313
|
-
variant: action.variant,
|
3314
|
-
onClick: handleClick(action),
|
3315
|
-
children: action.label
|
3316
|
-
}
|
3317
|
-
),
|
3318
|
-
action.dialog?.type === "dialog" ? /* @__PURE__ */ jsxRuntime.jsx(
|
3319
|
-
BulkActionConfirmDialog,
|
3320
|
-
{
|
3321
|
-
...action.dialog,
|
3322
|
-
variant: action.variant,
|
3323
|
-
isOpen: dialogId === action.id,
|
3324
|
-
onClose: handleClose
|
3325
|
-
}
|
3326
|
-
) : null,
|
3327
|
-
action.dialog?.type === "modal" ? /* @__PURE__ */ jsxRuntime.jsx(
|
3328
|
-
BulkActionModal,
|
3329
|
-
{
|
3330
|
-
...action.dialog,
|
3331
|
-
onModalClose: handleClose,
|
3332
|
-
isOpen: dialogId === action.id
|
3333
|
-
}
|
3334
|
-
) : null
|
3335
|
-
] });
|
3336
|
-
};
|
3337
|
-
const BulkActionConfirmDialog = ({
|
3338
|
-
onClose,
|
3339
|
-
onCancel,
|
3340
|
-
onConfirm,
|
3341
|
-
title,
|
3342
|
-
content,
|
3343
|
-
confirmButton,
|
3344
|
-
isOpen,
|
3345
|
-
variant = "secondary"
|
3346
|
-
}) => {
|
3347
|
-
const { formatMessage } = reactIntl.useIntl();
|
3348
|
-
const handleClose = async () => {
|
3349
|
-
if (onCancel) {
|
3350
|
-
await onCancel();
|
3351
|
-
}
|
3352
|
-
onClose();
|
3353
|
-
};
|
3354
|
-
const handleConfirm = async () => {
|
3355
|
-
if (onConfirm) {
|
3356
|
-
await onConfirm();
|
3357
|
-
}
|
3358
|
-
onClose();
|
3359
|
-
};
|
3360
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog, { isOpen, title, onClose: handleClose, children: [
|
3361
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.DialogBody, { icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, {}), children: content }),
|
3362
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
3363
|
-
designSystem.DialogFooter,
|
3364
|
-
{
|
3365
|
-
startAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleClose, variant: "tertiary", children: formatMessage({
|
3366
|
-
id: "app.components.Button.cancel",
|
3367
|
-
defaultMessage: "Cancel"
|
3368
|
-
}) }),
|
3369
|
-
endAction: /* @__PURE__ */ jsxRuntime.jsx(
|
3370
|
-
designSystem.Button,
|
3371
|
-
{
|
3372
|
-
onClick: handleConfirm,
|
3373
|
-
variant: variant === "danger-light" ? variant : "secondary",
|
3374
|
-
startIcon: variant === "danger-light" ? /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}) : /* @__PURE__ */ jsxRuntime.jsx(Icons.Check, {}),
|
3375
|
-
children: confirmButton ? confirmButton : formatMessage({
|
3376
|
-
id: "app.components.Button.confirm",
|
3377
|
-
defaultMessage: "Confirm"
|
3378
|
-
})
|
3379
|
-
}
|
3380
|
-
)
|
3381
|
-
}
|
3382
|
-
)
|
3383
|
-
] });
|
3384
|
-
};
|
3385
|
-
const BulkActionModal = ({
|
3386
|
-
isOpen,
|
3387
|
-
title,
|
3388
|
-
onClose,
|
3389
|
-
content: Content,
|
3390
|
-
onModalClose
|
3391
|
-
}) => {
|
3392
|
-
const id = React__namespace.useId();
|
3393
|
-
if (!isOpen) {
|
3394
|
-
return null;
|
3395
|
-
}
|
3396
|
-
const handleClose = () => {
|
3397
|
-
if (onClose) {
|
3398
|
-
onClose();
|
3399
|
-
}
|
3400
|
-
onModalClose();
|
3401
|
-
};
|
3402
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.ModalLayout, { borderRadius: "4px", overflow: "hidden", onClose: handleClose, labelledBy: id, children: [
|
3403
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral800", tag: "h2", id, children: title }) }),
|
3404
|
-
/* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose })
|
3405
|
-
] });
|
3406
|
-
};
|
3407
3743
|
const DeleteAction = ({ documents, model }) => {
|
3408
3744
|
const { formatMessage } = reactIntl.useIntl();
|
3409
3745
|
const { schema: contentType } = useDoc();
|
@@ -3424,8 +3760,7 @@ const DeleteAction = ({ documents, model }) => {
|
|
3424
3760
|
selectRow([]);
|
3425
3761
|
}
|
3426
3762
|
};
|
3427
|
-
if (!hasDeletePermission)
|
3428
|
-
return null;
|
3763
|
+
if (!hasDeletePermission) return null;
|
3429
3764
|
return {
|
3430
3765
|
variant: "danger-light",
|
3431
3766
|
label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
|
@@ -3436,6 +3771,7 @@ const DeleteAction = ({ documents, model }) => {
|
|
3436
3771
|
defaultMessage: "Confirmation"
|
3437
3772
|
}),
|
3438
3773
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3774
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3439
3775
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3440
3776
|
id: "popUpWarning.bodyMessage.contentType.delete.all",
|
3441
3777
|
defaultMessage: "Are you sure you want to delete these entries?"
|
@@ -3472,9 +3808,8 @@ const UnpublishAction = ({ documents, model }) => {
|
|
3472
3808
|
selectRow([]);
|
3473
3809
|
}
|
3474
3810
|
};
|
3475
|
-
const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published");
|
3476
|
-
if (!showUnpublishButton)
|
3477
|
-
return null;
|
3811
|
+
const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
|
3812
|
+
if (!showUnpublishButton) return null;
|
3478
3813
|
return {
|
3479
3814
|
variant: "tertiary",
|
3480
3815
|
label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
|
@@ -3485,6 +3820,7 @@ const UnpublishAction = ({ documents, model }) => {
|
|
3485
3820
|
defaultMessage: "Confirmation"
|
3486
3821
|
}),
|
3487
3822
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3823
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3488
3824
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3489
3825
|
id: "popUpWarning.bodyMessage.contentType.unpublish.all",
|
3490
3826
|
defaultMessage: "Are you sure you want to unpublish these entries?"
|
@@ -3578,7 +3914,7 @@ const TableActions = ({ document }) => {
|
|
3578
3914
|
strapiAdmin.DescriptionComponentRenderer,
|
3579
3915
|
{
|
3580
3916
|
props,
|
3581
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3917
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("table-row").filter((action) => action.name !== "PublishAction"),
|
3582
3918
|
children: (actions2) => {
|
3583
3919
|
const tableRowActions = actions2.filter((action) => {
|
3584
3920
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -3637,6 +3973,7 @@ const EditAction = ({ documentId }) => {
|
|
3637
3973
|
};
|
3638
3974
|
};
|
3639
3975
|
EditAction.type = "edit";
|
3976
|
+
EditAction.position = "table-row";
|
3640
3977
|
const StyledPencil = styledComponents.styled(Icons.Pencil)`
|
3641
3978
|
path {
|
3642
3979
|
fill: currentColor;
|
@@ -3689,7 +4026,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3689
4026
|
}),
|
3690
4027
|
content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
3691
4028
|
footer: ({ onClose }) => {
|
3692
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
4029
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
3693
4030
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
3694
4031
|
id: "cancel",
|
3695
4032
|
defaultMessage: "Cancel"
|
@@ -3713,6 +4050,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3713
4050
|
};
|
3714
4051
|
};
|
3715
4052
|
CloneAction.type = "clone";
|
4053
|
+
CloneAction.position = "table-row";
|
3716
4054
|
const StyledDuplicate = styledComponents.styled(Icons.Duplicate)`
|
3717
4055
|
path {
|
3718
4056
|
fill: currentColor;
|
@@ -3730,8 +4068,7 @@ class ContentManagerPlugin {
|
|
3730
4068
|
documentActions = [
|
3731
4069
|
...DEFAULT_ACTIONS,
|
3732
4070
|
...DEFAULT_TABLE_ROW_ACTIONS,
|
3733
|
-
...DEFAULT_HEADER_ACTIONS
|
3734
|
-
HistoryAction
|
4071
|
+
...DEFAULT_HEADER_ACTIONS
|
3735
4072
|
];
|
3736
4073
|
editViewSidePanels = [ActionsPanel];
|
3737
4074
|
headerActions = [];
|
@@ -3800,7 +4137,14 @@ class ContentManagerPlugin {
|
|
3800
4137
|
addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
|
3801
4138
|
addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
|
3802
4139
|
getBulkActions: () => this.bulkActions,
|
3803
|
-
getDocumentActions: () =>
|
4140
|
+
getDocumentActions: (position) => {
|
4141
|
+
if (position) {
|
4142
|
+
return this.documentActions.filter(
|
4143
|
+
(action) => action.position == void 0 || [action.position].flat().includes(position)
|
4144
|
+
);
|
4145
|
+
}
|
4146
|
+
return this.documentActions;
|
4147
|
+
},
|
3804
4148
|
getEditViewSidePanels: () => this.editViewSidePanels,
|
3805
4149
|
getHeaderActions: () => this.headerActions
|
3806
4150
|
}
|
@@ -3810,16 +4154,71 @@ class ContentManagerPlugin {
|
|
3810
4154
|
const getPrintableType = (value) => {
|
3811
4155
|
const nativeType = typeof value;
|
3812
4156
|
if (nativeType === "object") {
|
3813
|
-
if (value === null)
|
3814
|
-
|
3815
|
-
if (Array.isArray(value))
|
3816
|
-
return "array";
|
4157
|
+
if (value === null) return "null";
|
4158
|
+
if (Array.isArray(value)) return "array";
|
3817
4159
|
if (value instanceof Object && value.constructor.name !== "Object") {
|
3818
4160
|
return value.constructor.name;
|
3819
4161
|
}
|
3820
4162
|
}
|
3821
4163
|
return nativeType;
|
3822
4164
|
};
|
4165
|
+
const HistoryAction = ({ model, document }) => {
|
4166
|
+
const { formatMessage } = reactIntl.useIntl();
|
4167
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
4168
|
+
const navigate = reactRouterDom.useNavigate();
|
4169
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
4170
|
+
const { pathname } = reactRouterDom.useLocation();
|
4171
|
+
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
4172
|
+
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
4173
|
+
return null;
|
4174
|
+
}
|
4175
|
+
const handleOnClick = () => {
|
4176
|
+
const destination = { pathname: "history", search: pluginsQueryParams };
|
4177
|
+
trackUsage("willNavigate", {
|
4178
|
+
from: pathname,
|
4179
|
+
to: `${pathname}/${destination.pathname}`
|
4180
|
+
});
|
4181
|
+
navigate(destination);
|
4182
|
+
};
|
4183
|
+
return {
|
4184
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
4185
|
+
label: formatMessage({
|
4186
|
+
id: "content-manager.history.document-action",
|
4187
|
+
defaultMessage: "Content History"
|
4188
|
+
}),
|
4189
|
+
onClick: handleOnClick,
|
4190
|
+
disabled: (
|
4191
|
+
/**
|
4192
|
+
* The user is creating a new document.
|
4193
|
+
* It hasn't been saved yet, so there's no history to go to
|
4194
|
+
*/
|
4195
|
+
!document || /**
|
4196
|
+
* The document has been created but the current dimension has never been saved.
|
4197
|
+
* For example, the user is creating a new locale in an existing document,
|
4198
|
+
* so there's no history for the document in that locale
|
4199
|
+
*/
|
4200
|
+
!document.id || /**
|
4201
|
+
* History is only available for content types created by the user.
|
4202
|
+
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
4203
|
+
* which start with `admin::` or `plugin::`
|
4204
|
+
*/
|
4205
|
+
!model.startsWith("api::")
|
4206
|
+
),
|
4207
|
+
position: "header"
|
4208
|
+
};
|
4209
|
+
};
|
4210
|
+
HistoryAction.type = "history";
|
4211
|
+
HistoryAction.position = "header";
|
4212
|
+
const historyAdmin = {
|
4213
|
+
bootstrap(app) {
|
4214
|
+
const { addDocumentAction } = app.getPlugin("content-manager").apis;
|
4215
|
+
addDocumentAction((actions2) => {
|
4216
|
+
const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
|
4217
|
+
actions2.splice(indexOfDeleteAction, 0, HistoryAction);
|
4218
|
+
return actions2;
|
4219
|
+
});
|
4220
|
+
}
|
4221
|
+
};
|
3823
4222
|
const initialState = {
|
3824
4223
|
collectionTypeLinks: [],
|
3825
4224
|
components: [],
|
@@ -3856,6 +4255,88 @@ const { setInitialData } = actions;
|
|
3856
4255
|
const reducer = toolkit.combineReducers({
|
3857
4256
|
app: reducer$1
|
3858
4257
|
});
|
4258
|
+
const previewApi = contentManagerApi.injectEndpoints({
|
4259
|
+
endpoints: (builder) => ({
|
4260
|
+
getPreviewUrl: builder.query({
|
4261
|
+
query({ query, params }) {
|
4262
|
+
return {
|
4263
|
+
url: `/content-manager/preview/url/${params.contentType}`,
|
4264
|
+
method: "GET",
|
4265
|
+
config: {
|
4266
|
+
params: query
|
4267
|
+
}
|
4268
|
+
};
|
4269
|
+
}
|
4270
|
+
})
|
4271
|
+
})
|
4272
|
+
});
|
4273
|
+
const { useGetPreviewUrlQuery } = previewApi;
|
4274
|
+
const ConditionalTooltip = ({ isShown, label, children }) => {
|
4275
|
+
if (isShown) {
|
4276
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { label, children });
|
4277
|
+
}
|
4278
|
+
return children;
|
4279
|
+
};
|
4280
|
+
const PreviewSidePanel = ({ model, documentId, document }) => {
|
4281
|
+
const { formatMessage } = reactIntl.useIntl();
|
4282
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
4283
|
+
const { pathname } = reactRouterDom.useLocation();
|
4284
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
4285
|
+
const isModified = strapiAdmin.useForm("PreviewSidePanel", (state) => state.modified);
|
4286
|
+
const { data, error } = useGetPreviewUrlQuery({
|
4287
|
+
params: {
|
4288
|
+
contentType: model
|
4289
|
+
},
|
4290
|
+
query: {
|
4291
|
+
documentId,
|
4292
|
+
locale: document?.locale,
|
4293
|
+
status: document?.status
|
4294
|
+
}
|
4295
|
+
});
|
4296
|
+
if (!data?.data?.url || error) {
|
4297
|
+
return null;
|
4298
|
+
}
|
4299
|
+
const trackNavigation = () => {
|
4300
|
+
const destinationPathname = pathname.replace(/\/$/, "") + "/preview";
|
4301
|
+
trackUsage("willNavigate", { from: pathname, to: destinationPathname });
|
4302
|
+
};
|
4303
|
+
return {
|
4304
|
+
title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
|
4305
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(
|
4306
|
+
ConditionalTooltip,
|
4307
|
+
{
|
4308
|
+
label: formatMessage({
|
4309
|
+
id: "content-manager.preview.panel.button-disabled-tooltip",
|
4310
|
+
defaultMessage: "Please save to open the preview"
|
4311
|
+
}),
|
4312
|
+
isShown: isModified,
|
4313
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { cursor: "not-allowed", width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(
|
4314
|
+
designSystem.Button,
|
4315
|
+
{
|
4316
|
+
variant: "tertiary",
|
4317
|
+
tag: reactRouterDom.Link,
|
4318
|
+
to: { pathname: "preview", search: qs.stringify(query, { encode: false }) },
|
4319
|
+
onClick: trackNavigation,
|
4320
|
+
width: "100%",
|
4321
|
+
disabled: isModified,
|
4322
|
+
pointerEvents: isModified ? "none" : void 0,
|
4323
|
+
tabIndex: isModified ? -1 : void 0,
|
4324
|
+
children: formatMessage({
|
4325
|
+
id: "content-manager.preview.panel.button",
|
4326
|
+
defaultMessage: "Open preview"
|
4327
|
+
})
|
4328
|
+
}
|
4329
|
+
) })
|
4330
|
+
}
|
4331
|
+
)
|
4332
|
+
};
|
4333
|
+
};
|
4334
|
+
const previewAdmin = {
|
4335
|
+
bootstrap(app) {
|
4336
|
+
const contentManagerPluginApis = app.getPlugin("content-manager").apis;
|
4337
|
+
contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
|
4338
|
+
}
|
4339
|
+
};
|
3859
4340
|
const index = {
|
3860
4341
|
register(app) {
|
3861
4342
|
const cm = new ContentManagerPlugin();
|
@@ -3870,15 +4351,32 @@ const index = {
|
|
3870
4351
|
defaultMessage: "Content Manager"
|
3871
4352
|
},
|
3872
4353
|
permissions: [],
|
3873
|
-
Component: () => Promise.resolve().then(() => require("./layout-b91XRlD2.js")).then((mod) => ({ default: mod.Layout })),
|
3874
4354
|
position: 1
|
3875
4355
|
});
|
4356
|
+
app.router.addRoute({
|
4357
|
+
path: "content-manager/*",
|
4358
|
+
lazy: async () => {
|
4359
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-4TbKVax8.js"));
|
4360
|
+
return {
|
4361
|
+
Component: Layout
|
4362
|
+
};
|
4363
|
+
},
|
4364
|
+
children: routes
|
4365
|
+
});
|
3876
4366
|
app.registerPlugin(cm.config);
|
3877
4367
|
},
|
4368
|
+
bootstrap(app) {
|
4369
|
+
if (typeof historyAdmin.bootstrap === "function") {
|
4370
|
+
historyAdmin.bootstrap(app);
|
4371
|
+
}
|
4372
|
+
if (typeof previewAdmin.bootstrap === "function") {
|
4373
|
+
previewAdmin.bootstrap(app);
|
4374
|
+
}
|
4375
|
+
},
|
3878
4376
|
async registerTrads({ locales }) {
|
3879
4377
|
const importedTrads = await Promise.all(
|
3880
4378
|
locales.map((locale) => {
|
3881
|
-
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-
|
4379
|
+
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-CzCnBk4S.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-9K52xZIr.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-B2Kyv8Z9.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-7sfIbjxE.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`, 3).then(({ default: data }) => {
|
3882
4380
|
return {
|
3883
4381
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3884
4382
|
locale
|
@@ -3896,10 +4394,10 @@ const index = {
|
|
3896
4394
|
};
|
3897
4395
|
exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
|
3898
4396
|
exports.BulkActionsRenderer = BulkActionsRenderer;
|
4397
|
+
exports.CLONE_PATH = CLONE_PATH;
|
3899
4398
|
exports.COLLECTION_TYPES = COLLECTION_TYPES;
|
3900
4399
|
exports.CREATOR_FIELDS = CREATOR_FIELDS;
|
3901
4400
|
exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
|
3902
|
-
exports.DOCUMENT_META_FIELDS = DOCUMENT_META_FIELDS;
|
3903
4401
|
exports.DocumentRBAC = DocumentRBAC;
|
3904
4402
|
exports.DocumentStatus = DocumentStatus;
|
3905
4403
|
exports.HOOKS = HOOKS;
|
@@ -3916,14 +4414,18 @@ exports.checkIfAttributeIsDisplayable = checkIfAttributeIsDisplayable;
|
|
3916
4414
|
exports.contentManagerApi = contentManagerApi;
|
3917
4415
|
exports.convertEditLayoutToFieldLayouts = convertEditLayoutToFieldLayouts;
|
3918
4416
|
exports.convertListLayoutToFieldLayouts = convertListLayoutToFieldLayouts;
|
4417
|
+
exports.createDefaultForm = createDefaultForm;
|
3919
4418
|
exports.createYupSchema = createYupSchema;
|
3920
4419
|
exports.extractContentTypeComponents = extractContentTypeComponents;
|
3921
4420
|
exports.getDisplayName = getDisplayName;
|
3922
4421
|
exports.getMainField = getMainField;
|
3923
4422
|
exports.getTranslation = getTranslation;
|
3924
4423
|
exports.index = index;
|
3925
|
-
exports.
|
4424
|
+
exports.prepareTempKeys = prepareTempKeys;
|
4425
|
+
exports.removeFieldsThatDontExistOnSchema = removeFieldsThatDontExistOnSchema;
|
3926
4426
|
exports.setInitialData = setInitialData;
|
4427
|
+
exports.transformDocument = transformDocument;
|
4428
|
+
exports.useContentManagerContext = useContentManagerContext;
|
3927
4429
|
exports.useContentTypeSchema = useContentTypeSchema;
|
3928
4430
|
exports.useDoc = useDoc;
|
3929
4431
|
exports.useDocLayout = useDocLayout;
|
@@ -3935,5 +4437,6 @@ exports.useGetAllContentTypeSettingsQuery = useGetAllContentTypeSettingsQuery;
|
|
3935
4437
|
exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
3936
4438
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
3937
4439
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
4440
|
+
exports.useGetPreviewUrlQuery = useGetPreviewUrlQuery;
|
3938
4441
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
3939
|
-
//# sourceMappingURL=index-
|
4442
|
+
//# sourceMappingURL=index-EXJvmn4t.js.map
|