@strapi/content-manager 0.0.0-experimental.cb311d9fcfbd8e441f790aea232f0a39bdd90e16 → 0.0.0-experimental.cfda358b7f27015e34e739b8742a2962ae2e7aee
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/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -1
- package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-DL1MHO8i.js → ComponentConfigurationPage-BTR_hQow.js} +5 -6
- package/dist/_chunks/{ComponentConfigurationPage-DL1MHO8i.js.map → ComponentConfigurationPage-BTR_hQow.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-D0dyDTwq.mjs → ComponentConfigurationPage-bLQr82ce.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-D0dyDTwq.mjs.map → ComponentConfigurationPage-bLQr82ce.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-13b7S5Cq.mjs → EditConfigurationPage-BhRSnUsL.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-13b7S5Cq.mjs.map → EditConfigurationPage-BhRSnUsL.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CMaOf-A-.js → EditConfigurationPage-z39Wv3E6.js} +5 -6
- package/dist/_chunks/{EditConfigurationPage-CMaOf-A-.js.map → EditConfigurationPage-z39Wv3E6.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-C3tIZ8F5.mjs → EditViewPage-BCjNxNlY.mjs} +63 -12
- package/dist/_chunks/EditViewPage-BCjNxNlY.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-BSVmMpRd.js → EditViewPage-wujOq90c.js} +63 -13
- package/dist/_chunks/EditViewPage-wujOq90c.js.map +1 -0
- package/dist/_chunks/{Field-DUCVth4C.js → Field-B5QXnctJ.js} +320 -169
- package/dist/_chunks/Field-B5QXnctJ.js.map +1 -0
- package/dist/_chunks/{Field-BvuT8cGL.mjs → Field-Byr3mPTl.mjs} +316 -165
- package/dist/_chunks/Field-Byr3mPTl.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-BZmDNVr9.mjs → Form-BZgvE8C8.mjs} +37 -18
- package/dist/_chunks/Form-BZgvE8C8.mjs.map +1 -0
- package/dist/_chunks/{Form-Cpl4W1ak.js → Form-D7mexvm3.js} +39 -21
- package/dist/_chunks/Form-D7mexvm3.js.map +1 -0
- package/dist/_chunks/{History-Cq_Hrzuu.mjs → History-CqNgxkqK.mjs} +43 -100
- package/dist/_chunks/History-CqNgxkqK.mjs.map +1 -0
- package/dist/_chunks/{History-D4U2YISB.js → History-DYl2A8Z_.js} +42 -100
- package/dist/_chunks/History-DYl2A8Z_.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-Bny6CdWe.js → ListConfigurationPage-BXnu_OoY.js} +19 -9
- package/dist/_chunks/ListConfigurationPage-BXnu_OoY.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-W-KQHmBv.mjs → ListConfigurationPage-BbQjzKkQ.mjs} +19 -8
- package/dist/_chunks/ListConfigurationPage-BbQjzKkQ.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-O8F1pBJo.js → ListViewPage-BtSi8C1l.js} +103 -77
- package/dist/_chunks/ListViewPage-BtSi8C1l.js.map +1 -0
- package/dist/_chunks/{ListViewPage-HBBnJa8K.mjs → ListViewPage-D4ofkbjR.mjs} +99 -72
- package/dist/_chunks/ListViewPage-D4ofkbjR.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-CQWChGPw.js → NoContentTypePage-CitJeOq4.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-CQWChGPw.js.map → NoContentTypePage-CitJeOq4.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-B-gIhHWM.mjs → NoContentTypePage-DyUx5mXh.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-B-gIhHWM.mjs.map → NoContentTypePage-DyUx5mXh.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-XhOPl8wx.mjs → NoPermissionsPage-DhIiyWkk.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-XhOPl8wx.mjs.map → NoPermissionsPage-DhIiyWkk.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-CY46zxnM.js → NoPermissionsPage-DzgWz0M-.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-CY46zxnM.js.map → NoPermissionsPage-DzgWz0M-.js.map} +1 -1
- package/dist/_chunks/Preview-BaYGJ0nb.mjs +293 -0
- package/dist/_chunks/Preview-BaYGJ0nb.mjs.map +1 -0
- package/dist/_chunks/Preview-DfNx8Ke-.js +311 -0
- package/dist/_chunks/Preview-DfNx8Ke-.js.map +1 -0
- package/dist/_chunks/{Relations-vFZ6Wasg.mjs → Relations-DM2yUTST.mjs} +76 -42
- package/dist/_chunks/Relations-DM2yUTST.mjs.map +1 -0
- package/dist/_chunks/{Relations-C4gGfZRv.js → Relations-DuKCaXrv.js} +76 -43
- package/dist/_chunks/Relations-DuKCaXrv.js.map +1 -0
- package/dist/_chunks/{en-uOUIxfcQ.js → en-BK8Xyl5I.js} +28 -15
- package/dist/_chunks/{en-uOUIxfcQ.js.map → en-BK8Xyl5I.js.map} +1 -1
- package/dist/_chunks/{en-BrCTWlZv.mjs → en-Dtk_ot79.mjs} +28 -15
- package/dist/_chunks/{en-BrCTWlZv.mjs.map → en-Dtk_ot79.mjs.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-5EMXLEM_.js → index-BUWEmX8m.js} +1320 -996
- package/dist/_chunks/index-BUWEmX8m.js.map +1 -0
- package/dist/_chunks/{index-Dpxg3ctD.mjs → index-DVAIIsOs.mjs} +1338 -1014
- package/dist/_chunks/index-DVAIIsOs.mjs.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-C0INpKap.mjs → layout-Bxsv5mP7.mjs} +9 -8
- package/dist/_chunks/layout-Bxsv5mP7.mjs.map +1 -0
- package/dist/_chunks/{layout-P3eKO1Qy.js → layout-C3fN7Ejz.js} +10 -10
- package/dist/_chunks/layout-C3fN7Ejz.js.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-B1y0K6LE.js → relations-BPZKAoEY.js} +6 -7
- package/dist/_chunks/relations-BPZKAoEY.js.map +1 -0
- package/dist/_chunks/{relations-FBRRBWeO.mjs → relations-o3pPhzY4.mjs} +6 -7
- package/dist/_chunks/relations-o3pPhzY4.mjs.map +1 -0
- package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
- package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs.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/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +5 -4
- package/dist/admin/src/content-manager.d.ts +3 -2
- package/dist/admin/src/exports.d.ts +1 -1
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +32 -1
- package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
- 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 +1 -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 +4 -48
- package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
- 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 +482 -219
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +482 -218
- 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/utils/metadata.d.ts +15 -1
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
- 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 +3 -3
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +4 -4
- 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 +8 -8
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +4 -4
- 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/configuration/index.d.ts +2 -2
- package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
- 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 -15
- package/dist/_chunks/EditViewPage-BSVmMpRd.js.map +0 -1
- package/dist/_chunks/EditViewPage-C3tIZ8F5.mjs.map +0 -1
- package/dist/_chunks/Field-BvuT8cGL.mjs.map +0 -1
- package/dist/_chunks/Field-DUCVth4C.js.map +0 -1
- package/dist/_chunks/Form-BZmDNVr9.mjs.map +0 -1
- package/dist/_chunks/Form-Cpl4W1ak.js.map +0 -1
- package/dist/_chunks/History-Cq_Hrzuu.mjs.map +0 -1
- package/dist/_chunks/History-D4U2YISB.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-Bny6CdWe.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-W-KQHmBv.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-HBBnJa8K.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-O8F1pBJo.js.map +0 -1
- package/dist/_chunks/Relations-C4gGfZRv.js.map +0 -1
- package/dist/_chunks/Relations-vFZ6Wasg.mjs.map +0 -1
- package/dist/_chunks/index-5EMXLEM_.js.map +0 -1
- package/dist/_chunks/index-Dpxg3ctD.mjs.map +0 -1
- package/dist/_chunks/layout-C0INpKap.mjs.map +0 -1
- package/dist/_chunks/layout-P3eKO1Qy.js.map +0 -1
- package/dist/_chunks/relations-B1y0K6LE.js.map +0 -1
- package/dist/_chunks/relations-FBRRBWeO.mjs.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
@@ -4,18 +4,18 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const strapiAdmin = require("@strapi/admin/strapi-admin");
|
5
5
|
const React = require("react");
|
6
6
|
const designSystem = require("@strapi/design-system");
|
7
|
+
const mapValues = require("lodash/fp/mapValues");
|
7
8
|
const reactIntl = require("react-intl");
|
8
9
|
const reactRouterDom = require("react-router-dom");
|
9
10
|
const styledComponents = require("styled-components");
|
10
11
|
const yup = require("yup");
|
12
|
+
const qs = require("qs");
|
11
13
|
const pipe = require("lodash/fp/pipe");
|
12
14
|
const dateFns = require("date-fns");
|
13
|
-
const qs = require("qs");
|
14
15
|
const toolkit = require("@reduxjs/toolkit");
|
15
16
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
16
17
|
function _interopNamespace(e) {
|
17
|
-
if (e && e.__esModule)
|
18
|
-
return e;
|
18
|
+
if (e && e.__esModule) return e;
|
19
19
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
20
20
|
if (e) {
|
21
21
|
for (const k in e) {
|
@@ -32,15 +32,23 @@ function _interopNamespace(e) {
|
|
32
32
|
return Object.freeze(n);
|
33
33
|
}
|
34
34
|
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
35
|
+
const mapValues__default = /* @__PURE__ */ _interopDefault(mapValues);
|
35
36
|
const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
|
36
37
|
const pipe__default = /* @__PURE__ */ _interopDefault(pipe);
|
37
|
-
const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
38
|
+
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
38
39
|
const v = glob[path];
|
39
40
|
if (v) {
|
40
41
|
return typeof v === "function" ? v() : Promise.resolve(v);
|
41
42
|
}
|
42
43
|
return new Promise((_, reject) => {
|
43
|
-
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
44
|
+
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
45
|
+
reject.bind(
|
46
|
+
null,
|
47
|
+
new Error(
|
48
|
+
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
49
|
+
)
|
50
|
+
)
|
51
|
+
);
|
44
52
|
});
|
45
53
|
};
|
46
54
|
const PLUGIN_ID = "content-manager";
|
@@ -121,6 +129,7 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
121
129
|
if (!slug) {
|
122
130
|
throw new Error("Cannot find the slug param in the URL");
|
123
131
|
}
|
132
|
+
const [{ rawQuery }] = strapiAdmin.useQueryParams();
|
124
133
|
const userPermissions = strapiAdmin.useAuth("DocumentRBAC", (state) => state.permissions);
|
125
134
|
const contentTypePermissions = React__namespace.useMemo(() => {
|
126
135
|
const contentTypePermissions2 = userPermissions.filter(
|
@@ -131,7 +140,14 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
131
140
|
return { ...acc, [action]: [permission] };
|
132
141
|
}, {});
|
133
142
|
}, [slug, userPermissions]);
|
134
|
-
const { isLoading, allowedActions } = strapiAdmin.useRBAC(
|
143
|
+
const { isLoading, allowedActions } = strapiAdmin.useRBAC(
|
144
|
+
contentTypePermissions,
|
145
|
+
permissions ?? void 0,
|
146
|
+
// TODO: useRBAC context should be typed and built differently
|
147
|
+
// We are passing raw query as context to the hook so that it can
|
148
|
+
// rely on the locale provided from DocumentRBAC for its permission calculations.
|
149
|
+
rawQuery
|
150
|
+
);
|
135
151
|
const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
|
136
152
|
const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
|
137
153
|
const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
|
@@ -179,7 +195,8 @@ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
|
|
179
195
|
"Document",
|
180
196
|
"InitialData",
|
181
197
|
"HistoryVersion",
|
182
|
-
"Relations"
|
198
|
+
"Relations",
|
199
|
+
"UidAvailability"
|
183
200
|
]
|
184
201
|
});
|
185
202
|
const documentApi = contentManagerApi.injectEndpoints({
|
@@ -209,7 +226,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
209
226
|
params
|
210
227
|
}
|
211
228
|
}),
|
212
|
-
invalidatesTags: (_result, _error, { model }) => [
|
229
|
+
invalidatesTags: (_result, _error, { model }) => [
|
230
|
+
{ type: "Document", id: `${model}_LIST` },
|
231
|
+
{ type: "UidAvailability", id: model }
|
232
|
+
]
|
213
233
|
}),
|
214
234
|
/**
|
215
235
|
* Creates a new collection-type document. This should ONLY be used for collection-types.
|
@@ -226,7 +246,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
226
246
|
}),
|
227
247
|
invalidatesTags: (result, _error, { model }) => [
|
228
248
|
{ type: "Document", id: `${model}_LIST` },
|
229
|
-
"Relations"
|
249
|
+
"Relations",
|
250
|
+
{ type: "UidAvailability", id: model }
|
230
251
|
]
|
231
252
|
}),
|
232
253
|
deleteDocument: builder.mutation({
|
@@ -267,7 +288,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
267
288
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
268
289
|
},
|
269
290
|
{ type: "Document", id: `${model}_LIST` },
|
270
|
-
"Relations"
|
291
|
+
"Relations",
|
292
|
+
{ type: "UidAvailability", id: model }
|
271
293
|
];
|
272
294
|
}
|
273
295
|
}),
|
@@ -280,7 +302,7 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
280
302
|
url: `/content-manager/collection-types/${model}`,
|
281
303
|
method: "GET",
|
282
304
|
config: {
|
283
|
-
params
|
305
|
+
params: qs.stringify(params, { encode: true })
|
284
306
|
}
|
285
307
|
}),
|
286
308
|
providesTags: (result, _error, arg) => {
|
@@ -392,7 +414,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
392
414
|
type: "Document",
|
393
415
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
394
416
|
},
|
395
|
-
"Relations"
|
417
|
+
"Relations",
|
418
|
+
{ type: "UidAvailability", id: model }
|
396
419
|
];
|
397
420
|
},
|
398
421
|
async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
|
@@ -458,8 +481,7 @@ const {
|
|
458
481
|
useUnpublishManyDocumentsMutation
|
459
482
|
} = documentApi;
|
460
483
|
const buildValidParams = (query) => {
|
461
|
-
if (!query)
|
462
|
-
return query;
|
484
|
+
if (!query) return query;
|
463
485
|
const { plugins: _, ...validQueryParams } = {
|
464
486
|
...query,
|
465
487
|
...Object.values(query?.plugins ?? {}).reduce(
|
@@ -467,28 +489,44 @@ const buildValidParams = (query) => {
|
|
467
489
|
{}
|
468
490
|
)
|
469
491
|
};
|
470
|
-
if ("_q" in validQueryParams) {
|
471
|
-
validQueryParams._q = encodeURIComponent(validQueryParams._q);
|
472
|
-
}
|
473
492
|
return validQueryParams;
|
474
493
|
};
|
475
494
|
const isBaseQueryError = (error) => {
|
476
495
|
return error.name !== void 0;
|
477
496
|
};
|
478
|
-
const
|
497
|
+
const arrayValidator = (attribute, options) => ({
|
498
|
+
message: strapiAdmin.translatedErrors.required,
|
499
|
+
test(value) {
|
500
|
+
if (options.status === "draft") {
|
501
|
+
return true;
|
502
|
+
}
|
503
|
+
if (!attribute.required) {
|
504
|
+
return true;
|
505
|
+
}
|
506
|
+
if (!value) {
|
507
|
+
return false;
|
508
|
+
}
|
509
|
+
if (Array.isArray(value) && value.length === 0) {
|
510
|
+
return false;
|
511
|
+
}
|
512
|
+
return true;
|
513
|
+
}
|
514
|
+
});
|
515
|
+
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
479
516
|
const createModelSchema = (attributes2) => yup__namespace.object().shape(
|
480
517
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
481
518
|
if (DOCUMENT_META_FIELDS.includes(name)) {
|
482
519
|
return acc;
|
483
520
|
}
|
484
521
|
const validations = [
|
522
|
+
addNullableValidation,
|
485
523
|
addRequiredValidation,
|
486
524
|
addMinLengthValidation,
|
487
525
|
addMaxLengthValidation,
|
488
526
|
addMinValidation,
|
489
527
|
addMaxValidation,
|
490
528
|
addRegexValidation
|
491
|
-
].map((fn) => fn(attribute));
|
529
|
+
].map((fn) => fn(attribute, options));
|
492
530
|
const transformSchema = pipe__default.default(...validations);
|
493
531
|
switch (attribute.type) {
|
494
532
|
case "component": {
|
@@ -498,12 +536,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
498
536
|
...acc,
|
499
537
|
[name]: transformSchema(
|
500
538
|
yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
|
501
|
-
)
|
539
|
+
).test(arrayValidator(attribute, options))
|
502
540
|
};
|
503
541
|
} else {
|
504
542
|
return {
|
505
543
|
...acc,
|
506
|
-
[name]: transformSchema(createModelSchema(attributes3))
|
544
|
+
[name]: transformSchema(createModelSchema(attributes3).nullable())
|
507
545
|
};
|
508
546
|
}
|
509
547
|
}
|
@@ -525,7 +563,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
525
563
|
}
|
526
564
|
)
|
527
565
|
)
|
528
|
-
)
|
566
|
+
).test(arrayValidator(attribute, options))
|
529
567
|
};
|
530
568
|
case "relation":
|
531
569
|
return {
|
@@ -537,7 +575,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
537
575
|
} else if (Array.isArray(value)) {
|
538
576
|
return yup__namespace.array().of(
|
539
577
|
yup__namespace.object().shape({
|
540
|
-
id: yup__namespace.
|
578
|
+
id: yup__namespace.number().required()
|
541
579
|
})
|
542
580
|
);
|
543
581
|
} else if (typeof value === "object") {
|
@@ -615,13 +653,7 @@ const createAttributeSchema = (attribute) => {
|
|
615
653
|
return yup__namespace.mixed();
|
616
654
|
}
|
617
655
|
};
|
618
|
-
const
|
619
|
-
if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
|
620
|
-
return schema.min(1, strapiAdmin.translatedErrors.required);
|
621
|
-
}
|
622
|
-
if (attribute.required && attribute.type !== "relation") {
|
623
|
-
return schema.required(strapiAdmin.translatedErrors.required);
|
624
|
-
}
|
656
|
+
const nullableSchema = (schema) => {
|
625
657
|
return schema?.nullable ? schema.nullable() : (
|
626
658
|
// In some cases '.nullable' will not be available on the schema.
|
627
659
|
// e.g. when the schema has been built using yup.lazy (e.g. for relations).
|
@@ -629,7 +661,22 @@ const addRequiredValidation = (attribute) => (schema) => {
|
|
629
661
|
schema
|
630
662
|
);
|
631
663
|
};
|
632
|
-
const
|
664
|
+
const addNullableValidation = () => (schema) => {
|
665
|
+
return nullableSchema(schema);
|
666
|
+
};
|
667
|
+
const addRequiredValidation = (attribute, options) => (schema) => {
|
668
|
+
if (options.status === "draft" || !attribute.required) {
|
669
|
+
return schema;
|
670
|
+
}
|
671
|
+
if (attribute.required && "required" in schema) {
|
672
|
+
return schema.required(strapiAdmin.translatedErrors.required);
|
673
|
+
}
|
674
|
+
return schema;
|
675
|
+
};
|
676
|
+
const addMinLengthValidation = (attribute, options) => (schema) => {
|
677
|
+
if (options.status === "draft") {
|
678
|
+
return schema;
|
679
|
+
}
|
633
680
|
if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
|
634
681
|
return schema.min(attribute.minLength, {
|
635
682
|
...strapiAdmin.translatedErrors.minLength,
|
@@ -651,32 +698,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
651
698
|
}
|
652
699
|
return schema;
|
653
700
|
};
|
654
|
-
const addMinValidation = (attribute) => (schema) => {
|
655
|
-
if ("
|
701
|
+
const addMinValidation = (attribute, options) => (schema) => {
|
702
|
+
if (options.status === "draft") {
|
703
|
+
return schema;
|
704
|
+
}
|
705
|
+
if ("min" in attribute && "min" in schema) {
|
656
706
|
const min = toInteger(attribute.min);
|
657
|
-
if (
|
658
|
-
if (!attribute.required && "test" in schema && min) {
|
659
|
-
return schema.test(
|
660
|
-
"custom-min",
|
661
|
-
{
|
662
|
-
...strapiAdmin.translatedErrors.min,
|
663
|
-
values: {
|
664
|
-
min: attribute.min
|
665
|
-
}
|
666
|
-
},
|
667
|
-
(value) => {
|
668
|
-
if (!value) {
|
669
|
-
return true;
|
670
|
-
}
|
671
|
-
if (Array.isArray(value) && value.length === 0) {
|
672
|
-
return true;
|
673
|
-
}
|
674
|
-
return value.length >= min;
|
675
|
-
}
|
676
|
-
);
|
677
|
-
}
|
678
|
-
}
|
679
|
-
if ("min" in schema && min) {
|
707
|
+
if (min) {
|
680
708
|
return schema.min(min, {
|
681
709
|
...strapiAdmin.translatedErrors.min,
|
682
710
|
values: {
|
@@ -794,19 +822,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
|
|
794
822
|
}, {});
|
795
823
|
return componentsByKey;
|
796
824
|
};
|
797
|
-
const
|
825
|
+
const HOOKS = {
|
826
|
+
/**
|
827
|
+
* Hook that allows to mutate the displayed headers of the list view table
|
828
|
+
* @constant
|
829
|
+
* @type {string}
|
830
|
+
*/
|
831
|
+
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
832
|
+
/**
|
833
|
+
* Hook that allows to mutate the CM's collection types links pre-set filters
|
834
|
+
* @constant
|
835
|
+
* @type {string}
|
836
|
+
*/
|
837
|
+
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
838
|
+
/**
|
839
|
+
* Hook that allows to mutate the CM's edit view layout
|
840
|
+
* @constant
|
841
|
+
* @type {string}
|
842
|
+
*/
|
843
|
+
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
844
|
+
/**
|
845
|
+
* Hook that allows to mutate the CM's single types links pre-set filters
|
846
|
+
* @constant
|
847
|
+
* @type {string}
|
848
|
+
*/
|
849
|
+
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
850
|
+
};
|
851
|
+
const contentTypesApi = contentManagerApi.injectEndpoints({
|
852
|
+
endpoints: (builder) => ({
|
853
|
+
getContentTypeConfiguration: builder.query({
|
854
|
+
query: (uid) => ({
|
855
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
856
|
+
method: "GET"
|
857
|
+
}),
|
858
|
+
transformResponse: (response) => response.data,
|
859
|
+
providesTags: (_result, _error, uid) => [
|
860
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
861
|
+
{ type: "ContentTypeSettings", id: "LIST" }
|
862
|
+
]
|
863
|
+
}),
|
864
|
+
getAllContentTypeSettings: builder.query({
|
865
|
+
query: () => "/content-manager/content-types-settings",
|
866
|
+
transformResponse: (response) => response.data,
|
867
|
+
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
868
|
+
}),
|
869
|
+
updateContentTypeConfiguration: builder.mutation({
|
870
|
+
query: ({ uid, ...body }) => ({
|
871
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
872
|
+
method: "PUT",
|
873
|
+
data: body
|
874
|
+
}),
|
875
|
+
transformResponse: (response) => response.data,
|
876
|
+
invalidatesTags: (_result, _error, { uid }) => [
|
877
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
878
|
+
{ type: "ContentTypeSettings", id: "LIST" },
|
879
|
+
// Is this necessary?
|
880
|
+
{ type: "InitialData" }
|
881
|
+
]
|
882
|
+
})
|
883
|
+
})
|
884
|
+
});
|
885
|
+
const {
|
886
|
+
useGetContentTypeConfigurationQuery,
|
887
|
+
useGetAllContentTypeSettingsQuery,
|
888
|
+
useUpdateContentTypeConfigurationMutation
|
889
|
+
} = contentTypesApi;
|
890
|
+
const checkIfAttributeIsDisplayable = (attribute) => {
|
891
|
+
const { type } = attribute;
|
892
|
+
if (type === "relation") {
|
893
|
+
return !attribute.relation.toLowerCase().includes("morph");
|
894
|
+
}
|
895
|
+
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
896
|
+
};
|
897
|
+
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
898
|
+
if (!mainFieldName) {
|
899
|
+
return void 0;
|
900
|
+
}
|
901
|
+
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
902
|
+
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
903
|
+
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
904
|
+
);
|
905
|
+
return {
|
906
|
+
name: mainFieldName,
|
907
|
+
type: mainFieldType ?? "string"
|
908
|
+
};
|
909
|
+
};
|
910
|
+
const DEFAULT_SETTINGS = {
|
911
|
+
bulkable: false,
|
912
|
+
filterable: false,
|
913
|
+
searchable: false,
|
914
|
+
pagination: false,
|
915
|
+
defaultSortBy: "",
|
916
|
+
defaultSortOrder: "asc",
|
917
|
+
mainField: "id",
|
918
|
+
pageSize: 10
|
919
|
+
};
|
920
|
+
const useDocumentLayout = (model) => {
|
921
|
+
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
922
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
923
|
+
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
798
924
|
const { toggleNotification } = strapiAdmin.useNotification();
|
799
925
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
926
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
800
927
|
const {
|
801
|
-
|
802
|
-
isLoading:
|
803
|
-
|
804
|
-
|
805
|
-
} =
|
806
|
-
|
807
|
-
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
808
|
-
});
|
809
|
-
const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
|
928
|
+
data,
|
929
|
+
isLoading: isLoadingConfigs,
|
930
|
+
error,
|
931
|
+
isFetching: isFetchingConfigs
|
932
|
+
} = useGetContentTypeConfigurationQuery(model);
|
933
|
+
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
810
934
|
React__namespace.useEffect(() => {
|
811
935
|
if (error) {
|
812
936
|
toggleNotification({
|
@@ -814,397 +938,654 @@ const useDocument = (args, opts) => {
|
|
814
938
|
message: formatAPIError(error)
|
815
939
|
});
|
816
940
|
}
|
817
|
-
}, [
|
818
|
-
const
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
(document) => {
|
826
|
-
if (!validationSchema) {
|
827
|
-
throw new Error(
|
828
|
-
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
829
|
-
);
|
830
|
-
}
|
831
|
-
try {
|
832
|
-
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
833
|
-
return null;
|
834
|
-
} catch (error2) {
|
835
|
-
if (error2 instanceof yup.ValidationError) {
|
836
|
-
return strapiAdmin.getYupValidationErrors(error2);
|
837
|
-
}
|
838
|
-
throw error2;
|
839
|
-
}
|
941
|
+
}, [error, formatAPIError, toggleNotification]);
|
942
|
+
const editLayout = React__namespace.useMemo(
|
943
|
+
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
944
|
+
layout: [],
|
945
|
+
components: {},
|
946
|
+
metadatas: {},
|
947
|
+
options: {},
|
948
|
+
settings: DEFAULT_SETTINGS
|
840
949
|
},
|
841
|
-
[
|
950
|
+
[data, isLoading, schemas, schema, components]
|
951
|
+
);
|
952
|
+
const listLayout = React__namespace.useMemo(() => {
|
953
|
+
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
954
|
+
layout: [],
|
955
|
+
metadatas: {},
|
956
|
+
options: {},
|
957
|
+
settings: DEFAULT_SETTINGS
|
958
|
+
};
|
959
|
+
}, [data, isLoading, schemas, schema, components]);
|
960
|
+
const { layout: edit } = React__namespace.useMemo(
|
961
|
+
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
962
|
+
layout: editLayout,
|
963
|
+
query
|
964
|
+
}),
|
965
|
+
[editLayout, query, runHookWaterfall]
|
842
966
|
);
|
843
|
-
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
844
967
|
return {
|
845
|
-
|
846
|
-
document: data?.data,
|
847
|
-
meta: data?.meta,
|
968
|
+
error,
|
848
969
|
isLoading,
|
849
|
-
|
850
|
-
|
851
|
-
};
|
852
|
-
};
|
853
|
-
const useDoc = () => {
|
854
|
-
const { id, slug, collectionType, origin } = reactRouterDom.useParams();
|
855
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
856
|
-
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
857
|
-
if (!collectionType) {
|
858
|
-
throw new Error("Could not find collectionType in url params");
|
859
|
-
}
|
860
|
-
if (!slug) {
|
861
|
-
throw new Error("Could not find model in url params");
|
862
|
-
}
|
863
|
-
return {
|
864
|
-
collectionType,
|
865
|
-
model: slug,
|
866
|
-
id: origin || id === "create" ? void 0 : id,
|
867
|
-
...useDocument(
|
868
|
-
{ documentId: origin || id, model: slug, collectionType, params },
|
869
|
-
{
|
870
|
-
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
871
|
-
}
|
872
|
-
)
|
970
|
+
edit,
|
971
|
+
list: listLayout
|
873
972
|
};
|
874
973
|
};
|
875
|
-
const
|
876
|
-
|
877
|
-
|
878
|
-
}
|
879
|
-
return Object.keys(trad).reduce((acc, current) => {
|
880
|
-
acc[`${pluginId}.${current}`] = trad[current];
|
881
|
-
return acc;
|
882
|
-
}, {});
|
883
|
-
};
|
884
|
-
const getTranslation = (id) => `content-manager.${id}`;
|
885
|
-
const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
886
|
-
id: "notification.error",
|
887
|
-
defaultMessage: "An error occurred, please try again"
|
974
|
+
const useDocLayout = () => {
|
975
|
+
const { model } = useDoc();
|
976
|
+
return useDocumentLayout(model);
|
888
977
|
};
|
889
|
-
const
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
const
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
return { error: res.error };
|
911
|
-
}
|
912
|
-
toggleNotification({
|
913
|
-
type: "success",
|
914
|
-
message: formatMessage({
|
915
|
-
id: getTranslation("success.record.delete"),
|
916
|
-
defaultMessage: "Deleted document"
|
917
|
-
})
|
918
|
-
});
|
919
|
-
trackUsage("didDeleteEntry", trackerProperty);
|
920
|
-
return res.data;
|
921
|
-
} catch (err) {
|
922
|
-
toggleNotification({
|
923
|
-
type: "danger",
|
924
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
925
|
-
});
|
926
|
-
trackUsage("didNotDeleteEntry", { error: err, ...trackerProperty });
|
927
|
-
throw err;
|
978
|
+
const formatEditLayout = (data, {
|
979
|
+
schemas,
|
980
|
+
schema,
|
981
|
+
components
|
982
|
+
}) => {
|
983
|
+
let currentPanelIndex = 0;
|
984
|
+
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
985
|
+
data.contentType.layouts.edit,
|
986
|
+
schema?.attributes,
|
987
|
+
data.contentType.metadatas,
|
988
|
+
{ configurations: data.components, schemas: components },
|
989
|
+
schemas
|
990
|
+
).reduce((panels, row) => {
|
991
|
+
if (row.some((field) => field.type === "dynamiczone")) {
|
992
|
+
panels.push([row]);
|
993
|
+
currentPanelIndex += 2;
|
994
|
+
} else {
|
995
|
+
if (!panels[currentPanelIndex]) {
|
996
|
+
panels.push([row]);
|
997
|
+
} else {
|
998
|
+
panels[currentPanelIndex].push(row);
|
928
999
|
}
|
929
|
-
}
|
930
|
-
|
931
|
-
);
|
932
|
-
const
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
message: formatAPIError(res.error)
|
946
|
-
});
|
947
|
-
return { error: res.error };
|
1000
|
+
}
|
1001
|
+
return panels;
|
1002
|
+
}, []);
|
1003
|
+
const componentEditAttributes = Object.entries(data.components).reduce(
|
1004
|
+
(acc, [uid, configuration]) => {
|
1005
|
+
acc[uid] = {
|
1006
|
+
layout: convertEditLayoutToFieldLayouts(
|
1007
|
+
configuration.layouts.edit,
|
1008
|
+
components[uid].attributes,
|
1009
|
+
configuration.metadatas,
|
1010
|
+
{ configurations: data.components, schemas: components }
|
1011
|
+
),
|
1012
|
+
settings: {
|
1013
|
+
...configuration.settings,
|
1014
|
+
icon: components[uid].info.icon,
|
1015
|
+
displayName: components[uid].info.displayName
|
948
1016
|
}
|
949
|
-
|
950
|
-
|
951
|
-
title: formatMessage({
|
952
|
-
id: getTranslation("success.records.delete"),
|
953
|
-
defaultMessage: "Successfully deleted."
|
954
|
-
}),
|
955
|
-
message: ""
|
956
|
-
});
|
957
|
-
trackUsage("didBulkDeleteEntries");
|
958
|
-
return res.data;
|
959
|
-
} catch (err) {
|
960
|
-
toggleNotification({
|
961
|
-
type: "danger",
|
962
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
963
|
-
});
|
964
|
-
trackUsage("didNotBulkDeleteEntries");
|
965
|
-
throw err;
|
966
|
-
}
|
1017
|
+
};
|
1018
|
+
return acc;
|
967
1019
|
},
|
968
|
-
|
1020
|
+
{}
|
969
1021
|
);
|
970
|
-
const
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
model,
|
977
|
-
documentId,
|
978
|
-
params
|
979
|
-
});
|
980
|
-
if ("error" in res) {
|
981
|
-
toggleNotification({
|
982
|
-
type: "danger",
|
983
|
-
message: formatAPIError(res.error)
|
984
|
-
});
|
985
|
-
return { error: res.error };
|
986
|
-
}
|
987
|
-
toggleNotification({
|
988
|
-
type: "success",
|
989
|
-
message: formatMessage({
|
990
|
-
id: "content-manager.success.record.discard",
|
991
|
-
defaultMessage: "Changes discarded"
|
992
|
-
})
|
993
|
-
});
|
994
|
-
return res.data;
|
995
|
-
} catch (err) {
|
996
|
-
toggleNotification({
|
997
|
-
type: "danger",
|
998
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
999
|
-
});
|
1000
|
-
throw err;
|
1001
|
-
}
|
1022
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1023
|
+
(acc, [attribute, metadata]) => {
|
1024
|
+
return {
|
1025
|
+
...acc,
|
1026
|
+
[attribute]: metadata.edit
|
1027
|
+
};
|
1002
1028
|
},
|
1003
|
-
|
1029
|
+
{}
|
1004
1030
|
);
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
model,
|
1013
|
-
documentId,
|
1014
|
-
data,
|
1015
|
-
params
|
1016
|
-
});
|
1017
|
-
if ("error" in res) {
|
1018
|
-
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1019
|
-
return { error: res.error };
|
1020
|
-
}
|
1021
|
-
trackUsage("didPublishEntry");
|
1022
|
-
toggleNotification({
|
1023
|
-
type: "success",
|
1024
|
-
message: formatMessage({
|
1025
|
-
id: getTranslation("success.record.publish"),
|
1026
|
-
defaultMessage: "Published document"
|
1027
|
-
})
|
1028
|
-
});
|
1029
|
-
return res.data;
|
1030
|
-
} catch (err) {
|
1031
|
-
toggleNotification({
|
1032
|
-
type: "danger",
|
1033
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1034
|
-
});
|
1035
|
-
throw err;
|
1036
|
-
}
|
1031
|
+
return {
|
1032
|
+
layout: panelledEditAttributes,
|
1033
|
+
components: componentEditAttributes,
|
1034
|
+
metadatas: editMetadatas,
|
1035
|
+
settings: {
|
1036
|
+
...data.contentType.settings,
|
1037
|
+
displayName: schema?.info.displayName
|
1037
1038
|
},
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
return { error: res.error };
|
1052
|
-
}
|
1053
|
-
toggleNotification({
|
1054
|
-
type: "success",
|
1055
|
-
message: formatMessage({
|
1056
|
-
id: getTranslation("success.record.publish"),
|
1057
|
-
defaultMessage: "Published document"
|
1058
|
-
})
|
1059
|
-
});
|
1060
|
-
return res.data;
|
1061
|
-
} catch (err) {
|
1062
|
-
toggleNotification({
|
1063
|
-
type: "danger",
|
1064
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1065
|
-
});
|
1066
|
-
throw err;
|
1039
|
+
options: {
|
1040
|
+
...schema?.options,
|
1041
|
+
...schema?.pluginOptions,
|
1042
|
+
...data.contentType.options
|
1043
|
+
}
|
1044
|
+
};
|
1045
|
+
};
|
1046
|
+
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
1047
|
+
return rows.map(
|
1048
|
+
(row) => row.map((field) => {
|
1049
|
+
const attribute = attributes[field.name];
|
1050
|
+
if (!attribute) {
|
1051
|
+
return null;
|
1067
1052
|
}
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1053
|
+
const { edit: metadata } = metadatas[field.name];
|
1054
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1055
|
+
return {
|
1056
|
+
attribute,
|
1057
|
+
disabled: !metadata.editable,
|
1058
|
+
hint: metadata.description,
|
1059
|
+
label: metadata.label ?? "",
|
1060
|
+
name: field.name,
|
1061
|
+
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
1062
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1063
|
+
schemas,
|
1064
|
+
components: components?.schemas ?? {}
|
1065
|
+
}),
|
1066
|
+
placeholder: metadata.placeholder ?? "",
|
1067
|
+
required: attribute.required ?? false,
|
1068
|
+
size: field.size,
|
1069
|
+
unique: "unique" in attribute ? attribute.unique : false,
|
1070
|
+
visible: metadata.visible ?? true,
|
1071
|
+
type: attribute.type
|
1072
|
+
};
|
1073
|
+
}).filter((field) => field !== null)
|
1076
1074
|
);
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1075
|
+
};
|
1076
|
+
const formatListLayout = (data, {
|
1077
|
+
schemas,
|
1078
|
+
schema,
|
1079
|
+
components
|
1080
|
+
}) => {
|
1081
|
+
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1082
|
+
(acc, [attribute, metadata]) => {
|
1083
|
+
return {
|
1084
|
+
...acc,
|
1085
|
+
[attribute]: metadata.list
|
1086
|
+
};
|
1087
|
+
},
|
1088
|
+
{}
|
1089
|
+
);
|
1090
|
+
const listAttributes = convertListLayoutToFieldLayouts(
|
1091
|
+
data.contentType.layouts.list,
|
1092
|
+
schema?.attributes,
|
1093
|
+
listMetadatas,
|
1094
|
+
{ configurations: data.components, schemas: components },
|
1095
|
+
schemas
|
1096
|
+
);
|
1097
|
+
return {
|
1098
|
+
layout: listAttributes,
|
1099
|
+
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
1100
|
+
metadatas: listMetadatas,
|
1101
|
+
options: {
|
1102
|
+
...schema?.options,
|
1103
|
+
...schema?.pluginOptions,
|
1104
|
+
...data.contentType.options
|
1105
|
+
}
|
1106
|
+
};
|
1107
|
+
};
|
1108
|
+
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
1109
|
+
return columns.map((name) => {
|
1110
|
+
const attribute = attributes[name];
|
1111
|
+
if (!attribute) {
|
1112
|
+
return null;
|
1113
|
+
}
|
1114
|
+
const metadata = metadatas[name];
|
1115
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1116
|
+
return {
|
1117
|
+
attribute,
|
1118
|
+
label: metadata.label ?? "",
|
1119
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1120
|
+
schemas,
|
1121
|
+
components: components?.schemas ?? {}
|
1122
|
+
}),
|
1123
|
+
name,
|
1124
|
+
searchable: metadata.searchable ?? true,
|
1125
|
+
sortable: metadata.sortable ?? true
|
1126
|
+
};
|
1127
|
+
}).filter((field) => field !== null);
|
1128
|
+
};
|
1129
|
+
const useDocument = (args, opts) => {
|
1130
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
1131
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1132
|
+
const {
|
1133
|
+
currentData: data,
|
1134
|
+
isLoading: isLoadingDocument,
|
1135
|
+
isFetching: isFetchingDocument,
|
1136
|
+
error
|
1137
|
+
} = useGetDocumentQuery(args, {
|
1138
|
+
...opts,
|
1139
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
1140
|
+
});
|
1141
|
+
const {
|
1142
|
+
components,
|
1143
|
+
schema,
|
1144
|
+
schemas,
|
1145
|
+
isLoading: isLoadingSchema
|
1146
|
+
} = useContentTypeSchema(args.model);
|
1147
|
+
React__namespace.useEffect(() => {
|
1148
|
+
if (error) {
|
1149
|
+
toggleNotification({
|
1150
|
+
type: "danger",
|
1151
|
+
message: formatAPIError(error)
|
1152
|
+
});
|
1153
|
+
}
|
1154
|
+
}, [toggleNotification, error, formatAPIError, args.collectionType]);
|
1155
|
+
const validationSchema = React__namespace.useMemo(() => {
|
1156
|
+
if (!schema) {
|
1157
|
+
return null;
|
1158
|
+
}
|
1159
|
+
return createYupSchema(schema.attributes, components);
|
1160
|
+
}, [schema, components]);
|
1161
|
+
const validate = React__namespace.useCallback(
|
1162
|
+
(document) => {
|
1163
|
+
if (!validationSchema) {
|
1164
|
+
throw new Error(
|
1165
|
+
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
1166
|
+
);
|
1167
|
+
}
|
1080
1168
|
try {
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
data,
|
1087
|
-
params
|
1088
|
-
});
|
1089
|
-
if ("error" in res) {
|
1090
|
-
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1091
|
-
trackUsage("didNotEditEntry", { error: res.error, ...trackerProperty });
|
1092
|
-
return { error: res.error };
|
1169
|
+
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
1170
|
+
return null;
|
1171
|
+
} catch (error2) {
|
1172
|
+
if (error2 instanceof yup.ValidationError) {
|
1173
|
+
return strapiAdmin.getYupValidationErrors(error2);
|
1093
1174
|
}
|
1094
|
-
|
1095
|
-
toggleNotification({
|
1096
|
-
type: "success",
|
1097
|
-
message: formatMessage({
|
1098
|
-
id: getTranslation("success.record.save"),
|
1099
|
-
defaultMessage: "Saved document"
|
1100
|
-
})
|
1101
|
-
});
|
1102
|
-
return res.data;
|
1103
|
-
} catch (err) {
|
1104
|
-
trackUsage("didNotEditEntry", { error: err, ...trackerProperty });
|
1105
|
-
toggleNotification({
|
1106
|
-
type: "danger",
|
1107
|
-
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1108
|
-
});
|
1109
|
-
throw err;
|
1175
|
+
throw error2;
|
1110
1176
|
}
|
1111
1177
|
},
|
1112
|
-
[
|
1178
|
+
[validationSchema]
|
1113
1179
|
);
|
1114
|
-
const
|
1115
|
-
const
|
1116
|
-
|
1180
|
+
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
1181
|
+
const hasError = !!error;
|
1182
|
+
return {
|
1183
|
+
components,
|
1184
|
+
document: data?.data,
|
1185
|
+
meta: data?.meta,
|
1186
|
+
isLoading,
|
1187
|
+
hasError,
|
1188
|
+
schema,
|
1189
|
+
schemas,
|
1190
|
+
validate
|
1191
|
+
};
|
1192
|
+
};
|
1193
|
+
const useDoc = () => {
|
1194
|
+
const { id, slug, collectionType, origin } = reactRouterDom.useParams();
|
1195
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
1196
|
+
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
1197
|
+
if (!collectionType) {
|
1198
|
+
throw new Error("Could not find collectionType in url params");
|
1199
|
+
}
|
1200
|
+
if (!slug) {
|
1201
|
+
throw new Error("Could not find model in url params");
|
1202
|
+
}
|
1203
|
+
const document = useDocument(
|
1204
|
+
{ documentId: origin || id, model: slug, collectionType, params },
|
1205
|
+
{
|
1206
|
+
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
1207
|
+
}
|
1208
|
+
);
|
1209
|
+
const returnId = origin || id === "create" ? void 0 : id;
|
1210
|
+
return {
|
1211
|
+
collectionType,
|
1212
|
+
model: slug,
|
1213
|
+
id: returnId,
|
1214
|
+
...document
|
1215
|
+
};
|
1216
|
+
};
|
1217
|
+
const useContentManagerContext = () => {
|
1218
|
+
const {
|
1219
|
+
collectionType,
|
1220
|
+
model,
|
1221
|
+
id,
|
1222
|
+
components,
|
1223
|
+
isLoading: isLoadingDoc,
|
1224
|
+
schema,
|
1225
|
+
schemas
|
1226
|
+
} = useDoc();
|
1227
|
+
const layout = useDocumentLayout(model);
|
1228
|
+
const form = strapiAdmin.useForm("useContentManagerContext", (state) => state);
|
1229
|
+
const isSingleType = collectionType === SINGLE_TYPES;
|
1230
|
+
const slug = model;
|
1231
|
+
const isCreatingEntry = id === "create";
|
1232
|
+
useContentTypeSchema();
|
1233
|
+
const isLoading = isLoadingDoc || layout.isLoading;
|
1234
|
+
const error = layout.error;
|
1235
|
+
return {
|
1236
|
+
error,
|
1237
|
+
isLoading,
|
1238
|
+
// Base metadata
|
1239
|
+
model,
|
1240
|
+
collectionType,
|
1241
|
+
id,
|
1242
|
+
slug,
|
1243
|
+
isCreatingEntry,
|
1244
|
+
isSingleType,
|
1245
|
+
hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
|
1246
|
+
// All schema infos
|
1247
|
+
components,
|
1248
|
+
contentType: schema,
|
1249
|
+
contentTypes: schemas,
|
1250
|
+
// Form state
|
1251
|
+
form,
|
1252
|
+
// layout infos
|
1253
|
+
layout
|
1254
|
+
};
|
1255
|
+
};
|
1256
|
+
const prefixPluginTranslations = (trad, pluginId) => {
|
1257
|
+
return Object.keys(trad).reduce((acc, current) => {
|
1258
|
+
acc[`${pluginId}.${current}`] = trad[current];
|
1259
|
+
return acc;
|
1260
|
+
}, {});
|
1261
|
+
};
|
1262
|
+
const getTranslation = (id) => `content-manager.${id}`;
|
1263
|
+
const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
1264
|
+
id: "notification.error",
|
1265
|
+
defaultMessage: "An error occurred, please try again"
|
1266
|
+
};
|
1267
|
+
const useDocumentActions = () => {
|
1268
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
1269
|
+
const { formatMessage } = reactIntl.useIntl();
|
1270
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
1271
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1272
|
+
const navigate = reactRouterDom.useNavigate();
|
1273
|
+
const setCurrentStep = strapiAdmin.useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
|
1274
|
+
const [deleteDocument] = useDeleteDocumentMutation();
|
1275
|
+
const _delete = React__namespace.useCallback(
|
1276
|
+
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
1117
1277
|
try {
|
1118
|
-
trackUsage("
|
1119
|
-
const res = await
|
1278
|
+
trackUsage("willDeleteEntry", trackerProperty);
|
1279
|
+
const res = await deleteDocument({
|
1120
1280
|
collectionType,
|
1121
1281
|
model,
|
1122
1282
|
documentId,
|
1123
|
-
params
|
1124
|
-
data: {
|
1125
|
-
discardDraft
|
1126
|
-
}
|
1283
|
+
params
|
1127
1284
|
});
|
1128
1285
|
if ("error" in res) {
|
1129
|
-
toggleNotification({
|
1286
|
+
toggleNotification({
|
1287
|
+
type: "danger",
|
1288
|
+
message: formatAPIError(res.error)
|
1289
|
+
});
|
1130
1290
|
return { error: res.error };
|
1131
1291
|
}
|
1132
|
-
trackUsage("didUnpublishEntry");
|
1133
1292
|
toggleNotification({
|
1134
1293
|
type: "success",
|
1135
1294
|
message: formatMessage({
|
1136
|
-
id: getTranslation("success.record.
|
1137
|
-
defaultMessage: "
|
1295
|
+
id: getTranslation("success.record.delete"),
|
1296
|
+
defaultMessage: "Deleted document"
|
1138
1297
|
})
|
1139
1298
|
});
|
1299
|
+
trackUsage("didDeleteEntry", trackerProperty);
|
1140
1300
|
return res.data;
|
1141
1301
|
} catch (err) {
|
1142
1302
|
toggleNotification({
|
1143
1303
|
type: "danger",
|
1144
1304
|
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1145
1305
|
});
|
1306
|
+
trackUsage("didNotDeleteEntry", { error: err, ...trackerProperty });
|
1146
1307
|
throw err;
|
1147
1308
|
}
|
1148
1309
|
},
|
1149
|
-
[trackUsage,
|
1310
|
+
[trackUsage, deleteDocument, toggleNotification, formatMessage, formatAPIError]
|
1150
1311
|
);
|
1151
|
-
const [
|
1152
|
-
const
|
1312
|
+
const [deleteManyDocuments] = useDeleteManyDocumentsMutation();
|
1313
|
+
const deleteMany = React__namespace.useCallback(
|
1153
1314
|
async ({ model, documentIds, params }) => {
|
1154
1315
|
try {
|
1155
|
-
trackUsage("
|
1156
|
-
const res = await
|
1316
|
+
trackUsage("willBulkDeleteEntries");
|
1317
|
+
const res = await deleteManyDocuments({
|
1157
1318
|
model,
|
1158
1319
|
documentIds,
|
1159
1320
|
params
|
1160
1321
|
});
|
1161
1322
|
if ("error" in res) {
|
1162
|
-
toggleNotification({
|
1323
|
+
toggleNotification({
|
1324
|
+
type: "danger",
|
1325
|
+
message: formatAPIError(res.error)
|
1326
|
+
});
|
1163
1327
|
return { error: res.error };
|
1164
1328
|
}
|
1165
|
-
trackUsage("didBulkUnpublishEntries");
|
1166
1329
|
toggleNotification({
|
1167
1330
|
type: "success",
|
1168
1331
|
title: formatMessage({
|
1169
|
-
id: getTranslation("success.records.
|
1170
|
-
defaultMessage: "Successfully
|
1332
|
+
id: getTranslation("success.records.delete"),
|
1333
|
+
defaultMessage: "Successfully deleted."
|
1171
1334
|
}),
|
1172
1335
|
message: ""
|
1173
1336
|
});
|
1337
|
+
trackUsage("didBulkDeleteEntries");
|
1174
1338
|
return res.data;
|
1175
1339
|
} catch (err) {
|
1176
1340
|
toggleNotification({
|
1177
1341
|
type: "danger",
|
1178
1342
|
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1179
1343
|
});
|
1180
|
-
trackUsage("
|
1344
|
+
trackUsage("didNotBulkDeleteEntries");
|
1181
1345
|
throw err;
|
1182
1346
|
}
|
1183
1347
|
},
|
1184
|
-
[trackUsage,
|
1348
|
+
[trackUsage, deleteManyDocuments, toggleNotification, formatMessage, formatAPIError]
|
1185
1349
|
);
|
1186
|
-
const [
|
1187
|
-
const
|
1188
|
-
async ({ model, params }
|
1350
|
+
const [discardDocument] = useDiscardDocumentMutation();
|
1351
|
+
const discard = React__namespace.useCallback(
|
1352
|
+
async ({ collectionType, model, documentId, params }) => {
|
1189
1353
|
try {
|
1190
|
-
const res = await
|
1354
|
+
const res = await discardDocument({
|
1355
|
+
collectionType,
|
1191
1356
|
model,
|
1192
|
-
|
1357
|
+
documentId,
|
1193
1358
|
params
|
1194
1359
|
});
|
1195
1360
|
if ("error" in res) {
|
1196
|
-
toggleNotification({
|
1197
|
-
|
1361
|
+
toggleNotification({
|
1362
|
+
type: "danger",
|
1363
|
+
message: formatAPIError(res.error)
|
1364
|
+
});
|
1198
1365
|
return { error: res.error };
|
1199
1366
|
}
|
1200
|
-
trackUsage("didCreateEntry", trackerProperty);
|
1201
1367
|
toggleNotification({
|
1202
1368
|
type: "success",
|
1203
1369
|
message: formatMessage({
|
1204
|
-
id:
|
1370
|
+
id: "content-manager.success.record.discard",
|
1371
|
+
defaultMessage: "Changes discarded"
|
1372
|
+
})
|
1373
|
+
});
|
1374
|
+
return res.data;
|
1375
|
+
} catch (err) {
|
1376
|
+
toggleNotification({
|
1377
|
+
type: "danger",
|
1378
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1379
|
+
});
|
1380
|
+
throw err;
|
1381
|
+
}
|
1382
|
+
},
|
1383
|
+
[discardDocument, formatAPIError, formatMessage, toggleNotification]
|
1384
|
+
);
|
1385
|
+
const [publishDocument] = usePublishDocumentMutation();
|
1386
|
+
const publish = React__namespace.useCallback(
|
1387
|
+
async ({ collectionType, model, documentId, params }, data) => {
|
1388
|
+
try {
|
1389
|
+
trackUsage("willPublishEntry");
|
1390
|
+
const res = await publishDocument({
|
1391
|
+
collectionType,
|
1392
|
+
model,
|
1393
|
+
documentId,
|
1394
|
+
data,
|
1395
|
+
params
|
1396
|
+
});
|
1397
|
+
if ("error" in res) {
|
1398
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1399
|
+
return { error: res.error };
|
1400
|
+
}
|
1401
|
+
trackUsage("didPublishEntry");
|
1402
|
+
toggleNotification({
|
1403
|
+
type: "success",
|
1404
|
+
message: formatMessage({
|
1405
|
+
id: getTranslation("success.record.publish"),
|
1406
|
+
defaultMessage: "Published document"
|
1407
|
+
})
|
1408
|
+
});
|
1409
|
+
return res.data;
|
1410
|
+
} catch (err) {
|
1411
|
+
toggleNotification({
|
1412
|
+
type: "danger",
|
1413
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1414
|
+
});
|
1415
|
+
throw err;
|
1416
|
+
}
|
1417
|
+
},
|
1418
|
+
[trackUsage, publishDocument, toggleNotification, formatMessage, formatAPIError]
|
1419
|
+
);
|
1420
|
+
const [publishManyDocuments] = usePublishManyDocumentsMutation();
|
1421
|
+
const publishMany = React__namespace.useCallback(
|
1422
|
+
async ({ model, documentIds, params }) => {
|
1423
|
+
try {
|
1424
|
+
const res = await publishManyDocuments({
|
1425
|
+
model,
|
1426
|
+
documentIds,
|
1427
|
+
params
|
1428
|
+
});
|
1429
|
+
if ("error" in res) {
|
1430
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1431
|
+
return { error: res.error };
|
1432
|
+
}
|
1433
|
+
toggleNotification({
|
1434
|
+
type: "success",
|
1435
|
+
message: formatMessage({
|
1436
|
+
id: getTranslation("success.record.publish"),
|
1437
|
+
defaultMessage: "Published document"
|
1438
|
+
})
|
1439
|
+
});
|
1440
|
+
return res.data;
|
1441
|
+
} catch (err) {
|
1442
|
+
toggleNotification({
|
1443
|
+
type: "danger",
|
1444
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1445
|
+
});
|
1446
|
+
throw err;
|
1447
|
+
}
|
1448
|
+
},
|
1449
|
+
[
|
1450
|
+
// trackUsage,
|
1451
|
+
publishManyDocuments,
|
1452
|
+
toggleNotification,
|
1453
|
+
formatMessage,
|
1454
|
+
formatAPIError
|
1455
|
+
]
|
1456
|
+
);
|
1457
|
+
const [updateDocument] = useUpdateDocumentMutation();
|
1458
|
+
const update = React__namespace.useCallback(
|
1459
|
+
async ({ collectionType, model, documentId, params }, data, trackerProperty) => {
|
1460
|
+
try {
|
1461
|
+
trackUsage("willEditEntry", trackerProperty);
|
1462
|
+
const res = await updateDocument({
|
1463
|
+
collectionType,
|
1464
|
+
model,
|
1465
|
+
documentId,
|
1466
|
+
data,
|
1467
|
+
params
|
1468
|
+
});
|
1469
|
+
if ("error" in res) {
|
1470
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1471
|
+
trackUsage("didNotEditEntry", { error: res.error, ...trackerProperty });
|
1472
|
+
return { error: res.error };
|
1473
|
+
}
|
1474
|
+
trackUsage("didEditEntry", trackerProperty);
|
1475
|
+
toggleNotification({
|
1476
|
+
type: "success",
|
1477
|
+
message: formatMessage({
|
1478
|
+
id: getTranslation("success.record.save"),
|
1479
|
+
defaultMessage: "Saved document"
|
1480
|
+
})
|
1481
|
+
});
|
1482
|
+
return res.data;
|
1483
|
+
} catch (err) {
|
1484
|
+
trackUsage("didNotEditEntry", { error: err, ...trackerProperty });
|
1485
|
+
toggleNotification({
|
1486
|
+
type: "danger",
|
1487
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1488
|
+
});
|
1489
|
+
throw err;
|
1490
|
+
}
|
1491
|
+
},
|
1492
|
+
[trackUsage, updateDocument, toggleNotification, formatMessage, formatAPIError]
|
1493
|
+
);
|
1494
|
+
const [unpublishDocument] = useUnpublishDocumentMutation();
|
1495
|
+
const unpublish = React__namespace.useCallback(
|
1496
|
+
async ({ collectionType, model, documentId, params }, discardDraft = false) => {
|
1497
|
+
try {
|
1498
|
+
trackUsage("willUnpublishEntry");
|
1499
|
+
const res = await unpublishDocument({
|
1500
|
+
collectionType,
|
1501
|
+
model,
|
1502
|
+
documentId,
|
1503
|
+
params,
|
1504
|
+
data: {
|
1505
|
+
discardDraft
|
1506
|
+
}
|
1507
|
+
});
|
1508
|
+
if ("error" in res) {
|
1509
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1510
|
+
return { error: res.error };
|
1511
|
+
}
|
1512
|
+
trackUsage("didUnpublishEntry");
|
1513
|
+
toggleNotification({
|
1514
|
+
type: "success",
|
1515
|
+
message: formatMessage({
|
1516
|
+
id: getTranslation("success.record.unpublish"),
|
1517
|
+
defaultMessage: "Unpublished document"
|
1518
|
+
})
|
1519
|
+
});
|
1520
|
+
return res.data;
|
1521
|
+
} catch (err) {
|
1522
|
+
toggleNotification({
|
1523
|
+
type: "danger",
|
1524
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1525
|
+
});
|
1526
|
+
throw err;
|
1527
|
+
}
|
1528
|
+
},
|
1529
|
+
[trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
|
1530
|
+
);
|
1531
|
+
const [unpublishManyDocuments] = useUnpublishManyDocumentsMutation();
|
1532
|
+
const unpublishMany = React__namespace.useCallback(
|
1533
|
+
async ({ model, documentIds, params }) => {
|
1534
|
+
try {
|
1535
|
+
trackUsage("willBulkUnpublishEntries");
|
1536
|
+
const res = await unpublishManyDocuments({
|
1537
|
+
model,
|
1538
|
+
documentIds,
|
1539
|
+
params
|
1540
|
+
});
|
1541
|
+
if ("error" in res) {
|
1542
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1543
|
+
return { error: res.error };
|
1544
|
+
}
|
1545
|
+
trackUsage("didBulkUnpublishEntries");
|
1546
|
+
toggleNotification({
|
1547
|
+
type: "success",
|
1548
|
+
title: formatMessage({
|
1549
|
+
id: getTranslation("success.records.unpublish"),
|
1550
|
+
defaultMessage: "Successfully unpublished."
|
1551
|
+
}),
|
1552
|
+
message: ""
|
1553
|
+
});
|
1554
|
+
return res.data;
|
1555
|
+
} catch (err) {
|
1556
|
+
toggleNotification({
|
1557
|
+
type: "danger",
|
1558
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1559
|
+
});
|
1560
|
+
trackUsage("didNotBulkUnpublishEntries");
|
1561
|
+
throw err;
|
1562
|
+
}
|
1563
|
+
},
|
1564
|
+
[trackUsage, unpublishManyDocuments, toggleNotification, formatMessage, formatAPIError]
|
1565
|
+
);
|
1566
|
+
const [createDocument] = useCreateDocumentMutation();
|
1567
|
+
const create = React__namespace.useCallback(
|
1568
|
+
async ({ model, params }, data, trackerProperty) => {
|
1569
|
+
try {
|
1570
|
+
const res = await createDocument({
|
1571
|
+
model,
|
1572
|
+
data,
|
1573
|
+
params
|
1574
|
+
});
|
1575
|
+
if ("error" in res) {
|
1576
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1577
|
+
trackUsage("didNotCreateEntry", { error: res.error, ...trackerProperty });
|
1578
|
+
return { error: res.error };
|
1579
|
+
}
|
1580
|
+
trackUsage("didCreateEntry", trackerProperty);
|
1581
|
+
toggleNotification({
|
1582
|
+
type: "success",
|
1583
|
+
message: formatMessage({
|
1584
|
+
id: getTranslation("success.record.save"),
|
1205
1585
|
defaultMessage: "Saved document"
|
1206
1586
|
})
|
1207
1587
|
});
|
1588
|
+
setCurrentStep("contentManager.success");
|
1208
1589
|
return res.data;
|
1209
1590
|
} catch (err) {
|
1210
1591
|
toggleNotification({
|
@@ -1244,7 +1625,7 @@ const useDocumentActions = () => {
|
|
1244
1625
|
throw err;
|
1245
1626
|
}
|
1246
1627
|
},
|
1247
|
-
[autoCloneDocument,
|
1628
|
+
[autoCloneDocument, formatMessage, toggleNotification]
|
1248
1629
|
);
|
1249
1630
|
const [cloneDocument] = useCloneDocumentMutation();
|
1250
1631
|
const clone = React__namespace.useCallback(
|
@@ -1270,6 +1651,7 @@ const useDocumentActions = () => {
|
|
1270
1651
|
defaultMessage: "Cloned document"
|
1271
1652
|
})
|
1272
1653
|
});
|
1654
|
+
navigate(`../../${res.data.data.documentId}`, { relative: "path" });
|
1273
1655
|
return res.data;
|
1274
1656
|
} catch (err) {
|
1275
1657
|
toggleNotification({
|
@@ -1280,7 +1662,7 @@ const useDocumentActions = () => {
|
|
1280
1662
|
throw err;
|
1281
1663
|
}
|
1282
1664
|
},
|
1283
|
-
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
|
1665
|
+
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
|
1284
1666
|
);
|
1285
1667
|
const [getDoc] = useLazyGetDocumentQuery();
|
1286
1668
|
const getDocument = React__namespace.useCallback(
|
@@ -1305,10 +1687,10 @@ const useDocumentActions = () => {
|
|
1305
1687
|
update
|
1306
1688
|
};
|
1307
1689
|
};
|
1308
|
-
const ProtectedHistoryPage =
|
1309
|
-
() => Promise.resolve().then(() => require("./History-
|
1690
|
+
const ProtectedHistoryPage = React__namespace.lazy(
|
1691
|
+
() => Promise.resolve().then(() => require("./History-DYl2A8Z_.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1310
1692
|
);
|
1311
|
-
const routes$
|
1693
|
+
const routes$2 = [
|
1312
1694
|
{
|
1313
1695
|
path: ":collectionType/:slug/:id/history",
|
1314
1696
|
Component: ProtectedHistoryPage
|
@@ -1318,32 +1700,45 @@ const routes$1 = [
|
|
1318
1700
|
Component: ProtectedHistoryPage
|
1319
1701
|
}
|
1320
1702
|
];
|
1703
|
+
const ProtectedPreviewPage = React__namespace.lazy(
|
1704
|
+
() => Promise.resolve().then(() => require("./Preview-DfNx8Ke-.js")).then((mod) => ({ default: mod.ProtectedPreviewPage }))
|
1705
|
+
);
|
1706
|
+
const routes$1 = [
|
1707
|
+
{
|
1708
|
+
path: ":collectionType/:slug/:id/preview",
|
1709
|
+
Component: ProtectedPreviewPage
|
1710
|
+
},
|
1711
|
+
{
|
1712
|
+
path: ":collectionType/:slug/preview",
|
1713
|
+
Component: ProtectedPreviewPage
|
1714
|
+
}
|
1715
|
+
];
|
1321
1716
|
const ProtectedEditViewPage = React.lazy(
|
1322
|
-
() => Promise.resolve().then(() => require("./EditViewPage-
|
1717
|
+
() => Promise.resolve().then(() => require("./EditViewPage-wujOq90c.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1323
1718
|
);
|
1324
1719
|
const ProtectedListViewPage = React.lazy(
|
1325
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1720
|
+
() => Promise.resolve().then(() => require("./ListViewPage-BtSi8C1l.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1326
1721
|
);
|
1327
1722
|
const ProtectedListConfiguration = React.lazy(
|
1328
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1723
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-BXnu_OoY.js")).then((mod) => ({
|
1329
1724
|
default: mod.ProtectedListConfiguration
|
1330
1725
|
}))
|
1331
1726
|
);
|
1332
1727
|
const ProtectedEditConfigurationPage = React.lazy(
|
1333
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1728
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-z39Wv3E6.js")).then((mod) => ({
|
1334
1729
|
default: mod.ProtectedEditConfigurationPage
|
1335
1730
|
}))
|
1336
1731
|
);
|
1337
1732
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1338
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1733
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-BTR_hQow.js")).then((mod) => ({
|
1339
1734
|
default: mod.ProtectedComponentConfigurationPage
|
1340
1735
|
}))
|
1341
1736
|
);
|
1342
1737
|
const NoPermissions = React.lazy(
|
1343
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1738
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-DzgWz0M-.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1344
1739
|
);
|
1345
1740
|
const NoContentType = React.lazy(
|
1346
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1741
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-CitJeOq4.js")).then((mod) => ({ default: mod.NoContentType }))
|
1347
1742
|
);
|
1348
1743
|
const CollectionTypePages = () => {
|
1349
1744
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1355,7 +1750,7 @@ const CollectionTypePages = () => {
|
|
1355
1750
|
const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
|
1356
1751
|
const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
|
1357
1752
|
const LIST_RELATIVE_PATH = ":collectionType/:slug";
|
1358
|
-
const LIST_PATH = `/content-manager
|
1753
|
+
const LIST_PATH = `/content-manager/collection-types/:slug`;
|
1359
1754
|
const routes = [
|
1360
1755
|
{
|
1361
1756
|
path: LIST_RELATIVE_PATH,
|
@@ -1389,6 +1784,7 @@ const routes = [
|
|
1389
1784
|
path: "no-content-types",
|
1390
1785
|
Component: NoContentType
|
1391
1786
|
},
|
1787
|
+
...routes$2,
|
1392
1788
|
...routes$1
|
1393
1789
|
];
|
1394
1790
|
const DocumentActions = ({ actions: actions2 }) => {
|
@@ -1463,6 +1859,8 @@ const DocumentActionButton = (action) => {
|
|
1463
1859
|
onClick: handleClick(action),
|
1464
1860
|
justifyContent: "center",
|
1465
1861
|
variant: action.variant || "default",
|
1862
|
+
paddingTop: "7px",
|
1863
|
+
paddingBottom: "7px",
|
1466
1864
|
children: action.label
|
1467
1865
|
}
|
1468
1866
|
),
|
@@ -1485,6 +1883,11 @@ const DocumentActionButton = (action) => {
|
|
1485
1883
|
) : null
|
1486
1884
|
] });
|
1487
1885
|
};
|
1886
|
+
const MenuItem = styledComponents.styled(designSystem.Menu.Item)`
|
1887
|
+
&:hover {
|
1888
|
+
background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
|
1889
|
+
}
|
1890
|
+
`;
|
1488
1891
|
const DocumentActionsMenu = ({
|
1489
1892
|
actions: actions2,
|
1490
1893
|
children,
|
@@ -1540,44 +1943,35 @@ const DocumentActionsMenu = ({
|
|
1540
1943
|
]
|
1541
1944
|
}
|
1542
1945
|
),
|
1543
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, {
|
1946
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
|
1544
1947
|
actions2.map((action) => {
|
1545
1948
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
1546
|
-
|
1949
|
+
MenuItem,
|
1547
1950
|
{
|
1548
1951
|
disabled: action.disabled,
|
1549
1952
|
onSelect: handleClick(action),
|
1550
1953
|
display: "block",
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
height: 5,
|
1573
|
-
paddingLeft: 2,
|
1574
|
-
paddingRight: 2,
|
1575
|
-
hasRadius: true,
|
1576
|
-
color: "alternative600",
|
1577
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", fontWeight: "bold", lineHeight: 1, children: formatMessage({ id: "global.new", defaultMessage: "New" }) })
|
1578
|
-
}
|
1579
|
-
)
|
1580
|
-
] })
|
1954
|
+
isVariantDanger: action.variant === "danger",
|
1955
|
+
isDisabled: action.disabled,
|
1956
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
1957
|
+
designSystem.Flex,
|
1958
|
+
{
|
1959
|
+
color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
|
1960
|
+
gap: 2,
|
1961
|
+
tag: "span",
|
1962
|
+
children: [
|
1963
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
1964
|
+
designSystem.Flex,
|
1965
|
+
{
|
1966
|
+
tag: "span",
|
1967
|
+
color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
|
1968
|
+
children: action.icon
|
1969
|
+
}
|
1970
|
+
),
|
1971
|
+
action.label
|
1972
|
+
]
|
1973
|
+
}
|
1974
|
+
) })
|
1581
1975
|
},
|
1582
1976
|
action.id
|
1583
1977
|
);
|
@@ -1619,6 +2013,18 @@ const convertActionVariantToColor = (variant = "secondary") => {
|
|
1619
2013
|
return "primary600";
|
1620
2014
|
}
|
1621
2015
|
};
|
2016
|
+
const convertActionVariantToIconColor = (variant = "secondary") => {
|
2017
|
+
switch (variant) {
|
2018
|
+
case "danger":
|
2019
|
+
return "danger600";
|
2020
|
+
case "secondary":
|
2021
|
+
return "neutral500";
|
2022
|
+
case "success":
|
2023
|
+
return "success600";
|
2024
|
+
default:
|
2025
|
+
return "primary600";
|
2026
|
+
}
|
2027
|
+
};
|
1622
2028
|
const DocumentActionConfirmDialog = ({
|
1623
2029
|
onClose,
|
1624
2030
|
onCancel,
|
@@ -1645,11 +2051,11 @@ const DocumentActionConfirmDialog = ({
|
|
1645
2051
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
1646
2052
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
|
1647
2053
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
1648
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
|
2054
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
|
1649
2055
|
id: "app.components.Button.cancel",
|
1650
2056
|
defaultMessage: "Cancel"
|
1651
2057
|
}) }) }),
|
1652
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
|
2058
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
|
1653
2059
|
id: "app.components.Button.confirm",
|
1654
2060
|
defaultMessage: "Confirm"
|
1655
2061
|
}) })
|
@@ -1676,6 +2082,18 @@ const DocumentActionModal = ({
|
|
1676
2082
|
typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
|
1677
2083
|
] }) });
|
1678
2084
|
};
|
2085
|
+
const transformData = (data) => {
|
2086
|
+
if (Array.isArray(data)) {
|
2087
|
+
return data.map(transformData);
|
2088
|
+
}
|
2089
|
+
if (typeof data === "object" && data !== null) {
|
2090
|
+
if ("apiData" in data) {
|
2091
|
+
return data.apiData;
|
2092
|
+
}
|
2093
|
+
return mapValues__default.default(transformData)(data);
|
2094
|
+
}
|
2095
|
+
return data;
|
2096
|
+
};
|
1679
2097
|
const PublishAction$1 = ({
|
1680
2098
|
activeTab,
|
1681
2099
|
documentId,
|
@@ -1688,12 +2106,11 @@ const PublishAction$1 = ({
|
|
1688
2106
|
const navigate = reactRouterDom.useNavigate();
|
1689
2107
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1690
2108
|
const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
|
2109
|
+
const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
|
1691
2110
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2111
|
+
const { id } = reactRouterDom.useParams();
|
1692
2112
|
const { formatMessage } = reactIntl.useIntl();
|
1693
|
-
const { canPublish
|
1694
|
-
"PublishAction",
|
1695
|
-
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1696
|
-
);
|
2113
|
+
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
1697
2114
|
const { publish } = useDocumentActions();
|
1698
2115
|
const [
|
1699
2116
|
countDraftRelations,
|
@@ -1745,32 +2162,35 @@ const PublishAction$1 = ({
|
|
1745
2162
|
}
|
1746
2163
|
}, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
|
1747
2164
|
React__namespace.useEffect(() => {
|
1748
|
-
if (documentId) {
|
1749
|
-
|
1750
|
-
const { data, error } = await countDraftRelations({
|
1751
|
-
collectionType,
|
1752
|
-
model,
|
1753
|
-
documentId,
|
1754
|
-
params
|
1755
|
-
});
|
1756
|
-
if (error) {
|
1757
|
-
throw error;
|
1758
|
-
}
|
1759
|
-
if (data) {
|
1760
|
-
setServerCountOfDraftRelations(data.data);
|
1761
|
-
}
|
1762
|
-
};
|
1763
|
-
fetchDraftRelationsCount();
|
2165
|
+
if (!document || !document.documentId || isListView) {
|
2166
|
+
return;
|
1764
2167
|
}
|
1765
|
-
|
1766
|
-
|
2168
|
+
const fetchDraftRelationsCount = async () => {
|
2169
|
+
const { data, error } = await countDraftRelations({
|
2170
|
+
collectionType,
|
2171
|
+
model,
|
2172
|
+
documentId,
|
2173
|
+
params
|
2174
|
+
});
|
2175
|
+
if (error) {
|
2176
|
+
throw error;
|
2177
|
+
}
|
2178
|
+
if (data) {
|
2179
|
+
setServerCountOfDraftRelations(data.data);
|
2180
|
+
}
|
2181
|
+
};
|
2182
|
+
fetchDraftRelationsCount();
|
2183
|
+
}, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
|
2184
|
+
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1767
2185
|
if (!schema?.options?.draftAndPublish) {
|
1768
2186
|
return null;
|
1769
2187
|
}
|
1770
2188
|
const performPublish = async () => {
|
1771
2189
|
setSubmitting(true);
|
1772
2190
|
try {
|
1773
|
-
const { errors } = await validate(
|
2191
|
+
const { errors } = await validate(true, {
|
2192
|
+
status: "published"
|
2193
|
+
});
|
1774
2194
|
if (errors) {
|
1775
2195
|
toggleNotification({
|
1776
2196
|
type: "danger",
|
@@ -1788,13 +2208,15 @@ const PublishAction$1 = ({
|
|
1788
2208
|
documentId,
|
1789
2209
|
params
|
1790
2210
|
},
|
1791
|
-
formValues
|
2211
|
+
transformData(formValues)
|
1792
2212
|
);
|
1793
2213
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
2214
|
+
if (id === "create") {
|
2215
|
+
navigate({
|
2216
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
2217
|
+
search: rawQuery
|
2218
|
+
});
|
2219
|
+
}
|
1798
2220
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1799
2221
|
setErrors(formatValidationErrors(res.error));
|
1800
2222
|
}
|
@@ -1803,7 +2225,8 @@ const PublishAction$1 = ({
|
|
1803
2225
|
}
|
1804
2226
|
};
|
1805
2227
|
const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
|
1806
|
-
const
|
2228
|
+
const enableDraftRelationsCount = false;
|
2229
|
+
const hasDraftRelations = enableDraftRelationsCount;
|
1807
2230
|
return {
|
1808
2231
|
/**
|
1809
2232
|
* Disabled when:
|
@@ -1820,9 +2243,6 @@ const PublishAction$1 = ({
|
|
1820
2243
|
defaultMessage: "Publish"
|
1821
2244
|
}),
|
1822
2245
|
onClick: async () => {
|
1823
|
-
if (hasDraftRelations) {
|
1824
|
-
return;
|
1825
|
-
}
|
1826
2246
|
await performPublish();
|
1827
2247
|
},
|
1828
2248
|
dialog: hasDraftRelations ? {
|
@@ -1849,6 +2269,7 @@ const PublishAction$1 = ({
|
|
1849
2269
|
};
|
1850
2270
|
};
|
1851
2271
|
PublishAction$1.type = "publish";
|
2272
|
+
PublishAction$1.position = "panel";
|
1852
2273
|
const UpdateAction = ({
|
1853
2274
|
activeTab,
|
1854
2275
|
documentId,
|
@@ -1861,10 +2282,6 @@ const UpdateAction = ({
|
|
1861
2282
|
const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
|
1862
2283
|
const isCloning = cloneMatch !== null;
|
1863
2284
|
const { formatMessage } = reactIntl.useIntl();
|
1864
|
-
useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
|
1865
|
-
canCreate: canCreate2,
|
1866
|
-
canUpdate: canUpdate2
|
1867
|
-
}));
|
1868
2285
|
const { create, update, clone } = useDocumentActions();
|
1869
2286
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1870
2287
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
@@ -1875,6 +2292,117 @@ const UpdateAction = ({
|
|
1875
2292
|
const validate = strapiAdmin.useForm("UpdateAction", (state) => state.validate);
|
1876
2293
|
const setErrors = strapiAdmin.useForm("UpdateAction", (state) => state.setErrors);
|
1877
2294
|
const resetForm = strapiAdmin.useForm("PublishAction", ({ resetForm: resetForm2 }) => resetForm2);
|
2295
|
+
const handleUpdate = React__namespace.useCallback(async () => {
|
2296
|
+
setSubmitting(true);
|
2297
|
+
try {
|
2298
|
+
if (!modified) {
|
2299
|
+
return;
|
2300
|
+
}
|
2301
|
+
const { errors } = await validate(true, {
|
2302
|
+
status: "draft"
|
2303
|
+
});
|
2304
|
+
if (errors) {
|
2305
|
+
toggleNotification({
|
2306
|
+
type: "danger",
|
2307
|
+
message: formatMessage({
|
2308
|
+
id: "content-manager.validation.error",
|
2309
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
2310
|
+
})
|
2311
|
+
});
|
2312
|
+
return;
|
2313
|
+
}
|
2314
|
+
if (isCloning) {
|
2315
|
+
const res = await clone(
|
2316
|
+
{
|
2317
|
+
model,
|
2318
|
+
documentId: cloneMatch.params.origin,
|
2319
|
+
params
|
2320
|
+
},
|
2321
|
+
transformData(document)
|
2322
|
+
);
|
2323
|
+
if ("data" in res) {
|
2324
|
+
navigate(
|
2325
|
+
{
|
2326
|
+
pathname: `../${res.data.documentId}`,
|
2327
|
+
search: rawQuery
|
2328
|
+
},
|
2329
|
+
{ relative: "path" }
|
2330
|
+
);
|
2331
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2332
|
+
setErrors(formatValidationErrors(res.error));
|
2333
|
+
}
|
2334
|
+
} else if (documentId || collectionType === SINGLE_TYPES) {
|
2335
|
+
const res = await update(
|
2336
|
+
{
|
2337
|
+
collectionType,
|
2338
|
+
model,
|
2339
|
+
documentId,
|
2340
|
+
params
|
2341
|
+
},
|
2342
|
+
transformData(document)
|
2343
|
+
);
|
2344
|
+
if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2345
|
+
setErrors(formatValidationErrors(res.error));
|
2346
|
+
} else {
|
2347
|
+
resetForm();
|
2348
|
+
}
|
2349
|
+
} else {
|
2350
|
+
const res = await create(
|
2351
|
+
{
|
2352
|
+
model,
|
2353
|
+
params
|
2354
|
+
},
|
2355
|
+
transformData(document)
|
2356
|
+
);
|
2357
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
2358
|
+
navigate(
|
2359
|
+
{
|
2360
|
+
pathname: `../${res.data.documentId}`,
|
2361
|
+
search: rawQuery
|
2362
|
+
},
|
2363
|
+
{ replace: true, relative: "path" }
|
2364
|
+
);
|
2365
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2366
|
+
setErrors(formatValidationErrors(res.error));
|
2367
|
+
}
|
2368
|
+
}
|
2369
|
+
} finally {
|
2370
|
+
setSubmitting(false);
|
2371
|
+
}
|
2372
|
+
}, [
|
2373
|
+
clone,
|
2374
|
+
cloneMatch?.params.origin,
|
2375
|
+
collectionType,
|
2376
|
+
create,
|
2377
|
+
document,
|
2378
|
+
documentId,
|
2379
|
+
formatMessage,
|
2380
|
+
formatValidationErrors,
|
2381
|
+
isCloning,
|
2382
|
+
model,
|
2383
|
+
modified,
|
2384
|
+
navigate,
|
2385
|
+
params,
|
2386
|
+
rawQuery,
|
2387
|
+
resetForm,
|
2388
|
+
setErrors,
|
2389
|
+
setSubmitting,
|
2390
|
+
toggleNotification,
|
2391
|
+
update,
|
2392
|
+
validate
|
2393
|
+
]);
|
2394
|
+
React__namespace.useEffect(() => {
|
2395
|
+
const handleKeyDown = (e) => {
|
2396
|
+
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
2397
|
+
e.preventDefault();
|
2398
|
+
handleUpdate();
|
2399
|
+
}
|
2400
|
+
};
|
2401
|
+
window.addEventListener("keydown", handleKeyDown);
|
2402
|
+
return () => {
|
2403
|
+
window.removeEventListener("keydown", handleKeyDown);
|
2404
|
+
};
|
2405
|
+
}, [handleUpdate]);
|
1878
2406
|
return {
|
1879
2407
|
/**
|
1880
2408
|
* Disabled when:
|
@@ -1884,85 +2412,14 @@ const UpdateAction = ({
|
|
1884
2412
|
*/
|
1885
2413
|
disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
|
1886
2414
|
label: formatMessage({
|
1887
|
-
id: "
|
2415
|
+
id: "global.save",
|
1888
2416
|
defaultMessage: "Save"
|
1889
2417
|
}),
|
1890
|
-
onClick:
|
1891
|
-
setSubmitting(true);
|
1892
|
-
try {
|
1893
|
-
const { errors } = await validate();
|
1894
|
-
if (errors) {
|
1895
|
-
toggleNotification({
|
1896
|
-
type: "danger",
|
1897
|
-
message: formatMessage({
|
1898
|
-
id: "content-manager.validation.error",
|
1899
|
-
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
1900
|
-
})
|
1901
|
-
});
|
1902
|
-
return;
|
1903
|
-
}
|
1904
|
-
if (isCloning) {
|
1905
|
-
const res = await clone(
|
1906
|
-
{
|
1907
|
-
model,
|
1908
|
-
documentId: cloneMatch.params.origin,
|
1909
|
-
params
|
1910
|
-
},
|
1911
|
-
document
|
1912
|
-
);
|
1913
|
-
if ("data" in res) {
|
1914
|
-
navigate(
|
1915
|
-
{
|
1916
|
-
pathname: `../${res.data.documentId}`,
|
1917
|
-
search: rawQuery
|
1918
|
-
},
|
1919
|
-
{ relative: "path" }
|
1920
|
-
);
|
1921
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1922
|
-
setErrors(formatValidationErrors(res.error));
|
1923
|
-
}
|
1924
|
-
} else if (documentId || collectionType === SINGLE_TYPES) {
|
1925
|
-
const res = await update(
|
1926
|
-
{
|
1927
|
-
collectionType,
|
1928
|
-
model,
|
1929
|
-
documentId,
|
1930
|
-
params
|
1931
|
-
},
|
1932
|
-
document
|
1933
|
-
);
|
1934
|
-
if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1935
|
-
setErrors(formatValidationErrors(res.error));
|
1936
|
-
} else {
|
1937
|
-
resetForm();
|
1938
|
-
}
|
1939
|
-
} else {
|
1940
|
-
const res = await create(
|
1941
|
-
{
|
1942
|
-
model,
|
1943
|
-
params
|
1944
|
-
},
|
1945
|
-
document
|
1946
|
-
);
|
1947
|
-
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1948
|
-
navigate(
|
1949
|
-
{
|
1950
|
-
pathname: `../${res.data.documentId}`,
|
1951
|
-
search: rawQuery
|
1952
|
-
},
|
1953
|
-
{ replace: true, relative: "path" }
|
1954
|
-
);
|
1955
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1956
|
-
setErrors(formatValidationErrors(res.error));
|
1957
|
-
}
|
1958
|
-
}
|
1959
|
-
} finally {
|
1960
|
-
setSubmitting(false);
|
1961
|
-
}
|
1962
|
-
}
|
2418
|
+
onClick: handleUpdate
|
1963
2419
|
};
|
1964
2420
|
};
|
1965
2421
|
UpdateAction.type = "update";
|
2422
|
+
UpdateAction.position = "panel";
|
1966
2423
|
const UNPUBLISH_DRAFT_OPTIONS = {
|
1967
2424
|
KEEP: "keep",
|
1968
2425
|
DISCARD: "discard"
|
@@ -1995,7 +2452,7 @@ const UnpublishAction$1 = ({
|
|
1995
2452
|
id: "app.utils.unpublish",
|
1996
2453
|
defaultMessage: "Unpublish"
|
1997
2454
|
}),
|
1998
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2455
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
|
1999
2456
|
onClick: async () => {
|
2000
2457
|
if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
|
2001
2458
|
if (!documentId) {
|
@@ -2085,6 +2542,7 @@ const UnpublishAction$1 = ({
|
|
2085
2542
|
};
|
2086
2543
|
};
|
2087
2544
|
UnpublishAction$1.type = "unpublish";
|
2545
|
+
UnpublishAction$1.position = "panel";
|
2088
2546
|
const DiscardAction = ({
|
2089
2547
|
activeTab,
|
2090
2548
|
documentId,
|
@@ -2107,7 +2565,7 @@ const DiscardAction = ({
|
|
2107
2565
|
id: "content-manager.actions.discard.label",
|
2108
2566
|
defaultMessage: "Discard changes"
|
2109
2567
|
}),
|
2110
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2568
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
|
2111
2569
|
position: ["panel", "table-row"],
|
2112
2570
|
variant: "danger",
|
2113
2571
|
dialog: {
|
@@ -2135,11 +2593,7 @@ const DiscardAction = ({
|
|
2135
2593
|
};
|
2136
2594
|
};
|
2137
2595
|
DiscardAction.type = "discard";
|
2138
|
-
|
2139
|
-
path {
|
2140
|
-
fill: currentColor;
|
2141
|
-
}
|
2142
|
-
`;
|
2596
|
+
DiscardAction.position = "panel";
|
2143
2597
|
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
2144
2598
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
2145
2599
|
const RelativeTime = React__namespace.forwardRef(
|
@@ -2152,7 +2606,7 @@ const RelativeTime = React__namespace.forwardRef(
|
|
2152
2606
|
});
|
2153
2607
|
const unit = intervals.find((intervalUnit) => {
|
2154
2608
|
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
|
2155
|
-
});
|
2609
|
+
}) ?? "seconds";
|
2156
2610
|
const relativeTime = dateFns.isPast(timestamp) ? -interval[unit] : interval[unit];
|
2157
2611
|
const customInterval = customIntervals.find(
|
2158
2612
|
(custom) => interval[custom.unit] < custom.threshold
|
@@ -2186,19 +2640,29 @@ const getDisplayName = ({
|
|
2186
2640
|
return email ?? "";
|
2187
2641
|
};
|
2188
2642
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2189
|
-
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2190
|
-
const statusVariant = status === "draft" ? "
|
2191
|
-
|
2643
|
+
const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
|
2644
|
+
const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
|
2645
|
+
const { formatMessage } = reactIntl.useIntl();
|
2646
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
|
2647
|
+
id: `content-manager.containers.List.${status}`,
|
2648
|
+
defaultMessage: capitalise(status)
|
2649
|
+
}) }) });
|
2192
2650
|
};
|
2193
2651
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
2194
2652
|
const { formatMessage } = reactIntl.useIntl();
|
2195
2653
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2654
|
+
const params = reactRouterDom.useParams();
|
2196
2655
|
const title = isCreating ? formatMessage({
|
2197
2656
|
id: "content-manager.containers.edit.title.new",
|
2198
2657
|
defaultMessage: "Create an entry"
|
2199
2658
|
}) : documentTitle;
|
2200
2659
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2201
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
2660
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2661
|
+
strapiAdmin.BackButton,
|
2662
|
+
{
|
2663
|
+
fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
|
2664
|
+
}
|
2665
|
+
),
|
2202
2666
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2203
2667
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2204
2668
|
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
@@ -2249,7 +2713,7 @@ const HeaderToolbar = () => {
|
|
2249
2713
|
meta: isCloning ? void 0 : meta,
|
2250
2714
|
collectionType
|
2251
2715
|
},
|
2252
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2716
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("header"),
|
2253
2717
|
children: (actions2) => {
|
2254
2718
|
const headerActions = actions2.filter((action) => {
|
2255
2719
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -2286,12 +2750,12 @@ const Information = ({ activeTab }) => {
|
|
2286
2750
|
isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
|
2287
2751
|
label: formatMessage({
|
2288
2752
|
id: "content-manager.containers.edit.information.last-published.label",
|
2289
|
-
defaultMessage: "
|
2753
|
+
defaultMessage: "Published"
|
2290
2754
|
}),
|
2291
2755
|
value: formatMessage(
|
2292
2756
|
{
|
2293
2757
|
id: "content-manager.containers.edit.information.last-published.value",
|
2294
|
-
defaultMessage: `
|
2758
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2295
2759
|
},
|
2296
2760
|
{
|
2297
2761
|
time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
|
@@ -2304,12 +2768,12 @@ const Information = ({ activeTab }) => {
|
|
2304
2768
|
isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
|
2305
2769
|
label: formatMessage({
|
2306
2770
|
id: "content-manager.containers.edit.information.last-draft.label",
|
2307
|
-
defaultMessage: "
|
2771
|
+
defaultMessage: "Updated"
|
2308
2772
|
}),
|
2309
2773
|
value: formatMessage(
|
2310
2774
|
{
|
2311
2775
|
id: "content-manager.containers.edit.information.last-draft.value",
|
2312
|
-
defaultMessage: `
|
2776
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2313
2777
|
},
|
2314
2778
|
{
|
2315
2779
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2327,12 +2791,12 @@ const Information = ({ activeTab }) => {
|
|
2327
2791
|
isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
|
2328
2792
|
label: formatMessage({
|
2329
2793
|
id: "content-manager.containers.edit.information.document.label",
|
2330
|
-
defaultMessage: "
|
2794
|
+
defaultMessage: "Created"
|
2331
2795
|
}),
|
2332
2796
|
value: formatMessage(
|
2333
2797
|
{
|
2334
2798
|
id: "content-manager.containers.edit.information.document.value",
|
2335
|
-
defaultMessage: `
|
2799
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2336
2800
|
},
|
2337
2801
|
{
|
2338
2802
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2370,25 +2834,77 @@ const Information = ({ activeTab }) => {
|
|
2370
2834
|
);
|
2371
2835
|
};
|
2372
2836
|
const HeaderActions = ({ actions: actions2 }) => {
|
2373
|
-
|
2374
|
-
|
2837
|
+
const [dialogId, setDialogId] = React__namespace.useState(null);
|
2838
|
+
const handleClick = (action) => async (e) => {
|
2839
|
+
if (!("options" in action)) {
|
2840
|
+
const { onClick = () => false, dialog, id } = action;
|
2841
|
+
const muteDialog = await onClick(e);
|
2842
|
+
if (dialog && !muteDialog) {
|
2843
|
+
e.preventDefault();
|
2844
|
+
setDialogId(id);
|
2845
|
+
}
|
2846
|
+
}
|
2847
|
+
};
|
2848
|
+
const handleClose = () => {
|
2849
|
+
setDialogId(null);
|
2850
|
+
};
|
2851
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, children: actions2.map((action) => {
|
2852
|
+
if (action.options) {
|
2375
2853
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
2376
2854
|
designSystem.SingleSelect,
|
2377
2855
|
{
|
2378
2856
|
size: "S",
|
2379
|
-
disabled: action.disabled,
|
2380
|
-
"aria-label": action.label,
|
2381
2857
|
onChange: action.onSelect,
|
2382
|
-
|
2858
|
+
"aria-label": action.label,
|
2859
|
+
...action,
|
2383
2860
|
children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
|
2384
2861
|
},
|
2385
2862
|
action.id
|
2386
2863
|
);
|
2387
2864
|
} else {
|
2388
|
-
|
2865
|
+
if (action.type === "icon") {
|
2866
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
|
2867
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2868
|
+
designSystem.IconButton,
|
2869
|
+
{
|
2870
|
+
disabled: action.disabled,
|
2871
|
+
label: action.label,
|
2872
|
+
size: "S",
|
2873
|
+
onClick: handleClick(action),
|
2874
|
+
children: action.icon
|
2875
|
+
}
|
2876
|
+
),
|
2877
|
+
action.dialog ? /* @__PURE__ */ jsxRuntime.jsx(
|
2878
|
+
HeaderActionDialog,
|
2879
|
+
{
|
2880
|
+
...action.dialog,
|
2881
|
+
isOpen: dialogId === action.id,
|
2882
|
+
onClose: handleClose
|
2883
|
+
}
|
2884
|
+
) : null
|
2885
|
+
] }, action.id);
|
2886
|
+
}
|
2389
2887
|
}
|
2390
2888
|
}) });
|
2391
2889
|
};
|
2890
|
+
const HeaderActionDialog = ({
|
2891
|
+
onClose,
|
2892
|
+
onCancel,
|
2893
|
+
title,
|
2894
|
+
content: Content,
|
2895
|
+
isOpen
|
2896
|
+
}) => {
|
2897
|
+
const handleClose = async () => {
|
2898
|
+
if (onCancel) {
|
2899
|
+
await onCancel();
|
2900
|
+
}
|
2901
|
+
onClose();
|
2902
|
+
};
|
2903
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2904
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
2905
|
+
typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content
|
2906
|
+
] }) });
|
2907
|
+
};
|
2392
2908
|
const ConfigureTheViewAction = ({ collectionType, model }) => {
|
2393
2909
|
const navigate = reactRouterDom.useNavigate();
|
2394
2910
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2405,6 +2921,7 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
|
|
2405
2921
|
};
|
2406
2922
|
};
|
2407
2923
|
ConfigureTheViewAction.type = "configure-the-view";
|
2924
|
+
ConfigureTheViewAction.position = "header";
|
2408
2925
|
const EditTheModelAction = ({ model }) => {
|
2409
2926
|
const navigate = reactRouterDom.useNavigate();
|
2410
2927
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2421,6 +2938,7 @@ const EditTheModelAction = ({ model }) => {
|
|
2421
2938
|
};
|
2422
2939
|
};
|
2423
2940
|
EditTheModelAction.type = "edit-the-model";
|
2941
|
+
EditTheModelAction.position = "header";
|
2424
2942
|
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2425
2943
|
const navigate = reactRouterDom.useNavigate();
|
2426
2944
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2429,12 +2947,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2429
2947
|
const { delete: deleteAction } = useDocumentActions();
|
2430
2948
|
const { toggleNotification } = strapiAdmin.useNotification();
|
2431
2949
|
const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
|
2950
|
+
const isLocalized = document?.locale != null;
|
2432
2951
|
return {
|
2433
2952
|
disabled: !canDelete || !document,
|
2434
|
-
label: formatMessage(
|
2435
|
-
|
2436
|
-
|
2437
|
-
|
2953
|
+
label: formatMessage(
|
2954
|
+
{
|
2955
|
+
id: "content-manager.actions.delete.label",
|
2956
|
+
defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
|
2957
|
+
},
|
2958
|
+
{ isLocalized }
|
2959
|
+
),
|
2438
2960
|
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
|
2439
2961
|
dialog: {
|
2440
2962
|
type: "dialog",
|
@@ -2476,417 +2998,116 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2476
2998
|
}
|
2477
2999
|
});
|
2478
3000
|
if (!("error" in res)) {
|
2479
|
-
navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
|
2480
|
-
}
|
2481
|
-
} finally {
|
2482
|
-
if (!listViewPathMatch) {
|
2483
|
-
setSubmitting(false);
|
2484
|
-
}
|
2485
|
-
}
|
2486
|
-
}
|
2487
|
-
},
|
2488
|
-
variant: "danger",
|
2489
|
-
position: ["header", "table-row"]
|
2490
|
-
};
|
2491
|
-
};
|
2492
|
-
DeleteAction$1.type = "delete";
|
2493
|
-
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2494
|
-
const Panels = () => {
|
2495
|
-
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2496
|
-
const [
|
2497
|
-
{
|
2498
|
-
query: { status }
|
2499
|
-
}
|
2500
|
-
] = strapiAdmin.useQueryParams({
|
2501
|
-
status: "draft"
|
2502
|
-
});
|
2503
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2504
|
-
const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
|
2505
|
-
const props = {
|
2506
|
-
activeTab: status,
|
2507
|
-
model,
|
2508
|
-
documentId: id,
|
2509
|
-
document: isCloning ? void 0 : document,
|
2510
|
-
meta: isCloning ? void 0 : meta,
|
2511
|
-
collectionType
|
2512
|
-
};
|
2513
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
2514
|
-
strapiAdmin.DescriptionComponentRenderer,
|
2515
|
-
{
|
2516
|
-
props,
|
2517
|
-
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
2518
|
-
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
|
2519
|
-
}
|
2520
|
-
) });
|
2521
|
-
};
|
2522
|
-
const ActionsPanel = () => {
|
2523
|
-
const { formatMessage } = reactIntl.useIntl();
|
2524
|
-
return {
|
2525
|
-
title: formatMessage({
|
2526
|
-
id: "content-manager.containers.edit.panels.default.title",
|
2527
|
-
defaultMessage: "Document"
|
2528
|
-
}),
|
2529
|
-
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2530
|
-
};
|
2531
|
-
};
|
2532
|
-
ActionsPanel.type = "actions";
|
2533
|
-
const ActionsPanelContent = () => {
|
2534
|
-
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2535
|
-
const [
|
2536
|
-
{
|
2537
|
-
query: { status = "draft" }
|
2538
|
-
}
|
2539
|
-
] = strapiAdmin.useQueryParams();
|
2540
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2541
|
-
const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
|
2542
|
-
const props = {
|
2543
|
-
activeTab: status,
|
2544
|
-
model,
|
2545
|
-
documentId: id,
|
2546
|
-
document: isCloning ? void 0 : document,
|
2547
|
-
meta: isCloning ? void 0 : meta,
|
2548
|
-
collectionType
|
2549
|
-
};
|
2550
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
|
2551
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
2552
|
-
strapiAdmin.DescriptionComponentRenderer,
|
2553
|
-
{
|
2554
|
-
props,
|
2555
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2556
|
-
children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
|
2557
|
-
}
|
2558
|
-
),
|
2559
|
-
/* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
2560
|
-
] });
|
2561
|
-
};
|
2562
|
-
const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
2563
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
2564
|
-
designSystem.Flex,
|
2565
|
-
{
|
2566
|
-
ref,
|
2567
|
-
tag: "aside",
|
2568
|
-
"aria-labelledby": "additional-information",
|
2569
|
-
background: "neutral0",
|
2570
|
-
borderColor: "neutral150",
|
2571
|
-
hasRadius: true,
|
2572
|
-
paddingBottom: 4,
|
2573
|
-
paddingLeft: 4,
|
2574
|
-
paddingRight: 4,
|
2575
|
-
paddingTop: 4,
|
2576
|
-
shadow: "tableShadow",
|
2577
|
-
gap: 3,
|
2578
|
-
direction: "column",
|
2579
|
-
justifyContent: "stretch",
|
2580
|
-
alignItems: "flex-start",
|
2581
|
-
children: [
|
2582
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
|
2583
|
-
children
|
2584
|
-
]
|
2585
|
-
}
|
2586
|
-
);
|
2587
|
-
});
|
2588
|
-
const HOOKS = {
|
2589
|
-
/**
|
2590
|
-
* Hook that allows to mutate the displayed headers of the list view table
|
2591
|
-
* @constant
|
2592
|
-
* @type {string}
|
2593
|
-
*/
|
2594
|
-
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
2595
|
-
/**
|
2596
|
-
* Hook that allows to mutate the CM's collection types links pre-set filters
|
2597
|
-
* @constant
|
2598
|
-
* @type {string}
|
2599
|
-
*/
|
2600
|
-
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
2601
|
-
/**
|
2602
|
-
* Hook that allows to mutate the CM's edit view layout
|
2603
|
-
* @constant
|
2604
|
-
* @type {string}
|
2605
|
-
*/
|
2606
|
-
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
2607
|
-
/**
|
2608
|
-
* Hook that allows to mutate the CM's single types links pre-set filters
|
2609
|
-
* @constant
|
2610
|
-
* @type {string}
|
2611
|
-
*/
|
2612
|
-
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
2613
|
-
};
|
2614
|
-
const contentTypesApi = contentManagerApi.injectEndpoints({
|
2615
|
-
endpoints: (builder) => ({
|
2616
|
-
getContentTypeConfiguration: builder.query({
|
2617
|
-
query: (uid) => ({
|
2618
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2619
|
-
method: "GET"
|
2620
|
-
}),
|
2621
|
-
transformResponse: (response) => response.data,
|
2622
|
-
providesTags: (_result, _error, uid) => [
|
2623
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2624
|
-
{ type: "ContentTypeSettings", id: "LIST" }
|
2625
|
-
]
|
2626
|
-
}),
|
2627
|
-
getAllContentTypeSettings: builder.query({
|
2628
|
-
query: () => "/content-manager/content-types-settings",
|
2629
|
-
transformResponse: (response) => response.data,
|
2630
|
-
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
2631
|
-
}),
|
2632
|
-
updateContentTypeConfiguration: builder.mutation({
|
2633
|
-
query: ({ uid, ...body }) => ({
|
2634
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2635
|
-
method: "PUT",
|
2636
|
-
data: body
|
2637
|
-
}),
|
2638
|
-
transformResponse: (response) => response.data,
|
2639
|
-
invalidatesTags: (_result, _error, { uid }) => [
|
2640
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2641
|
-
{ type: "ContentTypeSettings", id: "LIST" },
|
2642
|
-
// Is this necessary?
|
2643
|
-
{ type: "InitialData" }
|
2644
|
-
]
|
2645
|
-
})
|
2646
|
-
})
|
2647
|
-
});
|
2648
|
-
const {
|
2649
|
-
useGetContentTypeConfigurationQuery,
|
2650
|
-
useGetAllContentTypeSettingsQuery,
|
2651
|
-
useUpdateContentTypeConfigurationMutation
|
2652
|
-
} = contentTypesApi;
|
2653
|
-
const checkIfAttributeIsDisplayable = (attribute) => {
|
2654
|
-
const { type } = attribute;
|
2655
|
-
if (type === "relation") {
|
2656
|
-
return !attribute.relation.toLowerCase().includes("morph");
|
2657
|
-
}
|
2658
|
-
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
2659
|
-
};
|
2660
|
-
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
2661
|
-
if (!mainFieldName) {
|
2662
|
-
return void 0;
|
2663
|
-
}
|
2664
|
-
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
2665
|
-
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
2666
|
-
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2667
|
-
);
|
2668
|
-
return {
|
2669
|
-
name: mainFieldName,
|
2670
|
-
type: mainFieldType ?? "string"
|
2671
|
-
};
|
2672
|
-
};
|
2673
|
-
const DEFAULT_SETTINGS = {
|
2674
|
-
bulkable: false,
|
2675
|
-
filterable: false,
|
2676
|
-
searchable: false,
|
2677
|
-
pagination: false,
|
2678
|
-
defaultSortBy: "",
|
2679
|
-
defaultSortOrder: "asc",
|
2680
|
-
mainField: "id",
|
2681
|
-
pageSize: 10
|
2682
|
-
};
|
2683
|
-
const useDocumentLayout = (model) => {
|
2684
|
-
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
2685
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
2686
|
-
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
2687
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
2688
|
-
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
2689
|
-
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
2690
|
-
const {
|
2691
|
-
data,
|
2692
|
-
isLoading: isLoadingConfigs,
|
2693
|
-
error,
|
2694
|
-
isFetching: isFetchingConfigs
|
2695
|
-
} = useGetContentTypeConfigurationQuery(model);
|
2696
|
-
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
2697
|
-
React__namespace.useEffect(() => {
|
2698
|
-
if (error) {
|
2699
|
-
toggleNotification({
|
2700
|
-
type: "danger",
|
2701
|
-
message: formatAPIError(error)
|
2702
|
-
});
|
2703
|
-
}
|
2704
|
-
}, [error, formatAPIError, toggleNotification]);
|
2705
|
-
const editLayout = React__namespace.useMemo(
|
2706
|
-
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
2707
|
-
layout: [],
|
2708
|
-
components: {},
|
2709
|
-
metadatas: {},
|
2710
|
-
options: {},
|
2711
|
-
settings: DEFAULT_SETTINGS
|
2712
|
-
},
|
2713
|
-
[data, isLoading, schemas, schema, components]
|
2714
|
-
);
|
2715
|
-
const listLayout = React__namespace.useMemo(() => {
|
2716
|
-
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
2717
|
-
layout: [],
|
2718
|
-
metadatas: {},
|
2719
|
-
options: {},
|
2720
|
-
settings: DEFAULT_SETTINGS
|
2721
|
-
};
|
2722
|
-
}, [data, isLoading, schemas, schema, components]);
|
2723
|
-
const { layout: edit } = React__namespace.useMemo(
|
2724
|
-
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
2725
|
-
layout: editLayout,
|
2726
|
-
query
|
2727
|
-
}),
|
2728
|
-
[editLayout, query, runHookWaterfall]
|
2729
|
-
);
|
2730
|
-
return {
|
2731
|
-
error,
|
2732
|
-
isLoading,
|
2733
|
-
edit,
|
2734
|
-
list: listLayout
|
2735
|
-
};
|
2736
|
-
};
|
2737
|
-
const useDocLayout = () => {
|
2738
|
-
const { model } = useDoc();
|
2739
|
-
return useDocumentLayout(model);
|
2740
|
-
};
|
2741
|
-
const formatEditLayout = (data, {
|
2742
|
-
schemas,
|
2743
|
-
schema,
|
2744
|
-
components
|
2745
|
-
}) => {
|
2746
|
-
let currentPanelIndex = 0;
|
2747
|
-
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
2748
|
-
data.contentType.layouts.edit,
|
2749
|
-
schema?.attributes,
|
2750
|
-
data.contentType.metadatas,
|
2751
|
-
{ configurations: data.components, schemas: components },
|
2752
|
-
schemas
|
2753
|
-
).reduce((panels, row) => {
|
2754
|
-
if (row.some((field) => field.type === "dynamiczone")) {
|
2755
|
-
panels.push([row]);
|
2756
|
-
currentPanelIndex += 2;
|
2757
|
-
} else {
|
2758
|
-
if (!panels[currentPanelIndex]) {
|
2759
|
-
panels.push([]);
|
2760
|
-
}
|
2761
|
-
panels[currentPanelIndex].push(row);
|
2762
|
-
}
|
2763
|
-
return panels;
|
2764
|
-
}, []);
|
2765
|
-
const componentEditAttributes = Object.entries(data.components).reduce(
|
2766
|
-
(acc, [uid, configuration]) => {
|
2767
|
-
acc[uid] = {
|
2768
|
-
layout: convertEditLayoutToFieldLayouts(
|
2769
|
-
configuration.layouts.edit,
|
2770
|
-
components[uid].attributes,
|
2771
|
-
configuration.metadatas
|
2772
|
-
),
|
2773
|
-
settings: {
|
2774
|
-
...configuration.settings,
|
2775
|
-
icon: components[uid].info.icon,
|
2776
|
-
displayName: components[uid].info.displayName
|
3001
|
+
navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
|
3002
|
+
}
|
3003
|
+
} finally {
|
3004
|
+
if (!listViewPathMatch) {
|
3005
|
+
setSubmitting(false);
|
3006
|
+
}
|
2777
3007
|
}
|
2778
|
-
}
|
2779
|
-
return acc;
|
2780
|
-
},
|
2781
|
-
{}
|
2782
|
-
);
|
2783
|
-
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2784
|
-
(acc, [attribute, metadata]) => {
|
2785
|
-
return {
|
2786
|
-
...acc,
|
2787
|
-
[attribute]: metadata.edit
|
2788
|
-
};
|
2789
|
-
},
|
2790
|
-
{}
|
2791
|
-
);
|
2792
|
-
return {
|
2793
|
-
layout: panelledEditAttributes,
|
2794
|
-
components: componentEditAttributes,
|
2795
|
-
metadatas: editMetadatas,
|
2796
|
-
settings: {
|
2797
|
-
...data.contentType.settings,
|
2798
|
-
displayName: schema?.info.displayName
|
3008
|
+
}
|
2799
3009
|
},
|
2800
|
-
|
2801
|
-
|
2802
|
-
...schema?.pluginOptions,
|
2803
|
-
...data.contentType.options
|
2804
|
-
}
|
3010
|
+
variant: "danger",
|
3011
|
+
position: ["header", "table-row"]
|
2805
3012
|
};
|
2806
3013
|
};
|
2807
|
-
|
2808
|
-
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2812
|
-
|
2813
|
-
|
2814
|
-
|
2815
|
-
|
2816
|
-
|
2817
|
-
|
2818
|
-
|
2819
|
-
|
2820
|
-
|
2821
|
-
|
2822
|
-
|
2823
|
-
|
2824
|
-
|
2825
|
-
|
2826
|
-
|
2827
|
-
|
2828
|
-
|
2829
|
-
|
2830
|
-
|
2831
|
-
|
2832
|
-
|
2833
|
-
|
2834
|
-
|
2835
|
-
|
3014
|
+
DeleteAction$1.type = "delete";
|
3015
|
+
DeleteAction$1.position = ["header", "table-row"];
|
3016
|
+
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
3017
|
+
const Panels = () => {
|
3018
|
+
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
3019
|
+
const [
|
3020
|
+
{
|
3021
|
+
query: { status }
|
3022
|
+
}
|
3023
|
+
] = strapiAdmin.useQueryParams({
|
3024
|
+
status: "draft"
|
3025
|
+
});
|
3026
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
3027
|
+
const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
|
3028
|
+
const props = {
|
3029
|
+
activeTab: status,
|
3030
|
+
model,
|
3031
|
+
documentId: id,
|
3032
|
+
document: isCloning ? void 0 : document,
|
3033
|
+
meta: isCloning ? void 0 : meta,
|
3034
|
+
collectionType
|
3035
|
+
};
|
3036
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
3037
|
+
strapiAdmin.DescriptionComponentRenderer,
|
3038
|
+
{
|
3039
|
+
props,
|
3040
|
+
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
3041
|
+
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
|
3042
|
+
}
|
3043
|
+
) });
|
2836
3044
|
};
|
2837
|
-
const
|
2838
|
-
|
2839
|
-
schema,
|
2840
|
-
components
|
2841
|
-
}) => {
|
2842
|
-
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2843
|
-
(acc, [attribute, metadata]) => {
|
2844
|
-
return {
|
2845
|
-
...acc,
|
2846
|
-
[attribute]: metadata.list
|
2847
|
-
};
|
2848
|
-
},
|
2849
|
-
{}
|
2850
|
-
);
|
2851
|
-
const listAttributes = convertListLayoutToFieldLayouts(
|
2852
|
-
data.contentType.layouts.list,
|
2853
|
-
schema?.attributes,
|
2854
|
-
listMetadatas,
|
2855
|
-
{ configurations: data.components, schemas: components },
|
2856
|
-
schemas
|
2857
|
-
);
|
3045
|
+
const ActionsPanel = () => {
|
3046
|
+
const { formatMessage } = reactIntl.useIntl();
|
2858
3047
|
return {
|
2859
|
-
|
2860
|
-
|
2861
|
-
|
2862
|
-
|
2863
|
-
|
2864
|
-
...schema?.pluginOptions,
|
2865
|
-
...data.contentType.options
|
2866
|
-
}
|
3048
|
+
title: formatMessage({
|
3049
|
+
id: "content-manager.containers.edit.panels.default.title",
|
3050
|
+
defaultMessage: "Entry"
|
3051
|
+
}),
|
3052
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2867
3053
|
};
|
2868
3054
|
};
|
2869
|
-
|
2870
|
-
|
2871
|
-
|
2872
|
-
|
2873
|
-
|
3055
|
+
ActionsPanel.type = "actions";
|
3056
|
+
const ActionsPanelContent = () => {
|
3057
|
+
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
3058
|
+
const [
|
3059
|
+
{
|
3060
|
+
query: { status = "draft" }
|
2874
3061
|
}
|
2875
|
-
|
2876
|
-
|
2877
|
-
|
2878
|
-
|
2879
|
-
|
2880
|
-
|
2881
|
-
|
2882
|
-
|
2883
|
-
|
2884
|
-
|
2885
|
-
|
2886
|
-
|
2887
|
-
|
2888
|
-
|
3062
|
+
] = strapiAdmin.useQueryParams();
|
3063
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
3064
|
+
const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
|
3065
|
+
const props = {
|
3066
|
+
activeTab: status,
|
3067
|
+
model,
|
3068
|
+
documentId: id,
|
3069
|
+
document: isCloning ? void 0 : document,
|
3070
|
+
meta: isCloning ? void 0 : meta,
|
3071
|
+
collectionType
|
3072
|
+
};
|
3073
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
|
3074
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3075
|
+
strapiAdmin.DescriptionComponentRenderer,
|
3076
|
+
{
|
3077
|
+
props,
|
3078
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("panel"),
|
3079
|
+
children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
|
3080
|
+
}
|
3081
|
+
),
|
3082
|
+
/* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
3083
|
+
] });
|
2889
3084
|
};
|
3085
|
+
const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
3086
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
3087
|
+
designSystem.Flex,
|
3088
|
+
{
|
3089
|
+
ref,
|
3090
|
+
tag: "aside",
|
3091
|
+
"aria-labelledby": "additional-information",
|
3092
|
+
background: "neutral0",
|
3093
|
+
borderColor: "neutral150",
|
3094
|
+
hasRadius: true,
|
3095
|
+
paddingBottom: 4,
|
3096
|
+
paddingLeft: 4,
|
3097
|
+
paddingRight: 4,
|
3098
|
+
paddingTop: 4,
|
3099
|
+
shadow: "tableShadow",
|
3100
|
+
gap: 3,
|
3101
|
+
direction: "column",
|
3102
|
+
justifyContent: "stretch",
|
3103
|
+
alignItems: "flex-start",
|
3104
|
+
children: [
|
3105
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
|
3106
|
+
children
|
3107
|
+
]
|
3108
|
+
}
|
3109
|
+
);
|
3110
|
+
});
|
2890
3111
|
const ConfirmBulkActionDialog = ({
|
2891
3112
|
onToggleDialog,
|
2892
3113
|
isOpen = false,
|
@@ -2925,6 +3146,7 @@ const ConfirmDialogPublishAll = ({
|
|
2925
3146
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler(getTranslation);
|
2926
3147
|
const { model, schema } = useDoc();
|
2927
3148
|
const [{ query }] = strapiAdmin.useQueryParams();
|
3149
|
+
const enableDraftRelationsCount = false;
|
2928
3150
|
const {
|
2929
3151
|
data: countDraftRelations = 0,
|
2930
3152
|
isLoading,
|
@@ -2936,7 +3158,7 @@ const ConfirmDialogPublishAll = ({
|
|
2936
3158
|
locale: query?.plugins?.i18n?.locale
|
2937
3159
|
},
|
2938
3160
|
{
|
2939
|
-
skip:
|
3161
|
+
skip: !enableDraftRelationsCount
|
2940
3162
|
}
|
2941
3163
|
);
|
2942
3164
|
React__namespace.useEffect(() => {
|
@@ -3121,7 +3343,7 @@ const SelectedEntriesTableContent = ({
|
|
3121
3343
|
status: row.status
|
3122
3344
|
}
|
3123
3345
|
) }),
|
3124
|
-
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3346
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3125
3347
|
designSystem.IconButton,
|
3126
3348
|
{
|
3127
3349
|
tag: reactRouterDom.Link,
|
@@ -3130,23 +3352,16 @@ const SelectedEntriesTableContent = ({
|
|
3130
3352
|
search: row.locale && `?plugins[i18n][locale]=${row.locale}`
|
3131
3353
|
},
|
3132
3354
|
state: { from: pathname },
|
3133
|
-
label: formatMessage(
|
3134
|
-
|
3135
|
-
|
3136
|
-
|
3137
|
-
{
|
3138
|
-
id: "content-manager.components.ListViewHelperPluginTable.row-line",
|
3139
|
-
defaultMessage: "item line {number}"
|
3140
|
-
},
|
3141
|
-
{ number: index2 + 1 }
|
3142
|
-
)
|
3143
|
-
}
|
3144
|
-
),
|
3355
|
+
label: formatMessage({
|
3356
|
+
id: "content-manager.bulk-publish.edit",
|
3357
|
+
defaultMessage: "Edit"
|
3358
|
+
}),
|
3145
3359
|
target: "_blank",
|
3146
3360
|
marginLeft: "auto",
|
3147
|
-
|
3361
|
+
variant: "ghost",
|
3362
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, { width: "1.6rem", height: "1.6rem" })
|
3148
3363
|
}
|
3149
|
-
) })
|
3364
|
+
) }) })
|
3150
3365
|
] }, row.id)) })
|
3151
3366
|
] });
|
3152
3367
|
};
|
@@ -3183,7 +3398,13 @@ const SelectedEntriesModalContent = ({
|
|
3183
3398
|
);
|
3184
3399
|
const { rows, validationErrors } = React__namespace.useMemo(() => {
|
3185
3400
|
if (data.length > 0 && schema) {
|
3186
|
-
const validate = createYupSchema(
|
3401
|
+
const validate = createYupSchema(
|
3402
|
+
schema.attributes,
|
3403
|
+
components,
|
3404
|
+
// Since this is the "Publish" action, the validation
|
3405
|
+
// schema must enforce the rules for published entities
|
3406
|
+
{ status: "published" }
|
3407
|
+
);
|
3187
3408
|
const validationErrors2 = {};
|
3188
3409
|
const rows2 = data.map((entry) => {
|
3189
3410
|
try {
|
@@ -3308,8 +3529,7 @@ const PublishAction = ({ documents, model }) => {
|
|
3308
3529
|
const refetchList = () => {
|
3309
3530
|
contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
|
3310
3531
|
};
|
3311
|
-
if (!showPublishButton)
|
3312
|
-
return null;
|
3532
|
+
if (!showPublishButton) return null;
|
3313
3533
|
return {
|
3314
3534
|
actionType: "publish",
|
3315
3535
|
variant: "tertiary",
|
@@ -3377,8 +3597,7 @@ const DeleteAction = ({ documents, model }) => {
|
|
3377
3597
|
selectRow([]);
|
3378
3598
|
}
|
3379
3599
|
};
|
3380
|
-
if (!hasDeletePermission)
|
3381
|
-
return null;
|
3600
|
+
if (!hasDeletePermission) return null;
|
3382
3601
|
return {
|
3383
3602
|
variant: "danger-light",
|
3384
3603
|
label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
|
@@ -3427,8 +3646,7 @@ const UnpublishAction = ({ documents, model }) => {
|
|
3427
3646
|
}
|
3428
3647
|
};
|
3429
3648
|
const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
|
3430
|
-
if (!showUnpublishButton)
|
3431
|
-
return null;
|
3649
|
+
if (!showUnpublishButton) return null;
|
3432
3650
|
return {
|
3433
3651
|
variant: "tertiary",
|
3434
3652
|
label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
|
@@ -3533,7 +3751,7 @@ const TableActions = ({ document }) => {
|
|
3533
3751
|
strapiAdmin.DescriptionComponentRenderer,
|
3534
3752
|
{
|
3535
3753
|
props,
|
3536
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3754
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("table-row").filter((action) => action.name !== "PublishAction"),
|
3537
3755
|
children: (actions2) => {
|
3538
3756
|
const tableRowActions = actions2.filter((action) => {
|
3539
3757
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -3592,6 +3810,7 @@ const EditAction = ({ documentId }) => {
|
|
3592
3810
|
};
|
3593
3811
|
};
|
3594
3812
|
EditAction.type = "edit";
|
3813
|
+
EditAction.position = "table-row";
|
3595
3814
|
const StyledPencil = styledComponents.styled(Icons.Pencil)`
|
3596
3815
|
path {
|
3597
3816
|
fill: currentColor;
|
@@ -3644,7 +3863,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3644
3863
|
}),
|
3645
3864
|
content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
3646
3865
|
footer: ({ onClose }) => {
|
3647
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
3866
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
3648
3867
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
3649
3868
|
id: "cancel",
|
3650
3869
|
defaultMessage: "Cancel"
|
@@ -3668,6 +3887,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3668
3887
|
};
|
3669
3888
|
};
|
3670
3889
|
CloneAction.type = "clone";
|
3890
|
+
CloneAction.position = "table-row";
|
3671
3891
|
const StyledDuplicate = styledComponents.styled(Icons.Duplicate)`
|
3672
3892
|
path {
|
3673
3893
|
fill: currentColor;
|
@@ -3754,7 +3974,14 @@ class ContentManagerPlugin {
|
|
3754
3974
|
addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
|
3755
3975
|
addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
|
3756
3976
|
getBulkActions: () => this.bulkActions,
|
3757
|
-
getDocumentActions: () =>
|
3977
|
+
getDocumentActions: (position) => {
|
3978
|
+
if (position) {
|
3979
|
+
return this.documentActions.filter(
|
3980
|
+
(action) => action.position == void 0 || [action.position].flat().includes(position)
|
3981
|
+
);
|
3982
|
+
}
|
3983
|
+
return this.documentActions;
|
3984
|
+
},
|
3758
3985
|
getEditViewSidePanels: () => this.editViewSidePanels,
|
3759
3986
|
getHeaderActions: () => this.headerActions
|
3760
3987
|
}
|
@@ -3764,10 +3991,8 @@ class ContentManagerPlugin {
|
|
3764
3991
|
const getPrintableType = (value) => {
|
3765
3992
|
const nativeType = typeof value;
|
3766
3993
|
if (nativeType === "object") {
|
3767
|
-
if (value === null)
|
3768
|
-
|
3769
|
-
if (Array.isArray(value))
|
3770
|
-
return "array";
|
3994
|
+
if (value === null) return "null";
|
3995
|
+
if (Array.isArray(value)) return "array";
|
3771
3996
|
if (value instanceof Object && value.constructor.name !== "Object") {
|
3772
3997
|
return value.constructor.name;
|
3773
3998
|
}
|
@@ -3778,17 +4003,27 @@ const HistoryAction = ({ model, document }) => {
|
|
3778
4003
|
const { formatMessage } = reactIntl.useIntl();
|
3779
4004
|
const [{ query }] = strapiAdmin.useQueryParams();
|
3780
4005
|
const navigate = reactRouterDom.useNavigate();
|
4006
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
4007
|
+
const { pathname } = reactRouterDom.useLocation();
|
3781
4008
|
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
3782
4009
|
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
3783
4010
|
return null;
|
3784
4011
|
}
|
4012
|
+
const handleOnClick = () => {
|
4013
|
+
const destination = { pathname: "history", search: pluginsQueryParams };
|
4014
|
+
trackUsage("willNavigate", {
|
4015
|
+
from: pathname,
|
4016
|
+
to: `${pathname}/${destination.pathname}`
|
4017
|
+
});
|
4018
|
+
navigate(destination);
|
4019
|
+
};
|
3785
4020
|
return {
|
3786
4021
|
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
3787
4022
|
label: formatMessage({
|
3788
4023
|
id: "content-manager.history.document-action",
|
3789
4024
|
defaultMessage: "Content History"
|
3790
4025
|
}),
|
3791
|
-
onClick:
|
4026
|
+
onClick: handleOnClick,
|
3792
4027
|
disabled: (
|
3793
4028
|
/**
|
3794
4029
|
* The user is creating a new document.
|
@@ -3810,6 +4045,7 @@ const HistoryAction = ({ model, document }) => {
|
|
3810
4045
|
};
|
3811
4046
|
};
|
3812
4047
|
HistoryAction.type = "history";
|
4048
|
+
HistoryAction.position = "header";
|
3813
4049
|
const historyAdmin = {
|
3814
4050
|
bootstrap(app) {
|
3815
4051
|
const { addDocumentAction } = app.getPlugin("content-manager").apis;
|
@@ -3856,6 +4092,88 @@ const { setInitialData } = actions;
|
|
3856
4092
|
const reducer = toolkit.combineReducers({
|
3857
4093
|
app: reducer$1
|
3858
4094
|
});
|
4095
|
+
const previewApi = contentManagerApi.injectEndpoints({
|
4096
|
+
endpoints: (builder) => ({
|
4097
|
+
getPreviewUrl: builder.query({
|
4098
|
+
query({ query, params }) {
|
4099
|
+
return {
|
4100
|
+
url: `/content-manager/preview/url/${params.contentType}`,
|
4101
|
+
method: "GET",
|
4102
|
+
config: {
|
4103
|
+
params: query
|
4104
|
+
}
|
4105
|
+
};
|
4106
|
+
}
|
4107
|
+
})
|
4108
|
+
})
|
4109
|
+
});
|
4110
|
+
const { useGetPreviewUrlQuery } = previewApi;
|
4111
|
+
const ConditionalTooltip = ({ isShown, label, children }) => {
|
4112
|
+
if (isShown) {
|
4113
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { label, children });
|
4114
|
+
}
|
4115
|
+
return children;
|
4116
|
+
};
|
4117
|
+
const PreviewSidePanel = ({ model, documentId, document }) => {
|
4118
|
+
const { formatMessage } = reactIntl.useIntl();
|
4119
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
4120
|
+
const { pathname } = reactRouterDom.useLocation();
|
4121
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
4122
|
+
const isModified = strapiAdmin.useForm("PreviewSidePanel", (state) => state.modified);
|
4123
|
+
const { data, error } = useGetPreviewUrlQuery({
|
4124
|
+
params: {
|
4125
|
+
contentType: model
|
4126
|
+
},
|
4127
|
+
query: {
|
4128
|
+
documentId,
|
4129
|
+
locale: document?.locale,
|
4130
|
+
status: document?.status
|
4131
|
+
}
|
4132
|
+
});
|
4133
|
+
if (!data?.data?.url || error) {
|
4134
|
+
return null;
|
4135
|
+
}
|
4136
|
+
const trackNavigation = () => {
|
4137
|
+
const destinationPathname = pathname.replace(/\/$/, "") + "/preview";
|
4138
|
+
trackUsage("willNavigate", { from: pathname, to: destinationPathname });
|
4139
|
+
};
|
4140
|
+
return {
|
4141
|
+
title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
|
4142
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(
|
4143
|
+
ConditionalTooltip,
|
4144
|
+
{
|
4145
|
+
label: formatMessage({
|
4146
|
+
id: "content-manager.preview.panel.button-disabled-tooltip",
|
4147
|
+
defaultMessage: "Please save to open the preview"
|
4148
|
+
}),
|
4149
|
+
isShown: isModified,
|
4150
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { cursor: "not-allowed", width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(
|
4151
|
+
designSystem.Button,
|
4152
|
+
{
|
4153
|
+
variant: "tertiary",
|
4154
|
+
tag: reactRouterDom.Link,
|
4155
|
+
to: { pathname: "preview", search: qs.stringify(query, { encode: false }) },
|
4156
|
+
onClick: trackNavigation,
|
4157
|
+
width: "100%",
|
4158
|
+
disabled: isModified,
|
4159
|
+
pointerEvents: isModified ? "none" : void 0,
|
4160
|
+
tabIndex: isModified ? -1 : void 0,
|
4161
|
+
children: formatMessage({
|
4162
|
+
id: "content-manager.preview.panel.button",
|
4163
|
+
defaultMessage: "Open preview"
|
4164
|
+
})
|
4165
|
+
}
|
4166
|
+
) })
|
4167
|
+
}
|
4168
|
+
)
|
4169
|
+
};
|
4170
|
+
};
|
4171
|
+
const previewAdmin = {
|
4172
|
+
bootstrap(app) {
|
4173
|
+
const contentManagerPluginApis = app.getPlugin("content-manager").apis;
|
4174
|
+
contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
|
4175
|
+
}
|
4176
|
+
};
|
3859
4177
|
const index = {
|
3860
4178
|
register(app) {
|
3861
4179
|
const cm = new ContentManagerPlugin();
|
@@ -3875,7 +4193,7 @@ const index = {
|
|
3875
4193
|
app.router.addRoute({
|
3876
4194
|
path: "content-manager/*",
|
3877
4195
|
lazy: async () => {
|
3878
|
-
const { Layout } = await Promise.resolve().then(() => require("./layout-
|
4196
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-C3fN7Ejz.js"));
|
3879
4197
|
return {
|
3880
4198
|
Component: Layout
|
3881
4199
|
};
|
@@ -3888,11 +4206,14 @@ const index = {
|
|
3888
4206
|
if (typeof historyAdmin.bootstrap === "function") {
|
3889
4207
|
historyAdmin.bootstrap(app);
|
3890
4208
|
}
|
4209
|
+
if (typeof previewAdmin.bootstrap === "function") {
|
4210
|
+
previewAdmin.bootstrap(app);
|
4211
|
+
}
|
3891
4212
|
},
|
3892
4213
|
async registerTrads({ locales }) {
|
3893
4214
|
const importedTrads = await Promise.all(
|
3894
4215
|
locales.map((locale) => {
|
3895
|
-
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-
|
4216
|
+
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-BK8Xyl5I.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 }) => {
|
3896
4217
|
return {
|
3897
4218
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3898
4219
|
locale
|
@@ -3910,6 +4231,7 @@ const index = {
|
|
3910
4231
|
};
|
3911
4232
|
exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
|
3912
4233
|
exports.BulkActionsRenderer = BulkActionsRenderer;
|
4234
|
+
exports.CLONE_PATH = CLONE_PATH;
|
3913
4235
|
exports.COLLECTION_TYPES = COLLECTION_TYPES;
|
3914
4236
|
exports.CREATOR_FIELDS = CREATOR_FIELDS;
|
3915
4237
|
exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
|
@@ -3937,6 +4259,7 @@ exports.getMainField = getMainField;
|
|
3937
4259
|
exports.getTranslation = getTranslation;
|
3938
4260
|
exports.index = index;
|
3939
4261
|
exports.setInitialData = setInitialData;
|
4262
|
+
exports.useContentManagerContext = useContentManagerContext;
|
3940
4263
|
exports.useContentTypeSchema = useContentTypeSchema;
|
3941
4264
|
exports.useDoc = useDoc;
|
3942
4265
|
exports.useDocLayout = useDocLayout;
|
@@ -3948,5 +4271,6 @@ exports.useGetAllContentTypeSettingsQuery = useGetAllContentTypeSettingsQuery;
|
|
3948
4271
|
exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
3949
4272
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
3950
4273
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
4274
|
+
exports.useGetPreviewUrlQuery = useGetPreviewUrlQuery;
|
3951
4275
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
3952
|
-
//# sourceMappingURL=index-
|
4276
|
+
//# sourceMappingURL=index-BUWEmX8m.js.map
|