@strapi/content-manager 0.0.0-experimental.da85533897155e719d784f0271223c866d2f69ab → 0.0.0-experimental.dd1d47ef78ef6cfec4ed62576108500bd9f13740
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-9lRmRdIr.mjs → ComponentConfigurationPage-BpM_Hc7r.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-9lRmRdIr.mjs.map → ComponentConfigurationPage-BpM_Hc7r.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-DyDkPajU.js → ComponentConfigurationPage-CL9CAMaL.js} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-DyDkPajU.js.map → ComponentConfigurationPage-CL9CAMaL.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-DValmA0m.js → EditConfigurationPage-ILWo0h1e.js} +4 -4
- package/dist/_chunks/{EditConfigurationPage-DValmA0m.js.map → EditConfigurationPage-ILWo0h1e.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-Bk893vVY.mjs → EditConfigurationPage-_prbqpTM.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-Bk893vVY.mjs.map → EditConfigurationPage-_prbqpTM.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-Dk7Eaft4.js → EditViewPage-BqZvBN4s.js} +15 -5
- package/dist/_chunks/EditViewPage-BqZvBN4s.js.map +1 -0
- package/dist/_chunks/{EditViewPage-DiNFdFqP.mjs → EditViewPage-DAtscabN.mjs} +15 -5
- package/dist/_chunks/EditViewPage-DAtscabN.mjs.map +1 -0
- package/dist/_chunks/{Field-DH2OaqUP.js → Field-CcoQiiz1.js} +78 -44
- package/dist/_chunks/Field-CcoQiiz1.js.map +1 -0
- package/dist/_chunks/{Field-Dv_HTFTa.mjs → Field-D-mgn1tH.mjs} +74 -40
- package/dist/_chunks/Field-D-mgn1tH.mjs.map +1 -0
- package/dist/_chunks/{Form-Dy6P4HgH.mjs → Form-BxyeWiXW.mjs} +16 -8
- package/dist/_chunks/Form-BxyeWiXW.mjs.map +1 -0
- package/dist/_chunks/{Form-B_dUDizM.js → Form-CmLbZDfi.js} +16 -8
- package/dist/_chunks/Form-CmLbZDfi.js.map +1 -0
- package/dist/_chunks/{History-DrwsD1Vc.mjs → History-BOhLaq_g.mjs} +38 -41
- package/dist/_chunks/History-BOhLaq_g.mjs.map +1 -0
- package/dist/_chunks/{History-BT4w83Oa.js → History-uECUbCZB.js} +37 -40
- package/dist/_chunks/History-uECUbCZB.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-BxIP0jRy.mjs → ListConfigurationPage-D0vQez6F.mjs} +3 -3
- package/dist/_chunks/{ListConfigurationPage-BxIP0jRy.mjs.map → ListConfigurationPage-D0vQez6F.mjs.map} +1 -1
- package/dist/_chunks/{ListConfigurationPage-CuYrMcW3.js → ListConfigurationPage-D_bBSFNW.js} +3 -3
- package/dist/_chunks/{ListConfigurationPage-CuYrMcW3.js.map → ListConfigurationPage-D_bBSFNW.js.map} +1 -1
- package/dist/_chunks/{ListViewPage-BvpwNur7.js → ListViewPage-BkZ83b1A.js} +40 -17
- package/dist/_chunks/ListViewPage-BkZ83b1A.js.map +1 -0
- package/dist/_chunks/{ListViewPage-5a1vw-OK.mjs → ListViewPage-ns-bmy5C.mjs} +36 -13
- package/dist/_chunks/ListViewPage-ns-bmy5C.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-Bm6tRcd3.mjs → NoContentTypePage-BA5ZKMDR.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-Bm6tRcd3.mjs.map → NoContentTypePage-BA5ZKMDR.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-UqEiWKkM.js → NoContentTypePage-C1439s4s.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-UqEiWKkM.js.map → NoContentTypePage-C1439s4s.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-BHPqn_tQ.mjs → NoPermissionsPage-B0GdMw1Q.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-BHPqn_tQ.mjs.map → NoPermissionsPage-B0GdMw1Q.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-C_vGRo8Q.js → NoPermissionsPage-CPGwsVfb.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-C_vGRo8Q.js.map → NoPermissionsPage-CPGwsVfb.js.map} +1 -1
- package/dist/_chunks/{Relations-C7fPyh5P.mjs → Relations-BIGPMSW4.mjs} +72 -36
- package/dist/_chunks/Relations-BIGPMSW4.mjs.map +1 -0
- package/dist/_chunks/{Relations-CznVF6LS.js → Relations-d-8Uef_-.js} +71 -35
- package/dist/_chunks/Relations-d-8Uef_-.js.map +1 -0
- package/dist/_chunks/{en-otD_UBJi.js → en-Bdpa50w3.js} +17 -12
- package/dist/_chunks/{en-otD_UBJi.js.map → en-Bdpa50w3.js.map} +1 -1
- package/dist/_chunks/{en-CbaIuYoB.mjs → en-CZw4xdPY.mjs} +17 -12
- package/dist/_chunks/{en-CbaIuYoB.mjs.map → en-CZw4xdPY.mjs.map} +1 -1
- package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
- package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
- package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
- package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
- package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
- package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
- package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
- package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
- package/dist/_chunks/{index-BJ6uTqLL.mjs → index-3_WeHXYp.mjs} +890 -685
- package/dist/_chunks/index-3_WeHXYp.mjs.map +1 -0
- package/dist/_chunks/{index-D9UmmBcM.js → index-BgaeYWIy.js} +887 -681
- package/dist/_chunks/index-BgaeYWIy.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-kfu5Wtix.js → layout-ByFyQRDH.js} +5 -4
- package/dist/_chunks/{layout-kfu5Wtix.js.map → layout-ByFyQRDH.js.map} +1 -1
- package/dist/_chunks/{layout-uomiIGbG.mjs → layout-CrTxOnCy.mjs} +5 -4
- package/dist/_chunks/{layout-uomiIGbG.mjs.map → layout-CrTxOnCy.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-DiDufGSA.mjs → relations-BlpLgngh.mjs} +3 -7
- package/dist/_chunks/relations-BlpLgngh.mjs.map +1 -0
- package/dist/_chunks/{relations-DKENrxko.js → relations-C5RSW926.js} +3 -7
- package/dist/_chunks/relations-C5RSW926.js.map +1 -0
- package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
- package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +3 -2
- 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/components/Header.d.ts +11 -11
- 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/services/preview.d.ts +3 -0
- package/dist/admin/src/services/documents.d.ts +3 -1
- package/dist/server/index.js +378 -162
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +378 -162
- 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 +15 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts +30 -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 +18 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -0
- package/dist/server/src/routes/index.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/collection-types.d.ts +3 -1
- package/dist/shared/contracts/collection-types.d.ts.map +1 -1
- package/dist/shared/contracts/index.d.ts +1 -0
- package/dist/shared/contracts/index.d.ts.map +1 -1
- package/dist/shared/contracts/preview.d.ts +27 -0
- package/dist/shared/contracts/preview.d.ts.map +1 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +4 -0
- package/dist/shared/index.mjs.map +1 -1
- package/package.json +13 -13
- package/dist/_chunks/EditViewPage-DiNFdFqP.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-Dk7Eaft4.js.map +0 -1
- package/dist/_chunks/Field-DH2OaqUP.js.map +0 -1
- package/dist/_chunks/Field-Dv_HTFTa.mjs.map +0 -1
- package/dist/_chunks/Form-B_dUDizM.js.map +0 -1
- package/dist/_chunks/Form-Dy6P4HgH.mjs.map +0 -1
- package/dist/_chunks/History-BT4w83Oa.js.map +0 -1
- package/dist/_chunks/History-DrwsD1Vc.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-5a1vw-OK.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-BvpwNur7.js.map +0 -1
- package/dist/_chunks/Relations-C7fPyh5P.mjs.map +0 -1
- package/dist/_chunks/Relations-CznVF6LS.js.map +0 -1
- package/dist/_chunks/index-BJ6uTqLL.mjs.map +0 -1
- package/dist/_chunks/index-D9UmmBcM.js.map +0 -1
- package/dist/_chunks/relations-DKENrxko.js.map +0 -1
- package/dist/_chunks/relations-DiDufGSA.mjs.map +0 -1
- package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
- package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
- package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
- package/strapi-server.js +0 -3
@@ -1,16 +1,17 @@
|
|
1
|
-
import {
|
1
|
+
import { More, Cross, WarningCircle, ListPlus, Pencil, Trash, Check, CrossCircle, CheckCircle, ArrowsCounterClockwise, ChevronRight, Duplicate, ClockCounterClockwise, Link as Link$1, Feather } from "@strapi/icons";
|
2
2
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
3
|
-
import { useStrapiApp, createContext, useAuth, useRBAC, Page, adminApi, translatedErrors, useNotification, useAPIErrorHandler, getYupValidationErrors,
|
3
|
+
import { useStrapiApp, createContext, useQueryParams, useAuth, useRBAC, Page, adminApi, translatedErrors, useNotification, useAPIErrorHandler, getYupValidationErrors, useForm, useTracking, useGuidedTour, BackButton, DescriptionComponentRenderer, useTable, Table, useClipboard } from "@strapi/admin/strapi-admin";
|
4
4
|
import * as React from "react";
|
5
5
|
import { lazy } from "react";
|
6
|
-
import { Button, Menu, VisuallyHidden, Flex, Typography, Dialog, Modal, Radio, Status, Box, SingleSelect, SingleSelectOption,
|
6
|
+
import { Button, Menu, VisuallyHidden, Flex, Typography, Dialog, Modal, Radio, Status, Box, SingleSelect, SingleSelectOption, IconButton, Loader, Tooltip, LinkButton } from "@strapi/design-system";
|
7
|
+
import mapValues from "lodash/fp/mapValues";
|
7
8
|
import { useIntl } from "react-intl";
|
8
9
|
import { useParams, useNavigate, Navigate, useMatch, useLocation, Link, NavLink } from "react-router-dom";
|
9
|
-
import { styled } from "styled-components";
|
10
10
|
import * as yup from "yup";
|
11
11
|
import { ValidationError } from "yup";
|
12
12
|
import pipe from "lodash/fp/pipe";
|
13
13
|
import { intervalToDuration, isPast } from "date-fns";
|
14
|
+
import { styled } from "styled-components";
|
14
15
|
import { stringify } from "qs";
|
15
16
|
import { createSlice, combineReducers } from "@reduxjs/toolkit";
|
16
17
|
const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
@@ -100,6 +101,7 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
100
101
|
if (!slug) {
|
101
102
|
throw new Error("Cannot find the slug param in the URL");
|
102
103
|
}
|
104
|
+
const [{ rawQuery }] = useQueryParams();
|
103
105
|
const userPermissions = useAuth("DocumentRBAC", (state) => state.permissions);
|
104
106
|
const contentTypePermissions = React.useMemo(() => {
|
105
107
|
const contentTypePermissions2 = userPermissions.filter(
|
@@ -110,7 +112,14 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
110
112
|
return { ...acc, [action]: [permission] };
|
111
113
|
}, {});
|
112
114
|
}, [slug, userPermissions]);
|
113
|
-
const { isLoading, allowedActions } = useRBAC(
|
115
|
+
const { isLoading, allowedActions } = useRBAC(
|
116
|
+
contentTypePermissions,
|
117
|
+
permissions ?? void 0,
|
118
|
+
// TODO: useRBAC context should be typed and built differently
|
119
|
+
// We are passing raw query as context to the hook so that it can
|
120
|
+
// rely on the locale provided from DocumentRBAC for its permission calculations.
|
121
|
+
rawQuery
|
122
|
+
);
|
114
123
|
const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
|
115
124
|
const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
|
116
125
|
const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
|
@@ -461,6 +470,24 @@ const buildValidParams = (query) => {
|
|
461
470
|
const isBaseQueryError = (error) => {
|
462
471
|
return error.name !== void 0;
|
463
472
|
};
|
473
|
+
const arrayValidator = (attribute, options) => ({
|
474
|
+
message: translatedErrors.required,
|
475
|
+
test(value) {
|
476
|
+
if (options.status === "draft") {
|
477
|
+
return true;
|
478
|
+
}
|
479
|
+
if (!attribute.required) {
|
480
|
+
return true;
|
481
|
+
}
|
482
|
+
if (!value) {
|
483
|
+
return false;
|
484
|
+
}
|
485
|
+
if (Array.isArray(value) && value.length === 0) {
|
486
|
+
return false;
|
487
|
+
}
|
488
|
+
return true;
|
489
|
+
}
|
490
|
+
});
|
464
491
|
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
465
492
|
const createModelSchema = (attributes2) => yup.object().shape(
|
466
493
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
@@ -468,6 +495,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
468
495
|
return acc;
|
469
496
|
}
|
470
497
|
const validations = [
|
498
|
+
addNullableValidation,
|
471
499
|
addRequiredValidation,
|
472
500
|
addMinLengthValidation,
|
473
501
|
addMaxLengthValidation,
|
@@ -484,12 +512,12 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
484
512
|
...acc,
|
485
513
|
[name]: transformSchema(
|
486
514
|
yup.array().of(createModelSchema(attributes3).nullable(false))
|
487
|
-
)
|
515
|
+
).test(arrayValidator(attribute, options))
|
488
516
|
};
|
489
517
|
} else {
|
490
518
|
return {
|
491
519
|
...acc,
|
492
|
-
[name]: transformSchema(createModelSchema(attributes3))
|
520
|
+
[name]: transformSchema(createModelSchema(attributes3).nullable())
|
493
521
|
};
|
494
522
|
}
|
495
523
|
}
|
@@ -511,7 +539,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
511
539
|
}
|
512
540
|
)
|
513
541
|
)
|
514
|
-
)
|
542
|
+
).test(arrayValidator(attribute, options))
|
515
543
|
};
|
516
544
|
case "relation":
|
517
545
|
return {
|
@@ -523,7 +551,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
|
|
523
551
|
} else if (Array.isArray(value)) {
|
524
552
|
return yup.array().of(
|
525
553
|
yup.object().shape({
|
526
|
-
id: yup.
|
554
|
+
id: yup.number().required()
|
527
555
|
})
|
528
556
|
);
|
529
557
|
} else if (typeof value === "object") {
|
@@ -609,17 +637,17 @@ const nullableSchema = (schema) => {
|
|
609
637
|
schema
|
610
638
|
);
|
611
639
|
};
|
640
|
+
const addNullableValidation = () => (schema) => {
|
641
|
+
return nullableSchema(schema);
|
642
|
+
};
|
612
643
|
const addRequiredValidation = (attribute, options) => (schema) => {
|
613
|
-
if (options.status === "draft") {
|
614
|
-
return
|
615
|
-
}
|
616
|
-
if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
|
617
|
-
return schema.min(1, translatedErrors.required);
|
644
|
+
if (options.status === "draft" || !attribute.required) {
|
645
|
+
return schema;
|
618
646
|
}
|
619
|
-
if (attribute.required &&
|
647
|
+
if (attribute.required && "required" in schema) {
|
620
648
|
return schema.required(translatedErrors.required);
|
621
649
|
}
|
622
|
-
return
|
650
|
+
return schema;
|
623
651
|
};
|
624
652
|
const addMinLengthValidation = (attribute, options) => (schema) => {
|
625
653
|
if (options.status === "draft") {
|
@@ -647,31 +675,12 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
647
675
|
return schema;
|
648
676
|
};
|
649
677
|
const addMinValidation = (attribute, options) => (schema) => {
|
650
|
-
if ("
|
678
|
+
if (options.status === "draft") {
|
679
|
+
return schema;
|
680
|
+
}
|
681
|
+
if ("min" in attribute && "min" in schema) {
|
651
682
|
const min = toInteger(attribute.min);
|
652
|
-
if (
|
653
|
-
if (options.status !== "draft" && !attribute.required && "test" in schema && min) {
|
654
|
-
return schema.test(
|
655
|
-
"custom-min",
|
656
|
-
{
|
657
|
-
...translatedErrors.min,
|
658
|
-
values: {
|
659
|
-
min: attribute.min
|
660
|
-
}
|
661
|
-
},
|
662
|
-
(value) => {
|
663
|
-
if (!value) {
|
664
|
-
return true;
|
665
|
-
}
|
666
|
-
if (Array.isArray(value) && value.length === 0) {
|
667
|
-
return true;
|
668
|
-
}
|
669
|
-
return value.length >= min;
|
670
|
-
}
|
671
|
-
);
|
672
|
-
}
|
673
|
-
}
|
674
|
-
if ("min" in schema && min) {
|
683
|
+
if (min) {
|
675
684
|
return schema.min(min, {
|
676
685
|
...translatedErrors.min,
|
677
686
|
values: {
|
@@ -789,19 +798,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
|
|
789
798
|
}, {});
|
790
799
|
return componentsByKey;
|
791
800
|
};
|
792
|
-
const
|
801
|
+
const HOOKS = {
|
802
|
+
/**
|
803
|
+
* Hook that allows to mutate the displayed headers of the list view table
|
804
|
+
* @constant
|
805
|
+
* @type {string}
|
806
|
+
*/
|
807
|
+
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
808
|
+
/**
|
809
|
+
* Hook that allows to mutate the CM's collection types links pre-set filters
|
810
|
+
* @constant
|
811
|
+
* @type {string}
|
812
|
+
*/
|
813
|
+
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
814
|
+
/**
|
815
|
+
* Hook that allows to mutate the CM's edit view layout
|
816
|
+
* @constant
|
817
|
+
* @type {string}
|
818
|
+
*/
|
819
|
+
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
820
|
+
/**
|
821
|
+
* Hook that allows to mutate the CM's single types links pre-set filters
|
822
|
+
* @constant
|
823
|
+
* @type {string}
|
824
|
+
*/
|
825
|
+
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
826
|
+
};
|
827
|
+
const contentTypesApi = contentManagerApi.injectEndpoints({
|
828
|
+
endpoints: (builder) => ({
|
829
|
+
getContentTypeConfiguration: builder.query({
|
830
|
+
query: (uid) => ({
|
831
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
832
|
+
method: "GET"
|
833
|
+
}),
|
834
|
+
transformResponse: (response) => response.data,
|
835
|
+
providesTags: (_result, _error, uid) => [
|
836
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
837
|
+
{ type: "ContentTypeSettings", id: "LIST" }
|
838
|
+
]
|
839
|
+
}),
|
840
|
+
getAllContentTypeSettings: builder.query({
|
841
|
+
query: () => "/content-manager/content-types-settings",
|
842
|
+
transformResponse: (response) => response.data,
|
843
|
+
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
844
|
+
}),
|
845
|
+
updateContentTypeConfiguration: builder.mutation({
|
846
|
+
query: ({ uid, ...body }) => ({
|
847
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
848
|
+
method: "PUT",
|
849
|
+
data: body
|
850
|
+
}),
|
851
|
+
transformResponse: (response) => response.data,
|
852
|
+
invalidatesTags: (_result, _error, { uid }) => [
|
853
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
854
|
+
{ type: "ContentTypeSettings", id: "LIST" },
|
855
|
+
// Is this necessary?
|
856
|
+
{ type: "InitialData" }
|
857
|
+
]
|
858
|
+
})
|
859
|
+
})
|
860
|
+
});
|
861
|
+
const {
|
862
|
+
useGetContentTypeConfigurationQuery,
|
863
|
+
useGetAllContentTypeSettingsQuery,
|
864
|
+
useUpdateContentTypeConfigurationMutation
|
865
|
+
} = contentTypesApi;
|
866
|
+
const checkIfAttributeIsDisplayable = (attribute) => {
|
867
|
+
const { type } = attribute;
|
868
|
+
if (type === "relation") {
|
869
|
+
return !attribute.relation.toLowerCase().includes("morph");
|
870
|
+
}
|
871
|
+
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
872
|
+
};
|
873
|
+
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
874
|
+
if (!mainFieldName) {
|
875
|
+
return void 0;
|
876
|
+
}
|
877
|
+
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
878
|
+
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
879
|
+
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
880
|
+
);
|
881
|
+
return {
|
882
|
+
name: mainFieldName,
|
883
|
+
type: mainFieldType ?? "string"
|
884
|
+
};
|
885
|
+
};
|
886
|
+
const DEFAULT_SETTINGS = {
|
887
|
+
bulkable: false,
|
888
|
+
filterable: false,
|
889
|
+
searchable: false,
|
890
|
+
pagination: false,
|
891
|
+
defaultSortBy: "",
|
892
|
+
defaultSortOrder: "asc",
|
893
|
+
mainField: "id",
|
894
|
+
pageSize: 10
|
895
|
+
};
|
896
|
+
const useDocumentLayout = (model) => {
|
897
|
+
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
898
|
+
const [{ query }] = useQueryParams();
|
899
|
+
const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
793
900
|
const { toggleNotification } = useNotification();
|
794
901
|
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
902
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
795
903
|
const {
|
796
|
-
|
797
|
-
isLoading:
|
798
|
-
|
799
|
-
|
800
|
-
} =
|
801
|
-
|
802
|
-
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
803
|
-
});
|
804
|
-
const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
|
904
|
+
data,
|
905
|
+
isLoading: isLoadingConfigs,
|
906
|
+
error,
|
907
|
+
isFetching: isFetchingConfigs
|
908
|
+
} = useGetContentTypeConfigurationQuery(model);
|
909
|
+
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
805
910
|
React.useEffect(() => {
|
806
911
|
if (error) {
|
807
912
|
toggleNotification({
|
@@ -809,98 +914,353 @@ const useDocument = (args, opts) => {
|
|
809
914
|
message: formatAPIError(error)
|
810
915
|
});
|
811
916
|
}
|
812
|
-
}, [
|
813
|
-
const
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
(document) => {
|
821
|
-
if (!validationSchema) {
|
822
|
-
throw new Error(
|
823
|
-
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
824
|
-
);
|
825
|
-
}
|
826
|
-
try {
|
827
|
-
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
828
|
-
return null;
|
829
|
-
} catch (error2) {
|
830
|
-
if (error2 instanceof ValidationError) {
|
831
|
-
return getYupValidationErrors(error2);
|
832
|
-
}
|
833
|
-
throw error2;
|
834
|
-
}
|
917
|
+
}, [error, formatAPIError, toggleNotification]);
|
918
|
+
const editLayout = React.useMemo(
|
919
|
+
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
920
|
+
layout: [],
|
921
|
+
components: {},
|
922
|
+
metadatas: {},
|
923
|
+
options: {},
|
924
|
+
settings: DEFAULT_SETTINGS
|
835
925
|
},
|
836
|
-
[
|
926
|
+
[data, isLoading, schemas, schema, components]
|
927
|
+
);
|
928
|
+
const listLayout = React.useMemo(() => {
|
929
|
+
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
930
|
+
layout: [],
|
931
|
+
metadatas: {},
|
932
|
+
options: {},
|
933
|
+
settings: DEFAULT_SETTINGS
|
934
|
+
};
|
935
|
+
}, [data, isLoading, schemas, schema, components]);
|
936
|
+
const { layout: edit } = React.useMemo(
|
937
|
+
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
938
|
+
layout: editLayout,
|
939
|
+
query
|
940
|
+
}),
|
941
|
+
[editLayout, query, runHookWaterfall]
|
837
942
|
);
|
838
|
-
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
839
943
|
return {
|
840
|
-
|
841
|
-
document: data?.data,
|
842
|
-
meta: data?.meta,
|
944
|
+
error,
|
843
945
|
isLoading,
|
844
|
-
|
845
|
-
|
846
|
-
};
|
847
|
-
};
|
848
|
-
const useDoc = () => {
|
849
|
-
const { id, slug, collectionType, origin } = useParams();
|
850
|
-
const [{ query }] = useQueryParams();
|
851
|
-
const params = React.useMemo(() => buildValidParams(query), [query]);
|
852
|
-
if (!collectionType) {
|
853
|
-
throw new Error("Could not find collectionType in url params");
|
854
|
-
}
|
855
|
-
if (!slug) {
|
856
|
-
throw new Error("Could not find model in url params");
|
857
|
-
}
|
858
|
-
return {
|
859
|
-
collectionType,
|
860
|
-
model: slug,
|
861
|
-
id: origin || id === "create" ? void 0 : id,
|
862
|
-
...useDocument(
|
863
|
-
{ documentId: origin || id, model: slug, collectionType, params },
|
864
|
-
{
|
865
|
-
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
866
|
-
}
|
867
|
-
)
|
946
|
+
edit,
|
947
|
+
list: listLayout
|
868
948
|
};
|
869
949
|
};
|
870
|
-
const
|
871
|
-
|
872
|
-
|
873
|
-
}
|
874
|
-
return Object.keys(trad).reduce((acc, current) => {
|
875
|
-
acc[`${pluginId}.${current}`] = trad[current];
|
876
|
-
return acc;
|
877
|
-
}, {});
|
878
|
-
};
|
879
|
-
const getTranslation = (id) => `content-manager.${id}`;
|
880
|
-
const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
881
|
-
id: "notification.error",
|
882
|
-
defaultMessage: "An error occurred, please try again"
|
950
|
+
const useDocLayout = () => {
|
951
|
+
const { model } = useDoc();
|
952
|
+
return useDocumentLayout(model);
|
883
953
|
};
|
884
|
-
const
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
const
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
954
|
+
const formatEditLayout = (data, {
|
955
|
+
schemas,
|
956
|
+
schema,
|
957
|
+
components
|
958
|
+
}) => {
|
959
|
+
let currentPanelIndex = 0;
|
960
|
+
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
961
|
+
data.contentType.layouts.edit,
|
962
|
+
schema?.attributes,
|
963
|
+
data.contentType.metadatas,
|
964
|
+
{ configurations: data.components, schemas: components },
|
965
|
+
schemas
|
966
|
+
).reduce((panels, row) => {
|
967
|
+
if (row.some((field) => field.type === "dynamiczone")) {
|
968
|
+
panels.push([row]);
|
969
|
+
currentPanelIndex += 2;
|
970
|
+
} else {
|
971
|
+
if (!panels[currentPanelIndex]) {
|
972
|
+
panels.push([row]);
|
973
|
+
} else {
|
974
|
+
panels[currentPanelIndex].push(row);
|
975
|
+
}
|
976
|
+
}
|
977
|
+
return panels;
|
978
|
+
}, []);
|
979
|
+
const componentEditAttributes = Object.entries(data.components).reduce(
|
980
|
+
(acc, [uid, configuration]) => {
|
981
|
+
acc[uid] = {
|
982
|
+
layout: convertEditLayoutToFieldLayouts(
|
983
|
+
configuration.layouts.edit,
|
984
|
+
components[uid].attributes,
|
985
|
+
configuration.metadatas,
|
986
|
+
{ configurations: data.components, schemas: components }
|
987
|
+
),
|
988
|
+
settings: {
|
989
|
+
...configuration.settings,
|
990
|
+
icon: components[uid].info.icon,
|
991
|
+
displayName: components[uid].info.displayName
|
992
|
+
}
|
993
|
+
};
|
994
|
+
return acc;
|
995
|
+
},
|
996
|
+
{}
|
997
|
+
);
|
998
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
999
|
+
(acc, [attribute, metadata]) => {
|
1000
|
+
return {
|
1001
|
+
...acc,
|
1002
|
+
[attribute]: metadata.edit
|
1003
|
+
};
|
1004
|
+
},
|
1005
|
+
{}
|
1006
|
+
);
|
1007
|
+
return {
|
1008
|
+
layout: panelledEditAttributes,
|
1009
|
+
components: componentEditAttributes,
|
1010
|
+
metadatas: editMetadatas,
|
1011
|
+
settings: {
|
1012
|
+
...data.contentType.settings,
|
1013
|
+
displayName: schema?.info.displayName
|
1014
|
+
},
|
1015
|
+
options: {
|
1016
|
+
...schema?.options,
|
1017
|
+
...schema?.pluginOptions,
|
1018
|
+
...data.contentType.options
|
1019
|
+
}
|
1020
|
+
};
|
1021
|
+
};
|
1022
|
+
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
1023
|
+
return rows.map(
|
1024
|
+
(row) => row.map((field) => {
|
1025
|
+
const attribute = attributes[field.name];
|
1026
|
+
if (!attribute) {
|
1027
|
+
return null;
|
1028
|
+
}
|
1029
|
+
const { edit: metadata } = metadatas[field.name];
|
1030
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1031
|
+
return {
|
1032
|
+
attribute,
|
1033
|
+
disabled: !metadata.editable,
|
1034
|
+
hint: metadata.description,
|
1035
|
+
label: metadata.label ?? "",
|
1036
|
+
name: field.name,
|
1037
|
+
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
1038
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1039
|
+
schemas,
|
1040
|
+
components: components?.schemas ?? {}
|
1041
|
+
}),
|
1042
|
+
placeholder: metadata.placeholder ?? "",
|
1043
|
+
required: attribute.required ?? false,
|
1044
|
+
size: field.size,
|
1045
|
+
unique: "unique" in attribute ? attribute.unique : false,
|
1046
|
+
visible: metadata.visible ?? true,
|
1047
|
+
type: attribute.type
|
1048
|
+
};
|
1049
|
+
}).filter((field) => field !== null)
|
1050
|
+
);
|
1051
|
+
};
|
1052
|
+
const formatListLayout = (data, {
|
1053
|
+
schemas,
|
1054
|
+
schema,
|
1055
|
+
components
|
1056
|
+
}) => {
|
1057
|
+
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1058
|
+
(acc, [attribute, metadata]) => {
|
1059
|
+
return {
|
1060
|
+
...acc,
|
1061
|
+
[attribute]: metadata.list
|
1062
|
+
};
|
1063
|
+
},
|
1064
|
+
{}
|
1065
|
+
);
|
1066
|
+
const listAttributes = convertListLayoutToFieldLayouts(
|
1067
|
+
data.contentType.layouts.list,
|
1068
|
+
schema?.attributes,
|
1069
|
+
listMetadatas,
|
1070
|
+
{ configurations: data.components, schemas: components },
|
1071
|
+
schemas
|
1072
|
+
);
|
1073
|
+
return {
|
1074
|
+
layout: listAttributes,
|
1075
|
+
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
1076
|
+
metadatas: listMetadatas,
|
1077
|
+
options: {
|
1078
|
+
...schema?.options,
|
1079
|
+
...schema?.pluginOptions,
|
1080
|
+
...data.contentType.options
|
1081
|
+
}
|
1082
|
+
};
|
1083
|
+
};
|
1084
|
+
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
1085
|
+
return columns.map((name) => {
|
1086
|
+
const attribute = attributes[name];
|
1087
|
+
if (!attribute) {
|
1088
|
+
return null;
|
1089
|
+
}
|
1090
|
+
const metadata = metadatas[name];
|
1091
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1092
|
+
return {
|
1093
|
+
attribute,
|
1094
|
+
label: metadata.label ?? "",
|
1095
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1096
|
+
schemas,
|
1097
|
+
components: components?.schemas ?? {}
|
1098
|
+
}),
|
1099
|
+
name,
|
1100
|
+
searchable: metadata.searchable ?? true,
|
1101
|
+
sortable: metadata.sortable ?? true
|
1102
|
+
};
|
1103
|
+
}).filter((field) => field !== null);
|
1104
|
+
};
|
1105
|
+
const useDocument = (args, opts) => {
|
1106
|
+
const { toggleNotification } = useNotification();
|
1107
|
+
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
1108
|
+
const {
|
1109
|
+
currentData: data,
|
1110
|
+
isLoading: isLoadingDocument,
|
1111
|
+
isFetching: isFetchingDocument,
|
1112
|
+
error
|
1113
|
+
} = useGetDocumentQuery(args, {
|
1114
|
+
...opts,
|
1115
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
1116
|
+
});
|
1117
|
+
const {
|
1118
|
+
components,
|
1119
|
+
schema,
|
1120
|
+
schemas,
|
1121
|
+
isLoading: isLoadingSchema
|
1122
|
+
} = useContentTypeSchema(args.model);
|
1123
|
+
React.useEffect(() => {
|
1124
|
+
if (error) {
|
1125
|
+
toggleNotification({
|
1126
|
+
type: "danger",
|
1127
|
+
message: formatAPIError(error)
|
1128
|
+
});
|
1129
|
+
}
|
1130
|
+
}, [toggleNotification, error, formatAPIError, args.collectionType]);
|
1131
|
+
const validationSchema = React.useMemo(() => {
|
1132
|
+
if (!schema) {
|
1133
|
+
return null;
|
1134
|
+
}
|
1135
|
+
return createYupSchema(schema.attributes, components);
|
1136
|
+
}, [schema, components]);
|
1137
|
+
const validate = React.useCallback(
|
1138
|
+
(document) => {
|
1139
|
+
if (!validationSchema) {
|
1140
|
+
throw new Error(
|
1141
|
+
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
1142
|
+
);
|
1143
|
+
}
|
1144
|
+
try {
|
1145
|
+
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
1146
|
+
return null;
|
1147
|
+
} catch (error2) {
|
1148
|
+
if (error2 instanceof ValidationError) {
|
1149
|
+
return getYupValidationErrors(error2);
|
1150
|
+
}
|
1151
|
+
throw error2;
|
1152
|
+
}
|
1153
|
+
},
|
1154
|
+
[validationSchema]
|
1155
|
+
);
|
1156
|
+
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
1157
|
+
const hasError = !!error;
|
1158
|
+
return {
|
1159
|
+
components,
|
1160
|
+
document: data?.data,
|
1161
|
+
meta: data?.meta,
|
1162
|
+
isLoading,
|
1163
|
+
hasError,
|
1164
|
+
schema,
|
1165
|
+
schemas,
|
1166
|
+
validate
|
1167
|
+
};
|
1168
|
+
};
|
1169
|
+
const useDoc = () => {
|
1170
|
+
const { id, slug, collectionType, origin } = useParams();
|
1171
|
+
const [{ query }] = useQueryParams();
|
1172
|
+
const params = React.useMemo(() => buildValidParams(query), [query]);
|
1173
|
+
if (!collectionType) {
|
1174
|
+
throw new Error("Could not find collectionType in url params");
|
1175
|
+
}
|
1176
|
+
if (!slug) {
|
1177
|
+
throw new Error("Could not find model in url params");
|
1178
|
+
}
|
1179
|
+
const document = useDocument(
|
1180
|
+
{ documentId: origin || id, model: slug, collectionType, params },
|
1181
|
+
{
|
1182
|
+
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
1183
|
+
}
|
1184
|
+
);
|
1185
|
+
const returnId = origin || id === "create" ? void 0 : id;
|
1186
|
+
return {
|
1187
|
+
collectionType,
|
1188
|
+
model: slug,
|
1189
|
+
id: returnId,
|
1190
|
+
...document
|
1191
|
+
};
|
1192
|
+
};
|
1193
|
+
const useContentManagerContext = () => {
|
1194
|
+
const {
|
1195
|
+
collectionType,
|
1196
|
+
model,
|
1197
|
+
id,
|
1198
|
+
components,
|
1199
|
+
isLoading: isLoadingDoc,
|
1200
|
+
schema,
|
1201
|
+
schemas
|
1202
|
+
} = useDoc();
|
1203
|
+
const layout = useDocumentLayout(model);
|
1204
|
+
const form = useForm("useContentManagerContext", (state) => state);
|
1205
|
+
const isSingleType = collectionType === SINGLE_TYPES;
|
1206
|
+
const slug = model;
|
1207
|
+
const isCreatingEntry = id === "create";
|
1208
|
+
useContentTypeSchema();
|
1209
|
+
const isLoading = isLoadingDoc || layout.isLoading;
|
1210
|
+
const error = layout.error;
|
1211
|
+
return {
|
1212
|
+
error,
|
1213
|
+
isLoading,
|
1214
|
+
// Base metadata
|
1215
|
+
model,
|
1216
|
+
collectionType,
|
1217
|
+
id,
|
1218
|
+
slug,
|
1219
|
+
isCreatingEntry,
|
1220
|
+
isSingleType,
|
1221
|
+
hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
|
1222
|
+
// All schema infos
|
1223
|
+
components,
|
1224
|
+
contentType: schema,
|
1225
|
+
contentTypes: schemas,
|
1226
|
+
// Form state
|
1227
|
+
form,
|
1228
|
+
// layout infos
|
1229
|
+
layout
|
1230
|
+
};
|
1231
|
+
};
|
1232
|
+
const prefixPluginTranslations = (trad, pluginId) => {
|
1233
|
+
return Object.keys(trad).reduce((acc, current) => {
|
1234
|
+
acc[`${pluginId}.${current}`] = trad[current];
|
1235
|
+
return acc;
|
1236
|
+
}, {});
|
1237
|
+
};
|
1238
|
+
const getTranslation = (id) => `content-manager.${id}`;
|
1239
|
+
const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
1240
|
+
id: "notification.error",
|
1241
|
+
defaultMessage: "An error occurred, please try again"
|
1242
|
+
};
|
1243
|
+
const useDocumentActions = () => {
|
1244
|
+
const { toggleNotification } = useNotification();
|
1245
|
+
const { formatMessage } = useIntl();
|
1246
|
+
const { trackUsage } = useTracking();
|
1247
|
+
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
1248
|
+
const navigate = useNavigate();
|
1249
|
+
const setCurrentStep = useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
|
1250
|
+
const [deleteDocument] = useDeleteDocumentMutation();
|
1251
|
+
const _delete = React.useCallback(
|
1252
|
+
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
1253
|
+
try {
|
1254
|
+
trackUsage("willDeleteEntry", trackerProperty);
|
1255
|
+
const res = await deleteDocument({
|
1256
|
+
collectionType,
|
1257
|
+
model,
|
1258
|
+
documentId,
|
1259
|
+
params
|
1260
|
+
});
|
1261
|
+
if ("error" in res) {
|
1262
|
+
toggleNotification({
|
1263
|
+
type: "danger",
|
904
1264
|
message: formatAPIError(res.error)
|
905
1265
|
});
|
906
1266
|
return { error: res.error };
|
@@ -1201,6 +1561,7 @@ const useDocumentActions = () => {
|
|
1201
1561
|
defaultMessage: "Saved document"
|
1202
1562
|
})
|
1203
1563
|
});
|
1564
|
+
setCurrentStep("contentManager.success");
|
1204
1565
|
return res.data;
|
1205
1566
|
} catch (err) {
|
1206
1567
|
toggleNotification({
|
@@ -1303,7 +1664,7 @@ const useDocumentActions = () => {
|
|
1303
1664
|
};
|
1304
1665
|
};
|
1305
1666
|
const ProtectedHistoryPage = lazy(
|
1306
|
-
() => import("./History-
|
1667
|
+
() => import("./History-BOhLaq_g.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1307
1668
|
);
|
1308
1669
|
const routes$1 = [
|
1309
1670
|
{
|
@@ -1316,31 +1677,31 @@ const routes$1 = [
|
|
1316
1677
|
}
|
1317
1678
|
];
|
1318
1679
|
const ProtectedEditViewPage = lazy(
|
1319
|
-
() => import("./EditViewPage-
|
1680
|
+
() => import("./EditViewPage-DAtscabN.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1320
1681
|
);
|
1321
1682
|
const ProtectedListViewPage = lazy(
|
1322
|
-
() => import("./ListViewPage-
|
1683
|
+
() => import("./ListViewPage-ns-bmy5C.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1323
1684
|
);
|
1324
1685
|
const ProtectedListConfiguration = lazy(
|
1325
|
-
() => import("./ListConfigurationPage-
|
1686
|
+
() => import("./ListConfigurationPage-D0vQez6F.mjs").then((mod) => ({
|
1326
1687
|
default: mod.ProtectedListConfiguration
|
1327
1688
|
}))
|
1328
1689
|
);
|
1329
1690
|
const ProtectedEditConfigurationPage = lazy(
|
1330
|
-
() => import("./EditConfigurationPage-
|
1691
|
+
() => import("./EditConfigurationPage-_prbqpTM.mjs").then((mod) => ({
|
1331
1692
|
default: mod.ProtectedEditConfigurationPage
|
1332
1693
|
}))
|
1333
1694
|
);
|
1334
1695
|
const ProtectedComponentConfigurationPage = lazy(
|
1335
|
-
() => import("./ComponentConfigurationPage-
|
1696
|
+
() => import("./ComponentConfigurationPage-BpM_Hc7r.mjs").then((mod) => ({
|
1336
1697
|
default: mod.ProtectedComponentConfigurationPage
|
1337
1698
|
}))
|
1338
1699
|
);
|
1339
1700
|
const NoPermissions = lazy(
|
1340
|
-
() => import("./NoPermissionsPage-
|
1701
|
+
() => import("./NoPermissionsPage-B0GdMw1Q.mjs").then((mod) => ({ default: mod.NoPermissions }))
|
1341
1702
|
);
|
1342
1703
|
const NoContentType = lazy(
|
1343
|
-
() => import("./NoContentTypePage-
|
1704
|
+
() => import("./NoContentTypePage-BA5ZKMDR.mjs").then((mod) => ({ default: mod.NoContentType }))
|
1344
1705
|
);
|
1345
1706
|
const CollectionTypePages = () => {
|
1346
1707
|
const { collectionType } = useParams();
|
@@ -1539,7 +1900,7 @@ const DocumentActionsMenu = ({
|
|
1539
1900
|
]
|
1540
1901
|
}
|
1541
1902
|
),
|
1542
|
-
/* @__PURE__ */ jsxs(Menu.Content, {
|
1903
|
+
/* @__PURE__ */ jsxs(Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
|
1543
1904
|
actions2.map((action) => {
|
1544
1905
|
return /* @__PURE__ */ jsx(
|
1545
1906
|
Menu.Item,
|
@@ -1663,11 +2024,11 @@ const DocumentActionConfirmDialog = ({
|
|
1663
2024
|
/* @__PURE__ */ jsx(Dialog.Header, { children: title }),
|
1664
2025
|
/* @__PURE__ */ jsx(Dialog.Body, { children: content }),
|
1665
2026
|
/* @__PURE__ */ jsxs(Dialog.Footer, { children: [
|
1666
|
-
/* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: formatMessage({
|
2027
|
+
/* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
|
1667
2028
|
id: "app.components.Button.cancel",
|
1668
2029
|
defaultMessage: "Cancel"
|
1669
2030
|
}) }) }),
|
1670
|
-
/* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, children: formatMessage({
|
2031
|
+
/* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
|
1671
2032
|
id: "app.components.Button.confirm",
|
1672
2033
|
defaultMessage: "Confirm"
|
1673
2034
|
}) })
|
@@ -1694,6 +2055,18 @@ const DocumentActionModal = ({
|
|
1694
2055
|
typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
|
1695
2056
|
] }) });
|
1696
2057
|
};
|
2058
|
+
const transformData = (data) => {
|
2059
|
+
if (Array.isArray(data)) {
|
2060
|
+
return data.map(transformData);
|
2061
|
+
}
|
2062
|
+
if (typeof data === "object" && data !== null) {
|
2063
|
+
if ("apiData" in data) {
|
2064
|
+
return data.apiData;
|
2065
|
+
}
|
2066
|
+
return mapValues(transformData)(data);
|
2067
|
+
}
|
2068
|
+
return data;
|
2069
|
+
};
|
1697
2070
|
const PublishAction$1 = ({
|
1698
2071
|
activeTab,
|
1699
2072
|
documentId,
|
@@ -1761,24 +2134,25 @@ const PublishAction$1 = ({
|
|
1761
2134
|
}
|
1762
2135
|
}, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
|
1763
2136
|
React.useEffect(() => {
|
1764
|
-
if (documentId
|
1765
|
-
|
1766
|
-
const { data, error } = await countDraftRelations({
|
1767
|
-
collectionType,
|
1768
|
-
model,
|
1769
|
-
documentId,
|
1770
|
-
params
|
1771
|
-
});
|
1772
|
-
if (error) {
|
1773
|
-
throw error;
|
1774
|
-
}
|
1775
|
-
if (data) {
|
1776
|
-
setServerCountOfDraftRelations(data.data);
|
1777
|
-
}
|
1778
|
-
};
|
1779
|
-
fetchDraftRelationsCount();
|
2137
|
+
if (!document || !document.documentId || isListView) {
|
2138
|
+
return;
|
1780
2139
|
}
|
1781
|
-
|
2140
|
+
const fetchDraftRelationsCount = async () => {
|
2141
|
+
const { data, error } = await countDraftRelations({
|
2142
|
+
collectionType,
|
2143
|
+
model,
|
2144
|
+
documentId,
|
2145
|
+
params
|
2146
|
+
});
|
2147
|
+
if (error) {
|
2148
|
+
throw error;
|
2149
|
+
}
|
2150
|
+
if (data) {
|
2151
|
+
setServerCountOfDraftRelations(data.data);
|
2152
|
+
}
|
2153
|
+
};
|
2154
|
+
fetchDraftRelationsCount();
|
2155
|
+
}, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
|
1782
2156
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1783
2157
|
if (!schema?.options?.draftAndPublish) {
|
1784
2158
|
return null;
|
@@ -1786,7 +2160,9 @@ const PublishAction$1 = ({
|
|
1786
2160
|
const performPublish = async () => {
|
1787
2161
|
setSubmitting(true);
|
1788
2162
|
try {
|
1789
|
-
const { errors } = await validate(
|
2163
|
+
const { errors } = await validate(true, {
|
2164
|
+
status: "published"
|
2165
|
+
});
|
1790
2166
|
if (errors) {
|
1791
2167
|
toggleNotification({
|
1792
2168
|
type: "danger",
|
@@ -1804,7 +2180,7 @@ const PublishAction$1 = ({
|
|
1804
2180
|
documentId,
|
1805
2181
|
params
|
1806
2182
|
},
|
1807
|
-
formValues
|
2183
|
+
transformData(formValues)
|
1808
2184
|
);
|
1809
2185
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1810
2186
|
navigate({
|
@@ -1900,18 +2276,18 @@ const UpdateAction = ({
|
|
1900
2276
|
onClick: async () => {
|
1901
2277
|
setSubmitting(true);
|
1902
2278
|
try {
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
})
|
1913
|
-
|
1914
|
-
|
2279
|
+
const { errors } = await validate(true, {
|
2280
|
+
status: "draft"
|
2281
|
+
});
|
2282
|
+
if (errors) {
|
2283
|
+
toggleNotification({
|
2284
|
+
type: "danger",
|
2285
|
+
message: formatMessage({
|
2286
|
+
id: "content-manager.validation.error",
|
2287
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
2288
|
+
})
|
2289
|
+
});
|
2290
|
+
return;
|
1915
2291
|
}
|
1916
2292
|
if (isCloning) {
|
1917
2293
|
const res = await clone(
|
@@ -1920,7 +2296,7 @@ const UpdateAction = ({
|
|
1920
2296
|
documentId: cloneMatch.params.origin,
|
1921
2297
|
params
|
1922
2298
|
},
|
1923
|
-
document
|
2299
|
+
transformData(document)
|
1924
2300
|
);
|
1925
2301
|
if ("data" in res) {
|
1926
2302
|
navigate(
|
@@ -1941,7 +2317,7 @@ const UpdateAction = ({
|
|
1941
2317
|
documentId,
|
1942
2318
|
params
|
1943
2319
|
},
|
1944
|
-
document
|
2320
|
+
transformData(document)
|
1945
2321
|
);
|
1946
2322
|
if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1947
2323
|
setErrors(formatValidationErrors(res.error));
|
@@ -1954,7 +2330,7 @@ const UpdateAction = ({
|
|
1954
2330
|
model,
|
1955
2331
|
params
|
1956
2332
|
},
|
1957
|
-
document
|
2333
|
+
transformData(document)
|
1958
2334
|
);
|
1959
2335
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1960
2336
|
navigate(
|
@@ -2007,7 +2383,7 @@ const UnpublishAction$1 = ({
|
|
2007
2383
|
id: "app.utils.unpublish",
|
2008
2384
|
defaultMessage: "Unpublish"
|
2009
2385
|
}),
|
2010
|
-
icon: /* @__PURE__ */ jsx(
|
2386
|
+
icon: /* @__PURE__ */ jsx(Cross, {}),
|
2011
2387
|
onClick: async () => {
|
2012
2388
|
if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
|
2013
2389
|
if (!documentId) {
|
@@ -2119,7 +2495,7 @@ const DiscardAction = ({
|
|
2119
2495
|
id: "content-manager.actions.discard.label",
|
2120
2496
|
defaultMessage: "Discard changes"
|
2121
2497
|
}),
|
2122
|
-
icon: /* @__PURE__ */ jsx(
|
2498
|
+
icon: /* @__PURE__ */ jsx(Cross, {}),
|
2123
2499
|
position: ["panel", "table-row"],
|
2124
2500
|
variant: "danger",
|
2125
2501
|
dialog: {
|
@@ -2147,11 +2523,6 @@ const DiscardAction = ({
|
|
2147
2523
|
};
|
2148
2524
|
};
|
2149
2525
|
DiscardAction.type = "discard";
|
2150
|
-
const StyledCrossCircle = styled(CrossCircle)`
|
2151
|
-
path {
|
2152
|
-
fill: currentColor;
|
2153
|
-
}
|
2154
|
-
`;
|
2155
2526
|
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
2156
2527
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
2157
2528
|
const RelativeTime = React.forwardRef(
|
@@ -2199,7 +2570,7 @@ const getDisplayName = ({
|
|
2199
2570
|
};
|
2200
2571
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2201
2572
|
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2202
|
-
const statusVariant = status === "draft" ? "
|
2573
|
+
const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
|
2203
2574
|
return /* @__PURE__ */ jsx(Status, { ...restProps, showBullet: false, size: "S", variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: capitalise(status) }) });
|
2204
2575
|
};
|
2205
2576
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
@@ -2298,12 +2669,12 @@ const Information = ({ activeTab }) => {
|
|
2298
2669
|
isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
|
2299
2670
|
label: formatMessage({
|
2300
2671
|
id: "content-manager.containers.edit.information.last-published.label",
|
2301
|
-
defaultMessage: "
|
2672
|
+
defaultMessage: "Published"
|
2302
2673
|
}),
|
2303
2674
|
value: formatMessage(
|
2304
2675
|
{
|
2305
2676
|
id: "content-manager.containers.edit.information.last-published.value",
|
2306
|
-
defaultMessage: `
|
2677
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2307
2678
|
},
|
2308
2679
|
{
|
2309
2680
|
time: /* @__PURE__ */ jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
|
@@ -2316,12 +2687,12 @@ const Information = ({ activeTab }) => {
|
|
2316
2687
|
isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
|
2317
2688
|
label: formatMessage({
|
2318
2689
|
id: "content-manager.containers.edit.information.last-draft.label",
|
2319
|
-
defaultMessage: "
|
2690
|
+
defaultMessage: "Updated"
|
2320
2691
|
}),
|
2321
2692
|
value: formatMessage(
|
2322
2693
|
{
|
2323
2694
|
id: "content-manager.containers.edit.information.last-draft.value",
|
2324
|
-
defaultMessage: `
|
2695
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2325
2696
|
},
|
2326
2697
|
{
|
2327
2698
|
time: /* @__PURE__ */ jsx(
|
@@ -2339,12 +2710,12 @@ const Information = ({ activeTab }) => {
|
|
2339
2710
|
isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
|
2340
2711
|
label: formatMessage({
|
2341
2712
|
id: "content-manager.containers.edit.information.document.label",
|
2342
|
-
defaultMessage: "
|
2713
|
+
defaultMessage: "Created"
|
2343
2714
|
}),
|
2344
2715
|
value: formatMessage(
|
2345
2716
|
{
|
2346
2717
|
id: "content-manager.containers.edit.information.document.value",
|
2347
|
-
defaultMessage: `
|
2718
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2348
2719
|
},
|
2349
2720
|
{
|
2350
2721
|
time: /* @__PURE__ */ jsx(
|
@@ -2382,523 +2753,277 @@ const Information = ({ activeTab }) => {
|
|
2382
2753
|
);
|
2383
2754
|
};
|
2384
2755
|
const HeaderActions = ({ actions: actions2 }) => {
|
2385
|
-
|
2386
|
-
|
2756
|
+
const [dialogId, setDialogId] = React.useState(null);
|
2757
|
+
const handleClick = (action) => async (e) => {
|
2758
|
+
if (!("options" in action)) {
|
2759
|
+
const { onClick = () => false, dialog, id } = action;
|
2760
|
+
const muteDialog = await onClick(e);
|
2761
|
+
if (dialog && !muteDialog) {
|
2762
|
+
e.preventDefault();
|
2763
|
+
setDialogId(id);
|
2764
|
+
}
|
2765
|
+
}
|
2766
|
+
};
|
2767
|
+
const handleClose = () => {
|
2768
|
+
setDialogId(null);
|
2769
|
+
};
|
2770
|
+
return /* @__PURE__ */ jsx(Flex, { gap: 1, children: actions2.map((action) => {
|
2771
|
+
if (action.options) {
|
2387
2772
|
return /* @__PURE__ */ jsx(
|
2388
2773
|
SingleSelect,
|
2389
2774
|
{
|
2390
2775
|
size: "S",
|
2391
|
-
disabled: action.disabled,
|
2392
|
-
"aria-label": action.label,
|
2393
2776
|
onChange: action.onSelect,
|
2394
|
-
|
2777
|
+
"aria-label": action.label,
|
2778
|
+
...action,
|
2395
2779
|
children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsx(SingleSelectOption, { ...option, children: label }, option.value))
|
2396
2780
|
},
|
2397
2781
|
action.id
|
2398
2782
|
);
|
2399
2783
|
} else {
|
2400
|
-
|
2401
|
-
|
2402
|
-
|
2403
|
-
|
2404
|
-
|
2405
|
-
|
2406
|
-
|
2407
|
-
|
2408
|
-
|
2409
|
-
|
2410
|
-
defaultMessage: "Configure the view"
|
2411
|
-
}),
|
2412
|
-
icon: /* @__PURE__ */ jsx(ListPlus, {}),
|
2413
|
-
onClick: () => {
|
2414
|
-
navigate(`../${collectionType}/${model}/configurations/edit`);
|
2415
|
-
},
|
2416
|
-
position: "header"
|
2417
|
-
};
|
2418
|
-
};
|
2419
|
-
ConfigureTheViewAction.type = "configure-the-view";
|
2420
|
-
const EditTheModelAction = ({ model }) => {
|
2421
|
-
const navigate = useNavigate();
|
2422
|
-
const { formatMessage } = useIntl();
|
2423
|
-
return {
|
2424
|
-
label: formatMessage({
|
2425
|
-
id: "content-manager.link-to-ctb",
|
2426
|
-
defaultMessage: "Edit the model"
|
2427
|
-
}),
|
2428
|
-
icon: /* @__PURE__ */ jsx(Pencil, {}),
|
2429
|
-
onClick: () => {
|
2430
|
-
navigate(`/plugins/content-type-builder/content-types/${model}`);
|
2431
|
-
},
|
2432
|
-
position: "header"
|
2433
|
-
};
|
2434
|
-
};
|
2435
|
-
EditTheModelAction.type = "edit-the-model";
|
2436
|
-
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2437
|
-
const navigate = useNavigate();
|
2438
|
-
const { formatMessage } = useIntl();
|
2439
|
-
const listViewPathMatch = useMatch(LIST_PATH);
|
2440
|
-
const canDelete = useDocumentRBAC("DeleteAction", (state) => state.canDelete);
|
2441
|
-
const { delete: deleteAction } = useDocumentActions();
|
2442
|
-
const { toggleNotification } = useNotification();
|
2443
|
-
const setSubmitting = useForm("DeleteAction", (state) => state.setSubmitting);
|
2444
|
-
return {
|
2445
|
-
disabled: !canDelete || !document,
|
2446
|
-
label: formatMessage({
|
2447
|
-
id: "content-manager.actions.delete.label",
|
2448
|
-
defaultMessage: "Delete document"
|
2449
|
-
}),
|
2450
|
-
icon: /* @__PURE__ */ jsx(Trash, {}),
|
2451
|
-
dialog: {
|
2452
|
-
type: "dialog",
|
2453
|
-
title: formatMessage({
|
2454
|
-
id: "app.components.ConfirmDialog.title",
|
2455
|
-
defaultMessage: "Confirmation"
|
2456
|
-
}),
|
2457
|
-
content: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
|
2458
|
-
/* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
2459
|
-
/* @__PURE__ */ jsx(Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
2460
|
-
id: "content-manager.actions.delete.dialog.body",
|
2461
|
-
defaultMessage: "Are you sure?"
|
2462
|
-
}) })
|
2463
|
-
] }),
|
2464
|
-
onConfirm: async () => {
|
2465
|
-
if (!listViewPathMatch) {
|
2466
|
-
setSubmitting(true);
|
2467
|
-
}
|
2468
|
-
try {
|
2469
|
-
if (!documentId && collectionType !== SINGLE_TYPES) {
|
2470
|
-
console.error(
|
2471
|
-
"You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue."
|
2472
|
-
);
|
2473
|
-
toggleNotification({
|
2474
|
-
message: formatMessage({
|
2475
|
-
id: "content-manager.actions.delete.error",
|
2476
|
-
defaultMessage: "An error occurred while trying to delete the document."
|
2477
|
-
}),
|
2478
|
-
type: "danger"
|
2479
|
-
});
|
2480
|
-
return;
|
2481
|
-
}
|
2482
|
-
const res = await deleteAction({
|
2483
|
-
documentId,
|
2484
|
-
model,
|
2485
|
-
collectionType,
|
2486
|
-
params: {
|
2487
|
-
locale: "*"
|
2784
|
+
if (action.type === "icon") {
|
2785
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
2786
|
+
/* @__PURE__ */ jsx(
|
2787
|
+
IconButton,
|
2788
|
+
{
|
2789
|
+
disabled: action.disabled,
|
2790
|
+
label: action.label,
|
2791
|
+
size: "S",
|
2792
|
+
onClick: handleClick(action),
|
2793
|
+
children: action.icon
|
2488
2794
|
}
|
2489
|
-
|
2490
|
-
|
2491
|
-
|
2492
|
-
|
2493
|
-
|
2494
|
-
|
2495
|
-
|
2496
|
-
|
2497
|
-
|
2498
|
-
|
2499
|
-
|
2500
|
-
variant: "danger",
|
2501
|
-
position: ["header", "table-row"]
|
2502
|
-
};
|
2503
|
-
};
|
2504
|
-
DeleteAction$1.type = "delete";
|
2505
|
-
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2506
|
-
const Panels = () => {
|
2507
|
-
const isCloning = useMatch(CLONE_PATH) !== null;
|
2508
|
-
const [
|
2509
|
-
{
|
2510
|
-
query: { status }
|
2511
|
-
}
|
2512
|
-
] = useQueryParams({
|
2513
|
-
status: "draft"
|
2514
|
-
});
|
2515
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2516
|
-
const plugins = useStrapiApp("Panels", (state) => state.plugins);
|
2517
|
-
const props = {
|
2518
|
-
activeTab: status,
|
2519
|
-
model,
|
2520
|
-
documentId: id,
|
2521
|
-
document: isCloning ? void 0 : document,
|
2522
|
-
meta: isCloning ? void 0 : meta,
|
2523
|
-
collectionType
|
2524
|
-
};
|
2525
|
-
return /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsx(
|
2526
|
-
DescriptionComponentRenderer,
|
2527
|
-
{
|
2528
|
-
props,
|
2529
|
-
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
2530
|
-
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsx(Panel, { ...description, children: content }, id2))
|
2531
|
-
}
|
2532
|
-
) });
|
2533
|
-
};
|
2534
|
-
const ActionsPanel = () => {
|
2535
|
-
const { formatMessage } = useIntl();
|
2536
|
-
return {
|
2537
|
-
title: formatMessage({
|
2538
|
-
id: "content-manager.containers.edit.panels.default.title",
|
2539
|
-
defaultMessage: "Document"
|
2540
|
-
}),
|
2541
|
-
content: /* @__PURE__ */ jsx(ActionsPanelContent, {})
|
2542
|
-
};
|
2543
|
-
};
|
2544
|
-
ActionsPanel.type = "actions";
|
2545
|
-
const ActionsPanelContent = () => {
|
2546
|
-
const isCloning = useMatch(CLONE_PATH) !== null;
|
2547
|
-
const [
|
2548
|
-
{
|
2549
|
-
query: { status = "draft" }
|
2550
|
-
}
|
2551
|
-
] = useQueryParams();
|
2552
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2553
|
-
const plugins = useStrapiApp("ActionsPanel", (state) => state.plugins);
|
2554
|
-
const props = {
|
2555
|
-
activeTab: status,
|
2556
|
-
model,
|
2557
|
-
documentId: id,
|
2558
|
-
document: isCloning ? void 0 : document,
|
2559
|
-
meta: isCloning ? void 0 : meta,
|
2560
|
-
collectionType
|
2561
|
-
};
|
2562
|
-
return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, width: "100%", children: [
|
2563
|
-
/* @__PURE__ */ jsx(
|
2564
|
-
DescriptionComponentRenderer,
|
2565
|
-
{
|
2566
|
-
props,
|
2567
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2568
|
-
children: (actions2) => /* @__PURE__ */ jsx(DocumentActions, { actions: actions2 })
|
2569
|
-
}
|
2570
|
-
),
|
2571
|
-
/* @__PURE__ */ jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
2572
|
-
] });
|
2573
|
-
};
|
2574
|
-
const Panel = React.forwardRef(({ children, title }, ref) => {
|
2575
|
-
return /* @__PURE__ */ jsxs(
|
2576
|
-
Flex,
|
2577
|
-
{
|
2578
|
-
ref,
|
2579
|
-
tag: "aside",
|
2580
|
-
"aria-labelledby": "additional-information",
|
2581
|
-
background: "neutral0",
|
2582
|
-
borderColor: "neutral150",
|
2583
|
-
hasRadius: true,
|
2584
|
-
paddingBottom: 4,
|
2585
|
-
paddingLeft: 4,
|
2586
|
-
paddingRight: 4,
|
2587
|
-
paddingTop: 4,
|
2588
|
-
shadow: "tableShadow",
|
2589
|
-
gap: 3,
|
2590
|
-
direction: "column",
|
2591
|
-
justifyContent: "stretch",
|
2592
|
-
alignItems: "flex-start",
|
2593
|
-
children: [
|
2594
|
-
/* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
|
2595
|
-
children
|
2596
|
-
]
|
2795
|
+
),
|
2796
|
+
action.dialog ? /* @__PURE__ */ jsx(
|
2797
|
+
HeaderActionDialog,
|
2798
|
+
{
|
2799
|
+
...action.dialog,
|
2800
|
+
isOpen: dialogId === action.id,
|
2801
|
+
onClose: handleClose
|
2802
|
+
}
|
2803
|
+
) : null
|
2804
|
+
] }, action.id);
|
2805
|
+
}
|
2597
2806
|
}
|
2598
|
-
);
|
2599
|
-
});
|
2600
|
-
const HOOKS = {
|
2601
|
-
/**
|
2602
|
-
* Hook that allows to mutate the displayed headers of the list view table
|
2603
|
-
* @constant
|
2604
|
-
* @type {string}
|
2605
|
-
*/
|
2606
|
-
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
2607
|
-
/**
|
2608
|
-
* Hook that allows to mutate the CM's collection types links pre-set filters
|
2609
|
-
* @constant
|
2610
|
-
* @type {string}
|
2611
|
-
*/
|
2612
|
-
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
2613
|
-
/**
|
2614
|
-
* Hook that allows to mutate the CM's edit view layout
|
2615
|
-
* @constant
|
2616
|
-
* @type {string}
|
2617
|
-
*/
|
2618
|
-
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
2619
|
-
/**
|
2620
|
-
* Hook that allows to mutate the CM's single types links pre-set filters
|
2621
|
-
* @constant
|
2622
|
-
* @type {string}
|
2623
|
-
*/
|
2624
|
-
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
2807
|
+
}) });
|
2625
2808
|
};
|
2626
|
-
const
|
2627
|
-
|
2628
|
-
|
2629
|
-
|
2630
|
-
|
2631
|
-
|
2632
|
-
|
2633
|
-
|
2634
|
-
|
2635
|
-
|
2636
|
-
|
2637
|
-
|
2638
|
-
|
2639
|
-
|
2640
|
-
|
2641
|
-
|
2642
|
-
|
2643
|
-
}),
|
2644
|
-
updateContentTypeConfiguration: builder.mutation({
|
2645
|
-
query: ({ uid, ...body }) => ({
|
2646
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2647
|
-
method: "PUT",
|
2648
|
-
data: body
|
2649
|
-
}),
|
2650
|
-
transformResponse: (response) => response.data,
|
2651
|
-
invalidatesTags: (_result, _error, { uid }) => [
|
2652
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2653
|
-
{ type: "ContentTypeSettings", id: "LIST" },
|
2654
|
-
// Is this necessary?
|
2655
|
-
{ type: "InitialData" }
|
2656
|
-
]
|
2657
|
-
})
|
2658
|
-
})
|
2659
|
-
});
|
2660
|
-
const {
|
2661
|
-
useGetContentTypeConfigurationQuery,
|
2662
|
-
useGetAllContentTypeSettingsQuery,
|
2663
|
-
useUpdateContentTypeConfigurationMutation
|
2664
|
-
} = contentTypesApi;
|
2665
|
-
const checkIfAttributeIsDisplayable = (attribute) => {
|
2666
|
-
const { type } = attribute;
|
2667
|
-
if (type === "relation") {
|
2668
|
-
return !attribute.relation.toLowerCase().includes("morph");
|
2669
|
-
}
|
2670
|
-
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
2809
|
+
const HeaderActionDialog = ({
|
2810
|
+
onClose,
|
2811
|
+
onCancel,
|
2812
|
+
title,
|
2813
|
+
content: Content,
|
2814
|
+
isOpen
|
2815
|
+
}) => {
|
2816
|
+
const handleClose = async () => {
|
2817
|
+
if (onCancel) {
|
2818
|
+
await onCancel();
|
2819
|
+
}
|
2820
|
+
onClose();
|
2821
|
+
};
|
2822
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
2823
|
+
/* @__PURE__ */ jsx(Dialog.Header, { children: title }),
|
2824
|
+
typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : Content
|
2825
|
+
] }) });
|
2671
2826
|
};
|
2672
|
-
const
|
2673
|
-
|
2674
|
-
|
2675
|
-
}
|
2676
|
-
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
2677
|
-
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
2678
|
-
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2679
|
-
);
|
2827
|
+
const ConfigureTheViewAction = ({ collectionType, model }) => {
|
2828
|
+
const navigate = useNavigate();
|
2829
|
+
const { formatMessage } = useIntl();
|
2680
2830
|
return {
|
2681
|
-
|
2682
|
-
|
2831
|
+
label: formatMessage({
|
2832
|
+
id: "app.links.configure-view",
|
2833
|
+
defaultMessage: "Configure the view"
|
2834
|
+
}),
|
2835
|
+
icon: /* @__PURE__ */ jsx(ListPlus, {}),
|
2836
|
+
onClick: () => {
|
2837
|
+
navigate(`../${collectionType}/${model}/configurations/edit`);
|
2838
|
+
},
|
2839
|
+
position: "header"
|
2683
2840
|
};
|
2684
2841
|
};
|
2685
|
-
|
2686
|
-
|
2687
|
-
|
2688
|
-
|
2689
|
-
pagination: false,
|
2690
|
-
defaultSortBy: "",
|
2691
|
-
defaultSortOrder: "asc",
|
2692
|
-
mainField: "id",
|
2693
|
-
pageSize: 10
|
2694
|
-
};
|
2695
|
-
const useDocumentLayout = (model) => {
|
2696
|
-
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
2697
|
-
const [{ query }] = useQueryParams();
|
2698
|
-
const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
2699
|
-
const { toggleNotification } = useNotification();
|
2700
|
-
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
2701
|
-
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
2702
|
-
const {
|
2703
|
-
data,
|
2704
|
-
isLoading: isLoadingConfigs,
|
2705
|
-
error,
|
2706
|
-
isFetching: isFetchingConfigs
|
2707
|
-
} = useGetContentTypeConfigurationQuery(model);
|
2708
|
-
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
2709
|
-
React.useEffect(() => {
|
2710
|
-
if (error) {
|
2711
|
-
toggleNotification({
|
2712
|
-
type: "danger",
|
2713
|
-
message: formatAPIError(error)
|
2714
|
-
});
|
2715
|
-
}
|
2716
|
-
}, [error, formatAPIError, toggleNotification]);
|
2717
|
-
const editLayout = React.useMemo(
|
2718
|
-
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
2719
|
-
layout: [],
|
2720
|
-
components: {},
|
2721
|
-
metadatas: {},
|
2722
|
-
options: {},
|
2723
|
-
settings: DEFAULT_SETTINGS
|
2724
|
-
},
|
2725
|
-
[data, isLoading, schemas, schema, components]
|
2726
|
-
);
|
2727
|
-
const listLayout = React.useMemo(() => {
|
2728
|
-
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
2729
|
-
layout: [],
|
2730
|
-
metadatas: {},
|
2731
|
-
options: {},
|
2732
|
-
settings: DEFAULT_SETTINGS
|
2733
|
-
};
|
2734
|
-
}, [data, isLoading, schemas, schema, components]);
|
2735
|
-
const { layout: edit } = React.useMemo(
|
2736
|
-
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
2737
|
-
layout: editLayout,
|
2738
|
-
query
|
2739
|
-
}),
|
2740
|
-
[editLayout, query, runHookWaterfall]
|
2741
|
-
);
|
2842
|
+
ConfigureTheViewAction.type = "configure-the-view";
|
2843
|
+
const EditTheModelAction = ({ model }) => {
|
2844
|
+
const navigate = useNavigate();
|
2845
|
+
const { formatMessage } = useIntl();
|
2742
2846
|
return {
|
2743
|
-
|
2744
|
-
|
2745
|
-
|
2746
|
-
|
2847
|
+
label: formatMessage({
|
2848
|
+
id: "content-manager.link-to-ctb",
|
2849
|
+
defaultMessage: "Edit the model"
|
2850
|
+
}),
|
2851
|
+
icon: /* @__PURE__ */ jsx(Pencil, {}),
|
2852
|
+
onClick: () => {
|
2853
|
+
navigate(`/plugins/content-type-builder/content-types/${model}`);
|
2854
|
+
},
|
2855
|
+
position: "header"
|
2747
2856
|
};
|
2748
2857
|
};
|
2749
|
-
|
2750
|
-
|
2751
|
-
|
2752
|
-
};
|
2753
|
-
const
|
2754
|
-
|
2755
|
-
|
2756
|
-
|
2757
|
-
|
2758
|
-
|
2759
|
-
|
2760
|
-
|
2761
|
-
|
2762
|
-
|
2763
|
-
|
2764
|
-
|
2765
|
-
|
2766
|
-
|
2767
|
-
|
2768
|
-
|
2769
|
-
|
2770
|
-
|
2771
|
-
|
2772
|
-
|
2773
|
-
|
2774
|
-
|
2775
|
-
|
2776
|
-
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2782
|
-
|
2783
|
-
|
2784
|
-
|
2785
|
-
|
2786
|
-
|
2787
|
-
|
2788
|
-
|
2858
|
+
EditTheModelAction.type = "edit-the-model";
|
2859
|
+
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2860
|
+
const navigate = useNavigate();
|
2861
|
+
const { formatMessage } = useIntl();
|
2862
|
+
const listViewPathMatch = useMatch(LIST_PATH);
|
2863
|
+
const canDelete = useDocumentRBAC("DeleteAction", (state) => state.canDelete);
|
2864
|
+
const { delete: deleteAction } = useDocumentActions();
|
2865
|
+
const { toggleNotification } = useNotification();
|
2866
|
+
const setSubmitting = useForm("DeleteAction", (state) => state.setSubmitting);
|
2867
|
+
const isLocalized = document?.locale != null;
|
2868
|
+
return {
|
2869
|
+
disabled: !canDelete || !document,
|
2870
|
+
label: formatMessage(
|
2871
|
+
{
|
2872
|
+
id: "content-manager.actions.delete.label",
|
2873
|
+
defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
|
2874
|
+
},
|
2875
|
+
{ isLocalized }
|
2876
|
+
),
|
2877
|
+
icon: /* @__PURE__ */ jsx(Trash, {}),
|
2878
|
+
dialog: {
|
2879
|
+
type: "dialog",
|
2880
|
+
title: formatMessage({
|
2881
|
+
id: "app.components.ConfirmDialog.title",
|
2882
|
+
defaultMessage: "Confirmation"
|
2883
|
+
}),
|
2884
|
+
content: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
|
2885
|
+
/* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
2886
|
+
/* @__PURE__ */ jsx(Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
2887
|
+
id: "content-manager.actions.delete.dialog.body",
|
2888
|
+
defaultMessage: "Are you sure?"
|
2889
|
+
}) })
|
2890
|
+
] }),
|
2891
|
+
onConfirm: async () => {
|
2892
|
+
if (!listViewPathMatch) {
|
2893
|
+
setSubmitting(true);
|
2894
|
+
}
|
2895
|
+
try {
|
2896
|
+
if (!documentId && collectionType !== SINGLE_TYPES) {
|
2897
|
+
console.error(
|
2898
|
+
"You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue."
|
2899
|
+
);
|
2900
|
+
toggleNotification({
|
2901
|
+
message: formatMessage({
|
2902
|
+
id: "content-manager.actions.delete.error",
|
2903
|
+
defaultMessage: "An error occurred while trying to delete the document."
|
2904
|
+
}),
|
2905
|
+
type: "danger"
|
2906
|
+
});
|
2907
|
+
return;
|
2908
|
+
}
|
2909
|
+
const res = await deleteAction({
|
2910
|
+
documentId,
|
2911
|
+
model,
|
2912
|
+
collectionType,
|
2913
|
+
params: {
|
2914
|
+
locale: "*"
|
2915
|
+
}
|
2916
|
+
});
|
2917
|
+
if (!("error" in res)) {
|
2918
|
+
navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
|
2919
|
+
}
|
2920
|
+
} finally {
|
2921
|
+
if (!listViewPathMatch) {
|
2922
|
+
setSubmitting(false);
|
2923
|
+
}
|
2789
2924
|
}
|
2790
|
-
}
|
2791
|
-
return acc;
|
2792
|
-
},
|
2793
|
-
{}
|
2794
|
-
);
|
2795
|
-
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2796
|
-
(acc, [attribute, metadata]) => {
|
2797
|
-
return {
|
2798
|
-
...acc,
|
2799
|
-
[attribute]: metadata.edit
|
2800
|
-
};
|
2801
|
-
},
|
2802
|
-
{}
|
2803
|
-
);
|
2804
|
-
return {
|
2805
|
-
layout: panelledEditAttributes,
|
2806
|
-
components: componentEditAttributes,
|
2807
|
-
metadatas: editMetadatas,
|
2808
|
-
settings: {
|
2809
|
-
...data.contentType.settings,
|
2810
|
-
displayName: schema?.info.displayName
|
2925
|
+
}
|
2811
2926
|
},
|
2812
|
-
|
2813
|
-
|
2814
|
-
...schema?.pluginOptions,
|
2815
|
-
...data.contentType.options
|
2816
|
-
}
|
2927
|
+
variant: "danger",
|
2928
|
+
position: ["header", "table-row"]
|
2817
2929
|
};
|
2818
2930
|
};
|
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
|
-
);
|
2931
|
+
DeleteAction$1.type = "delete";
|
2932
|
+
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2933
|
+
const Panels = () => {
|
2934
|
+
const isCloning = useMatch(CLONE_PATH) !== null;
|
2935
|
+
const [
|
2936
|
+
{
|
2937
|
+
query: { status }
|
2938
|
+
}
|
2939
|
+
] = useQueryParams({
|
2940
|
+
status: "draft"
|
2941
|
+
});
|
2942
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
2943
|
+
const plugins = useStrapiApp("Panels", (state) => state.plugins);
|
2944
|
+
const props = {
|
2945
|
+
activeTab: status,
|
2946
|
+
model,
|
2947
|
+
documentId: id,
|
2948
|
+
document: isCloning ? void 0 : document,
|
2949
|
+
meta: isCloning ? void 0 : meta,
|
2950
|
+
collectionType
|
2951
|
+
};
|
2952
|
+
return /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsx(
|
2953
|
+
DescriptionComponentRenderer,
|
2954
|
+
{
|
2955
|
+
props,
|
2956
|
+
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
2957
|
+
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsx(Panel, { ...description, children: content }, id2))
|
2958
|
+
}
|
2959
|
+
) });
|
2848
2960
|
};
|
2849
|
-
const
|
2850
|
-
|
2851
|
-
schema,
|
2852
|
-
components
|
2853
|
-
}) => {
|
2854
|
-
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2855
|
-
(acc, [attribute, metadata]) => {
|
2856
|
-
return {
|
2857
|
-
...acc,
|
2858
|
-
[attribute]: metadata.list
|
2859
|
-
};
|
2860
|
-
},
|
2861
|
-
{}
|
2862
|
-
);
|
2863
|
-
const listAttributes = convertListLayoutToFieldLayouts(
|
2864
|
-
data.contentType.layouts.list,
|
2865
|
-
schema?.attributes,
|
2866
|
-
listMetadatas,
|
2867
|
-
{ configurations: data.components, schemas: components },
|
2868
|
-
schemas
|
2869
|
-
);
|
2961
|
+
const ActionsPanel = () => {
|
2962
|
+
const { formatMessage } = useIntl();
|
2870
2963
|
return {
|
2871
|
-
|
2872
|
-
|
2873
|
-
|
2874
|
-
|
2875
|
-
|
2876
|
-
...schema?.pluginOptions,
|
2877
|
-
...data.contentType.options
|
2878
|
-
}
|
2964
|
+
title: formatMessage({
|
2965
|
+
id: "content-manager.containers.edit.panels.default.title",
|
2966
|
+
defaultMessage: "Entry"
|
2967
|
+
}),
|
2968
|
+
content: /* @__PURE__ */ jsx(ActionsPanelContent, {})
|
2879
2969
|
};
|
2880
2970
|
};
|
2881
|
-
|
2882
|
-
|
2883
|
-
|
2884
|
-
|
2885
|
-
|
2971
|
+
ActionsPanel.type = "actions";
|
2972
|
+
const ActionsPanelContent = () => {
|
2973
|
+
const isCloning = useMatch(CLONE_PATH) !== null;
|
2974
|
+
const [
|
2975
|
+
{
|
2976
|
+
query: { status = "draft" }
|
2886
2977
|
}
|
2887
|
-
|
2888
|
-
|
2889
|
-
|
2890
|
-
|
2891
|
-
|
2892
|
-
|
2893
|
-
|
2894
|
-
|
2895
|
-
|
2896
|
-
|
2897
|
-
|
2898
|
-
|
2899
|
-
|
2900
|
-
|
2978
|
+
] = useQueryParams();
|
2979
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
2980
|
+
const plugins = useStrapiApp("ActionsPanel", (state) => state.plugins);
|
2981
|
+
const props = {
|
2982
|
+
activeTab: status,
|
2983
|
+
model,
|
2984
|
+
documentId: id,
|
2985
|
+
document: isCloning ? void 0 : document,
|
2986
|
+
meta: isCloning ? void 0 : meta,
|
2987
|
+
collectionType
|
2988
|
+
};
|
2989
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, width: "100%", children: [
|
2990
|
+
/* @__PURE__ */ jsx(
|
2991
|
+
DescriptionComponentRenderer,
|
2992
|
+
{
|
2993
|
+
props,
|
2994
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2995
|
+
children: (actions2) => /* @__PURE__ */ jsx(DocumentActions, { actions: actions2 })
|
2996
|
+
}
|
2997
|
+
),
|
2998
|
+
/* @__PURE__ */ jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
2999
|
+
] });
|
2901
3000
|
};
|
3001
|
+
const Panel = React.forwardRef(({ children, title }, ref) => {
|
3002
|
+
return /* @__PURE__ */ jsxs(
|
3003
|
+
Flex,
|
3004
|
+
{
|
3005
|
+
ref,
|
3006
|
+
tag: "aside",
|
3007
|
+
"aria-labelledby": "additional-information",
|
3008
|
+
background: "neutral0",
|
3009
|
+
borderColor: "neutral150",
|
3010
|
+
hasRadius: true,
|
3011
|
+
paddingBottom: 4,
|
3012
|
+
paddingLeft: 4,
|
3013
|
+
paddingRight: 4,
|
3014
|
+
paddingTop: 4,
|
3015
|
+
shadow: "tableShadow",
|
3016
|
+
gap: 3,
|
3017
|
+
direction: "column",
|
3018
|
+
justifyContent: "stretch",
|
3019
|
+
alignItems: "flex-start",
|
3020
|
+
children: [
|
3021
|
+
/* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
|
3022
|
+
children
|
3023
|
+
]
|
3024
|
+
}
|
3025
|
+
);
|
3026
|
+
});
|
2902
3027
|
const ConfirmBulkActionDialog = ({
|
2903
3028
|
onToggleDialog,
|
2904
3029
|
isOpen = false,
|
@@ -3876,6 +4001,82 @@ const { setInitialData } = actions;
|
|
3876
4001
|
const reducer = combineReducers({
|
3877
4002
|
app: reducer$1
|
3878
4003
|
});
|
4004
|
+
const previewApi = contentManagerApi.injectEndpoints({
|
4005
|
+
endpoints: (builder) => ({
|
4006
|
+
getPreviewUrl: builder.query({
|
4007
|
+
query({ query, params }) {
|
4008
|
+
return {
|
4009
|
+
url: `/content-manager/preview/url/${params.contentType}`,
|
4010
|
+
method: "GET",
|
4011
|
+
config: {
|
4012
|
+
params: query
|
4013
|
+
}
|
4014
|
+
};
|
4015
|
+
}
|
4016
|
+
})
|
4017
|
+
})
|
4018
|
+
});
|
4019
|
+
const { useGetPreviewUrlQuery } = previewApi;
|
4020
|
+
const PreviewSidePanel = ({ model, documentId, document }) => {
|
4021
|
+
const { formatMessage } = useIntl();
|
4022
|
+
const { toggleNotification } = useNotification();
|
4023
|
+
const { copy } = useClipboard();
|
4024
|
+
const { data, error } = useGetPreviewUrlQuery({
|
4025
|
+
params: {
|
4026
|
+
contentType: model
|
4027
|
+
},
|
4028
|
+
query: {
|
4029
|
+
documentId,
|
4030
|
+
locale: document?.locale,
|
4031
|
+
status: document?.status
|
4032
|
+
}
|
4033
|
+
});
|
4034
|
+
if (!data?.data?.url || error) {
|
4035
|
+
return null;
|
4036
|
+
}
|
4037
|
+
const { url } = data.data;
|
4038
|
+
const handleCopyLink = () => {
|
4039
|
+
copy(url);
|
4040
|
+
toggleNotification({
|
4041
|
+
message: formatMessage({
|
4042
|
+
id: "content-manager.preview.copy.success",
|
4043
|
+
defaultMessage: "Copied preview link"
|
4044
|
+
}),
|
4045
|
+
type: "success"
|
4046
|
+
});
|
4047
|
+
};
|
4048
|
+
return {
|
4049
|
+
title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
|
4050
|
+
content: /* @__PURE__ */ jsxs(Flex, { gap: 2, width: "100%", children: [
|
4051
|
+
/* @__PURE__ */ jsx(Button, { variant: "tertiary", tag: Link, to: url, target: "_blank", flex: "auto", children: formatMessage({
|
4052
|
+
id: "content-manager.preview.panel.button",
|
4053
|
+
defaultMessage: "Open preview"
|
4054
|
+
}) }),
|
4055
|
+
/* @__PURE__ */ jsx(
|
4056
|
+
IconButton,
|
4057
|
+
{
|
4058
|
+
type: "button",
|
4059
|
+
label: formatMessage({
|
4060
|
+
id: "preview.copy.label",
|
4061
|
+
defaultMessage: "Copy preview link"
|
4062
|
+
}),
|
4063
|
+
onClick: handleCopyLink,
|
4064
|
+
children: /* @__PURE__ */ jsx(Link$1, {})
|
4065
|
+
}
|
4066
|
+
)
|
4067
|
+
] })
|
4068
|
+
};
|
4069
|
+
};
|
4070
|
+
const FEATURE_ID = "preview";
|
4071
|
+
const previewAdmin = {
|
4072
|
+
bootstrap(app) {
|
4073
|
+
if (!window.strapi.future.isEnabled(FEATURE_ID)) {
|
4074
|
+
return;
|
4075
|
+
}
|
4076
|
+
const contentManagerPluginApis = app.getPlugin("content-manager").apis;
|
4077
|
+
contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
|
4078
|
+
}
|
4079
|
+
};
|
3879
4080
|
const index = {
|
3880
4081
|
register(app) {
|
3881
4082
|
const cm = new ContentManagerPlugin();
|
@@ -3895,7 +4096,7 @@ const index = {
|
|
3895
4096
|
app.router.addRoute({
|
3896
4097
|
path: "content-manager/*",
|
3897
4098
|
lazy: async () => {
|
3898
|
-
const { Layout } = await import("./layout-
|
4099
|
+
const { Layout } = await import("./layout-CrTxOnCy.mjs");
|
3899
4100
|
return {
|
3900
4101
|
Component: Layout
|
3901
4102
|
};
|
@@ -3908,11 +4109,14 @@ const index = {
|
|
3908
4109
|
if (typeof historyAdmin.bootstrap === "function") {
|
3909
4110
|
historyAdmin.bootstrap(app);
|
3910
4111
|
}
|
4112
|
+
if (typeof previewAdmin.bootstrap === "function") {
|
4113
|
+
previewAdmin.bootstrap(app);
|
4114
|
+
}
|
3911
4115
|
},
|
3912
4116
|
async registerTrads({ locales }) {
|
3913
4117
|
const importedTrads = await Promise.all(
|
3914
4118
|
locales.map((locale) => {
|
3915
|
-
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => import("./ar-CCEVvqGG.mjs"), "./translations/ca.json": () => import("./ca-5U32ON2v.mjs"), "./translations/cs.json": () => import("./cs-CM2aBUar.mjs"), "./translations/de.json": () => import("./de-C72KDNOl.mjs"), "./translations/en.json": () => import("./en-
|
4119
|
+
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => import("./ar-CCEVvqGG.mjs"), "./translations/ca.json": () => import("./ca-5U32ON2v.mjs"), "./translations/cs.json": () => import("./cs-CM2aBUar.mjs"), "./translations/de.json": () => import("./de-C72KDNOl.mjs"), "./translations/en.json": () => import("./en-CZw4xdPY.mjs"), "./translations/es.json": () => import("./es-D34tqjMw.mjs"), "./translations/eu.json": () => import("./eu-CdALomew.mjs"), "./translations/fr.json": () => import("./fr--pg5jUbt.mjs"), "./translations/gu.json": () => import("./gu-CNpaMDpH.mjs"), "./translations/hi.json": () => import("./hi-Dwvd04m3.mjs"), "./translations/hu.json": () => import("./hu-CeYvaaO0.mjs"), "./translations/id.json": () => import("./id-BtwA9WJT.mjs"), "./translations/it.json": () => import("./it-BrVPqaf1.mjs"), "./translations/ja.json": () => import("./ja-BHqhDq4V.mjs"), "./translations/ko.json": () => import("./ko-HVQRlfUI.mjs"), "./translations/ml.json": () => import("./ml-BihZwQit.mjs"), "./translations/ms.json": () => import("./ms-m_WjyWx7.mjs"), "./translations/nl.json": () => import("./nl-D4R9gHx5.mjs"), "./translations/pl.json": () => import("./pl-sbx9mSt_.mjs"), "./translations/pt-BR.json": () => import("./pt-BR-C71iDxnh.mjs"), "./translations/pt.json": () => import("./pt-BsaFvS8-.mjs"), "./translations/ru.json": () => import("./ru-BE6A4Exp.mjs"), "./translations/sa.json": () => import("./sa-Dag0k-Z8.mjs"), "./translations/sk.json": () => import("./sk-BFg-R8qJ.mjs"), "./translations/sv.json": () => import("./sv-CUnfWGsh.mjs"), "./translations/th.json": () => import("./th-BqbI8lIT.mjs"), "./translations/tr.json": () => import("./tr-CgeK3wJM.mjs"), "./translations/uk.json": () => import("./uk-CR-zDhAY.mjs"), "./translations/vi.json": () => import("./vi-DUXIk_fw.mjs"), "./translations/zh-Hans.json": () => import("./zh-Hans-BPQcRIyH.mjs"), "./translations/zh.json": () => import("./zh-BWZspA60.mjs") }), `./translations/${locale}.json`).then(({ default: data }) => {
|
3916
4120
|
return {
|
3917
4121
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3918
4122
|
locale
|
@@ -3940,7 +4144,8 @@ export {
|
|
3940
4144
|
InjectionZone as I,
|
3941
4145
|
useDocument as J,
|
3942
4146
|
index as K,
|
3943
|
-
|
4147
|
+
useContentManagerContext as L,
|
4148
|
+
useDocumentActions as M,
|
3944
4149
|
Panels as P,
|
3945
4150
|
RelativeTime as R,
|
3946
4151
|
SINGLE_TYPES as S,
|
@@ -3972,4 +4177,4 @@ export {
|
|
3972
4177
|
capitalise as y,
|
3973
4178
|
useUpdateContentTypeConfigurationMutation as z
|
3974
4179
|
};
|
3975
|
-
//# sourceMappingURL=index-
|
4180
|
+
//# sourceMappingURL=index-3_WeHXYp.mjs.map
|