@strapi/content-manager 0.0.0-experimental.e9122b401c96877b6707775c4f893660eab93ae3 → 0.0.0-experimental.eba25ec571b091c6bde1104eb6c753debdf15462
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/{ComponentConfigurationPage-CpBFh6_r.mjs → ComponentConfigurationPage-BaJMOQyq.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-CpBFh6_r.mjs.map → ComponentConfigurationPage-BaJMOQyq.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-_zF8p6CY.js → ComponentConfigurationPage-N-CTtgQa.js} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-_zF8p6CY.js.map → ComponentConfigurationPage-N-CTtgQa.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-_aG2DJSU.js → EditConfigurationPage-BHkjAbxH.js} +4 -4
- package/dist/_chunks/{EditConfigurationPage-_aG2DJSU.js.map → EditConfigurationPage-BHkjAbxH.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CE_yavTi.mjs → EditConfigurationPage-CKK-5LfX.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-CE_yavTi.mjs.map → EditConfigurationPage-CKK-5LfX.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-DeTn7rAF.mjs → EditViewPage-B11aeMcf.mjs} +50 -10
- package/dist/_chunks/EditViewPage-B11aeMcf.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-G9uNzwYL.js → EditViewPage-QPUftxUd.js} +49 -9
- package/dist/_chunks/EditViewPage-QPUftxUd.js.map +1 -0
- package/dist/_chunks/{Field-CnCKhI1R.mjs → Field-Bj_RgtGo.mjs} +109 -46
- package/dist/_chunks/Field-Bj_RgtGo.mjs.map +1 -0
- package/dist/_chunks/{Field-DDHUWEfV.js → Field-DUK83cfh.js} +108 -45
- package/dist/_chunks/Field-DUK83cfh.js.map +1 -0
- package/dist/_chunks/{Form-DYETaKUX.js → Form-DHmBRlHd.js} +3 -3
- package/dist/_chunks/Form-DHmBRlHd.js.map +1 -0
- package/dist/_chunks/{Form-IvVVwqRL.mjs → Form-DLMSoXV7.mjs} +3 -3
- package/dist/_chunks/Form-DLMSoXV7.mjs.map +1 -0
- package/dist/_chunks/{History-BMunT-do.mjs → History-CfCSNlG9.mjs} +43 -100
- package/dist/_chunks/History-CfCSNlG9.mjs.map +1 -0
- package/dist/_chunks/{History-CnZDctSO.js → History-Di3zm4HT.js} +41 -98
- package/dist/_chunks/History-Di3zm4HT.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-CDqkCxgV.mjs → ListConfigurationPage-0mtv_iqk.mjs} +6 -5
- package/dist/_chunks/ListConfigurationPage-0mtv_iqk.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-BynalOp8.js → ListConfigurationPage-Cq361KIt.js} +5 -4
- package/dist/_chunks/ListConfigurationPage-Cq361KIt.js.map +1 -0
- package/dist/_chunks/{ListViewPage-_5gS-DOF.mjs → ListViewPage-BxLVROX8.mjs} +69 -42
- package/dist/_chunks/ListViewPage-BxLVROX8.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-I88Ouzoq.js → ListViewPage-DFDcG8gM.js} +69 -42
- package/dist/_chunks/ListViewPage-DFDcG8gM.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-Dht-55hr.mjs → NoContentTypePage-BRfDd67_.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-Dht-55hr.mjs.map → NoContentTypePage-BRfDd67_.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-BaWQ7HsA.js → NoContentTypePage-BSyvnDZZ.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-BaWQ7HsA.js.map → NoContentTypePage-BSyvnDZZ.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-Bs8D5W_v.mjs → NoPermissionsPage-CV9V8KWa.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-Bs8D5W_v.mjs.map → NoPermissionsPage-CV9V8KWa.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DCVUh5at.js → NoPermissionsPage-DyLphsn_.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DCVUh5at.js.map → NoPermissionsPage-DyLphsn_.js.map} +1 -1
- package/dist/_chunks/Preview-C_B1nx3g.mjs +272 -0
- package/dist/_chunks/Preview-C_B1nx3g.mjs.map +1 -0
- package/dist/_chunks/Preview-D_3aO6Ly.js +291 -0
- package/dist/_chunks/Preview-D_3aO6Ly.js.map +1 -0
- package/dist/_chunks/{Relations-Chdt5qWc.mjs → Relations-C6pwmDXh.mjs} +72 -36
- package/dist/_chunks/Relations-C6pwmDXh.mjs.map +1 -0
- package/dist/_chunks/{Relations-BPgFQeGj.js → Relations-Cne2AlrL.js} +71 -35
- package/dist/_chunks/Relations-Cne2AlrL.js.map +1 -0
- package/dist/_chunks/{en-CPTj6CjC.mjs → en-DhFUjrNW.mjs} +22 -11
- package/dist/_chunks/{en-CPTj6CjC.mjs.map → en-DhFUjrNW.mjs.map} +1 -1
- package/dist/_chunks/{en-BVzUkPxZ.js → en-Ic0kXjxB.js} +22 -11
- package/dist/_chunks/{en-BVzUkPxZ.js.map → en-Ic0kXjxB.js.map} +1 -1
- package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
- package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
- package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
- package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
- package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
- package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
- package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
- package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
- package/dist/_chunks/{index-D4UGPFZC.mjs → index-BpxR3En4.mjs} +887 -726
- package/dist/_chunks/index-BpxR3En4.mjs.map +1 -0
- package/dist/_chunks/{index-BhbLFX4l.js → index-T-aWjbj2.js} +884 -722
- package/dist/_chunks/index-T-aWjbj2.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-CYA7s0qO.js → layout-BEuNwv-F.js} +3 -3
- package/dist/_chunks/{layout-CYA7s0qO.js.map → layout-BEuNwv-F.js.map} +1 -1
- package/dist/_chunks/{layout-D4HI4_PS.mjs → layout-DhMZ_lDx.mjs} +3 -3
- package/dist/_chunks/{layout-D4HI4_PS.mjs.map → layout-DhMZ_lDx.mjs.map} +1 -1
- package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
- package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
- package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
- package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
- package/dist/_chunks/{relations-1pXaYpBK.mjs → relations-BdnxoX6f.mjs} +6 -7
- package/dist/_chunks/relations-BdnxoX6f.mjs.map +1 -0
- package/dist/_chunks/{relations-DDZ9OxNo.js → relations-kLcuobLk.js} +6 -7
- package/dist/_chunks/relations-kLcuobLk.js.map +1 -0
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +4 -3
- package/dist/admin/src/exports.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/DocumentStatus.d.ts +2 -2
- 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/constants.d.ts +1 -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/documents.d.ts +0 -3
- package/dist/server/index.js +421 -160
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +422 -161
- 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/constants.d.ts +2 -0
- package/dist/server/src/preview/constants.d.ts.map +1 -0
- 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 +13 -13
- package/dist/_chunks/EditViewPage-DeTn7rAF.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-G9uNzwYL.js.map +0 -1
- package/dist/_chunks/Field-CnCKhI1R.mjs.map +0 -1
- package/dist/_chunks/Field-DDHUWEfV.js.map +0 -1
- package/dist/_chunks/Form-DYETaKUX.js.map +0 -1
- package/dist/_chunks/Form-IvVVwqRL.mjs.map +0 -1
- package/dist/_chunks/History-BMunT-do.mjs.map +0 -1
- package/dist/_chunks/History-CnZDctSO.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-BynalOp8.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-CDqkCxgV.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-I88Ouzoq.js.map +0 -1
- package/dist/_chunks/ListViewPage-_5gS-DOF.mjs.map +0 -1
- package/dist/_chunks/Relations-BPgFQeGj.js.map +0 -1
- package/dist/_chunks/Relations-Chdt5qWc.mjs.map +0 -1
- package/dist/_chunks/index-BhbLFX4l.js.map +0 -1
- package/dist/_chunks/index-D4UGPFZC.mjs.map +0 -1
- package/dist/_chunks/relations-1pXaYpBK.mjs.map +0 -1
- package/dist/_chunks/relations-DDZ9OxNo.js.map +0 -1
- package/strapi-server.js +0 -3
@@ -4,13 +4,14 @@ 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) {
|
@@ -32,6 +33,7 @@ function _interopNamespace(e) {
|
|
32
33
|
return Object.freeze(n);
|
33
34
|
}
|
34
35
|
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
36
|
+
const mapValues__default = /* @__PURE__ */ _interopDefault(mapValues);
|
35
37
|
const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
|
36
38
|
const pipe__default = /* @__PURE__ */ _interopDefault(pipe);
|
37
39
|
const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
@@ -121,6 +123,7 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
121
123
|
if (!slug) {
|
122
124
|
throw new Error("Cannot find the slug param in the URL");
|
123
125
|
}
|
126
|
+
const [{ rawQuery }] = strapiAdmin.useQueryParams();
|
124
127
|
const userPermissions = strapiAdmin.useAuth("DocumentRBAC", (state) => state.permissions);
|
125
128
|
const contentTypePermissions = React__namespace.useMemo(() => {
|
126
129
|
const contentTypePermissions2 = userPermissions.filter(
|
@@ -131,7 +134,14 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
131
134
|
return { ...acc, [action]: [permission] };
|
132
135
|
}, {});
|
133
136
|
}, [slug, userPermissions]);
|
134
|
-
const { isLoading, allowedActions } = strapiAdmin.useRBAC(
|
137
|
+
const { isLoading, allowedActions } = strapiAdmin.useRBAC(
|
138
|
+
contentTypePermissions,
|
139
|
+
permissions ?? void 0,
|
140
|
+
// TODO: useRBAC context should be typed and built differently
|
141
|
+
// We are passing raw query as context to the hook so that it can
|
142
|
+
// rely on the locale provided from DocumentRBAC for its permission calculations.
|
143
|
+
rawQuery
|
144
|
+
);
|
135
145
|
const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
|
136
146
|
const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
|
137
147
|
const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
|
@@ -286,7 +296,7 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
286
296
|
url: `/content-manager/collection-types/${model}`,
|
287
297
|
method: "GET",
|
288
298
|
config: {
|
289
|
-
params
|
299
|
+
params: qs.stringify(params, { encode: true })
|
290
300
|
}
|
291
301
|
}),
|
292
302
|
providesTags: (result, _error, arg) => {
|
@@ -474,14 +484,29 @@ const buildValidParams = (query) => {
|
|
474
484
|
{}
|
475
485
|
)
|
476
486
|
};
|
477
|
-
if ("_q" in validQueryParams) {
|
478
|
-
validQueryParams._q = encodeURIComponent(validQueryParams._q);
|
479
|
-
}
|
480
487
|
return validQueryParams;
|
481
488
|
};
|
482
489
|
const isBaseQueryError = (error) => {
|
483
490
|
return error.name !== void 0;
|
484
491
|
};
|
492
|
+
const arrayValidator = (attribute, options) => ({
|
493
|
+
message: strapiAdmin.translatedErrors.required,
|
494
|
+
test(value) {
|
495
|
+
if (options.status === "draft") {
|
496
|
+
return true;
|
497
|
+
}
|
498
|
+
if (!attribute.required) {
|
499
|
+
return true;
|
500
|
+
}
|
501
|
+
if (!value) {
|
502
|
+
return false;
|
503
|
+
}
|
504
|
+
if (Array.isArray(value) && value.length === 0) {
|
505
|
+
return false;
|
506
|
+
}
|
507
|
+
return true;
|
508
|
+
}
|
509
|
+
});
|
485
510
|
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
486
511
|
const createModelSchema = (attributes2) => yup__namespace.object().shape(
|
487
512
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
@@ -489,6 +514,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
489
514
|
return acc;
|
490
515
|
}
|
491
516
|
const validations = [
|
517
|
+
addNullableValidation,
|
492
518
|
addRequiredValidation,
|
493
519
|
addMinLengthValidation,
|
494
520
|
addMaxLengthValidation,
|
@@ -505,12 +531,12 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
505
531
|
...acc,
|
506
532
|
[name]: transformSchema(
|
507
533
|
yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
|
508
|
-
)
|
534
|
+
).test(arrayValidator(attribute, options))
|
509
535
|
};
|
510
536
|
} else {
|
511
537
|
return {
|
512
538
|
...acc,
|
513
|
-
[name]: transformSchema(createModelSchema(attributes3))
|
539
|
+
[name]: transformSchema(createModelSchema(attributes3).nullable())
|
514
540
|
};
|
515
541
|
}
|
516
542
|
}
|
@@ -532,7 +558,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
532
558
|
}
|
533
559
|
)
|
534
560
|
)
|
535
|
-
)
|
561
|
+
).test(arrayValidator(attribute, options))
|
536
562
|
};
|
537
563
|
case "relation":
|
538
564
|
return {
|
@@ -544,7 +570,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
544
570
|
} else if (Array.isArray(value)) {
|
545
571
|
return yup__namespace.array().of(
|
546
572
|
yup__namespace.object().shape({
|
547
|
-
id: yup__namespace.
|
573
|
+
id: yup__namespace.number().required()
|
548
574
|
})
|
549
575
|
);
|
550
576
|
} else if (typeof value === "object") {
|
@@ -630,17 +656,17 @@ const nullableSchema = (schema) => {
|
|
630
656
|
schema
|
631
657
|
);
|
632
658
|
};
|
659
|
+
const addNullableValidation = () => (schema) => {
|
660
|
+
return nullableSchema(schema);
|
661
|
+
};
|
633
662
|
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);
|
663
|
+
if (options.status === "draft" || !attribute.required) {
|
664
|
+
return schema;
|
639
665
|
}
|
640
|
-
if (attribute.required &&
|
666
|
+
if (attribute.required && "required" in schema) {
|
641
667
|
return schema.required(strapiAdmin.translatedErrors.required);
|
642
668
|
}
|
643
|
-
return
|
669
|
+
return schema;
|
644
670
|
};
|
645
671
|
const addMinLengthValidation = (attribute, options) => (schema) => {
|
646
672
|
if (options.status === "draft") {
|
@@ -668,31 +694,12 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
668
694
|
return schema;
|
669
695
|
};
|
670
696
|
const addMinValidation = (attribute, options) => (schema) => {
|
671
|
-
if ("
|
697
|
+
if (options.status === "draft") {
|
698
|
+
return schema;
|
699
|
+
}
|
700
|
+
if ("min" in attribute && "min" in schema) {
|
672
701
|
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) {
|
702
|
+
if (min) {
|
696
703
|
return schema.min(min, {
|
697
704
|
...strapiAdmin.translatedErrors.min,
|
698
705
|
values: {
|
@@ -810,19 +817,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
|
|
810
817
|
}, {});
|
811
818
|
return componentsByKey;
|
812
819
|
};
|
813
|
-
const
|
820
|
+
const HOOKS = {
|
821
|
+
/**
|
822
|
+
* Hook that allows to mutate the displayed headers of the list view table
|
823
|
+
* @constant
|
824
|
+
* @type {string}
|
825
|
+
*/
|
826
|
+
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
827
|
+
/**
|
828
|
+
* Hook that allows to mutate the CM's collection types links pre-set filters
|
829
|
+
* @constant
|
830
|
+
* @type {string}
|
831
|
+
*/
|
832
|
+
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
833
|
+
/**
|
834
|
+
* Hook that allows to mutate the CM's edit view layout
|
835
|
+
* @constant
|
836
|
+
* @type {string}
|
837
|
+
*/
|
838
|
+
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
839
|
+
/**
|
840
|
+
* Hook that allows to mutate the CM's single types links pre-set filters
|
841
|
+
* @constant
|
842
|
+
* @type {string}
|
843
|
+
*/
|
844
|
+
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
845
|
+
};
|
846
|
+
const contentTypesApi = contentManagerApi.injectEndpoints({
|
847
|
+
endpoints: (builder) => ({
|
848
|
+
getContentTypeConfiguration: builder.query({
|
849
|
+
query: (uid) => ({
|
850
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
851
|
+
method: "GET"
|
852
|
+
}),
|
853
|
+
transformResponse: (response) => response.data,
|
854
|
+
providesTags: (_result, _error, uid) => [
|
855
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
856
|
+
{ type: "ContentTypeSettings", id: "LIST" }
|
857
|
+
]
|
858
|
+
}),
|
859
|
+
getAllContentTypeSettings: builder.query({
|
860
|
+
query: () => "/content-manager/content-types-settings",
|
861
|
+
transformResponse: (response) => response.data,
|
862
|
+
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
863
|
+
}),
|
864
|
+
updateContentTypeConfiguration: builder.mutation({
|
865
|
+
query: ({ uid, ...body }) => ({
|
866
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
867
|
+
method: "PUT",
|
868
|
+
data: body
|
869
|
+
}),
|
870
|
+
transformResponse: (response) => response.data,
|
871
|
+
invalidatesTags: (_result, _error, { uid }) => [
|
872
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
873
|
+
{ type: "ContentTypeSettings", id: "LIST" },
|
874
|
+
// Is this necessary?
|
875
|
+
{ type: "InitialData" }
|
876
|
+
]
|
877
|
+
})
|
878
|
+
})
|
879
|
+
});
|
880
|
+
const {
|
881
|
+
useGetContentTypeConfigurationQuery,
|
882
|
+
useGetAllContentTypeSettingsQuery,
|
883
|
+
useUpdateContentTypeConfigurationMutation
|
884
|
+
} = contentTypesApi;
|
885
|
+
const checkIfAttributeIsDisplayable = (attribute) => {
|
886
|
+
const { type } = attribute;
|
887
|
+
if (type === "relation") {
|
888
|
+
return !attribute.relation.toLowerCase().includes("morph");
|
889
|
+
}
|
890
|
+
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
891
|
+
};
|
892
|
+
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
893
|
+
if (!mainFieldName) {
|
894
|
+
return void 0;
|
895
|
+
}
|
896
|
+
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
897
|
+
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
898
|
+
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
899
|
+
);
|
900
|
+
return {
|
901
|
+
name: mainFieldName,
|
902
|
+
type: mainFieldType ?? "string"
|
903
|
+
};
|
904
|
+
};
|
905
|
+
const DEFAULT_SETTINGS = {
|
906
|
+
bulkable: false,
|
907
|
+
filterable: false,
|
908
|
+
searchable: false,
|
909
|
+
pagination: false,
|
910
|
+
defaultSortBy: "",
|
911
|
+
defaultSortOrder: "asc",
|
912
|
+
mainField: "id",
|
913
|
+
pageSize: 10
|
914
|
+
};
|
915
|
+
const useDocumentLayout = (model) => {
|
916
|
+
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
917
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
918
|
+
const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
814
919
|
const { toggleNotification } = strapiAdmin.useNotification();
|
815
920
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
921
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
816
922
|
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);
|
923
|
+
data,
|
924
|
+
isLoading: isLoadingConfigs,
|
925
|
+
error,
|
926
|
+
isFetching: isFetchingConfigs
|
927
|
+
} = useGetContentTypeConfigurationQuery(model);
|
928
|
+
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
826
929
|
React__namespace.useEffect(() => {
|
827
930
|
if (error) {
|
828
931
|
toggleNotification({
|
@@ -830,94 +933,349 @@ const useDocument = (args, opts) => {
|
|
830
933
|
message: formatAPIError(error)
|
831
934
|
});
|
832
935
|
}
|
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
|
-
}
|
936
|
+
}, [error, formatAPIError, toggleNotification]);
|
937
|
+
const editLayout = React__namespace.useMemo(
|
938
|
+
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
939
|
+
layout: [],
|
940
|
+
components: {},
|
941
|
+
metadatas: {},
|
942
|
+
options: {},
|
943
|
+
settings: DEFAULT_SETTINGS
|
856
944
|
},
|
857
|
-
[
|
945
|
+
[data, isLoading, schemas, schema, components]
|
946
|
+
);
|
947
|
+
const listLayout = React__namespace.useMemo(() => {
|
948
|
+
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
949
|
+
layout: [],
|
950
|
+
metadatas: {},
|
951
|
+
options: {},
|
952
|
+
settings: DEFAULT_SETTINGS
|
953
|
+
};
|
954
|
+
}, [data, isLoading, schemas, schema, components]);
|
955
|
+
const { layout: edit } = React__namespace.useMemo(
|
956
|
+
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
957
|
+
layout: editLayout,
|
958
|
+
query
|
959
|
+
}),
|
960
|
+
[editLayout, query, runHookWaterfall]
|
858
961
|
);
|
859
|
-
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
860
962
|
return {
|
861
|
-
|
862
|
-
document: data?.data,
|
863
|
-
meta: data?.meta,
|
963
|
+
error,
|
864
964
|
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
|
-
)
|
965
|
+
edit,
|
966
|
+
list: listLayout
|
889
967
|
};
|
890
968
|
};
|
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"
|
969
|
+
const useDocLayout = () => {
|
970
|
+
const { model } = useDoc();
|
971
|
+
return useDocumentLayout(model);
|
904
972
|
};
|
905
|
-
const
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
const
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
973
|
+
const formatEditLayout = (data, {
|
974
|
+
schemas,
|
975
|
+
schema,
|
976
|
+
components
|
977
|
+
}) => {
|
978
|
+
let currentPanelIndex = 0;
|
979
|
+
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
980
|
+
data.contentType.layouts.edit,
|
981
|
+
schema?.attributes,
|
982
|
+
data.contentType.metadatas,
|
983
|
+
{ configurations: data.components, schemas: components },
|
984
|
+
schemas
|
985
|
+
).reduce((panels, row) => {
|
986
|
+
if (row.some((field) => field.type === "dynamiczone")) {
|
987
|
+
panels.push([row]);
|
988
|
+
currentPanelIndex += 2;
|
989
|
+
} else {
|
990
|
+
if (!panels[currentPanelIndex]) {
|
991
|
+
panels.push([row]);
|
992
|
+
} else {
|
993
|
+
panels[currentPanelIndex].push(row);
|
994
|
+
}
|
995
|
+
}
|
996
|
+
return panels;
|
997
|
+
}, []);
|
998
|
+
const componentEditAttributes = Object.entries(data.components).reduce(
|
999
|
+
(acc, [uid, configuration]) => {
|
1000
|
+
acc[uid] = {
|
1001
|
+
layout: convertEditLayoutToFieldLayouts(
|
1002
|
+
configuration.layouts.edit,
|
1003
|
+
components[uid].attributes,
|
1004
|
+
configuration.metadatas,
|
1005
|
+
{ configurations: data.components, schemas: components }
|
1006
|
+
),
|
1007
|
+
settings: {
|
1008
|
+
...configuration.settings,
|
1009
|
+
icon: components[uid].info.icon,
|
1010
|
+
displayName: components[uid].info.displayName
|
1011
|
+
}
|
1012
|
+
};
|
1013
|
+
return acc;
|
1014
|
+
},
|
1015
|
+
{}
|
1016
|
+
);
|
1017
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1018
|
+
(acc, [attribute, metadata]) => {
|
1019
|
+
return {
|
1020
|
+
...acc,
|
1021
|
+
[attribute]: metadata.edit
|
1022
|
+
};
|
1023
|
+
},
|
1024
|
+
{}
|
1025
|
+
);
|
1026
|
+
return {
|
1027
|
+
layout: panelledEditAttributes,
|
1028
|
+
components: componentEditAttributes,
|
1029
|
+
metadatas: editMetadatas,
|
1030
|
+
settings: {
|
1031
|
+
...data.contentType.settings,
|
1032
|
+
displayName: schema?.info.displayName
|
1033
|
+
},
|
1034
|
+
options: {
|
1035
|
+
...schema?.options,
|
1036
|
+
...schema?.pluginOptions,
|
1037
|
+
...data.contentType.options
|
1038
|
+
}
|
1039
|
+
};
|
1040
|
+
};
|
1041
|
+
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
1042
|
+
return rows.map(
|
1043
|
+
(row) => row.map((field) => {
|
1044
|
+
const attribute = attributes[field.name];
|
1045
|
+
if (!attribute) {
|
1046
|
+
return null;
|
1047
|
+
}
|
1048
|
+
const { edit: metadata } = metadatas[field.name];
|
1049
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1050
|
+
return {
|
1051
|
+
attribute,
|
1052
|
+
disabled: !metadata.editable,
|
1053
|
+
hint: metadata.description,
|
1054
|
+
label: metadata.label ?? "",
|
1055
|
+
name: field.name,
|
1056
|
+
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
1057
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1058
|
+
schemas,
|
1059
|
+
components: components?.schemas ?? {}
|
1060
|
+
}),
|
1061
|
+
placeholder: metadata.placeholder ?? "",
|
1062
|
+
required: attribute.required ?? false,
|
1063
|
+
size: field.size,
|
1064
|
+
unique: "unique" in attribute ? attribute.unique : false,
|
1065
|
+
visible: metadata.visible ?? true,
|
1066
|
+
type: attribute.type
|
1067
|
+
};
|
1068
|
+
}).filter((field) => field !== null)
|
1069
|
+
);
|
1070
|
+
};
|
1071
|
+
const formatListLayout = (data, {
|
1072
|
+
schemas,
|
1073
|
+
schema,
|
1074
|
+
components
|
1075
|
+
}) => {
|
1076
|
+
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1077
|
+
(acc, [attribute, metadata]) => {
|
1078
|
+
return {
|
1079
|
+
...acc,
|
1080
|
+
[attribute]: metadata.list
|
1081
|
+
};
|
1082
|
+
},
|
1083
|
+
{}
|
1084
|
+
);
|
1085
|
+
const listAttributes = convertListLayoutToFieldLayouts(
|
1086
|
+
data.contentType.layouts.list,
|
1087
|
+
schema?.attributes,
|
1088
|
+
listMetadatas,
|
1089
|
+
{ configurations: data.components, schemas: components },
|
1090
|
+
schemas
|
1091
|
+
);
|
1092
|
+
return {
|
1093
|
+
layout: listAttributes,
|
1094
|
+
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
1095
|
+
metadatas: listMetadatas,
|
1096
|
+
options: {
|
1097
|
+
...schema?.options,
|
1098
|
+
...schema?.pluginOptions,
|
1099
|
+
...data.contentType.options
|
1100
|
+
}
|
1101
|
+
};
|
1102
|
+
};
|
1103
|
+
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
1104
|
+
return columns.map((name) => {
|
1105
|
+
const attribute = attributes[name];
|
1106
|
+
if (!attribute) {
|
1107
|
+
return null;
|
1108
|
+
}
|
1109
|
+
const metadata = metadatas[name];
|
1110
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1111
|
+
return {
|
1112
|
+
attribute,
|
1113
|
+
label: metadata.label ?? "",
|
1114
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1115
|
+
schemas,
|
1116
|
+
components: components?.schemas ?? {}
|
1117
|
+
}),
|
1118
|
+
name,
|
1119
|
+
searchable: metadata.searchable ?? true,
|
1120
|
+
sortable: metadata.sortable ?? true
|
1121
|
+
};
|
1122
|
+
}).filter((field) => field !== null);
|
1123
|
+
};
|
1124
|
+
const useDocument = (args, opts) => {
|
1125
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
1126
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1127
|
+
const {
|
1128
|
+
currentData: data,
|
1129
|
+
isLoading: isLoadingDocument,
|
1130
|
+
isFetching: isFetchingDocument,
|
1131
|
+
error
|
1132
|
+
} = useGetDocumentQuery(args, {
|
1133
|
+
...opts,
|
1134
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
1135
|
+
});
|
1136
|
+
const {
|
1137
|
+
components,
|
1138
|
+
schema,
|
1139
|
+
schemas,
|
1140
|
+
isLoading: isLoadingSchema
|
1141
|
+
} = useContentTypeSchema(args.model);
|
1142
|
+
React__namespace.useEffect(() => {
|
1143
|
+
if (error) {
|
1144
|
+
toggleNotification({
|
1145
|
+
type: "danger",
|
1146
|
+
message: formatAPIError(error)
|
1147
|
+
});
|
1148
|
+
}
|
1149
|
+
}, [toggleNotification, error, formatAPIError, args.collectionType]);
|
1150
|
+
const validationSchema = React__namespace.useMemo(() => {
|
1151
|
+
if (!schema) {
|
1152
|
+
return null;
|
1153
|
+
}
|
1154
|
+
return createYupSchema(schema.attributes, components);
|
1155
|
+
}, [schema, components]);
|
1156
|
+
const validate = React__namespace.useCallback(
|
1157
|
+
(document) => {
|
1158
|
+
if (!validationSchema) {
|
1159
|
+
throw new Error(
|
1160
|
+
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
1161
|
+
);
|
1162
|
+
}
|
1163
|
+
try {
|
1164
|
+
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
1165
|
+
return null;
|
1166
|
+
} catch (error2) {
|
1167
|
+
if (error2 instanceof yup.ValidationError) {
|
1168
|
+
return strapiAdmin.getYupValidationErrors(error2);
|
1169
|
+
}
|
1170
|
+
throw error2;
|
1171
|
+
}
|
1172
|
+
},
|
1173
|
+
[validationSchema]
|
1174
|
+
);
|
1175
|
+
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
1176
|
+
const hasError = !!error;
|
1177
|
+
return {
|
1178
|
+
components,
|
1179
|
+
document: data?.data,
|
1180
|
+
meta: data?.meta,
|
1181
|
+
isLoading,
|
1182
|
+
hasError,
|
1183
|
+
schema,
|
1184
|
+
schemas,
|
1185
|
+
validate
|
1186
|
+
};
|
1187
|
+
};
|
1188
|
+
const useDoc = () => {
|
1189
|
+
const { id, slug, collectionType, origin } = reactRouterDom.useParams();
|
1190
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
1191
|
+
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
1192
|
+
if (!collectionType) {
|
1193
|
+
throw new Error("Could not find collectionType in url params");
|
1194
|
+
}
|
1195
|
+
if (!slug) {
|
1196
|
+
throw new Error("Could not find model in url params");
|
1197
|
+
}
|
1198
|
+
const document = useDocument(
|
1199
|
+
{ documentId: origin || id, model: slug, collectionType, params },
|
1200
|
+
{
|
1201
|
+
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
1202
|
+
}
|
1203
|
+
);
|
1204
|
+
const returnId = origin || id === "create" ? void 0 : id;
|
1205
|
+
return {
|
1206
|
+
collectionType,
|
1207
|
+
model: slug,
|
1208
|
+
id: returnId,
|
1209
|
+
...document
|
1210
|
+
};
|
1211
|
+
};
|
1212
|
+
const useContentManagerContext = () => {
|
1213
|
+
const {
|
1214
|
+
collectionType,
|
1215
|
+
model,
|
1216
|
+
id,
|
1217
|
+
components,
|
1218
|
+
isLoading: isLoadingDoc,
|
1219
|
+
schema,
|
1220
|
+
schemas
|
1221
|
+
} = useDoc();
|
1222
|
+
const layout = useDocumentLayout(model);
|
1223
|
+
const form = strapiAdmin.useForm("useContentManagerContext", (state) => state);
|
1224
|
+
const isSingleType = collectionType === SINGLE_TYPES;
|
1225
|
+
const slug = model;
|
1226
|
+
const isCreatingEntry = id === "create";
|
1227
|
+
useContentTypeSchema();
|
1228
|
+
const isLoading = isLoadingDoc || layout.isLoading;
|
1229
|
+
const error = layout.error;
|
1230
|
+
return {
|
1231
|
+
error,
|
1232
|
+
isLoading,
|
1233
|
+
// Base metadata
|
1234
|
+
model,
|
1235
|
+
collectionType,
|
1236
|
+
id,
|
1237
|
+
slug,
|
1238
|
+
isCreatingEntry,
|
1239
|
+
isSingleType,
|
1240
|
+
hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
|
1241
|
+
// All schema infos
|
1242
|
+
components,
|
1243
|
+
contentType: schema,
|
1244
|
+
contentTypes: schemas,
|
1245
|
+
// Form state
|
1246
|
+
form,
|
1247
|
+
// layout infos
|
1248
|
+
layout
|
1249
|
+
};
|
1250
|
+
};
|
1251
|
+
const prefixPluginTranslations = (trad, pluginId) => {
|
1252
|
+
return Object.keys(trad).reduce((acc, current) => {
|
1253
|
+
acc[`${pluginId}.${current}`] = trad[current];
|
1254
|
+
return acc;
|
1255
|
+
}, {});
|
1256
|
+
};
|
1257
|
+
const getTranslation = (id) => `content-manager.${id}`;
|
1258
|
+
const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
1259
|
+
id: "notification.error",
|
1260
|
+
defaultMessage: "An error occurred, please try again"
|
1261
|
+
};
|
1262
|
+
const useDocumentActions = () => {
|
1263
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
1264
|
+
const { formatMessage } = reactIntl.useIntl();
|
1265
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
1266
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
1267
|
+
const navigate = reactRouterDom.useNavigate();
|
1268
|
+
const setCurrentStep = strapiAdmin.useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
|
1269
|
+
const [deleteDocument] = useDeleteDocumentMutation();
|
1270
|
+
const _delete = React__namespace.useCallback(
|
1271
|
+
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
1272
|
+
try {
|
1273
|
+
trackUsage("willDeleteEntry", trackerProperty);
|
1274
|
+
const res = await deleteDocument({
|
1275
|
+
collectionType,
|
1276
|
+
model,
|
1277
|
+
documentId,
|
1278
|
+
params
|
921
1279
|
});
|
922
1280
|
if ("error" in res) {
|
923
1281
|
toggleNotification({
|
@@ -1222,6 +1580,7 @@ const useDocumentActions = () => {
|
|
1222
1580
|
defaultMessage: "Saved document"
|
1223
1581
|
})
|
1224
1582
|
});
|
1583
|
+
setCurrentStep("contentManager.success");
|
1225
1584
|
return res.data;
|
1226
1585
|
} catch (err) {
|
1227
1586
|
toggleNotification({
|
@@ -1323,10 +1682,10 @@ const useDocumentActions = () => {
|
|
1323
1682
|
update
|
1324
1683
|
};
|
1325
1684
|
};
|
1326
|
-
const ProtectedHistoryPage =
|
1327
|
-
() => Promise.resolve().then(() => require("./History-
|
1685
|
+
const ProtectedHistoryPage = React__namespace.lazy(
|
1686
|
+
() => Promise.resolve().then(() => require("./History-Di3zm4HT.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1328
1687
|
);
|
1329
|
-
const routes$
|
1688
|
+
const routes$2 = [
|
1330
1689
|
{
|
1331
1690
|
path: ":collectionType/:slug/:id/history",
|
1332
1691
|
Component: ProtectedHistoryPage
|
@@ -1336,32 +1695,45 @@ const routes$1 = [
|
|
1336
1695
|
Component: ProtectedHistoryPage
|
1337
1696
|
}
|
1338
1697
|
];
|
1698
|
+
const ProtectedPreviewPage = React__namespace.lazy(
|
1699
|
+
() => Promise.resolve().then(() => require("./Preview-D_3aO6Ly.js")).then((mod) => ({ default: mod.ProtectedPreviewPage }))
|
1700
|
+
);
|
1701
|
+
const routes$1 = [
|
1702
|
+
{
|
1703
|
+
path: ":collectionType/:slug/:id/preview",
|
1704
|
+
Component: ProtectedPreviewPage
|
1705
|
+
},
|
1706
|
+
{
|
1707
|
+
path: ":collectionType/:slug/preview",
|
1708
|
+
Component: ProtectedPreviewPage
|
1709
|
+
}
|
1710
|
+
];
|
1339
1711
|
const ProtectedEditViewPage = React.lazy(
|
1340
|
-
() => Promise.resolve().then(() => require("./EditViewPage-
|
1712
|
+
() => Promise.resolve().then(() => require("./EditViewPage-QPUftxUd.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1341
1713
|
);
|
1342
1714
|
const ProtectedListViewPage = React.lazy(
|
1343
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1715
|
+
() => Promise.resolve().then(() => require("./ListViewPage-DFDcG8gM.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1344
1716
|
);
|
1345
1717
|
const ProtectedListConfiguration = React.lazy(
|
1346
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1718
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-Cq361KIt.js")).then((mod) => ({
|
1347
1719
|
default: mod.ProtectedListConfiguration
|
1348
1720
|
}))
|
1349
1721
|
);
|
1350
1722
|
const ProtectedEditConfigurationPage = React.lazy(
|
1351
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1723
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-BHkjAbxH.js")).then((mod) => ({
|
1352
1724
|
default: mod.ProtectedEditConfigurationPage
|
1353
1725
|
}))
|
1354
1726
|
);
|
1355
1727
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1356
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1728
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-N-CTtgQa.js")).then((mod) => ({
|
1357
1729
|
default: mod.ProtectedComponentConfigurationPage
|
1358
1730
|
}))
|
1359
1731
|
);
|
1360
1732
|
const NoPermissions = React.lazy(
|
1361
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1733
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-DyLphsn_.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1362
1734
|
);
|
1363
1735
|
const NoContentType = React.lazy(
|
1364
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1736
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-BSyvnDZZ.js")).then((mod) => ({ default: mod.NoContentType }))
|
1365
1737
|
);
|
1366
1738
|
const CollectionTypePages = () => {
|
1367
1739
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1373,7 +1745,7 @@ const CollectionTypePages = () => {
|
|
1373
1745
|
const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
|
1374
1746
|
const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
|
1375
1747
|
const LIST_RELATIVE_PATH = ":collectionType/:slug";
|
1376
|
-
const LIST_PATH = `/content-manager
|
1748
|
+
const LIST_PATH = `/content-manager/collection-types/:slug`;
|
1377
1749
|
const routes = [
|
1378
1750
|
{
|
1379
1751
|
path: LIST_RELATIVE_PATH,
|
@@ -1407,6 +1779,7 @@ const routes = [
|
|
1407
1779
|
path: "no-content-types",
|
1408
1780
|
Component: NoContentType
|
1409
1781
|
},
|
1782
|
+
...routes$2,
|
1410
1783
|
...routes$1
|
1411
1784
|
];
|
1412
1785
|
const DocumentActions = ({ actions: actions2 }) => {
|
@@ -1505,6 +1878,11 @@ const DocumentActionButton = (action) => {
|
|
1505
1878
|
) : null
|
1506
1879
|
] });
|
1507
1880
|
};
|
1881
|
+
const MenuItem = styledComponents.styled(designSystem.Menu.Item)`
|
1882
|
+
&:hover {
|
1883
|
+
background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
|
1884
|
+
}
|
1885
|
+
`;
|
1508
1886
|
const DocumentActionsMenu = ({
|
1509
1887
|
actions: actions2,
|
1510
1888
|
children,
|
@@ -1560,51 +1938,35 @@ const DocumentActionsMenu = ({
|
|
1560
1938
|
]
|
1561
1939
|
}
|
1562
1940
|
),
|
1563
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, {
|
1941
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
|
1564
1942
|
actions2.map((action) => {
|
1565
1943
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
1566
|
-
|
1944
|
+
MenuItem,
|
1567
1945
|
{
|
1568
1946
|
disabled: action.disabled,
|
1569
1947
|
onSelect: handleClick(action),
|
1570
1948
|
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
|
-
] })
|
1949
|
+
isVariantDanger: action.variant === "danger",
|
1950
|
+
isDisabled: action.disabled,
|
1951
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
1952
|
+
designSystem.Flex,
|
1953
|
+
{
|
1954
|
+
color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
|
1955
|
+
gap: 2,
|
1956
|
+
tag: "span",
|
1957
|
+
children: [
|
1958
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
1959
|
+
designSystem.Flex,
|
1960
|
+
{
|
1961
|
+
tag: "span",
|
1962
|
+
color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
|
1963
|
+
children: action.icon
|
1964
|
+
}
|
1965
|
+
),
|
1966
|
+
action.label
|
1967
|
+
]
|
1968
|
+
}
|
1969
|
+
) })
|
1608
1970
|
},
|
1609
1971
|
action.id
|
1610
1972
|
);
|
@@ -1715,6 +2077,18 @@ const DocumentActionModal = ({
|
|
1715
2077
|
typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
|
1716
2078
|
] }) });
|
1717
2079
|
};
|
2080
|
+
const transformData = (data) => {
|
2081
|
+
if (Array.isArray(data)) {
|
2082
|
+
return data.map(transformData);
|
2083
|
+
}
|
2084
|
+
if (typeof data === "object" && data !== null) {
|
2085
|
+
if ("apiData" in data) {
|
2086
|
+
return data.apiData;
|
2087
|
+
}
|
2088
|
+
return mapValues__default.default(transformData)(data);
|
2089
|
+
}
|
2090
|
+
return data;
|
2091
|
+
};
|
1718
2092
|
const PublishAction$1 = ({
|
1719
2093
|
activeTab,
|
1720
2094
|
documentId,
|
@@ -1729,6 +2103,7 @@ const PublishAction$1 = ({
|
|
1729
2103
|
const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
|
1730
2104
|
const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
|
1731
2105
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2106
|
+
const { id } = reactRouterDom.useParams();
|
1732
2107
|
const { formatMessage } = reactIntl.useIntl();
|
1733
2108
|
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
1734
2109
|
const { publish } = useDocumentActions();
|
@@ -1808,7 +2183,9 @@ const PublishAction$1 = ({
|
|
1808
2183
|
const performPublish = async () => {
|
1809
2184
|
setSubmitting(true);
|
1810
2185
|
try {
|
1811
|
-
const { errors } = await validate(
|
2186
|
+
const { errors } = await validate(true, {
|
2187
|
+
status: "published"
|
2188
|
+
});
|
1812
2189
|
if (errors) {
|
1813
2190
|
toggleNotification({
|
1814
2191
|
type: "danger",
|
@@ -1826,13 +2203,15 @@ const PublishAction$1 = ({
|
|
1826
2203
|
documentId,
|
1827
2204
|
params
|
1828
2205
|
},
|
1829
|
-
formValues
|
2206
|
+
transformData(formValues)
|
1830
2207
|
);
|
1831
2208
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
2209
|
+
if (id === "create") {
|
2210
|
+
navigate({
|
2211
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
2212
|
+
search: rawQuery
|
2213
|
+
});
|
2214
|
+
}
|
1836
2215
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1837
2216
|
setErrors(formatValidationErrors(res.error));
|
1838
2217
|
}
|
@@ -1916,24 +2295,24 @@ const UpdateAction = ({
|
|
1916
2295
|
*/
|
1917
2296
|
disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
|
1918
2297
|
label: formatMessage({
|
1919
|
-
id: "
|
2298
|
+
id: "global.save",
|
1920
2299
|
defaultMessage: "Save"
|
1921
2300
|
}),
|
1922
2301
|
onClick: async () => {
|
1923
2302
|
setSubmitting(true);
|
1924
2303
|
try {
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
})
|
1935
|
-
|
1936
|
-
|
2304
|
+
const { errors } = await validate(true, {
|
2305
|
+
status: "draft"
|
2306
|
+
});
|
2307
|
+
if (errors) {
|
2308
|
+
toggleNotification({
|
2309
|
+
type: "danger",
|
2310
|
+
message: formatMessage({
|
2311
|
+
id: "content-manager.validation.error",
|
2312
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
2313
|
+
})
|
2314
|
+
});
|
2315
|
+
return;
|
1937
2316
|
}
|
1938
2317
|
if (isCloning) {
|
1939
2318
|
const res = await clone(
|
@@ -1942,7 +2321,7 @@ const UpdateAction = ({
|
|
1942
2321
|
documentId: cloneMatch.params.origin,
|
1943
2322
|
params
|
1944
2323
|
},
|
1945
|
-
document
|
2324
|
+
transformData(document)
|
1946
2325
|
);
|
1947
2326
|
if ("data" in res) {
|
1948
2327
|
navigate(
|
@@ -1963,7 +2342,7 @@ const UpdateAction = ({
|
|
1963
2342
|
documentId,
|
1964
2343
|
params
|
1965
2344
|
},
|
1966
|
-
document
|
2345
|
+
transformData(document)
|
1967
2346
|
);
|
1968
2347
|
if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1969
2348
|
setErrors(formatValidationErrors(res.error));
|
@@ -1976,7 +2355,7 @@ const UpdateAction = ({
|
|
1976
2355
|
model,
|
1977
2356
|
params
|
1978
2357
|
},
|
1979
|
-
document
|
2358
|
+
transformData(document)
|
1980
2359
|
);
|
1981
2360
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1982
2361
|
navigate(
|
@@ -2181,7 +2560,7 @@ const RelativeTime = React__namespace.forwardRef(
|
|
2181
2560
|
});
|
2182
2561
|
const unit = intervals.find((intervalUnit) => {
|
2183
2562
|
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
|
2184
|
-
});
|
2563
|
+
}) ?? "seconds";
|
2185
2564
|
const relativeTime = dateFns.isPast(timestamp) ? -interval[unit] : interval[unit];
|
2186
2565
|
const customInterval = customIntervals.find(
|
2187
2566
|
(custom) => interval[custom.unit] < custom.threshold
|
@@ -2215,19 +2594,29 @@ const getDisplayName = ({
|
|
2215
2594
|
return email ?? "";
|
2216
2595
|
};
|
2217
2596
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2218
|
-
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2597
|
+
const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
|
2219
2598
|
const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
|
2220
|
-
|
2599
|
+
const { formatMessage } = reactIntl.useIntl();
|
2600
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
|
2601
|
+
id: `content-manager.containers.List.${status}`,
|
2602
|
+
defaultMessage: capitalise(status)
|
2603
|
+
}) }) });
|
2221
2604
|
};
|
2222
2605
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
2223
2606
|
const { formatMessage } = reactIntl.useIntl();
|
2224
2607
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2608
|
+
const params = reactRouterDom.useParams();
|
2225
2609
|
const title = isCreating ? formatMessage({
|
2226
2610
|
id: "content-manager.containers.edit.title.new",
|
2227
2611
|
defaultMessage: "Create an entry"
|
2228
2612
|
}) : documentTitle;
|
2229
2613
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2230
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
2614
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2615
|
+
strapiAdmin.BackButton,
|
2616
|
+
{
|
2617
|
+
fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
|
2618
|
+
}
|
2619
|
+
),
|
2231
2620
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2232
2621
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
|
2233
2622
|
/* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
|
@@ -2315,12 +2704,12 @@ const Information = ({ activeTab }) => {
|
|
2315
2704
|
isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
|
2316
2705
|
label: formatMessage({
|
2317
2706
|
id: "content-manager.containers.edit.information.last-published.label",
|
2318
|
-
defaultMessage: "
|
2707
|
+
defaultMessage: "Published"
|
2319
2708
|
}),
|
2320
2709
|
value: formatMessage(
|
2321
2710
|
{
|
2322
2711
|
id: "content-manager.containers.edit.information.last-published.value",
|
2323
|
-
defaultMessage: `
|
2712
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2324
2713
|
},
|
2325
2714
|
{
|
2326
2715
|
time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
|
@@ -2333,12 +2722,12 @@ const Information = ({ activeTab }) => {
|
|
2333
2722
|
isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
|
2334
2723
|
label: formatMessage({
|
2335
2724
|
id: "content-manager.containers.edit.information.last-draft.label",
|
2336
|
-
defaultMessage: "
|
2725
|
+
defaultMessage: "Updated"
|
2337
2726
|
}),
|
2338
2727
|
value: formatMessage(
|
2339
2728
|
{
|
2340
2729
|
id: "content-manager.containers.edit.information.last-draft.value",
|
2341
|
-
defaultMessage: `
|
2730
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2342
2731
|
},
|
2343
2732
|
{
|
2344
2733
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2356,12 +2745,12 @@ const Information = ({ activeTab }) => {
|
|
2356
2745
|
isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
|
2357
2746
|
label: formatMessage({
|
2358
2747
|
id: "content-manager.containers.edit.information.document.label",
|
2359
|
-
defaultMessage: "
|
2748
|
+
defaultMessage: "Created"
|
2360
2749
|
}),
|
2361
2750
|
value: formatMessage(
|
2362
2751
|
{
|
2363
2752
|
id: "content-manager.containers.edit.information.document.value",
|
2364
|
-
defaultMessage: `
|
2753
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2365
2754
|
},
|
2366
2755
|
{
|
2367
2756
|
time: /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -2419,10 +2808,9 @@ const HeaderActions = ({ actions: actions2 }) => {
|
|
2419
2808
|
designSystem.SingleSelect,
|
2420
2809
|
{
|
2421
2810
|
size: "S",
|
2422
|
-
disabled: action.disabled,
|
2423
|
-
"aria-label": action.label,
|
2424
2811
|
onChange: action.onSelect,
|
2425
|
-
|
2812
|
+
"aria-label": action.label,
|
2813
|
+
...action,
|
2426
2814
|
children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
|
2427
2815
|
},
|
2428
2816
|
action.id
|
@@ -2464,512 +2852,213 @@ const HeaderActionDialog = ({
|
|
2464
2852
|
if (onCancel) {
|
2465
2853
|
await onCancel();
|
2466
2854
|
}
|
2467
|
-
onClose();
|
2468
|
-
};
|
2469
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2470
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
2471
|
-
typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content
|
2472
|
-
] }) });
|
2473
|
-
};
|
2474
|
-
const ConfigureTheViewAction = ({ collectionType, model }) => {
|
2475
|
-
const navigate = reactRouterDom.useNavigate();
|
2476
|
-
const { formatMessage } = reactIntl.useIntl();
|
2477
|
-
return {
|
2478
|
-
label: formatMessage({
|
2479
|
-
id: "app.links.configure-view",
|
2480
|
-
defaultMessage: "Configure the view"
|
2481
|
-
}),
|
2482
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ListPlus, {}),
|
2483
|
-
onClick: () => {
|
2484
|
-
navigate(`../${collectionType}/${model}/configurations/edit`);
|
2485
|
-
},
|
2486
|
-
position: "header"
|
2487
|
-
};
|
2488
|
-
};
|
2489
|
-
ConfigureTheViewAction.type = "configure-the-view";
|
2490
|
-
const EditTheModelAction = ({ model }) => {
|
2491
|
-
const navigate = reactRouterDom.useNavigate();
|
2492
|
-
const { formatMessage } = reactIntl.useIntl();
|
2493
|
-
return {
|
2494
|
-
label: formatMessage({
|
2495
|
-
id: "content-manager.link-to-ctb",
|
2496
|
-
defaultMessage: "Edit the model"
|
2497
|
-
}),
|
2498
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {}),
|
2499
|
-
onClick: () => {
|
2500
|
-
navigate(`/plugins/content-type-builder/content-types/${model}`);
|
2501
|
-
},
|
2502
|
-
position: "header"
|
2503
|
-
};
|
2504
|
-
};
|
2505
|
-
EditTheModelAction.type = "edit-the-model";
|
2506
|
-
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2507
|
-
const navigate = reactRouterDom.useNavigate();
|
2508
|
-
const { formatMessage } = reactIntl.useIntl();
|
2509
|
-
const listViewPathMatch = reactRouterDom.useMatch(LIST_PATH);
|
2510
|
-
const canDelete = useDocumentRBAC("DeleteAction", (state) => state.canDelete);
|
2511
|
-
const { delete: deleteAction } = useDocumentActions();
|
2512
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
2513
|
-
const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
|
2514
|
-
return {
|
2515
|
-
disabled: !canDelete || !document,
|
2516
|
-
label: formatMessage({
|
2517
|
-
id: "content-manager.actions.delete.label",
|
2518
|
-
defaultMessage: "Delete document"
|
2519
|
-
}),
|
2520
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
|
2521
|
-
dialog: {
|
2522
|
-
type: "dialog",
|
2523
|
-
title: formatMessage({
|
2524
|
-
id: "app.components.ConfirmDialog.title",
|
2525
|
-
defaultMessage: "Confirmation"
|
2526
|
-
}),
|
2527
|
-
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
|
2528
|
-
/* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
2529
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
2530
|
-
id: "content-manager.actions.delete.dialog.body",
|
2531
|
-
defaultMessage: "Are you sure?"
|
2532
|
-
}) })
|
2533
|
-
] }),
|
2534
|
-
onConfirm: async () => {
|
2535
|
-
if (!listViewPathMatch) {
|
2536
|
-
setSubmitting(true);
|
2537
|
-
}
|
2538
|
-
try {
|
2539
|
-
if (!documentId && collectionType !== SINGLE_TYPES) {
|
2540
|
-
console.error(
|
2541
|
-
"You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue."
|
2542
|
-
);
|
2543
|
-
toggleNotification({
|
2544
|
-
message: formatMessage({
|
2545
|
-
id: "content-manager.actions.delete.error",
|
2546
|
-
defaultMessage: "An error occurred while trying to delete the document."
|
2547
|
-
}),
|
2548
|
-
type: "danger"
|
2549
|
-
});
|
2550
|
-
return;
|
2551
|
-
}
|
2552
|
-
const res = await deleteAction({
|
2553
|
-
documentId,
|
2554
|
-
model,
|
2555
|
-
collectionType,
|
2556
|
-
params: {
|
2557
|
-
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"
|
2855
|
+
onClose();
|
2856
|
+
};
|
2857
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
2858
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
|
2859
|
+
typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content
|
2860
|
+
] }) });
|
2695
2861
|
};
|
2696
|
-
const
|
2697
|
-
|
2698
|
-
|
2699
|
-
|
2700
|
-
|
2701
|
-
|
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" }]
|
2862
|
+
const ConfigureTheViewAction = ({ collectionType, model }) => {
|
2863
|
+
const navigate = reactRouterDom.useNavigate();
|
2864
|
+
const { formatMessage } = reactIntl.useIntl();
|
2865
|
+
return {
|
2866
|
+
label: formatMessage({
|
2867
|
+
id: "app.links.configure-view",
|
2868
|
+
defaultMessage: "Configure the view"
|
2713
2869
|
}),
|
2714
|
-
|
2715
|
-
|
2716
|
-
|
2717
|
-
|
2718
|
-
|
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;
|
2870
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ListPlus, {}),
|
2871
|
+
onClick: () => {
|
2872
|
+
navigate(`../${collectionType}/${model}/configurations/edit`);
|
2873
|
+
},
|
2874
|
+
position: "header"
|
2875
|
+
};
|
2741
2876
|
};
|
2742
|
-
|
2743
|
-
|
2744
|
-
|
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
|
-
);
|
2877
|
+
ConfigureTheViewAction.type = "configure-the-view";
|
2878
|
+
const EditTheModelAction = ({ model }) => {
|
2879
|
+
const navigate = reactRouterDom.useNavigate();
|
2880
|
+
const { formatMessage } = reactIntl.useIntl();
|
2750
2881
|
return {
|
2751
|
-
|
2752
|
-
|
2882
|
+
label: formatMessage({
|
2883
|
+
id: "content-manager.link-to-ctb",
|
2884
|
+
defaultMessage: "Edit the model"
|
2885
|
+
}),
|
2886
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {}),
|
2887
|
+
onClick: () => {
|
2888
|
+
navigate(`/plugins/content-type-builder/content-types/${model}`);
|
2889
|
+
},
|
2890
|
+
position: "header"
|
2753
2891
|
};
|
2754
2892
|
};
|
2755
|
-
|
2756
|
-
|
2757
|
-
|
2758
|
-
|
2759
|
-
|
2760
|
-
|
2761
|
-
|
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);
|
2893
|
+
EditTheModelAction.type = "edit-the-model";
|
2894
|
+
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2895
|
+
const navigate = reactRouterDom.useNavigate();
|
2896
|
+
const { formatMessage } = reactIntl.useIntl();
|
2897
|
+
const listViewPathMatch = reactRouterDom.useMatch(LIST_PATH);
|
2898
|
+
const canDelete = useDocumentRBAC("DeleteAction", (state) => state.canDelete);
|
2899
|
+
const { delete: deleteAction } = useDocumentActions();
|
2769
2900
|
const { toggleNotification } = strapiAdmin.useNotification();
|
2770
|
-
const
|
2771
|
-
const
|
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
|
-
);
|
2901
|
+
const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
|
2902
|
+
const isLocalized = document?.locale != null;
|
2812
2903
|
return {
|
2813
|
-
|
2814
|
-
|
2815
|
-
|
2816
|
-
|
2817
|
-
|
2818
|
-
}
|
2819
|
-
|
2820
|
-
|
2821
|
-
|
2822
|
-
|
2823
|
-
|
2824
|
-
|
2825
|
-
|
2826
|
-
|
2827
|
-
})
|
2828
|
-
|
2829
|
-
|
2830
|
-
|
2831
|
-
|
2832
|
-
|
2833
|
-
|
2834
|
-
|
2835
|
-
|
2836
|
-
|
2837
|
-
|
2838
|
-
|
2839
|
-
|
2840
|
-
|
2841
|
-
|
2842
|
-
|
2843
|
-
|
2844
|
-
|
2845
|
-
|
2846
|
-
|
2847
|
-
|
2848
|
-
|
2849
|
-
|
2850
|
-
|
2851
|
-
|
2852
|
-
|
2853
|
-
|
2854
|
-
|
2855
|
-
|
2856
|
-
|
2857
|
-
|
2858
|
-
|
2859
|
-
|
2904
|
+
disabled: !canDelete || !document,
|
2905
|
+
label: formatMessage(
|
2906
|
+
{
|
2907
|
+
id: "content-manager.actions.delete.label",
|
2908
|
+
defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
|
2909
|
+
},
|
2910
|
+
{ isLocalized }
|
2911
|
+
),
|
2912
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
|
2913
|
+
dialog: {
|
2914
|
+
type: "dialog",
|
2915
|
+
title: formatMessage({
|
2916
|
+
id: "app.components.ConfirmDialog.title",
|
2917
|
+
defaultMessage: "Confirmation"
|
2918
|
+
}),
|
2919
|
+
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
|
2920
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
2921
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
2922
|
+
id: "content-manager.actions.delete.dialog.body",
|
2923
|
+
defaultMessage: "Are you sure?"
|
2924
|
+
}) })
|
2925
|
+
] }),
|
2926
|
+
onConfirm: async () => {
|
2927
|
+
if (!listViewPathMatch) {
|
2928
|
+
setSubmitting(true);
|
2929
|
+
}
|
2930
|
+
try {
|
2931
|
+
if (!documentId && collectionType !== SINGLE_TYPES) {
|
2932
|
+
console.error(
|
2933
|
+
"You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue."
|
2934
|
+
);
|
2935
|
+
toggleNotification({
|
2936
|
+
message: formatMessage({
|
2937
|
+
id: "content-manager.actions.delete.error",
|
2938
|
+
defaultMessage: "An error occurred while trying to delete the document."
|
2939
|
+
}),
|
2940
|
+
type: "danger"
|
2941
|
+
});
|
2942
|
+
return;
|
2943
|
+
}
|
2944
|
+
const res = await deleteAction({
|
2945
|
+
documentId,
|
2946
|
+
model,
|
2947
|
+
collectionType,
|
2948
|
+
params: {
|
2949
|
+
locale: "*"
|
2950
|
+
}
|
2951
|
+
});
|
2952
|
+
if (!("error" in res)) {
|
2953
|
+
navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
|
2954
|
+
}
|
2955
|
+
} finally {
|
2956
|
+
if (!listViewPathMatch) {
|
2957
|
+
setSubmitting(false);
|
2958
|
+
}
|
2860
2959
|
}
|
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
|
2960
|
+
}
|
2882
2961
|
},
|
2883
|
-
|
2884
|
-
|
2885
|
-
...schema?.pluginOptions,
|
2886
|
-
...data.contentType.options
|
2887
|
-
}
|
2962
|
+
variant: "danger",
|
2963
|
+
position: ["header", "table-row"]
|
2888
2964
|
};
|
2889
2965
|
};
|
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
|
-
);
|
2966
|
+
DeleteAction$1.type = "delete";
|
2967
|
+
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2968
|
+
const Panels = () => {
|
2969
|
+
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2970
|
+
const [
|
2971
|
+
{
|
2972
|
+
query: { status }
|
2973
|
+
}
|
2974
|
+
] = strapiAdmin.useQueryParams({
|
2975
|
+
status: "draft"
|
2976
|
+
});
|
2977
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
2978
|
+
const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
|
2979
|
+
const props = {
|
2980
|
+
activeTab: status,
|
2981
|
+
model,
|
2982
|
+
documentId: id,
|
2983
|
+
document: isCloning ? void 0 : document,
|
2984
|
+
meta: isCloning ? void 0 : meta,
|
2985
|
+
collectionType
|
2986
|
+
};
|
2987
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
2988
|
+
strapiAdmin.DescriptionComponentRenderer,
|
2989
|
+
{
|
2990
|
+
props,
|
2991
|
+
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
2992
|
+
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
|
2993
|
+
}
|
2994
|
+
) });
|
2919
2995
|
};
|
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
|
-
);
|
2996
|
+
const ActionsPanel = () => {
|
2997
|
+
const { formatMessage } = reactIntl.useIntl();
|
2941
2998
|
return {
|
2942
|
-
|
2943
|
-
|
2944
|
-
|
2945
|
-
|
2946
|
-
|
2947
|
-
...schema?.pluginOptions,
|
2948
|
-
...data.contentType.options
|
2949
|
-
}
|
2999
|
+
title: formatMessage({
|
3000
|
+
id: "content-manager.containers.edit.panels.default.title",
|
3001
|
+
defaultMessage: "Entry"
|
3002
|
+
}),
|
3003
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
|
2950
3004
|
};
|
2951
3005
|
};
|
2952
|
-
|
2953
|
-
|
2954
|
-
|
2955
|
-
|
2956
|
-
|
3006
|
+
ActionsPanel.type = "actions";
|
3007
|
+
const ActionsPanelContent = () => {
|
3008
|
+
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
3009
|
+
const [
|
3010
|
+
{
|
3011
|
+
query: { status = "draft" }
|
2957
3012
|
}
|
2958
|
-
|
2959
|
-
|
2960
|
-
|
2961
|
-
|
2962
|
-
|
2963
|
-
|
2964
|
-
|
2965
|
-
|
2966
|
-
|
2967
|
-
|
2968
|
-
|
2969
|
-
|
2970
|
-
|
2971
|
-
|
3013
|
+
] = strapiAdmin.useQueryParams();
|
3014
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
3015
|
+
const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
|
3016
|
+
const props = {
|
3017
|
+
activeTab: status,
|
3018
|
+
model,
|
3019
|
+
documentId: id,
|
3020
|
+
document: isCloning ? void 0 : document,
|
3021
|
+
meta: isCloning ? void 0 : meta,
|
3022
|
+
collectionType
|
3023
|
+
};
|
3024
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
|
3025
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3026
|
+
strapiAdmin.DescriptionComponentRenderer,
|
3027
|
+
{
|
3028
|
+
props,
|
3029
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3030
|
+
children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
|
3031
|
+
}
|
3032
|
+
),
|
3033
|
+
/* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
3034
|
+
] });
|
2972
3035
|
};
|
3036
|
+
const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
3037
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
3038
|
+
designSystem.Flex,
|
3039
|
+
{
|
3040
|
+
ref,
|
3041
|
+
tag: "aside",
|
3042
|
+
"aria-labelledby": "additional-information",
|
3043
|
+
background: "neutral0",
|
3044
|
+
borderColor: "neutral150",
|
3045
|
+
hasRadius: true,
|
3046
|
+
paddingBottom: 4,
|
3047
|
+
paddingLeft: 4,
|
3048
|
+
paddingRight: 4,
|
3049
|
+
paddingTop: 4,
|
3050
|
+
shadow: "tableShadow",
|
3051
|
+
gap: 3,
|
3052
|
+
direction: "column",
|
3053
|
+
justifyContent: "stretch",
|
3054
|
+
alignItems: "flex-start",
|
3055
|
+
children: [
|
3056
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
|
3057
|
+
children
|
3058
|
+
]
|
3059
|
+
}
|
3060
|
+
);
|
3061
|
+
});
|
2973
3062
|
const ConfirmBulkActionDialog = ({
|
2974
3063
|
onToggleDialog,
|
2975
3064
|
isOpen = false,
|
@@ -3214,18 +3303,10 @@ const SelectedEntriesTableContent = ({
|
|
3214
3303
|
search: row.locale && `?plugins[i18n][locale]=${row.locale}`
|
3215
3304
|
},
|
3216
3305
|
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
|
-
),
|
3306
|
+
label: formatMessage({
|
3307
|
+
id: "content-manager.bulk-publish.edit",
|
3308
|
+
defaultMessage: "Edit"
|
3309
|
+
}),
|
3229
3310
|
target: "_blank",
|
3230
3311
|
marginLeft: "auto",
|
3231
3312
|
variant: "ghost",
|
@@ -3869,17 +3950,27 @@ const HistoryAction = ({ model, document }) => {
|
|
3869
3950
|
const { formatMessage } = reactIntl.useIntl();
|
3870
3951
|
const [{ query }] = strapiAdmin.useQueryParams();
|
3871
3952
|
const navigate = reactRouterDom.useNavigate();
|
3953
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
3954
|
+
const { pathname } = reactRouterDom.useLocation();
|
3872
3955
|
const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
|
3873
3956
|
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
3874
3957
|
return null;
|
3875
3958
|
}
|
3959
|
+
const handleOnClick = () => {
|
3960
|
+
const destination = { pathname: "history", search: pluginsQueryParams };
|
3961
|
+
trackUsage("willNavigate", {
|
3962
|
+
from: pathname,
|
3963
|
+
to: `${pathname}/${destination.pathname}`
|
3964
|
+
});
|
3965
|
+
navigate(destination);
|
3966
|
+
};
|
3876
3967
|
return {
|
3877
3968
|
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
|
3878
3969
|
label: formatMessage({
|
3879
3970
|
id: "content-manager.history.document-action",
|
3880
3971
|
defaultMessage: "Content History"
|
3881
3972
|
}),
|
3882
|
-
onClick:
|
3973
|
+
onClick: handleOnClick,
|
3883
3974
|
disabled: (
|
3884
3975
|
/**
|
3885
3976
|
* The user is creating a new document.
|
@@ -3947,6 +4038,72 @@ const { setInitialData } = actions;
|
|
3947
4038
|
const reducer = toolkit.combineReducers({
|
3948
4039
|
app: reducer$1
|
3949
4040
|
});
|
4041
|
+
const previewApi = contentManagerApi.injectEndpoints({
|
4042
|
+
endpoints: (builder) => ({
|
4043
|
+
getPreviewUrl: builder.query({
|
4044
|
+
query({ query, params }) {
|
4045
|
+
return {
|
4046
|
+
url: `/content-manager/preview/url/${params.contentType}`,
|
4047
|
+
method: "GET",
|
4048
|
+
config: {
|
4049
|
+
params: query
|
4050
|
+
}
|
4051
|
+
};
|
4052
|
+
}
|
4053
|
+
})
|
4054
|
+
})
|
4055
|
+
});
|
4056
|
+
const { useGetPreviewUrlQuery } = previewApi;
|
4057
|
+
const PreviewSidePanel = ({ model, documentId, document }) => {
|
4058
|
+
const { formatMessage } = reactIntl.useIntl();
|
4059
|
+
const { trackUsage } = strapiAdmin.useTracking();
|
4060
|
+
const { pathname } = reactRouterDom.useLocation();
|
4061
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
4062
|
+
const { data, error } = useGetPreviewUrlQuery({
|
4063
|
+
params: {
|
4064
|
+
contentType: model
|
4065
|
+
},
|
4066
|
+
query: {
|
4067
|
+
documentId,
|
4068
|
+
locale: document?.locale,
|
4069
|
+
status: document?.status
|
4070
|
+
}
|
4071
|
+
});
|
4072
|
+
if (!data?.data?.url || error) {
|
4073
|
+
return null;
|
4074
|
+
}
|
4075
|
+
const trackNavigation = () => {
|
4076
|
+
const destinationPathname = pathname.replace(/\/$/, "") + "/preview";
|
4077
|
+
trackUsage("willNavigate", { from: pathname, to: destinationPathname });
|
4078
|
+
};
|
4079
|
+
return {
|
4080
|
+
title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
|
4081
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(
|
4082
|
+
designSystem.Button,
|
4083
|
+
{
|
4084
|
+
variant: "tertiary",
|
4085
|
+
tag: reactRouterDom.Link,
|
4086
|
+
to: { pathname: "preview", search: qs.stringify(query, { encode: false }) },
|
4087
|
+
onClick: trackNavigation,
|
4088
|
+
flex: "auto",
|
4089
|
+
children: formatMessage({
|
4090
|
+
id: "content-manager.preview.panel.button",
|
4091
|
+
defaultMessage: "Open preview"
|
4092
|
+
})
|
4093
|
+
}
|
4094
|
+
) })
|
4095
|
+
};
|
4096
|
+
};
|
4097
|
+
const FEATURE_ID = "preview";
|
4098
|
+
const previewAdmin = {
|
4099
|
+
bootstrap(app) {
|
4100
|
+
if (!window.strapi.future.isEnabled(FEATURE_ID)) {
|
4101
|
+
return;
|
4102
|
+
}
|
4103
|
+
const contentManagerPluginApis = app.getPlugin("content-manager").apis;
|
4104
|
+
contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
|
4105
|
+
}
|
4106
|
+
};
|
3950
4107
|
const index = {
|
3951
4108
|
register(app) {
|
3952
4109
|
const cm = new ContentManagerPlugin();
|
@@ -3966,7 +4123,7 @@ const index = {
|
|
3966
4123
|
app.router.addRoute({
|
3967
4124
|
path: "content-manager/*",
|
3968
4125
|
lazy: async () => {
|
3969
|
-
const { Layout } = await Promise.resolve().then(() => require("./layout-
|
4126
|
+
const { Layout } = await Promise.resolve().then(() => require("./layout-BEuNwv-F.js"));
|
3970
4127
|
return {
|
3971
4128
|
Component: Layout
|
3972
4129
|
};
|
@@ -3979,11 +4136,14 @@ const index = {
|
|
3979
4136
|
if (typeof historyAdmin.bootstrap === "function") {
|
3980
4137
|
historyAdmin.bootstrap(app);
|
3981
4138
|
}
|
4139
|
+
if (typeof previewAdmin.bootstrap === "function") {
|
4140
|
+
previewAdmin.bootstrap(app);
|
4141
|
+
}
|
3982
4142
|
},
|
3983
4143
|
async registerTrads({ locales }) {
|
3984
4144
|
const importedTrads = await Promise.all(
|
3985
4145
|
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-
|
4146
|
+
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-Ic0kXjxB.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`).then(({ default: data }) => {
|
3987
4147
|
return {
|
3988
4148
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3989
4149
|
locale
|
@@ -4029,6 +4189,7 @@ exports.getMainField = getMainField;
|
|
4029
4189
|
exports.getTranslation = getTranslation;
|
4030
4190
|
exports.index = index;
|
4031
4191
|
exports.setInitialData = setInitialData;
|
4192
|
+
exports.useContentManagerContext = useContentManagerContext;
|
4032
4193
|
exports.useContentTypeSchema = useContentTypeSchema;
|
4033
4194
|
exports.useDoc = useDoc;
|
4034
4195
|
exports.useDocLayout = useDocLayout;
|
@@ -4040,5 +4201,6 @@ exports.useGetAllContentTypeSettingsQuery = useGetAllContentTypeSettingsQuery;
|
|
4040
4201
|
exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
4041
4202
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
4042
4203
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
4204
|
+
exports.useGetPreviewUrlQuery = useGetPreviewUrlQuery;
|
4043
4205
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
4044
|
-
//# sourceMappingURL=index-
|
4206
|
+
//# sourceMappingURL=index-T-aWjbj2.js.map
|