@strapi/content-manager 0.0.0-experimental.d954d57341a6623992a0d211daaec8e245c3517d → 0.0.0-experimental.dad3c50630ca4fd9eccdcbe549ee632fc572e23d
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/LICENSE +18 -3
- package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -1
- package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-WRPUXGd6.js → ComponentConfigurationPage-BLWQy8ru.js} +5 -6
- package/dist/_chunks/{ComponentConfigurationPage-WRPUXGd6.js.map → ComponentConfigurationPage-BLWQy8ru.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-gdUj_t-O.mjs → ComponentConfigurationPage-CtIa3aa2.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-gdUj_t-O.mjs.map → ComponentConfigurationPage-CtIa3aa2.mjs.map} +1 -1
- package/dist/_chunks/{ComponentIcon-BXdiCGQp.js → ComponentIcon-CRbtQEUV.js} +2 -3
- package/dist/_chunks/{ComponentIcon-BXdiCGQp.js.map → ComponentIcon-CRbtQEUV.js.map} +1 -1
- package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -1
- package/dist/_chunks/{EditConfigurationPage-BwuIPOJG.mjs → EditConfigurationPage-DsPR2DVk.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-BwuIPOJG.mjs.map → EditConfigurationPage-DsPR2DVk.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-C1vjMBgy.js → EditConfigurationPage-RQkymxCy.js} +5 -6
- package/dist/_chunks/{EditConfigurationPage-C1vjMBgy.js.map → EditConfigurationPage-RQkymxCy.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-DbcGfyqK.js → EditViewPage-B-kExt8C.js} +63 -13
- package/dist/_chunks/EditViewPage-B-kExt8C.js.map +1 -0
- package/dist/_chunks/{EditViewPage-0MiFkXa8.mjs → EditViewPage-BPyVuPfM.mjs} +63 -12
- package/dist/_chunks/EditViewPage-BPyVuPfM.mjs.map +1 -0
- package/dist/_chunks/{Field-BG1xu38N.js → Field-DPIsQRre.js} +680 -261
- package/dist/_chunks/Field-DPIsQRre.js.map +1 -0
- package/dist/_chunks/{Field-BDMSCcy5.mjs → Field-Dltnt1km.mjs} +676 -257
- package/dist/_chunks/Field-Dltnt1km.mjs.map +1 -0
- package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
- package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
- package/dist/_chunks/{Form-9BnFyUjy.js → Form-BFi4MXMT.js} +43 -22
- package/dist/_chunks/Form-BFi4MXMT.js.map +1 -0
- package/dist/_chunks/{Form-CPVWavB8.mjs → Form-C1IcWm1u.mjs} +41 -19
- package/dist/_chunks/Form-C1IcWm1u.mjs.map +1 -0
- package/dist/_chunks/{History-BVpd8LP3.mjs → History-04ChQ4pl.mjs} +108 -116
- package/dist/_chunks/History-04ChQ4pl.mjs.map +1 -0
- package/dist/_chunks/{History-BWWxLt2Z.js → History-wjcK4L0C.js} +107 -116
- package/dist/_chunks/History-wjcK4L0C.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DozVMKcR.mjs → ListConfigurationPage-BYqPYLSU.mjs} +25 -12
- package/dist/_chunks/ListConfigurationPage-BYqPYLSU.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-6swzjdAZ.js → ListConfigurationPage-CRbxIC3J.js} +25 -13
- package/dist/_chunks/ListConfigurationPage-CRbxIC3J.js.map +1 -0
- package/dist/_chunks/{ListViewPage-BlzfjS2Q.js → ListViewPage-D5NY9183.js} +121 -81
- package/dist/_chunks/ListViewPage-D5NY9183.js.map +1 -0
- package/dist/_chunks/{ListViewPage-Ds0ulgfG.mjs → ListViewPage-FU2LBuhl.mjs} +118 -77
- package/dist/_chunks/ListViewPage-FU2LBuhl.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-D2nCCWEl.js → NoContentTypePage-BgQVE_Qb.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-D2nCCWEl.js.map → NoContentTypePage-BgQVE_Qb.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-BH11kaKt.mjs → NoContentTypePage-DCKUkwb8.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-BH11kaKt.mjs.map → NoContentTypePage-DCKUkwb8.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DN_JlsU2.js → NoPermissionsPage-C5jwn70o.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DN_JlsU2.js.map → NoPermissionsPage-C5jwn70o.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-BT2Tn0D_.mjs → NoPermissionsPage-jqve7C8l.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-BT2Tn0D_.mjs.map → NoPermissionsPage-jqve7C8l.mjs.map} +1 -1
- package/dist/_chunks/Preview-BMYN548c.mjs +294 -0
- package/dist/_chunks/Preview-BMYN548c.mjs.map +1 -0
- package/dist/_chunks/Preview-DaOihysv.js +312 -0
- package/dist/_chunks/Preview-DaOihysv.js.map +1 -0
- package/dist/_chunks/{Relations-CcgFTcWo.js → Relations-CTGM7Hv5.js} +76 -43
- package/dist/_chunks/Relations-CTGM7Hv5.js.map +1 -0
- package/dist/_chunks/{Relations-Dnag3fhV.mjs → Relations-gscPkxjF.mjs} +76 -42
- package/dist/_chunks/Relations-gscPkxjF.mjs.map +1 -0
- package/dist/_chunks/{en-fbKQxLGn.js → en-BzQmavmK.js} +37 -18
- package/dist/_chunks/{en-fbKQxLGn.js.map → en-BzQmavmK.js.map} +1 -1
- package/dist/_chunks/{en-Ux26r5pl.mjs → en-CSxLmrh1.mjs} +37 -18
- package/dist/_chunks/{en-Ux26r5pl.mjs.map → en-CSxLmrh1.mjs.map} +1 -1
- package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
- package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
- package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
- package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
- package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
- package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
- package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
- package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
- package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
- package/dist/_chunks/{index-CWpLBSt0.js → index-Ca7YWlAA.js} +1271 -746
- package/dist/_chunks/index-Ca7YWlAA.js.map +1 -0
- package/dist/_chunks/{index-JNNNKUHs.mjs → index-DqasUQ6Q.mjs} +1288 -763
- package/dist/_chunks/index-DqasUQ6Q.mjs.map +1 -0
- package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
- package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
- package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
- package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
- package/dist/_chunks/{layout--iHdZzRk.js → layout-BW80JSCd.js} +27 -15
- package/dist/_chunks/layout-BW80JSCd.js.map +1 -0
- package/dist/_chunks/{layout-DC503LnF.mjs → layout-W3clJSCy.mjs} +28 -15
- package/dist/_chunks/layout-W3clJSCy.mjs.map +1 -0
- package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
- package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
- package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
- package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
- package/dist/_chunks/{relations-CTje5t-a.mjs → relations-BlDkoeWh.mjs} +6 -7
- package/dist/_chunks/relations-BlDkoeWh.mjs.map +1 -0
- package/dist/_chunks/{relations-BbHizA5K.js → relations-C9Usz9k5.js} +6 -7
- package/dist/_chunks/relations-C9Usz9k5.js.map +1 -0
- package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
- package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
- package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
- package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
- package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
- package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
- package/dist/admin/index.js +3 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +5 -3
- package/dist/admin/src/content-manager.d.ts +3 -2
- package/dist/admin/src/exports.d.ts +2 -1
- package/dist/admin/src/history/index.d.ts +3 -0
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +32 -1
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +2 -1
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +3 -3
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +5 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +4 -48
- package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
- package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
- package/dist/admin/src/preview/index.d.ts +4 -0
- package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
- package/dist/admin/src/preview/routes.d.ts +3 -0
- package/dist/admin/src/preview/services/preview.d.ts +3 -0
- package/dist/admin/src/router.d.ts +1 -1
- package/dist/admin/src/services/api.d.ts +1 -1
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +3 -3
- package/dist/admin/src/services/documents.d.ts +19 -20
- package/dist/admin/src/services/init.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +2 -2
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/admin/src/utils/validation.d.ts +4 -1
- package/dist/server/index.js +765 -437
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +766 -437
- 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/uid.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +16 -1
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
- package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
- package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts +3 -3
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +8 -12
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +7 -6
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
- package/dist/server/src/preview/controllers/index.d.ts +2 -0
- package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/preview.d.ts +13 -0
- package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
- package/dist/server/src/preview/index.d.ts +4 -0
- package/dist/server/src/preview/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/index.d.ts +8 -0
- package/dist/server/src/preview/routes/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/preview.d.ts +4 -0
- package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
- package/dist/server/src/preview/services/index.d.ts +16 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts +32 -0
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview.d.ts +12 -0
- package/dist/server/src/preview/services/preview.d.ts.map +1 -0
- package/dist/server/src/preview/utils.d.ts +19 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -0
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +12 -10
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +7 -6
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/permission-checker.d.ts.map +1 -1
- package/dist/server/src/services/utils/populate.d.ts +2 -2
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts +2 -0
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/shared/contracts/collection-types.d.ts +3 -1
- package/dist/shared/contracts/collection-types.d.ts.map +1 -1
- package/dist/shared/contracts/index.d.ts +1 -0
- package/dist/shared/contracts/index.d.ts.map +1 -1
- package/dist/shared/contracts/preview.d.ts +27 -0
- package/dist/shared/contracts/preview.d.ts.map +1 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +4 -0
- package/dist/shared/index.mjs.map +1 -1
- package/package.json +17 -15
- package/dist/_chunks/EditViewPage-0MiFkXa8.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-DbcGfyqK.js.map +0 -1
- package/dist/_chunks/Field-BDMSCcy5.mjs.map +0 -1
- package/dist/_chunks/Field-BG1xu38N.js.map +0 -1
- package/dist/_chunks/Form-9BnFyUjy.js.map +0 -1
- package/dist/_chunks/Form-CPVWavB8.mjs.map +0 -1
- package/dist/_chunks/History-BVpd8LP3.mjs.map +0 -1
- package/dist/_chunks/History-BWWxLt2Z.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-6swzjdAZ.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DozVMKcR.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-BlzfjS2Q.js.map +0 -1
- package/dist/_chunks/ListViewPage-Ds0ulgfG.mjs.map +0 -1
- package/dist/_chunks/Relations-CcgFTcWo.js.map +0 -1
- package/dist/_chunks/Relations-Dnag3fhV.mjs.map +0 -1
- package/dist/_chunks/index-CWpLBSt0.js.map +0 -1
- package/dist/_chunks/index-JNNNKUHs.mjs.map +0 -1
- package/dist/_chunks/layout--iHdZzRk.js.map +0 -1
- package/dist/_chunks/layout-DC503LnF.mjs.map +0 -1
- package/dist/_chunks/relations-BbHizA5K.js.map +0 -1
- package/dist/_chunks/relations-CTje5t-a.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,25 +1,33 @@
|
|
1
|
-
import {
|
1
|
+
import { More, Cross, WarningCircle, ListPlus, Pencil, Trash, Check, CrossCircle, CheckCircle, ArrowsCounterClockwise, ChevronRight, Duplicate, ClockCounterClockwise, Feather } from "@strapi/icons";
|
2
2
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
3
|
-
import { useStrapiApp,
|
4
|
-
import { stringify } from "qs";
|
5
|
-
import { useIntl } from "react-intl";
|
6
|
-
import { useNavigate, useParams, Navigate, useMatch, useLocation, Link, NavLink } from "react-router-dom";
|
3
|
+
import { useStrapiApp, createContext, useQueryParams, useAuth, useRBAC, Page, adminApi, translatedErrors, useNotification, useAPIErrorHandler, getYupValidationErrors, useForm, useTracking, useGuidedTour, BackButton, DescriptionComponentRenderer, useTable, Table } from "@strapi/admin/strapi-admin";
|
7
4
|
import * as React from "react";
|
8
5
|
import { lazy } from "react";
|
9
|
-
import {
|
6
|
+
import { Menu, Button, VisuallyHidden, Flex, Dialog, Modal, Typography, Radio, Status, Box, SingleSelect, SingleSelectOption, IconButton, Loader, Tooltip, LinkButton } from "@strapi/design-system";
|
7
|
+
import mapValues from "lodash/fp/mapValues";
|
8
|
+
import { useIntl } from "react-intl";
|
9
|
+
import { useParams, useNavigate, Navigate, useMatch, useLocation, Link, NavLink } from "react-router-dom";
|
10
10
|
import { styled } from "styled-components";
|
11
11
|
import * as yup from "yup";
|
12
12
|
import { ValidationError } from "yup";
|
13
|
+
import { stringify } from "qs";
|
13
14
|
import pipe from "lodash/fp/pipe";
|
14
15
|
import { intervalToDuration, isPast } from "date-fns";
|
15
16
|
import { createSlice, combineReducers } from "@reduxjs/toolkit";
|
16
|
-
const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
17
|
+
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
17
18
|
const v = glob[path];
|
18
19
|
if (v) {
|
19
20
|
return typeof v === "function" ? v() : Promise.resolve(v);
|
20
21
|
}
|
21
22
|
return new Promise((_, reject) => {
|
22
|
-
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
23
|
+
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
24
|
+
reject.bind(
|
25
|
+
null,
|
26
|
+
new Error(
|
27
|
+
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
28
|
+
)
|
29
|
+
)
|
30
|
+
);
|
23
31
|
});
|
24
32
|
};
|
25
33
|
const PLUGIN_ID = "content-manager";
|
@@ -49,42 +57,6 @@ const useInjectionZone = (area) => {
|
|
49
57
|
const [page, position] = area.split(".");
|
50
58
|
return contentManagerPlugin.getInjectedComponents(page, position);
|
51
59
|
};
|
52
|
-
const HistoryAction = ({ model, document }) => {
|
53
|
-
const { formatMessage } = useIntl();
|
54
|
-
const [{ query }] = useQueryParams();
|
55
|
-
const navigate = useNavigate();
|
56
|
-
const pluginsQueryParams = stringify({ plugins: query.plugins }, { encode: false });
|
57
|
-
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
58
|
-
return null;
|
59
|
-
}
|
60
|
-
return {
|
61
|
-
icon: /* @__PURE__ */ jsx(ClockCounterClockwise, {}),
|
62
|
-
label: formatMessage({
|
63
|
-
id: "content-manager.history.document-action",
|
64
|
-
defaultMessage: "Content History"
|
65
|
-
}),
|
66
|
-
onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
|
67
|
-
disabled: (
|
68
|
-
/**
|
69
|
-
* The user is creating a new document.
|
70
|
-
* It hasn't been saved yet, so there's no history to go to
|
71
|
-
*/
|
72
|
-
!document || /**
|
73
|
-
* The document has been created but the current dimension has never been saved.
|
74
|
-
* For example, the user is creating a new locale in an existing document,
|
75
|
-
* so there's no history for the document in that locale
|
76
|
-
*/
|
77
|
-
!document.id || /**
|
78
|
-
* History is only available for content types created by the user.
|
79
|
-
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
80
|
-
* which start with `admin::` or `plugin::`
|
81
|
-
*/
|
82
|
-
!model.startsWith("api::")
|
83
|
-
),
|
84
|
-
position: "header"
|
85
|
-
};
|
86
|
-
};
|
87
|
-
HistoryAction.type = "history";
|
88
60
|
const ID = "id";
|
89
61
|
const CREATED_BY_ATTRIBUTE_NAME = "createdBy";
|
90
62
|
const UPDATED_BY_ATTRIBUTE_NAME = "updatedBy";
|
@@ -136,6 +108,7 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
136
108
|
if (!slug) {
|
137
109
|
throw new Error("Cannot find the slug param in the URL");
|
138
110
|
}
|
111
|
+
const [{ rawQuery }] = useQueryParams();
|
139
112
|
const userPermissions = useAuth("DocumentRBAC", (state) => state.permissions);
|
140
113
|
const contentTypePermissions = React.useMemo(() => {
|
141
114
|
const contentTypePermissions2 = userPermissions.filter(
|
@@ -146,7 +119,14 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
146
119
|
return { ...acc, [action]: [permission] };
|
147
120
|
}, {});
|
148
121
|
}, [slug, userPermissions]);
|
149
|
-
const { isLoading, allowedActions } = useRBAC(
|
122
|
+
const { isLoading, allowedActions } = useRBAC(
|
123
|
+
contentTypePermissions,
|
124
|
+
permissions ?? void 0,
|
125
|
+
// TODO: useRBAC context should be typed and built differently
|
126
|
+
// We are passing raw query as context to the hook so that it can
|
127
|
+
// rely on the locale provided from DocumentRBAC for its permission calculations.
|
128
|
+
rawQuery
|
129
|
+
);
|
150
130
|
const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
|
151
131
|
const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
|
152
132
|
const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
|
@@ -194,10 +174,13 @@ const contentManagerApi = adminApi.enhanceEndpoints({
|
|
194
174
|
"Document",
|
195
175
|
"InitialData",
|
196
176
|
"HistoryVersion",
|
197
|
-
"Relations"
|
177
|
+
"Relations",
|
178
|
+
"UidAvailability",
|
179
|
+
"RecentDocumentList"
|
198
180
|
]
|
199
181
|
});
|
200
182
|
const documentApi = contentManagerApi.injectEndpoints({
|
183
|
+
overrideExisting: true,
|
201
184
|
endpoints: (builder) => ({
|
202
185
|
autoCloneDocument: builder.mutation({
|
203
186
|
query: ({ model, sourceId, query }) => ({
|
@@ -207,7 +190,12 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
207
190
|
params: query
|
208
191
|
}
|
209
192
|
}),
|
210
|
-
invalidatesTags: (_result,
|
193
|
+
invalidatesTags: (_result, error, { model }) => {
|
194
|
+
if (error) {
|
195
|
+
return [];
|
196
|
+
}
|
197
|
+
return [{ type: "Document", id: `${model}_LIST` }, "RecentDocumentList"];
|
198
|
+
}
|
211
199
|
}),
|
212
200
|
cloneDocument: builder.mutation({
|
213
201
|
query: ({ model, sourceId, data, params }) => ({
|
@@ -218,7 +206,11 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
218
206
|
params
|
219
207
|
}
|
220
208
|
}),
|
221
|
-
invalidatesTags: (_result, _error, { model }) => [
|
209
|
+
invalidatesTags: (_result, _error, { model }) => [
|
210
|
+
{ type: "Document", id: `${model}_LIST` },
|
211
|
+
{ type: "UidAvailability", id: model },
|
212
|
+
"RecentDocumentList"
|
213
|
+
]
|
222
214
|
}),
|
223
215
|
/**
|
224
216
|
* Creates a new collection-type document. This should ONLY be used for collection-types.
|
@@ -235,8 +227,22 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
235
227
|
}),
|
236
228
|
invalidatesTags: (result, _error, { model }) => [
|
237
229
|
{ type: "Document", id: `${model}_LIST` },
|
238
|
-
"Relations"
|
239
|
-
|
230
|
+
"Relations",
|
231
|
+
{ type: "UidAvailability", id: model },
|
232
|
+
"RecentDocumentList"
|
233
|
+
],
|
234
|
+
transformResponse: (response, meta, arg) => {
|
235
|
+
if (!("data" in response) && arg.model === "plugin::users-permissions.user") {
|
236
|
+
return {
|
237
|
+
data: response,
|
238
|
+
meta: {
|
239
|
+
availableStatus: [],
|
240
|
+
availableLocales: []
|
241
|
+
}
|
242
|
+
};
|
243
|
+
}
|
244
|
+
return response;
|
245
|
+
}
|
240
246
|
}),
|
241
247
|
deleteDocument: builder.mutation({
|
242
248
|
query: ({ collectionType, model, documentId, params }) => ({
|
@@ -247,7 +253,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
247
253
|
}
|
248
254
|
}),
|
249
255
|
invalidatesTags: (_result, _error, { collectionType, model }) => [
|
250
|
-
{ type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model }
|
256
|
+
{ type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model },
|
257
|
+
"RecentDocumentList"
|
251
258
|
]
|
252
259
|
}),
|
253
260
|
deleteManyDocuments: builder.mutation({
|
@@ -259,7 +266,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
259
266
|
params
|
260
267
|
}
|
261
268
|
}),
|
262
|
-
invalidatesTags: (_res, _error, { model }) => [
|
269
|
+
invalidatesTags: (_res, _error, { model }) => [
|
270
|
+
{ type: "Document", id: `${model}_LIST` },
|
271
|
+
"RecentDocumentList"
|
272
|
+
]
|
263
273
|
}),
|
264
274
|
discardDocument: builder.mutation({
|
265
275
|
query: ({ collectionType, model, documentId, params }) => ({
|
@@ -276,7 +286,9 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
276
286
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
277
287
|
},
|
278
288
|
{ type: "Document", id: `${model}_LIST` },
|
279
|
-
"Relations"
|
289
|
+
"Relations",
|
290
|
+
{ type: "UidAvailability", id: model },
|
291
|
+
"RecentDocumentList"
|
280
292
|
];
|
281
293
|
}
|
282
294
|
}),
|
@@ -289,11 +301,12 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
289
301
|
url: `/content-manager/collection-types/${model}`,
|
290
302
|
method: "GET",
|
291
303
|
config: {
|
292
|
-
params
|
304
|
+
params: stringify(params, { encode: true })
|
293
305
|
}
|
294
306
|
}),
|
295
307
|
providesTags: (result, _error, arg) => {
|
296
308
|
return [
|
309
|
+
{ type: "Document", id: `ALL_LIST` },
|
297
310
|
{ type: "Document", id: `${arg.model}_LIST` },
|
298
311
|
...result?.results.map(({ documentId }) => ({
|
299
312
|
type: "Document",
|
@@ -332,6 +345,11 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
332
345
|
{
|
333
346
|
type: "Document",
|
334
347
|
id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
|
348
|
+
},
|
349
|
+
// Make it easy to invalidate all individual documents queries for a model
|
350
|
+
{
|
351
|
+
type: "Document",
|
352
|
+
id: `${model}_ALL_ITEMS`
|
335
353
|
}
|
336
354
|
];
|
337
355
|
}
|
@@ -365,7 +383,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
365
383
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
366
384
|
},
|
367
385
|
{ type: "Document", id: `${model}_LIST` },
|
368
|
-
"Relations"
|
386
|
+
"Relations",
|
387
|
+
"RecentDocumentList"
|
369
388
|
];
|
370
389
|
}
|
371
390
|
}),
|
@@ -395,8 +414,23 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
395
414
|
type: "Document",
|
396
415
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
397
416
|
},
|
398
|
-
"Relations"
|
417
|
+
"Relations",
|
418
|
+
{ type: "UidAvailability", id: model },
|
419
|
+
"RecentDocumentList",
|
420
|
+
"RecentDocumentList"
|
399
421
|
];
|
422
|
+
},
|
423
|
+
async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
|
424
|
+
const patchResult = dispatch(
|
425
|
+
documentApi.util.updateQueryData("getDocument", patch, (draft) => {
|
426
|
+
Object.assign(draft.data, data);
|
427
|
+
})
|
428
|
+
);
|
429
|
+
try {
|
430
|
+
await queryFulfilled;
|
431
|
+
} catch {
|
432
|
+
patchResult.undo();
|
433
|
+
}
|
400
434
|
}
|
401
435
|
}),
|
402
436
|
unpublishDocument: builder.mutation({
|
@@ -413,7 +447,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
413
447
|
{
|
414
448
|
type: "Document",
|
415
449
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
416
|
-
}
|
450
|
+
},
|
451
|
+
"RecentDocumentList"
|
417
452
|
];
|
418
453
|
}
|
419
454
|
}),
|
@@ -426,7 +461,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
426
461
|
params
|
427
462
|
}
|
428
463
|
}),
|
429
|
-
invalidatesTags: (_res, _error, { model, documentIds }) =>
|
464
|
+
invalidatesTags: (_res, _error, { model, documentIds }) => [
|
465
|
+
...documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` })),
|
466
|
+
"RecentDocumentList"
|
467
|
+
]
|
430
468
|
})
|
431
469
|
})
|
432
470
|
});
|
@@ -449,8 +487,7 @@ const {
|
|
449
487
|
useUnpublishManyDocumentsMutation
|
450
488
|
} = documentApi;
|
451
489
|
const buildValidParams = (query) => {
|
452
|
-
if (!query)
|
453
|
-
return query;
|
490
|
+
if (!query) return query;
|
454
491
|
const { plugins: _, ...validQueryParams } = {
|
455
492
|
...query,
|
456
493
|
...Object.values(query?.plugins ?? {}).reduce(
|
@@ -458,28 +495,44 @@ const buildValidParams = (query) => {
|
|
458
495
|
{}
|
459
496
|
)
|
460
497
|
};
|
461
|
-
if ("_q" in validQueryParams) {
|
462
|
-
validQueryParams._q = encodeURIComponent(validQueryParams._q);
|
463
|
-
}
|
464
498
|
return validQueryParams;
|
465
499
|
};
|
466
500
|
const isBaseQueryError = (error) => {
|
467
501
|
return error.name !== void 0;
|
468
502
|
};
|
469
|
-
const
|
503
|
+
const arrayValidator = (attribute, options) => ({
|
504
|
+
message: translatedErrors.required,
|
505
|
+
test(value) {
|
506
|
+
if (options.status === "draft") {
|
507
|
+
return true;
|
508
|
+
}
|
509
|
+
if (!attribute.required) {
|
510
|
+
return true;
|
511
|
+
}
|
512
|
+
if (!value) {
|
513
|
+
return false;
|
514
|
+
}
|
515
|
+
if (Array.isArray(value) && value.length === 0) {
|
516
|
+
return false;
|
517
|
+
}
|
518
|
+
return true;
|
519
|
+
}
|
520
|
+
});
|
521
|
+
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
470
522
|
const createModelSchema = (attributes2) => yup.object().shape(
|
471
523
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
472
524
|
if (DOCUMENT_META_FIELDS.includes(name)) {
|
473
525
|
return acc;
|
474
526
|
}
|
475
527
|
const validations = [
|
528
|
+
addNullableValidation,
|
476
529
|
addRequiredValidation,
|
477
530
|
addMinLengthValidation,
|
478
531
|
addMaxLengthValidation,
|
479
532
|
addMinValidation,
|
480
533
|
addMaxValidation,
|
481
534
|
addRegexValidation
|
482
|
-
].map((fn) => fn(attribute));
|
535
|
+
].map((fn) => fn(attribute, options));
|
483
536
|
const transformSchema = pipe(...validations);
|
484
537
|
switch (attribute.type) {
|
485
538
|
case "component": {
|
@@ -489,12 +542,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
489
542
|
...acc,
|
490
543
|
[name]: transformSchema(
|
491
544
|
yup.array().of(createModelSchema(attributes3).nullable(false))
|
492
|
-
)
|
545
|
+
).test(arrayValidator(attribute, options))
|
493
546
|
};
|
494
547
|
} else {
|
495
548
|
return {
|
496
549
|
...acc,
|
497
|
-
[name]: transformSchema(createModelSchema(attributes3))
|
550
|
+
[name]: transformSchema(createModelSchema(attributes3).nullable())
|
498
551
|
};
|
499
552
|
}
|
500
553
|
}
|
@@ -516,7 +569,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
516
569
|
}
|
517
570
|
)
|
518
571
|
)
|
519
|
-
)
|
572
|
+
).test(arrayValidator(attribute, options))
|
520
573
|
};
|
521
574
|
case "relation":
|
522
575
|
return {
|
@@ -528,7 +581,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
528
581
|
} else if (Array.isArray(value)) {
|
529
582
|
return yup.array().of(
|
530
583
|
yup.object().shape({
|
531
|
-
id: yup.
|
584
|
+
id: yup.number().required()
|
532
585
|
})
|
533
586
|
);
|
534
587
|
} else if (typeof value === "object") {
|
@@ -580,6 +633,14 @@ const createAttributeSchema = (attribute) => {
|
|
580
633
|
if (!value || typeof value === "string" && value.length === 0) {
|
581
634
|
return true;
|
582
635
|
}
|
636
|
+
if (typeof value === "object") {
|
637
|
+
try {
|
638
|
+
JSON.stringify(value);
|
639
|
+
return true;
|
640
|
+
} catch (err) {
|
641
|
+
return false;
|
642
|
+
}
|
643
|
+
}
|
583
644
|
try {
|
584
645
|
JSON.parse(value);
|
585
646
|
return true;
|
@@ -598,13 +659,7 @@ const createAttributeSchema = (attribute) => {
|
|
598
659
|
return yup.mixed();
|
599
660
|
}
|
600
661
|
};
|
601
|
-
const
|
602
|
-
if (attribute.required) {
|
603
|
-
return schema.required({
|
604
|
-
id: translatedErrors.required.id,
|
605
|
-
defaultMessage: "This field is required."
|
606
|
-
});
|
607
|
-
}
|
662
|
+
const nullableSchema = (schema) => {
|
608
663
|
return schema?.nullable ? schema.nullable() : (
|
609
664
|
// In some cases '.nullable' will not be available on the schema.
|
610
665
|
// e.g. when the schema has been built using yup.lazy (e.g. for relations).
|
@@ -612,7 +667,22 @@ const addRequiredValidation = (attribute) => (schema) => {
|
|
612
667
|
schema
|
613
668
|
);
|
614
669
|
};
|
615
|
-
const
|
670
|
+
const addNullableValidation = () => (schema) => {
|
671
|
+
return nullableSchema(schema);
|
672
|
+
};
|
673
|
+
const addRequiredValidation = (attribute, options) => (schema) => {
|
674
|
+
if (options.status === "draft" || !attribute.required) {
|
675
|
+
return schema;
|
676
|
+
}
|
677
|
+
if (attribute.required && "required" in schema) {
|
678
|
+
return schema.required(translatedErrors.required);
|
679
|
+
}
|
680
|
+
return schema;
|
681
|
+
};
|
682
|
+
const addMinLengthValidation = (attribute, options) => (schema) => {
|
683
|
+
if (options.status === "draft") {
|
684
|
+
return schema;
|
685
|
+
}
|
616
686
|
if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
|
617
687
|
return schema.min(attribute.minLength, {
|
618
688
|
...translatedErrors.minLength,
|
@@ -634,10 +704,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
634
704
|
}
|
635
705
|
return schema;
|
636
706
|
};
|
637
|
-
const addMinValidation = (attribute) => (schema) => {
|
638
|
-
if ("
|
707
|
+
const addMinValidation = (attribute, options) => (schema) => {
|
708
|
+
if (options.status === "draft") {
|
709
|
+
return schema;
|
710
|
+
}
|
711
|
+
if ("min" in attribute && "min" in schema) {
|
639
712
|
const min = toInteger(attribute.min);
|
640
|
-
if (
|
713
|
+
if (min) {
|
641
714
|
return schema.min(min, {
|
642
715
|
...translatedErrors.min,
|
643
716
|
values: {
|
@@ -755,16 +828,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
|
|
755
828
|
}, {});
|
756
829
|
return componentsByKey;
|
757
830
|
};
|
758
|
-
const
|
831
|
+
const HOOKS = {
|
832
|
+
/**
|
833
|
+
* Hook that allows to mutate the displayed headers of the list view table
|
834
|
+
* @constant
|
835
|
+
* @type {string}
|
836
|
+
*/
|
837
|
+
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
838
|
+
/**
|
839
|
+
* Hook that allows to mutate the CM's collection types links pre-set filters
|
840
|
+
* @constant
|
841
|
+
* @type {string}
|
842
|
+
*/
|
843
|
+
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
844
|
+
/**
|
845
|
+
* Hook that allows to mutate the CM's edit view layout
|
846
|
+
* @constant
|
847
|
+
* @type {string}
|
848
|
+
*/
|
849
|
+
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
850
|
+
/**
|
851
|
+
* Hook that allows to mutate the CM's single types links pre-set filters
|
852
|
+
* @constant
|
853
|
+
* @type {string}
|
854
|
+
*/
|
855
|
+
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
856
|
+
};
|
857
|
+
const contentTypesApi = contentManagerApi.injectEndpoints({
|
858
|
+
endpoints: (builder) => ({
|
859
|
+
getContentTypeConfiguration: builder.query({
|
860
|
+
query: (uid) => ({
|
861
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
862
|
+
method: "GET"
|
863
|
+
}),
|
864
|
+
transformResponse: (response) => response.data,
|
865
|
+
providesTags: (_result, _error, uid) => [
|
866
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
867
|
+
{ type: "ContentTypeSettings", id: "LIST" }
|
868
|
+
]
|
869
|
+
}),
|
870
|
+
getAllContentTypeSettings: builder.query({
|
871
|
+
query: () => "/content-manager/content-types-settings",
|
872
|
+
transformResponse: (response) => response.data,
|
873
|
+
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
874
|
+
}),
|
875
|
+
updateContentTypeConfiguration: builder.mutation({
|
876
|
+
query: ({ uid, ...body }) => ({
|
877
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
878
|
+
method: "PUT",
|
879
|
+
data: body
|
880
|
+
}),
|
881
|
+
transformResponse: (response) => response.data,
|
882
|
+
invalidatesTags: (_result, _error, { uid }) => [
|
883
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
884
|
+
{ type: "ContentTypeSettings", id: "LIST" },
|
885
|
+
// Is this necessary?
|
886
|
+
{ type: "InitialData" }
|
887
|
+
]
|
888
|
+
})
|
889
|
+
})
|
890
|
+
});
|
891
|
+
const {
|
892
|
+
useGetContentTypeConfigurationQuery,
|
893
|
+
useGetAllContentTypeSettingsQuery,
|
894
|
+
useUpdateContentTypeConfigurationMutation
|
895
|
+
} = contentTypesApi;
|
896
|
+
const checkIfAttributeIsDisplayable = (attribute) => {
|
897
|
+
const { type } = attribute;
|
898
|
+
if (type === "relation") {
|
899
|
+
return !attribute.relation.toLowerCase().includes("morph");
|
900
|
+
}
|
901
|
+
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
902
|
+
};
|
903
|
+
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
904
|
+
if (!mainFieldName) {
|
905
|
+
return void 0;
|
906
|
+
}
|
907
|
+
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
908
|
+
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
909
|
+
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
910
|
+
);
|
911
|
+
return {
|
912
|
+
name: mainFieldName,
|
913
|
+
type: mainFieldType ?? "string"
|
914
|
+
};
|
915
|
+
};
|
916
|
+
const DEFAULT_SETTINGS = {
|
917
|
+
bulkable: false,
|
918
|
+
filterable: false,
|
919
|
+
searchable: false,
|
920
|
+
pagination: false,
|
921
|
+
defaultSortBy: "",
|
922
|
+
defaultSortOrder: "asc",
|
923
|
+
mainField: "id",
|
924
|
+
pageSize: 10
|
925
|
+
};
|
926
|
+
const useDocumentLayout = (model) => {
|
927
|
+
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
928
|
+
const [{ query }] = useQueryParams();
|
929
|
+
const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
759
930
|
const { toggleNotification } = useNotification();
|
760
931
|
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
932
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
761
933
|
const {
|
762
|
-
|
763
|
-
isLoading:
|
764
|
-
|
765
|
-
|
766
|
-
} =
|
767
|
-
const
|
934
|
+
data,
|
935
|
+
isLoading: isLoadingConfigs,
|
936
|
+
error,
|
937
|
+
isFetching: isFetchingConfigs
|
938
|
+
} = useGetContentTypeConfigurationQuery(model);
|
939
|
+
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
768
940
|
React.useEffect(() => {
|
769
941
|
if (error) {
|
770
942
|
toggleNotification({
|
@@ -772,40 +944,256 @@ const useDocument = (args, opts) => {
|
|
772
944
|
message: formatAPIError(error)
|
773
945
|
});
|
774
946
|
}
|
775
|
-
}, [
|
776
|
-
const
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
(document) => {
|
784
|
-
if (!validationSchema) {
|
785
|
-
throw new Error(
|
786
|
-
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
787
|
-
);
|
788
|
-
}
|
789
|
-
try {
|
790
|
-
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
791
|
-
return null;
|
792
|
-
} catch (error2) {
|
793
|
-
if (error2 instanceof ValidationError) {
|
794
|
-
return getYupValidationErrors(error2);
|
795
|
-
}
|
796
|
-
throw error2;
|
797
|
-
}
|
947
|
+
}, [error, formatAPIError, toggleNotification]);
|
948
|
+
const editLayout = React.useMemo(
|
949
|
+
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
950
|
+
layout: [],
|
951
|
+
components: {},
|
952
|
+
metadatas: {},
|
953
|
+
options: {},
|
954
|
+
settings: DEFAULT_SETTINGS
|
798
955
|
},
|
799
|
-
[
|
956
|
+
[data, isLoading, schemas, schema, components]
|
957
|
+
);
|
958
|
+
const listLayout = React.useMemo(() => {
|
959
|
+
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
960
|
+
layout: [],
|
961
|
+
metadatas: {},
|
962
|
+
options: {},
|
963
|
+
settings: DEFAULT_SETTINGS
|
964
|
+
};
|
965
|
+
}, [data, isLoading, schemas, schema, components]);
|
966
|
+
const { layout: edit } = React.useMemo(
|
967
|
+
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
968
|
+
layout: editLayout,
|
969
|
+
query
|
970
|
+
}),
|
971
|
+
[editLayout, query, runHookWaterfall]
|
800
972
|
);
|
801
|
-
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
802
973
|
return {
|
803
|
-
|
804
|
-
document: data?.data,
|
805
|
-
meta: data?.meta,
|
974
|
+
error,
|
806
975
|
isLoading,
|
807
|
-
|
808
|
-
|
976
|
+
edit,
|
977
|
+
list: listLayout
|
978
|
+
};
|
979
|
+
};
|
980
|
+
const useDocLayout = () => {
|
981
|
+
const { model } = useDoc();
|
982
|
+
return useDocumentLayout(model);
|
983
|
+
};
|
984
|
+
const formatEditLayout = (data, {
|
985
|
+
schemas,
|
986
|
+
schema,
|
987
|
+
components
|
988
|
+
}) => {
|
989
|
+
let currentPanelIndex = 0;
|
990
|
+
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
991
|
+
data.contentType.layouts.edit,
|
992
|
+
schema?.attributes,
|
993
|
+
data.contentType.metadatas,
|
994
|
+
{ configurations: data.components, schemas: components },
|
995
|
+
schemas
|
996
|
+
).reduce((panels, row) => {
|
997
|
+
if (row.some((field) => field.type === "dynamiczone")) {
|
998
|
+
panels.push([row]);
|
999
|
+
currentPanelIndex += 2;
|
1000
|
+
} else {
|
1001
|
+
if (!panels[currentPanelIndex]) {
|
1002
|
+
panels.push([row]);
|
1003
|
+
} else {
|
1004
|
+
panels[currentPanelIndex].push(row);
|
1005
|
+
}
|
1006
|
+
}
|
1007
|
+
return panels;
|
1008
|
+
}, []);
|
1009
|
+
const componentEditAttributes = Object.entries(data.components).reduce(
|
1010
|
+
(acc, [uid, configuration]) => {
|
1011
|
+
acc[uid] = {
|
1012
|
+
layout: convertEditLayoutToFieldLayouts(
|
1013
|
+
configuration.layouts.edit,
|
1014
|
+
components[uid].attributes,
|
1015
|
+
configuration.metadatas,
|
1016
|
+
{ configurations: data.components, schemas: components }
|
1017
|
+
),
|
1018
|
+
settings: {
|
1019
|
+
...configuration.settings,
|
1020
|
+
icon: components[uid].info.icon,
|
1021
|
+
displayName: components[uid].info.displayName
|
1022
|
+
}
|
1023
|
+
};
|
1024
|
+
return acc;
|
1025
|
+
},
|
1026
|
+
{}
|
1027
|
+
);
|
1028
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1029
|
+
(acc, [attribute, metadata]) => {
|
1030
|
+
return {
|
1031
|
+
...acc,
|
1032
|
+
[attribute]: metadata.edit
|
1033
|
+
};
|
1034
|
+
},
|
1035
|
+
{}
|
1036
|
+
);
|
1037
|
+
return {
|
1038
|
+
layout: panelledEditAttributes,
|
1039
|
+
components: componentEditAttributes,
|
1040
|
+
metadatas: editMetadatas,
|
1041
|
+
settings: {
|
1042
|
+
...data.contentType.settings,
|
1043
|
+
displayName: schema?.info.displayName
|
1044
|
+
},
|
1045
|
+
options: {
|
1046
|
+
...schema?.options,
|
1047
|
+
...schema?.pluginOptions,
|
1048
|
+
...data.contentType.options
|
1049
|
+
}
|
1050
|
+
};
|
1051
|
+
};
|
1052
|
+
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
1053
|
+
return rows.map(
|
1054
|
+
(row) => row.map((field) => {
|
1055
|
+
const attribute = attributes[field.name];
|
1056
|
+
if (!attribute) {
|
1057
|
+
return null;
|
1058
|
+
}
|
1059
|
+
const { edit: metadata } = metadatas[field.name];
|
1060
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1061
|
+
return {
|
1062
|
+
attribute,
|
1063
|
+
disabled: !metadata.editable,
|
1064
|
+
hint: metadata.description,
|
1065
|
+
label: metadata.label ?? "",
|
1066
|
+
name: field.name,
|
1067
|
+
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
1068
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1069
|
+
schemas,
|
1070
|
+
components: components?.schemas ?? {}
|
1071
|
+
}),
|
1072
|
+
placeholder: metadata.placeholder ?? "",
|
1073
|
+
required: attribute.required ?? false,
|
1074
|
+
size: field.size,
|
1075
|
+
unique: "unique" in attribute ? attribute.unique : false,
|
1076
|
+
visible: metadata.visible ?? true,
|
1077
|
+
type: attribute.type
|
1078
|
+
};
|
1079
|
+
}).filter((field) => field !== null)
|
1080
|
+
);
|
1081
|
+
};
|
1082
|
+
const formatListLayout = (data, {
|
1083
|
+
schemas,
|
1084
|
+
schema,
|
1085
|
+
components
|
1086
|
+
}) => {
|
1087
|
+
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1088
|
+
(acc, [attribute, metadata]) => {
|
1089
|
+
return {
|
1090
|
+
...acc,
|
1091
|
+
[attribute]: metadata.list
|
1092
|
+
};
|
1093
|
+
},
|
1094
|
+
{}
|
1095
|
+
);
|
1096
|
+
const listAttributes = convertListLayoutToFieldLayouts(
|
1097
|
+
data.contentType.layouts.list,
|
1098
|
+
schema?.attributes,
|
1099
|
+
listMetadatas,
|
1100
|
+
{ configurations: data.components, schemas: components },
|
1101
|
+
schemas
|
1102
|
+
);
|
1103
|
+
return {
|
1104
|
+
layout: listAttributes,
|
1105
|
+
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
1106
|
+
metadatas: listMetadatas,
|
1107
|
+
options: {
|
1108
|
+
...schema?.options,
|
1109
|
+
...schema?.pluginOptions,
|
1110
|
+
...data.contentType.options
|
1111
|
+
}
|
1112
|
+
};
|
1113
|
+
};
|
1114
|
+
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
1115
|
+
return columns.map((name) => {
|
1116
|
+
const attribute = attributes[name];
|
1117
|
+
if (!attribute) {
|
1118
|
+
return null;
|
1119
|
+
}
|
1120
|
+
const metadata = metadatas[name];
|
1121
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1122
|
+
return {
|
1123
|
+
attribute,
|
1124
|
+
label: metadata.label ?? "",
|
1125
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1126
|
+
schemas,
|
1127
|
+
components: components?.schemas ?? {}
|
1128
|
+
}),
|
1129
|
+
name,
|
1130
|
+
searchable: metadata.searchable ?? true,
|
1131
|
+
sortable: metadata.sortable ?? true
|
1132
|
+
};
|
1133
|
+
}).filter((field) => field !== null);
|
1134
|
+
};
|
1135
|
+
const useDocument = (args, opts) => {
|
1136
|
+
const { toggleNotification } = useNotification();
|
1137
|
+
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
1138
|
+
const {
|
1139
|
+
currentData: data,
|
1140
|
+
isLoading: isLoadingDocument,
|
1141
|
+
isFetching: isFetchingDocument,
|
1142
|
+
error
|
1143
|
+
} = useGetDocumentQuery(args, {
|
1144
|
+
...opts,
|
1145
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
1146
|
+
});
|
1147
|
+
const {
|
1148
|
+
components,
|
1149
|
+
schema,
|
1150
|
+
schemas,
|
1151
|
+
isLoading: isLoadingSchema
|
1152
|
+
} = useContentTypeSchema(args.model);
|
1153
|
+
React.useEffect(() => {
|
1154
|
+
if (error) {
|
1155
|
+
toggleNotification({
|
1156
|
+
type: "danger",
|
1157
|
+
message: formatAPIError(error)
|
1158
|
+
});
|
1159
|
+
}
|
1160
|
+
}, [toggleNotification, error, formatAPIError, args.collectionType]);
|
1161
|
+
const validationSchema = React.useMemo(() => {
|
1162
|
+
if (!schema) {
|
1163
|
+
return null;
|
1164
|
+
}
|
1165
|
+
return createYupSchema(schema.attributes, components);
|
1166
|
+
}, [schema, components]);
|
1167
|
+
const validate = React.useCallback(
|
1168
|
+
(document) => {
|
1169
|
+
if (!validationSchema) {
|
1170
|
+
throw new Error(
|
1171
|
+
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
1172
|
+
);
|
1173
|
+
}
|
1174
|
+
try {
|
1175
|
+
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
1176
|
+
return null;
|
1177
|
+
} catch (error2) {
|
1178
|
+
if (error2 instanceof ValidationError) {
|
1179
|
+
return getYupValidationErrors(error2);
|
1180
|
+
}
|
1181
|
+
throw error2;
|
1182
|
+
}
|
1183
|
+
},
|
1184
|
+
[validationSchema]
|
1185
|
+
);
|
1186
|
+
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
1187
|
+
const hasError = !!error;
|
1188
|
+
return {
|
1189
|
+
components,
|
1190
|
+
document: data?.data,
|
1191
|
+
meta: data?.meta,
|
1192
|
+
isLoading,
|
1193
|
+
hasError,
|
1194
|
+
schema,
|
1195
|
+
schemas,
|
1196
|
+
validate
|
809
1197
|
};
|
810
1198
|
};
|
811
1199
|
const useDoc = () => {
|
@@ -818,22 +1206,60 @@ const useDoc = () => {
|
|
818
1206
|
if (!slug) {
|
819
1207
|
throw new Error("Could not find model in url params");
|
820
1208
|
}
|
1209
|
+
const document = useDocument(
|
1210
|
+
{ documentId: origin || id, model: slug, collectionType, params },
|
1211
|
+
{
|
1212
|
+
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
1213
|
+
}
|
1214
|
+
);
|
1215
|
+
const returnId = origin || id === "create" ? void 0 : id;
|
821
1216
|
return {
|
822
1217
|
collectionType,
|
823
1218
|
model: slug,
|
824
|
-
id:
|
825
|
-
...
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
1219
|
+
id: returnId,
|
1220
|
+
...document
|
1221
|
+
};
|
1222
|
+
};
|
1223
|
+
const useContentManagerContext = () => {
|
1224
|
+
const {
|
1225
|
+
collectionType,
|
1226
|
+
model,
|
1227
|
+
id,
|
1228
|
+
components,
|
1229
|
+
isLoading: isLoadingDoc,
|
1230
|
+
schema,
|
1231
|
+
schemas
|
1232
|
+
} = useDoc();
|
1233
|
+
const layout = useDocumentLayout(model);
|
1234
|
+
const form = useForm("useContentManagerContext", (state) => state);
|
1235
|
+
const isSingleType = collectionType === SINGLE_TYPES;
|
1236
|
+
const slug = model;
|
1237
|
+
const isCreatingEntry = id === "create";
|
1238
|
+
useContentTypeSchema();
|
1239
|
+
const isLoading = isLoadingDoc || layout.isLoading;
|
1240
|
+
const error = layout.error;
|
1241
|
+
return {
|
1242
|
+
error,
|
1243
|
+
isLoading,
|
1244
|
+
// Base metadata
|
1245
|
+
model,
|
1246
|
+
collectionType,
|
1247
|
+
id,
|
1248
|
+
slug,
|
1249
|
+
isCreatingEntry,
|
1250
|
+
isSingleType,
|
1251
|
+
hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
|
1252
|
+
// All schema infos
|
1253
|
+
components,
|
1254
|
+
contentType: schema,
|
1255
|
+
contentTypes: schemas,
|
1256
|
+
// Form state
|
1257
|
+
form,
|
1258
|
+
// layout infos
|
1259
|
+
layout
|
831
1260
|
};
|
832
1261
|
};
|
833
1262
|
const prefixPluginTranslations = (trad, pluginId) => {
|
834
|
-
if (!pluginId) {
|
835
|
-
throw new TypeError("pluginId can't be empty");
|
836
|
-
}
|
837
1263
|
return Object.keys(trad).reduce((acc, current) => {
|
838
1264
|
acc[`${pluginId}.${current}`] = trad[current];
|
839
1265
|
return acc;
|
@@ -849,6 +1275,8 @@ const useDocumentActions = () => {
|
|
849
1275
|
const { formatMessage } = useIntl();
|
850
1276
|
const { trackUsage } = useTracking();
|
851
1277
|
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
1278
|
+
const navigate = useNavigate();
|
1279
|
+
const setCurrentStep = useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
|
852
1280
|
const [deleteDocument] = useDeleteDocumentMutation();
|
853
1281
|
const _delete = React.useCallback(
|
854
1282
|
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
@@ -1163,6 +1591,7 @@ const useDocumentActions = () => {
|
|
1163
1591
|
defaultMessage: "Saved document"
|
1164
1592
|
})
|
1165
1593
|
});
|
1594
|
+
setCurrentStep("contentManager.success");
|
1166
1595
|
return res.data;
|
1167
1596
|
} catch (err) {
|
1168
1597
|
toggleNotification({
|
@@ -1184,7 +1613,6 @@ const useDocumentActions = () => {
|
|
1184
1613
|
sourceId
|
1185
1614
|
});
|
1186
1615
|
if ("error" in res) {
|
1187
|
-
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1188
1616
|
return { error: res.error };
|
1189
1617
|
}
|
1190
1618
|
toggleNotification({
|
@@ -1203,7 +1631,7 @@ const useDocumentActions = () => {
|
|
1203
1631
|
throw err;
|
1204
1632
|
}
|
1205
1633
|
},
|
1206
|
-
[autoCloneDocument,
|
1634
|
+
[autoCloneDocument, formatMessage, toggleNotification]
|
1207
1635
|
);
|
1208
1636
|
const [cloneDocument] = useCloneDocumentMutation();
|
1209
1637
|
const clone = React.useCallback(
|
@@ -1229,6 +1657,7 @@ const useDocumentActions = () => {
|
|
1229
1657
|
defaultMessage: "Cloned document"
|
1230
1658
|
})
|
1231
1659
|
});
|
1660
|
+
navigate(`../../${res.data.data.documentId}`, { relative: "path" });
|
1232
1661
|
return res.data;
|
1233
1662
|
} catch (err) {
|
1234
1663
|
toggleNotification({
|
@@ -1239,7 +1668,7 @@ const useDocumentActions = () => {
|
|
1239
1668
|
throw err;
|
1240
1669
|
}
|
1241
1670
|
},
|
1242
|
-
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
|
1671
|
+
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
|
1243
1672
|
);
|
1244
1673
|
const [getDoc] = useLazyGetDocumentQuery();
|
1245
1674
|
const getDocument = React.useCallback(
|
@@ -1264,10 +1693,10 @@ const useDocumentActions = () => {
|
|
1264
1693
|
update
|
1265
1694
|
};
|
1266
1695
|
};
|
1267
|
-
const ProtectedHistoryPage = lazy(
|
1268
|
-
() => import("./History-
|
1696
|
+
const ProtectedHistoryPage = React.lazy(
|
1697
|
+
() => import("./History-04ChQ4pl.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1269
1698
|
);
|
1270
|
-
const routes$
|
1699
|
+
const routes$2 = [
|
1271
1700
|
{
|
1272
1701
|
path: ":collectionType/:slug/:id/history",
|
1273
1702
|
Component: ProtectedHistoryPage
|
@@ -1277,32 +1706,45 @@ const routes$1 = [
|
|
1277
1706
|
Component: ProtectedHistoryPage
|
1278
1707
|
}
|
1279
1708
|
];
|
1709
|
+
const ProtectedPreviewPage = React.lazy(
|
1710
|
+
() => import("./Preview-BMYN548c.mjs").then((mod) => ({ default: mod.ProtectedPreviewPage }))
|
1711
|
+
);
|
1712
|
+
const routes$1 = [
|
1713
|
+
{
|
1714
|
+
path: ":collectionType/:slug/:id/preview",
|
1715
|
+
Component: ProtectedPreviewPage
|
1716
|
+
},
|
1717
|
+
{
|
1718
|
+
path: ":collectionType/:slug/preview",
|
1719
|
+
Component: ProtectedPreviewPage
|
1720
|
+
}
|
1721
|
+
];
|
1280
1722
|
const ProtectedEditViewPage = lazy(
|
1281
|
-
() => import("./EditViewPage-
|
1723
|
+
() => import("./EditViewPage-BPyVuPfM.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1282
1724
|
);
|
1283
1725
|
const ProtectedListViewPage = lazy(
|
1284
|
-
() => import("./ListViewPage-
|
1726
|
+
() => import("./ListViewPage-FU2LBuhl.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1285
1727
|
);
|
1286
1728
|
const ProtectedListConfiguration = lazy(
|
1287
|
-
() => import("./ListConfigurationPage-
|
1729
|
+
() => import("./ListConfigurationPage-BYqPYLSU.mjs").then((mod) => ({
|
1288
1730
|
default: mod.ProtectedListConfiguration
|
1289
1731
|
}))
|
1290
1732
|
);
|
1291
1733
|
const ProtectedEditConfigurationPage = lazy(
|
1292
|
-
() => import("./EditConfigurationPage-
|
1734
|
+
() => import("./EditConfigurationPage-DsPR2DVk.mjs").then((mod) => ({
|
1293
1735
|
default: mod.ProtectedEditConfigurationPage
|
1294
1736
|
}))
|
1295
1737
|
);
|
1296
1738
|
const ProtectedComponentConfigurationPage = lazy(
|
1297
|
-
() => import("./ComponentConfigurationPage-
|
1739
|
+
() => import("./ComponentConfigurationPage-CtIa3aa2.mjs").then((mod) => ({
|
1298
1740
|
default: mod.ProtectedComponentConfigurationPage
|
1299
1741
|
}))
|
1300
1742
|
);
|
1301
1743
|
const NoPermissions = lazy(
|
1302
|
-
() => import("./NoPermissionsPage-
|
1744
|
+
() => import("./NoPermissionsPage-jqve7C8l.mjs").then((mod) => ({ default: mod.NoPermissions }))
|
1303
1745
|
);
|
1304
1746
|
const NoContentType = lazy(
|
1305
|
-
() => import("./NoContentTypePage-
|
1747
|
+
() => import("./NoContentTypePage-DCKUkwb8.mjs").then((mod) => ({ default: mod.NoContentType }))
|
1306
1748
|
);
|
1307
1749
|
const CollectionTypePages = () => {
|
1308
1750
|
const { collectionType } = useParams();
|
@@ -1314,7 +1756,7 @@ const CollectionTypePages = () => {
|
|
1314
1756
|
const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
|
1315
1757
|
const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
|
1316
1758
|
const LIST_RELATIVE_PATH = ":collectionType/:slug";
|
1317
|
-
const LIST_PATH = `/content-manager
|
1759
|
+
const LIST_PATH = `/content-manager/collection-types/:slug`;
|
1318
1760
|
const routes = [
|
1319
1761
|
{
|
1320
1762
|
path: LIST_RELATIVE_PATH,
|
@@ -1348,6 +1790,7 @@ const routes = [
|
|
1348
1790
|
path: "no-content-types",
|
1349
1791
|
Component: NoContentType
|
1350
1792
|
},
|
1793
|
+
...routes$2,
|
1351
1794
|
...routes$1
|
1352
1795
|
];
|
1353
1796
|
const DocumentActions = ({ actions: actions2 }) => {
|
@@ -1416,12 +1859,14 @@ const DocumentActionButton = (action) => {
|
|
1416
1859
|
/* @__PURE__ */ jsx(
|
1417
1860
|
Button,
|
1418
1861
|
{
|
1419
|
-
flex:
|
1862
|
+
flex: "auto",
|
1420
1863
|
startIcon: action.icon,
|
1421
1864
|
disabled: action.disabled,
|
1422
1865
|
onClick: handleClick(action),
|
1423
1866
|
justifyContent: "center",
|
1424
1867
|
variant: action.variant || "default",
|
1868
|
+
paddingTop: "7px",
|
1869
|
+
paddingBottom: "7px",
|
1425
1870
|
children: action.label
|
1426
1871
|
}
|
1427
1872
|
),
|
@@ -1429,7 +1874,7 @@ const DocumentActionButton = (action) => {
|
|
1429
1874
|
DocumentActionConfirmDialog,
|
1430
1875
|
{
|
1431
1876
|
...action.dialog,
|
1432
|
-
variant: action.variant,
|
1877
|
+
variant: action.dialog?.variant ?? action.variant,
|
1433
1878
|
isOpen: dialogId === action.id,
|
1434
1879
|
onClose: handleClose
|
1435
1880
|
}
|
@@ -1444,6 +1889,11 @@ const DocumentActionButton = (action) => {
|
|
1444
1889
|
) : null
|
1445
1890
|
] });
|
1446
1891
|
};
|
1892
|
+
const MenuItem = styled(Menu.Item)`
|
1893
|
+
&:hover {
|
1894
|
+
background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
|
1895
|
+
}
|
1896
|
+
`;
|
1447
1897
|
const DocumentActionsMenu = ({
|
1448
1898
|
actions: actions2,
|
1449
1899
|
children,
|
@@ -1486,9 +1936,9 @@ const DocumentActionsMenu = ({
|
|
1486
1936
|
disabled: isDisabled,
|
1487
1937
|
size: "S",
|
1488
1938
|
endIcon: null,
|
1489
|
-
paddingTop: "
|
1490
|
-
paddingLeft: "
|
1491
|
-
paddingRight: "
|
1939
|
+
paddingTop: "4px",
|
1940
|
+
paddingLeft: "7px",
|
1941
|
+
paddingRight: "7px",
|
1492
1942
|
variant,
|
1493
1943
|
children: [
|
1494
1944
|
/* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
|
@@ -1499,36 +1949,35 @@ const DocumentActionsMenu = ({
|
|
1499
1949
|
]
|
1500
1950
|
}
|
1501
1951
|
),
|
1502
|
-
/* @__PURE__ */ jsxs(Menu.Content, {
|
1952
|
+
/* @__PURE__ */ jsxs(Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
|
1503
1953
|
actions2.map((action) => {
|
1504
1954
|
return /* @__PURE__ */ jsx(
|
1505
|
-
|
1955
|
+
MenuItem,
|
1506
1956
|
{
|
1507
1957
|
disabled: action.disabled,
|
1508
1958
|
onSelect: handleClick(action),
|
1509
1959
|
display: "block",
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
] })
|
1960
|
+
isVariantDanger: action.variant === "danger",
|
1961
|
+
isDisabled: action.disabled,
|
1962
|
+
children: /* @__PURE__ */ jsx(Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxs(
|
1963
|
+
Flex,
|
1964
|
+
{
|
1965
|
+
color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
|
1966
|
+
gap: 2,
|
1967
|
+
tag: "span",
|
1968
|
+
children: [
|
1969
|
+
/* @__PURE__ */ jsx(
|
1970
|
+
Flex,
|
1971
|
+
{
|
1972
|
+
tag: "span",
|
1973
|
+
color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
|
1974
|
+
children: action.icon
|
1975
|
+
}
|
1976
|
+
),
|
1977
|
+
action.label
|
1978
|
+
]
|
1979
|
+
}
|
1980
|
+
) })
|
1532
1981
|
},
|
1533
1982
|
action.id
|
1534
1983
|
);
|
@@ -1570,14 +2019,26 @@ const convertActionVariantToColor = (variant = "secondary") => {
|
|
1570
2019
|
return "primary600";
|
1571
2020
|
}
|
1572
2021
|
};
|
1573
|
-
const
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
2022
|
+
const convertActionVariantToIconColor = (variant = "secondary") => {
|
2023
|
+
switch (variant) {
|
2024
|
+
case "danger":
|
2025
|
+
return "danger600";
|
2026
|
+
case "secondary":
|
2027
|
+
return "neutral500";
|
2028
|
+
case "success":
|
2029
|
+
return "success600";
|
2030
|
+
default:
|
2031
|
+
return "primary600";
|
2032
|
+
}
|
2033
|
+
};
|
2034
|
+
const DocumentActionConfirmDialog = ({
|
2035
|
+
onClose,
|
2036
|
+
onCancel,
|
2037
|
+
onConfirm,
|
2038
|
+
title,
|
2039
|
+
content,
|
2040
|
+
isOpen,
|
2041
|
+
variant = "secondary"
|
1581
2042
|
}) => {
|
1582
2043
|
const { formatMessage } = useIntl();
|
1583
2044
|
const handleClose = async () => {
|
@@ -1596,11 +2057,11 @@ const DocumentActionConfirmDialog = ({
|
|
1596
2057
|
/* @__PURE__ */ jsx(Dialog.Header, { children: title }),
|
1597
2058
|
/* @__PURE__ */ jsx(Dialog.Body, { children: content }),
|
1598
2059
|
/* @__PURE__ */ jsxs(Dialog.Footer, { children: [
|
1599
|
-
/* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: formatMessage({
|
2060
|
+
/* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
|
1600
2061
|
id: "app.components.Button.cancel",
|
1601
2062
|
defaultMessage: "Cancel"
|
1602
2063
|
}) }) }),
|
1603
|
-
/* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, children: formatMessage({
|
2064
|
+
/* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
|
1604
2065
|
id: "app.components.Button.confirm",
|
1605
2066
|
defaultMessage: "Confirm"
|
1606
2067
|
}) })
|
@@ -1627,6 +2088,18 @@ const DocumentActionModal = ({
|
|
1627
2088
|
typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
|
1628
2089
|
] }) });
|
1629
2090
|
};
|
2091
|
+
const transformData = (data) => {
|
2092
|
+
if (Array.isArray(data)) {
|
2093
|
+
return data.map(transformData);
|
2094
|
+
}
|
2095
|
+
if (typeof data === "object" && data !== null) {
|
2096
|
+
if ("apiData" in data) {
|
2097
|
+
return data.apiData;
|
2098
|
+
}
|
2099
|
+
return mapValues(transformData)(data);
|
2100
|
+
}
|
2101
|
+
return data;
|
2102
|
+
};
|
1630
2103
|
const PublishAction$1 = ({
|
1631
2104
|
activeTab,
|
1632
2105
|
documentId,
|
@@ -1639,13 +2112,18 @@ const PublishAction$1 = ({
|
|
1639
2112
|
const navigate = useNavigate();
|
1640
2113
|
const { toggleNotification } = useNotification();
|
1641
2114
|
const { _unstableFormatValidationErrors: formatValidationErrors } = useAPIErrorHandler();
|
2115
|
+
const isListView = useMatch(LIST_PATH) !== null;
|
1642
2116
|
const isCloning = useMatch(CLONE_PATH) !== null;
|
2117
|
+
const { id } = useParams();
|
1643
2118
|
const { formatMessage } = useIntl();
|
1644
|
-
const { canPublish
|
1645
|
-
"PublishAction",
|
1646
|
-
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1647
|
-
);
|
2119
|
+
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
1648
2120
|
const { publish } = useDocumentActions();
|
2121
|
+
const [
|
2122
|
+
countDraftRelations,
|
2123
|
+
{ isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }
|
2124
|
+
] = useLazyGetDraftRelationCountQuery();
|
2125
|
+
const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React.useState(0);
|
2126
|
+
const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React.useState(0);
|
1649
2127
|
const [{ query, rawQuery }] = useQueryParams();
|
1650
2128
|
const params = React.useMemo(() => buildValidParams(query), [query]);
|
1651
2129
|
const modified = useForm("PublishAction", ({ modified: modified2 }) => modified2);
|
@@ -1654,10 +2132,107 @@ const PublishAction$1 = ({
|
|
1654
2132
|
const validate = useForm("PublishAction", (state) => state.validate);
|
1655
2133
|
const setErrors = useForm("PublishAction", (state) => state.setErrors);
|
1656
2134
|
const formValues = useForm("PublishAction", ({ values }) => values);
|
2135
|
+
React.useEffect(() => {
|
2136
|
+
if (isErrorDraftRelations) {
|
2137
|
+
toggleNotification({
|
2138
|
+
type: "danger",
|
2139
|
+
message: formatMessage({
|
2140
|
+
id: getTranslation("error.records.fetch-draft-relatons"),
|
2141
|
+
defaultMessage: "An error occurred while fetching draft relations on this document."
|
2142
|
+
})
|
2143
|
+
});
|
2144
|
+
}
|
2145
|
+
}, [isErrorDraftRelations, toggleNotification, formatMessage]);
|
2146
|
+
React.useEffect(() => {
|
2147
|
+
const localDraftRelations = /* @__PURE__ */ new Set();
|
2148
|
+
const extractDraftRelations = (data) => {
|
2149
|
+
const relations = data.connect || [];
|
2150
|
+
relations.forEach((relation) => {
|
2151
|
+
if (relation.status === "draft") {
|
2152
|
+
localDraftRelations.add(relation.id);
|
2153
|
+
}
|
2154
|
+
});
|
2155
|
+
};
|
2156
|
+
const traverseAndExtract = (data) => {
|
2157
|
+
Object.entries(data).forEach(([key, value]) => {
|
2158
|
+
if (key === "connect" && Array.isArray(value)) {
|
2159
|
+
extractDraftRelations({ connect: value });
|
2160
|
+
} else if (typeof value === "object" && value !== null) {
|
2161
|
+
traverseAndExtract(value);
|
2162
|
+
}
|
2163
|
+
});
|
2164
|
+
};
|
2165
|
+
if (!documentId || modified) {
|
2166
|
+
traverseAndExtract(formValues);
|
2167
|
+
setLocalCountOfDraftRelations(localDraftRelations.size);
|
2168
|
+
}
|
2169
|
+
}, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
|
2170
|
+
React.useEffect(() => {
|
2171
|
+
if (!document || !document.documentId || isListView) {
|
2172
|
+
return;
|
2173
|
+
}
|
2174
|
+
const fetchDraftRelationsCount = async () => {
|
2175
|
+
const { data, error } = await countDraftRelations({
|
2176
|
+
collectionType,
|
2177
|
+
model,
|
2178
|
+
documentId,
|
2179
|
+
params
|
2180
|
+
});
|
2181
|
+
if (error) {
|
2182
|
+
throw error;
|
2183
|
+
}
|
2184
|
+
if (data) {
|
2185
|
+
setServerCountOfDraftRelations(data.data);
|
2186
|
+
}
|
2187
|
+
};
|
2188
|
+
fetchDraftRelationsCount();
|
2189
|
+
}, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
|
1657
2190
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1658
2191
|
if (!schema?.options?.draftAndPublish) {
|
1659
2192
|
return null;
|
1660
2193
|
}
|
2194
|
+
const performPublish = async () => {
|
2195
|
+
setSubmitting(true);
|
2196
|
+
try {
|
2197
|
+
const { errors } = await validate(true, {
|
2198
|
+
status: "published"
|
2199
|
+
});
|
2200
|
+
if (errors) {
|
2201
|
+
toggleNotification({
|
2202
|
+
type: "danger",
|
2203
|
+
message: formatMessage({
|
2204
|
+
id: "content-manager.validation.error",
|
2205
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
2206
|
+
})
|
2207
|
+
});
|
2208
|
+
return;
|
2209
|
+
}
|
2210
|
+
const res = await publish(
|
2211
|
+
{
|
2212
|
+
collectionType,
|
2213
|
+
model,
|
2214
|
+
documentId,
|
2215
|
+
params
|
2216
|
+
},
|
2217
|
+
transformData(formValues)
|
2218
|
+
);
|
2219
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
2220
|
+
if (id === "create") {
|
2221
|
+
navigate({
|
2222
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
2223
|
+
search: rawQuery
|
2224
|
+
});
|
2225
|
+
}
|
2226
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2227
|
+
setErrors(formatValidationErrors(res.error));
|
2228
|
+
}
|
2229
|
+
} finally {
|
2230
|
+
setSubmitting(false);
|
2231
|
+
}
|
2232
|
+
};
|
2233
|
+
const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
|
2234
|
+
const enableDraftRelationsCount = false;
|
2235
|
+
const hasDraftRelations = enableDraftRelationsCount;
|
1661
2236
|
return {
|
1662
2237
|
/**
|
1663
2238
|
* Disabled when:
|
@@ -1667,52 +2242,40 @@ const PublishAction$1 = ({
|
|
1667
2242
|
* - the document is already published & not modified
|
1668
2243
|
* - the document is being created & not modified
|
1669
2244
|
* - the user doesn't have the permission to publish
|
1670
|
-
* - the user doesn't have the permission to create a new document
|
1671
|
-
* - the user doesn't have the permission to update the document
|
1672
2245
|
*/
|
1673
|
-
disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish
|
2246
|
+
disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
|
1674
2247
|
label: formatMessage({
|
1675
2248
|
id: "app.utils.publish",
|
1676
2249
|
defaultMessage: "Publish"
|
1677
2250
|
}),
|
1678
2251
|
onClick: async () => {
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
documentId,
|
1697
|
-
params
|
1698
|
-
},
|
1699
|
-
formValues
|
1700
|
-
);
|
1701
|
-
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1702
|
-
navigate({
|
1703
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1704
|
-
search: rawQuery
|
1705
|
-
});
|
1706
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1707
|
-
setErrors(formatValidationErrors(res.error));
|
2252
|
+
await performPublish();
|
2253
|
+
},
|
2254
|
+
dialog: hasDraftRelations ? {
|
2255
|
+
type: "dialog",
|
2256
|
+
variant: "danger",
|
2257
|
+
footer: null,
|
2258
|
+
title: formatMessage({
|
2259
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.title`),
|
2260
|
+
defaultMessage: "Confirmation"
|
2261
|
+
}),
|
2262
|
+
content: formatMessage(
|
2263
|
+
{
|
2264
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
|
2265
|
+
defaultMessage: "This entry is related to {count, plural, one {# draft entry} other {# draft entries}}. Publishing it could leave broken links in your app."
|
2266
|
+
},
|
2267
|
+
{
|
2268
|
+
count: totalDraftRelations
|
1708
2269
|
}
|
1709
|
-
|
1710
|
-
|
2270
|
+
),
|
2271
|
+
onConfirm: async () => {
|
2272
|
+
await performPublish();
|
1711
2273
|
}
|
1712
|
-
}
|
2274
|
+
} : void 0
|
1713
2275
|
};
|
1714
2276
|
};
|
1715
2277
|
PublishAction$1.type = "publish";
|
2278
|
+
PublishAction$1.position = "panel";
|
1716
2279
|
const UpdateAction = ({
|
1717
2280
|
activeTab,
|
1718
2281
|
documentId,
|
@@ -1725,10 +2288,6 @@ const UpdateAction = ({
|
|
1725
2288
|
const cloneMatch = useMatch(CLONE_PATH);
|
1726
2289
|
const isCloning = cloneMatch !== null;
|
1727
2290
|
const { formatMessage } = useIntl();
|
1728
|
-
const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
|
1729
|
-
canCreate: canCreate2,
|
1730
|
-
canUpdate: canUpdate2
|
1731
|
-
}));
|
1732
2291
|
const { create, update, clone } = useDocumentActions();
|
1733
2292
|
const [{ query, rawQuery }] = useQueryParams();
|
1734
2293
|
const params = React.useMemo(() => buildValidParams(query), [query]);
|
@@ -1739,90 +2298,134 @@ const UpdateAction = ({
|
|
1739
2298
|
const validate = useForm("UpdateAction", (state) => state.validate);
|
1740
2299
|
const setErrors = useForm("UpdateAction", (state) => state.setErrors);
|
1741
2300
|
const resetForm = useForm("PublishAction", ({ resetForm: resetForm2 }) => resetForm2);
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
}
|
1768
|
-
|
1769
|
-
|
1770
|
-
if (
|
1771
|
-
|
2301
|
+
const handleUpdate = React.useCallback(async () => {
|
2302
|
+
setSubmitting(true);
|
2303
|
+
try {
|
2304
|
+
if (!modified) {
|
2305
|
+
return;
|
2306
|
+
}
|
2307
|
+
const { errors } = await validate(true, {
|
2308
|
+
status: "draft"
|
2309
|
+
});
|
2310
|
+
if (errors) {
|
2311
|
+
toggleNotification({
|
2312
|
+
type: "danger",
|
2313
|
+
message: formatMessage({
|
2314
|
+
id: "content-manager.validation.error",
|
2315
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
2316
|
+
})
|
2317
|
+
});
|
2318
|
+
return;
|
2319
|
+
}
|
2320
|
+
if (isCloning) {
|
2321
|
+
const res = await clone(
|
2322
|
+
{
|
2323
|
+
model,
|
2324
|
+
documentId: cloneMatch.params.origin,
|
2325
|
+
params
|
2326
|
+
},
|
2327
|
+
transformData(document)
|
2328
|
+
);
|
2329
|
+
if ("data" in res) {
|
2330
|
+
navigate(
|
1772
2331
|
{
|
1773
|
-
|
1774
|
-
documentId: cloneMatch.params.origin,
|
1775
|
-
params
|
1776
|
-
},
|
1777
|
-
document
|
1778
|
-
);
|
1779
|
-
if ("data" in res) {
|
1780
|
-
navigate({
|
1781
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
2332
|
+
pathname: `../${res.data.documentId}`,
|
1782
2333
|
search: rawQuery
|
1783
|
-
});
|
1784
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1785
|
-
setErrors(formatValidationErrors(res.error));
|
1786
|
-
}
|
1787
|
-
} else if (documentId || collectionType === SINGLE_TYPES) {
|
1788
|
-
const res = await update(
|
1789
|
-
{
|
1790
|
-
collectionType,
|
1791
|
-
model,
|
1792
|
-
documentId,
|
1793
|
-
params
|
1794
2334
|
},
|
1795
|
-
|
2335
|
+
{ relative: "path" }
|
1796
2336
|
);
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
2337
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2338
|
+
setErrors(formatValidationErrors(res.error));
|
2339
|
+
}
|
2340
|
+
} else if (documentId || collectionType === SINGLE_TYPES) {
|
2341
|
+
const res = await update(
|
2342
|
+
{
|
2343
|
+
collectionType,
|
2344
|
+
model,
|
2345
|
+
documentId,
|
2346
|
+
params
|
2347
|
+
},
|
2348
|
+
transformData(document)
|
2349
|
+
);
|
2350
|
+
if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2351
|
+
setErrors(formatValidationErrors(res.error));
|
1802
2352
|
} else {
|
1803
|
-
|
2353
|
+
resetForm();
|
2354
|
+
}
|
2355
|
+
} else {
|
2356
|
+
const res = await create(
|
2357
|
+
{
|
2358
|
+
model,
|
2359
|
+
params
|
2360
|
+
},
|
2361
|
+
transformData(document)
|
2362
|
+
);
|
2363
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
2364
|
+
navigate(
|
1804
2365
|
{
|
1805
|
-
|
1806
|
-
|
2366
|
+
pathname: `../${res.data.documentId}`,
|
2367
|
+
search: rawQuery
|
1807
2368
|
},
|
1808
|
-
|
2369
|
+
{ replace: true, relative: "path" }
|
1809
2370
|
);
|
1810
|
-
|
1811
|
-
|
1812
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1813
|
-
search: rawQuery
|
1814
|
-
});
|
1815
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1816
|
-
setErrors(formatValidationErrors(res.error));
|
1817
|
-
}
|
2371
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2372
|
+
setErrors(formatValidationErrors(res.error));
|
1818
2373
|
}
|
1819
|
-
} finally {
|
1820
|
-
setSubmitting(false);
|
1821
2374
|
}
|
2375
|
+
} finally {
|
2376
|
+
setSubmitting(false);
|
1822
2377
|
}
|
2378
|
+
}, [
|
2379
|
+
clone,
|
2380
|
+
cloneMatch?.params.origin,
|
2381
|
+
collectionType,
|
2382
|
+
create,
|
2383
|
+
document,
|
2384
|
+
documentId,
|
2385
|
+
formatMessage,
|
2386
|
+
formatValidationErrors,
|
2387
|
+
isCloning,
|
2388
|
+
model,
|
2389
|
+
modified,
|
2390
|
+
navigate,
|
2391
|
+
params,
|
2392
|
+
rawQuery,
|
2393
|
+
resetForm,
|
2394
|
+
setErrors,
|
2395
|
+
setSubmitting,
|
2396
|
+
toggleNotification,
|
2397
|
+
update,
|
2398
|
+
validate
|
2399
|
+
]);
|
2400
|
+
React.useEffect(() => {
|
2401
|
+
const handleKeyDown = (e) => {
|
2402
|
+
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
2403
|
+
e.preventDefault();
|
2404
|
+
handleUpdate();
|
2405
|
+
}
|
2406
|
+
};
|
2407
|
+
window.addEventListener("keydown", handleKeyDown);
|
2408
|
+
return () => {
|
2409
|
+
window.removeEventListener("keydown", handleKeyDown);
|
2410
|
+
};
|
2411
|
+
}, [handleUpdate]);
|
2412
|
+
return {
|
2413
|
+
/**
|
2414
|
+
* Disabled when:
|
2415
|
+
* - the form is submitting
|
2416
|
+
* - the document is not modified & we're not cloning (you can save a clone entity straight away)
|
2417
|
+
* - the active tab is the published tab
|
2418
|
+
*/
|
2419
|
+
disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
|
2420
|
+
label: formatMessage({
|
2421
|
+
id: "global.save",
|
2422
|
+
defaultMessage: "Save"
|
2423
|
+
}),
|
2424
|
+
onClick: handleUpdate
|
1823
2425
|
};
|
1824
2426
|
};
|
1825
2427
|
UpdateAction.type = "update";
|
2428
|
+
UpdateAction.position = "panel";
|
1826
2429
|
const UNPUBLISH_DRAFT_OPTIONS = {
|
1827
2430
|
KEEP: "keep",
|
1828
2431
|
DISCARD: "discard"
|
@@ -1855,7 +2458,7 @@ const UnpublishAction$1 = ({
|
|
1855
2458
|
id: "app.utils.unpublish",
|
1856
2459
|
defaultMessage: "Unpublish"
|
1857
2460
|
}),
|
1858
|
-
icon: /* @__PURE__ */ jsx(
|
2461
|
+
icon: /* @__PURE__ */ jsx(Cross, {}),
|
1859
2462
|
onClick: async () => {
|
1860
2463
|
if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
|
1861
2464
|
if (!documentId) {
|
@@ -1945,6 +2548,7 @@ const UnpublishAction$1 = ({
|
|
1945
2548
|
};
|
1946
2549
|
};
|
1947
2550
|
UnpublishAction$1.type = "unpublish";
|
2551
|
+
UnpublishAction$1.position = "panel";
|
1948
2552
|
const DiscardAction = ({
|
1949
2553
|
activeTab,
|
1950
2554
|
documentId,
|
@@ -1967,7 +2571,7 @@ const DiscardAction = ({
|
|
1967
2571
|
id: "content-manager.actions.discard.label",
|
1968
2572
|
defaultMessage: "Discard changes"
|
1969
2573
|
}),
|
1970
|
-
icon: /* @__PURE__ */ jsx(
|
2574
|
+
icon: /* @__PURE__ */ jsx(Cross, {}),
|
1971
2575
|
position: ["panel", "table-row"],
|
1972
2576
|
variant: "danger",
|
1973
2577
|
dialog: {
|
@@ -1995,11 +2599,7 @@ const DiscardAction = ({
|
|
1995
2599
|
};
|
1996
2600
|
};
|
1997
2601
|
DiscardAction.type = "discard";
|
1998
|
-
|
1999
|
-
path {
|
2000
|
-
fill: currentColor;
|
2001
|
-
}
|
2002
|
-
`;
|
2602
|
+
DiscardAction.position = "panel";
|
2003
2603
|
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
2004
2604
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
2005
2605
|
const RelativeTime = React.forwardRef(
|
@@ -2012,7 +2612,7 @@ const RelativeTime = React.forwardRef(
|
|
2012
2612
|
});
|
2013
2613
|
const unit = intervals.find((intervalUnit) => {
|
2014
2614
|
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
|
2015
|
-
});
|
2615
|
+
}) ?? "seconds";
|
2016
2616
|
const relativeTime = isPast(timestamp) ? -interval[unit] : interval[unit];
|
2017
2617
|
const customInterval = customIntervals.find(
|
2018
2618
|
(custom) => interval[custom.unit] < custom.threshold
|
@@ -2046,34 +2646,34 @@ const getDisplayName = ({
|
|
2046
2646
|
return email ?? "";
|
2047
2647
|
};
|
2048
2648
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2049
|
-
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2050
|
-
const statusVariant = status === "draft" ? "
|
2051
|
-
|
2649
|
+
const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
|
2650
|
+
const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
|
2651
|
+
const { formatMessage } = useIntl();
|
2652
|
+
return /* @__PURE__ */ jsx(Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
|
2653
|
+
id: `content-manager.containers.List.${status}`,
|
2654
|
+
defaultMessage: capitalise(status)
|
2655
|
+
}) }) });
|
2052
2656
|
};
|
2053
2657
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
2054
2658
|
const { formatMessage } = useIntl();
|
2055
2659
|
const isCloning = useMatch(CLONE_PATH) !== null;
|
2660
|
+
const params = useParams();
|
2056
2661
|
const title = isCreating ? formatMessage({
|
2057
2662
|
id: "content-manager.containers.edit.title.new",
|
2058
2663
|
defaultMessage: "Create an entry"
|
2059
2664
|
}) : documentTitle;
|
2060
|
-
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop:
|
2061
|
-
/* @__PURE__ */ jsx(
|
2062
|
-
|
2063
|
-
Flex,
|
2665
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2666
|
+
/* @__PURE__ */ jsx(
|
2667
|
+
BackButton,
|
2064
2668
|
{
|
2065
|
-
|
2066
|
-
justifyContent: "space-between",
|
2067
|
-
paddingTop: 1,
|
2068
|
-
gap: "80px",
|
2069
|
-
alignItems: "flex-start",
|
2070
|
-
children: [
|
2071
|
-
/* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
|
2072
|
-
/* @__PURE__ */ jsx(HeaderToolbar, {})
|
2073
|
-
]
|
2669
|
+
fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
|
2074
2670
|
}
|
2075
2671
|
),
|
2076
|
-
|
2672
|
+
/* @__PURE__ */ jsxs(Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2673
|
+
/* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
|
2674
|
+
/* @__PURE__ */ jsx(HeaderToolbar, {})
|
2675
|
+
] }),
|
2676
|
+
status ? /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
|
2077
2677
|
] });
|
2078
2678
|
};
|
2079
2679
|
const HeaderToolbar = () => {
|
@@ -2119,7 +2719,7 @@ const HeaderToolbar = () => {
|
|
2119
2719
|
meta: isCloning ? void 0 : meta,
|
2120
2720
|
collectionType
|
2121
2721
|
},
|
2122
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2722
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("header"),
|
2123
2723
|
children: (actions2) => {
|
2124
2724
|
const headerActions = actions2.filter((action) => {
|
2125
2725
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -2156,12 +2756,12 @@ const Information = ({ activeTab }) => {
|
|
2156
2756
|
isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
|
2157
2757
|
label: formatMessage({
|
2158
2758
|
id: "content-manager.containers.edit.information.last-published.label",
|
2159
|
-
defaultMessage: "
|
2759
|
+
defaultMessage: "Published"
|
2160
2760
|
}),
|
2161
2761
|
value: formatMessage(
|
2162
2762
|
{
|
2163
2763
|
id: "content-manager.containers.edit.information.last-published.value",
|
2164
|
-
defaultMessage: `
|
2764
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2165
2765
|
},
|
2166
2766
|
{
|
2167
2767
|
time: /* @__PURE__ */ jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
|
@@ -2174,12 +2774,12 @@ const Information = ({ activeTab }) => {
|
|
2174
2774
|
isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
|
2175
2775
|
label: formatMessage({
|
2176
2776
|
id: "content-manager.containers.edit.information.last-draft.label",
|
2177
|
-
defaultMessage: "
|
2777
|
+
defaultMessage: "Updated"
|
2178
2778
|
}),
|
2179
2779
|
value: formatMessage(
|
2180
2780
|
{
|
2181
2781
|
id: "content-manager.containers.edit.information.last-draft.value",
|
2182
|
-
defaultMessage: `
|
2782
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2183
2783
|
},
|
2184
2784
|
{
|
2185
2785
|
time: /* @__PURE__ */ jsx(
|
@@ -2197,12 +2797,12 @@ const Information = ({ activeTab }) => {
|
|
2197
2797
|
isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
|
2198
2798
|
label: formatMessage({
|
2199
2799
|
id: "content-manager.containers.edit.information.document.label",
|
2200
|
-
defaultMessage: "
|
2800
|
+
defaultMessage: "Created"
|
2201
2801
|
}),
|
2202
2802
|
value: formatMessage(
|
2203
2803
|
{
|
2204
2804
|
id: "content-manager.containers.edit.information.document.value",
|
2205
|
-
defaultMessage: `
|
2805
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2206
2806
|
},
|
2207
2807
|
{
|
2208
2808
|
time: /* @__PURE__ */ jsx(
|
@@ -2240,25 +2840,77 @@ const Information = ({ activeTab }) => {
|
|
2240
2840
|
);
|
2241
2841
|
};
|
2242
2842
|
const HeaderActions = ({ actions: actions2 }) => {
|
2243
|
-
|
2244
|
-
|
2843
|
+
const [dialogId, setDialogId] = React.useState(null);
|
2844
|
+
const handleClick = (action) => async (e) => {
|
2845
|
+
if (!("options" in action)) {
|
2846
|
+
const { onClick = () => false, dialog, id } = action;
|
2847
|
+
const muteDialog = await onClick(e);
|
2848
|
+
if (dialog && !muteDialog) {
|
2849
|
+
e.preventDefault();
|
2850
|
+
setDialogId(id);
|
2851
|
+
}
|
2852
|
+
}
|
2853
|
+
};
|
2854
|
+
const handleClose = () => {
|
2855
|
+
setDialogId(null);
|
2856
|
+
};
|
2857
|
+
return /* @__PURE__ */ jsx(Flex, { gap: 1, children: actions2.map((action) => {
|
2858
|
+
if (action.options) {
|
2245
2859
|
return /* @__PURE__ */ jsx(
|
2246
2860
|
SingleSelect,
|
2247
2861
|
{
|
2248
2862
|
size: "S",
|
2249
|
-
disabled: action.disabled,
|
2250
|
-
"aria-label": action.label,
|
2251
2863
|
onChange: action.onSelect,
|
2252
|
-
|
2864
|
+
"aria-label": action.label,
|
2865
|
+
...action,
|
2253
2866
|
children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsx(SingleSelectOption, { ...option, children: label }, option.value))
|
2254
2867
|
},
|
2255
2868
|
action.id
|
2256
2869
|
);
|
2257
2870
|
} else {
|
2258
|
-
|
2871
|
+
if (action.type === "icon") {
|
2872
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
2873
|
+
/* @__PURE__ */ jsx(
|
2874
|
+
IconButton,
|
2875
|
+
{
|
2876
|
+
disabled: action.disabled,
|
2877
|
+
label: action.label,
|
2878
|
+
size: "S",
|
2879
|
+
onClick: handleClick(action),
|
2880
|
+
children: action.icon
|
2881
|
+
}
|
2882
|
+
),
|
2883
|
+
action.dialog ? /* @__PURE__ */ jsx(
|
2884
|
+
HeaderActionDialog,
|
2885
|
+
{
|
2886
|
+
...action.dialog,
|
2887
|
+
isOpen: dialogId === action.id,
|
2888
|
+
onClose: handleClose
|
2889
|
+
}
|
2890
|
+
) : null
|
2891
|
+
] }, action.id);
|
2892
|
+
}
|
2259
2893
|
}
|
2260
2894
|
}) });
|
2261
2895
|
};
|
2896
|
+
const HeaderActionDialog = ({
|
2897
|
+
onClose,
|
2898
|
+
onCancel,
|
2899
|
+
title,
|
2900
|
+
content: Content,
|
2901
|
+
isOpen
|
2902
|
+
}) => {
|
2903
|
+
const handleClose = async () => {
|
2904
|
+
if (onCancel) {
|
2905
|
+
await onCancel();
|
2906
|
+
}
|
2907
|
+
onClose();
|
2908
|
+
};
|
2909
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
2910
|
+
/* @__PURE__ */ jsx(Dialog.Header, { children: title }),
|
2911
|
+
typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : Content
|
2912
|
+
] }) });
|
2913
|
+
};
|
2262
2914
|
const ConfigureTheViewAction = ({ collectionType, model }) => {
|
2263
2915
|
const navigate = useNavigate();
|
2264
2916
|
const { formatMessage } = useIntl();
|
@@ -2275,6 +2927,7 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
|
|
2275
2927
|
};
|
2276
2928
|
};
|
2277
2929
|
ConfigureTheViewAction.type = "configure-the-view";
|
2930
|
+
ConfigureTheViewAction.position = "header";
|
2278
2931
|
const EditTheModelAction = ({ model }) => {
|
2279
2932
|
const navigate = useNavigate();
|
2280
2933
|
const { formatMessage } = useIntl();
|
@@ -2291,6 +2944,7 @@ const EditTheModelAction = ({ model }) => {
|
|
2291
2944
|
};
|
2292
2945
|
};
|
2293
2946
|
EditTheModelAction.type = "edit-the-model";
|
2947
|
+
EditTheModelAction.position = "header";
|
2294
2948
|
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2295
2949
|
const navigate = useNavigate();
|
2296
2950
|
const { formatMessage } = useIntl();
|
@@ -2299,12 +2953,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2299
2953
|
const { delete: deleteAction } = useDocumentActions();
|
2300
2954
|
const { toggleNotification } = useNotification();
|
2301
2955
|
const setSubmitting = useForm("DeleteAction", (state) => state.setSubmitting);
|
2956
|
+
const isLocalized = document?.locale != null;
|
2302
2957
|
return {
|
2303
2958
|
disabled: !canDelete || !document,
|
2304
|
-
label: formatMessage(
|
2305
|
-
|
2306
|
-
|
2307
|
-
|
2959
|
+
label: formatMessage(
|
2960
|
+
{
|
2961
|
+
id: "content-manager.actions.delete.label",
|
2962
|
+
defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
|
2963
|
+
},
|
2964
|
+
{ isLocalized }
|
2965
|
+
),
|
2308
2966
|
icon: /* @__PURE__ */ jsx(Trash, {}),
|
2309
2967
|
dialog: {
|
2310
2968
|
type: "dialog",
|
@@ -2360,403 +3018,102 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2360
3018
|
};
|
2361
3019
|
};
|
2362
3020
|
DeleteAction$1.type = "delete";
|
3021
|
+
DeleteAction$1.position = ["header", "table-row"];
|
2363
3022
|
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2364
3023
|
const Panels = () => {
|
2365
3024
|
const isCloning = useMatch(CLONE_PATH) !== null;
|
2366
3025
|
const [
|
2367
3026
|
{
|
2368
|
-
query: { status }
|
2369
|
-
}
|
2370
|
-
] = useQueryParams({
|
2371
|
-
status: "draft"
|
2372
|
-
});
|
2373
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2374
|
-
const plugins = useStrapiApp("Panels", (state) => state.plugins);
|
2375
|
-
const props = {
|
2376
|
-
activeTab: status,
|
2377
|
-
model,
|
2378
|
-
documentId: id,
|
2379
|
-
document: isCloning ? void 0 : document,
|
2380
|
-
meta: isCloning ? void 0 : meta,
|
2381
|
-
collectionType
|
2382
|
-
};
|
2383
|
-
return /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsx(
|
2384
|
-
DescriptionComponentRenderer,
|
2385
|
-
{
|
2386
|
-
props,
|
2387
|
-
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
2388
|
-
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsx(Panel, { ...description, children: content }, id2))
|
2389
|
-
}
|
2390
|
-
) });
|
2391
|
-
};
|
2392
|
-
const ActionsPanel = () => {
|
2393
|
-
const { formatMessage } = useIntl();
|
2394
|
-
return {
|
2395
|
-
title: formatMessage({
|
2396
|
-
id: "content-manager.containers.edit.panels.default.title",
|
2397
|
-
defaultMessage: "Document"
|
2398
|
-
}),
|
2399
|
-
content: /* @__PURE__ */ jsx(ActionsPanelContent, {})
|
2400
|
-
};
|
2401
|
-
};
|
2402
|
-
ActionsPanel.type = "actions";
|
2403
|
-
const ActionsPanelContent = () => {
|
2404
|
-
const isCloning = useMatch(CLONE_PATH) !== null;
|
2405
|
-
const [
|
2406
|
-
{
|
2407
|
-
query: { status = "draft" }
|
2408
|
-
}
|
2409
|
-
] = useQueryParams();
|
2410
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2411
|
-
const plugins = useStrapiApp("ActionsPanel", (state) => state.plugins);
|
2412
|
-
const props = {
|
2413
|
-
activeTab: status,
|
2414
|
-
model,
|
2415
|
-
documentId: id,
|
2416
|
-
document: isCloning ? void 0 : document,
|
2417
|
-
meta: isCloning ? void 0 : meta,
|
2418
|
-
collectionType
|
2419
|
-
};
|
2420
|
-
return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, width: "100%", children: [
|
2421
|
-
/* @__PURE__ */ jsx(
|
2422
|
-
DescriptionComponentRenderer,
|
2423
|
-
{
|
2424
|
-
props,
|
2425
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2426
|
-
children: (actions2) => /* @__PURE__ */ jsx(DocumentActions, { actions: actions2 })
|
2427
|
-
}
|
2428
|
-
),
|
2429
|
-
/* @__PURE__ */ jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
2430
|
-
] });
|
2431
|
-
};
|
2432
|
-
const Panel = React.forwardRef(({ children, title }, ref) => {
|
2433
|
-
return /* @__PURE__ */ jsxs(
|
2434
|
-
Flex,
|
2435
|
-
{
|
2436
|
-
ref,
|
2437
|
-
tag: "aside",
|
2438
|
-
"aria-labelledby": "additional-information",
|
2439
|
-
background: "neutral0",
|
2440
|
-
borderColor: "neutral150",
|
2441
|
-
hasRadius: true,
|
2442
|
-
paddingBottom: 4,
|
2443
|
-
paddingLeft: 4,
|
2444
|
-
paddingRight: 4,
|
2445
|
-
paddingTop: 4,
|
2446
|
-
shadow: "tableShadow",
|
2447
|
-
gap: 3,
|
2448
|
-
direction: "column",
|
2449
|
-
justifyContent: "stretch",
|
2450
|
-
alignItems: "flex-start",
|
2451
|
-
children: [
|
2452
|
-
/* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
|
2453
|
-
children
|
2454
|
-
]
|
2455
|
-
}
|
2456
|
-
);
|
2457
|
-
});
|
2458
|
-
const HOOKS = {
|
2459
|
-
/**
|
2460
|
-
* Hook that allows to mutate the displayed headers of the list view table
|
2461
|
-
* @constant
|
2462
|
-
* @type {string}
|
2463
|
-
*/
|
2464
|
-
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
2465
|
-
/**
|
2466
|
-
* Hook that allows to mutate the CM's collection types links pre-set filters
|
2467
|
-
* @constant
|
2468
|
-
* @type {string}
|
2469
|
-
*/
|
2470
|
-
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
2471
|
-
/**
|
2472
|
-
* Hook that allows to mutate the CM's edit view layout
|
2473
|
-
* @constant
|
2474
|
-
* @type {string}
|
2475
|
-
*/
|
2476
|
-
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
2477
|
-
/**
|
2478
|
-
* Hook that allows to mutate the CM's single types links pre-set filters
|
2479
|
-
* @constant
|
2480
|
-
* @type {string}
|
2481
|
-
*/
|
2482
|
-
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
2483
|
-
};
|
2484
|
-
const contentTypesApi = contentManagerApi.injectEndpoints({
|
2485
|
-
endpoints: (builder) => ({
|
2486
|
-
getContentTypeConfiguration: builder.query({
|
2487
|
-
query: (uid) => ({
|
2488
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2489
|
-
method: "GET"
|
2490
|
-
}),
|
2491
|
-
transformResponse: (response) => response.data,
|
2492
|
-
providesTags: (_result, _error, uid) => [
|
2493
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2494
|
-
{ type: "ContentTypeSettings", id: "LIST" }
|
2495
|
-
]
|
2496
|
-
}),
|
2497
|
-
getAllContentTypeSettings: builder.query({
|
2498
|
-
query: () => "/content-manager/content-types-settings",
|
2499
|
-
transformResponse: (response) => response.data,
|
2500
|
-
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
2501
|
-
}),
|
2502
|
-
updateContentTypeConfiguration: builder.mutation({
|
2503
|
-
query: ({ uid, ...body }) => ({
|
2504
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2505
|
-
method: "PUT",
|
2506
|
-
data: body
|
2507
|
-
}),
|
2508
|
-
transformResponse: (response) => response.data,
|
2509
|
-
invalidatesTags: (_result, _error, { uid }) => [
|
2510
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2511
|
-
{ type: "ContentTypeSettings", id: "LIST" },
|
2512
|
-
// Is this necessary?
|
2513
|
-
{ type: "InitialData" }
|
2514
|
-
]
|
2515
|
-
})
|
2516
|
-
})
|
2517
|
-
});
|
2518
|
-
const {
|
2519
|
-
useGetContentTypeConfigurationQuery,
|
2520
|
-
useGetAllContentTypeSettingsQuery,
|
2521
|
-
useUpdateContentTypeConfigurationMutation
|
2522
|
-
} = contentTypesApi;
|
2523
|
-
const checkIfAttributeIsDisplayable = (attribute) => {
|
2524
|
-
const { type } = attribute;
|
2525
|
-
if (type === "relation") {
|
2526
|
-
return !attribute.relation.toLowerCase().includes("morph");
|
2527
|
-
}
|
2528
|
-
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
2529
|
-
};
|
2530
|
-
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
2531
|
-
if (!mainFieldName) {
|
2532
|
-
return void 0;
|
2533
|
-
}
|
2534
|
-
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
2535
|
-
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
2536
|
-
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2537
|
-
);
|
2538
|
-
return {
|
2539
|
-
name: mainFieldName,
|
2540
|
-
type: mainFieldType ?? "string"
|
2541
|
-
};
|
2542
|
-
};
|
2543
|
-
const DEFAULT_SETTINGS = {
|
2544
|
-
bulkable: false,
|
2545
|
-
filterable: false,
|
2546
|
-
searchable: false,
|
2547
|
-
pagination: false,
|
2548
|
-
defaultSortBy: "",
|
2549
|
-
defaultSortOrder: "asc",
|
2550
|
-
mainField: "id",
|
2551
|
-
pageSize: 10
|
2552
|
-
};
|
2553
|
-
const useDocumentLayout = (model) => {
|
2554
|
-
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
2555
|
-
const [{ query }] = useQueryParams();
|
2556
|
-
const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
2557
|
-
const { toggleNotification } = useNotification();
|
2558
|
-
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
2559
|
-
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
2560
|
-
const {
|
2561
|
-
data,
|
2562
|
-
isLoading: isLoadingConfigs,
|
2563
|
-
error,
|
2564
|
-
isFetching: isFetchingConfigs
|
2565
|
-
} = useGetContentTypeConfigurationQuery(model);
|
2566
|
-
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
2567
|
-
React.useEffect(() => {
|
2568
|
-
if (error) {
|
2569
|
-
toggleNotification({
|
2570
|
-
type: "danger",
|
2571
|
-
message: formatAPIError(error)
|
2572
|
-
});
|
2573
|
-
}
|
2574
|
-
}, [error, formatAPIError, toggleNotification]);
|
2575
|
-
const editLayout = React.useMemo(
|
2576
|
-
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
2577
|
-
layout: [],
|
2578
|
-
components: {},
|
2579
|
-
metadatas: {},
|
2580
|
-
options: {},
|
2581
|
-
settings: DEFAULT_SETTINGS
|
2582
|
-
},
|
2583
|
-
[data, isLoading, schemas, schema, components]
|
2584
|
-
);
|
2585
|
-
const listLayout = React.useMemo(() => {
|
2586
|
-
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
2587
|
-
layout: [],
|
2588
|
-
metadatas: {},
|
2589
|
-
options: {},
|
2590
|
-
settings: DEFAULT_SETTINGS
|
2591
|
-
};
|
2592
|
-
}, [data, isLoading, schemas, schema, components]);
|
2593
|
-
const { layout: edit } = React.useMemo(
|
2594
|
-
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
2595
|
-
layout: editLayout,
|
2596
|
-
query
|
2597
|
-
}),
|
2598
|
-
[editLayout, query, runHookWaterfall]
|
2599
|
-
);
|
2600
|
-
return {
|
2601
|
-
error,
|
2602
|
-
isLoading,
|
2603
|
-
edit,
|
2604
|
-
list: listLayout
|
2605
|
-
};
|
2606
|
-
};
|
2607
|
-
const useDocLayout = () => {
|
2608
|
-
const { model } = useDoc();
|
2609
|
-
return useDocumentLayout(model);
|
2610
|
-
};
|
2611
|
-
const formatEditLayout = (data, {
|
2612
|
-
schemas,
|
2613
|
-
schema,
|
2614
|
-
components
|
2615
|
-
}) => {
|
2616
|
-
let currentPanelIndex = 0;
|
2617
|
-
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
2618
|
-
data.contentType.layouts.edit,
|
2619
|
-
schema?.attributes,
|
2620
|
-
data.contentType.metadatas,
|
2621
|
-
{ configurations: data.components, schemas: components },
|
2622
|
-
schemas
|
2623
|
-
).reduce((panels, row) => {
|
2624
|
-
if (row.some((field) => field.type === "dynamiczone")) {
|
2625
|
-
panels.push([row]);
|
2626
|
-
currentPanelIndex += 2;
|
2627
|
-
} else {
|
2628
|
-
if (!panels[currentPanelIndex]) {
|
2629
|
-
panels.push([]);
|
2630
|
-
}
|
2631
|
-
panels[currentPanelIndex].push(row);
|
2632
|
-
}
|
2633
|
-
return panels;
|
2634
|
-
}, []);
|
2635
|
-
const componentEditAttributes = Object.entries(data.components).reduce(
|
2636
|
-
(acc, [uid, configuration]) => {
|
2637
|
-
acc[uid] = {
|
2638
|
-
layout: convertEditLayoutToFieldLayouts(
|
2639
|
-
configuration.layouts.edit,
|
2640
|
-
components[uid].attributes,
|
2641
|
-
configuration.metadatas
|
2642
|
-
),
|
2643
|
-
settings: {
|
2644
|
-
...configuration.settings,
|
2645
|
-
icon: components[uid].info.icon,
|
2646
|
-
displayName: components[uid].info.displayName
|
2647
|
-
}
|
2648
|
-
};
|
2649
|
-
return acc;
|
2650
|
-
},
|
2651
|
-
{}
|
2652
|
-
);
|
2653
|
-
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2654
|
-
(acc, [attribute, metadata]) => {
|
2655
|
-
return {
|
2656
|
-
...acc,
|
2657
|
-
[attribute]: metadata.edit
|
2658
|
-
};
|
2659
|
-
},
|
2660
|
-
{}
|
2661
|
-
);
|
2662
|
-
return {
|
2663
|
-
layout: panelledEditAttributes,
|
2664
|
-
components: componentEditAttributes,
|
2665
|
-
metadatas: editMetadatas,
|
2666
|
-
settings: {
|
2667
|
-
...data.contentType.settings,
|
2668
|
-
displayName: schema?.info.displayName
|
2669
|
-
},
|
2670
|
-
options: {
|
2671
|
-
...schema?.options,
|
2672
|
-
...schema?.pluginOptions,
|
2673
|
-
...data.contentType.options
|
3027
|
+
query: { status }
|
2674
3028
|
}
|
3029
|
+
] = useQueryParams({
|
3030
|
+
status: "draft"
|
3031
|
+
});
|
3032
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
3033
|
+
const plugins = useStrapiApp("Panels", (state) => state.plugins);
|
3034
|
+
const props = {
|
3035
|
+
activeTab: status,
|
3036
|
+
model,
|
3037
|
+
documentId: id,
|
3038
|
+
document: isCloning ? void 0 : document,
|
3039
|
+
meta: isCloning ? void 0 : meta,
|
3040
|
+
collectionType
|
2675
3041
|
};
|
3042
|
+
return /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsx(
|
3043
|
+
DescriptionComponentRenderer,
|
3044
|
+
{
|
3045
|
+
props,
|
3046
|
+
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
3047
|
+
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsx(Panel, { ...description, children: content }, id2))
|
3048
|
+
}
|
3049
|
+
) });
|
2676
3050
|
};
|
2677
|
-
const
|
2678
|
-
|
2679
|
-
(row) => row.map((field) => {
|
2680
|
-
const attribute = attributes[field.name];
|
2681
|
-
if (!attribute) {
|
2682
|
-
return null;
|
2683
|
-
}
|
2684
|
-
const { edit: metadata } = metadatas[field.name];
|
2685
|
-
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
2686
|
-
return {
|
2687
|
-
attribute,
|
2688
|
-
disabled: !metadata.editable,
|
2689
|
-
hint: metadata.description,
|
2690
|
-
label: metadata.label ?? "",
|
2691
|
-
name: field.name,
|
2692
|
-
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
2693
|
-
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
2694
|
-
schemas,
|
2695
|
-
components: components?.schemas ?? {}
|
2696
|
-
}),
|
2697
|
-
placeholder: metadata.placeholder ?? "",
|
2698
|
-
required: attribute.required ?? false,
|
2699
|
-
size: field.size,
|
2700
|
-
unique: "unique" in attribute ? attribute.unique : false,
|
2701
|
-
visible: metadata.visible ?? true,
|
2702
|
-
type: attribute.type
|
2703
|
-
};
|
2704
|
-
}).filter((field) => field !== null)
|
2705
|
-
);
|
2706
|
-
};
|
2707
|
-
const formatListLayout = (data, {
|
2708
|
-
schemas,
|
2709
|
-
schema,
|
2710
|
-
components
|
2711
|
-
}) => {
|
2712
|
-
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2713
|
-
(acc, [attribute, metadata]) => {
|
2714
|
-
return {
|
2715
|
-
...acc,
|
2716
|
-
[attribute]: metadata.list
|
2717
|
-
};
|
2718
|
-
},
|
2719
|
-
{}
|
2720
|
-
);
|
2721
|
-
const listAttributes = convertListLayoutToFieldLayouts(
|
2722
|
-
data.contentType.layouts.list,
|
2723
|
-
schema?.attributes,
|
2724
|
-
listMetadatas,
|
2725
|
-
{ configurations: data.components, schemas: components },
|
2726
|
-
schemas
|
2727
|
-
);
|
3051
|
+
const ActionsPanel = () => {
|
3052
|
+
const { formatMessage } = useIntl();
|
2728
3053
|
return {
|
2729
|
-
|
2730
|
-
|
2731
|
-
|
2732
|
-
|
2733
|
-
|
2734
|
-
...schema?.pluginOptions,
|
2735
|
-
...data.contentType.options
|
2736
|
-
}
|
3054
|
+
title: formatMessage({
|
3055
|
+
id: "content-manager.containers.edit.panels.default.title",
|
3056
|
+
defaultMessage: "Entry"
|
3057
|
+
}),
|
3058
|
+
content: /* @__PURE__ */ jsx(ActionsPanelContent, {})
|
2737
3059
|
};
|
2738
3060
|
};
|
2739
|
-
|
2740
|
-
|
2741
|
-
|
2742
|
-
|
2743
|
-
|
3061
|
+
ActionsPanel.type = "actions";
|
3062
|
+
const ActionsPanelContent = () => {
|
3063
|
+
const isCloning = useMatch(CLONE_PATH) !== null;
|
3064
|
+
const [
|
3065
|
+
{
|
3066
|
+
query: { status = "draft" }
|
2744
3067
|
}
|
2745
|
-
|
2746
|
-
|
2747
|
-
|
2748
|
-
|
2749
|
-
|
2750
|
-
|
2751
|
-
|
2752
|
-
|
2753
|
-
|
2754
|
-
|
2755
|
-
|
2756
|
-
|
2757
|
-
|
2758
|
-
|
3068
|
+
] = useQueryParams();
|
3069
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
3070
|
+
const plugins = useStrapiApp("ActionsPanel", (state) => state.plugins);
|
3071
|
+
const props = {
|
3072
|
+
activeTab: status,
|
3073
|
+
model,
|
3074
|
+
documentId: id,
|
3075
|
+
document: isCloning ? void 0 : document,
|
3076
|
+
meta: isCloning ? void 0 : meta,
|
3077
|
+
collectionType
|
3078
|
+
};
|
3079
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, width: "100%", children: [
|
3080
|
+
/* @__PURE__ */ jsx(
|
3081
|
+
DescriptionComponentRenderer,
|
3082
|
+
{
|
3083
|
+
props,
|
3084
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("panel"),
|
3085
|
+
children: (actions2) => /* @__PURE__ */ jsx(DocumentActions, { actions: actions2 })
|
3086
|
+
}
|
3087
|
+
),
|
3088
|
+
/* @__PURE__ */ jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
3089
|
+
] });
|
2759
3090
|
};
|
3091
|
+
const Panel = React.forwardRef(({ children, title }, ref) => {
|
3092
|
+
return /* @__PURE__ */ jsxs(
|
3093
|
+
Flex,
|
3094
|
+
{
|
3095
|
+
ref,
|
3096
|
+
tag: "aside",
|
3097
|
+
"aria-labelledby": "additional-information",
|
3098
|
+
background: "neutral0",
|
3099
|
+
borderColor: "neutral150",
|
3100
|
+
hasRadius: true,
|
3101
|
+
paddingBottom: 4,
|
3102
|
+
paddingLeft: 4,
|
3103
|
+
paddingRight: 4,
|
3104
|
+
paddingTop: 4,
|
3105
|
+
shadow: "tableShadow",
|
3106
|
+
gap: 3,
|
3107
|
+
direction: "column",
|
3108
|
+
justifyContent: "stretch",
|
3109
|
+
alignItems: "flex-start",
|
3110
|
+
children: [
|
3111
|
+
/* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
|
3112
|
+
children
|
3113
|
+
]
|
3114
|
+
}
|
3115
|
+
);
|
3116
|
+
});
|
2760
3117
|
const ConfirmBulkActionDialog = ({
|
2761
3118
|
onToggleDialog,
|
2762
3119
|
isOpen = false,
|
@@ -2764,7 +3121,7 @@ const ConfirmBulkActionDialog = ({
|
|
2764
3121
|
endAction
|
2765
3122
|
}) => {
|
2766
3123
|
const { formatMessage } = useIntl();
|
2767
|
-
return /* @__PURE__ */ jsx(Dialog.Root, {
|
3124
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
2768
3125
|
/* @__PURE__ */ jsx(Dialog.Header, { children: formatMessage({
|
2769
3126
|
id: "app.components.ConfirmDialog.title",
|
2770
3127
|
defaultMessage: "Confirmation"
|
@@ -2795,6 +3152,7 @@ const ConfirmDialogPublishAll = ({
|
|
2795
3152
|
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler(getTranslation);
|
2796
3153
|
const { model, schema } = useDoc();
|
2797
3154
|
const [{ query }] = useQueryParams();
|
3155
|
+
const enableDraftRelationsCount = false;
|
2798
3156
|
const {
|
2799
3157
|
data: countDraftRelations = 0,
|
2800
3158
|
isLoading,
|
@@ -2806,7 +3164,7 @@ const ConfirmDialogPublishAll = ({
|
|
2806
3164
|
locale: query?.plugins?.i18n?.locale
|
2807
3165
|
},
|
2808
3166
|
{
|
2809
|
-
skip:
|
3167
|
+
skip: !enableDraftRelationsCount
|
2810
3168
|
}
|
2811
3169
|
);
|
2812
3170
|
React.useEffect(() => {
|
@@ -2885,7 +3243,14 @@ const formatErrorMessages = (errors, parentKey, formatMessage) => {
|
|
2885
3243
|
)
|
2886
3244
|
);
|
2887
3245
|
} else {
|
2888
|
-
messages.push(
|
3246
|
+
messages.push(
|
3247
|
+
...formatErrorMessages(
|
3248
|
+
// @ts-expect-error TODO: check why value is not compatible with FormErrors
|
3249
|
+
value,
|
3250
|
+
currentKey,
|
3251
|
+
formatMessage
|
3252
|
+
)
|
3253
|
+
);
|
2889
3254
|
}
|
2890
3255
|
} else {
|
2891
3256
|
messages.push(
|
@@ -2984,7 +3349,7 @@ const SelectedEntriesTableContent = ({
|
|
2984
3349
|
status: row.status
|
2985
3350
|
}
|
2986
3351
|
) }),
|
2987
|
-
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(
|
3352
|
+
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(
|
2988
3353
|
IconButton,
|
2989
3354
|
{
|
2990
3355
|
tag: Link,
|
@@ -2993,23 +3358,16 @@ const SelectedEntriesTableContent = ({
|
|
2993
3358
|
search: row.locale && `?plugins[i18n][locale]=${row.locale}`
|
2994
3359
|
},
|
2995
3360
|
state: { from: pathname },
|
2996
|
-
label: formatMessage(
|
2997
|
-
|
2998
|
-
|
2999
|
-
|
3000
|
-
{
|
3001
|
-
id: "content-manager.components.ListViewHelperPluginTable.row-line",
|
3002
|
-
defaultMessage: "item line {number}"
|
3003
|
-
},
|
3004
|
-
{ number: index2 + 1 }
|
3005
|
-
)
|
3006
|
-
}
|
3007
|
-
),
|
3361
|
+
label: formatMessage({
|
3362
|
+
id: "content-manager.bulk-publish.edit",
|
3363
|
+
defaultMessage: "Edit"
|
3364
|
+
}),
|
3008
3365
|
target: "_blank",
|
3009
3366
|
marginLeft: "auto",
|
3010
|
-
|
3367
|
+
variant: "ghost",
|
3368
|
+
children: /* @__PURE__ */ jsx(Pencil, { width: "1.6rem", height: "1.6rem" })
|
3011
3369
|
}
|
3012
|
-
) })
|
3370
|
+
) }) })
|
3013
3371
|
] }, row.id)) })
|
3014
3372
|
] });
|
3015
3373
|
};
|
@@ -3046,7 +3404,13 @@ const SelectedEntriesModalContent = ({
|
|
3046
3404
|
);
|
3047
3405
|
const { rows, validationErrors } = React.useMemo(() => {
|
3048
3406
|
if (data.length > 0 && schema) {
|
3049
|
-
const validate = createYupSchema(
|
3407
|
+
const validate = createYupSchema(
|
3408
|
+
schema.attributes,
|
3409
|
+
components,
|
3410
|
+
// Since this is the "Publish" action, the validation
|
3411
|
+
// schema must enforce the rules for published entities
|
3412
|
+
{ status: "published" }
|
3413
|
+
);
|
3050
3414
|
const validationErrors2 = {};
|
3051
3415
|
const rows2 = data.map((entry) => {
|
3052
3416
|
try {
|
@@ -3171,8 +3535,7 @@ const PublishAction = ({ documents, model }) => {
|
|
3171
3535
|
const refetchList = () => {
|
3172
3536
|
contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
|
3173
3537
|
};
|
3174
|
-
if (!showPublishButton)
|
3175
|
-
return null;
|
3538
|
+
if (!showPublishButton) return null;
|
3176
3539
|
return {
|
3177
3540
|
actionType: "publish",
|
3178
3541
|
variant: "tertiary",
|
@@ -3240,8 +3603,7 @@ const DeleteAction = ({ documents, model }) => {
|
|
3240
3603
|
selectRow([]);
|
3241
3604
|
}
|
3242
3605
|
};
|
3243
|
-
if (!hasDeletePermission)
|
3244
|
-
return null;
|
3606
|
+
if (!hasDeletePermission) return null;
|
3245
3607
|
return {
|
3246
3608
|
variant: "danger-light",
|
3247
3609
|
label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
|
@@ -3290,8 +3652,7 @@ const UnpublishAction = ({ documents, model }) => {
|
|
3290
3652
|
}
|
3291
3653
|
};
|
3292
3654
|
const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
|
3293
|
-
if (!showUnpublishButton)
|
3294
|
-
return null;
|
3655
|
+
if (!showUnpublishButton) return null;
|
3295
3656
|
return {
|
3296
3657
|
variant: "tertiary",
|
3297
3658
|
label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
|
@@ -3396,7 +3757,7 @@ const TableActions = ({ document }) => {
|
|
3396
3757
|
DescriptionComponentRenderer,
|
3397
3758
|
{
|
3398
3759
|
props,
|
3399
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3760
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("table-row").filter((action) => action.name !== "PublishAction"),
|
3400
3761
|
children: (actions2) => {
|
3401
3762
|
const tableRowActions = actions2.filter((action) => {
|
3402
3763
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -3455,6 +3816,7 @@ const EditAction = ({ documentId }) => {
|
|
3455
3816
|
};
|
3456
3817
|
};
|
3457
3818
|
EditAction.type = "edit";
|
3819
|
+
EditAction.position = "table-row";
|
3458
3820
|
const StyledPencil = styled(Pencil)`
|
3459
3821
|
path {
|
3460
3822
|
fill: currentColor;
|
@@ -3507,7 +3869,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3507
3869
|
}),
|
3508
3870
|
content: /* @__PURE__ */ jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
3509
3871
|
footer: ({ onClose }) => {
|
3510
|
-
return /* @__PURE__ */ jsxs(
|
3872
|
+
return /* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
3511
3873
|
/* @__PURE__ */ jsx(Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
3512
3874
|
id: "cancel",
|
3513
3875
|
defaultMessage: "Cancel"
|
@@ -3531,6 +3893,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3531
3893
|
};
|
3532
3894
|
};
|
3533
3895
|
CloneAction.type = "clone";
|
3896
|
+
CloneAction.position = "table-row";
|
3534
3897
|
const StyledDuplicate = styled(Duplicate)`
|
3535
3898
|
path {
|
3536
3899
|
fill: currentColor;
|
@@ -3548,8 +3911,7 @@ class ContentManagerPlugin {
|
|
3548
3911
|
documentActions = [
|
3549
3912
|
...DEFAULT_ACTIONS,
|
3550
3913
|
...DEFAULT_TABLE_ROW_ACTIONS,
|
3551
|
-
...DEFAULT_HEADER_ACTIONS
|
3552
|
-
HistoryAction
|
3914
|
+
...DEFAULT_HEADER_ACTIONS
|
3553
3915
|
];
|
3554
3916
|
editViewSidePanels = [ActionsPanel];
|
3555
3917
|
headerActions = [];
|
@@ -3618,7 +3980,14 @@ class ContentManagerPlugin {
|
|
3618
3980
|
addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
|
3619
3981
|
addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
|
3620
3982
|
getBulkActions: () => this.bulkActions,
|
3621
|
-
getDocumentActions: () =>
|
3983
|
+
getDocumentActions: (position) => {
|
3984
|
+
if (position) {
|
3985
|
+
return this.documentActions.filter(
|
3986
|
+
(action) => action.position == void 0 || [action.position].flat().includes(position)
|
3987
|
+
);
|
3988
|
+
}
|
3989
|
+
return this.documentActions;
|
3990
|
+
},
|
3622
3991
|
getEditViewSidePanels: () => this.editViewSidePanels,
|
3623
3992
|
getHeaderActions: () => this.headerActions
|
3624
3993
|
}
|
@@ -3628,16 +3997,71 @@ class ContentManagerPlugin {
|
|
3628
3997
|
const getPrintableType = (value) => {
|
3629
3998
|
const nativeType = typeof value;
|
3630
3999
|
if (nativeType === "object") {
|
3631
|
-
if (value === null)
|
3632
|
-
|
3633
|
-
if (Array.isArray(value))
|
3634
|
-
return "array";
|
4000
|
+
if (value === null) return "null";
|
4001
|
+
if (Array.isArray(value)) return "array";
|
3635
4002
|
if (value instanceof Object && value.constructor.name !== "Object") {
|
3636
4003
|
return value.constructor.name;
|
3637
4004
|
}
|
3638
4005
|
}
|
3639
4006
|
return nativeType;
|
3640
4007
|
};
|
4008
|
+
const HistoryAction = ({ model, document }) => {
|
4009
|
+
const { formatMessage } = useIntl();
|
4010
|
+
const [{ query }] = useQueryParams();
|
4011
|
+
const navigate = useNavigate();
|
4012
|
+
const { trackUsage } = useTracking();
|
4013
|
+
const { pathname } = useLocation();
|
4014
|
+
const pluginsQueryParams = stringify({ plugins: query.plugins }, { encode: false });
|
4015
|
+
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
4016
|
+
return null;
|
4017
|
+
}
|
4018
|
+
const handleOnClick = () => {
|
4019
|
+
const destination = { pathname: "history", search: pluginsQueryParams };
|
4020
|
+
trackUsage("willNavigate", {
|
4021
|
+
from: pathname,
|
4022
|
+
to: `${pathname}/${destination.pathname}`
|
4023
|
+
});
|
4024
|
+
navigate(destination);
|
4025
|
+
};
|
4026
|
+
return {
|
4027
|
+
icon: /* @__PURE__ */ jsx(ClockCounterClockwise, {}),
|
4028
|
+
label: formatMessage({
|
4029
|
+
id: "content-manager.history.document-action",
|
4030
|
+
defaultMessage: "Content History"
|
4031
|
+
}),
|
4032
|
+
onClick: handleOnClick,
|
4033
|
+
disabled: (
|
4034
|
+
/**
|
4035
|
+
* The user is creating a new document.
|
4036
|
+
* It hasn't been saved yet, so there's no history to go to
|
4037
|
+
*/
|
4038
|
+
!document || /**
|
4039
|
+
* The document has been created but the current dimension has never been saved.
|
4040
|
+
* For example, the user is creating a new locale in an existing document,
|
4041
|
+
* so there's no history for the document in that locale
|
4042
|
+
*/
|
4043
|
+
!document.id || /**
|
4044
|
+
* History is only available for content types created by the user.
|
4045
|
+
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
4046
|
+
* which start with `admin::` or `plugin::`
|
4047
|
+
*/
|
4048
|
+
!model.startsWith("api::")
|
4049
|
+
),
|
4050
|
+
position: "header"
|
4051
|
+
};
|
4052
|
+
};
|
4053
|
+
HistoryAction.type = "history";
|
4054
|
+
HistoryAction.position = "header";
|
4055
|
+
const historyAdmin = {
|
4056
|
+
bootstrap(app) {
|
4057
|
+
const { addDocumentAction } = app.getPlugin("content-manager").apis;
|
4058
|
+
addDocumentAction((actions2) => {
|
4059
|
+
const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
|
4060
|
+
actions2.splice(indexOfDeleteAction, 0, HistoryAction);
|
4061
|
+
return actions2;
|
4062
|
+
});
|
4063
|
+
}
|
4064
|
+
};
|
3641
4065
|
const initialState = {
|
3642
4066
|
collectionTypeLinks: [],
|
3643
4067
|
components: [],
|
@@ -3674,6 +4098,88 @@ const { setInitialData } = actions;
|
|
3674
4098
|
const reducer = combineReducers({
|
3675
4099
|
app: reducer$1
|
3676
4100
|
});
|
4101
|
+
const previewApi = contentManagerApi.injectEndpoints({
|
4102
|
+
endpoints: (builder) => ({
|
4103
|
+
getPreviewUrl: builder.query({
|
4104
|
+
query({ query, params }) {
|
4105
|
+
return {
|
4106
|
+
url: `/content-manager/preview/url/${params.contentType}`,
|
4107
|
+
method: "GET",
|
4108
|
+
config: {
|
4109
|
+
params: query
|
4110
|
+
}
|
4111
|
+
};
|
4112
|
+
}
|
4113
|
+
})
|
4114
|
+
})
|
4115
|
+
});
|
4116
|
+
const { useGetPreviewUrlQuery } = previewApi;
|
4117
|
+
const ConditionalTooltip = ({ isShown, label, children }) => {
|
4118
|
+
if (isShown) {
|
4119
|
+
return /* @__PURE__ */ jsx(Tooltip, { label, children });
|
4120
|
+
}
|
4121
|
+
return children;
|
4122
|
+
};
|
4123
|
+
const PreviewSidePanel = ({ model, documentId, document }) => {
|
4124
|
+
const { formatMessage } = useIntl();
|
4125
|
+
const { trackUsage } = useTracking();
|
4126
|
+
const { pathname } = useLocation();
|
4127
|
+
const [{ query }] = useQueryParams();
|
4128
|
+
const isModified = useForm("PreviewSidePanel", (state) => state.modified);
|
4129
|
+
const { data, error } = useGetPreviewUrlQuery({
|
4130
|
+
params: {
|
4131
|
+
contentType: model
|
4132
|
+
},
|
4133
|
+
query: {
|
4134
|
+
documentId,
|
4135
|
+
locale: document?.locale,
|
4136
|
+
status: document?.status
|
4137
|
+
}
|
4138
|
+
});
|
4139
|
+
if (!data?.data?.url || error) {
|
4140
|
+
return null;
|
4141
|
+
}
|
4142
|
+
const trackNavigation = () => {
|
4143
|
+
const destinationPathname = pathname.replace(/\/$/, "") + "/preview";
|
4144
|
+
trackUsage("willNavigate", { from: pathname, to: destinationPathname });
|
4145
|
+
};
|
4146
|
+
return {
|
4147
|
+
title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
|
4148
|
+
content: /* @__PURE__ */ jsx(
|
4149
|
+
ConditionalTooltip,
|
4150
|
+
{
|
4151
|
+
label: formatMessage({
|
4152
|
+
id: "content-manager.preview.panel.button-disabled-tooltip",
|
4153
|
+
defaultMessage: "Please save to open the preview"
|
4154
|
+
}),
|
4155
|
+
isShown: isModified,
|
4156
|
+
children: /* @__PURE__ */ jsx(Box, { cursor: "not-allowed", width: "100%", children: /* @__PURE__ */ jsx(
|
4157
|
+
Button,
|
4158
|
+
{
|
4159
|
+
variant: "tertiary",
|
4160
|
+
tag: Link,
|
4161
|
+
to: { pathname: "preview", search: stringify(query, { encode: false }) },
|
4162
|
+
onClick: trackNavigation,
|
4163
|
+
width: "100%",
|
4164
|
+
disabled: isModified,
|
4165
|
+
pointerEvents: isModified ? "none" : void 0,
|
4166
|
+
tabIndex: isModified ? -1 : void 0,
|
4167
|
+
children: formatMessage({
|
4168
|
+
id: "content-manager.preview.panel.button",
|
4169
|
+
defaultMessage: "Open preview"
|
4170
|
+
})
|
4171
|
+
}
|
4172
|
+
) })
|
4173
|
+
}
|
4174
|
+
)
|
4175
|
+
};
|
4176
|
+
};
|
4177
|
+
const previewAdmin = {
|
4178
|
+
bootstrap(app) {
|
4179
|
+
const contentManagerPluginApis = app.getPlugin("content-manager").apis;
|
4180
|
+
contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
|
4181
|
+
}
|
4182
|
+
};
|
3677
4183
|
const index = {
|
3678
4184
|
register(app) {
|
3679
4185
|
const cm = new ContentManagerPlugin();
|
@@ -3688,15 +4194,32 @@ const index = {
|
|
3688
4194
|
defaultMessage: "Content Manager"
|
3689
4195
|
},
|
3690
4196
|
permissions: [],
|
3691
|
-
Component: () => import("./layout-DC503LnF.mjs").then((mod) => ({ default: mod.Layout })),
|
3692
4197
|
position: 1
|
3693
4198
|
});
|
4199
|
+
app.router.addRoute({
|
4200
|
+
path: "content-manager/*",
|
4201
|
+
lazy: async () => {
|
4202
|
+
const { Layout } = await import("./layout-W3clJSCy.mjs");
|
4203
|
+
return {
|
4204
|
+
Component: Layout
|
4205
|
+
};
|
4206
|
+
},
|
4207
|
+
children: routes
|
4208
|
+
});
|
3694
4209
|
app.registerPlugin(cm.config);
|
3695
4210
|
},
|
4211
|
+
bootstrap(app) {
|
4212
|
+
if (typeof historyAdmin.bootstrap === "function") {
|
4213
|
+
historyAdmin.bootstrap(app);
|
4214
|
+
}
|
4215
|
+
if (typeof previewAdmin.bootstrap === "function") {
|
4216
|
+
previewAdmin.bootstrap(app);
|
4217
|
+
}
|
4218
|
+
},
|
3696
4219
|
async registerTrads({ locales }) {
|
3697
4220
|
const importedTrads = await Promise.all(
|
3698
4221
|
locales.map((locale) => {
|
3699
|
-
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-
|
4222
|
+
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-CSxLmrh1.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`, 3).then(({ default: data }) => {
|
3700
4223
|
return {
|
3701
4224
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3702
4225
|
locale
|
@@ -3723,8 +4246,10 @@ export {
|
|
3723
4246
|
HOOKS as H,
|
3724
4247
|
InjectionZone as I,
|
3725
4248
|
useDocument as J,
|
3726
|
-
|
3727
|
-
|
4249
|
+
useGetPreviewUrlQuery as K,
|
4250
|
+
index as L,
|
4251
|
+
useContentManagerContext as M,
|
4252
|
+
useDocumentActions as N,
|
3728
4253
|
Panels as P,
|
3729
4254
|
RelativeTime as R,
|
3730
4255
|
SINGLE_TYPES as S,
|
@@ -3742,11 +4267,11 @@ export {
|
|
3742
4267
|
PERMISSIONS as k,
|
3743
4268
|
DocumentRBAC as l,
|
3744
4269
|
DOCUMENT_META_FIELDS as m,
|
3745
|
-
|
3746
|
-
|
3747
|
-
|
3748
|
-
|
3749
|
-
|
4270
|
+
CLONE_PATH as n,
|
4271
|
+
useDocLayout as o,
|
4272
|
+
useGetContentTypeConfigurationQuery as p,
|
4273
|
+
CREATOR_FIELDS as q,
|
4274
|
+
getMainField as r,
|
3750
4275
|
setInitialData as s,
|
3751
4276
|
getDisplayName as t,
|
3752
4277
|
useContentTypeSchema as u,
|
@@ -3756,4 +4281,4 @@ export {
|
|
3756
4281
|
capitalise as y,
|
3757
4282
|
useUpdateContentTypeConfigurationMutation as z
|
3758
4283
|
};
|
3759
|
-
//# sourceMappingURL=index-
|
4284
|
+
//# sourceMappingURL=index-DqasUQ6Q.mjs.map
|