@strapi/content-manager 0.0.0-experimental.edc24aaa3bb5a90fa5fd4fee208167dd4e2e38d4 → 0.0.0-experimental.ee7402bacc4656d268ab76aa9c334a7b7a951201
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-5ukroXAh.js → ComponentConfigurationPage-BlzvDpbX.js} +5 -6
- package/dist/_chunks/{ComponentConfigurationPage-5ukroXAh.js.map → ComponentConfigurationPage-BlzvDpbX.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-BAgyHiMm.mjs → ComponentConfigurationPage-DaPOlQaD.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-BAgyHiMm.mjs.map → ComponentConfigurationPage-DaPOlQaD.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-DmoXawIh.mjs → EditConfigurationPage-BZPXItXo.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-DmoXawIh.mjs.map → EditConfigurationPage-BZPXItXo.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-Xp7lun0f.js → EditConfigurationPage-uy-v43AR.js} +5 -6
- package/dist/_chunks/{EditConfigurationPage-Xp7lun0f.js.map → EditConfigurationPage-uy-v43AR.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-C-ukDOB7.js → EditViewPage-DT6A4ayX.js} +63 -13
- package/dist/_chunks/EditViewPage-DT6A4ayX.js.map +1 -0
- package/dist/_chunks/{EditViewPage-BLsjc5F-.mjs → EditViewPage-oOLeTySr.mjs} +63 -12
- package/dist/_chunks/EditViewPage-oOLeTySr.mjs.map +1 -0
- package/dist/_chunks/{Field-Cs7duwWd.mjs → Field-D7dv2aUX.mjs} +335 -211
- package/dist/_chunks/Field-D7dv2aUX.mjs.map +1 -0
- package/dist/_chunks/{Field-Bfph5SOd.js → Field-kYFVIGiP.js} +339 -215
- package/dist/_chunks/Field-kYFVIGiP.js.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-Dg_GS5TQ.mjs → Form-BxR6sc29.mjs} +37 -18
- package/dist/_chunks/Form-BxR6sc29.mjs.map +1 -0
- package/dist/_chunks/{Form-CPYqIWDG.js → Form-CCijSg3V.js} +39 -21
- package/dist/_chunks/Form-CCijSg3V.js.map +1 -0
- package/dist/_chunks/{History-DNQkXANT.js → History-BMndx49M.js} +42 -100
- package/dist/_chunks/History-BMndx49M.js.map +1 -0
- package/dist/_chunks/{History-wrnHqf09.mjs → History-D8F7aYQU.mjs} +43 -100
- package/dist/_chunks/History-D8F7aYQU.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-CUQxfpjT.js → ListConfigurationPage-DouY1EWM.js} +19 -9
- package/dist/_chunks/ListConfigurationPage-DouY1EWM.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DScmJVkW.mjs → ListConfigurationPage-DqAdSPwC.mjs} +19 -8
- package/dist/_chunks/ListConfigurationPage-DqAdSPwC.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-BsLiH2-2.js → ListViewPage-BPVmh9pq.js} +109 -78
- package/dist/_chunks/ListViewPage-BPVmh9pq.js.map +1 -0
- package/dist/_chunks/{ListViewPage-C4IvrMgY.mjs → ListViewPage-C73F0jPh.mjs} +106 -74
- package/dist/_chunks/ListViewPage-C73F0jPh.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-Djg8nPlj.mjs → NoContentTypePage-B5w7iJOF.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-Djg8nPlj.mjs.map → NoContentTypePage-B5w7iJOF.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-BZ-PnGAf.js → NoContentTypePage-BwcL--4H.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-BZ-PnGAf.js.map → NoContentTypePage-BwcL--4H.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-_lUqjGW3.js → NoPermissionsPage-BMFKVcwJ.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-_lUqjGW3.js.map → NoPermissionsPage-BMFKVcwJ.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DSP7R-hv.mjs → NoPermissionsPage-UnEgMGK4.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DSP7R-hv.mjs.map → NoPermissionsPage-UnEgMGK4.mjs.map} +1 -1
- package/dist/_chunks/Preview-B7PR3Ok_.js +312 -0
- package/dist/_chunks/Preview-B7PR3Ok_.js.map +1 -0
- package/dist/_chunks/Preview-DECOhK0D.mjs +294 -0
- package/dist/_chunks/Preview-DECOhK0D.mjs.map +1 -0
- package/dist/_chunks/{Relations-BZr8tL0R.mjs → Relations-DinMQJ4B.mjs} +76 -42
- package/dist/_chunks/Relations-DinMQJ4B.mjs.map +1 -0
- package/dist/_chunks/{Relations-CtELXYIK.js → Relations-lndx3aQk.js} +76 -43
- package/dist/_chunks/Relations-lndx3aQk.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-c_5DdJi-.mjs → index-C2SagWVW.mjs} +1107 -777
- package/dist/_chunks/index-C2SagWVW.mjs.map +1 -0
- package/dist/_chunks/{index-OerGjbAN.js → index-Cnw4gqee.js} +1089 -759
- package/dist/_chunks/index-Cnw4gqee.js.map +1 -0
- package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
- package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
- package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
- package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
- package/dist/_chunks/{layout-oPBiO7RY.mjs → layout-DY_D9MGA.mjs} +23 -10
- package/dist/_chunks/layout-DY_D9MGA.mjs.map +1 -0
- package/dist/_chunks/{layout-Ci7qHlFb.js → layout-ivwIVPnV.js} +23 -11
- package/dist/_chunks/layout-ivwIVPnV.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-COBpStiF.js → relations-B7C7O_Pv.js} +6 -7
- package/dist/_chunks/relations-B7C7O_Pv.js.map +1 -0
- package/dist/_chunks/{relations-BIdWFjdq.mjs → relations-Boc5Y9kX.mjs} +6 -7
- package/dist/_chunks/relations-Boc5Y9kX.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 +648 -333
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +649 -333
- 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 +16 -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 +4 -4
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +7 -6
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
- package/dist/server/src/preview/controllers/index.d.ts +2 -0
- package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/preview.d.ts +13 -0
- package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
- package/dist/server/src/preview/index.d.ts +4 -0
- package/dist/server/src/preview/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/index.d.ts +8 -0
- package/dist/server/src/preview/routes/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/preview.d.ts +4 -0
- package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
- package/dist/server/src/preview/services/index.d.ts +16 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts +32 -0
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview.d.ts +12 -0
- package/dist/server/src/preview/services/preview.d.ts.map +1 -0
- package/dist/server/src/preview/utils.d.ts +19 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -0
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +12 -10
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +7 -6
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/permission-checker.d.ts.map +1 -1
- package/dist/server/src/services/utils/populate.d.ts +2 -2
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts +2 -0
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/shared/contracts/collection-types.d.ts +3 -1
- package/dist/shared/contracts/collection-types.d.ts.map +1 -1
- package/dist/shared/contracts/index.d.ts +1 -0
- package/dist/shared/contracts/index.d.ts.map +1 -1
- package/dist/shared/contracts/preview.d.ts +27 -0
- package/dist/shared/contracts/preview.d.ts.map +1 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +4 -0
- package/dist/shared/index.mjs.map +1 -1
- package/package.json +17 -15
- package/dist/_chunks/EditViewPage-BLsjc5F-.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-C-ukDOB7.js.map +0 -1
- package/dist/_chunks/Field-Bfph5SOd.js.map +0 -1
- package/dist/_chunks/Field-Cs7duwWd.mjs.map +0 -1
- package/dist/_chunks/Form-CPYqIWDG.js.map +0 -1
- package/dist/_chunks/Form-Dg_GS5TQ.mjs.map +0 -1
- package/dist/_chunks/History-DNQkXANT.js.map +0 -1
- package/dist/_chunks/History-wrnHqf09.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-CUQxfpjT.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DScmJVkW.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-BsLiH2-2.js.map +0 -1
- package/dist/_chunks/ListViewPage-C4IvrMgY.mjs.map +0 -1
- package/dist/_chunks/Relations-BZr8tL0R.mjs.map +0 -1
- package/dist/_chunks/Relations-CtELXYIK.js.map +0 -1
- package/dist/_chunks/index-OerGjbAN.js.map +0 -1
- package/dist/_chunks/index-c_5DdJi-.mjs.map +0 -1
- package/dist/_chunks/layout-Ci7qHlFb.js.map +0 -1
- package/dist/_chunks/layout-oPBiO7RY.mjs.map +0 -1
- package/dist/_chunks/relations-BIdWFjdq.mjs.map +0 -1
- package/dist/_chunks/relations-COBpStiF.js.map +0 -1
- package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
- package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
- package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
- package/strapi-server.js +0 -3
@@ -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,11 +302,12 @@ 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) => {
|
287
309
|
return [
|
310
|
+
{ type: "Document", id: `ALL_LIST` },
|
288
311
|
{ type: "Document", id: `${arg.model}_LIST` },
|
289
312
|
...result?.results.map(({ documentId }) => ({
|
290
313
|
type: "Document",
|
@@ -323,6 +346,11 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
323
346
|
{
|
324
347
|
type: "Document",
|
325
348
|
id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
|
349
|
+
},
|
350
|
+
// Make it easy to invalidate all individual documents queries for a model
|
351
|
+
{
|
352
|
+
type: "Document",
|
353
|
+
id: `${model}_ALL_ITEMS`
|
326
354
|
}
|
327
355
|
];
|
328
356
|
}
|
@@ -386,7 +414,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
386
414
|
type: "Document",
|
387
415
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
388
416
|
},
|
389
|
-
"Relations"
|
417
|
+
"Relations",
|
418
|
+
{ type: "UidAvailability", id: model }
|
390
419
|
];
|
391
420
|
},
|
392
421
|
async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
|
@@ -452,8 +481,7 @@ const {
|
|
452
481
|
useUnpublishManyDocumentsMutation
|
453
482
|
} = documentApi;
|
454
483
|
const buildValidParams = (query) => {
|
455
|
-
if (!query)
|
456
|
-
return query;
|
484
|
+
if (!query) return query;
|
457
485
|
const { plugins: _, ...validQueryParams } = {
|
458
486
|
...query,
|
459
487
|
...Object.values(query?.plugins ?? {}).reduce(
|
@@ -461,28 +489,44 @@ const buildValidParams = (query) => {
|
|
461
489
|
{}
|
462
490
|
)
|
463
491
|
};
|
464
|
-
if ("_q" in validQueryParams) {
|
465
|
-
validQueryParams._q = encodeURIComponent(validQueryParams._q);
|
466
|
-
}
|
467
492
|
return validQueryParams;
|
468
493
|
};
|
469
494
|
const isBaseQueryError = (error) => {
|
470
495
|
return error.name !== void 0;
|
471
496
|
};
|
472
|
-
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 }) => {
|
473
516
|
const createModelSchema = (attributes2) => yup__namespace.object().shape(
|
474
517
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
475
518
|
if (DOCUMENT_META_FIELDS.includes(name)) {
|
476
519
|
return acc;
|
477
520
|
}
|
478
521
|
const validations = [
|
522
|
+
addNullableValidation,
|
479
523
|
addRequiredValidation,
|
480
524
|
addMinLengthValidation,
|
481
525
|
addMaxLengthValidation,
|
482
526
|
addMinValidation,
|
483
527
|
addMaxValidation,
|
484
528
|
addRegexValidation
|
485
|
-
].map((fn) => fn(attribute));
|
529
|
+
].map((fn) => fn(attribute, options));
|
486
530
|
const transformSchema = pipe__default.default(...validations);
|
487
531
|
switch (attribute.type) {
|
488
532
|
case "component": {
|
@@ -492,12 +536,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
492
536
|
...acc,
|
493
537
|
[name]: transformSchema(
|
494
538
|
yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
|
495
|
-
)
|
539
|
+
).test(arrayValidator(attribute, options))
|
496
540
|
};
|
497
541
|
} else {
|
498
542
|
return {
|
499
543
|
...acc,
|
500
|
-
[name]: transformSchema(createModelSchema(attributes3))
|
544
|
+
[name]: transformSchema(createModelSchema(attributes3).nullable())
|
501
545
|
};
|
502
546
|
}
|
503
547
|
}
|
@@ -519,7 +563,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
519
563
|
}
|
520
564
|
)
|
521
565
|
)
|
522
|
-
)
|
566
|
+
).test(arrayValidator(attribute, options))
|
523
567
|
};
|
524
568
|
case "relation":
|
525
569
|
return {
|
@@ -531,7 +575,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
531
575
|
} else if (Array.isArray(value)) {
|
532
576
|
return yup__namespace.array().of(
|
533
577
|
yup__namespace.object().shape({
|
534
|
-
id: yup__namespace.
|
578
|
+
id: yup__namespace.number().required()
|
535
579
|
})
|
536
580
|
);
|
537
581
|
} else if (typeof value === "object") {
|
@@ -583,6 +627,14 @@ const createAttributeSchema = (attribute) => {
|
|
583
627
|
if (!value || typeof value === "string" && value.length === 0) {
|
584
628
|
return true;
|
585
629
|
}
|
630
|
+
if (typeof value === "object") {
|
631
|
+
try {
|
632
|
+
JSON.stringify(value);
|
633
|
+
return true;
|
634
|
+
} catch (err) {
|
635
|
+
return false;
|
636
|
+
}
|
637
|
+
}
|
586
638
|
try {
|
587
639
|
JSON.parse(value);
|
588
640
|
return true;
|
@@ -601,13 +653,7 @@ const createAttributeSchema = (attribute) => {
|
|
601
653
|
return yup__namespace.mixed();
|
602
654
|
}
|
603
655
|
};
|
604
|
-
const
|
605
|
-
if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
|
606
|
-
return schema.min(1, strapiAdmin.translatedErrors.required);
|
607
|
-
}
|
608
|
-
if (attribute.required && attribute.type !== "relation") {
|
609
|
-
return schema.required(strapiAdmin.translatedErrors.required);
|
610
|
-
}
|
656
|
+
const nullableSchema = (schema) => {
|
611
657
|
return schema?.nullable ? schema.nullable() : (
|
612
658
|
// In some cases '.nullable' will not be available on the schema.
|
613
659
|
// e.g. when the schema has been built using yup.lazy (e.g. for relations).
|
@@ -615,7 +661,22 @@ const addRequiredValidation = (attribute) => (schema) => {
|
|
615
661
|
schema
|
616
662
|
);
|
617
663
|
};
|
618
|
-
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
|
+
}
|
619
680
|
if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
|
620
681
|
return schema.min(attribute.minLength, {
|
621
682
|
...strapiAdmin.translatedErrors.minLength,
|
@@ -637,32 +698,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
637
698
|
}
|
638
699
|
return schema;
|
639
700
|
};
|
640
|
-
const addMinValidation = (attribute) => (schema) => {
|
641
|
-
if ("
|
701
|
+
const addMinValidation = (attribute, options) => (schema) => {
|
702
|
+
if (options.status === "draft") {
|
703
|
+
return schema;
|
704
|
+
}
|
705
|
+
if ("min" in attribute && "min" in schema) {
|
642
706
|
const min = toInteger(attribute.min);
|
643
|
-
if (
|
644
|
-
if (!attribute.required && "test" in schema && min) {
|
645
|
-
return schema.test(
|
646
|
-
"custom-min",
|
647
|
-
{
|
648
|
-
...strapiAdmin.translatedErrors.min,
|
649
|
-
values: {
|
650
|
-
min: attribute.min
|
651
|
-
}
|
652
|
-
},
|
653
|
-
(value) => {
|
654
|
-
if (!value) {
|
655
|
-
return true;
|
656
|
-
}
|
657
|
-
if (Array.isArray(value) && value.length === 0) {
|
658
|
-
return true;
|
659
|
-
}
|
660
|
-
return value.length >= min;
|
661
|
-
}
|
662
|
-
);
|
663
|
-
}
|
664
|
-
}
|
665
|
-
if ("min" in schema && min) {
|
707
|
+
if (min) {
|
666
708
|
return schema.min(min, {
|
667
709
|
...strapiAdmin.translatedErrors.min,
|
668
710
|
values: {
|
@@ -780,19 +822,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
|
|
780
822
|
}, {});
|
781
823
|
return componentsByKey;
|
782
824
|
};
|
783
|
-
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);
|
784
924
|
const { toggleNotification } = strapiAdmin.useNotification();
|
785
925
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
926
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
786
927
|
const {
|
787
|
-
|
788
|
-
isLoading:
|
789
|
-
|
790
|
-
|
791
|
-
} =
|
792
|
-
|
793
|
-
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
794
|
-
});
|
795
|
-
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;
|
796
934
|
React__namespace.useEffect(() => {
|
797
935
|
if (error) {
|
798
936
|
toggleNotification({
|
@@ -800,83 +938,339 @@ const useDocument = (args, opts) => {
|
|
800
938
|
message: formatAPIError(error)
|
801
939
|
});
|
802
940
|
}
|
803
|
-
}, [
|
804
|
-
const
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
(document) => {
|
812
|
-
if (!validationSchema) {
|
813
|
-
throw new Error(
|
814
|
-
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
815
|
-
);
|
816
|
-
}
|
817
|
-
try {
|
818
|
-
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
819
|
-
return null;
|
820
|
-
} catch (error2) {
|
821
|
-
if (error2 instanceof yup.ValidationError) {
|
822
|
-
return strapiAdmin.getYupValidationErrors(error2);
|
823
|
-
}
|
824
|
-
throw error2;
|
825
|
-
}
|
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
|
826
949
|
},
|
827
|
-
[
|
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]
|
828
966
|
);
|
829
|
-
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
830
967
|
return {
|
831
|
-
|
832
|
-
document: data?.data,
|
833
|
-
meta: data?.meta,
|
968
|
+
error,
|
834
969
|
isLoading,
|
835
|
-
|
836
|
-
|
837
|
-
};
|
838
|
-
};
|
839
|
-
const useDoc = () => {
|
840
|
-
const { id, slug, collectionType, origin } = reactRouterDom.useParams();
|
841
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
842
|
-
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
843
|
-
if (!collectionType) {
|
844
|
-
throw new Error("Could not find collectionType in url params");
|
845
|
-
}
|
846
|
-
if (!slug) {
|
847
|
-
throw new Error("Could not find model in url params");
|
848
|
-
}
|
849
|
-
return {
|
850
|
-
collectionType,
|
851
|
-
model: slug,
|
852
|
-
id: origin || id === "create" ? void 0 : id,
|
853
|
-
...useDocument(
|
854
|
-
{ documentId: origin || id, model: slug, collectionType, params },
|
855
|
-
{
|
856
|
-
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
857
|
-
}
|
858
|
-
)
|
970
|
+
edit,
|
971
|
+
list: listLayout
|
859
972
|
};
|
860
973
|
};
|
861
|
-
const
|
862
|
-
|
863
|
-
|
864
|
-
}
|
865
|
-
return Object.keys(trad).reduce((acc, current) => {
|
866
|
-
acc[`${pluginId}.${current}`] = trad[current];
|
867
|
-
return acc;
|
868
|
-
}, {});
|
869
|
-
};
|
870
|
-
const getTranslation = (id) => `content-manager.${id}`;
|
871
|
-
const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
872
|
-
id: "notification.error",
|
873
|
-
defaultMessage: "An error occurred, please try again"
|
974
|
+
const useDocLayout = () => {
|
975
|
+
const { model } = useDoc();
|
976
|
+
return useDocumentLayout(model);
|
874
977
|
};
|
875
|
-
const
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
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);
|
999
|
+
}
|
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
|
1016
|
+
}
|
1017
|
+
};
|
1018
|
+
return acc;
|
1019
|
+
},
|
1020
|
+
{}
|
1021
|
+
);
|
1022
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1023
|
+
(acc, [attribute, metadata]) => {
|
1024
|
+
return {
|
1025
|
+
...acc,
|
1026
|
+
[attribute]: metadata.edit
|
1027
|
+
};
|
1028
|
+
},
|
1029
|
+
{}
|
1030
|
+
);
|
1031
|
+
return {
|
1032
|
+
layout: panelledEditAttributes,
|
1033
|
+
components: componentEditAttributes,
|
1034
|
+
metadatas: editMetadatas,
|
1035
|
+
settings: {
|
1036
|
+
...data.contentType.settings,
|
1037
|
+
displayName: schema?.info.displayName
|
1038
|
+
},
|
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;
|
1052
|
+
}
|
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)
|
1074
|
+
);
|
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
|
+
}
|
1168
|
+
try {
|
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);
|
1174
|
+
}
|
1175
|
+
throw error2;
|
1176
|
+
}
|
1177
|
+
},
|
1178
|
+
[validationSchema]
|
1179
|
+
);
|
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);
|
880
1274
|
const [deleteDocument] = useDeleteDocumentMutation();
|
881
1275
|
const _delete = React__namespace.useCallback(
|
882
1276
|
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
@@ -1191,6 +1585,7 @@ const useDocumentActions = () => {
|
|
1191
1585
|
defaultMessage: "Saved document"
|
1192
1586
|
})
|
1193
1587
|
});
|
1588
|
+
setCurrentStep("contentManager.success");
|
1194
1589
|
return res.data;
|
1195
1590
|
} catch (err) {
|
1196
1591
|
toggleNotification({
|
@@ -1230,7 +1625,7 @@ const useDocumentActions = () => {
|
|
1230
1625
|
throw err;
|
1231
1626
|
}
|
1232
1627
|
},
|
1233
|
-
[autoCloneDocument,
|
1628
|
+
[autoCloneDocument, formatMessage, toggleNotification]
|
1234
1629
|
);
|
1235
1630
|
const [cloneDocument] = useCloneDocumentMutation();
|
1236
1631
|
const clone = React__namespace.useCallback(
|
@@ -1256,6 +1651,7 @@ const useDocumentActions = () => {
|
|
1256
1651
|
defaultMessage: "Cloned document"
|
1257
1652
|
})
|
1258
1653
|
});
|
1654
|
+
navigate(`../../${res.data.data.documentId}`, { relative: "path" });
|
1259
1655
|
return res.data;
|
1260
1656
|
} catch (err) {
|
1261
1657
|
toggleNotification({
|
@@ -1266,7 +1662,7 @@ const useDocumentActions = () => {
|
|
1266
1662
|
throw err;
|
1267
1663
|
}
|
1268
1664
|
},
|
1269
|
-
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
|
1665
|
+
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
|
1270
1666
|
);
|
1271
1667
|
const [getDoc] = useLazyGetDocumentQuery();
|
1272
1668
|
const getDocument = React__namespace.useCallback(
|
@@ -1291,10 +1687,10 @@ const useDocumentActions = () => {
|
|
1291
1687
|
update
|
1292
1688
|
};
|
1293
1689
|
};
|
1294
|
-
const ProtectedHistoryPage =
|
1295
|
-
() => Promise.resolve().then(() => require("./History-
|
1690
|
+
const ProtectedHistoryPage = React__namespace.lazy(
|
1691
|
+
() => Promise.resolve().then(() => require("./History-BMndx49M.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1296
1692
|
);
|
1297
|
-
const routes$
|
1693
|
+
const routes$2 = [
|
1298
1694
|
{
|
1299
1695
|
path: ":collectionType/:slug/:id/history",
|
1300
1696
|
Component: ProtectedHistoryPage
|
@@ -1304,32 +1700,45 @@ const routes$1 = [
|
|
1304
1700
|
Component: ProtectedHistoryPage
|
1305
1701
|
}
|
1306
1702
|
];
|
1307
|
-
const
|
1308
|
-
() => Promise.resolve().then(() => require("./
|
1703
|
+
const ProtectedPreviewPage = React__namespace.lazy(
|
1704
|
+
() => Promise.resolve().then(() => require("./Preview-B7PR3Ok_.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
|
+
];
|
1716
|
+
const ProtectedEditViewPage = React.lazy(
|
1717
|
+
() => Promise.resolve().then(() => require("./EditViewPage-DT6A4ayX.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1309
1718
|
);
|
1310
1719
|
const ProtectedListViewPage = React.lazy(
|
1311
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1720
|
+
() => Promise.resolve().then(() => require("./ListViewPage-BPVmh9pq.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1312
1721
|
);
|
1313
1722
|
const ProtectedListConfiguration = React.lazy(
|
1314
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1723
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-DouY1EWM.js")).then((mod) => ({
|
1315
1724
|
default: mod.ProtectedListConfiguration
|
1316
1725
|
}))
|
1317
1726
|
);
|
1318
1727
|
const ProtectedEditConfigurationPage = React.lazy(
|
1319
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1728
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-uy-v43AR.js")).then((mod) => ({
|
1320
1729
|
default: mod.ProtectedEditConfigurationPage
|
1321
1730
|
}))
|
1322
1731
|
);
|
1323
1732
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1324
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1733
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-BlzvDpbX.js")).then((mod) => ({
|
1325
1734
|
default: mod.ProtectedComponentConfigurationPage
|
1326
1735
|
}))
|
1327
1736
|
);
|
1328
1737
|
const NoPermissions = React.lazy(
|
1329
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1738
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-BMFKVcwJ.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1330
1739
|
);
|
1331
1740
|
const NoContentType = React.lazy(
|
1332
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1741
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-BwcL--4H.js")).then((mod) => ({ default: mod.NoContentType }))
|
1333
1742
|
);
|
1334
1743
|
const CollectionTypePages = () => {
|
1335
1744
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1341,7 +1750,7 @@ const CollectionTypePages = () => {
|
|
1341
1750
|
const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
|
1342
1751
|
const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
|
1343
1752
|
const LIST_RELATIVE_PATH = ":collectionType/:slug";
|
1344
|
-
const LIST_PATH = `/content-manager
|
1753
|
+
const LIST_PATH = `/content-manager/collection-types/:slug`;
|
1345
1754
|
const routes = [
|
1346
1755
|
{
|
1347
1756
|
path: LIST_RELATIVE_PATH,
|
@@ -1375,6 +1784,7 @@ const routes = [
|
|
1375
1784
|
path: "no-content-types",
|
1376
1785
|
Component: NoContentType
|
1377
1786
|
},
|
1787
|
+
...routes$2,
|
1378
1788
|
...routes$1
|
1379
1789
|
];
|
1380
1790
|
const DocumentActions = ({ actions: actions2 }) => {
|
@@ -1443,12 +1853,14 @@ const DocumentActionButton = (action) => {
|
|
1443
1853
|
/* @__PURE__ */ jsxRuntime.jsx(
|
1444
1854
|
designSystem.Button,
|
1445
1855
|
{
|
1446
|
-
flex:
|
1856
|
+
flex: "auto",
|
1447
1857
|
startIcon: action.icon,
|
1448
1858
|
disabled: action.disabled,
|
1449
1859
|
onClick: handleClick(action),
|
1450
1860
|
justifyContent: "center",
|
1451
1861
|
variant: action.variant || "default",
|
1862
|
+
paddingTop: "7px",
|
1863
|
+
paddingBottom: "7px",
|
1452
1864
|
children: action.label
|
1453
1865
|
}
|
1454
1866
|
),
|
@@ -1471,6 +1883,11 @@ const DocumentActionButton = (action) => {
|
|
1471
1883
|
) : null
|
1472
1884
|
] });
|
1473
1885
|
};
|
1886
|
+
const MenuItem = styledComponents.styled(designSystem.Menu.Item)`
|
1887
|
+
&:hover {
|
1888
|
+
background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
|
1889
|
+
}
|
1890
|
+
`;
|
1474
1891
|
const DocumentActionsMenu = ({
|
1475
1892
|
actions: actions2,
|
1476
1893
|
children,
|
@@ -1513,9 +1930,9 @@ const DocumentActionsMenu = ({
|
|
1513
1930
|
disabled: isDisabled,
|
1514
1931
|
size: "S",
|
1515
1932
|
endIcon: null,
|
1516
|
-
paddingTop: "
|
1517
|
-
paddingLeft: "
|
1518
|
-
paddingRight: "
|
1933
|
+
paddingTop: "4px",
|
1934
|
+
paddingLeft: "7px",
|
1935
|
+
paddingRight: "7px",
|
1519
1936
|
variant,
|
1520
1937
|
children: [
|
1521
1938
|
/* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
|
@@ -1526,36 +1943,35 @@ const DocumentActionsMenu = ({
|
|
1526
1943
|
]
|
1527
1944
|
}
|
1528
1945
|
),
|
1529
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, {
|
1946
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
|
1530
1947
|
actions2.map((action) => {
|
1531
1948
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
1532
|
-
|
1949
|
+
MenuItem,
|
1533
1950
|
{
|
1534
1951
|
disabled: action.disabled,
|
1535
1952
|
onSelect: handleClick(action),
|
1536
1953
|
display: "block",
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
] })
|
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
|
+
) })
|
1559
1975
|
},
|
1560
1976
|
action.id
|
1561
1977
|
);
|
@@ -1635,11 +2051,11 @@ const DocumentActionConfirmDialog = ({
|
|
1635
2051
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
1636
2052
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
|
1637
2053
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
1638
|
-
/* @__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({
|
1639
2055
|
id: "app.components.Button.cancel",
|
1640
2056
|
defaultMessage: "Cancel"
|
1641
2057
|
}) }) }),
|
1642
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
|
2058
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
|
1643
2059
|
id: "app.components.Button.confirm",
|
1644
2060
|
defaultMessage: "Confirm"
|
1645
2061
|
}) })
|
@@ -1666,6 +2082,18 @@ const DocumentActionModal = ({
|
|
1666
2082
|
typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
|
1667
2083
|
] }) });
|
1668
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
|
+
};
|
1669
2097
|
const PublishAction$1 = ({
|
1670
2098
|
activeTab,
|
1671
2099
|
documentId,
|
@@ -1678,12 +2106,11 @@ const PublishAction$1 = ({
|
|
1678
2106
|
const navigate = reactRouterDom.useNavigate();
|
1679
2107
|
const { toggleNotification } = strapiAdmin.useNotification();
|
1680
2108
|
const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
|
2109
|
+
const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
|
1681
2110
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2111
|
+
const { id } = reactRouterDom.useParams();
|
1682
2112
|
const { formatMessage } = reactIntl.useIntl();
|
1683
|
-
const { canPublish
|
1684
|
-
"PublishAction",
|
1685
|
-
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1686
|
-
);
|
2113
|
+
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
1687
2114
|
const { publish } = useDocumentActions();
|
1688
2115
|
const [
|
1689
2116
|
countDraftRelations,
|
@@ -1735,24 +2162,25 @@ const PublishAction$1 = ({
|
|
1735
2162
|
}
|
1736
2163
|
}, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
|
1737
2164
|
React__namespace.useEffect(() => {
|
1738
|
-
if (documentId) {
|
1739
|
-
|
1740
|
-
const { data, error } = await countDraftRelations({
|
1741
|
-
collectionType,
|
1742
|
-
model,
|
1743
|
-
documentId,
|
1744
|
-
params
|
1745
|
-
});
|
1746
|
-
if (error) {
|
1747
|
-
throw error;
|
1748
|
-
}
|
1749
|
-
if (data) {
|
1750
|
-
setServerCountOfDraftRelations(data.data);
|
1751
|
-
}
|
1752
|
-
};
|
1753
|
-
fetchDraftRelationsCount();
|
2165
|
+
if (!document || !document.documentId || isListView) {
|
2166
|
+
return;
|
1754
2167
|
}
|
1755
|
-
|
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]);
|
1756
2184
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1757
2185
|
if (!schema?.options?.draftAndPublish) {
|
1758
2186
|
return null;
|
@@ -1760,7 +2188,9 @@ const PublishAction$1 = ({
|
|
1760
2188
|
const performPublish = async () => {
|
1761
2189
|
setSubmitting(true);
|
1762
2190
|
try {
|
1763
|
-
const { errors } = await validate(
|
2191
|
+
const { errors } = await validate(true, {
|
2192
|
+
status: "published"
|
2193
|
+
});
|
1764
2194
|
if (errors) {
|
1765
2195
|
toggleNotification({
|
1766
2196
|
type: "danger",
|
@@ -1778,13 +2208,15 @@ const PublishAction$1 = ({
|
|
1778
2208
|
documentId,
|
1779
2209
|
params
|
1780
2210
|
},
|
1781
|
-
formValues
|
2211
|
+
transformData(formValues)
|
1782
2212
|
);
|
1783
2213
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
2214
|
+
if (id === "create") {
|
2215
|
+
navigate({
|
2216
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
2217
|
+
search: rawQuery
|
2218
|
+
});
|
2219
|
+
}
|
1788
2220
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1789
2221
|
setErrors(formatValidationErrors(res.error));
|
1790
2222
|
}
|
@@ -1793,7 +2225,8 @@ const PublishAction$1 = ({
|
|
1793
2225
|
}
|
1794
2226
|
};
|
1795
2227
|
const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
|
1796
|
-
const
|
2228
|
+
const enableDraftRelationsCount = false;
|
2229
|
+
const hasDraftRelations = enableDraftRelationsCount;
|
1797
2230
|
return {
|
1798
2231
|
/**
|
1799
2232
|
* Disabled when:
|
@@ -1803,18 +2236,13 @@ const PublishAction$1 = ({
|
|
1803
2236
|
* - the document is already published & not modified
|
1804
2237
|
* - the document is being created & not modified
|
1805
2238
|
* - the user doesn't have the permission to publish
|
1806
|
-
* - the user doesn't have the permission to create a new document
|
1807
|
-
* - the user doesn't have the permission to update the document
|
1808
2239
|
*/
|
1809
|
-
disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish
|
2240
|
+
disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
|
1810
2241
|
label: formatMessage({
|
1811
2242
|
id: "app.utils.publish",
|
1812
2243
|
defaultMessage: "Publish"
|
1813
2244
|
}),
|
1814
2245
|
onClick: async () => {
|
1815
|
-
if (hasDraftRelations) {
|
1816
|
-
return;
|
1817
|
-
}
|
1818
2246
|
await performPublish();
|
1819
2247
|
},
|
1820
2248
|
dialog: hasDraftRelations ? {
|
@@ -1841,6 +2269,7 @@ const PublishAction$1 = ({
|
|
1841
2269
|
};
|
1842
2270
|
};
|
1843
2271
|
PublishAction$1.type = "publish";
|
2272
|
+
PublishAction$1.position = "panel";
|
1844
2273
|
const UpdateAction = ({
|
1845
2274
|
activeTab,
|
1846
2275
|
documentId,
|
@@ -1853,10 +2282,6 @@ const UpdateAction = ({
|
|
1853
2282
|
const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
|
1854
2283
|
const isCloning = cloneMatch !== null;
|
1855
2284
|
const { formatMessage } = reactIntl.useIntl();
|
1856
|
-
const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
|
1857
|
-
canCreate: canCreate2,
|
1858
|
-
canUpdate: canUpdate2
|
1859
|
-
}));
|
1860
2285
|
const { create, update, clone } = useDocumentActions();
|
1861
2286
|
const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
|
1862
2287
|
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
@@ -1867,96 +2292,134 @@ const UpdateAction = ({
|
|
1867
2292
|
const validate = strapiAdmin.useForm("UpdateAction", (state) => state.validate);
|
1868
2293
|
const setErrors = strapiAdmin.useForm("UpdateAction", (state) => state.setErrors);
|
1869
2294
|
const resetForm = strapiAdmin.useForm("PublishAction", ({ resetForm: resetForm2 }) => resetForm2);
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1895
|
-
}
|
1896
|
-
|
1897
|
-
|
1898
|
-
if (
|
1899
|
-
|
1900
|
-
{
|
1901
|
-
model,
|
1902
|
-
documentId: cloneMatch.params.origin,
|
1903
|
-
params
|
1904
|
-
},
|
1905
|
-
document
|
1906
|
-
);
|
1907
|
-
if ("data" in res) {
|
1908
|
-
navigate(
|
1909
|
-
{
|
1910
|
-
pathname: `../${res.data.documentId}`,
|
1911
|
-
search: rawQuery
|
1912
|
-
},
|
1913
|
-
{ relative: "path" }
|
1914
|
-
);
|
1915
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1916
|
-
setErrors(formatValidationErrors(res.error));
|
1917
|
-
}
|
1918
|
-
} else if (documentId || collectionType === SINGLE_TYPES) {
|
1919
|
-
const res = await update(
|
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(
|
1920
2325
|
{
|
1921
|
-
|
1922
|
-
|
1923
|
-
documentId,
|
1924
|
-
params
|
2326
|
+
pathname: `../${res.data.documentId}`,
|
2327
|
+
search: rawQuery
|
1925
2328
|
},
|
1926
|
-
|
2329
|
+
{ relative: "path" }
|
1927
2330
|
);
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
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));
|
1933
2346
|
} else {
|
1934
|
-
|
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(
|
1935
2359
|
{
|
1936
|
-
|
1937
|
-
|
2360
|
+
pathname: `../${res.data.documentId}`,
|
2361
|
+
search: rawQuery
|
1938
2362
|
},
|
1939
|
-
|
2363
|
+
{ replace: true, relative: "path" }
|
1940
2364
|
);
|
1941
|
-
|
1942
|
-
|
1943
|
-
{
|
1944
|
-
pathname: `../${res.data.documentId}`,
|
1945
|
-
search: rawQuery
|
1946
|
-
},
|
1947
|
-
{ replace: true, relative: "path" }
|
1948
|
-
);
|
1949
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1950
|
-
setErrors(formatValidationErrors(res.error));
|
1951
|
-
}
|
2365
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2366
|
+
setErrors(formatValidationErrors(res.error));
|
1952
2367
|
}
|
1953
|
-
} finally {
|
1954
|
-
setSubmitting(false);
|
1955
2368
|
}
|
2369
|
+
} finally {
|
2370
|
+
setSubmitting(false);
|
1956
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]);
|
2406
|
+
return {
|
2407
|
+
/**
|
2408
|
+
* Disabled when:
|
2409
|
+
* - the form is submitting
|
2410
|
+
* - the document is not modified & we're not cloning (you can save a clone entity straight away)
|
2411
|
+
* - the active tab is the published tab
|
2412
|
+
*/
|
2413
|
+
disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
|
2414
|
+
label: formatMessage({
|
2415
|
+
id: "global.save",
|
2416
|
+
defaultMessage: "Save"
|
2417
|
+
}),
|
2418
|
+
onClick: handleUpdate
|
1957
2419
|
};
|
1958
2420
|
};
|
1959
2421
|
UpdateAction.type = "update";
|
2422
|
+
UpdateAction.position = "panel";
|
1960
2423
|
const UNPUBLISH_DRAFT_OPTIONS = {
|
1961
2424
|
KEEP: "keep",
|
1962
2425
|
DISCARD: "discard"
|
@@ -1989,7 +2452,7 @@ const UnpublishAction$1 = ({
|
|
1989
2452
|
id: "app.utils.unpublish",
|
1990
2453
|
defaultMessage: "Unpublish"
|
1991
2454
|
}),
|
1992
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2455
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
|
1993
2456
|
onClick: async () => {
|
1994
2457
|
if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
|
1995
2458
|
if (!documentId) {
|
@@ -2079,6 +2542,7 @@ const UnpublishAction$1 = ({
|
|
2079
2542
|
};
|
2080
2543
|
};
|
2081
2544
|
UnpublishAction$1.type = "unpublish";
|
2545
|
+
UnpublishAction$1.position = "panel";
|
2082
2546
|
const DiscardAction = ({
|
2083
2547
|
activeTab,
|
2084
2548
|
documentId,
|
@@ -2101,7 +2565,7 @@ const DiscardAction = ({
|
|
2101
2565
|
id: "content-manager.actions.discard.label",
|
2102
2566
|
defaultMessage: "Discard changes"
|
2103
2567
|
}),
|
2104
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2568
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
|
2105
2569
|
position: ["panel", "table-row"],
|
2106
2570
|
variant: "danger",
|
2107
2571
|
dialog: {
|
@@ -2129,11 +2593,7 @@ const DiscardAction = ({
|
|
2129
2593
|
};
|
2130
2594
|
};
|
2131
2595
|
DiscardAction.type = "discard";
|
2132
|
-
|
2133
|
-
path {
|
2134
|
-
fill: currentColor;
|
2135
|
-
}
|
2136
|
-
`;
|
2596
|
+
DiscardAction.position = "panel";
|
2137
2597
|
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
2138
2598
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
2139
2599
|
const RelativeTime = React__namespace.forwardRef(
|
@@ -2146,7 +2606,7 @@ const RelativeTime = React__namespace.forwardRef(
|
|
2146
2606
|
});
|
2147
2607
|
const unit = intervals.find((intervalUnit) => {
|
2148
2608
|
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
|
2149
|
-
});
|
2609
|
+
}) ?? "seconds";
|
2150
2610
|
const relativeTime = dateFns.isPast(timestamp) ? -interval[unit] : interval[unit];
|
2151
2611
|
const customInterval = customIntervals.find(
|
2152
2612
|
(custom) => interval[custom.unit] < custom.threshold
|
@@ -2180,19 +2640,29 @@ const getDisplayName = ({
|
|
2180
2640
|
return email ?? "";
|
2181
2641
|
};
|
2182
2642
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2183
|
-
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2184
|
-
const statusVariant = status === "draft" ? "
|
2185
|
-
|
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
|
+
}) }) });
|
2186
2650
|
};
|
2187
2651
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
2188
2652
|
const { formatMessage } = reactIntl.useIntl();
|
2189
2653
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2654
|
+
const params = reactRouterDom.useParams();
|
2190
2655
|
const title = isCreating ? formatMessage({
|
2191
2656
|
id: "content-manager.containers.edit.title.new",
|
2192
2657
|
defaultMessage: "Create an entry"
|
2193
2658
|
}) : documentTitle;
|
2194
2659
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2195
|
-
/* @__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
|
+
),
|
2196
2666
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2197
2667
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2198
2668
|
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
@@ -2243,7 +2713,7 @@ const HeaderToolbar = () => {
|
|
2243
2713
|
meta: isCloning ? void 0 : meta,
|
2244
2714
|
collectionType
|
2245
2715
|
},
|
2246
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2716
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("header"),
|
2247
2717
|
children: (actions2) => {
|
2248
2718
|
const headerActions = actions2.filter((action) => {
|
2249
2719
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -2280,12 +2750,12 @@ const Information = ({ activeTab }) => {
|
|
2280
2750
|
isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
|
2281
2751
|
label: formatMessage({
|
2282
2752
|
id: "content-manager.containers.edit.information.last-published.label",
|
2283
|
-
defaultMessage: "
|
2753
|
+
defaultMessage: "Published"
|
2284
2754
|
}),
|
2285
2755
|
value: formatMessage(
|
2286
2756
|
{
|
2287
2757
|
id: "content-manager.containers.edit.information.last-published.value",
|
2288
|
-
defaultMessage: `
|
2758
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2289
2759
|
},
|
2290
2760
|
{
|
2291
2761
|
time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
|
@@ -2298,12 +2768,12 @@ const Information = ({ activeTab }) => {
|
|
2298
2768
|
isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
|
2299
2769
|
label: formatMessage({
|
2300
2770
|
id: "content-manager.containers.edit.information.last-draft.label",
|
2301
|
-
defaultMessage: "
|
2771
|
+
defaultMessage: "Updated"
|
2302
2772
|
}),
|
2303
2773
|
value: formatMessage(
|
2304
2774
|
{
|
2305
2775
|
id: "content-manager.containers.edit.information.last-draft.value",
|
2306
|
-
defaultMessage: `
|
2776
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2307
2777
|
},
|
2308
2778
|
{
|
2309
2779
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2321,12 +2791,12 @@ const Information = ({ activeTab }) => {
|
|
2321
2791
|
isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
|
2322
2792
|
label: formatMessage({
|
2323
2793
|
id: "content-manager.containers.edit.information.document.label",
|
2324
|
-
defaultMessage: "
|
2794
|
+
defaultMessage: "Created"
|
2325
2795
|
}),
|
2326
2796
|
value: formatMessage(
|
2327
2797
|
{
|
2328
2798
|
id: "content-manager.containers.edit.information.document.value",
|
2329
|
-
defaultMessage: `
|
2799
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2330
2800
|
},
|
2331
2801
|
{
|
2332
2802
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2364,25 +2834,77 @@ const Information = ({ activeTab }) => {
|
|
2364
2834
|
);
|
2365
2835
|
};
|
2366
2836
|
const HeaderActions = ({ actions: actions2 }) => {
|
2367
|
-
|
2368
|
-
|
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) {
|
2369
2853
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
2370
2854
|
designSystem.SingleSelect,
|
2371
2855
|
{
|
2372
2856
|
size: "S",
|
2373
|
-
disabled: action.disabled,
|
2374
|
-
"aria-label": action.label,
|
2375
2857
|
onChange: action.onSelect,
|
2376
|
-
|
2858
|
+
"aria-label": action.label,
|
2859
|
+
...action,
|
2377
2860
|
children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
|
2378
2861
|
},
|
2379
2862
|
action.id
|
2380
2863
|
);
|
2381
2864
|
} else {
|
2382
|
-
|
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
|
+
}
|
2383
2887
|
}
|
2384
2888
|
}) });
|
2385
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
|
+
};
|
2386
2908
|
const ConfigureTheViewAction = ({ collectionType, model }) => {
|
2387
2909
|
const navigate = reactRouterDom.useNavigate();
|
2388
2910
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2399,6 +2921,7 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
|
|
2399
2921
|
};
|
2400
2922
|
};
|
2401
2923
|
ConfigureTheViewAction.type = "configure-the-view";
|
2924
|
+
ConfigureTheViewAction.position = "header";
|
2402
2925
|
const EditTheModelAction = ({ model }) => {
|
2403
2926
|
const navigate = reactRouterDom.useNavigate();
|
2404
2927
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2415,6 +2938,7 @@ const EditTheModelAction = ({ model }) => {
|
|
2415
2938
|
};
|
2416
2939
|
};
|
2417
2940
|
EditTheModelAction.type = "edit-the-model";
|
2941
|
+
EditTheModelAction.position = "header";
|
2418
2942
|
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2419
2943
|
const navigate = reactRouterDom.useNavigate();
|
2420
2944
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2423,12 +2947,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2423
2947
|
const { delete: deleteAction } = useDocumentActions();
|
2424
2948
|
const { toggleNotification } = strapiAdmin.useNotification();
|
2425
2949
|
const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
|
2950
|
+
const isLocalized = document?.locale != null;
|
2426
2951
|
return {
|
2427
2952
|
disabled: !canDelete || !document,
|
2428
|
-
label: formatMessage(
|
2429
|
-
|
2430
|
-
|
2431
|
-
|
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
|
+
),
|
2432
2960
|
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
|
2433
2961
|
dialog: {
|
2434
2962
|
type: "dialog",
|
@@ -2470,417 +2998,116 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2470
2998
|
}
|
2471
2999
|
});
|
2472
3000
|
if (!("error" in res)) {
|
2473
|
-
navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
|
2474
|
-
}
|
2475
|
-
} finally {
|
2476
|
-
if (!listViewPathMatch) {
|
2477
|
-
setSubmitting(false);
|
2478
|
-
}
|
2479
|
-
}
|
2480
|
-
}
|
2481
|
-
},
|
2482
|
-
variant: "danger",
|
2483
|
-
position: ["header", "table-row"]
|
2484
|
-
};
|
2485
|
-
};
|
2486
|
-
DeleteAction$1.type = "delete";
|
2487
|
-
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2488
|
-
const Panels = () => {
|
2489
|
-
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2490
|
-
const [
|
2491
|
-
{
|
2492
|
-
query: { status }
|
2493
|
-
}
|
2494
|
-
] = strapiAdmin.useQueryParams({
|
2495
|
-
status: "draft"
|
2496
|
-
});
|
2497
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2498
|
-
const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
|
2499
|
-
const props = {
|
2500
|
-
activeTab: status,
|
2501
|
-
model,
|
2502
|
-
documentId: id,
|
2503
|
-
document: isCloning ? void 0 : document,
|
2504
|
-
meta: isCloning ? void 0 : meta,
|
2505
|
-
collectionType
|
2506
|
-
};
|
2507
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
2508
|
-
strapiAdmin.DescriptionComponentRenderer,
|
2509
|
-
{
|
2510
|
-
props,
|
2511
|
-
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
2512
|
-
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
|
2513
|
-
}
|
2514
|
-
) });
|
2515
|
-
};
|
2516
|
-
const ActionsPanel = () => {
|
2517
|
-
const { formatMessage } = reactIntl.useIntl();
|
2518
|
-
return {
|
2519
|
-
title: formatMessage({
|
2520
|
-
id: "content-manager.containers.edit.panels.default.title",
|
2521
|
-
defaultMessage: "Document"
|
2522
|
-
}),
|
2523
|
-
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2524
|
-
};
|
2525
|
-
};
|
2526
|
-
ActionsPanel.type = "actions";
|
2527
|
-
const ActionsPanelContent = () => {
|
2528
|
-
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2529
|
-
const [
|
2530
|
-
{
|
2531
|
-
query: { status = "draft" }
|
2532
|
-
}
|
2533
|
-
] = strapiAdmin.useQueryParams();
|
2534
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2535
|
-
const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
|
2536
|
-
const props = {
|
2537
|
-
activeTab: status,
|
2538
|
-
model,
|
2539
|
-
documentId: id,
|
2540
|
-
document: isCloning ? void 0 : document,
|
2541
|
-
meta: isCloning ? void 0 : meta,
|
2542
|
-
collectionType
|
2543
|
-
};
|
2544
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
|
2545
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
2546
|
-
strapiAdmin.DescriptionComponentRenderer,
|
2547
|
-
{
|
2548
|
-
props,
|
2549
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2550
|
-
children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
|
2551
|
-
}
|
2552
|
-
),
|
2553
|
-
/* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
2554
|
-
] });
|
2555
|
-
};
|
2556
|
-
const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
2557
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
2558
|
-
designSystem.Flex,
|
2559
|
-
{
|
2560
|
-
ref,
|
2561
|
-
tag: "aside",
|
2562
|
-
"aria-labelledby": "additional-information",
|
2563
|
-
background: "neutral0",
|
2564
|
-
borderColor: "neutral150",
|
2565
|
-
hasRadius: true,
|
2566
|
-
paddingBottom: 4,
|
2567
|
-
paddingLeft: 4,
|
2568
|
-
paddingRight: 4,
|
2569
|
-
paddingTop: 4,
|
2570
|
-
shadow: "tableShadow",
|
2571
|
-
gap: 3,
|
2572
|
-
direction: "column",
|
2573
|
-
justifyContent: "stretch",
|
2574
|
-
alignItems: "flex-start",
|
2575
|
-
children: [
|
2576
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
|
2577
|
-
children
|
2578
|
-
]
|
2579
|
-
}
|
2580
|
-
);
|
2581
|
-
});
|
2582
|
-
const HOOKS = {
|
2583
|
-
/**
|
2584
|
-
* Hook that allows to mutate the displayed headers of the list view table
|
2585
|
-
* @constant
|
2586
|
-
* @type {string}
|
2587
|
-
*/
|
2588
|
-
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
2589
|
-
/**
|
2590
|
-
* Hook that allows to mutate the CM's collection types links pre-set filters
|
2591
|
-
* @constant
|
2592
|
-
* @type {string}
|
2593
|
-
*/
|
2594
|
-
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
2595
|
-
/**
|
2596
|
-
* Hook that allows to mutate the CM's edit view layout
|
2597
|
-
* @constant
|
2598
|
-
* @type {string}
|
2599
|
-
*/
|
2600
|
-
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
2601
|
-
/**
|
2602
|
-
* Hook that allows to mutate the CM's single types links pre-set filters
|
2603
|
-
* @constant
|
2604
|
-
* @type {string}
|
2605
|
-
*/
|
2606
|
-
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
2607
|
-
};
|
2608
|
-
const contentTypesApi = contentManagerApi.injectEndpoints({
|
2609
|
-
endpoints: (builder) => ({
|
2610
|
-
getContentTypeConfiguration: builder.query({
|
2611
|
-
query: (uid) => ({
|
2612
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2613
|
-
method: "GET"
|
2614
|
-
}),
|
2615
|
-
transformResponse: (response) => response.data,
|
2616
|
-
providesTags: (_result, _error, uid) => [
|
2617
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2618
|
-
{ type: "ContentTypeSettings", id: "LIST" }
|
2619
|
-
]
|
2620
|
-
}),
|
2621
|
-
getAllContentTypeSettings: builder.query({
|
2622
|
-
query: () => "/content-manager/content-types-settings",
|
2623
|
-
transformResponse: (response) => response.data,
|
2624
|
-
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
2625
|
-
}),
|
2626
|
-
updateContentTypeConfiguration: builder.mutation({
|
2627
|
-
query: ({ uid, ...body }) => ({
|
2628
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2629
|
-
method: "PUT",
|
2630
|
-
data: body
|
2631
|
-
}),
|
2632
|
-
transformResponse: (response) => response.data,
|
2633
|
-
invalidatesTags: (_result, _error, { uid }) => [
|
2634
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2635
|
-
{ type: "ContentTypeSettings", id: "LIST" },
|
2636
|
-
// Is this necessary?
|
2637
|
-
{ type: "InitialData" }
|
2638
|
-
]
|
2639
|
-
})
|
2640
|
-
})
|
2641
|
-
});
|
2642
|
-
const {
|
2643
|
-
useGetContentTypeConfigurationQuery,
|
2644
|
-
useGetAllContentTypeSettingsQuery,
|
2645
|
-
useUpdateContentTypeConfigurationMutation
|
2646
|
-
} = contentTypesApi;
|
2647
|
-
const checkIfAttributeIsDisplayable = (attribute) => {
|
2648
|
-
const { type } = attribute;
|
2649
|
-
if (type === "relation") {
|
2650
|
-
return !attribute.relation.toLowerCase().includes("morph");
|
2651
|
-
}
|
2652
|
-
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
2653
|
-
};
|
2654
|
-
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
2655
|
-
if (!mainFieldName) {
|
2656
|
-
return void 0;
|
2657
|
-
}
|
2658
|
-
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
2659
|
-
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
2660
|
-
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2661
|
-
);
|
2662
|
-
return {
|
2663
|
-
name: mainFieldName,
|
2664
|
-
type: mainFieldType ?? "string"
|
2665
|
-
};
|
2666
|
-
};
|
2667
|
-
const DEFAULT_SETTINGS = {
|
2668
|
-
bulkable: false,
|
2669
|
-
filterable: false,
|
2670
|
-
searchable: false,
|
2671
|
-
pagination: false,
|
2672
|
-
defaultSortBy: "",
|
2673
|
-
defaultSortOrder: "asc",
|
2674
|
-
mainField: "id",
|
2675
|
-
pageSize: 10
|
2676
|
-
};
|
2677
|
-
const useDocumentLayout = (model) => {
|
2678
|
-
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
2679
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
2680
|
-
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
2681
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
2682
|
-
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
2683
|
-
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
2684
|
-
const {
|
2685
|
-
data,
|
2686
|
-
isLoading: isLoadingConfigs,
|
2687
|
-
error,
|
2688
|
-
isFetching: isFetchingConfigs
|
2689
|
-
} = useGetContentTypeConfigurationQuery(model);
|
2690
|
-
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
2691
|
-
React__namespace.useEffect(() => {
|
2692
|
-
if (error) {
|
2693
|
-
toggleNotification({
|
2694
|
-
type: "danger",
|
2695
|
-
message: formatAPIError(error)
|
2696
|
-
});
|
2697
|
-
}
|
2698
|
-
}, [error, formatAPIError, toggleNotification]);
|
2699
|
-
const editLayout = React__namespace.useMemo(
|
2700
|
-
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
2701
|
-
layout: [],
|
2702
|
-
components: {},
|
2703
|
-
metadatas: {},
|
2704
|
-
options: {},
|
2705
|
-
settings: DEFAULT_SETTINGS
|
2706
|
-
},
|
2707
|
-
[data, isLoading, schemas, schema, components]
|
2708
|
-
);
|
2709
|
-
const listLayout = React__namespace.useMemo(() => {
|
2710
|
-
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
2711
|
-
layout: [],
|
2712
|
-
metadatas: {},
|
2713
|
-
options: {},
|
2714
|
-
settings: DEFAULT_SETTINGS
|
2715
|
-
};
|
2716
|
-
}, [data, isLoading, schemas, schema, components]);
|
2717
|
-
const { layout: edit } = React__namespace.useMemo(
|
2718
|
-
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
2719
|
-
layout: editLayout,
|
2720
|
-
query
|
2721
|
-
}),
|
2722
|
-
[editLayout, query, runHookWaterfall]
|
2723
|
-
);
|
2724
|
-
return {
|
2725
|
-
error,
|
2726
|
-
isLoading,
|
2727
|
-
edit,
|
2728
|
-
list: listLayout
|
2729
|
-
};
|
2730
|
-
};
|
2731
|
-
const useDocLayout = () => {
|
2732
|
-
const { model } = useDoc();
|
2733
|
-
return useDocumentLayout(model);
|
2734
|
-
};
|
2735
|
-
const formatEditLayout = (data, {
|
2736
|
-
schemas,
|
2737
|
-
schema,
|
2738
|
-
components
|
2739
|
-
}) => {
|
2740
|
-
let currentPanelIndex = 0;
|
2741
|
-
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
2742
|
-
data.contentType.layouts.edit,
|
2743
|
-
schema?.attributes,
|
2744
|
-
data.contentType.metadatas,
|
2745
|
-
{ configurations: data.components, schemas: components },
|
2746
|
-
schemas
|
2747
|
-
).reduce((panels, row) => {
|
2748
|
-
if (row.some((field) => field.type === "dynamiczone")) {
|
2749
|
-
panels.push([row]);
|
2750
|
-
currentPanelIndex += 2;
|
2751
|
-
} else {
|
2752
|
-
if (!panels[currentPanelIndex]) {
|
2753
|
-
panels.push([]);
|
2754
|
-
}
|
2755
|
-
panels[currentPanelIndex].push(row);
|
2756
|
-
}
|
2757
|
-
return panels;
|
2758
|
-
}, []);
|
2759
|
-
const componentEditAttributes = Object.entries(data.components).reduce(
|
2760
|
-
(acc, [uid, configuration]) => {
|
2761
|
-
acc[uid] = {
|
2762
|
-
layout: convertEditLayoutToFieldLayouts(
|
2763
|
-
configuration.layouts.edit,
|
2764
|
-
components[uid].attributes,
|
2765
|
-
configuration.metadatas
|
2766
|
-
),
|
2767
|
-
settings: {
|
2768
|
-
...configuration.settings,
|
2769
|
-
icon: components[uid].info.icon,
|
2770
|
-
displayName: components[uid].info.displayName
|
3001
|
+
navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
|
3002
|
+
}
|
3003
|
+
} finally {
|
3004
|
+
if (!listViewPathMatch) {
|
3005
|
+
setSubmitting(false);
|
3006
|
+
}
|
2771
3007
|
}
|
2772
|
-
}
|
2773
|
-
return acc;
|
2774
|
-
},
|
2775
|
-
{}
|
2776
|
-
);
|
2777
|
-
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2778
|
-
(acc, [attribute, metadata]) => {
|
2779
|
-
return {
|
2780
|
-
...acc,
|
2781
|
-
[attribute]: metadata.edit
|
2782
|
-
};
|
2783
|
-
},
|
2784
|
-
{}
|
2785
|
-
);
|
2786
|
-
return {
|
2787
|
-
layout: panelledEditAttributes,
|
2788
|
-
components: componentEditAttributes,
|
2789
|
-
metadatas: editMetadatas,
|
2790
|
-
settings: {
|
2791
|
-
...data.contentType.settings,
|
2792
|
-
displayName: schema?.info.displayName
|
3008
|
+
}
|
2793
3009
|
},
|
2794
|
-
|
2795
|
-
|
2796
|
-
...schema?.pluginOptions,
|
2797
|
-
...data.contentType.options
|
2798
|
-
}
|
3010
|
+
variant: "danger",
|
3011
|
+
position: ["header", "table-row"]
|
2799
3012
|
};
|
2800
3013
|
};
|
2801
|
-
|
2802
|
-
|
2803
|
-
|
2804
|
-
|
2805
|
-
|
2806
|
-
|
2807
|
-
|
2808
|
-
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2812
|
-
|
2813
|
-
|
2814
|
-
|
2815
|
-
|
2816
|
-
|
2817
|
-
|
2818
|
-
|
2819
|
-
|
2820
|
-
|
2821
|
-
|
2822
|
-
|
2823
|
-
|
2824
|
-
|
2825
|
-
|
2826
|
-
|
2827
|
-
|
2828
|
-
|
2829
|
-
|
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
|
+
) });
|
2830
3044
|
};
|
2831
|
-
const
|
2832
|
-
|
2833
|
-
schema,
|
2834
|
-
components
|
2835
|
-
}) => {
|
2836
|
-
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2837
|
-
(acc, [attribute, metadata]) => {
|
2838
|
-
return {
|
2839
|
-
...acc,
|
2840
|
-
[attribute]: metadata.list
|
2841
|
-
};
|
2842
|
-
},
|
2843
|
-
{}
|
2844
|
-
);
|
2845
|
-
const listAttributes = convertListLayoutToFieldLayouts(
|
2846
|
-
data.contentType.layouts.list,
|
2847
|
-
schema?.attributes,
|
2848
|
-
listMetadatas,
|
2849
|
-
{ configurations: data.components, schemas: components },
|
2850
|
-
schemas
|
2851
|
-
);
|
3045
|
+
const ActionsPanel = () => {
|
3046
|
+
const { formatMessage } = reactIntl.useIntl();
|
2852
3047
|
return {
|
2853
|
-
|
2854
|
-
|
2855
|
-
|
2856
|
-
|
2857
|
-
|
2858
|
-
...schema?.pluginOptions,
|
2859
|
-
...data.contentType.options
|
2860
|
-
}
|
3048
|
+
title: formatMessage({
|
3049
|
+
id: "content-manager.containers.edit.panels.default.title",
|
3050
|
+
defaultMessage: "Entry"
|
3051
|
+
}),
|
3052
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2861
3053
|
};
|
2862
3054
|
};
|
2863
|
-
|
2864
|
-
|
2865
|
-
|
2866
|
-
|
2867
|
-
|
3055
|
+
ActionsPanel.type = "actions";
|
3056
|
+
const ActionsPanelContent = () => {
|
3057
|
+
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
3058
|
+
const [
|
3059
|
+
{
|
3060
|
+
query: { status = "draft" }
|
2868
3061
|
}
|
2869
|
-
|
2870
|
-
|
2871
|
-
|
2872
|
-
|
2873
|
-
|
2874
|
-
|
2875
|
-
|
2876
|
-
|
2877
|
-
|
2878
|
-
|
2879
|
-
|
2880
|
-
|
2881
|
-
|
2882
|
-
|
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
|
+
] });
|
2883
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
|
+
});
|
2884
3111
|
const ConfirmBulkActionDialog = ({
|
2885
3112
|
onToggleDialog,
|
2886
3113
|
isOpen = false,
|
@@ -2919,6 +3146,7 @@ const ConfirmDialogPublishAll = ({
|
|
2919
3146
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler(getTranslation);
|
2920
3147
|
const { model, schema } = useDoc();
|
2921
3148
|
const [{ query }] = strapiAdmin.useQueryParams();
|
3149
|
+
const enableDraftRelationsCount = false;
|
2922
3150
|
const {
|
2923
3151
|
data: countDraftRelations = 0,
|
2924
3152
|
isLoading,
|
@@ -2930,7 +3158,7 @@ const ConfirmDialogPublishAll = ({
|
|
2930
3158
|
locale: query?.plugins?.i18n?.locale
|
2931
3159
|
},
|
2932
3160
|
{
|
2933
|
-
skip:
|
3161
|
+
skip: !enableDraftRelationsCount
|
2934
3162
|
}
|
2935
3163
|
);
|
2936
3164
|
React__namespace.useEffect(() => {
|
@@ -3115,7 +3343,7 @@ const SelectedEntriesTableContent = ({
|
|
3115
3343
|
status: row.status
|
3116
3344
|
}
|
3117
3345
|
) }),
|
3118
|
-
/* @__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(
|
3119
3347
|
designSystem.IconButton,
|
3120
3348
|
{
|
3121
3349
|
tag: reactRouterDom.Link,
|
@@ -3124,23 +3352,16 @@ const SelectedEntriesTableContent = ({
|
|
3124
3352
|
search: row.locale && `?plugins[i18n][locale]=${row.locale}`
|
3125
3353
|
},
|
3126
3354
|
state: { from: pathname },
|
3127
|
-
label: formatMessage(
|
3128
|
-
|
3129
|
-
|
3130
|
-
|
3131
|
-
{
|
3132
|
-
id: "content-manager.components.ListViewHelperPluginTable.row-line",
|
3133
|
-
defaultMessage: "item line {number}"
|
3134
|
-
},
|
3135
|
-
{ number: index2 + 1 }
|
3136
|
-
)
|
3137
|
-
}
|
3138
|
-
),
|
3355
|
+
label: formatMessage({
|
3356
|
+
id: "content-manager.bulk-publish.edit",
|
3357
|
+
defaultMessage: "Edit"
|
3358
|
+
}),
|
3139
3359
|
target: "_blank",
|
3140
3360
|
marginLeft: "auto",
|
3141
|
-
|
3361
|
+
variant: "ghost",
|
3362
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, { width: "1.6rem", height: "1.6rem" })
|
3142
3363
|
}
|
3143
|
-
) })
|
3364
|
+
) }) })
|
3144
3365
|
] }, row.id)) })
|
3145
3366
|
] });
|
3146
3367
|
};
|
@@ -3177,7 +3398,13 @@ const SelectedEntriesModalContent = ({
|
|
3177
3398
|
);
|
3178
3399
|
const { rows, validationErrors } = React__namespace.useMemo(() => {
|
3179
3400
|
if (data.length > 0 && schema) {
|
3180
|
-
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
|
+
);
|
3181
3408
|
const validationErrors2 = {};
|
3182
3409
|
const rows2 = data.map((entry) => {
|
3183
3410
|
try {
|
@@ -3302,8 +3529,7 @@ const PublishAction = ({ documents, model }) => {
|
|
3302
3529
|
const refetchList = () => {
|
3303
3530
|
contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
|
3304
3531
|
};
|
3305
|
-
if (!showPublishButton)
|
3306
|
-
return null;
|
3532
|
+
if (!showPublishButton) return null;
|
3307
3533
|
return {
|
3308
3534
|
actionType: "publish",
|
3309
3535
|
variant: "tertiary",
|
@@ -3371,8 +3597,7 @@ const DeleteAction = ({ documents, model }) => {
|
|
3371
3597
|
selectRow([]);
|
3372
3598
|
}
|
3373
3599
|
};
|
3374
|
-
if (!hasDeletePermission)
|
3375
|
-
return null;
|
3600
|
+
if (!hasDeletePermission) return null;
|
3376
3601
|
return {
|
3377
3602
|
variant: "danger-light",
|
3378
3603
|
label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
|
@@ -3421,8 +3646,7 @@ const UnpublishAction = ({ documents, model }) => {
|
|
3421
3646
|
}
|
3422
3647
|
};
|
3423
3648
|
const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
|
3424
|
-
if (!showUnpublishButton)
|
3425
|
-
return null;
|
3649
|
+
if (!showUnpublishButton) return null;
|
3426
3650
|
return {
|
3427
3651
|
variant: "tertiary",
|
3428
3652
|
label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
|
@@ -3527,7 +3751,7 @@ const TableActions = ({ document }) => {
|
|
3527
3751
|
strapiAdmin.DescriptionComponentRenderer,
|
3528
3752
|
{
|
3529
3753
|
props,
|
3530
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3754
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("table-row").filter((action) => action.name !== "PublishAction"),
|
3531
3755
|
children: (actions2) => {
|
3532
3756
|
const tableRowActions = actions2.filter((action) => {
|
3533
3757
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -3586,6 +3810,7 @@ const EditAction = ({ documentId }) => {
|
|
3586
3810
|
};
|
3587
3811
|
};
|
3588
3812
|
EditAction.type = "edit";
|
3813
|
+
EditAction.position = "table-row";
|
3589
3814
|
const StyledPencil = styledComponents.styled(Icons.Pencil)`
|
3590
3815
|
path {
|
3591
3816
|
fill: currentColor;
|
@@ -3638,7 +3863,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3638
3863
|
}),
|
3639
3864
|
content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
3640
3865
|
footer: ({ onClose }) => {
|
3641
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
3866
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
3642
3867
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
3643
3868
|
id: "cancel",
|
3644
3869
|
defaultMessage: "Cancel"
|
@@ -3662,6 +3887,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3662
3887
|
};
|
3663
3888
|
};
|
3664
3889
|
CloneAction.type = "clone";
|
3890
|
+
CloneAction.position = "table-row";
|
3665
3891
|
const StyledDuplicate = styledComponents.styled(Icons.Duplicate)`
|
3666
3892
|
path {
|
3667
3893
|
fill: currentColor;
|
@@ -3748,7 +3974,14 @@ class ContentManagerPlugin {
|
|
3748
3974
|
addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
|
3749
3975
|
addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
|
3750
3976
|
getBulkActions: () => this.bulkActions,
|
3751
|
-
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
|
+
},
|
3752
3985
|
getEditViewSidePanels: () => this.editViewSidePanels,
|
3753
3986
|
getHeaderActions: () => this.headerActions
|
3754
3987
|
}
|
@@ -3758,10 +3991,8 @@ class ContentManagerPlugin {
|
|
3758
3991
|
const getPrintableType = (value) => {
|
3759
3992
|
const nativeType = typeof value;
|
3760
3993
|
if (nativeType === "object") {
|
3761
|
-
if (value === null)
|
3762
|
-
|
3763
|
-
if (Array.isArray(value))
|
3764
|
-
return "array";
|
3994
|
+
if (value === null) return "null";
|
3995
|
+
if (Array.isArray(value)) return "array";
|
3765
3996
|
if (value instanceof Object && value.constructor.name !== "Object") {
|
3766
3997
|
return value.constructor.name;
|
3767
3998
|
}
|
@@ -3772,17 +4003,27 @@ const HistoryAction = ({ model, document }) => {
|
|
3772
4003
|
const { formatMessage } = reactIntl.useIntl();
|
3773
4004
|
const [{ query }] = strapiAdmin.useQueryParams();
|
3774
4005
|
const navigate = reactRouterDom.useNavigate();
|
4006
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
4007
|
+
const { pathname } = reactRouterDom.useLocation();
|
3775
4008
|
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
3776
4009
|
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
3777
4010
|
return null;
|
3778
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
|
+
};
|
3779
4020
|
return {
|
3780
4021
|
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
3781
4022
|
label: formatMessage({
|
3782
4023
|
id: "content-manager.history.document-action",
|
3783
4024
|
defaultMessage: "Content History"
|
3784
4025
|
}),
|
3785
|
-
onClick:
|
4026
|
+
onClick: handleOnClick,
|
3786
4027
|
disabled: (
|
3787
4028
|
/**
|
3788
4029
|
* The user is creating a new document.
|
@@ -3804,6 +4045,7 @@ const HistoryAction = ({ model, document }) => {
|
|
3804
4045
|
};
|
3805
4046
|
};
|
3806
4047
|
HistoryAction.type = "history";
|
4048
|
+
HistoryAction.position = "header";
|
3807
4049
|
const historyAdmin = {
|
3808
4050
|
bootstrap(app) {
|
3809
4051
|
const { addDocumentAction } = app.getPlugin("content-manager").apis;
|
@@ -3850,6 +4092,88 @@ const { setInitialData } = actions;
|
|
3850
4092
|
const reducer = toolkit.combineReducers({
|
3851
4093
|
app: reducer$1
|
3852
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
|
+
};
|
3853
4177
|
const index = {
|
3854
4178
|
register(app) {
|
3855
4179
|
const cm = new ContentManagerPlugin();
|
@@ -3869,7 +4193,7 @@ const index = {
|
|
3869
4193
|
app.router.addRoute({
|
3870
4194
|
path: "content-manager/*",
|
3871
4195
|
lazy: async () => {
|
3872
|
-
const { Layout } = await Promise.resolve().then(() => require("./layout-
|
4196
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-ivwIVPnV.js"));
|
3873
4197
|
return {
|
3874
4198
|
Component: Layout
|
3875
4199
|
};
|
@@ -3882,11 +4206,14 @@ const index = {
|
|
3882
4206
|
if (typeof historyAdmin.bootstrap === "function") {
|
3883
4207
|
historyAdmin.bootstrap(app);
|
3884
4208
|
}
|
4209
|
+
if (typeof previewAdmin.bootstrap === "function") {
|
4210
|
+
previewAdmin.bootstrap(app);
|
4211
|
+
}
|
3885
4212
|
},
|
3886
4213
|
async registerTrads({ locales }) {
|
3887
4214
|
const importedTrads = await Promise.all(
|
3888
4215
|
locales.map((locale) => {
|
3889
|
-
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 }) => {
|
3890
4217
|
return {
|
3891
4218
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3892
4219
|
locale
|
@@ -3904,6 +4231,7 @@ const index = {
|
|
3904
4231
|
};
|
3905
4232
|
exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
|
3906
4233
|
exports.BulkActionsRenderer = BulkActionsRenderer;
|
4234
|
+
exports.CLONE_PATH = CLONE_PATH;
|
3907
4235
|
exports.COLLECTION_TYPES = COLLECTION_TYPES;
|
3908
4236
|
exports.CREATOR_FIELDS = CREATOR_FIELDS;
|
3909
4237
|
exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
|
@@ -3931,6 +4259,7 @@ exports.getMainField = getMainField;
|
|
3931
4259
|
exports.getTranslation = getTranslation;
|
3932
4260
|
exports.index = index;
|
3933
4261
|
exports.setInitialData = setInitialData;
|
4262
|
+
exports.useContentManagerContext = useContentManagerContext;
|
3934
4263
|
exports.useContentTypeSchema = useContentTypeSchema;
|
3935
4264
|
exports.useDoc = useDoc;
|
3936
4265
|
exports.useDocLayout = useDocLayout;
|
@@ -3942,5 +4271,6 @@ exports.useGetAllContentTypeSettingsQuery = useGetAllContentTypeSettingsQuery;
|
|
3942
4271
|
exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
3943
4272
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
3944
4273
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
4274
|
+
exports.useGetPreviewUrlQuery = useGetPreviewUrlQuery;
|
3945
4275
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
3946
|
-
//# sourceMappingURL=index-
|
4276
|
+
//# sourceMappingURL=index-Cnw4gqee.js.map
|