@strapi/content-manager 0.0.0-experimental.afa3b513b8f95459043f33fb94f4bac03af1474f → 0.0.0-experimental.b05633daea1bf090c66312b8ab30ec13bdb52f57
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-CnL10QYC.mjs → ComponentConfigurationPage-A5f-t42A.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-CnL10QYC.mjs.map → ComponentConfigurationPage-A5f-t42A.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-G4EIirP8.js → ComponentConfigurationPage-BtmEfYUS.js} +5 -6
- package/dist/_chunks/{ComponentConfigurationPage-G4EIirP8.js.map → ComponentConfigurationPage-BtmEfYUS.js.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-B2AA1kVF.js → EditConfigurationPage-CXLQhPpj.js} +5 -6
- package/dist/_chunks/{EditConfigurationPage-B2AA1kVF.js.map → EditConfigurationPage-CXLQhPpj.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-I2kKh9dx.mjs → EditConfigurationPage-DN6yaDFZ.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-I2kKh9dx.mjs.map → EditConfigurationPage-DN6yaDFZ.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-CHgoNwlc.js → EditViewPage-BW-BJJVg.js} +50 -11
- package/dist/_chunks/EditViewPage-BW-BJJVg.js.map +1 -0
- package/dist/_chunks/{EditViewPage-zFjJK0s8.mjs → EditViewPage-ONky_-8U.mjs} +50 -10
- package/dist/_chunks/EditViewPage-ONky_-8U.mjs.map +1 -0
- package/dist/_chunks/{Field-DPAzUS1M.mjs → Field-B4gAYDmQ.mjs} +215 -92
- package/dist/_chunks/Field-B4gAYDmQ.mjs.map +1 -0
- package/dist/_chunks/{Field-9DePZh-0.js → Field-BMlzghtV.js} +217 -94
- package/dist/_chunks/Field-BMlzghtV.js.map +1 -0
- package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
- package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
- package/dist/_chunks/{Form-DPm-KZ1A.js → Form-DQPyv3UY.js} +6 -7
- package/dist/_chunks/Form-DQPyv3UY.js.map +1 -0
- package/dist/_chunks/{Form-CEkENbkF.mjs → Form-e4RpNQY0.mjs} +4 -4
- package/dist/_chunks/Form-e4RpNQY0.mjs.map +1 -0
- package/dist/_chunks/{History-utls71em.mjs → History-Bk2VCzmJ.mjs} +43 -100
- package/dist/_chunks/History-Bk2VCzmJ.mjs.map +1 -0
- package/dist/_chunks/{History-DXSbTWez.js → History-CzkXjAR0.js} +42 -100
- package/dist/_chunks/History-CzkXjAR0.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-D5C7ACZ_.js → ListConfigurationPage-B9TbaEqp.js} +7 -7
- package/dist/_chunks/ListConfigurationPage-B9TbaEqp.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-CuMXWWqb.mjs → ListConfigurationPage-BhNCzkQd.mjs} +7 -6
- package/dist/_chunks/ListConfigurationPage-BhNCzkQd.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-DfuwH1tt.js → ListViewPage-CIHO4H2J.js} +64 -42
- package/dist/_chunks/ListViewPage-CIHO4H2J.js.map +1 -0
- package/dist/_chunks/{ListViewPage-CdKd-PS_.mjs → ListViewPage-mK-sFVGU.mjs} +63 -40
- package/dist/_chunks/ListViewPage-mK-sFVGU.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DkToTT7u.mjs → NoContentTypePage-BSVg7nZI.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-DkToTT7u.mjs.map → NoContentTypePage-BSVg7nZI.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-BIxlkWWi.js → NoContentTypePage-Dbfi49ek.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-BIxlkWWi.js.map → NoContentTypePage-Dbfi49ek.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-Bu4GWYb-.js → NoPermissionsPage-CDvWOtEy.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-Bu4GWYb-.js.map → NoPermissionsPage-CDvWOtEy.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DlWi4BAH.mjs → NoPermissionsPage-zpYME1_X.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DlWi4BAH.mjs.map → NoPermissionsPage-zpYME1_X.mjs.map} +1 -1
- package/dist/_chunks/Preview-8U27vy1U.js +311 -0
- package/dist/_chunks/Preview-8U27vy1U.js.map +1 -0
- package/dist/_chunks/Preview-Dd3kQluA.mjs +293 -0
- package/dist/_chunks/Preview-Dd3kQluA.mjs.map +1 -0
- package/dist/_chunks/{Relations-QP5yn9_z.mjs → Relations-BvdARGTL.mjs} +75 -41
- package/dist/_chunks/Relations-BvdARGTL.mjs.map +1 -0
- package/dist/_chunks/{Relations-CFjTESWQ.js → Relations-CFMS6Dm8.js} +75 -42
- package/dist/_chunks/Relations-CFMS6Dm8.js.map +1 -0
- package/dist/_chunks/{en-BVzUkPxZ.js → en-BzQmavmK.js} +28 -11
- package/dist/_chunks/{en-BVzUkPxZ.js.map → en-BzQmavmK.js.map} +1 -1
- package/dist/_chunks/{en-CPTj6CjC.mjs → en-CSxLmrh1.mjs} +28 -11
- package/dist/_chunks/{en-CPTj6CjC.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-BHfS6_D5.mjs → index-B3tHjkLZ.mjs} +971 -724
- package/dist/_chunks/index-B3tHjkLZ.mjs.map +1 -0
- package/dist/_chunks/{index-DXiHxy70.js → index-TSBwtMDV.js} +969 -722
- package/dist/_chunks/index-TSBwtMDV.js.map +1 -0
- package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
- package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
- package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
- package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
- package/dist/_chunks/{layout-DX_52HSH.mjs → layout-C71zeI19.mjs} +4 -4
- package/dist/_chunks/{layout-DX_52HSH.mjs.map → layout-C71zeI19.mjs.map} +1 -1
- package/dist/_chunks/{layout-bE-WUnQ0.js → layout-CB2vrWLp.js} +5 -6
- package/dist/_chunks/{layout-bE-WUnQ0.js.map → layout-CB2vrWLp.js.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-D706vblp.js → relations-8mON7ZVQ.js} +6 -7
- package/dist/_chunks/relations-8mON7ZVQ.js.map +1 -0
- package/dist/_chunks/{relations-SCVAL_aJ.mjs → relations-DcEHhh0U.mjs} +6 -7
- package/dist/_chunks/relations-DcEHhh0U.mjs.map +1 -0
- package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -1
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -1
- 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/Header.d.ts +1 -0
- 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 +432 -194
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +432 -193
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +2 -3
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +4 -4
- package/dist/server/src/preview/controllers/index.d.ts +2 -0
- package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/preview.d.ts +13 -0
- package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
- package/dist/server/src/preview/index.d.ts +4 -0
- package/dist/server/src/preview/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/index.d.ts +8 -0
- package/dist/server/src/preview/routes/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/preview.d.ts +4 -0
- package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
- package/dist/server/src/preview/services/index.d.ts +16 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts +32 -0
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview.d.ts +12 -0
- package/dist/server/src/preview/services/preview.d.ts.map +1 -0
- package/dist/server/src/preview/utils.d.ts +19 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -0
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +8 -8
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +4 -4
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
- package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
- package/dist/server/src/utils/index.d.ts +2 -0
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/shared/contracts/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 +14 -12
- package/dist/_chunks/EditViewPage-CHgoNwlc.js.map +0 -1
- package/dist/_chunks/EditViewPage-zFjJK0s8.mjs.map +0 -1
- package/dist/_chunks/Field-9DePZh-0.js.map +0 -1
- package/dist/_chunks/Field-DPAzUS1M.mjs.map +0 -1
- package/dist/_chunks/Form-CEkENbkF.mjs.map +0 -1
- package/dist/_chunks/Form-DPm-KZ1A.js.map +0 -1
- package/dist/_chunks/History-DXSbTWez.js.map +0 -1
- package/dist/_chunks/History-utls71em.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-CuMXWWqb.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-D5C7ACZ_.js.map +0 -1
- package/dist/_chunks/ListViewPage-CdKd-PS_.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-DfuwH1tt.js.map +0 -1
- package/dist/_chunks/Relations-CFjTESWQ.js.map +0 -1
- package/dist/_chunks/Relations-QP5yn9_z.mjs.map +0 -1
- package/dist/_chunks/index-BHfS6_D5.mjs.map +0 -1
- package/dist/_chunks/index-DXiHxy70.js.map +0 -1
- package/dist/_chunks/relations-D706vblp.js.map +0 -1
- package/dist/_chunks/relations-SCVAL_aJ.mjs.map +0 -1
@@ -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,7 +249,8 @@ 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 }
|
252
|
+
{ type: "UidAvailability", id: model },
|
253
|
+
"RecentDocumentList"
|
235
254
|
]
|
236
255
|
}),
|
237
256
|
deleteDocument: builder.mutation({
|
@@ -243,7 +262,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
243
262
|
}
|
244
263
|
}),
|
245
264
|
invalidatesTags: (_result, _error, { collectionType, model }) => [
|
246
|
-
{ type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model }
|
265
|
+
{ type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model },
|
266
|
+
"RecentDocumentList"
|
247
267
|
]
|
248
268
|
}),
|
249
269
|
deleteManyDocuments: builder.mutation({
|
@@ -255,7 +275,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
255
275
|
params
|
256
276
|
}
|
257
277
|
}),
|
258
|
-
invalidatesTags: (_res, _error, { model }) => [
|
278
|
+
invalidatesTags: (_res, _error, { model }) => [
|
279
|
+
{ type: "Document", id: `${model}_LIST` },
|
280
|
+
"RecentDocumentList"
|
281
|
+
]
|
259
282
|
}),
|
260
283
|
discardDocument: builder.mutation({
|
261
284
|
query: ({ collectionType, model, documentId, params }) => ({
|
@@ -273,7 +296,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
273
296
|
},
|
274
297
|
{ type: "Document", id: `${model}_LIST` },
|
275
298
|
"Relations",
|
276
|
-
{ type: "UidAvailability", id: model }
|
299
|
+
{ type: "UidAvailability", id: model },
|
300
|
+
"RecentDocumentList"
|
277
301
|
];
|
278
302
|
}
|
279
303
|
}),
|
@@ -286,7 +310,7 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
286
310
|
url: `/content-manager/collection-types/${model}`,
|
287
311
|
method: "GET",
|
288
312
|
config: {
|
289
|
-
params
|
313
|
+
params: qs.stringify(params, { encode: true })
|
290
314
|
}
|
291
315
|
}),
|
292
316
|
providesTags: (result, _error, arg) => {
|
@@ -368,7 +392,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
368
392
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
369
393
|
},
|
370
394
|
{ type: "Document", id: `${model}_LIST` },
|
371
|
-
"Relations"
|
395
|
+
"Relations",
|
396
|
+
"RecentDocumentList"
|
372
397
|
];
|
373
398
|
}
|
374
399
|
}),
|
@@ -399,7 +424,9 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
399
424
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
400
425
|
},
|
401
426
|
"Relations",
|
402
|
-
{ type: "UidAvailability", id: model }
|
427
|
+
{ type: "UidAvailability", id: model },
|
428
|
+
"RecentDocumentList",
|
429
|
+
"RecentDocumentList"
|
403
430
|
];
|
404
431
|
},
|
405
432
|
async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
|
@@ -429,7 +456,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
429
456
|
{
|
430
457
|
type: "Document",
|
431
458
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
432
|
-
}
|
459
|
+
},
|
460
|
+
"RecentDocumentList"
|
433
461
|
];
|
434
462
|
}
|
435
463
|
}),
|
@@ -442,7 +470,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
442
470
|
params
|
443
471
|
}
|
444
472
|
}),
|
445
|
-
invalidatesTags: (_res, _error, { model, documentIds }) =>
|
473
|
+
invalidatesTags: (_res, _error, { model, documentIds }) => [
|
474
|
+
...documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` })),
|
475
|
+
"RecentDocumentList"
|
476
|
+
]
|
446
477
|
})
|
447
478
|
})
|
448
479
|
});
|
@@ -465,8 +496,7 @@ const {
|
|
465
496
|
useUnpublishManyDocumentsMutation
|
466
497
|
} = documentApi;
|
467
498
|
const buildValidParams = (query) => {
|
468
|
-
if (!query)
|
469
|
-
return query;
|
499
|
+
if (!query) return query;
|
470
500
|
const { plugins: _, ...validQueryParams } = {
|
471
501
|
...query,
|
472
502
|
...Object.values(query?.plugins ?? {}).reduce(
|
@@ -474,14 +504,29 @@ const buildValidParams = (query) => {
|
|
474
504
|
{}
|
475
505
|
)
|
476
506
|
};
|
477
|
-
if ("_q" in validQueryParams) {
|
478
|
-
validQueryParams._q = encodeURIComponent(validQueryParams._q);
|
479
|
-
}
|
480
507
|
return validQueryParams;
|
481
508
|
};
|
482
509
|
const isBaseQueryError = (error) => {
|
483
510
|
return error.name !== void 0;
|
484
511
|
};
|
512
|
+
const arrayValidator = (attribute, options) => ({
|
513
|
+
message: strapiAdmin.translatedErrors.required,
|
514
|
+
test(value) {
|
515
|
+
if (options.status === "draft") {
|
516
|
+
return true;
|
517
|
+
}
|
518
|
+
if (!attribute.required) {
|
519
|
+
return true;
|
520
|
+
}
|
521
|
+
if (!value) {
|
522
|
+
return false;
|
523
|
+
}
|
524
|
+
if (Array.isArray(value) && value.length === 0) {
|
525
|
+
return false;
|
526
|
+
}
|
527
|
+
return true;
|
528
|
+
}
|
529
|
+
});
|
485
530
|
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
486
531
|
const createModelSchema = (attributes2) => yup__namespace.object().shape(
|
487
532
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
@@ -489,6 +534,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
489
534
|
return acc;
|
490
535
|
}
|
491
536
|
const validations = [
|
537
|
+
addNullableValidation,
|
492
538
|
addRequiredValidation,
|
493
539
|
addMinLengthValidation,
|
494
540
|
addMaxLengthValidation,
|
@@ -505,12 +551,12 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
505
551
|
...acc,
|
506
552
|
[name]: transformSchema(
|
507
553
|
yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
|
508
|
-
)
|
554
|
+
).test(arrayValidator(attribute, options))
|
509
555
|
};
|
510
556
|
} else {
|
511
557
|
return {
|
512
558
|
...acc,
|
513
|
-
[name]: transformSchema(createModelSchema(attributes3))
|
559
|
+
[name]: transformSchema(createModelSchema(attributes3).nullable())
|
514
560
|
};
|
515
561
|
}
|
516
562
|
}
|
@@ -532,7 +578,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
532
578
|
}
|
533
579
|
)
|
534
580
|
)
|
535
|
-
)
|
581
|
+
).test(arrayValidator(attribute, options))
|
536
582
|
};
|
537
583
|
case "relation":
|
538
584
|
return {
|
@@ -544,7 +590,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
544
590
|
} else if (Array.isArray(value)) {
|
545
591
|
return yup__namespace.array().of(
|
546
592
|
yup__namespace.object().shape({
|
547
|
-
id: yup__namespace.
|
593
|
+
id: yup__namespace.number().required()
|
548
594
|
})
|
549
595
|
);
|
550
596
|
} else if (typeof value === "object") {
|
@@ -630,17 +676,17 @@ const nullableSchema = (schema) => {
|
|
630
676
|
schema
|
631
677
|
);
|
632
678
|
};
|
679
|
+
const addNullableValidation = () => (schema) => {
|
680
|
+
return nullableSchema(schema);
|
681
|
+
};
|
633
682
|
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);
|
683
|
+
if (options.status === "draft" || !attribute.required) {
|
684
|
+
return schema;
|
639
685
|
}
|
640
|
-
if (attribute.required &&
|
686
|
+
if (attribute.required && "required" in schema) {
|
641
687
|
return schema.required(strapiAdmin.translatedErrors.required);
|
642
688
|
}
|
643
|
-
return
|
689
|
+
return schema;
|
644
690
|
};
|
645
691
|
const addMinLengthValidation = (attribute, options) => (schema) => {
|
646
692
|
if (options.status === "draft") {
|
@@ -668,31 +714,12 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
668
714
|
return schema;
|
669
715
|
};
|
670
716
|
const addMinValidation = (attribute, options) => (schema) => {
|
671
|
-
if ("
|
717
|
+
if (options.status === "draft") {
|
718
|
+
return schema;
|
719
|
+
}
|
720
|
+
if ("min" in attribute && "min" in schema) {
|
672
721
|
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) {
|
722
|
+
if (min) {
|
696
723
|
return schema.min(min, {
|
697
724
|
...strapiAdmin.translatedErrors.min,
|
698
725
|
values: {
|
@@ -810,19 +837,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
|
|
810
837
|
}, {});
|
811
838
|
return componentsByKey;
|
812
839
|
};
|
813
|
-
const
|
840
|
+
const HOOKS = {
|
841
|
+
/**
|
842
|
+
* Hook that allows to mutate the displayed headers of the list view table
|
843
|
+
* @constant
|
844
|
+
* @type {string}
|
845
|
+
*/
|
846
|
+
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
847
|
+
/**
|
848
|
+
* Hook that allows to mutate the CM's collection types links pre-set filters
|
849
|
+
* @constant
|
850
|
+
* @type {string}
|
851
|
+
*/
|
852
|
+
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
853
|
+
/**
|
854
|
+
* Hook that allows to mutate the CM's edit view layout
|
855
|
+
* @constant
|
856
|
+
* @type {string}
|
857
|
+
*/
|
858
|
+
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
859
|
+
/**
|
860
|
+
* Hook that allows to mutate the CM's single types links pre-set filters
|
861
|
+
* @constant
|
862
|
+
* @type {string}
|
863
|
+
*/
|
864
|
+
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
865
|
+
};
|
866
|
+
const contentTypesApi = contentManagerApi.injectEndpoints({
|
867
|
+
endpoints: (builder) => ({
|
868
|
+
getContentTypeConfiguration: builder.query({
|
869
|
+
query: (uid) => ({
|
870
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
871
|
+
method: "GET"
|
872
|
+
}),
|
873
|
+
transformResponse: (response) => response.data,
|
874
|
+
providesTags: (_result, _error, uid) => [
|
875
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
876
|
+
{ type: "ContentTypeSettings", id: "LIST" }
|
877
|
+
]
|
878
|
+
}),
|
879
|
+
getAllContentTypeSettings: builder.query({
|
880
|
+
query: () => "/content-manager/content-types-settings",
|
881
|
+
transformResponse: (response) => response.data,
|
882
|
+
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
883
|
+
}),
|
884
|
+
updateContentTypeConfiguration: builder.mutation({
|
885
|
+
query: ({ uid, ...body }) => ({
|
886
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
887
|
+
method: "PUT",
|
888
|
+
data: body
|
889
|
+
}),
|
890
|
+
transformResponse: (response) => response.data,
|
891
|
+
invalidatesTags: (_result, _error, { uid }) => [
|
892
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
893
|
+
{ type: "ContentTypeSettings", id: "LIST" },
|
894
|
+
// Is this necessary?
|
895
|
+
{ type: "InitialData" }
|
896
|
+
]
|
897
|
+
})
|
898
|
+
})
|
899
|
+
});
|
900
|
+
const {
|
901
|
+
useGetContentTypeConfigurationQuery,
|
902
|
+
useGetAllContentTypeSettingsQuery,
|
903
|
+
useUpdateContentTypeConfigurationMutation
|
904
|
+
} = contentTypesApi;
|
905
|
+
const checkIfAttributeIsDisplayable = (attribute) => {
|
906
|
+
const { type } = attribute;
|
907
|
+
if (type === "relation") {
|
908
|
+
return !attribute.relation.toLowerCase().includes("morph");
|
909
|
+
}
|
910
|
+
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
911
|
+
};
|
912
|
+
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
913
|
+
if (!mainFieldName) {
|
914
|
+
return void 0;
|
915
|
+
}
|
916
|
+
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
917
|
+
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
918
|
+
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
919
|
+
);
|
920
|
+
return {
|
921
|
+
name: mainFieldName,
|
922
|
+
type: mainFieldType ?? "string"
|
923
|
+
};
|
924
|
+
};
|
925
|
+
const DEFAULT_SETTINGS = {
|
926
|
+
bulkable: false,
|
927
|
+
filterable: false,
|
928
|
+
searchable: false,
|
929
|
+
pagination: false,
|
930
|
+
defaultSortBy: "",
|
931
|
+
defaultSortOrder: "asc",
|
932
|
+
mainField: "id",
|
933
|
+
pageSize: 10
|
934
|
+
};
|
935
|
+
const useDocumentLayout = (model) => {
|
936
|
+
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
937
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
938
|
+
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
814
939
|
const { toggleNotification } = strapiAdmin.useNotification();
|
815
940
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
941
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
816
942
|
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);
|
943
|
+
data,
|
944
|
+
isLoading: isLoadingConfigs,
|
945
|
+
error,
|
946
|
+
isFetching: isFetchingConfigs
|
947
|
+
} = useGetContentTypeConfigurationQuery(model);
|
948
|
+
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
826
949
|
React__namespace.useEffect(() => {
|
827
950
|
if (error) {
|
828
951
|
toggleNotification({
|
@@ -830,84 +953,339 @@ const useDocument = (args, opts) => {
|
|
830
953
|
message: formatAPIError(error)
|
831
954
|
});
|
832
955
|
}
|
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
|
-
}
|
956
|
+
}, [error, formatAPIError, toggleNotification]);
|
957
|
+
const editLayout = React__namespace.useMemo(
|
958
|
+
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
959
|
+
layout: [],
|
960
|
+
components: {},
|
961
|
+
metadatas: {},
|
962
|
+
options: {},
|
963
|
+
settings: DEFAULT_SETTINGS
|
856
964
|
},
|
857
|
-
[
|
965
|
+
[data, isLoading, schemas, schema, components]
|
966
|
+
);
|
967
|
+
const listLayout = React__namespace.useMemo(() => {
|
968
|
+
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
969
|
+
layout: [],
|
970
|
+
metadatas: {},
|
971
|
+
options: {},
|
972
|
+
settings: DEFAULT_SETTINGS
|
973
|
+
};
|
974
|
+
}, [data, isLoading, schemas, schema, components]);
|
975
|
+
const { layout: edit } = React__namespace.useMemo(
|
976
|
+
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
977
|
+
layout: editLayout,
|
978
|
+
query
|
979
|
+
}),
|
980
|
+
[editLayout, query, runHookWaterfall]
|
858
981
|
);
|
859
|
-
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
860
982
|
return {
|
861
|
-
|
862
|
-
document: data?.data,
|
863
|
-
meta: data?.meta,
|
983
|
+
error,
|
864
984
|
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
|
-
)
|
985
|
+
edit,
|
986
|
+
list: listLayout
|
889
987
|
};
|
890
988
|
};
|
891
|
-
const
|
892
|
-
|
893
|
-
|
894
|
-
}
|
895
|
-
return Object.keys(trad).reduce((acc, current) => {
|
896
|
-
acc[`${pluginId}.${current}`] = trad[current];
|
897
|
-
return acc;
|
898
|
-
}, {});
|
899
|
-
};
|
900
|
-
const getTranslation = (id) => `content-manager.${id}`;
|
901
|
-
const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
902
|
-
id: "notification.error",
|
903
|
-
defaultMessage: "An error occurred, please try again"
|
989
|
+
const useDocLayout = () => {
|
990
|
+
const { model } = useDoc();
|
991
|
+
return useDocumentLayout(model);
|
904
992
|
};
|
905
|
-
const
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
993
|
+
const formatEditLayout = (data, {
|
994
|
+
schemas,
|
995
|
+
schema,
|
996
|
+
components
|
997
|
+
}) => {
|
998
|
+
let currentPanelIndex = 0;
|
999
|
+
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
1000
|
+
data.contentType.layouts.edit,
|
1001
|
+
schema?.attributes,
|
1002
|
+
data.contentType.metadatas,
|
1003
|
+
{ configurations: data.components, schemas: components },
|
1004
|
+
schemas
|
1005
|
+
).reduce((panels, row) => {
|
1006
|
+
if (row.some((field) => field.type === "dynamiczone")) {
|
1007
|
+
panels.push([row]);
|
1008
|
+
currentPanelIndex += 2;
|
1009
|
+
} else {
|
1010
|
+
if (!panels[currentPanelIndex]) {
|
1011
|
+
panels.push([row]);
|
1012
|
+
} else {
|
1013
|
+
panels[currentPanelIndex].push(row);
|
1014
|
+
}
|
1015
|
+
}
|
1016
|
+
return panels;
|
1017
|
+
}, []);
|
1018
|
+
const componentEditAttributes = Object.entries(data.components).reduce(
|
1019
|
+
(acc, [uid, configuration]) => {
|
1020
|
+
acc[uid] = {
|
1021
|
+
layout: convertEditLayoutToFieldLayouts(
|
1022
|
+
configuration.layouts.edit,
|
1023
|
+
components[uid].attributes,
|
1024
|
+
configuration.metadatas,
|
1025
|
+
{ configurations: data.components, schemas: components }
|
1026
|
+
),
|
1027
|
+
settings: {
|
1028
|
+
...configuration.settings,
|
1029
|
+
icon: components[uid].info.icon,
|
1030
|
+
displayName: components[uid].info.displayName
|
1031
|
+
}
|
1032
|
+
};
|
1033
|
+
return acc;
|
1034
|
+
},
|
1035
|
+
{}
|
1036
|
+
);
|
1037
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1038
|
+
(acc, [attribute, metadata]) => {
|
1039
|
+
return {
|
1040
|
+
...acc,
|
1041
|
+
[attribute]: metadata.edit
|
1042
|
+
};
|
1043
|
+
},
|
1044
|
+
{}
|
1045
|
+
);
|
1046
|
+
return {
|
1047
|
+
layout: panelledEditAttributes,
|
1048
|
+
components: componentEditAttributes,
|
1049
|
+
metadatas: editMetadatas,
|
1050
|
+
settings: {
|
1051
|
+
...data.contentType.settings,
|
1052
|
+
displayName: schema?.info.displayName
|
1053
|
+
},
|
1054
|
+
options: {
|
1055
|
+
...schema?.options,
|
1056
|
+
...schema?.pluginOptions,
|
1057
|
+
...data.contentType.options
|
1058
|
+
}
|
1059
|
+
};
|
1060
|
+
};
|
1061
|
+
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
1062
|
+
return rows.map(
|
1063
|
+
(row) => row.map((field) => {
|
1064
|
+
const attribute = attributes[field.name];
|
1065
|
+
if (!attribute) {
|
1066
|
+
return null;
|
1067
|
+
}
|
1068
|
+
const { edit: metadata } = metadatas[field.name];
|
1069
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1070
|
+
return {
|
1071
|
+
attribute,
|
1072
|
+
disabled: !metadata.editable,
|
1073
|
+
hint: metadata.description,
|
1074
|
+
label: metadata.label ?? "",
|
1075
|
+
name: field.name,
|
1076
|
+
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
1077
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1078
|
+
schemas,
|
1079
|
+
components: components?.schemas ?? {}
|
1080
|
+
}),
|
1081
|
+
placeholder: metadata.placeholder ?? "",
|
1082
|
+
required: attribute.required ?? false,
|
1083
|
+
size: field.size,
|
1084
|
+
unique: "unique" in attribute ? attribute.unique : false,
|
1085
|
+
visible: metadata.visible ?? true,
|
1086
|
+
type: attribute.type
|
1087
|
+
};
|
1088
|
+
}).filter((field) => field !== null)
|
1089
|
+
);
|
1090
|
+
};
|
1091
|
+
const formatListLayout = (data, {
|
1092
|
+
schemas,
|
1093
|
+
schema,
|
1094
|
+
components
|
1095
|
+
}) => {
|
1096
|
+
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1097
|
+
(acc, [attribute, metadata]) => {
|
1098
|
+
return {
|
1099
|
+
...acc,
|
1100
|
+
[attribute]: metadata.list
|
1101
|
+
};
|
1102
|
+
},
|
1103
|
+
{}
|
1104
|
+
);
|
1105
|
+
const listAttributes = convertListLayoutToFieldLayouts(
|
1106
|
+
data.contentType.layouts.list,
|
1107
|
+
schema?.attributes,
|
1108
|
+
listMetadatas,
|
1109
|
+
{ configurations: data.components, schemas: components },
|
1110
|
+
schemas
|
1111
|
+
);
|
1112
|
+
return {
|
1113
|
+
layout: listAttributes,
|
1114
|
+
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
1115
|
+
metadatas: listMetadatas,
|
1116
|
+
options: {
|
1117
|
+
...schema?.options,
|
1118
|
+
...schema?.pluginOptions,
|
1119
|
+
...data.contentType.options
|
1120
|
+
}
|
1121
|
+
};
|
1122
|
+
};
|
1123
|
+
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
1124
|
+
return columns.map((name) => {
|
1125
|
+
const attribute = attributes[name];
|
1126
|
+
if (!attribute) {
|
1127
|
+
return null;
|
1128
|
+
}
|
1129
|
+
const metadata = metadatas[name];
|
1130
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1131
|
+
return {
|
1132
|
+
attribute,
|
1133
|
+
label: metadata.label ?? "",
|
1134
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1135
|
+
schemas,
|
1136
|
+
components: components?.schemas ?? {}
|
1137
|
+
}),
|
1138
|
+
name,
|
1139
|
+
searchable: metadata.searchable ?? true,
|
1140
|
+
sortable: metadata.sortable ?? true
|
1141
|
+
};
|
1142
|
+
}).filter((field) => field !== null);
|
1143
|
+
};
|
1144
|
+
const useDocument = (args, opts) => {
|
1145
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
1146
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1147
|
+
const {
|
1148
|
+
currentData: data,
|
1149
|
+
isLoading: isLoadingDocument,
|
1150
|
+
isFetching: isFetchingDocument,
|
1151
|
+
error
|
1152
|
+
} = useGetDocumentQuery(args, {
|
1153
|
+
...opts,
|
1154
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
1155
|
+
});
|
1156
|
+
const {
|
1157
|
+
components,
|
1158
|
+
schema,
|
1159
|
+
schemas,
|
1160
|
+
isLoading: isLoadingSchema
|
1161
|
+
} = useContentTypeSchema(args.model);
|
1162
|
+
React__namespace.useEffect(() => {
|
1163
|
+
if (error) {
|
1164
|
+
toggleNotification({
|
1165
|
+
type: "danger",
|
1166
|
+
message: formatAPIError(error)
|
1167
|
+
});
|
1168
|
+
}
|
1169
|
+
}, [toggleNotification, error, formatAPIError, args.collectionType]);
|
1170
|
+
const validationSchema = React__namespace.useMemo(() => {
|
1171
|
+
if (!schema) {
|
1172
|
+
return null;
|
1173
|
+
}
|
1174
|
+
return createYupSchema(schema.attributes, components);
|
1175
|
+
}, [schema, components]);
|
1176
|
+
const validate = React__namespace.useCallback(
|
1177
|
+
(document) => {
|
1178
|
+
if (!validationSchema) {
|
1179
|
+
throw new Error(
|
1180
|
+
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
1181
|
+
);
|
1182
|
+
}
|
1183
|
+
try {
|
1184
|
+
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
1185
|
+
return null;
|
1186
|
+
} catch (error2) {
|
1187
|
+
if (error2 instanceof yup.ValidationError) {
|
1188
|
+
return strapiAdmin.getYupValidationErrors(error2);
|
1189
|
+
}
|
1190
|
+
throw error2;
|
1191
|
+
}
|
1192
|
+
},
|
1193
|
+
[validationSchema]
|
1194
|
+
);
|
1195
|
+
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
1196
|
+
const hasError = !!error;
|
1197
|
+
return {
|
1198
|
+
components,
|
1199
|
+
document: data?.data,
|
1200
|
+
meta: data?.meta,
|
1201
|
+
isLoading,
|
1202
|
+
hasError,
|
1203
|
+
schema,
|
1204
|
+
schemas,
|
1205
|
+
validate
|
1206
|
+
};
|
1207
|
+
};
|
1208
|
+
const useDoc = () => {
|
1209
|
+
const { id, slug, collectionType, origin } = reactRouterDom.useParams();
|
1210
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
1211
|
+
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
1212
|
+
if (!collectionType) {
|
1213
|
+
throw new Error("Could not find collectionType in url params");
|
1214
|
+
}
|
1215
|
+
if (!slug) {
|
1216
|
+
throw new Error("Could not find model in url params");
|
1217
|
+
}
|
1218
|
+
const document = useDocument(
|
1219
|
+
{ documentId: origin || id, model: slug, collectionType, params },
|
1220
|
+
{
|
1221
|
+
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
1222
|
+
}
|
1223
|
+
);
|
1224
|
+
const returnId = origin || id === "create" ? void 0 : id;
|
1225
|
+
return {
|
1226
|
+
collectionType,
|
1227
|
+
model: slug,
|
1228
|
+
id: returnId,
|
1229
|
+
...document
|
1230
|
+
};
|
1231
|
+
};
|
1232
|
+
const useContentManagerContext = () => {
|
1233
|
+
const {
|
1234
|
+
collectionType,
|
1235
|
+
model,
|
1236
|
+
id,
|
1237
|
+
components,
|
1238
|
+
isLoading: isLoadingDoc,
|
1239
|
+
schema,
|
1240
|
+
schemas
|
1241
|
+
} = useDoc();
|
1242
|
+
const layout = useDocumentLayout(model);
|
1243
|
+
const form = strapiAdmin.useForm("useContentManagerContext", (state) => state);
|
1244
|
+
const isSingleType = collectionType === SINGLE_TYPES;
|
1245
|
+
const slug = model;
|
1246
|
+
const isCreatingEntry = id === "create";
|
1247
|
+
useContentTypeSchema();
|
1248
|
+
const isLoading = isLoadingDoc || layout.isLoading;
|
1249
|
+
const error = layout.error;
|
1250
|
+
return {
|
1251
|
+
error,
|
1252
|
+
isLoading,
|
1253
|
+
// Base metadata
|
1254
|
+
model,
|
1255
|
+
collectionType,
|
1256
|
+
id,
|
1257
|
+
slug,
|
1258
|
+
isCreatingEntry,
|
1259
|
+
isSingleType,
|
1260
|
+
hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
|
1261
|
+
// All schema infos
|
1262
|
+
components,
|
1263
|
+
contentType: schema,
|
1264
|
+
contentTypes: schemas,
|
1265
|
+
// Form state
|
1266
|
+
form,
|
1267
|
+
// layout infos
|
1268
|
+
layout
|
1269
|
+
};
|
1270
|
+
};
|
1271
|
+
const prefixPluginTranslations = (trad, pluginId) => {
|
1272
|
+
return Object.keys(trad).reduce((acc, current) => {
|
1273
|
+
acc[`${pluginId}.${current}`] = trad[current];
|
1274
|
+
return acc;
|
1275
|
+
}, {});
|
1276
|
+
};
|
1277
|
+
const getTranslation = (id) => `content-manager.${id}`;
|
1278
|
+
const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
1279
|
+
id: "notification.error",
|
1280
|
+
defaultMessage: "An error occurred, please try again"
|
1281
|
+
};
|
1282
|
+
const useDocumentActions = () => {
|
1283
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
1284
|
+
const { formatMessage } = reactIntl.useIntl();
|
1285
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
1286
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1287
|
+
const navigate = reactRouterDom.useNavigate();
|
1288
|
+
const setCurrentStep = strapiAdmin.useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
|
911
1289
|
const [deleteDocument] = useDeleteDocumentMutation();
|
912
1290
|
const _delete = React__namespace.useCallback(
|
913
1291
|
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
@@ -1222,6 +1600,7 @@ const useDocumentActions = () => {
|
|
1222
1600
|
defaultMessage: "Saved document"
|
1223
1601
|
})
|
1224
1602
|
});
|
1603
|
+
setCurrentStep("contentManager.success");
|
1225
1604
|
return res.data;
|
1226
1605
|
} catch (err) {
|
1227
1606
|
toggleNotification({
|
@@ -1323,10 +1702,10 @@ const useDocumentActions = () => {
|
|
1323
1702
|
update
|
1324
1703
|
};
|
1325
1704
|
};
|
1326
|
-
const ProtectedHistoryPage =
|
1327
|
-
() => Promise.resolve().then(() => require("./History-
|
1705
|
+
const ProtectedHistoryPage = React__namespace.lazy(
|
1706
|
+
() => Promise.resolve().then(() => require("./History-CzkXjAR0.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1328
1707
|
);
|
1329
|
-
const routes$
|
1708
|
+
const routes$2 = [
|
1330
1709
|
{
|
1331
1710
|
path: ":collectionType/:slug/:id/history",
|
1332
1711
|
Component: ProtectedHistoryPage
|
@@ -1336,32 +1715,45 @@ const routes$1 = [
|
|
1336
1715
|
Component: ProtectedHistoryPage
|
1337
1716
|
}
|
1338
1717
|
];
|
1718
|
+
const ProtectedPreviewPage = React__namespace.lazy(
|
1719
|
+
() => Promise.resolve().then(() => require("./Preview-8U27vy1U.js")).then((mod) => ({ default: mod.ProtectedPreviewPage }))
|
1720
|
+
);
|
1721
|
+
const routes$1 = [
|
1722
|
+
{
|
1723
|
+
path: ":collectionType/:slug/:id/preview",
|
1724
|
+
Component: ProtectedPreviewPage
|
1725
|
+
},
|
1726
|
+
{
|
1727
|
+
path: ":collectionType/:slug/preview",
|
1728
|
+
Component: ProtectedPreviewPage
|
1729
|
+
}
|
1730
|
+
];
|
1339
1731
|
const ProtectedEditViewPage = React.lazy(
|
1340
|
-
() => Promise.resolve().then(() => require("./EditViewPage-
|
1732
|
+
() => Promise.resolve().then(() => require("./EditViewPage-BW-BJJVg.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1341
1733
|
);
|
1342
1734
|
const ProtectedListViewPage = React.lazy(
|
1343
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1735
|
+
() => Promise.resolve().then(() => require("./ListViewPage-CIHO4H2J.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1344
1736
|
);
|
1345
1737
|
const ProtectedListConfiguration = React.lazy(
|
1346
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1738
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-B9TbaEqp.js")).then((mod) => ({
|
1347
1739
|
default: mod.ProtectedListConfiguration
|
1348
1740
|
}))
|
1349
1741
|
);
|
1350
1742
|
const ProtectedEditConfigurationPage = React.lazy(
|
1351
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1743
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-CXLQhPpj.js")).then((mod) => ({
|
1352
1744
|
default: mod.ProtectedEditConfigurationPage
|
1353
1745
|
}))
|
1354
1746
|
);
|
1355
1747
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1356
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1748
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-BtmEfYUS.js")).then((mod) => ({
|
1357
1749
|
default: mod.ProtectedComponentConfigurationPage
|
1358
1750
|
}))
|
1359
1751
|
);
|
1360
1752
|
const NoPermissions = React.lazy(
|
1361
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1753
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-CDvWOtEy.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1362
1754
|
);
|
1363
1755
|
const NoContentType = React.lazy(
|
1364
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1756
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-Dbfi49ek.js")).then((mod) => ({ default: mod.NoContentType }))
|
1365
1757
|
);
|
1366
1758
|
const CollectionTypePages = () => {
|
1367
1759
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1373,7 +1765,7 @@ const CollectionTypePages = () => {
|
|
1373
1765
|
const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
|
1374
1766
|
const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
|
1375
1767
|
const LIST_RELATIVE_PATH = ":collectionType/:slug";
|
1376
|
-
const LIST_PATH = `/content-manager
|
1768
|
+
const LIST_PATH = `/content-manager/collection-types/:slug`;
|
1377
1769
|
const routes = [
|
1378
1770
|
{
|
1379
1771
|
path: LIST_RELATIVE_PATH,
|
@@ -1407,6 +1799,7 @@ const routes = [
|
|
1407
1799
|
path: "no-content-types",
|
1408
1800
|
Component: NoContentType
|
1409
1801
|
},
|
1802
|
+
...routes$2,
|
1410
1803
|
...routes$1
|
1411
1804
|
];
|
1412
1805
|
const DocumentActions = ({ actions: actions2 }) => {
|
@@ -1505,6 +1898,11 @@ const DocumentActionButton = (action) => {
|
|
1505
1898
|
) : null
|
1506
1899
|
] });
|
1507
1900
|
};
|
1901
|
+
const MenuItem = styledComponents.styled(designSystem.Menu.Item)`
|
1902
|
+
&:hover {
|
1903
|
+
background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
|
1904
|
+
}
|
1905
|
+
`;
|
1508
1906
|
const DocumentActionsMenu = ({
|
1509
1907
|
actions: actions2,
|
1510
1908
|
children,
|
@@ -1563,48 +1961,32 @@ const DocumentActionsMenu = ({
|
|
1563
1961
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
|
1564
1962
|
actions2.map((action) => {
|
1565
1963
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
1566
|
-
|
1964
|
+
MenuItem,
|
1567
1965
|
{
|
1568
1966
|
disabled: action.disabled,
|
1569
1967
|
onSelect: handleClick(action),
|
1570
1968
|
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
|
-
] })
|
1969
|
+
isVariantDanger: action.variant === "danger",
|
1970
|
+
isDisabled: action.disabled,
|
1971
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
1972
|
+
designSystem.Flex,
|
1973
|
+
{
|
1974
|
+
color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
|
1975
|
+
gap: 2,
|
1976
|
+
tag: "span",
|
1977
|
+
children: [
|
1978
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
1979
|
+
designSystem.Flex,
|
1980
|
+
{
|
1981
|
+
tag: "span",
|
1982
|
+
color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
|
1983
|
+
children: action.icon
|
1984
|
+
}
|
1985
|
+
),
|
1986
|
+
action.label
|
1987
|
+
]
|
1988
|
+
}
|
1989
|
+
) })
|
1608
1990
|
},
|
1609
1991
|
action.id
|
1610
1992
|
);
|
@@ -1715,6 +2097,18 @@ const DocumentActionModal = ({
|
|
1715
2097
|
typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
|
1716
2098
|
] }) });
|
1717
2099
|
};
|
2100
|
+
const transformData = (data) => {
|
2101
|
+
if (Array.isArray(data)) {
|
2102
|
+
return data.map(transformData);
|
2103
|
+
}
|
2104
|
+
if (typeof data === "object" && data !== null) {
|
2105
|
+
if ("apiData" in data) {
|
2106
|
+
return data.apiData;
|
2107
|
+
}
|
2108
|
+
return mapValues__default.default(transformData)(data);
|
2109
|
+
}
|
2110
|
+
return data;
|
2111
|
+
};
|
1718
2112
|
const PublishAction$1 = ({
|
1719
2113
|
activeTab,
|
1720
2114
|
documentId,
|
@@ -1729,6 +2123,7 @@ const PublishAction$1 = ({
|
|
1729
2123
|
const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
|
1730
2124
|
const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
|
1731
2125
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2126
|
+
const { id } = reactRouterDom.useParams();
|
1732
2127
|
const { formatMessage } = reactIntl.useIntl();
|
1733
2128
|
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
1734
2129
|
const { publish } = useDocumentActions();
|
@@ -1808,7 +2203,9 @@ const PublishAction$1 = ({
|
|
1808
2203
|
const performPublish = async () => {
|
1809
2204
|
setSubmitting(true);
|
1810
2205
|
try {
|
1811
|
-
const { errors } = await validate(
|
2206
|
+
const { errors } = await validate(true, {
|
2207
|
+
status: "published"
|
2208
|
+
});
|
1812
2209
|
if (errors) {
|
1813
2210
|
toggleNotification({
|
1814
2211
|
type: "danger",
|
@@ -1826,13 +2223,15 @@ const PublishAction$1 = ({
|
|
1826
2223
|
documentId,
|
1827
2224
|
params
|
1828
2225
|
},
|
1829
|
-
formValues
|
2226
|
+
transformData(formValues)
|
1830
2227
|
);
|
1831
2228
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
2229
|
+
if (id === "create") {
|
2230
|
+
navigate({
|
2231
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
2232
|
+
search: rawQuery
|
2233
|
+
});
|
2234
|
+
}
|
1836
2235
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1837
2236
|
setErrors(formatValidationErrors(res.error));
|
1838
2237
|
}
|
@@ -1885,6 +2284,7 @@ const PublishAction$1 = ({
|
|
1885
2284
|
};
|
1886
2285
|
};
|
1887
2286
|
PublishAction$1.type = "publish";
|
2287
|
+
PublishAction$1.position = "panel";
|
1888
2288
|
const UpdateAction = ({
|
1889
2289
|
activeTab,
|
1890
2290
|
documentId,
|
@@ -1907,6 +2307,117 @@ const UpdateAction = ({
|
|
1907
2307
|
const validate = strapiAdmin.useForm("UpdateAction", (state) => state.validate);
|
1908
2308
|
const setErrors = strapiAdmin.useForm("UpdateAction", (state) => state.setErrors);
|
1909
2309
|
const resetForm = strapiAdmin.useForm("PublishAction", ({ resetForm: resetForm2 }) => resetForm2);
|
2310
|
+
const handleUpdate = React__namespace.useCallback(async () => {
|
2311
|
+
setSubmitting(true);
|
2312
|
+
try {
|
2313
|
+
if (!modified) {
|
2314
|
+
return;
|
2315
|
+
}
|
2316
|
+
const { errors } = await validate(true, {
|
2317
|
+
status: "draft"
|
2318
|
+
});
|
2319
|
+
if (errors) {
|
2320
|
+
toggleNotification({
|
2321
|
+
type: "danger",
|
2322
|
+
message: formatMessage({
|
2323
|
+
id: "content-manager.validation.error",
|
2324
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
2325
|
+
})
|
2326
|
+
});
|
2327
|
+
return;
|
2328
|
+
}
|
2329
|
+
if (isCloning) {
|
2330
|
+
const res = await clone(
|
2331
|
+
{
|
2332
|
+
model,
|
2333
|
+
documentId: cloneMatch.params.origin,
|
2334
|
+
params
|
2335
|
+
},
|
2336
|
+
transformData(document)
|
2337
|
+
);
|
2338
|
+
if ("data" in res) {
|
2339
|
+
navigate(
|
2340
|
+
{
|
2341
|
+
pathname: `../${res.data.documentId}`,
|
2342
|
+
search: rawQuery
|
2343
|
+
},
|
2344
|
+
{ relative: "path" }
|
2345
|
+
);
|
2346
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2347
|
+
setErrors(formatValidationErrors(res.error));
|
2348
|
+
}
|
2349
|
+
} else if (documentId || collectionType === SINGLE_TYPES) {
|
2350
|
+
const res = await update(
|
2351
|
+
{
|
2352
|
+
collectionType,
|
2353
|
+
model,
|
2354
|
+
documentId,
|
2355
|
+
params
|
2356
|
+
},
|
2357
|
+
transformData(document)
|
2358
|
+
);
|
2359
|
+
if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2360
|
+
setErrors(formatValidationErrors(res.error));
|
2361
|
+
} else {
|
2362
|
+
resetForm();
|
2363
|
+
}
|
2364
|
+
} else {
|
2365
|
+
const res = await create(
|
2366
|
+
{
|
2367
|
+
model,
|
2368
|
+
params
|
2369
|
+
},
|
2370
|
+
transformData(document)
|
2371
|
+
);
|
2372
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
2373
|
+
navigate(
|
2374
|
+
{
|
2375
|
+
pathname: `../${res.data.documentId}`,
|
2376
|
+
search: rawQuery
|
2377
|
+
},
|
2378
|
+
{ replace: true, relative: "path" }
|
2379
|
+
);
|
2380
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2381
|
+
setErrors(formatValidationErrors(res.error));
|
2382
|
+
}
|
2383
|
+
}
|
2384
|
+
} finally {
|
2385
|
+
setSubmitting(false);
|
2386
|
+
}
|
2387
|
+
}, [
|
2388
|
+
clone,
|
2389
|
+
cloneMatch?.params.origin,
|
2390
|
+
collectionType,
|
2391
|
+
create,
|
2392
|
+
document,
|
2393
|
+
documentId,
|
2394
|
+
formatMessage,
|
2395
|
+
formatValidationErrors,
|
2396
|
+
isCloning,
|
2397
|
+
model,
|
2398
|
+
modified,
|
2399
|
+
navigate,
|
2400
|
+
params,
|
2401
|
+
rawQuery,
|
2402
|
+
resetForm,
|
2403
|
+
setErrors,
|
2404
|
+
setSubmitting,
|
2405
|
+
toggleNotification,
|
2406
|
+
update,
|
2407
|
+
validate
|
2408
|
+
]);
|
2409
|
+
React__namespace.useEffect(() => {
|
2410
|
+
const handleKeyDown = (e) => {
|
2411
|
+
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
2412
|
+
e.preventDefault();
|
2413
|
+
handleUpdate();
|
2414
|
+
}
|
2415
|
+
};
|
2416
|
+
window.addEventListener("keydown", handleKeyDown);
|
2417
|
+
return () => {
|
2418
|
+
window.removeEventListener("keydown", handleKeyDown);
|
2419
|
+
};
|
2420
|
+
}, [handleUpdate]);
|
1910
2421
|
return {
|
1911
2422
|
/**
|
1912
2423
|
* Disabled when:
|
@@ -1916,87 +2427,14 @@ const UpdateAction = ({
|
|
1916
2427
|
*/
|
1917
2428
|
disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
|
1918
2429
|
label: formatMessage({
|
1919
|
-
id: "
|
2430
|
+
id: "global.save",
|
1920
2431
|
defaultMessage: "Save"
|
1921
2432
|
}),
|
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
|
-
}
|
2433
|
+
onClick: handleUpdate
|
1997
2434
|
};
|
1998
2435
|
};
|
1999
2436
|
UpdateAction.type = "update";
|
2437
|
+
UpdateAction.position = "panel";
|
2000
2438
|
const UNPUBLISH_DRAFT_OPTIONS = {
|
2001
2439
|
KEEP: "keep",
|
2002
2440
|
DISCARD: "discard"
|
@@ -2119,6 +2557,7 @@ const UnpublishAction$1 = ({
|
|
2119
2557
|
};
|
2120
2558
|
};
|
2121
2559
|
UnpublishAction$1.type = "unpublish";
|
2560
|
+
UnpublishAction$1.position = "panel";
|
2122
2561
|
const DiscardAction = ({
|
2123
2562
|
activeTab,
|
2124
2563
|
documentId,
|
@@ -2169,6 +2608,7 @@ const DiscardAction = ({
|
|
2169
2608
|
};
|
2170
2609
|
};
|
2171
2610
|
DiscardAction.type = "discard";
|
2611
|
+
DiscardAction.position = "panel";
|
2172
2612
|
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
2173
2613
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
2174
2614
|
const RelativeTime = React__namespace.forwardRef(
|
@@ -2181,7 +2621,7 @@ const RelativeTime = React__namespace.forwardRef(
|
|
2181
2621
|
});
|
2182
2622
|
const unit = intervals.find((intervalUnit) => {
|
2183
2623
|
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
|
2184
|
-
});
|
2624
|
+
}) ?? "seconds";
|
2185
2625
|
const relativeTime = dateFns.isPast(timestamp) ? -interval[unit] : interval[unit];
|
2186
2626
|
const customInterval = customIntervals.find(
|
2187
2627
|
(custom) => interval[custom.unit] < custom.threshold
|
@@ -2215,19 +2655,29 @@ const getDisplayName = ({
|
|
2215
2655
|
return email ?? "";
|
2216
2656
|
};
|
2217
2657
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2218
|
-
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2658
|
+
const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
|
2219
2659
|
const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
|
2220
|
-
|
2660
|
+
const { formatMessage } = reactIntl.useIntl();
|
2661
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
|
2662
|
+
id: `content-manager.containers.List.${status}`,
|
2663
|
+
defaultMessage: capitalise(status)
|
2664
|
+
}) }) });
|
2221
2665
|
};
|
2222
2666
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
2223
2667
|
const { formatMessage } = reactIntl.useIntl();
|
2224
2668
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2669
|
+
const params = reactRouterDom.useParams();
|
2225
2670
|
const title = isCreating ? formatMessage({
|
2226
2671
|
id: "content-manager.containers.edit.title.new",
|
2227
2672
|
defaultMessage: "Create an entry"
|
2228
2673
|
}) : documentTitle;
|
2229
2674
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2230
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
2675
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2676
|
+
strapiAdmin.BackButton,
|
2677
|
+
{
|
2678
|
+
fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
|
2679
|
+
}
|
2680
|
+
),
|
2231
2681
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2232
2682
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2233
2683
|
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
@@ -2278,7 +2728,7 @@ const HeaderToolbar = () => {
|
|
2278
2728
|
meta: isCloning ? void 0 : meta,
|
2279
2729
|
collectionType
|
2280
2730
|
},
|
2281
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2731
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("header"),
|
2282
2732
|
children: (actions2) => {
|
2283
2733
|
const headerActions = actions2.filter((action) => {
|
2284
2734
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -2315,12 +2765,12 @@ const Information = ({ activeTab }) => {
|
|
2315
2765
|
isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
|
2316
2766
|
label: formatMessage({
|
2317
2767
|
id: "content-manager.containers.edit.information.last-published.label",
|
2318
|
-
defaultMessage: "
|
2768
|
+
defaultMessage: "Published"
|
2319
2769
|
}),
|
2320
2770
|
value: formatMessage(
|
2321
2771
|
{
|
2322
2772
|
id: "content-manager.containers.edit.information.last-published.value",
|
2323
|
-
defaultMessage: `
|
2773
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2324
2774
|
},
|
2325
2775
|
{
|
2326
2776
|
time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
|
@@ -2333,12 +2783,12 @@ const Information = ({ activeTab }) => {
|
|
2333
2783
|
isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
|
2334
2784
|
label: formatMessage({
|
2335
2785
|
id: "content-manager.containers.edit.information.last-draft.label",
|
2336
|
-
defaultMessage: "
|
2786
|
+
defaultMessage: "Updated"
|
2337
2787
|
}),
|
2338
2788
|
value: formatMessage(
|
2339
2789
|
{
|
2340
2790
|
id: "content-manager.containers.edit.information.last-draft.value",
|
2341
|
-
defaultMessage: `
|
2791
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2342
2792
|
},
|
2343
2793
|
{
|
2344
2794
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2356,12 +2806,12 @@ const Information = ({ activeTab }) => {
|
|
2356
2806
|
isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
|
2357
2807
|
label: formatMessage({
|
2358
2808
|
id: "content-manager.containers.edit.information.document.label",
|
2359
|
-
defaultMessage: "
|
2809
|
+
defaultMessage: "Created"
|
2360
2810
|
}),
|
2361
2811
|
value: formatMessage(
|
2362
2812
|
{
|
2363
2813
|
id: "content-manager.containers.edit.information.document.value",
|
2364
|
-
defaultMessage: `
|
2814
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2365
2815
|
},
|
2366
2816
|
{
|
2367
2817
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2419,10 +2869,9 @@ const HeaderActions = ({ actions: actions2 }) => {
|
|
2419
2869
|
designSystem.SingleSelect,
|
2420
2870
|
{
|
2421
2871
|
size: "S",
|
2422
|
-
disabled: action.disabled,
|
2423
|
-
"aria-label": action.label,
|
2424
2872
|
onChange: action.onSelect,
|
2425
|
-
|
2873
|
+
"aria-label": action.label,
|
2874
|
+
...action,
|
2426
2875
|
children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
|
2427
2876
|
},
|
2428
2877
|
action.id
|
@@ -2487,6 +2936,7 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
|
|
2487
2936
|
};
|
2488
2937
|
};
|
2489
2938
|
ConfigureTheViewAction.type = "configure-the-view";
|
2939
|
+
ConfigureTheViewAction.position = "header";
|
2490
2940
|
const EditTheModelAction = ({ model }) => {
|
2491
2941
|
const navigate = reactRouterDom.useNavigate();
|
2492
2942
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2503,6 +2953,7 @@ const EditTheModelAction = ({ model }) => {
|
|
2503
2953
|
};
|
2504
2954
|
};
|
2505
2955
|
EditTheModelAction.type = "edit-the-model";
|
2956
|
+
EditTheModelAction.position = "header";
|
2506
2957
|
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2507
2958
|
const navigate = reactRouterDom.useNavigate();
|
2508
2959
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2511,12 +2962,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2511
2962
|
const { delete: deleteAction } = useDocumentActions();
|
2512
2963
|
const { toggleNotification } = strapiAdmin.useNotification();
|
2513
2964
|
const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
|
2965
|
+
const isLocalized = document?.locale != null;
|
2514
2966
|
return {
|
2515
2967
|
disabled: !canDelete || !document,
|
2516
|
-
label: formatMessage(
|
2517
|
-
|
2518
|
-
|
2519
|
-
|
2968
|
+
label: formatMessage(
|
2969
|
+
{
|
2970
|
+
id: "content-manager.actions.delete.label",
|
2971
|
+
defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
|
2972
|
+
},
|
2973
|
+
{ isLocalized }
|
2974
|
+
),
|
2520
2975
|
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
|
2521
2976
|
dialog: {
|
2522
2977
|
type: "dialog",
|
@@ -2555,421 +3010,119 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2555
3010
|
collectionType,
|
2556
3011
|
params: {
|
2557
3012
|
locale: "*"
|
2558
|
-
}
|
2559
|
-
});
|
2560
|
-
if (!("error" in res)) {
|
2561
|
-
navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
|
2562
|
-
}
|
2563
|
-
} finally {
|
2564
|
-
if (!listViewPathMatch) {
|
2565
|
-
setSubmitting(false);
|
2566
|
-
}
|
2567
|
-
}
|
2568
|
-
}
|
2569
|
-
},
|
2570
|
-
variant: "danger",
|
2571
|
-
position: ["header", "table-row"]
|
2572
|
-
};
|
2573
|
-
};
|
2574
|
-
DeleteAction$1.type = "delete";
|
2575
|
-
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2576
|
-
const Panels = () => {
|
2577
|
-
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2578
|
-
const [
|
2579
|
-
{
|
2580
|
-
query: { status }
|
2581
|
-
}
|
2582
|
-
] = strapiAdmin.useQueryParams({
|
2583
|
-
status: "draft"
|
2584
|
-
});
|
2585
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2586
|
-
const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
|
2587
|
-
const props = {
|
2588
|
-
activeTab: status,
|
2589
|
-
model,
|
2590
|
-
documentId: id,
|
2591
|
-
document: isCloning ? void 0 : document,
|
2592
|
-
meta: isCloning ? void 0 : meta,
|
2593
|
-
collectionType
|
2594
|
-
};
|
2595
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
2596
|
-
strapiAdmin.DescriptionComponentRenderer,
|
2597
|
-
{
|
2598
|
-
props,
|
2599
|
-
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
2600
|
-
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
|
2601
|
-
}
|
2602
|
-
) });
|
2603
|
-
};
|
2604
|
-
const ActionsPanel = () => {
|
2605
|
-
const { formatMessage } = reactIntl.useIntl();
|
2606
|
-
return {
|
2607
|
-
title: formatMessage({
|
2608
|
-
id: "content-manager.containers.edit.panels.default.title",
|
2609
|
-
defaultMessage: "Entry"
|
2610
|
-
}),
|
2611
|
-
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2612
|
-
};
|
2613
|
-
};
|
2614
|
-
ActionsPanel.type = "actions";
|
2615
|
-
const ActionsPanelContent = () => {
|
2616
|
-
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2617
|
-
const [
|
2618
|
-
{
|
2619
|
-
query: { status = "draft" }
|
2620
|
-
}
|
2621
|
-
] = strapiAdmin.useQueryParams();
|
2622
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2623
|
-
const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
|
2624
|
-
const props = {
|
2625
|
-
activeTab: status,
|
2626
|
-
model,
|
2627
|
-
documentId: id,
|
2628
|
-
document: isCloning ? void 0 : document,
|
2629
|
-
meta: isCloning ? void 0 : meta,
|
2630
|
-
collectionType
|
2631
|
-
};
|
2632
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
|
2633
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
2634
|
-
strapiAdmin.DescriptionComponentRenderer,
|
2635
|
-
{
|
2636
|
-
props,
|
2637
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2638
|
-
children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
|
2639
|
-
}
|
2640
|
-
),
|
2641
|
-
/* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
2642
|
-
] });
|
2643
|
-
};
|
2644
|
-
const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
2645
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
2646
|
-
designSystem.Flex,
|
2647
|
-
{
|
2648
|
-
ref,
|
2649
|
-
tag: "aside",
|
2650
|
-
"aria-labelledby": "additional-information",
|
2651
|
-
background: "neutral0",
|
2652
|
-
borderColor: "neutral150",
|
2653
|
-
hasRadius: true,
|
2654
|
-
paddingBottom: 4,
|
2655
|
-
paddingLeft: 4,
|
2656
|
-
paddingRight: 4,
|
2657
|
-
paddingTop: 4,
|
2658
|
-
shadow: "tableShadow",
|
2659
|
-
gap: 3,
|
2660
|
-
direction: "column",
|
2661
|
-
justifyContent: "stretch",
|
2662
|
-
alignItems: "flex-start",
|
2663
|
-
children: [
|
2664
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
|
2665
|
-
children
|
2666
|
-
]
|
2667
|
-
}
|
2668
|
-
);
|
2669
|
-
});
|
2670
|
-
const HOOKS = {
|
2671
|
-
/**
|
2672
|
-
* Hook that allows to mutate the displayed headers of the list view table
|
2673
|
-
* @constant
|
2674
|
-
* @type {string}
|
2675
|
-
*/
|
2676
|
-
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
2677
|
-
/**
|
2678
|
-
* Hook that allows to mutate the CM's collection types links pre-set filters
|
2679
|
-
* @constant
|
2680
|
-
* @type {string}
|
2681
|
-
*/
|
2682
|
-
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
2683
|
-
/**
|
2684
|
-
* Hook that allows to mutate the CM's edit view layout
|
2685
|
-
* @constant
|
2686
|
-
* @type {string}
|
2687
|
-
*/
|
2688
|
-
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
2689
|
-
/**
|
2690
|
-
* Hook that allows to mutate the CM's single types links pre-set filters
|
2691
|
-
* @constant
|
2692
|
-
* @type {string}
|
2693
|
-
*/
|
2694
|
-
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
2695
|
-
};
|
2696
|
-
const contentTypesApi = contentManagerApi.injectEndpoints({
|
2697
|
-
endpoints: (builder) => ({
|
2698
|
-
getContentTypeConfiguration: builder.query({
|
2699
|
-
query: (uid) => ({
|
2700
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2701
|
-
method: "GET"
|
2702
|
-
}),
|
2703
|
-
transformResponse: (response) => response.data,
|
2704
|
-
providesTags: (_result, _error, uid) => [
|
2705
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2706
|
-
{ type: "ContentTypeSettings", id: "LIST" }
|
2707
|
-
]
|
2708
|
-
}),
|
2709
|
-
getAllContentTypeSettings: builder.query({
|
2710
|
-
query: () => "/content-manager/content-types-settings",
|
2711
|
-
transformResponse: (response) => response.data,
|
2712
|
-
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
2713
|
-
}),
|
2714
|
-
updateContentTypeConfiguration: builder.mutation({
|
2715
|
-
query: ({ uid, ...body }) => ({
|
2716
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2717
|
-
method: "PUT",
|
2718
|
-
data: body
|
2719
|
-
}),
|
2720
|
-
transformResponse: (response) => response.data,
|
2721
|
-
invalidatesTags: (_result, _error, { uid }) => [
|
2722
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2723
|
-
{ type: "ContentTypeSettings", id: "LIST" },
|
2724
|
-
// Is this necessary?
|
2725
|
-
{ type: "InitialData" }
|
2726
|
-
]
|
2727
|
-
})
|
2728
|
-
})
|
2729
|
-
});
|
2730
|
-
const {
|
2731
|
-
useGetContentTypeConfigurationQuery,
|
2732
|
-
useGetAllContentTypeSettingsQuery,
|
2733
|
-
useUpdateContentTypeConfigurationMutation
|
2734
|
-
} = contentTypesApi;
|
2735
|
-
const checkIfAttributeIsDisplayable = (attribute) => {
|
2736
|
-
const { type } = attribute;
|
2737
|
-
if (type === "relation") {
|
2738
|
-
return !attribute.relation.toLowerCase().includes("morph");
|
2739
|
-
}
|
2740
|
-
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
2741
|
-
};
|
2742
|
-
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
2743
|
-
if (!mainFieldName) {
|
2744
|
-
return void 0;
|
2745
|
-
}
|
2746
|
-
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
2747
|
-
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
2748
|
-
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2749
|
-
);
|
2750
|
-
return {
|
2751
|
-
name: mainFieldName,
|
2752
|
-
type: mainFieldType ?? "string"
|
2753
|
-
};
|
2754
|
-
};
|
2755
|
-
const DEFAULT_SETTINGS = {
|
2756
|
-
bulkable: false,
|
2757
|
-
filterable: false,
|
2758
|
-
searchable: false,
|
2759
|
-
pagination: false,
|
2760
|
-
defaultSortBy: "",
|
2761
|
-
defaultSortOrder: "asc",
|
2762
|
-
mainField: "id",
|
2763
|
-
pageSize: 10
|
2764
|
-
};
|
2765
|
-
const useDocumentLayout = (model) => {
|
2766
|
-
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
2767
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
2768
|
-
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
2769
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
2770
|
-
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
2771
|
-
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
2772
|
-
const {
|
2773
|
-
data,
|
2774
|
-
isLoading: isLoadingConfigs,
|
2775
|
-
error,
|
2776
|
-
isFetching: isFetchingConfigs
|
2777
|
-
} = useGetContentTypeConfigurationQuery(model);
|
2778
|
-
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
2779
|
-
React__namespace.useEffect(() => {
|
2780
|
-
if (error) {
|
2781
|
-
toggleNotification({
|
2782
|
-
type: "danger",
|
2783
|
-
message: formatAPIError(error)
|
2784
|
-
});
|
2785
|
-
}
|
2786
|
-
}, [error, formatAPIError, toggleNotification]);
|
2787
|
-
const editLayout = React__namespace.useMemo(
|
2788
|
-
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
2789
|
-
layout: [],
|
2790
|
-
components: {},
|
2791
|
-
metadatas: {},
|
2792
|
-
options: {},
|
2793
|
-
settings: DEFAULT_SETTINGS
|
2794
|
-
},
|
2795
|
-
[data, isLoading, schemas, schema, components]
|
2796
|
-
);
|
2797
|
-
const listLayout = React__namespace.useMemo(() => {
|
2798
|
-
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
2799
|
-
layout: [],
|
2800
|
-
metadatas: {},
|
2801
|
-
options: {},
|
2802
|
-
settings: DEFAULT_SETTINGS
|
2803
|
-
};
|
2804
|
-
}, [data, isLoading, schemas, schema, components]);
|
2805
|
-
const { layout: edit } = React__namespace.useMemo(
|
2806
|
-
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
2807
|
-
layout: editLayout,
|
2808
|
-
query
|
2809
|
-
}),
|
2810
|
-
[editLayout, query, runHookWaterfall]
|
2811
|
-
);
|
2812
|
-
return {
|
2813
|
-
error,
|
2814
|
-
isLoading,
|
2815
|
-
edit,
|
2816
|
-
list: listLayout
|
2817
|
-
};
|
2818
|
-
};
|
2819
|
-
const useDocLayout = () => {
|
2820
|
-
const { model } = useDoc();
|
2821
|
-
return useDocumentLayout(model);
|
2822
|
-
};
|
2823
|
-
const formatEditLayout = (data, {
|
2824
|
-
schemas,
|
2825
|
-
schema,
|
2826
|
-
components
|
2827
|
-
}) => {
|
2828
|
-
let currentPanelIndex = 0;
|
2829
|
-
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
2830
|
-
data.contentType.layouts.edit,
|
2831
|
-
schema?.attributes,
|
2832
|
-
data.contentType.metadatas,
|
2833
|
-
{ configurations: data.components, schemas: components },
|
2834
|
-
schemas
|
2835
|
-
).reduce((panels, row) => {
|
2836
|
-
if (row.some((field) => field.type === "dynamiczone")) {
|
2837
|
-
panels.push([row]);
|
2838
|
-
currentPanelIndex += 2;
|
2839
|
-
} else {
|
2840
|
-
if (!panels[currentPanelIndex]) {
|
2841
|
-
panels.push([]);
|
2842
|
-
}
|
2843
|
-
panels[currentPanelIndex].push(row);
|
2844
|
-
}
|
2845
|
-
return panels;
|
2846
|
-
}, []);
|
2847
|
-
const componentEditAttributes = Object.entries(data.components).reduce(
|
2848
|
-
(acc, [uid, configuration]) => {
|
2849
|
-
acc[uid] = {
|
2850
|
-
layout: convertEditLayoutToFieldLayouts(
|
2851
|
-
configuration.layouts.edit,
|
2852
|
-
components[uid].attributes,
|
2853
|
-
configuration.metadatas,
|
2854
|
-
{ configurations: data.components, schemas: components }
|
2855
|
-
),
|
2856
|
-
settings: {
|
2857
|
-
...configuration.settings,
|
2858
|
-
icon: components[uid].info.icon,
|
2859
|
-
displayName: components[uid].info.displayName
|
3013
|
+
}
|
3014
|
+
});
|
3015
|
+
if (!("error" in res)) {
|
3016
|
+
navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
|
3017
|
+
}
|
3018
|
+
} finally {
|
3019
|
+
if (!listViewPathMatch) {
|
3020
|
+
setSubmitting(false);
|
3021
|
+
}
|
2860
3022
|
}
|
2861
|
-
}
|
2862
|
-
return acc;
|
2863
|
-
},
|
2864
|
-
{}
|
2865
|
-
);
|
2866
|
-
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2867
|
-
(acc, [attribute, metadata]) => {
|
2868
|
-
return {
|
2869
|
-
...acc,
|
2870
|
-
[attribute]: metadata.edit
|
2871
|
-
};
|
2872
|
-
},
|
2873
|
-
{}
|
2874
|
-
);
|
2875
|
-
return {
|
2876
|
-
layout: panelledEditAttributes,
|
2877
|
-
components: componentEditAttributes,
|
2878
|
-
metadatas: editMetadatas,
|
2879
|
-
settings: {
|
2880
|
-
...data.contentType.settings,
|
2881
|
-
displayName: schema?.info.displayName
|
3023
|
+
}
|
2882
3024
|
},
|
2883
|
-
|
2884
|
-
|
2885
|
-
...schema?.pluginOptions,
|
2886
|
-
...data.contentType.options
|
2887
|
-
}
|
3025
|
+
variant: "danger",
|
3026
|
+
position: ["header", "table-row"]
|
2888
3027
|
};
|
2889
3028
|
};
|
2890
|
-
|
2891
|
-
|
2892
|
-
|
2893
|
-
|
2894
|
-
|
2895
|
-
|
2896
|
-
|
2897
|
-
|
2898
|
-
|
2899
|
-
|
2900
|
-
|
2901
|
-
|
2902
|
-
|
2903
|
-
|
2904
|
-
|
2905
|
-
|
2906
|
-
|
2907
|
-
|
2908
|
-
|
2909
|
-
|
2910
|
-
|
2911
|
-
|
2912
|
-
|
2913
|
-
|
2914
|
-
|
2915
|
-
|
2916
|
-
|
2917
|
-
|
2918
|
-
|
3029
|
+
DeleteAction$1.type = "delete";
|
3030
|
+
DeleteAction$1.position = ["header", "table-row"];
|
3031
|
+
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
3032
|
+
const Panels = () => {
|
3033
|
+
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
3034
|
+
const [
|
3035
|
+
{
|
3036
|
+
query: { status }
|
3037
|
+
}
|
3038
|
+
] = strapiAdmin.useQueryParams({
|
3039
|
+
status: "draft"
|
3040
|
+
});
|
3041
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
3042
|
+
const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
|
3043
|
+
const props = {
|
3044
|
+
activeTab: status,
|
3045
|
+
model,
|
3046
|
+
documentId: id,
|
3047
|
+
document: isCloning ? void 0 : document,
|
3048
|
+
meta: isCloning ? void 0 : meta,
|
3049
|
+
collectionType
|
3050
|
+
};
|
3051
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
3052
|
+
strapiAdmin.DescriptionComponentRenderer,
|
3053
|
+
{
|
3054
|
+
props,
|
3055
|
+
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
3056
|
+
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
|
3057
|
+
}
|
3058
|
+
) });
|
2919
3059
|
};
|
2920
|
-
const
|
2921
|
-
|
2922
|
-
schema,
|
2923
|
-
components
|
2924
|
-
}) => {
|
2925
|
-
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2926
|
-
(acc, [attribute, metadata]) => {
|
2927
|
-
return {
|
2928
|
-
...acc,
|
2929
|
-
[attribute]: metadata.list
|
2930
|
-
};
|
2931
|
-
},
|
2932
|
-
{}
|
2933
|
-
);
|
2934
|
-
const listAttributes = convertListLayoutToFieldLayouts(
|
2935
|
-
data.contentType.layouts.list,
|
2936
|
-
schema?.attributes,
|
2937
|
-
listMetadatas,
|
2938
|
-
{ configurations: data.components, schemas: components },
|
2939
|
-
schemas
|
2940
|
-
);
|
3060
|
+
const ActionsPanel = () => {
|
3061
|
+
const { formatMessage } = reactIntl.useIntl();
|
2941
3062
|
return {
|
2942
|
-
|
2943
|
-
|
2944
|
-
|
2945
|
-
|
2946
|
-
|
2947
|
-
...schema?.pluginOptions,
|
2948
|
-
...data.contentType.options
|
2949
|
-
}
|
3063
|
+
title: formatMessage({
|
3064
|
+
id: "content-manager.containers.edit.panels.default.title",
|
3065
|
+
defaultMessage: "Entry"
|
3066
|
+
}),
|
3067
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2950
3068
|
};
|
2951
3069
|
};
|
2952
|
-
|
2953
|
-
|
2954
|
-
|
2955
|
-
|
2956
|
-
|
3070
|
+
ActionsPanel.type = "actions";
|
3071
|
+
const ActionsPanelContent = () => {
|
3072
|
+
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
3073
|
+
const [
|
3074
|
+
{
|
3075
|
+
query: { status = "draft" }
|
2957
3076
|
}
|
2958
|
-
|
2959
|
-
|
2960
|
-
|
2961
|
-
|
2962
|
-
|
2963
|
-
|
2964
|
-
|
2965
|
-
|
2966
|
-
|
2967
|
-
|
2968
|
-
|
2969
|
-
|
2970
|
-
|
2971
|
-
|
3077
|
+
] = strapiAdmin.useQueryParams();
|
3078
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
3079
|
+
const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
|
3080
|
+
const props = {
|
3081
|
+
activeTab: status,
|
3082
|
+
model,
|
3083
|
+
documentId: id,
|
3084
|
+
document: isCloning ? void 0 : document,
|
3085
|
+
meta: isCloning ? void 0 : meta,
|
3086
|
+
collectionType
|
3087
|
+
};
|
3088
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
|
3089
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3090
|
+
strapiAdmin.DescriptionComponentRenderer,
|
3091
|
+
{
|
3092
|
+
props,
|
3093
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("panel"),
|
3094
|
+
children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
|
3095
|
+
}
|
3096
|
+
),
|
3097
|
+
/* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
3098
|
+
] });
|
2972
3099
|
};
|
3100
|
+
const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
3101
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
3102
|
+
designSystem.Flex,
|
3103
|
+
{
|
3104
|
+
ref,
|
3105
|
+
tag: "aside",
|
3106
|
+
"aria-labelledby": "additional-information",
|
3107
|
+
background: "neutral0",
|
3108
|
+
borderColor: "neutral150",
|
3109
|
+
hasRadius: true,
|
3110
|
+
paddingBottom: 4,
|
3111
|
+
paddingLeft: 4,
|
3112
|
+
paddingRight: 4,
|
3113
|
+
paddingTop: 4,
|
3114
|
+
shadow: "tableShadow",
|
3115
|
+
gap: 3,
|
3116
|
+
direction: "column",
|
3117
|
+
justifyContent: "stretch",
|
3118
|
+
alignItems: "flex-start",
|
3119
|
+
children: [
|
3120
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
|
3121
|
+
children
|
3122
|
+
]
|
3123
|
+
}
|
3124
|
+
);
|
3125
|
+
});
|
2973
3126
|
const ConfirmBulkActionDialog = ({
|
2974
3127
|
onToggleDialog,
|
2975
3128
|
isOpen = false,
|
@@ -3214,18 +3367,10 @@ const SelectedEntriesTableContent = ({
|
|
3214
3367
|
search: row.locale && `?plugins[i18n][locale]=${row.locale}`
|
3215
3368
|
},
|
3216
3369
|
state: { from: pathname },
|
3217
|
-
label: formatMessage(
|
3218
|
-
|
3219
|
-
|
3220
|
-
|
3221
|
-
{
|
3222
|
-
id: "content-manager.components.ListViewHelperPluginTable.row-line",
|
3223
|
-
defaultMessage: "item line {number}"
|
3224
|
-
},
|
3225
|
-
{ number: index2 + 1 }
|
3226
|
-
)
|
3227
|
-
}
|
3228
|
-
),
|
3370
|
+
label: formatMessage({
|
3371
|
+
id: "content-manager.bulk-publish.edit",
|
3372
|
+
defaultMessage: "Edit"
|
3373
|
+
}),
|
3229
3374
|
target: "_blank",
|
3230
3375
|
marginLeft: "auto",
|
3231
3376
|
variant: "ghost",
|
@@ -3399,8 +3544,7 @@ const PublishAction = ({ documents, model }) => {
|
|
3399
3544
|
const refetchList = () => {
|
3400
3545
|
contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
|
3401
3546
|
};
|
3402
|
-
if (!showPublishButton)
|
3403
|
-
return null;
|
3547
|
+
if (!showPublishButton) return null;
|
3404
3548
|
return {
|
3405
3549
|
actionType: "publish",
|
3406
3550
|
variant: "tertiary",
|
@@ -3468,8 +3612,7 @@ const DeleteAction = ({ documents, model }) => {
|
|
3468
3612
|
selectRow([]);
|
3469
3613
|
}
|
3470
3614
|
};
|
3471
|
-
if (!hasDeletePermission)
|
3472
|
-
return null;
|
3615
|
+
if (!hasDeletePermission) return null;
|
3473
3616
|
return {
|
3474
3617
|
variant: "danger-light",
|
3475
3618
|
label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
|
@@ -3518,8 +3661,7 @@ const UnpublishAction = ({ documents, model }) => {
|
|
3518
3661
|
}
|
3519
3662
|
};
|
3520
3663
|
const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
|
3521
|
-
if (!showUnpublishButton)
|
3522
|
-
return null;
|
3664
|
+
if (!showUnpublishButton) return null;
|
3523
3665
|
return {
|
3524
3666
|
variant: "tertiary",
|
3525
3667
|
label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
|
@@ -3624,7 +3766,7 @@ const TableActions = ({ document }) => {
|
|
3624
3766
|
strapiAdmin.DescriptionComponentRenderer,
|
3625
3767
|
{
|
3626
3768
|
props,
|
3627
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
|
3769
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("table-row").filter((action) => action.name !== "PublishAction"),
|
3628
3770
|
children: (actions2) => {
|
3629
3771
|
const tableRowActions = actions2.filter((action) => {
|
3630
3772
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -3683,6 +3825,7 @@ const EditAction = ({ documentId }) => {
|
|
3683
3825
|
};
|
3684
3826
|
};
|
3685
3827
|
EditAction.type = "edit";
|
3828
|
+
EditAction.position = "table-row";
|
3686
3829
|
const StyledPencil = styledComponents.styled(Icons.Pencil)`
|
3687
3830
|
path {
|
3688
3831
|
fill: currentColor;
|
@@ -3759,6 +3902,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3759
3902
|
};
|
3760
3903
|
};
|
3761
3904
|
CloneAction.type = "clone";
|
3905
|
+
CloneAction.position = "table-row";
|
3762
3906
|
const StyledDuplicate = styledComponents.styled(Icons.Duplicate)`
|
3763
3907
|
path {
|
3764
3908
|
fill: currentColor;
|
@@ -3845,7 +3989,14 @@ class ContentManagerPlugin {
|
|
3845
3989
|
addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
|
3846
3990
|
addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
|
3847
3991
|
getBulkActions: () => this.bulkActions,
|
3848
|
-
getDocumentActions: () =>
|
3992
|
+
getDocumentActions: (position) => {
|
3993
|
+
if (position) {
|
3994
|
+
return this.documentActions.filter(
|
3995
|
+
(action) => action.position == void 0 || [action.position].flat().includes(position)
|
3996
|
+
);
|
3997
|
+
}
|
3998
|
+
return this.documentActions;
|
3999
|
+
},
|
3849
4000
|
getEditViewSidePanels: () => this.editViewSidePanels,
|
3850
4001
|
getHeaderActions: () => this.headerActions
|
3851
4002
|
}
|
@@ -3855,10 +4006,8 @@ class ContentManagerPlugin {
|
|
3855
4006
|
const getPrintableType = (value) => {
|
3856
4007
|
const nativeType = typeof value;
|
3857
4008
|
if (nativeType === "object") {
|
3858
|
-
if (value === null)
|
3859
|
-
|
3860
|
-
if (Array.isArray(value))
|
3861
|
-
return "array";
|
4009
|
+
if (value === null) return "null";
|
4010
|
+
if (Array.isArray(value)) return "array";
|
3862
4011
|
if (value instanceof Object && value.constructor.name !== "Object") {
|
3863
4012
|
return value.constructor.name;
|
3864
4013
|
}
|
@@ -3869,17 +4018,27 @@ const HistoryAction = ({ model, document }) => {
|
|
3869
4018
|
const { formatMessage } = reactIntl.useIntl();
|
3870
4019
|
const [{ query }] = strapiAdmin.useQueryParams();
|
3871
4020
|
const navigate = reactRouterDom.useNavigate();
|
4021
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
4022
|
+
const { pathname } = reactRouterDom.useLocation();
|
3872
4023
|
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
3873
4024
|
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
3874
4025
|
return null;
|
3875
4026
|
}
|
4027
|
+
const handleOnClick = () => {
|
4028
|
+
const destination = { pathname: "history", search: pluginsQueryParams };
|
4029
|
+
trackUsage("willNavigate", {
|
4030
|
+
from: pathname,
|
4031
|
+
to: `${pathname}/${destination.pathname}`
|
4032
|
+
});
|
4033
|
+
navigate(destination);
|
4034
|
+
};
|
3876
4035
|
return {
|
3877
4036
|
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
3878
4037
|
label: formatMessage({
|
3879
4038
|
id: "content-manager.history.document-action",
|
3880
4039
|
defaultMessage: "Content History"
|
3881
4040
|
}),
|
3882
|
-
onClick:
|
4041
|
+
onClick: handleOnClick,
|
3883
4042
|
disabled: (
|
3884
4043
|
/**
|
3885
4044
|
* The user is creating a new document.
|
@@ -3901,6 +4060,7 @@ const HistoryAction = ({ model, document }) => {
|
|
3901
4060
|
};
|
3902
4061
|
};
|
3903
4062
|
HistoryAction.type = "history";
|
4063
|
+
HistoryAction.position = "header";
|
3904
4064
|
const historyAdmin = {
|
3905
4065
|
bootstrap(app) {
|
3906
4066
|
const { addDocumentAction } = app.getPlugin("content-manager").apis;
|
@@ -3947,6 +4107,88 @@ const { setInitialData } = actions;
|
|
3947
4107
|
const reducer = toolkit.combineReducers({
|
3948
4108
|
app: reducer$1
|
3949
4109
|
});
|
4110
|
+
const previewApi = contentManagerApi.injectEndpoints({
|
4111
|
+
endpoints: (builder) => ({
|
4112
|
+
getPreviewUrl: builder.query({
|
4113
|
+
query({ query, params }) {
|
4114
|
+
return {
|
4115
|
+
url: `/content-manager/preview/url/${params.contentType}`,
|
4116
|
+
method: "GET",
|
4117
|
+
config: {
|
4118
|
+
params: query
|
4119
|
+
}
|
4120
|
+
};
|
4121
|
+
}
|
4122
|
+
})
|
4123
|
+
})
|
4124
|
+
});
|
4125
|
+
const { useGetPreviewUrlQuery } = previewApi;
|
4126
|
+
const ConditionalTooltip = ({ isShown, label, children }) => {
|
4127
|
+
if (isShown) {
|
4128
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { label, children });
|
4129
|
+
}
|
4130
|
+
return children;
|
4131
|
+
};
|
4132
|
+
const PreviewSidePanel = ({ model, documentId, document }) => {
|
4133
|
+
const { formatMessage } = reactIntl.useIntl();
|
4134
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
4135
|
+
const { pathname } = reactRouterDom.useLocation();
|
4136
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
4137
|
+
const isModified = strapiAdmin.useForm("PreviewSidePanel", (state) => state.modified);
|
4138
|
+
const { data, error } = useGetPreviewUrlQuery({
|
4139
|
+
params: {
|
4140
|
+
contentType: model
|
4141
|
+
},
|
4142
|
+
query: {
|
4143
|
+
documentId,
|
4144
|
+
locale: document?.locale,
|
4145
|
+
status: document?.status
|
4146
|
+
}
|
4147
|
+
});
|
4148
|
+
if (!data?.data?.url || error) {
|
4149
|
+
return null;
|
4150
|
+
}
|
4151
|
+
const trackNavigation = () => {
|
4152
|
+
const destinationPathname = pathname.replace(/\/$/, "") + "/preview";
|
4153
|
+
trackUsage("willNavigate", { from: pathname, to: destinationPathname });
|
4154
|
+
};
|
4155
|
+
return {
|
4156
|
+
title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
|
4157
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(
|
4158
|
+
ConditionalTooltip,
|
4159
|
+
{
|
4160
|
+
label: formatMessage({
|
4161
|
+
id: "content-manager.preview.panel.button-disabled-tooltip",
|
4162
|
+
defaultMessage: "Please save to open the preview"
|
4163
|
+
}),
|
4164
|
+
isShown: isModified,
|
4165
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { cursor: "not-allowed", width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(
|
4166
|
+
designSystem.Button,
|
4167
|
+
{
|
4168
|
+
variant: "tertiary",
|
4169
|
+
tag: reactRouterDom.Link,
|
4170
|
+
to: { pathname: "preview", search: qs.stringify(query, { encode: false }) },
|
4171
|
+
onClick: trackNavigation,
|
4172
|
+
width: "100%",
|
4173
|
+
disabled: isModified,
|
4174
|
+
pointerEvents: isModified ? "none" : void 0,
|
4175
|
+
tabIndex: isModified ? -1 : void 0,
|
4176
|
+
children: formatMessage({
|
4177
|
+
id: "content-manager.preview.panel.button",
|
4178
|
+
defaultMessage: "Open preview"
|
4179
|
+
})
|
4180
|
+
}
|
4181
|
+
) })
|
4182
|
+
}
|
4183
|
+
)
|
4184
|
+
};
|
4185
|
+
};
|
4186
|
+
const previewAdmin = {
|
4187
|
+
bootstrap(app) {
|
4188
|
+
const contentManagerPluginApis = app.getPlugin("content-manager").apis;
|
4189
|
+
contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
|
4190
|
+
}
|
4191
|
+
};
|
3950
4192
|
const index = {
|
3951
4193
|
register(app) {
|
3952
4194
|
const cm = new ContentManagerPlugin();
|
@@ -3966,7 +4208,7 @@ const index = {
|
|
3966
4208
|
app.router.addRoute({
|
3967
4209
|
path: "content-manager/*",
|
3968
4210
|
lazy: async () => {
|
3969
|
-
const { Layout } = await Promise.resolve().then(() => require("./layout-
|
4211
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-CB2vrWLp.js"));
|
3970
4212
|
return {
|
3971
4213
|
Component: Layout
|
3972
4214
|
};
|
@@ -3979,11 +4221,14 @@ const index = {
|
|
3979
4221
|
if (typeof historyAdmin.bootstrap === "function") {
|
3980
4222
|
historyAdmin.bootstrap(app);
|
3981
4223
|
}
|
4224
|
+
if (typeof previewAdmin.bootstrap === "function") {
|
4225
|
+
previewAdmin.bootstrap(app);
|
4226
|
+
}
|
3982
4227
|
},
|
3983
4228
|
async registerTrads({ locales }) {
|
3984
4229
|
const importedTrads = await Promise.all(
|
3985
4230
|
locales.map((locale) => {
|
3986
|
-
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-
|
4231
|
+
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 }) => {
|
3987
4232
|
return {
|
3988
4233
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3989
4234
|
locale
|
@@ -4029,6 +4274,7 @@ exports.getMainField = getMainField;
|
|
4029
4274
|
exports.getTranslation = getTranslation;
|
4030
4275
|
exports.index = index;
|
4031
4276
|
exports.setInitialData = setInitialData;
|
4277
|
+
exports.useContentManagerContext = useContentManagerContext;
|
4032
4278
|
exports.useContentTypeSchema = useContentTypeSchema;
|
4033
4279
|
exports.useDoc = useDoc;
|
4034
4280
|
exports.useDocLayout = useDocLayout;
|
@@ -4040,5 +4286,6 @@ exports.useGetAllContentTypeSettingsQuery = useGetAllContentTypeSettingsQuery;
|
|
4040
4286
|
exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
4041
4287
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
4042
4288
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
4289
|
+
exports.useGetPreviewUrlQuery = useGetPreviewUrlQuery;
|
4043
4290
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
4044
|
-
//# sourceMappingURL=index-
|
4291
|
+
//# sourceMappingURL=index-TSBwtMDV.js.map
|