@strapi/content-manager 0.0.0-experimental.145e7d7ddefd1aef71aaf3d9bb86440d013035bf → 0.0.0-experimental.14fd433d38456a5899dff3ea799f80d8757a85e3
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-D_g11bYV.js → ComponentConfigurationPage-BLWQy8ru.js} +5 -6
- package/dist/_chunks/{ComponentConfigurationPage-D_g11bYV.js.map → ComponentConfigurationPage-BLWQy8ru.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-DJEJ49QD.mjs → ComponentConfigurationPage-CtIa3aa2.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-DJEJ49QD.mjs.map → ComponentConfigurationPage-CtIa3aa2.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-QBZdUYyG.mjs → EditConfigurationPage-DsPR2DVk.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-QBZdUYyG.mjs.map → EditConfigurationPage-DsPR2DVk.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CeL712KW.js → EditConfigurationPage-RQkymxCy.js} +5 -6
- package/dist/_chunks/{EditConfigurationPage-CeL712KW.js.map → EditConfigurationPage-RQkymxCy.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-g5TwrgRY.js → EditViewPage-B-kExt8C.js} +50 -11
- package/dist/_chunks/EditViewPage-B-kExt8C.js.map +1 -0
- package/dist/_chunks/{EditViewPage-CvRUUpVh.mjs → EditViewPage-BPyVuPfM.mjs} +50 -10
- package/dist/_chunks/EditViewPage-BPyVuPfM.mjs.map +1 -0
- package/dist/_chunks/{Field-ncdInvxS.js → Field-DPIsQRre.js} +250 -161
- package/dist/_chunks/Field-DPIsQRre.js.map +1 -0
- package/dist/_chunks/{Field-reyvfnop.mjs → Field-Dltnt1km.mjs} +244 -155
- package/dist/_chunks/Field-Dltnt1km.mjs.map +1 -0
- package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
- package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
- package/dist/_chunks/{Form-BJ7bYiUx.js → Form-BFi4MXMT.js} +17 -12
- package/dist/_chunks/Form-BFi4MXMT.js.map +1 -0
- package/dist/_chunks/{Form-DoMGsYxH.mjs → Form-C1IcWm1u.mjs} +15 -9
- package/dist/_chunks/Form-C1IcWm1u.mjs.map +1 -0
- package/dist/_chunks/{History-BseDJOrj.mjs → History-04ChQ4pl.mjs} +71 -104
- package/dist/_chunks/History-04ChQ4pl.mjs.map +1 -0
- package/dist/_chunks/{History-pbhkxIrf.js → History-wjcK4L0C.js} +70 -104
- package/dist/_chunks/History-wjcK4L0C.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DWE_fr5B.mjs → ListConfigurationPage-BYqPYLSU.mjs} +7 -6
- package/dist/_chunks/ListConfigurationPage-BYqPYLSU.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-Bna8zfjr.js → ListConfigurationPage-CRbxIC3J.js} +7 -7
- package/dist/_chunks/ListConfigurationPage-CRbxIC3J.js.map +1 -0
- package/dist/_chunks/{ListViewPage-Dymsvnv6.js → ListViewPage-D5NY9183.js} +88 -54
- package/dist/_chunks/ListViewPage-D5NY9183.js.map +1 -0
- package/dist/_chunks/{ListViewPage-lQ-VLV2G.mjs → ListViewPage-FU2LBuhl.mjs} +83 -48
- package/dist/_chunks/ListViewPage-FU2LBuhl.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-B4t_OsDR.js → NoContentTypePage-BgQVE_Qb.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-B4t_OsDR.js.map → NoContentTypePage-BgQVE_Qb.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-VCQOMwlf.mjs → NoContentTypePage-DCKUkwb8.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-VCQOMwlf.mjs.map → NoContentTypePage-DCKUkwb8.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-BOwB6hki.js → NoPermissionsPage-C5jwn70o.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-BOwB6hki.js.map → NoPermissionsPage-C5jwn70o.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-TV830k4P.mjs → NoPermissionsPage-jqve7C8l.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-TV830k4P.mjs.map → NoPermissionsPage-jqve7C8l.mjs.map} +1 -1
- package/dist/_chunks/Preview-BMYN548c.mjs +294 -0
- package/dist/_chunks/Preview-BMYN548c.mjs.map +1 -0
- package/dist/_chunks/Preview-DaOihysv.js +312 -0
- package/dist/_chunks/Preview-DaOihysv.js.map +1 -0
- package/dist/_chunks/{Relations-DdlstXTu.js → Relations-CTGM7Hv5.js} +75 -42
- package/dist/_chunks/Relations-CTGM7Hv5.js.map +1 -0
- package/dist/_chunks/{Relations-D6NAlnsl.mjs → Relations-gscPkxjF.mjs} +75 -41
- package/dist/_chunks/Relations-gscPkxjF.mjs.map +1 -0
- package/dist/_chunks/{en-Cf41pH5f.js → en-BzQmavmK.js} +29 -12
- package/dist/_chunks/{en-Cf41pH5f.js.map → en-BzQmavmK.js.map} +1 -1
- package/dist/_chunks/{en-DCszE74t.mjs → en-CSxLmrh1.mjs} +29 -12
- package/dist/_chunks/{en-DCszE74t.mjs.map → en-CSxLmrh1.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-CQos-KS0.js → index-Ca7YWlAA.js} +1042 -730
- package/dist/_chunks/index-Ca7YWlAA.js.map +1 -0
- package/dist/_chunks/{index-BYSWwHBJ.mjs → index-DqasUQ6Q.mjs} +1044 -732
- package/dist/_chunks/index-DqasUQ6Q.mjs.map +1 -0
- package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
- package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
- package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
- package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
- package/dist/_chunks/{layout-B4XAqu1v.js → layout-BW80JSCd.js} +7 -7
- package/dist/_chunks/{layout-B4XAqu1v.js.map → layout-BW80JSCd.js.map} +1 -1
- package/dist/_chunks/{layout-0TY7UtKO.mjs → layout-W3clJSCy.mjs} +6 -5
- package/dist/_chunks/{layout-0TY7UtKO.mjs.map → layout-W3clJSCy.mjs.map} +1 -1
- 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-DFDWfa0s.mjs → relations-BlDkoeWh.mjs} +6 -7
- package/dist/_chunks/relations-BlDkoeWh.mjs.map +1 -0
- package/dist/_chunks/{relations-xZ2tMj1G.js → relations-C9Usz9k5.js} +6 -7
- package/dist/_chunks/relations-C9Usz9k5.js.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 +3 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +5 -3
- package/dist/admin/src/content-manager.d.ts +3 -2
- package/dist/admin/src/exports.d.ts +2 -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 +3 -3
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +1 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/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 +16 -19
- 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/server/index.js +591 -334
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +592 -334
- 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/controllers/history-version.d.ts +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts +3 -3
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +6 -11
- 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/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/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/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-CvRUUpVh.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-g5TwrgRY.js.map +0 -1
- package/dist/_chunks/Field-ncdInvxS.js.map +0 -1
- package/dist/_chunks/Field-reyvfnop.mjs.map +0 -1
- package/dist/_chunks/Form-BJ7bYiUx.js.map +0 -1
- package/dist/_chunks/Form-DoMGsYxH.mjs.map +0 -1
- package/dist/_chunks/History-BseDJOrj.mjs.map +0 -1
- package/dist/_chunks/History-pbhkxIrf.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-Bna8zfjr.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DWE_fr5B.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-Dymsvnv6.js.map +0 -1
- package/dist/_chunks/ListViewPage-lQ-VLV2G.mjs.map +0 -1
- package/dist/_chunks/Relations-D6NAlnsl.mjs.map +0 -1
- package/dist/_chunks/Relations-DdlstXTu.js.map +0 -1
- package/dist/_chunks/index-BYSWwHBJ.mjs.map +0 -1
- package/dist/_chunks/index-CQos-KS0.js.map +0 -1
- package/dist/_chunks/relations-DFDWfa0s.mjs.map +0 -1
- package/dist/_chunks/relations-xZ2tMj1G.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");
|
10
|
+
const styledComponents = require("styled-components");
|
9
11
|
const yup = require("yup");
|
12
|
+
const qs = require("qs");
|
10
13
|
const pipe = require("lodash/fp/pipe");
|
11
14
|
const dateFns = require("date-fns");
|
12
|
-
const styledComponents = require("styled-components");
|
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) : [];
|
@@ -180,7 +196,8 @@ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
|
|
180
196
|
"InitialData",
|
181
197
|
"HistoryVersion",
|
182
198
|
"Relations",
|
183
|
-
"UidAvailability"
|
199
|
+
"UidAvailability",
|
200
|
+
"RecentDocumentList"
|
184
201
|
]
|
185
202
|
});
|
186
203
|
const documentApi = contentManagerApi.injectEndpoints({
|
@@ -198,7 +215,7 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
198
215
|
if (error) {
|
199
216
|
return [];
|
200
217
|
}
|
201
|
-
return [{ type: "Document", id: `${model}_LIST` }];
|
218
|
+
return [{ type: "Document", id: `${model}_LIST` }, "RecentDocumentList"];
|
202
219
|
}
|
203
220
|
}),
|
204
221
|
cloneDocument: builder.mutation({
|
@@ -212,7 +229,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
212
229
|
}),
|
213
230
|
invalidatesTags: (_result, _error, { model }) => [
|
214
231
|
{ type: "Document", id: `${model}_LIST` },
|
215
|
-
{ type: "UidAvailability", id: model }
|
232
|
+
{ type: "UidAvailability", id: model },
|
233
|
+
"RecentDocumentList"
|
216
234
|
]
|
217
235
|
}),
|
218
236
|
/**
|
@@ -231,8 +249,21 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
231
249
|
invalidatesTags: (result, _error, { model }) => [
|
232
250
|
{ type: "Document", id: `${model}_LIST` },
|
233
251
|
"Relations",
|
234
|
-
{ type: "UidAvailability", id: model }
|
235
|
-
|
252
|
+
{ type: "UidAvailability", id: model },
|
253
|
+
"RecentDocumentList"
|
254
|
+
],
|
255
|
+
transformResponse: (response, meta, arg) => {
|
256
|
+
if (!("data" in response) && arg.model === "plugin::users-permissions.user") {
|
257
|
+
return {
|
258
|
+
data: response,
|
259
|
+
meta: {
|
260
|
+
availableStatus: [],
|
261
|
+
availableLocales: []
|
262
|
+
}
|
263
|
+
};
|
264
|
+
}
|
265
|
+
return response;
|
266
|
+
}
|
236
267
|
}),
|
237
268
|
deleteDocument: builder.mutation({
|
238
269
|
query: ({ collectionType, model, documentId, params }) => ({
|
@@ -243,7 +274,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
243
274
|
}
|
244
275
|
}),
|
245
276
|
invalidatesTags: (_result, _error, { collectionType, model }) => [
|
246
|
-
{ type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model }
|
277
|
+
{ type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model },
|
278
|
+
"RecentDocumentList"
|
247
279
|
]
|
248
280
|
}),
|
249
281
|
deleteManyDocuments: builder.mutation({
|
@@ -255,7 +287,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
255
287
|
params
|
256
288
|
}
|
257
289
|
}),
|
258
|
-
invalidatesTags: (_res, _error, { model }) => [
|
290
|
+
invalidatesTags: (_res, _error, { model }) => [
|
291
|
+
{ type: "Document", id: `${model}_LIST` },
|
292
|
+
"RecentDocumentList"
|
293
|
+
]
|
259
294
|
}),
|
260
295
|
discardDocument: builder.mutation({
|
261
296
|
query: ({ collectionType, model, documentId, params }) => ({
|
@@ -273,7 +308,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
273
308
|
},
|
274
309
|
{ type: "Document", id: `${model}_LIST` },
|
275
310
|
"Relations",
|
276
|
-
{ type: "UidAvailability", id: model }
|
311
|
+
{ type: "UidAvailability", id: model },
|
312
|
+
"RecentDocumentList"
|
277
313
|
];
|
278
314
|
}
|
279
315
|
}),
|
@@ -286,7 +322,7 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
286
322
|
url: `/content-manager/collection-types/${model}`,
|
287
323
|
method: "GET",
|
288
324
|
config: {
|
289
|
-
params
|
325
|
+
params: qs.stringify(params, { encode: true })
|
290
326
|
}
|
291
327
|
}),
|
292
328
|
providesTags: (result, _error, arg) => {
|
@@ -368,7 +404,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
368
404
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
369
405
|
},
|
370
406
|
{ type: "Document", id: `${model}_LIST` },
|
371
|
-
"Relations"
|
407
|
+
"Relations",
|
408
|
+
"RecentDocumentList"
|
372
409
|
];
|
373
410
|
}
|
374
411
|
}),
|
@@ -399,7 +436,9 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
399
436
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
400
437
|
},
|
401
438
|
"Relations",
|
402
|
-
{ type: "UidAvailability", id: model }
|
439
|
+
{ type: "UidAvailability", id: model },
|
440
|
+
"RecentDocumentList",
|
441
|
+
"RecentDocumentList"
|
403
442
|
];
|
404
443
|
},
|
405
444
|
async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
|
@@ -429,7 +468,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
429
468
|
{
|
430
469
|
type: "Document",
|
431
470
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
432
|
-
}
|
471
|
+
},
|
472
|
+
"RecentDocumentList"
|
433
473
|
];
|
434
474
|
}
|
435
475
|
}),
|
@@ -442,7 +482,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
442
482
|
params
|
443
483
|
}
|
444
484
|
}),
|
445
|
-
invalidatesTags: (_res, _error, { model, documentIds }) =>
|
485
|
+
invalidatesTags: (_res, _error, { model, documentIds }) => [
|
486
|
+
...documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` })),
|
487
|
+
"RecentDocumentList"
|
488
|
+
]
|
446
489
|
})
|
447
490
|
})
|
448
491
|
});
|
@@ -465,8 +508,7 @@ const {
|
|
465
508
|
useUnpublishManyDocumentsMutation
|
466
509
|
} = documentApi;
|
467
510
|
const buildValidParams = (query) => {
|
468
|
-
if (!query)
|
469
|
-
return query;
|
511
|
+
if (!query) return query;
|
470
512
|
const { plugins: _, ...validQueryParams } = {
|
471
513
|
...query,
|
472
514
|
...Object.values(query?.plugins ?? {}).reduce(
|
@@ -474,14 +516,29 @@ const buildValidParams = (query) => {
|
|
474
516
|
{}
|
475
517
|
)
|
476
518
|
};
|
477
|
-
if ("_q" in validQueryParams) {
|
478
|
-
validQueryParams._q = encodeURIComponent(validQueryParams._q);
|
479
|
-
}
|
480
519
|
return validQueryParams;
|
481
520
|
};
|
482
521
|
const isBaseQueryError = (error) => {
|
483
522
|
return error.name !== void 0;
|
484
523
|
};
|
524
|
+
const arrayValidator = (attribute, options) => ({
|
525
|
+
message: strapiAdmin.translatedErrors.required,
|
526
|
+
test(value) {
|
527
|
+
if (options.status === "draft") {
|
528
|
+
return true;
|
529
|
+
}
|
530
|
+
if (!attribute.required) {
|
531
|
+
return true;
|
532
|
+
}
|
533
|
+
if (!value) {
|
534
|
+
return false;
|
535
|
+
}
|
536
|
+
if (Array.isArray(value) && value.length === 0) {
|
537
|
+
return false;
|
538
|
+
}
|
539
|
+
return true;
|
540
|
+
}
|
541
|
+
});
|
485
542
|
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
486
543
|
const createModelSchema = (attributes2) => yup__namespace.object().shape(
|
487
544
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
@@ -489,6 +546,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
489
546
|
return acc;
|
490
547
|
}
|
491
548
|
const validations = [
|
549
|
+
addNullableValidation,
|
492
550
|
addRequiredValidation,
|
493
551
|
addMinLengthValidation,
|
494
552
|
addMaxLengthValidation,
|
@@ -505,12 +563,12 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
505
563
|
...acc,
|
506
564
|
[name]: transformSchema(
|
507
565
|
yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
|
508
|
-
)
|
566
|
+
).test(arrayValidator(attribute, options))
|
509
567
|
};
|
510
568
|
} else {
|
511
569
|
return {
|
512
570
|
...acc,
|
513
|
-
[name]: transformSchema(createModelSchema(attributes3))
|
571
|
+
[name]: transformSchema(createModelSchema(attributes3).nullable())
|
514
572
|
};
|
515
573
|
}
|
516
574
|
}
|
@@ -532,7 +590,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
532
590
|
}
|
533
591
|
)
|
534
592
|
)
|
535
|
-
)
|
593
|
+
).test(arrayValidator(attribute, options))
|
536
594
|
};
|
537
595
|
case "relation":
|
538
596
|
return {
|
@@ -544,7 +602,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
544
602
|
} else if (Array.isArray(value)) {
|
545
603
|
return yup__namespace.array().of(
|
546
604
|
yup__namespace.object().shape({
|
547
|
-
id: yup__namespace.
|
605
|
+
id: yup__namespace.number().required()
|
548
606
|
})
|
549
607
|
);
|
550
608
|
} else if (typeof value === "object") {
|
@@ -630,17 +688,17 @@ const nullableSchema = (schema) => {
|
|
630
688
|
schema
|
631
689
|
);
|
632
690
|
};
|
691
|
+
const addNullableValidation = () => (schema) => {
|
692
|
+
return nullableSchema(schema);
|
693
|
+
};
|
633
694
|
const addRequiredValidation = (attribute, options) => (schema) => {
|
634
|
-
if (options.status === "draft") {
|
635
|
-
return
|
636
|
-
}
|
637
|
-
if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
|
638
|
-
return schema.min(1, strapiAdmin.translatedErrors.required);
|
695
|
+
if (options.status === "draft" || !attribute.required) {
|
696
|
+
return schema;
|
639
697
|
}
|
640
|
-
if (attribute.required &&
|
698
|
+
if (attribute.required && "required" in schema) {
|
641
699
|
return schema.required(strapiAdmin.translatedErrors.required);
|
642
700
|
}
|
643
|
-
return
|
701
|
+
return schema;
|
644
702
|
};
|
645
703
|
const addMinLengthValidation = (attribute, options) => (schema) => {
|
646
704
|
if (options.status === "draft") {
|
@@ -668,31 +726,12 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
668
726
|
return schema;
|
669
727
|
};
|
670
728
|
const addMinValidation = (attribute, options) => (schema) => {
|
671
|
-
if ("
|
729
|
+
if (options.status === "draft") {
|
730
|
+
return schema;
|
731
|
+
}
|
732
|
+
if ("min" in attribute && "min" in schema) {
|
672
733
|
const min = toInteger(attribute.min);
|
673
|
-
if (
|
674
|
-
if (options.status !== "draft" && !attribute.required && "test" in schema && min) {
|
675
|
-
return schema.test(
|
676
|
-
"custom-min",
|
677
|
-
{
|
678
|
-
...strapiAdmin.translatedErrors.min,
|
679
|
-
values: {
|
680
|
-
min: attribute.min
|
681
|
-
}
|
682
|
-
},
|
683
|
-
(value) => {
|
684
|
-
if (!value) {
|
685
|
-
return true;
|
686
|
-
}
|
687
|
-
if (Array.isArray(value) && value.length === 0) {
|
688
|
-
return true;
|
689
|
-
}
|
690
|
-
return value.length >= min;
|
691
|
-
}
|
692
|
-
);
|
693
|
-
}
|
694
|
-
}
|
695
|
-
if ("min" in schema && min) {
|
734
|
+
if (min) {
|
696
735
|
return schema.min(min, {
|
697
736
|
...strapiAdmin.translatedErrors.min,
|
698
737
|
values: {
|
@@ -810,19 +849,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
|
|
810
849
|
}, {});
|
811
850
|
return componentsByKey;
|
812
851
|
};
|
813
|
-
const
|
852
|
+
const HOOKS = {
|
853
|
+
/**
|
854
|
+
* Hook that allows to mutate the displayed headers of the list view table
|
855
|
+
* @constant
|
856
|
+
* @type {string}
|
857
|
+
*/
|
858
|
+
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
859
|
+
/**
|
860
|
+
* Hook that allows to mutate the CM's collection types links pre-set filters
|
861
|
+
* @constant
|
862
|
+
* @type {string}
|
863
|
+
*/
|
864
|
+
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
865
|
+
/**
|
866
|
+
* Hook that allows to mutate the CM's edit view layout
|
867
|
+
* @constant
|
868
|
+
* @type {string}
|
869
|
+
*/
|
870
|
+
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
871
|
+
/**
|
872
|
+
* Hook that allows to mutate the CM's single types links pre-set filters
|
873
|
+
* @constant
|
874
|
+
* @type {string}
|
875
|
+
*/
|
876
|
+
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
877
|
+
};
|
878
|
+
const contentTypesApi = contentManagerApi.injectEndpoints({
|
879
|
+
endpoints: (builder) => ({
|
880
|
+
getContentTypeConfiguration: builder.query({
|
881
|
+
query: (uid) => ({
|
882
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
883
|
+
method: "GET"
|
884
|
+
}),
|
885
|
+
transformResponse: (response) => response.data,
|
886
|
+
providesTags: (_result, _error, uid) => [
|
887
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
888
|
+
{ type: "ContentTypeSettings", id: "LIST" }
|
889
|
+
]
|
890
|
+
}),
|
891
|
+
getAllContentTypeSettings: builder.query({
|
892
|
+
query: () => "/content-manager/content-types-settings",
|
893
|
+
transformResponse: (response) => response.data,
|
894
|
+
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
895
|
+
}),
|
896
|
+
updateContentTypeConfiguration: builder.mutation({
|
897
|
+
query: ({ uid, ...body }) => ({
|
898
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
899
|
+
method: "PUT",
|
900
|
+
data: body
|
901
|
+
}),
|
902
|
+
transformResponse: (response) => response.data,
|
903
|
+
invalidatesTags: (_result, _error, { uid }) => [
|
904
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
905
|
+
{ type: "ContentTypeSettings", id: "LIST" },
|
906
|
+
// Is this necessary?
|
907
|
+
{ type: "InitialData" }
|
908
|
+
]
|
909
|
+
})
|
910
|
+
})
|
911
|
+
});
|
912
|
+
const {
|
913
|
+
useGetContentTypeConfigurationQuery,
|
914
|
+
useGetAllContentTypeSettingsQuery,
|
915
|
+
useUpdateContentTypeConfigurationMutation
|
916
|
+
} = contentTypesApi;
|
917
|
+
const checkIfAttributeIsDisplayable = (attribute) => {
|
918
|
+
const { type } = attribute;
|
919
|
+
if (type === "relation") {
|
920
|
+
return !attribute.relation.toLowerCase().includes("morph");
|
921
|
+
}
|
922
|
+
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
923
|
+
};
|
924
|
+
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
925
|
+
if (!mainFieldName) {
|
926
|
+
return void 0;
|
927
|
+
}
|
928
|
+
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
929
|
+
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
930
|
+
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
931
|
+
);
|
932
|
+
return {
|
933
|
+
name: mainFieldName,
|
934
|
+
type: mainFieldType ?? "string"
|
935
|
+
};
|
936
|
+
};
|
937
|
+
const DEFAULT_SETTINGS = {
|
938
|
+
bulkable: false,
|
939
|
+
filterable: false,
|
940
|
+
searchable: false,
|
941
|
+
pagination: false,
|
942
|
+
defaultSortBy: "",
|
943
|
+
defaultSortOrder: "asc",
|
944
|
+
mainField: "id",
|
945
|
+
pageSize: 10
|
946
|
+
};
|
947
|
+
const useDocumentLayout = (model) => {
|
948
|
+
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
949
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
950
|
+
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
814
951
|
const { toggleNotification } = strapiAdmin.useNotification();
|
815
952
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
953
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
816
954
|
const {
|
817
|
-
|
818
|
-
isLoading:
|
819
|
-
|
820
|
-
|
821
|
-
} =
|
822
|
-
|
823
|
-
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
824
|
-
});
|
825
|
-
const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
|
955
|
+
data,
|
956
|
+
isLoading: isLoadingConfigs,
|
957
|
+
error,
|
958
|
+
isFetching: isFetchingConfigs
|
959
|
+
} = useGetContentTypeConfigurationQuery(model);
|
960
|
+
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
826
961
|
React__namespace.useEffect(() => {
|
827
962
|
if (error) {
|
828
963
|
toggleNotification({
|
@@ -830,77 +965,331 @@ const useDocument = (args, opts) => {
|
|
830
965
|
message: formatAPIError(error)
|
831
966
|
});
|
832
967
|
}
|
833
|
-
}, [
|
834
|
-
const
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
(document) => {
|
842
|
-
if (!validationSchema) {
|
843
|
-
throw new Error(
|
844
|
-
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
845
|
-
);
|
846
|
-
}
|
847
|
-
try {
|
848
|
-
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
849
|
-
return null;
|
850
|
-
} catch (error2) {
|
851
|
-
if (error2 instanceof yup.ValidationError) {
|
852
|
-
return strapiAdmin.getYupValidationErrors(error2);
|
853
|
-
}
|
854
|
-
throw error2;
|
855
|
-
}
|
968
|
+
}, [error, formatAPIError, toggleNotification]);
|
969
|
+
const editLayout = React__namespace.useMemo(
|
970
|
+
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
971
|
+
layout: [],
|
972
|
+
components: {},
|
973
|
+
metadatas: {},
|
974
|
+
options: {},
|
975
|
+
settings: DEFAULT_SETTINGS
|
856
976
|
},
|
857
|
-
[
|
977
|
+
[data, isLoading, schemas, schema, components]
|
978
|
+
);
|
979
|
+
const listLayout = React__namespace.useMemo(() => {
|
980
|
+
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
981
|
+
layout: [],
|
982
|
+
metadatas: {},
|
983
|
+
options: {},
|
984
|
+
settings: DEFAULT_SETTINGS
|
985
|
+
};
|
986
|
+
}, [data, isLoading, schemas, schema, components]);
|
987
|
+
const { layout: edit } = React__namespace.useMemo(
|
988
|
+
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
989
|
+
layout: editLayout,
|
990
|
+
query
|
991
|
+
}),
|
992
|
+
[editLayout, query, runHookWaterfall]
|
858
993
|
);
|
859
|
-
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
860
994
|
return {
|
861
|
-
|
862
|
-
document: data?.data,
|
863
|
-
meta: data?.meta,
|
995
|
+
error,
|
864
996
|
isLoading,
|
865
|
-
|
866
|
-
|
867
|
-
};
|
868
|
-
};
|
869
|
-
const useDoc = () => {
|
870
|
-
const { id, slug, collectionType, origin } = reactRouterDom.useParams();
|
871
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
872
|
-
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
873
|
-
if (!collectionType) {
|
874
|
-
throw new Error("Could not find collectionType in url params");
|
875
|
-
}
|
876
|
-
if (!slug) {
|
877
|
-
throw new Error("Could not find model in url params");
|
878
|
-
}
|
879
|
-
return {
|
880
|
-
collectionType,
|
881
|
-
model: slug,
|
882
|
-
id: origin || id === "create" ? void 0 : id,
|
883
|
-
...useDocument(
|
884
|
-
{ documentId: origin || id, model: slug, collectionType, params },
|
885
|
-
{
|
886
|
-
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
887
|
-
}
|
888
|
-
)
|
997
|
+
edit,
|
998
|
+
list: listLayout
|
889
999
|
};
|
890
1000
|
};
|
891
|
-
const
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
}
|
900
|
-
|
901
|
-
const
|
902
|
-
|
903
|
-
|
1001
|
+
const useDocLayout = () => {
|
1002
|
+
const { model } = useDoc();
|
1003
|
+
return useDocumentLayout(model);
|
1004
|
+
};
|
1005
|
+
const formatEditLayout = (data, {
|
1006
|
+
schemas,
|
1007
|
+
schema,
|
1008
|
+
components
|
1009
|
+
}) => {
|
1010
|
+
let currentPanelIndex = 0;
|
1011
|
+
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
1012
|
+
data.contentType.layouts.edit,
|
1013
|
+
schema?.attributes,
|
1014
|
+
data.contentType.metadatas,
|
1015
|
+
{ configurations: data.components, schemas: components },
|
1016
|
+
schemas
|
1017
|
+
).reduce((panels, row) => {
|
1018
|
+
if (row.some((field) => field.type === "dynamiczone")) {
|
1019
|
+
panels.push([row]);
|
1020
|
+
currentPanelIndex += 2;
|
1021
|
+
} else {
|
1022
|
+
if (!panels[currentPanelIndex]) {
|
1023
|
+
panels.push([row]);
|
1024
|
+
} else {
|
1025
|
+
panels[currentPanelIndex].push(row);
|
1026
|
+
}
|
1027
|
+
}
|
1028
|
+
return panels;
|
1029
|
+
}, []);
|
1030
|
+
const componentEditAttributes = Object.entries(data.components).reduce(
|
1031
|
+
(acc, [uid, configuration]) => {
|
1032
|
+
acc[uid] = {
|
1033
|
+
layout: convertEditLayoutToFieldLayouts(
|
1034
|
+
configuration.layouts.edit,
|
1035
|
+
components[uid].attributes,
|
1036
|
+
configuration.metadatas,
|
1037
|
+
{ configurations: data.components, schemas: components }
|
1038
|
+
),
|
1039
|
+
settings: {
|
1040
|
+
...configuration.settings,
|
1041
|
+
icon: components[uid].info.icon,
|
1042
|
+
displayName: components[uid].info.displayName
|
1043
|
+
}
|
1044
|
+
};
|
1045
|
+
return acc;
|
1046
|
+
},
|
1047
|
+
{}
|
1048
|
+
);
|
1049
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1050
|
+
(acc, [attribute, metadata]) => {
|
1051
|
+
return {
|
1052
|
+
...acc,
|
1053
|
+
[attribute]: metadata.edit
|
1054
|
+
};
|
1055
|
+
},
|
1056
|
+
{}
|
1057
|
+
);
|
1058
|
+
return {
|
1059
|
+
layout: panelledEditAttributes,
|
1060
|
+
components: componentEditAttributes,
|
1061
|
+
metadatas: editMetadatas,
|
1062
|
+
settings: {
|
1063
|
+
...data.contentType.settings,
|
1064
|
+
displayName: schema?.info.displayName
|
1065
|
+
},
|
1066
|
+
options: {
|
1067
|
+
...schema?.options,
|
1068
|
+
...schema?.pluginOptions,
|
1069
|
+
...data.contentType.options
|
1070
|
+
}
|
1071
|
+
};
|
1072
|
+
};
|
1073
|
+
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
1074
|
+
return rows.map(
|
1075
|
+
(row) => row.map((field) => {
|
1076
|
+
const attribute = attributes[field.name];
|
1077
|
+
if (!attribute) {
|
1078
|
+
return null;
|
1079
|
+
}
|
1080
|
+
const { edit: metadata } = metadatas[field.name];
|
1081
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1082
|
+
return {
|
1083
|
+
attribute,
|
1084
|
+
disabled: !metadata.editable,
|
1085
|
+
hint: metadata.description,
|
1086
|
+
label: metadata.label ?? "",
|
1087
|
+
name: field.name,
|
1088
|
+
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
1089
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1090
|
+
schemas,
|
1091
|
+
components: components?.schemas ?? {}
|
1092
|
+
}),
|
1093
|
+
placeholder: metadata.placeholder ?? "",
|
1094
|
+
required: attribute.required ?? false,
|
1095
|
+
size: field.size,
|
1096
|
+
unique: "unique" in attribute ? attribute.unique : false,
|
1097
|
+
visible: metadata.visible ?? true,
|
1098
|
+
type: attribute.type
|
1099
|
+
};
|
1100
|
+
}).filter((field) => field !== null)
|
1101
|
+
);
|
1102
|
+
};
|
1103
|
+
const formatListLayout = (data, {
|
1104
|
+
schemas,
|
1105
|
+
schema,
|
1106
|
+
components
|
1107
|
+
}) => {
|
1108
|
+
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1109
|
+
(acc, [attribute, metadata]) => {
|
1110
|
+
return {
|
1111
|
+
...acc,
|
1112
|
+
[attribute]: metadata.list
|
1113
|
+
};
|
1114
|
+
},
|
1115
|
+
{}
|
1116
|
+
);
|
1117
|
+
const listAttributes = convertListLayoutToFieldLayouts(
|
1118
|
+
data.contentType.layouts.list,
|
1119
|
+
schema?.attributes,
|
1120
|
+
listMetadatas,
|
1121
|
+
{ configurations: data.components, schemas: components },
|
1122
|
+
schemas
|
1123
|
+
);
|
1124
|
+
return {
|
1125
|
+
layout: listAttributes,
|
1126
|
+
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
1127
|
+
metadatas: listMetadatas,
|
1128
|
+
options: {
|
1129
|
+
...schema?.options,
|
1130
|
+
...schema?.pluginOptions,
|
1131
|
+
...data.contentType.options
|
1132
|
+
}
|
1133
|
+
};
|
1134
|
+
};
|
1135
|
+
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
1136
|
+
return columns.map((name) => {
|
1137
|
+
const attribute = attributes[name];
|
1138
|
+
if (!attribute) {
|
1139
|
+
return null;
|
1140
|
+
}
|
1141
|
+
const metadata = metadatas[name];
|
1142
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1143
|
+
return {
|
1144
|
+
attribute,
|
1145
|
+
label: metadata.label ?? "",
|
1146
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1147
|
+
schemas,
|
1148
|
+
components: components?.schemas ?? {}
|
1149
|
+
}),
|
1150
|
+
name,
|
1151
|
+
searchable: metadata.searchable ?? true,
|
1152
|
+
sortable: metadata.sortable ?? true
|
1153
|
+
};
|
1154
|
+
}).filter((field) => field !== null);
|
1155
|
+
};
|
1156
|
+
const useDocument = (args, opts) => {
|
1157
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
1158
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1159
|
+
const {
|
1160
|
+
currentData: data,
|
1161
|
+
isLoading: isLoadingDocument,
|
1162
|
+
isFetching: isFetchingDocument,
|
1163
|
+
error
|
1164
|
+
} = useGetDocumentQuery(args, {
|
1165
|
+
...opts,
|
1166
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
1167
|
+
});
|
1168
|
+
const {
|
1169
|
+
components,
|
1170
|
+
schema,
|
1171
|
+
schemas,
|
1172
|
+
isLoading: isLoadingSchema
|
1173
|
+
} = useContentTypeSchema(args.model);
|
1174
|
+
React__namespace.useEffect(() => {
|
1175
|
+
if (error) {
|
1176
|
+
toggleNotification({
|
1177
|
+
type: "danger",
|
1178
|
+
message: formatAPIError(error)
|
1179
|
+
});
|
1180
|
+
}
|
1181
|
+
}, [toggleNotification, error, formatAPIError, args.collectionType]);
|
1182
|
+
const validationSchema = React__namespace.useMemo(() => {
|
1183
|
+
if (!schema) {
|
1184
|
+
return null;
|
1185
|
+
}
|
1186
|
+
return createYupSchema(schema.attributes, components);
|
1187
|
+
}, [schema, components]);
|
1188
|
+
const validate = React__namespace.useCallback(
|
1189
|
+
(document) => {
|
1190
|
+
if (!validationSchema) {
|
1191
|
+
throw new Error(
|
1192
|
+
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
1193
|
+
);
|
1194
|
+
}
|
1195
|
+
try {
|
1196
|
+
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
1197
|
+
return null;
|
1198
|
+
} catch (error2) {
|
1199
|
+
if (error2 instanceof yup.ValidationError) {
|
1200
|
+
return strapiAdmin.getYupValidationErrors(error2);
|
1201
|
+
}
|
1202
|
+
throw error2;
|
1203
|
+
}
|
1204
|
+
},
|
1205
|
+
[validationSchema]
|
1206
|
+
);
|
1207
|
+
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
1208
|
+
const hasError = !!error;
|
1209
|
+
return {
|
1210
|
+
components,
|
1211
|
+
document: data?.data,
|
1212
|
+
meta: data?.meta,
|
1213
|
+
isLoading,
|
1214
|
+
hasError,
|
1215
|
+
schema,
|
1216
|
+
schemas,
|
1217
|
+
validate
|
1218
|
+
};
|
1219
|
+
};
|
1220
|
+
const useDoc = () => {
|
1221
|
+
const { id, slug, collectionType, origin } = reactRouterDom.useParams();
|
1222
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
1223
|
+
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
1224
|
+
if (!collectionType) {
|
1225
|
+
throw new Error("Could not find collectionType in url params");
|
1226
|
+
}
|
1227
|
+
if (!slug) {
|
1228
|
+
throw new Error("Could not find model in url params");
|
1229
|
+
}
|
1230
|
+
const document = useDocument(
|
1231
|
+
{ documentId: origin || id, model: slug, collectionType, params },
|
1232
|
+
{
|
1233
|
+
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
1234
|
+
}
|
1235
|
+
);
|
1236
|
+
const returnId = origin || id === "create" ? void 0 : id;
|
1237
|
+
return {
|
1238
|
+
collectionType,
|
1239
|
+
model: slug,
|
1240
|
+
id: returnId,
|
1241
|
+
...document
|
1242
|
+
};
|
1243
|
+
};
|
1244
|
+
const useContentManagerContext = () => {
|
1245
|
+
const {
|
1246
|
+
collectionType,
|
1247
|
+
model,
|
1248
|
+
id,
|
1249
|
+
components,
|
1250
|
+
isLoading: isLoadingDoc,
|
1251
|
+
schema,
|
1252
|
+
schemas
|
1253
|
+
} = useDoc();
|
1254
|
+
const layout = useDocumentLayout(model);
|
1255
|
+
const form = strapiAdmin.useForm("useContentManagerContext", (state) => state);
|
1256
|
+
const isSingleType = collectionType === SINGLE_TYPES;
|
1257
|
+
const slug = model;
|
1258
|
+
const isCreatingEntry = id === "create";
|
1259
|
+
useContentTypeSchema();
|
1260
|
+
const isLoading = isLoadingDoc || layout.isLoading;
|
1261
|
+
const error = layout.error;
|
1262
|
+
return {
|
1263
|
+
error,
|
1264
|
+
isLoading,
|
1265
|
+
// Base metadata
|
1266
|
+
model,
|
1267
|
+
collectionType,
|
1268
|
+
id,
|
1269
|
+
slug,
|
1270
|
+
isCreatingEntry,
|
1271
|
+
isSingleType,
|
1272
|
+
hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
|
1273
|
+
// All schema infos
|
1274
|
+
components,
|
1275
|
+
contentType: schema,
|
1276
|
+
contentTypes: schemas,
|
1277
|
+
// Form state
|
1278
|
+
form,
|
1279
|
+
// layout infos
|
1280
|
+
layout
|
1281
|
+
};
|
1282
|
+
};
|
1283
|
+
const prefixPluginTranslations = (trad, pluginId) => {
|
1284
|
+
return Object.keys(trad).reduce((acc, current) => {
|
1285
|
+
acc[`${pluginId}.${current}`] = trad[current];
|
1286
|
+
return acc;
|
1287
|
+
}, {});
|
1288
|
+
};
|
1289
|
+
const getTranslation = (id) => `content-manager.${id}`;
|
1290
|
+
const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
1291
|
+
id: "notification.error",
|
1292
|
+
defaultMessage: "An error occurred, please try again"
|
904
1293
|
};
|
905
1294
|
const useDocumentActions = () => {
|
906
1295
|
const { toggleNotification } = strapiAdmin.useNotification();
|
@@ -908,6 +1297,7 @@ const useDocumentActions = () => {
|
|
908
1297
|
const { trackUsage } = strapiAdmin.useTracking();
|
909
1298
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
910
1299
|
const navigate = reactRouterDom.useNavigate();
|
1300
|
+
const setCurrentStep = strapiAdmin.useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
|
911
1301
|
const [deleteDocument] = useDeleteDocumentMutation();
|
912
1302
|
const _delete = React__namespace.useCallback(
|
913
1303
|
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
@@ -1222,6 +1612,7 @@ const useDocumentActions = () => {
|
|
1222
1612
|
defaultMessage: "Saved document"
|
1223
1613
|
})
|
1224
1614
|
});
|
1615
|
+
setCurrentStep("contentManager.success");
|
1225
1616
|
return res.data;
|
1226
1617
|
} catch (err) {
|
1227
1618
|
toggleNotification({
|
@@ -1323,10 +1714,10 @@ const useDocumentActions = () => {
|
|
1323
1714
|
update
|
1324
1715
|
};
|
1325
1716
|
};
|
1326
|
-
const ProtectedHistoryPage =
|
1327
|
-
() => Promise.resolve().then(() => require("./History-
|
1717
|
+
const ProtectedHistoryPage = React__namespace.lazy(
|
1718
|
+
() => Promise.resolve().then(() => require("./History-wjcK4L0C.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1328
1719
|
);
|
1329
|
-
const routes$
|
1720
|
+
const routes$2 = [
|
1330
1721
|
{
|
1331
1722
|
path: ":collectionType/:slug/:id/history",
|
1332
1723
|
Component: ProtectedHistoryPage
|
@@ -1336,32 +1727,45 @@ const routes$1 = [
|
|
1336
1727
|
Component: ProtectedHistoryPage
|
1337
1728
|
}
|
1338
1729
|
];
|
1339
|
-
const
|
1340
|
-
() => Promise.resolve().then(() => require("./
|
1730
|
+
const ProtectedPreviewPage = React__namespace.lazy(
|
1731
|
+
() => Promise.resolve().then(() => require("./Preview-DaOihysv.js")).then((mod) => ({ default: mod.ProtectedPreviewPage }))
|
1341
1732
|
);
|
1342
|
-
const
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1733
|
+
const routes$1 = [
|
1734
|
+
{
|
1735
|
+
path: ":collectionType/:slug/:id/preview",
|
1736
|
+
Component: ProtectedPreviewPage
|
1737
|
+
},
|
1738
|
+
{
|
1739
|
+
path: ":collectionType/:slug/preview",
|
1740
|
+
Component: ProtectedPreviewPage
|
1741
|
+
}
|
1742
|
+
];
|
1743
|
+
const ProtectedEditViewPage = React.lazy(
|
1744
|
+
() => Promise.resolve().then(() => require("./EditViewPage-B-kExt8C.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1745
|
+
);
|
1746
|
+
const ProtectedListViewPage = React.lazy(
|
1747
|
+
() => Promise.resolve().then(() => require("./ListViewPage-D5NY9183.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1748
|
+
);
|
1749
|
+
const ProtectedListConfiguration = React.lazy(
|
1750
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-CRbxIC3J.js")).then((mod) => ({
|
1751
|
+
default: mod.ProtectedListConfiguration
|
1348
1752
|
}))
|
1349
1753
|
);
|
1350
1754
|
const ProtectedEditConfigurationPage = React.lazy(
|
1351
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1755
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-RQkymxCy.js")).then((mod) => ({
|
1352
1756
|
default: mod.ProtectedEditConfigurationPage
|
1353
1757
|
}))
|
1354
1758
|
);
|
1355
1759
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1356
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1760
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-BLWQy8ru.js")).then((mod) => ({
|
1357
1761
|
default: mod.ProtectedComponentConfigurationPage
|
1358
1762
|
}))
|
1359
1763
|
);
|
1360
1764
|
const NoPermissions = React.lazy(
|
1361
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1765
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-C5jwn70o.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1362
1766
|
);
|
1363
1767
|
const NoContentType = React.lazy(
|
1364
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1768
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-BgQVE_Qb.js")).then((mod) => ({ default: mod.NoContentType }))
|
1365
1769
|
);
|
1366
1770
|
const CollectionTypePages = () => {
|
1367
1771
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1373,7 +1777,7 @@ const CollectionTypePages = () => {
|
|
1373
1777
|
const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
|
1374
1778
|
const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
|
1375
1779
|
const LIST_RELATIVE_PATH = ":collectionType/:slug";
|
1376
|
-
const LIST_PATH = `/content-manager
|
1780
|
+
const LIST_PATH = `/content-manager/collection-types/:slug`;
|
1377
1781
|
const routes = [
|
1378
1782
|
{
|
1379
1783
|
path: LIST_RELATIVE_PATH,
|
@@ -1407,6 +1811,7 @@ const routes = [
|
|
1407
1811
|
path: "no-content-types",
|
1408
1812
|
Component: NoContentType
|
1409
1813
|
},
|
1814
|
+
...routes$2,
|
1410
1815
|
...routes$1
|
1411
1816
|
];
|
1412
1817
|
const DocumentActions = ({ actions: actions2 }) => {
|
@@ -1505,6 +1910,11 @@ const DocumentActionButton = (action) => {
|
|
1505
1910
|
) : null
|
1506
1911
|
] });
|
1507
1912
|
};
|
1913
|
+
const MenuItem = styledComponents.styled(designSystem.Menu.Item)`
|
1914
|
+
&:hover {
|
1915
|
+
background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
|
1916
|
+
}
|
1917
|
+
`;
|
1508
1918
|
const DocumentActionsMenu = ({
|
1509
1919
|
actions: actions2,
|
1510
1920
|
children,
|
@@ -1560,51 +1970,35 @@ const DocumentActionsMenu = ({
|
|
1560
1970
|
]
|
1561
1971
|
}
|
1562
1972
|
),
|
1563
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, {
|
1973
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
|
1564
1974
|
actions2.map((action) => {
|
1565
1975
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
1566
|
-
|
1976
|
+
MenuItem,
|
1567
1977
|
{
|
1568
1978
|
disabled: action.disabled,
|
1569
1979
|
onSelect: handleClick(action),
|
1570
1980
|
display: "block",
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
designSystem.Flex,
|
1593
|
-
{
|
1594
|
-
alignItems: "center",
|
1595
|
-
background: "alternative100",
|
1596
|
-
borderStyle: "solid",
|
1597
|
-
borderColor: "alternative200",
|
1598
|
-
borderWidth: "1px",
|
1599
|
-
height: 5,
|
1600
|
-
paddingLeft: 2,
|
1601
|
-
paddingRight: 2,
|
1602
|
-
hasRadius: true,
|
1603
|
-
color: "alternative600",
|
1604
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", fontWeight: "bold", lineHeight: 1, children: formatMessage({ id: "global.new", defaultMessage: "New" }) })
|
1605
|
-
}
|
1606
|
-
)
|
1607
|
-
] })
|
1981
|
+
isVariantDanger: action.variant === "danger",
|
1982
|
+
isDisabled: action.disabled,
|
1983
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
1984
|
+
designSystem.Flex,
|
1985
|
+
{
|
1986
|
+
color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
|
1987
|
+
gap: 2,
|
1988
|
+
tag: "span",
|
1989
|
+
children: [
|
1990
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
1991
|
+
designSystem.Flex,
|
1992
|
+
{
|
1993
|
+
tag: "span",
|
1994
|
+
color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
|
1995
|
+
children: action.icon
|
1996
|
+
}
|
1997
|
+
),
|
1998
|
+
action.label
|
1999
|
+
]
|
2000
|
+
}
|
2001
|
+
) })
|
1608
2002
|
},
|
1609
2003
|
action.id
|
1610
2004
|
);
|
@@ -1684,11 +2078,11 @@ const DocumentActionConfirmDialog = ({
|
|
1684
2078
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
1685
2079
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
|
1686
2080
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
1687
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
|
2081
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
|
1688
2082
|
id: "app.components.Button.cancel",
|
1689
2083
|
defaultMessage: "Cancel"
|
1690
2084
|
}) }) }),
|
1691
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
|
2085
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
|
1692
2086
|
id: "app.components.Button.confirm",
|
1693
2087
|
defaultMessage: "Confirm"
|
1694
2088
|
}) })
|
@@ -1715,6 +2109,18 @@ const DocumentActionModal = ({
|
|
1715
2109
|
typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
|
1716
2110
|
] }) });
|
1717
2111
|
};
|
2112
|
+
const transformData = (data) => {
|
2113
|
+
if (Array.isArray(data)) {
|
2114
|
+
return data.map(transformData);
|
2115
|
+
}
|
2116
|
+
if (typeof data === "object" && data !== null) {
|
2117
|
+
if ("apiData" in data) {
|
2118
|
+
return data.apiData;
|
2119
|
+
}
|
2120
|
+
return mapValues__default.default(transformData)(data);
|
2121
|
+
}
|
2122
|
+
return data;
|
2123
|
+
};
|
1718
2124
|
const PublishAction$1 = ({
|
1719
2125
|
activeTab,
|
1720
2126
|
documentId,
|
@@ -1729,6 +2135,7 @@ const PublishAction$1 = ({
|
|
1729
2135
|
const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
|
1730
2136
|
const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
|
1731
2137
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2138
|
+
const { id } = reactRouterDom.useParams();
|
1732
2139
|
const { formatMessage } = reactIntl.useIntl();
|
1733
2140
|
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
1734
2141
|
const { publish } = useDocumentActions();
|
@@ -1808,7 +2215,9 @@ const PublishAction$1 = ({
|
|
1808
2215
|
const performPublish = async () => {
|
1809
2216
|
setSubmitting(true);
|
1810
2217
|
try {
|
1811
|
-
const { errors } = await validate(
|
2218
|
+
const { errors } = await validate(true, {
|
2219
|
+
status: "published"
|
2220
|
+
});
|
1812
2221
|
if (errors) {
|
1813
2222
|
toggleNotification({
|
1814
2223
|
type: "danger",
|
@@ -1826,13 +2235,15 @@ const PublishAction$1 = ({
|
|
1826
2235
|
documentId,
|
1827
2236
|
params
|
1828
2237
|
},
|
1829
|
-
formValues
|
2238
|
+
transformData(formValues)
|
1830
2239
|
);
|
1831
2240
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
2241
|
+
if (id === "create") {
|
2242
|
+
navigate({
|
2243
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
2244
|
+
search: rawQuery
|
2245
|
+
});
|
2246
|
+
}
|
1836
2247
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1837
2248
|
setErrors(formatValidationErrors(res.error));
|
1838
2249
|
}
|
@@ -1885,6 +2296,7 @@ const PublishAction$1 = ({
|
|
1885
2296
|
};
|
1886
2297
|
};
|
1887
2298
|
PublishAction$1.type = "publish";
|
2299
|
+
PublishAction$1.position = "panel";
|
1888
2300
|
const UpdateAction = ({
|
1889
2301
|
activeTab,
|
1890
2302
|
documentId,
|
@@ -1907,6 +2319,117 @@ const UpdateAction = ({
|
|
1907
2319
|
const validate = strapiAdmin.useForm("UpdateAction", (state) => state.validate);
|
1908
2320
|
const setErrors = strapiAdmin.useForm("UpdateAction", (state) => state.setErrors);
|
1909
2321
|
const resetForm = strapiAdmin.useForm("PublishAction", ({ resetForm: resetForm2 }) => resetForm2);
|
2322
|
+
const handleUpdate = React__namespace.useCallback(async () => {
|
2323
|
+
setSubmitting(true);
|
2324
|
+
try {
|
2325
|
+
if (!modified) {
|
2326
|
+
return;
|
2327
|
+
}
|
2328
|
+
const { errors } = await validate(true, {
|
2329
|
+
status: "draft"
|
2330
|
+
});
|
2331
|
+
if (errors) {
|
2332
|
+
toggleNotification({
|
2333
|
+
type: "danger",
|
2334
|
+
message: formatMessage({
|
2335
|
+
id: "content-manager.validation.error",
|
2336
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
2337
|
+
})
|
2338
|
+
});
|
2339
|
+
return;
|
2340
|
+
}
|
2341
|
+
if (isCloning) {
|
2342
|
+
const res = await clone(
|
2343
|
+
{
|
2344
|
+
model,
|
2345
|
+
documentId: cloneMatch.params.origin,
|
2346
|
+
params
|
2347
|
+
},
|
2348
|
+
transformData(document)
|
2349
|
+
);
|
2350
|
+
if ("data" in res) {
|
2351
|
+
navigate(
|
2352
|
+
{
|
2353
|
+
pathname: `../${res.data.documentId}`,
|
2354
|
+
search: rawQuery
|
2355
|
+
},
|
2356
|
+
{ relative: "path" }
|
2357
|
+
);
|
2358
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2359
|
+
setErrors(formatValidationErrors(res.error));
|
2360
|
+
}
|
2361
|
+
} else if (documentId || collectionType === SINGLE_TYPES) {
|
2362
|
+
const res = await update(
|
2363
|
+
{
|
2364
|
+
collectionType,
|
2365
|
+
model,
|
2366
|
+
documentId,
|
2367
|
+
params
|
2368
|
+
},
|
2369
|
+
transformData(document)
|
2370
|
+
);
|
2371
|
+
if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2372
|
+
setErrors(formatValidationErrors(res.error));
|
2373
|
+
} else {
|
2374
|
+
resetForm();
|
2375
|
+
}
|
2376
|
+
} else {
|
2377
|
+
const res = await create(
|
2378
|
+
{
|
2379
|
+
model,
|
2380
|
+
params
|
2381
|
+
},
|
2382
|
+
transformData(document)
|
2383
|
+
);
|
2384
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
2385
|
+
navigate(
|
2386
|
+
{
|
2387
|
+
pathname: `../${res.data.documentId}`,
|
2388
|
+
search: rawQuery
|
2389
|
+
},
|
2390
|
+
{ replace: true, relative: "path" }
|
2391
|
+
);
|
2392
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2393
|
+
setErrors(formatValidationErrors(res.error));
|
2394
|
+
}
|
2395
|
+
}
|
2396
|
+
} finally {
|
2397
|
+
setSubmitting(false);
|
2398
|
+
}
|
2399
|
+
}, [
|
2400
|
+
clone,
|
2401
|
+
cloneMatch?.params.origin,
|
2402
|
+
collectionType,
|
2403
|
+
create,
|
2404
|
+
document,
|
2405
|
+
documentId,
|
2406
|
+
formatMessage,
|
2407
|
+
formatValidationErrors,
|
2408
|
+
isCloning,
|
2409
|
+
model,
|
2410
|
+
modified,
|
2411
|
+
navigate,
|
2412
|
+
params,
|
2413
|
+
rawQuery,
|
2414
|
+
resetForm,
|
2415
|
+
setErrors,
|
2416
|
+
setSubmitting,
|
2417
|
+
toggleNotification,
|
2418
|
+
update,
|
2419
|
+
validate
|
2420
|
+
]);
|
2421
|
+
React__namespace.useEffect(() => {
|
2422
|
+
const handleKeyDown = (e) => {
|
2423
|
+
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
2424
|
+
e.preventDefault();
|
2425
|
+
handleUpdate();
|
2426
|
+
}
|
2427
|
+
};
|
2428
|
+
window.addEventListener("keydown", handleKeyDown);
|
2429
|
+
return () => {
|
2430
|
+
window.removeEventListener("keydown", handleKeyDown);
|
2431
|
+
};
|
2432
|
+
}, [handleUpdate]);
|
1910
2433
|
return {
|
1911
2434
|
/**
|
1912
2435
|
* Disabled when:
|
@@ -1916,87 +2439,14 @@ const UpdateAction = ({
|
|
1916
2439
|
*/
|
1917
2440
|
disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
|
1918
2441
|
label: formatMessage({
|
1919
|
-
id: "
|
2442
|
+
id: "global.save",
|
1920
2443
|
defaultMessage: "Save"
|
1921
2444
|
}),
|
1922
|
-
onClick:
|
1923
|
-
setSubmitting(true);
|
1924
|
-
try {
|
1925
|
-
if (activeTab !== "draft") {
|
1926
|
-
const { errors } = await validate();
|
1927
|
-
if (errors) {
|
1928
|
-
toggleNotification({
|
1929
|
-
type: "danger",
|
1930
|
-
message: formatMessage({
|
1931
|
-
id: "content-manager.validation.error",
|
1932
|
-
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
1933
|
-
})
|
1934
|
-
});
|
1935
|
-
return;
|
1936
|
-
}
|
1937
|
-
}
|
1938
|
-
if (isCloning) {
|
1939
|
-
const res = await clone(
|
1940
|
-
{
|
1941
|
-
model,
|
1942
|
-
documentId: cloneMatch.params.origin,
|
1943
|
-
params
|
1944
|
-
},
|
1945
|
-
document
|
1946
|
-
);
|
1947
|
-
if ("data" in res) {
|
1948
|
-
navigate(
|
1949
|
-
{
|
1950
|
-
pathname: `../${res.data.documentId}`,
|
1951
|
-
search: rawQuery
|
1952
|
-
},
|
1953
|
-
{ relative: "path" }
|
1954
|
-
);
|
1955
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1956
|
-
setErrors(formatValidationErrors(res.error));
|
1957
|
-
}
|
1958
|
-
} else if (documentId || collectionType === SINGLE_TYPES) {
|
1959
|
-
const res = await update(
|
1960
|
-
{
|
1961
|
-
collectionType,
|
1962
|
-
model,
|
1963
|
-
documentId,
|
1964
|
-
params
|
1965
|
-
},
|
1966
|
-
document
|
1967
|
-
);
|
1968
|
-
if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1969
|
-
setErrors(formatValidationErrors(res.error));
|
1970
|
-
} else {
|
1971
|
-
resetForm();
|
1972
|
-
}
|
1973
|
-
} else {
|
1974
|
-
const res = await create(
|
1975
|
-
{
|
1976
|
-
model,
|
1977
|
-
params
|
1978
|
-
},
|
1979
|
-
document
|
1980
|
-
);
|
1981
|
-
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1982
|
-
navigate(
|
1983
|
-
{
|
1984
|
-
pathname: `../${res.data.documentId}`,
|
1985
|
-
search: rawQuery
|
1986
|
-
},
|
1987
|
-
{ replace: true, relative: "path" }
|
1988
|
-
);
|
1989
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1990
|
-
setErrors(formatValidationErrors(res.error));
|
1991
|
-
}
|
1992
|
-
}
|
1993
|
-
} finally {
|
1994
|
-
setSubmitting(false);
|
1995
|
-
}
|
1996
|
-
}
|
2445
|
+
onClick: handleUpdate
|
1997
2446
|
};
|
1998
2447
|
};
|
1999
2448
|
UpdateAction.type = "update";
|
2449
|
+
UpdateAction.position = "panel";
|
2000
2450
|
const UNPUBLISH_DRAFT_OPTIONS = {
|
2001
2451
|
KEEP: "keep",
|
2002
2452
|
DISCARD: "discard"
|
@@ -2119,6 +2569,7 @@ const UnpublishAction$1 = ({
|
|
2119
2569
|
};
|
2120
2570
|
};
|
2121
2571
|
UnpublishAction$1.type = "unpublish";
|
2572
|
+
UnpublishAction$1.position = "panel";
|
2122
2573
|
const DiscardAction = ({
|
2123
2574
|
activeTab,
|
2124
2575
|
documentId,
|
@@ -2169,6 +2620,7 @@ const DiscardAction = ({
|
|
2169
2620
|
};
|
2170
2621
|
};
|
2171
2622
|
DiscardAction.type = "discard";
|
2623
|
+
DiscardAction.position = "panel";
|
2172
2624
|
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
2173
2625
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
2174
2626
|
const RelativeTime = React__namespace.forwardRef(
|
@@ -2181,7 +2633,7 @@ const RelativeTime = React__namespace.forwardRef(
|
|
2181
2633
|
});
|
2182
2634
|
const unit = intervals.find((intervalUnit) => {
|
2183
2635
|
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
|
2184
|
-
});
|
2636
|
+
}) ?? "seconds";
|
2185
2637
|
const relativeTime = dateFns.isPast(timestamp) ? -interval[unit] : interval[unit];
|
2186
2638
|
const customInterval = customIntervals.find(
|
2187
2639
|
(custom) => interval[custom.unit] < custom.threshold
|
@@ -2215,19 +2667,29 @@ const getDisplayName = ({
|
|
2215
2667
|
return email ?? "";
|
2216
2668
|
};
|
2217
2669
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2218
|
-
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2219
|
-
const statusVariant = status === "draft" ? "
|
2220
|
-
|
2670
|
+
const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
|
2671
|
+
const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
|
2672
|
+
const { formatMessage } = reactIntl.useIntl();
|
2673
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
|
2674
|
+
id: `content-manager.containers.List.${status}`,
|
2675
|
+
defaultMessage: capitalise(status)
|
2676
|
+
}) }) });
|
2221
2677
|
};
|
2222
2678
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
2223
2679
|
const { formatMessage } = reactIntl.useIntl();
|
2224
2680
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2681
|
+
const params = reactRouterDom.useParams();
|
2225
2682
|
const title = isCreating ? formatMessage({
|
2226
2683
|
id: "content-manager.containers.edit.title.new",
|
2227
2684
|
defaultMessage: "Create an entry"
|
2228
2685
|
}) : documentTitle;
|
2229
2686
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2230
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
2687
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2688
|
+
strapiAdmin.BackButton,
|
2689
|
+
{
|
2690
|
+
fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
|
2691
|
+
}
|
2692
|
+
),
|
2231
2693
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2232
2694
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2233
2695
|
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
@@ -2278,7 +2740,7 @@ const HeaderToolbar = () => {
|
|
2278
2740
|
meta: isCloning ? void 0 : meta,
|
2279
2741
|
collectionType
|
2280
2742
|
},
|
2281
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2743
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("header"),
|
2282
2744
|
children: (actions2) => {
|
2283
2745
|
const headerActions = actions2.filter((action) => {
|
2284
2746
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -2315,12 +2777,12 @@ const Information = ({ activeTab }) => {
|
|
2315
2777
|
isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
|
2316
2778
|
label: formatMessage({
|
2317
2779
|
id: "content-manager.containers.edit.information.last-published.label",
|
2318
|
-
defaultMessage: "
|
2780
|
+
defaultMessage: "Published"
|
2319
2781
|
}),
|
2320
2782
|
value: formatMessage(
|
2321
2783
|
{
|
2322
2784
|
id: "content-manager.containers.edit.information.last-published.value",
|
2323
|
-
defaultMessage: `
|
2785
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2324
2786
|
},
|
2325
2787
|
{
|
2326
2788
|
time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
|
@@ -2333,12 +2795,12 @@ const Information = ({ activeTab }) => {
|
|
2333
2795
|
isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
|
2334
2796
|
label: formatMessage({
|
2335
2797
|
id: "content-manager.containers.edit.information.last-draft.label",
|
2336
|
-
defaultMessage: "
|
2798
|
+
defaultMessage: "Updated"
|
2337
2799
|
}),
|
2338
2800
|
value: formatMessage(
|
2339
2801
|
{
|
2340
2802
|
id: "content-manager.containers.edit.information.last-draft.value",
|
2341
|
-
defaultMessage: `
|
2803
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2342
2804
|
},
|
2343
2805
|
{
|
2344
2806
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2356,12 +2818,12 @@ const Information = ({ activeTab }) => {
|
|
2356
2818
|
isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
|
2357
2819
|
label: formatMessage({
|
2358
2820
|
id: "content-manager.containers.edit.information.document.label",
|
2359
|
-
defaultMessage: "
|
2821
|
+
defaultMessage: "Created"
|
2360
2822
|
}),
|
2361
2823
|
value: formatMessage(
|
2362
2824
|
{
|
2363
2825
|
id: "content-manager.containers.edit.information.document.value",
|
2364
|
-
defaultMessage: `
|
2826
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2365
2827
|
},
|
2366
2828
|
{
|
2367
2829
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2399,25 +2861,77 @@ const Information = ({ activeTab }) => {
|
|
2399
2861
|
);
|
2400
2862
|
};
|
2401
2863
|
const HeaderActions = ({ actions: actions2 }) => {
|
2402
|
-
|
2403
|
-
|
2864
|
+
const [dialogId, setDialogId] = React__namespace.useState(null);
|
2865
|
+
const handleClick = (action) => async (e) => {
|
2866
|
+
if (!("options" in action)) {
|
2867
|
+
const { onClick = () => false, dialog, id } = action;
|
2868
|
+
const muteDialog = await onClick(e);
|
2869
|
+
if (dialog && !muteDialog) {
|
2870
|
+
e.preventDefault();
|
2871
|
+
setDialogId(id);
|
2872
|
+
}
|
2873
|
+
}
|
2874
|
+
};
|
2875
|
+
const handleClose = () => {
|
2876
|
+
setDialogId(null);
|
2877
|
+
};
|
2878
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, children: actions2.map((action) => {
|
2879
|
+
if (action.options) {
|
2404
2880
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
2405
2881
|
designSystem.SingleSelect,
|
2406
2882
|
{
|
2407
2883
|
size: "S",
|
2408
|
-
disabled: action.disabled,
|
2409
|
-
"aria-label": action.label,
|
2410
2884
|
onChange: action.onSelect,
|
2411
|
-
|
2885
|
+
"aria-label": action.label,
|
2886
|
+
...action,
|
2412
2887
|
children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
|
2413
2888
|
},
|
2414
2889
|
action.id
|
2415
2890
|
);
|
2416
2891
|
} else {
|
2417
|
-
|
2892
|
+
if (action.type === "icon") {
|
2893
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
|
2894
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2895
|
+
designSystem.IconButton,
|
2896
|
+
{
|
2897
|
+
disabled: action.disabled,
|
2898
|
+
label: action.label,
|
2899
|
+
size: "S",
|
2900
|
+
onClick: handleClick(action),
|
2901
|
+
children: action.icon
|
2902
|
+
}
|
2903
|
+
),
|
2904
|
+
action.dialog ? /* @__PURE__ */ jsxRuntime.jsx(
|
2905
|
+
HeaderActionDialog,
|
2906
|
+
{
|
2907
|
+
...action.dialog,
|
2908
|
+
isOpen: dialogId === action.id,
|
2909
|
+
onClose: handleClose
|
2910
|
+
}
|
2911
|
+
) : null
|
2912
|
+
] }, action.id);
|
2913
|
+
}
|
2418
2914
|
}
|
2419
2915
|
}) });
|
2420
2916
|
};
|
2917
|
+
const HeaderActionDialog = ({
|
2918
|
+
onClose,
|
2919
|
+
onCancel,
|
2920
|
+
title,
|
2921
|
+
content: Content,
|
2922
|
+
isOpen
|
2923
|
+
}) => {
|
2924
|
+
const handleClose = async () => {
|
2925
|
+
if (onCancel) {
|
2926
|
+
await onCancel();
|
2927
|
+
}
|
2928
|
+
onClose();
|
2929
|
+
};
|
2930
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2931
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
2932
|
+
typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content
|
2933
|
+
] }) });
|
2934
|
+
};
|
2421
2935
|
const ConfigureTheViewAction = ({ collectionType, model }) => {
|
2422
2936
|
const navigate = reactRouterDom.useNavigate();
|
2423
2937
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2434,6 +2948,7 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
|
|
2434
2948
|
};
|
2435
2949
|
};
|
2436
2950
|
ConfigureTheViewAction.type = "configure-the-view";
|
2951
|
+
ConfigureTheViewAction.position = "header";
|
2437
2952
|
const EditTheModelAction = ({ model }) => {
|
2438
2953
|
const navigate = reactRouterDom.useNavigate();
|
2439
2954
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2450,6 +2965,7 @@ const EditTheModelAction = ({ model }) => {
|
|
2450
2965
|
};
|
2451
2966
|
};
|
2452
2967
|
EditTheModelAction.type = "edit-the-model";
|
2968
|
+
EditTheModelAction.position = "header";
|
2453
2969
|
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2454
2970
|
const navigate = reactRouterDom.useNavigate();
|
2455
2971
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2458,12 +2974,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2458
2974
|
const { delete: deleteAction } = useDocumentActions();
|
2459
2975
|
const { toggleNotification } = strapiAdmin.useNotification();
|
2460
2976
|
const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
|
2977
|
+
const isLocalized = document?.locale != null;
|
2461
2978
|
return {
|
2462
2979
|
disabled: !canDelete || !document,
|
2463
|
-
label: formatMessage(
|
2464
|
-
|
2465
|
-
|
2466
|
-
|
2980
|
+
label: formatMessage(
|
2981
|
+
{
|
2982
|
+
id: "content-manager.actions.delete.label",
|
2983
|
+
defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
|
2984
|
+
},
|
2985
|
+
{ isLocalized }
|
2986
|
+
),
|
2467
2987
|
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
|
2468
2988
|
dialog: {
|
2469
2989
|
type: "dialog",
|
@@ -2501,422 +3021,120 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2501
3021
|
model,
|
2502
3022
|
collectionType,
|
2503
3023
|
params: {
|
2504
|
-
locale: "*"
|
2505
|
-
}
|
2506
|
-
});
|
2507
|
-
if (!("error" in res)) {
|
2508
|
-
navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
|
2509
|
-
}
|
2510
|
-
} finally {
|
2511
|
-
if (!listViewPathMatch) {
|
2512
|
-
setSubmitting(false);
|
2513
|
-
}
|
2514
|
-
}
|
2515
|
-
}
|
2516
|
-
},
|
2517
|
-
variant: "danger",
|
2518
|
-
position: ["header", "table-row"]
|
2519
|
-
};
|
2520
|
-
};
|
2521
|
-
DeleteAction$1.type = "delete";
|
2522
|
-
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2523
|
-
const Panels = () => {
|
2524
|
-
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2525
|
-
const [
|
2526
|
-
{
|
2527
|
-
query: { status }
|
2528
|
-
}
|
2529
|
-
] = strapiAdmin.useQueryParams({
|
2530
|
-
status: "draft"
|
2531
|
-
});
|
2532
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2533
|
-
const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
|
2534
|
-
const props = {
|
2535
|
-
activeTab: status,
|
2536
|
-
model,
|
2537
|
-
documentId: id,
|
2538
|
-
document: isCloning ? void 0 : document,
|
2539
|
-
meta: isCloning ? void 0 : meta,
|
2540
|
-
collectionType
|
2541
|
-
};
|
2542
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
2543
|
-
strapiAdmin.DescriptionComponentRenderer,
|
2544
|
-
{
|
2545
|
-
props,
|
2546
|
-
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
2547
|
-
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
|
2548
|
-
}
|
2549
|
-
) });
|
2550
|
-
};
|
2551
|
-
const ActionsPanel = () => {
|
2552
|
-
const { formatMessage } = reactIntl.useIntl();
|
2553
|
-
return {
|
2554
|
-
title: formatMessage({
|
2555
|
-
id: "content-manager.containers.edit.panels.default.title",
|
2556
|
-
defaultMessage: "Document"
|
2557
|
-
}),
|
2558
|
-
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2559
|
-
};
|
2560
|
-
};
|
2561
|
-
ActionsPanel.type = "actions";
|
2562
|
-
const ActionsPanelContent = () => {
|
2563
|
-
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2564
|
-
const [
|
2565
|
-
{
|
2566
|
-
query: { status = "draft" }
|
2567
|
-
}
|
2568
|
-
] = strapiAdmin.useQueryParams();
|
2569
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2570
|
-
const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
|
2571
|
-
const props = {
|
2572
|
-
activeTab: status,
|
2573
|
-
model,
|
2574
|
-
documentId: id,
|
2575
|
-
document: isCloning ? void 0 : document,
|
2576
|
-
meta: isCloning ? void 0 : meta,
|
2577
|
-
collectionType
|
2578
|
-
};
|
2579
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
|
2580
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
2581
|
-
strapiAdmin.DescriptionComponentRenderer,
|
2582
|
-
{
|
2583
|
-
props,
|
2584
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2585
|
-
children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
|
2586
|
-
}
|
2587
|
-
),
|
2588
|
-
/* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
2589
|
-
] });
|
2590
|
-
};
|
2591
|
-
const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
2592
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
2593
|
-
designSystem.Flex,
|
2594
|
-
{
|
2595
|
-
ref,
|
2596
|
-
tag: "aside",
|
2597
|
-
"aria-labelledby": "additional-information",
|
2598
|
-
background: "neutral0",
|
2599
|
-
borderColor: "neutral150",
|
2600
|
-
hasRadius: true,
|
2601
|
-
paddingBottom: 4,
|
2602
|
-
paddingLeft: 4,
|
2603
|
-
paddingRight: 4,
|
2604
|
-
paddingTop: 4,
|
2605
|
-
shadow: "tableShadow",
|
2606
|
-
gap: 3,
|
2607
|
-
direction: "column",
|
2608
|
-
justifyContent: "stretch",
|
2609
|
-
alignItems: "flex-start",
|
2610
|
-
children: [
|
2611
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
|
2612
|
-
children
|
2613
|
-
]
|
2614
|
-
}
|
2615
|
-
);
|
2616
|
-
});
|
2617
|
-
const HOOKS = {
|
2618
|
-
/**
|
2619
|
-
* Hook that allows to mutate the displayed headers of the list view table
|
2620
|
-
* @constant
|
2621
|
-
* @type {string}
|
2622
|
-
*/
|
2623
|
-
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
2624
|
-
/**
|
2625
|
-
* Hook that allows to mutate the CM's collection types links pre-set filters
|
2626
|
-
* @constant
|
2627
|
-
* @type {string}
|
2628
|
-
*/
|
2629
|
-
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
2630
|
-
/**
|
2631
|
-
* Hook that allows to mutate the CM's edit view layout
|
2632
|
-
* @constant
|
2633
|
-
* @type {string}
|
2634
|
-
*/
|
2635
|
-
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
2636
|
-
/**
|
2637
|
-
* Hook that allows to mutate the CM's single types links pre-set filters
|
2638
|
-
* @constant
|
2639
|
-
* @type {string}
|
2640
|
-
*/
|
2641
|
-
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
2642
|
-
};
|
2643
|
-
const contentTypesApi = contentManagerApi.injectEndpoints({
|
2644
|
-
endpoints: (builder) => ({
|
2645
|
-
getContentTypeConfiguration: builder.query({
|
2646
|
-
query: (uid) => ({
|
2647
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2648
|
-
method: "GET"
|
2649
|
-
}),
|
2650
|
-
transformResponse: (response) => response.data,
|
2651
|
-
providesTags: (_result, _error, uid) => [
|
2652
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2653
|
-
{ type: "ContentTypeSettings", id: "LIST" }
|
2654
|
-
]
|
2655
|
-
}),
|
2656
|
-
getAllContentTypeSettings: builder.query({
|
2657
|
-
query: () => "/content-manager/content-types-settings",
|
2658
|
-
transformResponse: (response) => response.data,
|
2659
|
-
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
2660
|
-
}),
|
2661
|
-
updateContentTypeConfiguration: builder.mutation({
|
2662
|
-
query: ({ uid, ...body }) => ({
|
2663
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2664
|
-
method: "PUT",
|
2665
|
-
data: body
|
2666
|
-
}),
|
2667
|
-
transformResponse: (response) => response.data,
|
2668
|
-
invalidatesTags: (_result, _error, { uid }) => [
|
2669
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2670
|
-
{ type: "ContentTypeSettings", id: "LIST" },
|
2671
|
-
// Is this necessary?
|
2672
|
-
{ type: "InitialData" }
|
2673
|
-
]
|
2674
|
-
})
|
2675
|
-
})
|
2676
|
-
});
|
2677
|
-
const {
|
2678
|
-
useGetContentTypeConfigurationQuery,
|
2679
|
-
useGetAllContentTypeSettingsQuery,
|
2680
|
-
useUpdateContentTypeConfigurationMutation
|
2681
|
-
} = contentTypesApi;
|
2682
|
-
const checkIfAttributeIsDisplayable = (attribute) => {
|
2683
|
-
const { type } = attribute;
|
2684
|
-
if (type === "relation") {
|
2685
|
-
return !attribute.relation.toLowerCase().includes("morph");
|
2686
|
-
}
|
2687
|
-
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
2688
|
-
};
|
2689
|
-
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
2690
|
-
if (!mainFieldName) {
|
2691
|
-
return void 0;
|
2692
|
-
}
|
2693
|
-
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
2694
|
-
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
2695
|
-
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2696
|
-
);
|
2697
|
-
return {
|
2698
|
-
name: mainFieldName,
|
2699
|
-
type: mainFieldType ?? "string"
|
2700
|
-
};
|
2701
|
-
};
|
2702
|
-
const DEFAULT_SETTINGS = {
|
2703
|
-
bulkable: false,
|
2704
|
-
filterable: false,
|
2705
|
-
searchable: false,
|
2706
|
-
pagination: false,
|
2707
|
-
defaultSortBy: "",
|
2708
|
-
defaultSortOrder: "asc",
|
2709
|
-
mainField: "id",
|
2710
|
-
pageSize: 10
|
2711
|
-
};
|
2712
|
-
const useDocumentLayout = (model) => {
|
2713
|
-
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
2714
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
2715
|
-
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
2716
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
2717
|
-
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
2718
|
-
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
2719
|
-
const {
|
2720
|
-
data,
|
2721
|
-
isLoading: isLoadingConfigs,
|
2722
|
-
error,
|
2723
|
-
isFetching: isFetchingConfigs
|
2724
|
-
} = useGetContentTypeConfigurationQuery(model);
|
2725
|
-
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
2726
|
-
React__namespace.useEffect(() => {
|
2727
|
-
if (error) {
|
2728
|
-
toggleNotification({
|
2729
|
-
type: "danger",
|
2730
|
-
message: formatAPIError(error)
|
2731
|
-
});
|
2732
|
-
}
|
2733
|
-
}, [error, formatAPIError, toggleNotification]);
|
2734
|
-
const editLayout = React__namespace.useMemo(
|
2735
|
-
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
2736
|
-
layout: [],
|
2737
|
-
components: {},
|
2738
|
-
metadatas: {},
|
2739
|
-
options: {},
|
2740
|
-
settings: DEFAULT_SETTINGS
|
2741
|
-
},
|
2742
|
-
[data, isLoading, schemas, schema, components]
|
2743
|
-
);
|
2744
|
-
const listLayout = React__namespace.useMemo(() => {
|
2745
|
-
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
2746
|
-
layout: [],
|
2747
|
-
metadatas: {},
|
2748
|
-
options: {},
|
2749
|
-
settings: DEFAULT_SETTINGS
|
2750
|
-
};
|
2751
|
-
}, [data, isLoading, schemas, schema, components]);
|
2752
|
-
const { layout: edit } = React__namespace.useMemo(
|
2753
|
-
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
2754
|
-
layout: editLayout,
|
2755
|
-
query
|
2756
|
-
}),
|
2757
|
-
[editLayout, query, runHookWaterfall]
|
2758
|
-
);
|
2759
|
-
return {
|
2760
|
-
error,
|
2761
|
-
isLoading,
|
2762
|
-
edit,
|
2763
|
-
list: listLayout
|
2764
|
-
};
|
2765
|
-
};
|
2766
|
-
const useDocLayout = () => {
|
2767
|
-
const { model } = useDoc();
|
2768
|
-
return useDocumentLayout(model);
|
2769
|
-
};
|
2770
|
-
const formatEditLayout = (data, {
|
2771
|
-
schemas,
|
2772
|
-
schema,
|
2773
|
-
components
|
2774
|
-
}) => {
|
2775
|
-
let currentPanelIndex = 0;
|
2776
|
-
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
2777
|
-
data.contentType.layouts.edit,
|
2778
|
-
schema?.attributes,
|
2779
|
-
data.contentType.metadatas,
|
2780
|
-
{ configurations: data.components, schemas: components },
|
2781
|
-
schemas
|
2782
|
-
).reduce((panels, row) => {
|
2783
|
-
if (row.some((field) => field.type === "dynamiczone")) {
|
2784
|
-
panels.push([row]);
|
2785
|
-
currentPanelIndex += 2;
|
2786
|
-
} else {
|
2787
|
-
if (!panels[currentPanelIndex]) {
|
2788
|
-
panels.push([]);
|
2789
|
-
}
|
2790
|
-
panels[currentPanelIndex].push(row);
|
2791
|
-
}
|
2792
|
-
return panels;
|
2793
|
-
}, []);
|
2794
|
-
const componentEditAttributes = Object.entries(data.components).reduce(
|
2795
|
-
(acc, [uid, configuration]) => {
|
2796
|
-
acc[uid] = {
|
2797
|
-
layout: convertEditLayoutToFieldLayouts(
|
2798
|
-
configuration.layouts.edit,
|
2799
|
-
components[uid].attributes,
|
2800
|
-
configuration.metadatas,
|
2801
|
-
{ configurations: data.components, schemas: components }
|
2802
|
-
),
|
2803
|
-
settings: {
|
2804
|
-
...configuration.settings,
|
2805
|
-
icon: components[uid].info.icon,
|
2806
|
-
displayName: components[uid].info.displayName
|
3024
|
+
locale: "*"
|
3025
|
+
}
|
3026
|
+
});
|
3027
|
+
if (!("error" in res)) {
|
3028
|
+
navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
|
3029
|
+
}
|
3030
|
+
} finally {
|
3031
|
+
if (!listViewPathMatch) {
|
3032
|
+
setSubmitting(false);
|
3033
|
+
}
|
2807
3034
|
}
|
2808
|
-
}
|
2809
|
-
return acc;
|
2810
|
-
},
|
2811
|
-
{}
|
2812
|
-
);
|
2813
|
-
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2814
|
-
(acc, [attribute, metadata]) => {
|
2815
|
-
return {
|
2816
|
-
...acc,
|
2817
|
-
[attribute]: metadata.edit
|
2818
|
-
};
|
2819
|
-
},
|
2820
|
-
{}
|
2821
|
-
);
|
2822
|
-
return {
|
2823
|
-
layout: panelledEditAttributes,
|
2824
|
-
components: componentEditAttributes,
|
2825
|
-
metadatas: editMetadatas,
|
2826
|
-
settings: {
|
2827
|
-
...data.contentType.settings,
|
2828
|
-
displayName: schema?.info.displayName
|
3035
|
+
}
|
2829
3036
|
},
|
2830
|
-
|
2831
|
-
|
2832
|
-
...schema?.pluginOptions,
|
2833
|
-
...data.contentType.options
|
2834
|
-
}
|
3037
|
+
variant: "danger",
|
3038
|
+
position: ["header", "table-row"]
|
2835
3039
|
};
|
2836
3040
|
};
|
2837
|
-
|
2838
|
-
|
2839
|
-
|
2840
|
-
|
2841
|
-
|
2842
|
-
|
2843
|
-
|
2844
|
-
|
2845
|
-
|
2846
|
-
|
2847
|
-
|
2848
|
-
|
2849
|
-
|
2850
|
-
|
2851
|
-
|
2852
|
-
|
2853
|
-
|
2854
|
-
|
2855
|
-
|
2856
|
-
|
2857
|
-
|
2858
|
-
|
2859
|
-
|
2860
|
-
|
2861
|
-
|
2862
|
-
|
2863
|
-
|
2864
|
-
|
2865
|
-
|
3041
|
+
DeleteAction$1.type = "delete";
|
3042
|
+
DeleteAction$1.position = ["header", "table-row"];
|
3043
|
+
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
3044
|
+
const Panels = () => {
|
3045
|
+
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
3046
|
+
const [
|
3047
|
+
{
|
3048
|
+
query: { status }
|
3049
|
+
}
|
3050
|
+
] = strapiAdmin.useQueryParams({
|
3051
|
+
status: "draft"
|
3052
|
+
});
|
3053
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
3054
|
+
const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
|
3055
|
+
const props = {
|
3056
|
+
activeTab: status,
|
3057
|
+
model,
|
3058
|
+
documentId: id,
|
3059
|
+
document: isCloning ? void 0 : document,
|
3060
|
+
meta: isCloning ? void 0 : meta,
|
3061
|
+
collectionType
|
3062
|
+
};
|
3063
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
3064
|
+
strapiAdmin.DescriptionComponentRenderer,
|
3065
|
+
{
|
3066
|
+
props,
|
3067
|
+
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
3068
|
+
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
|
3069
|
+
}
|
3070
|
+
) });
|
2866
3071
|
};
|
2867
|
-
const
|
2868
|
-
|
2869
|
-
schema,
|
2870
|
-
components
|
2871
|
-
}) => {
|
2872
|
-
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2873
|
-
(acc, [attribute, metadata]) => {
|
2874
|
-
return {
|
2875
|
-
...acc,
|
2876
|
-
[attribute]: metadata.list
|
2877
|
-
};
|
2878
|
-
},
|
2879
|
-
{}
|
2880
|
-
);
|
2881
|
-
const listAttributes = convertListLayoutToFieldLayouts(
|
2882
|
-
data.contentType.layouts.list,
|
2883
|
-
schema?.attributes,
|
2884
|
-
listMetadatas,
|
2885
|
-
{ configurations: data.components, schemas: components },
|
2886
|
-
schemas
|
2887
|
-
);
|
3072
|
+
const ActionsPanel = () => {
|
3073
|
+
const { formatMessage } = reactIntl.useIntl();
|
2888
3074
|
return {
|
2889
|
-
|
2890
|
-
|
2891
|
-
|
2892
|
-
|
2893
|
-
|
2894
|
-
...schema?.pluginOptions,
|
2895
|
-
...data.contentType.options
|
2896
|
-
}
|
3075
|
+
title: formatMessage({
|
3076
|
+
id: "content-manager.containers.edit.panels.default.title",
|
3077
|
+
defaultMessage: "Entry"
|
3078
|
+
}),
|
3079
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2897
3080
|
};
|
2898
3081
|
};
|
2899
|
-
|
2900
|
-
|
2901
|
-
|
2902
|
-
|
2903
|
-
|
3082
|
+
ActionsPanel.type = "actions";
|
3083
|
+
const ActionsPanelContent = () => {
|
3084
|
+
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
3085
|
+
const [
|
3086
|
+
{
|
3087
|
+
query: { status = "draft" }
|
2904
3088
|
}
|
2905
|
-
|
2906
|
-
|
2907
|
-
|
2908
|
-
|
2909
|
-
|
2910
|
-
|
2911
|
-
|
2912
|
-
|
2913
|
-
|
2914
|
-
|
2915
|
-
|
2916
|
-
|
2917
|
-
|
2918
|
-
|
3089
|
+
] = strapiAdmin.useQueryParams();
|
3090
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
3091
|
+
const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
|
3092
|
+
const props = {
|
3093
|
+
activeTab: status,
|
3094
|
+
model,
|
3095
|
+
documentId: id,
|
3096
|
+
document: isCloning ? void 0 : document,
|
3097
|
+
meta: isCloning ? void 0 : meta,
|
3098
|
+
collectionType
|
3099
|
+
};
|
3100
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
|
3101
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3102
|
+
strapiAdmin.DescriptionComponentRenderer,
|
3103
|
+
{
|
3104
|
+
props,
|
3105
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("panel"),
|
3106
|
+
children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
|
3107
|
+
}
|
3108
|
+
),
|
3109
|
+
/* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
3110
|
+
] });
|
2919
3111
|
};
|
3112
|
+
const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
3113
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
3114
|
+
designSystem.Flex,
|
3115
|
+
{
|
3116
|
+
ref,
|
3117
|
+
tag: "aside",
|
3118
|
+
"aria-labelledby": "additional-information",
|
3119
|
+
background: "neutral0",
|
3120
|
+
borderColor: "neutral150",
|
3121
|
+
hasRadius: true,
|
3122
|
+
paddingBottom: 4,
|
3123
|
+
paddingLeft: 4,
|
3124
|
+
paddingRight: 4,
|
3125
|
+
paddingTop: 4,
|
3126
|
+
shadow: "tableShadow",
|
3127
|
+
gap: 3,
|
3128
|
+
direction: "column",
|
3129
|
+
justifyContent: "stretch",
|
3130
|
+
alignItems: "flex-start",
|
3131
|
+
children: [
|
3132
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
|
3133
|
+
children
|
3134
|
+
]
|
3135
|
+
}
|
3136
|
+
);
|
3137
|
+
});
|
2920
3138
|
const ConfirmBulkActionDialog = ({
|
2921
3139
|
onToggleDialog,
|
2922
3140
|
isOpen = false,
|
@@ -3161,18 +3379,10 @@ const SelectedEntriesTableContent = ({
|
|
3161
3379
|
search: row.locale && `?plugins[i18n][locale]=${row.locale}`
|
3162
3380
|
},
|
3163
3381
|
state: { from: pathname },
|
3164
|
-
label: formatMessage(
|
3165
|
-
|
3166
|
-
|
3167
|
-
|
3168
|
-
{
|
3169
|
-
id: "content-manager.components.ListViewHelperPluginTable.row-line",
|
3170
|
-
defaultMessage: "item line {number}"
|
3171
|
-
},
|
3172
|
-
{ number: index2 + 1 }
|
3173
|
-
)
|
3174
|
-
}
|
3175
|
-
),
|
3382
|
+
label: formatMessage({
|
3383
|
+
id: "content-manager.bulk-publish.edit",
|
3384
|
+
defaultMessage: "Edit"
|
3385
|
+
}),
|
3176
3386
|
target: "_blank",
|
3177
3387
|
marginLeft: "auto",
|
3178
3388
|
variant: "ghost",
|
@@ -3346,8 +3556,7 @@ const PublishAction = ({ documents, model }) => {
|
|
3346
3556
|
const refetchList = () => {
|
3347
3557
|
contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
|
3348
3558
|
};
|
3349
|
-
if (!showPublishButton)
|
3350
|
-
return null;
|
3559
|
+
if (!showPublishButton) return null;
|
3351
3560
|
return {
|
3352
3561
|
actionType: "publish",
|
3353
3562
|
variant: "tertiary",
|
@@ -3415,8 +3624,7 @@ const DeleteAction = ({ documents, model }) => {
|
|
3415
3624
|
selectRow([]);
|
3416
3625
|
}
|
3417
3626
|
};
|
3418
|
-
if (!hasDeletePermission)
|
3419
|
-
return null;
|
3627
|
+
if (!hasDeletePermission) return null;
|
3420
3628
|
return {
|
3421
3629
|
variant: "danger-light",
|
3422
3630
|
label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
|
@@ -3465,8 +3673,7 @@ const UnpublishAction = ({ documents, model }) => {
|
|
3465
3673
|
}
|
3466
3674
|
};
|
3467
3675
|
const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
|
3468
|
-
if (!showUnpublishButton)
|
3469
|
-
return null;
|
3676
|
+
if (!showUnpublishButton) return null;
|
3470
3677
|
return {
|
3471
3678
|
variant: "tertiary",
|
3472
3679
|
label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
|
@@ -3571,7 +3778,7 @@ const TableActions = ({ document }) => {
|
|
3571
3778
|
strapiAdmin.DescriptionComponentRenderer,
|
3572
3779
|
{
|
3573
3780
|
props,
|
3574
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
|
3781
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("table-row").filter((action) => action.name !== "PublishAction"),
|
3575
3782
|
children: (actions2) => {
|
3576
3783
|
const tableRowActions = actions2.filter((action) => {
|
3577
3784
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -3630,6 +3837,7 @@ const EditAction = ({ documentId }) => {
|
|
3630
3837
|
};
|
3631
3838
|
};
|
3632
3839
|
EditAction.type = "edit";
|
3840
|
+
EditAction.position = "table-row";
|
3633
3841
|
const StyledPencil = styledComponents.styled(Icons.Pencil)`
|
3634
3842
|
path {
|
3635
3843
|
fill: currentColor;
|
@@ -3706,6 +3914,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3706
3914
|
};
|
3707
3915
|
};
|
3708
3916
|
CloneAction.type = "clone";
|
3917
|
+
CloneAction.position = "table-row";
|
3709
3918
|
const StyledDuplicate = styledComponents.styled(Icons.Duplicate)`
|
3710
3919
|
path {
|
3711
3920
|
fill: currentColor;
|
@@ -3792,7 +4001,14 @@ class ContentManagerPlugin {
|
|
3792
4001
|
addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
|
3793
4002
|
addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
|
3794
4003
|
getBulkActions: () => this.bulkActions,
|
3795
|
-
getDocumentActions: () =>
|
4004
|
+
getDocumentActions: (position) => {
|
4005
|
+
if (position) {
|
4006
|
+
return this.documentActions.filter(
|
4007
|
+
(action) => action.position == void 0 || [action.position].flat().includes(position)
|
4008
|
+
);
|
4009
|
+
}
|
4010
|
+
return this.documentActions;
|
4011
|
+
},
|
3796
4012
|
getEditViewSidePanels: () => this.editViewSidePanels,
|
3797
4013
|
getHeaderActions: () => this.headerActions
|
3798
4014
|
}
|
@@ -3802,10 +4018,8 @@ class ContentManagerPlugin {
|
|
3802
4018
|
const getPrintableType = (value) => {
|
3803
4019
|
const nativeType = typeof value;
|
3804
4020
|
if (nativeType === "object") {
|
3805
|
-
if (value === null)
|
3806
|
-
|
3807
|
-
if (Array.isArray(value))
|
3808
|
-
return "array";
|
4021
|
+
if (value === null) return "null";
|
4022
|
+
if (Array.isArray(value)) return "array";
|
3809
4023
|
if (value instanceof Object && value.constructor.name !== "Object") {
|
3810
4024
|
return value.constructor.name;
|
3811
4025
|
}
|
@@ -3816,17 +4030,27 @@ const HistoryAction = ({ model, document }) => {
|
|
3816
4030
|
const { formatMessage } = reactIntl.useIntl();
|
3817
4031
|
const [{ query }] = strapiAdmin.useQueryParams();
|
3818
4032
|
const navigate = reactRouterDom.useNavigate();
|
4033
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
4034
|
+
const { pathname } = reactRouterDom.useLocation();
|
3819
4035
|
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
3820
4036
|
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
3821
4037
|
return null;
|
3822
4038
|
}
|
4039
|
+
const handleOnClick = () => {
|
4040
|
+
const destination = { pathname: "history", search: pluginsQueryParams };
|
4041
|
+
trackUsage("willNavigate", {
|
4042
|
+
from: pathname,
|
4043
|
+
to: `${pathname}/${destination.pathname}`
|
4044
|
+
});
|
4045
|
+
navigate(destination);
|
4046
|
+
};
|
3823
4047
|
return {
|
3824
4048
|
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
3825
4049
|
label: formatMessage({
|
3826
4050
|
id: "content-manager.history.document-action",
|
3827
4051
|
defaultMessage: "Content History"
|
3828
4052
|
}),
|
3829
|
-
onClick:
|
4053
|
+
onClick: handleOnClick,
|
3830
4054
|
disabled: (
|
3831
4055
|
/**
|
3832
4056
|
* The user is creating a new document.
|
@@ -3848,6 +4072,7 @@ const HistoryAction = ({ model, document }) => {
|
|
3848
4072
|
};
|
3849
4073
|
};
|
3850
4074
|
HistoryAction.type = "history";
|
4075
|
+
HistoryAction.position = "header";
|
3851
4076
|
const historyAdmin = {
|
3852
4077
|
bootstrap(app) {
|
3853
4078
|
const { addDocumentAction } = app.getPlugin("content-manager").apis;
|
@@ -3894,6 +4119,88 @@ const { setInitialData } = actions;
|
|
3894
4119
|
const reducer = toolkit.combineReducers({
|
3895
4120
|
app: reducer$1
|
3896
4121
|
});
|
4122
|
+
const previewApi = contentManagerApi.injectEndpoints({
|
4123
|
+
endpoints: (builder) => ({
|
4124
|
+
getPreviewUrl: builder.query({
|
4125
|
+
query({ query, params }) {
|
4126
|
+
return {
|
4127
|
+
url: `/content-manager/preview/url/${params.contentType}`,
|
4128
|
+
method: "GET",
|
4129
|
+
config: {
|
4130
|
+
params: query
|
4131
|
+
}
|
4132
|
+
};
|
4133
|
+
}
|
4134
|
+
})
|
4135
|
+
})
|
4136
|
+
});
|
4137
|
+
const { useGetPreviewUrlQuery } = previewApi;
|
4138
|
+
const ConditionalTooltip = ({ isShown, label, children }) => {
|
4139
|
+
if (isShown) {
|
4140
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { label, children });
|
4141
|
+
}
|
4142
|
+
return children;
|
4143
|
+
};
|
4144
|
+
const PreviewSidePanel = ({ model, documentId, document }) => {
|
4145
|
+
const { formatMessage } = reactIntl.useIntl();
|
4146
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
4147
|
+
const { pathname } = reactRouterDom.useLocation();
|
4148
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
4149
|
+
const isModified = strapiAdmin.useForm("PreviewSidePanel", (state) => state.modified);
|
4150
|
+
const { data, error } = useGetPreviewUrlQuery({
|
4151
|
+
params: {
|
4152
|
+
contentType: model
|
4153
|
+
},
|
4154
|
+
query: {
|
4155
|
+
documentId,
|
4156
|
+
locale: document?.locale,
|
4157
|
+
status: document?.status
|
4158
|
+
}
|
4159
|
+
});
|
4160
|
+
if (!data?.data?.url || error) {
|
4161
|
+
return null;
|
4162
|
+
}
|
4163
|
+
const trackNavigation = () => {
|
4164
|
+
const destinationPathname = pathname.replace(/\/$/, "") + "/preview";
|
4165
|
+
trackUsage("willNavigate", { from: pathname, to: destinationPathname });
|
4166
|
+
};
|
4167
|
+
return {
|
4168
|
+
title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
|
4169
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(
|
4170
|
+
ConditionalTooltip,
|
4171
|
+
{
|
4172
|
+
label: formatMessage({
|
4173
|
+
id: "content-manager.preview.panel.button-disabled-tooltip",
|
4174
|
+
defaultMessage: "Please save to open the preview"
|
4175
|
+
}),
|
4176
|
+
isShown: isModified,
|
4177
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { cursor: "not-allowed", width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(
|
4178
|
+
designSystem.Button,
|
4179
|
+
{
|
4180
|
+
variant: "tertiary",
|
4181
|
+
tag: reactRouterDom.Link,
|
4182
|
+
to: { pathname: "preview", search: qs.stringify(query, { encode: false }) },
|
4183
|
+
onClick: trackNavigation,
|
4184
|
+
width: "100%",
|
4185
|
+
disabled: isModified,
|
4186
|
+
pointerEvents: isModified ? "none" : void 0,
|
4187
|
+
tabIndex: isModified ? -1 : void 0,
|
4188
|
+
children: formatMessage({
|
4189
|
+
id: "content-manager.preview.panel.button",
|
4190
|
+
defaultMessage: "Open preview"
|
4191
|
+
})
|
4192
|
+
}
|
4193
|
+
) })
|
4194
|
+
}
|
4195
|
+
)
|
4196
|
+
};
|
4197
|
+
};
|
4198
|
+
const previewAdmin = {
|
4199
|
+
bootstrap(app) {
|
4200
|
+
const contentManagerPluginApis = app.getPlugin("content-manager").apis;
|
4201
|
+
contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
|
4202
|
+
}
|
4203
|
+
};
|
3897
4204
|
const index = {
|
3898
4205
|
register(app) {
|
3899
4206
|
const cm = new ContentManagerPlugin();
|
@@ -3913,7 +4220,7 @@ const index = {
|
|
3913
4220
|
app.router.addRoute({
|
3914
4221
|
path: "content-manager/*",
|
3915
4222
|
lazy: async () => {
|
3916
|
-
const { Layout } = await Promise.resolve().then(() => require("./layout-
|
4223
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-BW80JSCd.js"));
|
3917
4224
|
return {
|
3918
4225
|
Component: Layout
|
3919
4226
|
};
|
@@ -3926,11 +4233,14 @@ const index = {
|
|
3926
4233
|
if (typeof historyAdmin.bootstrap === "function") {
|
3927
4234
|
historyAdmin.bootstrap(app);
|
3928
4235
|
}
|
4236
|
+
if (typeof previewAdmin.bootstrap === "function") {
|
4237
|
+
previewAdmin.bootstrap(app);
|
4238
|
+
}
|
3929
4239
|
},
|
3930
4240
|
async registerTrads({ locales }) {
|
3931
4241
|
const importedTrads = await Promise.all(
|
3932
4242
|
locales.map((locale) => {
|
3933
|
-
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-
|
4243
|
+
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-BzQmavmK.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 }) => {
|
3934
4244
|
return {
|
3935
4245
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3936
4246
|
locale
|
@@ -3976,6 +4286,7 @@ exports.getMainField = getMainField;
|
|
3976
4286
|
exports.getTranslation = getTranslation;
|
3977
4287
|
exports.index = index;
|
3978
4288
|
exports.setInitialData = setInitialData;
|
4289
|
+
exports.useContentManagerContext = useContentManagerContext;
|
3979
4290
|
exports.useContentTypeSchema = useContentTypeSchema;
|
3980
4291
|
exports.useDoc = useDoc;
|
3981
4292
|
exports.useDocLayout = useDocLayout;
|
@@ -3987,5 +4298,6 @@ exports.useGetAllContentTypeSettingsQuery = useGetAllContentTypeSettingsQuery;
|
|
3987
4298
|
exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
3988
4299
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
3989
4300
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
4301
|
+
exports.useGetPreviewUrlQuery = useGetPreviewUrlQuery;
|
3990
4302
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
3991
|
-
//# sourceMappingURL=index-
|
4303
|
+
//# sourceMappingURL=index-Ca7YWlAA.js.map
|