@strapi/content-manager 0.0.0-experimental.7afdc9b682bc83a53ce599c4fb7c9e4506b31fff → 0.0.0-experimental.7bc5339b0393e53f9f568301594621e7fb466e2f
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-DJcn1DrO.js → ComponentConfigurationPage-BPiQrhZ6.js} +5 -6
- package/dist/_chunks/{ComponentConfigurationPage-DJcn1DrO.js.map → ComponentConfigurationPage-BPiQrhZ6.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-CR5XdR33.mjs → ComponentConfigurationPage-viOAdZM6.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-CR5XdR33.mjs.map → ComponentConfigurationPage-viOAdZM6.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-tDtWj7R2.js → EditConfigurationPage-CZRKq8CN.js} +5 -6
- package/dist/_chunks/{EditConfigurationPage-tDtWj7R2.js.map → EditConfigurationPage-CZRKq8CN.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-DmCIb4kD.mjs → EditConfigurationPage-DKtPyjs_.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-DmCIb4kD.mjs.map → EditConfigurationPage-DKtPyjs_.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-CoQEnFlC.js → EditViewPage-C-TZmK5r.js} +101 -51
- package/dist/_chunks/EditViewPage-C-TZmK5r.js.map +1 -0
- package/dist/_chunks/{EditViewPage-DvaV7U9b.mjs → EditViewPage-D2FPb5Mh.mjs} +102 -51
- package/dist/_chunks/EditViewPage-D2FPb5Mh.mjs.map +1 -0
- package/dist/_chunks/{Field-ZdrmmQ4Y.js → Field-IMBnqF-k.js} +634 -283
- package/dist/_chunks/Field-IMBnqF-k.js.map +1 -0
- package/dist/_chunks/{Field-Cz_J9551.mjs → Field-hD0Y00Mt.mjs} +631 -279
- package/dist/_chunks/Field-hD0Y00Mt.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-Bpig5rch.js → Form-BaURS01O.js} +55 -38
- package/dist/_chunks/Form-BaURS01O.js.map +1 -0
- package/dist/_chunks/{Form-Dxmihyw8.mjs → Form-ZQ9fzWkd.mjs} +55 -37
- package/dist/_chunks/Form-ZQ9fzWkd.mjs.map +1 -0
- package/dist/_chunks/{History-BfX6XmZK.js → History-BqRQm2Lc.js} +175 -129
- package/dist/_chunks/History-BqRQm2Lc.js.map +1 -0
- package/dist/_chunks/{History-BZP8n7KT.mjs → History-C4X3jiQJ.mjs} +176 -129
- package/dist/_chunks/History-C4X3jiQJ.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-B3CXj8PY.js → ListConfigurationPage-BT69-TvF.js} +62 -51
- package/dist/_chunks/ListConfigurationPage-BT69-TvF.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DxKuVkKz.mjs → ListConfigurationPage-CwMU6tWQ.mjs} +63 -52
- package/dist/_chunks/ListConfigurationPage-CwMU6tWQ.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-Bk9VO__I.js → ListViewPage-CYkrfWsm.js} +155 -132
- package/dist/_chunks/ListViewPage-CYkrfWsm.js.map +1 -0
- package/dist/_chunks/{ListViewPage-D5D3tVPq.mjs → ListViewPage-CvxfiNTc.mjs} +152 -128
- package/dist/_chunks/ListViewPage-CvxfiNTc.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DsB2F7Z1.js → NoContentTypePage-BZMfRsrg.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-DsB2F7Z1.js.map → NoContentTypePage-BZMfRsrg.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-DnMeuQCj.mjs → NoContentTypePage-Dy6sa9LT.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-DnMeuQCj.mjs.map → NoContentTypePage-Dy6sa9LT.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-OyoME_Tf.mjs → NoPermissionsPage-DiW-TIzq.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-OyoME_Tf.mjs.map → NoPermissionsPage-DiW-TIzq.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-BQDM64_b.js → NoPermissionsPage-DjUdvhJ6.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-BQDM64_b.js.map → NoPermissionsPage-DjUdvhJ6.js.map} +1 -1
- package/dist/_chunks/Preview-BqRUSbFU.js +296 -0
- package/dist/_chunks/Preview-BqRUSbFU.js.map +1 -0
- package/dist/_chunks/Preview-DwWET-X7.mjs +278 -0
- package/dist/_chunks/Preview-DwWET-X7.mjs.map +1 -0
- package/dist/_chunks/{Relations-BOYZmuWy.mjs → Relations-BOTC_ZqE.mjs} +76 -42
- package/dist/_chunks/Relations-BOTC_ZqE.mjs.map +1 -0
- package/dist/_chunks/{Relations-B6B3A3mb.js → Relations-DnCdLzq_.js} +76 -43
- package/dist/_chunks/Relations-DnCdLzq_.js.map +1 -0
- package/dist/_chunks/{en-BN1bvFK7.js → en-BK8Xyl5I.js} +35 -18
- package/dist/_chunks/{en-BN1bvFK7.js.map → en-BK8Xyl5I.js.map} +1 -1
- package/dist/_chunks/{en-Dzv55oQw.mjs → en-Dtk_ot79.mjs} +35 -18
- package/dist/_chunks/{en-Dzv55oQw.mjs.map → en-Dtk_ot79.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-VHviNMeW.mjs → index-BeYsz0Vi.mjs} +1203 -899
- package/dist/_chunks/index-BeYsz0Vi.mjs.map +1 -0
- package/dist/_chunks/{index-DzN3kBgx.js → index-CptTdHNy.js} +1183 -879
- package/dist/_chunks/index-CptTdHNy.js.map +1 -0
- package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
- package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
- package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
- package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
- package/dist/_chunks/{layout-CPn1PM6x.mjs → layout-CzSSEy9b.mjs} +42 -24
- package/dist/_chunks/layout-CzSSEy9b.mjs.map +1 -0
- package/dist/_chunks/{layout-b91XRlD2.js → layout-szfTCeYm.js} +41 -24
- package/dist/_chunks/layout-szfTCeYm.js.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-BsqxS6tR.mjs → relations-DvzmDbWc.mjs} +6 -7
- package/dist/_chunks/relations-DvzmDbWc.mjs.map +1 -0
- package/dist/_chunks/{relations-CA7IYmcP.js → relations-qssSbh1V.js} +6 -7
- package/dist/_chunks/relations-qssSbh1V.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 +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +8 -7
- package/dist/admin/src/content-manager.d.ts +3 -2
- package/dist/admin/src/exports.d.ts +1 -1
- package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -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 +9 -4
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
- 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 +6 -58
- package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
- package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
- package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
- package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
- package/dist/admin/src/preview/constants.d.ts +1 -0
- package/dist/admin/src/preview/index.d.ts +4 -0
- package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
- package/dist/admin/src/preview/routes.d.ts +3 -0
- package/dist/admin/src/preview/services/preview.d.ts +3 -0
- package/dist/admin/src/router.d.ts +1 -1
- package/dist/admin/src/services/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 +614 -297
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +614 -296
- 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 +15 -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/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 +4 -4
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +4 -4
- package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
- package/dist/server/src/preview/constants.d.ts +2 -0
- package/dist/server/src/preview/constants.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/index.d.ts +2 -0
- package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/preview.d.ts +13 -0
- package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
- package/dist/server/src/preview/index.d.ts +4 -0
- package/dist/server/src/preview/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/index.d.ts +8 -0
- package/dist/server/src/preview/routes/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/preview.d.ts +4 -0
- package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
- package/dist/server/src/preview/services/index.d.ts +16 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts +32 -0
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview.d.ts +12 -0
- package/dist/server/src/preview/services/preview.d.ts.map +1 -0
- package/dist/server/src/preview/utils.d.ts +19 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -0
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +8 -8
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +4 -4
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/permission-checker.d.ts.map +1 -1
- package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
- package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
- package/dist/server/src/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 +15 -15
- package/dist/_chunks/EditViewPage-CoQEnFlC.js.map +0 -1
- package/dist/_chunks/EditViewPage-DvaV7U9b.mjs.map +0 -1
- package/dist/_chunks/Field-Cz_J9551.mjs.map +0 -1
- package/dist/_chunks/Field-ZdrmmQ4Y.js.map +0 -1
- package/dist/_chunks/Form-Bpig5rch.js.map +0 -1
- package/dist/_chunks/Form-Dxmihyw8.mjs.map +0 -1
- package/dist/_chunks/History-BZP8n7KT.mjs.map +0 -1
- package/dist/_chunks/History-BfX6XmZK.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-B3CXj8PY.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DxKuVkKz.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-Bk9VO__I.js.map +0 -1
- package/dist/_chunks/ListViewPage-D5D3tVPq.mjs.map +0 -1
- package/dist/_chunks/Relations-B6B3A3mb.js.map +0 -1
- package/dist/_chunks/Relations-BOYZmuWy.mjs.map +0 -1
- package/dist/_chunks/index-DzN3kBgx.js.map +0 -1
- package/dist/_chunks/index-VHviNMeW.mjs.map +0 -1
- package/dist/_chunks/layout-CPn1PM6x.mjs.map +0 -1
- package/dist/_chunks/layout-b91XRlD2.js.map +0 -1
- package/dist/_chunks/relations-BsqxS6tR.mjs.map +0 -1
- package/dist/_chunks/relations-CA7IYmcP.js.map +0 -1
- package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
- package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
- package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
- package/strapi-server.js +0 -3
@@ -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 { Menu, VisuallyHidden, Flex,
|
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,12 @@ const contentManagerApi = adminApi.enhanceEndpoints({
|
|
194
174
|
"Document",
|
195
175
|
"InitialData",
|
196
176
|
"HistoryVersion",
|
197
|
-
"Relations"
|
177
|
+
"Relations",
|
178
|
+
"UidAvailability"
|
198
179
|
]
|
199
180
|
});
|
200
181
|
const documentApi = contentManagerApi.injectEndpoints({
|
182
|
+
overrideExisting: true,
|
201
183
|
endpoints: (builder) => ({
|
202
184
|
autoCloneDocument: builder.mutation({
|
203
185
|
query: ({ model, sourceId, query }) => ({
|
@@ -207,7 +189,12 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
207
189
|
params: query
|
208
190
|
}
|
209
191
|
}),
|
210
|
-
invalidatesTags: (_result,
|
192
|
+
invalidatesTags: (_result, error, { model }) => {
|
193
|
+
if (error) {
|
194
|
+
return [];
|
195
|
+
}
|
196
|
+
return [{ type: "Document", id: `${model}_LIST` }];
|
197
|
+
}
|
211
198
|
}),
|
212
199
|
cloneDocument: builder.mutation({
|
213
200
|
query: ({ model, sourceId, data, params }) => ({
|
@@ -218,7 +205,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
218
205
|
params
|
219
206
|
}
|
220
207
|
}),
|
221
|
-
invalidatesTags: (_result, _error, { model }) => [
|
208
|
+
invalidatesTags: (_result, _error, { model }) => [
|
209
|
+
{ type: "Document", id: `${model}_LIST` },
|
210
|
+
{ type: "UidAvailability", id: model }
|
211
|
+
]
|
222
212
|
}),
|
223
213
|
/**
|
224
214
|
* Creates a new collection-type document. This should ONLY be used for collection-types.
|
@@ -235,7 +225,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
235
225
|
}),
|
236
226
|
invalidatesTags: (result, _error, { model }) => [
|
237
227
|
{ type: "Document", id: `${model}_LIST` },
|
238
|
-
"Relations"
|
228
|
+
"Relations",
|
229
|
+
{ type: "UidAvailability", id: model }
|
239
230
|
]
|
240
231
|
}),
|
241
232
|
deleteDocument: builder.mutation({
|
@@ -276,7 +267,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
276
267
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
277
268
|
},
|
278
269
|
{ type: "Document", id: `${model}_LIST` },
|
279
|
-
"Relations"
|
270
|
+
"Relations",
|
271
|
+
{ type: "UidAvailability", id: model }
|
280
272
|
];
|
281
273
|
}
|
282
274
|
}),
|
@@ -289,11 +281,12 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
289
281
|
url: `/content-manager/collection-types/${model}`,
|
290
282
|
method: "GET",
|
291
283
|
config: {
|
292
|
-
params
|
284
|
+
params: stringify(params, { encode: true })
|
293
285
|
}
|
294
286
|
}),
|
295
287
|
providesTags: (result, _error, arg) => {
|
296
288
|
return [
|
289
|
+
{ type: "Document", id: `ALL_LIST` },
|
297
290
|
{ type: "Document", id: `${arg.model}_LIST` },
|
298
291
|
...result?.results.map(({ documentId }) => ({
|
299
292
|
type: "Document",
|
@@ -332,6 +325,11 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
332
325
|
{
|
333
326
|
type: "Document",
|
334
327
|
id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
|
328
|
+
},
|
329
|
+
// Make it easy to invalidate all individual documents queries for a model
|
330
|
+
{
|
331
|
+
type: "Document",
|
332
|
+
id: `${model}_ALL_ITEMS`
|
335
333
|
}
|
336
334
|
];
|
337
335
|
}
|
@@ -395,8 +393,21 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
395
393
|
type: "Document",
|
396
394
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
397
395
|
},
|
398
|
-
"Relations"
|
396
|
+
"Relations",
|
397
|
+
{ type: "UidAvailability", id: model }
|
399
398
|
];
|
399
|
+
},
|
400
|
+
async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
|
401
|
+
const patchResult = dispatch(
|
402
|
+
documentApi.util.updateQueryData("getDocument", patch, (draft) => {
|
403
|
+
Object.assign(draft.data, data);
|
404
|
+
})
|
405
|
+
);
|
406
|
+
try {
|
407
|
+
await queryFulfilled;
|
408
|
+
} catch {
|
409
|
+
patchResult.undo();
|
410
|
+
}
|
400
411
|
}
|
401
412
|
}),
|
402
413
|
unpublishDocument: builder.mutation({
|
@@ -449,8 +460,7 @@ const {
|
|
449
460
|
useUnpublishManyDocumentsMutation
|
450
461
|
} = documentApi;
|
451
462
|
const buildValidParams = (query) => {
|
452
|
-
if (!query)
|
453
|
-
return query;
|
463
|
+
if (!query) return query;
|
454
464
|
const { plugins: _, ...validQueryParams } = {
|
455
465
|
...query,
|
456
466
|
...Object.values(query?.plugins ?? {}).reduce(
|
@@ -458,28 +468,44 @@ const buildValidParams = (query) => {
|
|
458
468
|
{}
|
459
469
|
)
|
460
470
|
};
|
461
|
-
if ("_q" in validQueryParams) {
|
462
|
-
validQueryParams._q = encodeURIComponent(validQueryParams._q);
|
463
|
-
}
|
464
471
|
return validQueryParams;
|
465
472
|
};
|
466
473
|
const isBaseQueryError = (error) => {
|
467
474
|
return error.name !== void 0;
|
468
475
|
};
|
469
|
-
const
|
476
|
+
const arrayValidator = (attribute, options) => ({
|
477
|
+
message: translatedErrors.required,
|
478
|
+
test(value) {
|
479
|
+
if (options.status === "draft") {
|
480
|
+
return true;
|
481
|
+
}
|
482
|
+
if (!attribute.required) {
|
483
|
+
return true;
|
484
|
+
}
|
485
|
+
if (!value) {
|
486
|
+
return false;
|
487
|
+
}
|
488
|
+
if (Array.isArray(value) && value.length === 0) {
|
489
|
+
return false;
|
490
|
+
}
|
491
|
+
return true;
|
492
|
+
}
|
493
|
+
});
|
494
|
+
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
470
495
|
const createModelSchema = (attributes2) => yup.object().shape(
|
471
496
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
472
497
|
if (DOCUMENT_META_FIELDS.includes(name)) {
|
473
498
|
return acc;
|
474
499
|
}
|
475
500
|
const validations = [
|
501
|
+
addNullableValidation,
|
476
502
|
addRequiredValidation,
|
477
503
|
addMinLengthValidation,
|
478
504
|
addMaxLengthValidation,
|
479
505
|
addMinValidation,
|
480
506
|
addMaxValidation,
|
481
507
|
addRegexValidation
|
482
|
-
].map((fn) => fn(attribute));
|
508
|
+
].map((fn) => fn(attribute, options));
|
483
509
|
const transformSchema = pipe(...validations);
|
484
510
|
switch (attribute.type) {
|
485
511
|
case "component": {
|
@@ -489,12 +515,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
489
515
|
...acc,
|
490
516
|
[name]: transformSchema(
|
491
517
|
yup.array().of(createModelSchema(attributes3).nullable(false))
|
492
|
-
)
|
518
|
+
).test(arrayValidator(attribute, options))
|
493
519
|
};
|
494
520
|
} else {
|
495
521
|
return {
|
496
522
|
...acc,
|
497
|
-
[name]: transformSchema(createModelSchema(attributes3))
|
523
|
+
[name]: transformSchema(createModelSchema(attributes3).nullable())
|
498
524
|
};
|
499
525
|
}
|
500
526
|
}
|
@@ -516,7 +542,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
516
542
|
}
|
517
543
|
)
|
518
544
|
)
|
519
|
-
)
|
545
|
+
).test(arrayValidator(attribute, options))
|
520
546
|
};
|
521
547
|
case "relation":
|
522
548
|
return {
|
@@ -528,7 +554,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
528
554
|
} else if (Array.isArray(value)) {
|
529
555
|
return yup.array().of(
|
530
556
|
yup.object().shape({
|
531
|
-
id: yup.
|
557
|
+
id: yup.number().required()
|
532
558
|
})
|
533
559
|
);
|
534
560
|
} else if (typeof value === "object") {
|
@@ -580,6 +606,14 @@ const createAttributeSchema = (attribute) => {
|
|
580
606
|
if (!value || typeof value === "string" && value.length === 0) {
|
581
607
|
return true;
|
582
608
|
}
|
609
|
+
if (typeof value === "object") {
|
610
|
+
try {
|
611
|
+
JSON.stringify(value);
|
612
|
+
return true;
|
613
|
+
} catch (err) {
|
614
|
+
return false;
|
615
|
+
}
|
616
|
+
}
|
583
617
|
try {
|
584
618
|
JSON.parse(value);
|
585
619
|
return true;
|
@@ -598,13 +632,7 @@ const createAttributeSchema = (attribute) => {
|
|
598
632
|
return yup.mixed();
|
599
633
|
}
|
600
634
|
};
|
601
|
-
const
|
602
|
-
if (attribute.required) {
|
603
|
-
return schema.required({
|
604
|
-
id: translatedErrors.required.id,
|
605
|
-
defaultMessage: "This field is required."
|
606
|
-
});
|
607
|
-
}
|
635
|
+
const nullableSchema = (schema) => {
|
608
636
|
return schema?.nullable ? schema.nullable() : (
|
609
637
|
// In some cases '.nullable' will not be available on the schema.
|
610
638
|
// e.g. when the schema has been built using yup.lazy (e.g. for relations).
|
@@ -612,7 +640,22 @@ const addRequiredValidation = (attribute) => (schema) => {
|
|
612
640
|
schema
|
613
641
|
);
|
614
642
|
};
|
615
|
-
const
|
643
|
+
const addNullableValidation = () => (schema) => {
|
644
|
+
return nullableSchema(schema);
|
645
|
+
};
|
646
|
+
const addRequiredValidation = (attribute, options) => (schema) => {
|
647
|
+
if (options.status === "draft" || !attribute.required) {
|
648
|
+
return schema;
|
649
|
+
}
|
650
|
+
if (attribute.required && "required" in schema) {
|
651
|
+
return schema.required(translatedErrors.required);
|
652
|
+
}
|
653
|
+
return schema;
|
654
|
+
};
|
655
|
+
const addMinLengthValidation = (attribute, options) => (schema) => {
|
656
|
+
if (options.status === "draft") {
|
657
|
+
return schema;
|
658
|
+
}
|
616
659
|
if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
|
617
660
|
return schema.min(attribute.minLength, {
|
618
661
|
...translatedErrors.minLength,
|
@@ -634,10 +677,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
634
677
|
}
|
635
678
|
return schema;
|
636
679
|
};
|
637
|
-
const addMinValidation = (attribute) => (schema) => {
|
638
|
-
if ("
|
680
|
+
const addMinValidation = (attribute, options) => (schema) => {
|
681
|
+
if (options.status === "draft") {
|
682
|
+
return schema;
|
683
|
+
}
|
684
|
+
if ("min" in attribute && "min" in schema) {
|
639
685
|
const min = toInteger(attribute.min);
|
640
|
-
if (
|
686
|
+
if (min) {
|
641
687
|
return schema.min(min, {
|
642
688
|
...translatedErrors.min,
|
643
689
|
values: {
|
@@ -755,16 +801,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
|
|
755
801
|
}, {});
|
756
802
|
return componentsByKey;
|
757
803
|
};
|
758
|
-
const
|
804
|
+
const HOOKS = {
|
805
|
+
/**
|
806
|
+
* Hook that allows to mutate the displayed headers of the list view table
|
807
|
+
* @constant
|
808
|
+
* @type {string}
|
809
|
+
*/
|
810
|
+
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
811
|
+
/**
|
812
|
+
* Hook that allows to mutate the CM's collection types links pre-set filters
|
813
|
+
* @constant
|
814
|
+
* @type {string}
|
815
|
+
*/
|
816
|
+
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
817
|
+
/**
|
818
|
+
* Hook that allows to mutate the CM's edit view layout
|
819
|
+
* @constant
|
820
|
+
* @type {string}
|
821
|
+
*/
|
822
|
+
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
823
|
+
/**
|
824
|
+
* Hook that allows to mutate the CM's single types links pre-set filters
|
825
|
+
* @constant
|
826
|
+
* @type {string}
|
827
|
+
*/
|
828
|
+
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
829
|
+
};
|
830
|
+
const contentTypesApi = contentManagerApi.injectEndpoints({
|
831
|
+
endpoints: (builder) => ({
|
832
|
+
getContentTypeConfiguration: builder.query({
|
833
|
+
query: (uid) => ({
|
834
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
835
|
+
method: "GET"
|
836
|
+
}),
|
837
|
+
transformResponse: (response) => response.data,
|
838
|
+
providesTags: (_result, _error, uid) => [
|
839
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
840
|
+
{ type: "ContentTypeSettings", id: "LIST" }
|
841
|
+
]
|
842
|
+
}),
|
843
|
+
getAllContentTypeSettings: builder.query({
|
844
|
+
query: () => "/content-manager/content-types-settings",
|
845
|
+
transformResponse: (response) => response.data,
|
846
|
+
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
847
|
+
}),
|
848
|
+
updateContentTypeConfiguration: builder.mutation({
|
849
|
+
query: ({ uid, ...body }) => ({
|
850
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
851
|
+
method: "PUT",
|
852
|
+
data: body
|
853
|
+
}),
|
854
|
+
transformResponse: (response) => response.data,
|
855
|
+
invalidatesTags: (_result, _error, { uid }) => [
|
856
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
857
|
+
{ type: "ContentTypeSettings", id: "LIST" },
|
858
|
+
// Is this necessary?
|
859
|
+
{ type: "InitialData" }
|
860
|
+
]
|
861
|
+
})
|
862
|
+
})
|
863
|
+
});
|
864
|
+
const {
|
865
|
+
useGetContentTypeConfigurationQuery,
|
866
|
+
useGetAllContentTypeSettingsQuery,
|
867
|
+
useUpdateContentTypeConfigurationMutation
|
868
|
+
} = contentTypesApi;
|
869
|
+
const checkIfAttributeIsDisplayable = (attribute) => {
|
870
|
+
const { type } = attribute;
|
871
|
+
if (type === "relation") {
|
872
|
+
return !attribute.relation.toLowerCase().includes("morph");
|
873
|
+
}
|
874
|
+
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
875
|
+
};
|
876
|
+
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
877
|
+
if (!mainFieldName) {
|
878
|
+
return void 0;
|
879
|
+
}
|
880
|
+
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
881
|
+
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
882
|
+
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
883
|
+
);
|
884
|
+
return {
|
885
|
+
name: mainFieldName,
|
886
|
+
type: mainFieldType ?? "string"
|
887
|
+
};
|
888
|
+
};
|
889
|
+
const DEFAULT_SETTINGS = {
|
890
|
+
bulkable: false,
|
891
|
+
filterable: false,
|
892
|
+
searchable: false,
|
893
|
+
pagination: false,
|
894
|
+
defaultSortBy: "",
|
895
|
+
defaultSortOrder: "asc",
|
896
|
+
mainField: "id",
|
897
|
+
pageSize: 10
|
898
|
+
};
|
899
|
+
const useDocumentLayout = (model) => {
|
900
|
+
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
901
|
+
const [{ query }] = useQueryParams();
|
902
|
+
const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
759
903
|
const { toggleNotification } = useNotification();
|
760
904
|
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
905
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
761
906
|
const {
|
762
|
-
|
763
|
-
isLoading:
|
764
|
-
|
765
|
-
|
766
|
-
} =
|
767
|
-
const
|
907
|
+
data,
|
908
|
+
isLoading: isLoadingConfigs,
|
909
|
+
error,
|
910
|
+
isFetching: isFetchingConfigs
|
911
|
+
} = useGetContentTypeConfigurationQuery(model);
|
912
|
+
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
768
913
|
React.useEffect(() => {
|
769
914
|
if (error) {
|
770
915
|
toggleNotification({
|
@@ -772,68 +917,322 @@ const useDocument = (args, opts) => {
|
|
772
917
|
message: formatAPIError(error)
|
773
918
|
});
|
774
919
|
}
|
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
|
-
}
|
920
|
+
}, [error, formatAPIError, toggleNotification]);
|
921
|
+
const editLayout = React.useMemo(
|
922
|
+
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
923
|
+
layout: [],
|
924
|
+
components: {},
|
925
|
+
metadatas: {},
|
926
|
+
options: {},
|
927
|
+
settings: DEFAULT_SETTINGS
|
798
928
|
},
|
799
|
-
[
|
929
|
+
[data, isLoading, schemas, schema, components]
|
930
|
+
);
|
931
|
+
const listLayout = React.useMemo(() => {
|
932
|
+
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
933
|
+
layout: [],
|
934
|
+
metadatas: {},
|
935
|
+
options: {},
|
936
|
+
settings: DEFAULT_SETTINGS
|
937
|
+
};
|
938
|
+
}, [data, isLoading, schemas, schema, components]);
|
939
|
+
const { layout: edit } = React.useMemo(
|
940
|
+
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
941
|
+
layout: editLayout,
|
942
|
+
query
|
943
|
+
}),
|
944
|
+
[editLayout, query, runHookWaterfall]
|
800
945
|
);
|
801
|
-
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
802
946
|
return {
|
803
|
-
|
804
|
-
document: data?.data,
|
805
|
-
meta: data?.meta,
|
947
|
+
error,
|
806
948
|
isLoading,
|
807
|
-
|
808
|
-
|
949
|
+
edit,
|
950
|
+
list: listLayout
|
809
951
|
};
|
810
952
|
};
|
811
|
-
const
|
812
|
-
const {
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
953
|
+
const useDocLayout = () => {
|
954
|
+
const { model } = useDoc();
|
955
|
+
return useDocumentLayout(model);
|
956
|
+
};
|
957
|
+
const formatEditLayout = (data, {
|
958
|
+
schemas,
|
959
|
+
schema,
|
960
|
+
components
|
961
|
+
}) => {
|
962
|
+
let currentPanelIndex = 0;
|
963
|
+
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
964
|
+
data.contentType.layouts.edit,
|
965
|
+
schema?.attributes,
|
966
|
+
data.contentType.metadatas,
|
967
|
+
{ configurations: data.components, schemas: components },
|
968
|
+
schemas
|
969
|
+
).reduce((panels, row) => {
|
970
|
+
if (row.some((field) => field.type === "dynamiczone")) {
|
971
|
+
panels.push([row]);
|
972
|
+
currentPanelIndex += 2;
|
973
|
+
} else {
|
974
|
+
if (!panels[currentPanelIndex]) {
|
975
|
+
panels.push([row]);
|
976
|
+
} else {
|
977
|
+
panels[currentPanelIndex].push(row);
|
978
|
+
}
|
979
|
+
}
|
980
|
+
return panels;
|
981
|
+
}, []);
|
982
|
+
const componentEditAttributes = Object.entries(data.components).reduce(
|
983
|
+
(acc, [uid, configuration]) => {
|
984
|
+
acc[uid] = {
|
985
|
+
layout: convertEditLayoutToFieldLayouts(
|
986
|
+
configuration.layouts.edit,
|
987
|
+
components[uid].attributes,
|
988
|
+
configuration.metadatas,
|
989
|
+
{ configurations: data.components, schemas: components }
|
990
|
+
),
|
991
|
+
settings: {
|
992
|
+
...configuration.settings,
|
993
|
+
icon: components[uid].info.icon,
|
994
|
+
displayName: components[uid].info.displayName
|
995
|
+
}
|
996
|
+
};
|
997
|
+
return acc;
|
998
|
+
},
|
999
|
+
{}
|
1000
|
+
);
|
1001
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1002
|
+
(acc, [attribute, metadata]) => {
|
1003
|
+
return {
|
1004
|
+
...acc,
|
1005
|
+
[attribute]: metadata.edit
|
1006
|
+
};
|
1007
|
+
},
|
1008
|
+
{}
|
1009
|
+
);
|
1010
|
+
return {
|
1011
|
+
layout: panelledEditAttributes,
|
1012
|
+
components: componentEditAttributes,
|
1013
|
+
metadatas: editMetadatas,
|
1014
|
+
settings: {
|
1015
|
+
...data.contentType.settings,
|
1016
|
+
displayName: schema?.info.displayName
|
1017
|
+
},
|
1018
|
+
options: {
|
1019
|
+
...schema?.options,
|
1020
|
+
...schema?.pluginOptions,
|
1021
|
+
...data.contentType.options
|
1022
|
+
}
|
1023
|
+
};
|
1024
|
+
};
|
1025
|
+
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
1026
|
+
return rows.map(
|
1027
|
+
(row) => row.map((field) => {
|
1028
|
+
const attribute = attributes[field.name];
|
1029
|
+
if (!attribute) {
|
1030
|
+
return null;
|
1031
|
+
}
|
1032
|
+
const { edit: metadata } = metadatas[field.name];
|
1033
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1034
|
+
return {
|
1035
|
+
attribute,
|
1036
|
+
disabled: !metadata.editable,
|
1037
|
+
hint: metadata.description,
|
1038
|
+
label: metadata.label ?? "",
|
1039
|
+
name: field.name,
|
1040
|
+
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
1041
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1042
|
+
schemas,
|
1043
|
+
components: components?.schemas ?? {}
|
1044
|
+
}),
|
1045
|
+
placeholder: metadata.placeholder ?? "",
|
1046
|
+
required: attribute.required ?? false,
|
1047
|
+
size: field.size,
|
1048
|
+
unique: "unique" in attribute ? attribute.unique : false,
|
1049
|
+
visible: metadata.visible ?? true,
|
1050
|
+
type: attribute.type
|
1051
|
+
};
|
1052
|
+
}).filter((field) => field !== null)
|
1053
|
+
);
|
1054
|
+
};
|
1055
|
+
const formatListLayout = (data, {
|
1056
|
+
schemas,
|
1057
|
+
schema,
|
1058
|
+
components
|
1059
|
+
}) => {
|
1060
|
+
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1061
|
+
(acc, [attribute, metadata]) => {
|
1062
|
+
return {
|
1063
|
+
...acc,
|
1064
|
+
[attribute]: metadata.list
|
1065
|
+
};
|
1066
|
+
},
|
1067
|
+
{}
|
1068
|
+
);
|
1069
|
+
const listAttributes = convertListLayoutToFieldLayouts(
|
1070
|
+
data.contentType.layouts.list,
|
1071
|
+
schema?.attributes,
|
1072
|
+
listMetadatas,
|
1073
|
+
{ configurations: data.components, schemas: components },
|
1074
|
+
schemas
|
1075
|
+
);
|
1076
|
+
return {
|
1077
|
+
layout: listAttributes,
|
1078
|
+
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
1079
|
+
metadatas: listMetadatas,
|
1080
|
+
options: {
|
1081
|
+
...schema?.options,
|
1082
|
+
...schema?.pluginOptions,
|
1083
|
+
...data.contentType.options
|
1084
|
+
}
|
1085
|
+
};
|
1086
|
+
};
|
1087
|
+
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
1088
|
+
return columns.map((name) => {
|
1089
|
+
const attribute = attributes[name];
|
1090
|
+
if (!attribute) {
|
1091
|
+
return null;
|
1092
|
+
}
|
1093
|
+
const metadata = metadatas[name];
|
1094
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1095
|
+
return {
|
1096
|
+
attribute,
|
1097
|
+
label: metadata.label ?? "",
|
1098
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1099
|
+
schemas,
|
1100
|
+
components: components?.schemas ?? {}
|
1101
|
+
}),
|
1102
|
+
name,
|
1103
|
+
searchable: metadata.searchable ?? true,
|
1104
|
+
sortable: metadata.sortable ?? true
|
1105
|
+
};
|
1106
|
+
}).filter((field) => field !== null);
|
1107
|
+
};
|
1108
|
+
const useDocument = (args, opts) => {
|
1109
|
+
const { toggleNotification } = useNotification();
|
1110
|
+
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
1111
|
+
const {
|
1112
|
+
currentData: data,
|
1113
|
+
isLoading: isLoadingDocument,
|
1114
|
+
isFetching: isFetchingDocument,
|
1115
|
+
error
|
1116
|
+
} = useGetDocumentQuery(args, {
|
1117
|
+
...opts,
|
1118
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
1119
|
+
});
|
1120
|
+
const {
|
1121
|
+
components,
|
1122
|
+
schema,
|
1123
|
+
schemas,
|
1124
|
+
isLoading: isLoadingSchema
|
1125
|
+
} = useContentTypeSchema(args.model);
|
1126
|
+
React.useEffect(() => {
|
1127
|
+
if (error) {
|
1128
|
+
toggleNotification({
|
1129
|
+
type: "danger",
|
1130
|
+
message: formatAPIError(error)
|
1131
|
+
});
|
1132
|
+
}
|
1133
|
+
}, [toggleNotification, error, formatAPIError, args.collectionType]);
|
1134
|
+
const validationSchema = React.useMemo(() => {
|
1135
|
+
if (!schema) {
|
1136
|
+
return null;
|
1137
|
+
}
|
1138
|
+
return createYupSchema(schema.attributes, components);
|
1139
|
+
}, [schema, components]);
|
1140
|
+
const validate = React.useCallback(
|
1141
|
+
(document) => {
|
1142
|
+
if (!validationSchema) {
|
1143
|
+
throw new Error(
|
1144
|
+
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
1145
|
+
);
|
1146
|
+
}
|
1147
|
+
try {
|
1148
|
+
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
1149
|
+
return null;
|
1150
|
+
} catch (error2) {
|
1151
|
+
if (error2 instanceof ValidationError) {
|
1152
|
+
return getYupValidationErrors(error2);
|
1153
|
+
}
|
1154
|
+
throw error2;
|
1155
|
+
}
|
1156
|
+
},
|
1157
|
+
[validationSchema]
|
1158
|
+
);
|
1159
|
+
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
1160
|
+
const hasError = !!error;
|
1161
|
+
return {
|
1162
|
+
components,
|
1163
|
+
document: data?.data,
|
1164
|
+
meta: data?.meta,
|
1165
|
+
isLoading,
|
1166
|
+
hasError,
|
1167
|
+
schema,
|
1168
|
+
schemas,
|
1169
|
+
validate
|
1170
|
+
};
|
1171
|
+
};
|
1172
|
+
const useDoc = () => {
|
1173
|
+
const { id, slug, collectionType, origin } = useParams();
|
1174
|
+
const [{ query }] = useQueryParams();
|
1175
|
+
const params = React.useMemo(() => buildValidParams(query), [query]);
|
1176
|
+
if (!collectionType) {
|
1177
|
+
throw new Error("Could not find collectionType in url params");
|
1178
|
+
}
|
1179
|
+
if (!slug) {
|
819
1180
|
throw new Error("Could not find model in url params");
|
820
1181
|
}
|
1182
|
+
const document = useDocument(
|
1183
|
+
{ documentId: origin || id, model: slug, collectionType, params },
|
1184
|
+
{
|
1185
|
+
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
1186
|
+
}
|
1187
|
+
);
|
1188
|
+
const returnId = origin || id === "create" ? void 0 : id;
|
821
1189
|
return {
|
822
1190
|
collectionType,
|
823
1191
|
model: slug,
|
824
|
-
id:
|
825
|
-
...
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
1192
|
+
id: returnId,
|
1193
|
+
...document
|
1194
|
+
};
|
1195
|
+
};
|
1196
|
+
const useContentManagerContext = () => {
|
1197
|
+
const {
|
1198
|
+
collectionType,
|
1199
|
+
model,
|
1200
|
+
id,
|
1201
|
+
components,
|
1202
|
+
isLoading: isLoadingDoc,
|
1203
|
+
schema,
|
1204
|
+
schemas
|
1205
|
+
} = useDoc();
|
1206
|
+
const layout = useDocumentLayout(model);
|
1207
|
+
const form = useForm("useContentManagerContext", (state) => state);
|
1208
|
+
const isSingleType = collectionType === SINGLE_TYPES;
|
1209
|
+
const slug = model;
|
1210
|
+
const isCreatingEntry = id === "create";
|
1211
|
+
useContentTypeSchema();
|
1212
|
+
const isLoading = isLoadingDoc || layout.isLoading;
|
1213
|
+
const error = layout.error;
|
1214
|
+
return {
|
1215
|
+
error,
|
1216
|
+
isLoading,
|
1217
|
+
// Base metadata
|
1218
|
+
model,
|
1219
|
+
collectionType,
|
1220
|
+
id,
|
1221
|
+
slug,
|
1222
|
+
isCreatingEntry,
|
1223
|
+
isSingleType,
|
1224
|
+
hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
|
1225
|
+
// All schema infos
|
1226
|
+
components,
|
1227
|
+
contentType: schema,
|
1228
|
+
contentTypes: schemas,
|
1229
|
+
// Form state
|
1230
|
+
form,
|
1231
|
+
// layout infos
|
1232
|
+
layout
|
831
1233
|
};
|
832
1234
|
};
|
833
1235
|
const prefixPluginTranslations = (trad, pluginId) => {
|
834
|
-
if (!pluginId) {
|
835
|
-
throw new TypeError("pluginId can't be empty");
|
836
|
-
}
|
837
1236
|
return Object.keys(trad).reduce((acc, current) => {
|
838
1237
|
acc[`${pluginId}.${current}`] = trad[current];
|
839
1238
|
return acc;
|
@@ -849,6 +1248,8 @@ const useDocumentActions = () => {
|
|
849
1248
|
const { formatMessage } = useIntl();
|
850
1249
|
const { trackUsage } = useTracking();
|
851
1250
|
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
1251
|
+
const navigate = useNavigate();
|
1252
|
+
const setCurrentStep = useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
|
852
1253
|
const [deleteDocument] = useDeleteDocumentMutation();
|
853
1254
|
const _delete = React.useCallback(
|
854
1255
|
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
@@ -927,12 +1328,13 @@ const useDocumentActions = () => {
|
|
927
1328
|
);
|
928
1329
|
const [discardDocument] = useDiscardDocumentMutation();
|
929
1330
|
const discard = React.useCallback(
|
930
|
-
async ({ collectionType, model, documentId }) => {
|
1331
|
+
async ({ collectionType, model, documentId, params }) => {
|
931
1332
|
try {
|
932
1333
|
const res = await discardDocument({
|
933
1334
|
collectionType,
|
934
1335
|
model,
|
935
|
-
documentId
|
1336
|
+
documentId,
|
1337
|
+
params
|
936
1338
|
});
|
937
1339
|
if ("error" in res) {
|
938
1340
|
toggleNotification({
|
@@ -1162,6 +1564,7 @@ const useDocumentActions = () => {
|
|
1162
1564
|
defaultMessage: "Saved document"
|
1163
1565
|
})
|
1164
1566
|
});
|
1567
|
+
setCurrentStep("contentManager.success");
|
1165
1568
|
return res.data;
|
1166
1569
|
} catch (err) {
|
1167
1570
|
toggleNotification({
|
@@ -1183,7 +1586,6 @@ const useDocumentActions = () => {
|
|
1183
1586
|
sourceId
|
1184
1587
|
});
|
1185
1588
|
if ("error" in res) {
|
1186
|
-
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1187
1589
|
return { error: res.error };
|
1188
1590
|
}
|
1189
1591
|
toggleNotification({
|
@@ -1202,7 +1604,7 @@ const useDocumentActions = () => {
|
|
1202
1604
|
throw err;
|
1203
1605
|
}
|
1204
1606
|
},
|
1205
|
-
[autoCloneDocument,
|
1607
|
+
[autoCloneDocument, formatMessage, toggleNotification]
|
1206
1608
|
);
|
1207
1609
|
const [cloneDocument] = useCloneDocumentMutation();
|
1208
1610
|
const clone = React.useCallback(
|
@@ -1228,6 +1630,7 @@ const useDocumentActions = () => {
|
|
1228
1630
|
defaultMessage: "Cloned document"
|
1229
1631
|
})
|
1230
1632
|
});
|
1633
|
+
navigate(`../../${res.data.data.documentId}`, { relative: "path" });
|
1231
1634
|
return res.data;
|
1232
1635
|
} catch (err) {
|
1233
1636
|
toggleNotification({
|
@@ -1238,7 +1641,7 @@ const useDocumentActions = () => {
|
|
1238
1641
|
throw err;
|
1239
1642
|
}
|
1240
1643
|
},
|
1241
|
-
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
|
1644
|
+
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
|
1242
1645
|
);
|
1243
1646
|
const [getDoc] = useLazyGetDocumentQuery();
|
1244
1647
|
const getDocument = React.useCallback(
|
@@ -1263,10 +1666,10 @@ const useDocumentActions = () => {
|
|
1263
1666
|
update
|
1264
1667
|
};
|
1265
1668
|
};
|
1266
|
-
const ProtectedHistoryPage = lazy(
|
1267
|
-
() => import("./History-
|
1669
|
+
const ProtectedHistoryPage = React.lazy(
|
1670
|
+
() => import("./History-C4X3jiQJ.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1268
1671
|
);
|
1269
|
-
const routes$
|
1672
|
+
const routes$2 = [
|
1270
1673
|
{
|
1271
1674
|
path: ":collectionType/:slug/:id/history",
|
1272
1675
|
Component: ProtectedHistoryPage
|
@@ -1276,32 +1679,45 @@ const routes$1 = [
|
|
1276
1679
|
Component: ProtectedHistoryPage
|
1277
1680
|
}
|
1278
1681
|
];
|
1682
|
+
const ProtectedPreviewPage = React.lazy(
|
1683
|
+
() => import("./Preview-DwWET-X7.mjs").then((mod) => ({ default: mod.ProtectedPreviewPage }))
|
1684
|
+
);
|
1685
|
+
const routes$1 = [
|
1686
|
+
{
|
1687
|
+
path: ":collectionType/:slug/:id/preview",
|
1688
|
+
Component: ProtectedPreviewPage
|
1689
|
+
},
|
1690
|
+
{
|
1691
|
+
path: ":collectionType/:slug/preview",
|
1692
|
+
Component: ProtectedPreviewPage
|
1693
|
+
}
|
1694
|
+
];
|
1279
1695
|
const ProtectedEditViewPage = lazy(
|
1280
|
-
() => import("./EditViewPage-
|
1696
|
+
() => import("./EditViewPage-D2FPb5Mh.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1281
1697
|
);
|
1282
1698
|
const ProtectedListViewPage = lazy(
|
1283
|
-
() => import("./ListViewPage-
|
1699
|
+
() => import("./ListViewPage-CvxfiNTc.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1284
1700
|
);
|
1285
1701
|
const ProtectedListConfiguration = lazy(
|
1286
|
-
() => import("./ListConfigurationPage-
|
1702
|
+
() => import("./ListConfigurationPage-CwMU6tWQ.mjs").then((mod) => ({
|
1287
1703
|
default: mod.ProtectedListConfiguration
|
1288
1704
|
}))
|
1289
1705
|
);
|
1290
1706
|
const ProtectedEditConfigurationPage = lazy(
|
1291
|
-
() => import("./EditConfigurationPage-
|
1707
|
+
() => import("./EditConfigurationPage-DKtPyjs_.mjs").then((mod) => ({
|
1292
1708
|
default: mod.ProtectedEditConfigurationPage
|
1293
1709
|
}))
|
1294
1710
|
);
|
1295
1711
|
const ProtectedComponentConfigurationPage = lazy(
|
1296
|
-
() => import("./ComponentConfigurationPage-
|
1712
|
+
() => import("./ComponentConfigurationPage-viOAdZM6.mjs").then((mod) => ({
|
1297
1713
|
default: mod.ProtectedComponentConfigurationPage
|
1298
1714
|
}))
|
1299
1715
|
);
|
1300
1716
|
const NoPermissions = lazy(
|
1301
|
-
() => import("./NoPermissionsPage-
|
1717
|
+
() => import("./NoPermissionsPage-DiW-TIzq.mjs").then((mod) => ({ default: mod.NoPermissions }))
|
1302
1718
|
);
|
1303
1719
|
const NoContentType = lazy(
|
1304
|
-
() => import("./NoContentTypePage-
|
1720
|
+
() => import("./NoContentTypePage-Dy6sa9LT.mjs").then((mod) => ({ default: mod.NoContentType }))
|
1305
1721
|
);
|
1306
1722
|
const CollectionTypePages = () => {
|
1307
1723
|
const { collectionType } = useParams();
|
@@ -1313,7 +1729,7 @@ const CollectionTypePages = () => {
|
|
1313
1729
|
const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
|
1314
1730
|
const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
|
1315
1731
|
const LIST_RELATIVE_PATH = ":collectionType/:slug";
|
1316
|
-
const LIST_PATH = `/content-manager
|
1732
|
+
const LIST_PATH = `/content-manager/collection-types/:slug`;
|
1317
1733
|
const routes = [
|
1318
1734
|
{
|
1319
1735
|
path: LIST_RELATIVE_PATH,
|
@@ -1347,6 +1763,7 @@ const routes = [
|
|
1347
1763
|
path: "no-content-types",
|
1348
1764
|
Component: NoContentType
|
1349
1765
|
},
|
1766
|
+
...routes$2,
|
1350
1767
|
...routes$1
|
1351
1768
|
];
|
1352
1769
|
const DocumentActions = ({ actions: actions2 }) => {
|
@@ -1415,12 +1832,14 @@ const DocumentActionButton = (action) => {
|
|
1415
1832
|
/* @__PURE__ */ jsx(
|
1416
1833
|
Button,
|
1417
1834
|
{
|
1418
|
-
flex:
|
1835
|
+
flex: "auto",
|
1419
1836
|
startIcon: action.icon,
|
1420
1837
|
disabled: action.disabled,
|
1421
1838
|
onClick: handleClick(action),
|
1422
1839
|
justifyContent: "center",
|
1423
1840
|
variant: action.variant || "default",
|
1841
|
+
paddingTop: "7px",
|
1842
|
+
paddingBottom: "7px",
|
1424
1843
|
children: action.label
|
1425
1844
|
}
|
1426
1845
|
),
|
@@ -1428,7 +1847,7 @@ const DocumentActionButton = (action) => {
|
|
1428
1847
|
DocumentActionConfirmDialog,
|
1429
1848
|
{
|
1430
1849
|
...action.dialog,
|
1431
|
-
variant: action.variant,
|
1850
|
+
variant: action.dialog?.variant ?? action.variant,
|
1432
1851
|
isOpen: dialogId === action.id,
|
1433
1852
|
onClose: handleClose
|
1434
1853
|
}
|
@@ -1443,6 +1862,11 @@ const DocumentActionButton = (action) => {
|
|
1443
1862
|
) : null
|
1444
1863
|
] });
|
1445
1864
|
};
|
1865
|
+
const MenuItem = styled(Menu.Item)`
|
1866
|
+
&:hover {
|
1867
|
+
background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
|
1868
|
+
}
|
1869
|
+
`;
|
1446
1870
|
const DocumentActionsMenu = ({
|
1447
1871
|
actions: actions2,
|
1448
1872
|
children,
|
@@ -1485,9 +1909,9 @@ const DocumentActionsMenu = ({
|
|
1485
1909
|
disabled: isDisabled,
|
1486
1910
|
size: "S",
|
1487
1911
|
endIcon: null,
|
1488
|
-
paddingTop: "
|
1489
|
-
paddingLeft: "
|
1490
|
-
paddingRight: "
|
1912
|
+
paddingTop: "4px",
|
1913
|
+
paddingLeft: "7px",
|
1914
|
+
paddingRight: "7px",
|
1491
1915
|
variant,
|
1492
1916
|
children: [
|
1493
1917
|
/* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
|
@@ -1498,36 +1922,35 @@ const DocumentActionsMenu = ({
|
|
1498
1922
|
]
|
1499
1923
|
}
|
1500
1924
|
),
|
1501
|
-
/* @__PURE__ */ jsxs(Menu.Content, {
|
1925
|
+
/* @__PURE__ */ jsxs(Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
|
1502
1926
|
actions2.map((action) => {
|
1503
1927
|
return /* @__PURE__ */ jsx(
|
1504
|
-
|
1928
|
+
MenuItem,
|
1505
1929
|
{
|
1506
1930
|
disabled: action.disabled,
|
1507
1931
|
onSelect: handleClick(action),
|
1508
1932
|
display: "block",
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
] })
|
1933
|
+
isVariantDanger: action.variant === "danger",
|
1934
|
+
isDisabled: action.disabled,
|
1935
|
+
children: /* @__PURE__ */ jsx(Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxs(
|
1936
|
+
Flex,
|
1937
|
+
{
|
1938
|
+
color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
|
1939
|
+
gap: 2,
|
1940
|
+
tag: "span",
|
1941
|
+
children: [
|
1942
|
+
/* @__PURE__ */ jsx(
|
1943
|
+
Flex,
|
1944
|
+
{
|
1945
|
+
tag: "span",
|
1946
|
+
color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
|
1947
|
+
children: action.icon
|
1948
|
+
}
|
1949
|
+
),
|
1950
|
+
action.label
|
1951
|
+
]
|
1952
|
+
}
|
1953
|
+
) })
|
1531
1954
|
},
|
1532
1955
|
action.id
|
1533
1956
|
);
|
@@ -1569,6 +1992,18 @@ const convertActionVariantToColor = (variant = "secondary") => {
|
|
1569
1992
|
return "primary600";
|
1570
1993
|
}
|
1571
1994
|
};
|
1995
|
+
const convertActionVariantToIconColor = (variant = "secondary") => {
|
1996
|
+
switch (variant) {
|
1997
|
+
case "danger":
|
1998
|
+
return "danger600";
|
1999
|
+
case "secondary":
|
2000
|
+
return "neutral500";
|
2001
|
+
case "success":
|
2002
|
+
return "success600";
|
2003
|
+
default:
|
2004
|
+
return "primary600";
|
2005
|
+
}
|
2006
|
+
};
|
1572
2007
|
const DocumentActionConfirmDialog = ({
|
1573
2008
|
onClose,
|
1574
2009
|
onCancel,
|
@@ -1591,22 +2026,20 @@ const DocumentActionConfirmDialog = ({
|
|
1591
2026
|
}
|
1592
2027
|
onClose();
|
1593
2028
|
};
|
1594
|
-
return /* @__PURE__ */
|
1595
|
-
/* @__PURE__ */ jsx(
|
1596
|
-
/* @__PURE__ */ jsx(
|
1597
|
-
|
1598
|
-
{
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
)
|
1609
|
-
] });
|
2029
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
2030
|
+
/* @__PURE__ */ jsx(Dialog.Header, { children: title }),
|
2031
|
+
/* @__PURE__ */ jsx(Dialog.Body, { children: content }),
|
2032
|
+
/* @__PURE__ */ jsxs(Dialog.Footer, { children: [
|
2033
|
+
/* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
|
2034
|
+
id: "app.components.Button.cancel",
|
2035
|
+
defaultMessage: "Cancel"
|
2036
|
+
}) }) }),
|
2037
|
+
/* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
|
2038
|
+
id: "app.components.Button.confirm",
|
2039
|
+
defaultMessage: "Confirm"
|
2040
|
+
}) })
|
2041
|
+
] })
|
2042
|
+
] }) });
|
1610
2043
|
};
|
1611
2044
|
const DocumentActionModal = ({
|
1612
2045
|
isOpen,
|
@@ -1616,34 +2049,29 @@ const DocumentActionModal = ({
|
|
1616
2049
|
content: Content,
|
1617
2050
|
onModalClose
|
1618
2051
|
}) => {
|
1619
|
-
const id = React.useId();
|
1620
|
-
if (!isOpen) {
|
1621
|
-
return null;
|
1622
|
-
}
|
1623
2052
|
const handleClose = () => {
|
1624
2053
|
if (onClose) {
|
1625
2054
|
onClose();
|
1626
2055
|
}
|
1627
2056
|
onModalClose();
|
1628
2057
|
};
|
1629
|
-
return /* @__PURE__ */
|
1630
|
-
/* @__PURE__ */ jsx(
|
1631
|
-
|
1632
|
-
/* @__PURE__ */ jsx(
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
] });
|
2058
|
+
return /* @__PURE__ */ jsx(Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Modal.Content, { children: [
|
2059
|
+
/* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: title }) }),
|
2060
|
+
typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : /* @__PURE__ */ jsx(Modal.Body, { children: Content }),
|
2061
|
+
typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
|
2062
|
+
] }) });
|
2063
|
+
};
|
2064
|
+
const transformData = (data) => {
|
2065
|
+
if (Array.isArray(data)) {
|
2066
|
+
return data.map(transformData);
|
2067
|
+
}
|
2068
|
+
if (typeof data === "object" && data !== null) {
|
2069
|
+
if ("apiData" in data) {
|
2070
|
+
return data.apiData;
|
2071
|
+
}
|
2072
|
+
return mapValues(transformData)(data);
|
2073
|
+
}
|
2074
|
+
return data;
|
1647
2075
|
};
|
1648
2076
|
const PublishAction$1 = ({
|
1649
2077
|
activeTab,
|
@@ -1657,13 +2085,18 @@ const PublishAction$1 = ({
|
|
1657
2085
|
const navigate = useNavigate();
|
1658
2086
|
const { toggleNotification } = useNotification();
|
1659
2087
|
const { _unstableFormatValidationErrors: formatValidationErrors } = useAPIErrorHandler();
|
2088
|
+
const isListView = useMatch(LIST_PATH) !== null;
|
1660
2089
|
const isCloning = useMatch(CLONE_PATH) !== null;
|
2090
|
+
const { id } = useParams();
|
1661
2091
|
const { formatMessage } = useIntl();
|
1662
|
-
const { canPublish
|
1663
|
-
"PublishAction",
|
1664
|
-
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1665
|
-
);
|
2092
|
+
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
1666
2093
|
const { publish } = useDocumentActions();
|
2094
|
+
const [
|
2095
|
+
countDraftRelations,
|
2096
|
+
{ isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }
|
2097
|
+
] = useLazyGetDraftRelationCountQuery();
|
2098
|
+
const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React.useState(0);
|
2099
|
+
const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React.useState(0);
|
1667
2100
|
const [{ query, rawQuery }] = useQueryParams();
|
1668
2101
|
const params = React.useMemo(() => buildValidParams(query), [query]);
|
1669
2102
|
const modified = useForm("PublishAction", ({ modified: modified2 }) => modified2);
|
@@ -1672,10 +2105,107 @@ const PublishAction$1 = ({
|
|
1672
2105
|
const validate = useForm("PublishAction", (state) => state.validate);
|
1673
2106
|
const setErrors = useForm("PublishAction", (state) => state.setErrors);
|
1674
2107
|
const formValues = useForm("PublishAction", ({ values }) => values);
|
2108
|
+
React.useEffect(() => {
|
2109
|
+
if (isErrorDraftRelations) {
|
2110
|
+
toggleNotification({
|
2111
|
+
type: "danger",
|
2112
|
+
message: formatMessage({
|
2113
|
+
id: getTranslation("error.records.fetch-draft-relatons"),
|
2114
|
+
defaultMessage: "An error occurred while fetching draft relations on this document."
|
2115
|
+
})
|
2116
|
+
});
|
2117
|
+
}
|
2118
|
+
}, [isErrorDraftRelations, toggleNotification, formatMessage]);
|
2119
|
+
React.useEffect(() => {
|
2120
|
+
const localDraftRelations = /* @__PURE__ */ new Set();
|
2121
|
+
const extractDraftRelations = (data) => {
|
2122
|
+
const relations = data.connect || [];
|
2123
|
+
relations.forEach((relation) => {
|
2124
|
+
if (relation.status === "draft") {
|
2125
|
+
localDraftRelations.add(relation.id);
|
2126
|
+
}
|
2127
|
+
});
|
2128
|
+
};
|
2129
|
+
const traverseAndExtract = (data) => {
|
2130
|
+
Object.entries(data).forEach(([key, value]) => {
|
2131
|
+
if (key === "connect" && Array.isArray(value)) {
|
2132
|
+
extractDraftRelations({ connect: value });
|
2133
|
+
} else if (typeof value === "object" && value !== null) {
|
2134
|
+
traverseAndExtract(value);
|
2135
|
+
}
|
2136
|
+
});
|
2137
|
+
};
|
2138
|
+
if (!documentId || modified) {
|
2139
|
+
traverseAndExtract(formValues);
|
2140
|
+
setLocalCountOfDraftRelations(localDraftRelations.size);
|
2141
|
+
}
|
2142
|
+
}, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
|
2143
|
+
React.useEffect(() => {
|
2144
|
+
if (!document || !document.documentId || isListView) {
|
2145
|
+
return;
|
2146
|
+
}
|
2147
|
+
const fetchDraftRelationsCount = async () => {
|
2148
|
+
const { data, error } = await countDraftRelations({
|
2149
|
+
collectionType,
|
2150
|
+
model,
|
2151
|
+
documentId,
|
2152
|
+
params
|
2153
|
+
});
|
2154
|
+
if (error) {
|
2155
|
+
throw error;
|
2156
|
+
}
|
2157
|
+
if (data) {
|
2158
|
+
setServerCountOfDraftRelations(data.data);
|
2159
|
+
}
|
2160
|
+
};
|
2161
|
+
fetchDraftRelationsCount();
|
2162
|
+
}, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
|
1675
2163
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1676
2164
|
if (!schema?.options?.draftAndPublish) {
|
1677
2165
|
return null;
|
1678
2166
|
}
|
2167
|
+
const performPublish = async () => {
|
2168
|
+
setSubmitting(true);
|
2169
|
+
try {
|
2170
|
+
const { errors } = await validate(true, {
|
2171
|
+
status: "published"
|
2172
|
+
});
|
2173
|
+
if (errors) {
|
2174
|
+
toggleNotification({
|
2175
|
+
type: "danger",
|
2176
|
+
message: formatMessage({
|
2177
|
+
id: "content-manager.validation.error",
|
2178
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
2179
|
+
})
|
2180
|
+
});
|
2181
|
+
return;
|
2182
|
+
}
|
2183
|
+
const res = await publish(
|
2184
|
+
{
|
2185
|
+
collectionType,
|
2186
|
+
model,
|
2187
|
+
documentId,
|
2188
|
+
params
|
2189
|
+
},
|
2190
|
+
transformData(formValues)
|
2191
|
+
);
|
2192
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
2193
|
+
if (id === "create") {
|
2194
|
+
navigate({
|
2195
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
2196
|
+
search: rawQuery
|
2197
|
+
});
|
2198
|
+
}
|
2199
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2200
|
+
setErrors(formatValidationErrors(res.error));
|
2201
|
+
}
|
2202
|
+
} finally {
|
2203
|
+
setSubmitting(false);
|
2204
|
+
}
|
2205
|
+
};
|
2206
|
+
const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
|
2207
|
+
const enableDraftRelationsCount = false;
|
2208
|
+
const hasDraftRelations = enableDraftRelationsCount;
|
1679
2209
|
return {
|
1680
2210
|
/**
|
1681
2211
|
* Disabled when:
|
@@ -1685,52 +2215,40 @@ const PublishAction$1 = ({
|
|
1685
2215
|
* - the document is already published & not modified
|
1686
2216
|
* - the document is being created & not modified
|
1687
2217
|
* - the user doesn't have the permission to publish
|
1688
|
-
* - the user doesn't have the permission to create a new document
|
1689
|
-
* - the user doesn't have the permission to update the document
|
1690
2218
|
*/
|
1691
|
-
disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish
|
2219
|
+
disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
|
1692
2220
|
label: formatMessage({
|
1693
2221
|
id: "app.utils.publish",
|
1694
2222
|
defaultMessage: "Publish"
|
1695
2223
|
}),
|
1696
2224
|
onClick: async () => {
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
documentId,
|
1715
|
-
params
|
1716
|
-
},
|
1717
|
-
formValues
|
1718
|
-
);
|
1719
|
-
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1720
|
-
navigate({
|
1721
|
-
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1722
|
-
search: rawQuery
|
1723
|
-
});
|
1724
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1725
|
-
setErrors(formatValidationErrors(res.error));
|
2225
|
+
await performPublish();
|
2226
|
+
},
|
2227
|
+
dialog: hasDraftRelations ? {
|
2228
|
+
type: "dialog",
|
2229
|
+
variant: "danger",
|
2230
|
+
footer: null,
|
2231
|
+
title: formatMessage({
|
2232
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.title`),
|
2233
|
+
defaultMessage: "Confirmation"
|
2234
|
+
}),
|
2235
|
+
content: formatMessage(
|
2236
|
+
{
|
2237
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
|
2238
|
+
defaultMessage: "This entry is related to {count, plural, one {# draft entry} other {# draft entries}}. Publishing it could leave broken links in your app."
|
2239
|
+
},
|
2240
|
+
{
|
2241
|
+
count: totalDraftRelations
|
1726
2242
|
}
|
1727
|
-
|
1728
|
-
|
2243
|
+
),
|
2244
|
+
onConfirm: async () => {
|
2245
|
+
await performPublish();
|
1729
2246
|
}
|
1730
|
-
}
|
2247
|
+
} : void 0
|
1731
2248
|
};
|
1732
2249
|
};
|
1733
2250
|
PublishAction$1.type = "publish";
|
2251
|
+
PublishAction$1.position = "panel";
|
1734
2252
|
const UpdateAction = ({
|
1735
2253
|
activeTab,
|
1736
2254
|
documentId,
|
@@ -1743,10 +2261,6 @@ const UpdateAction = ({
|
|
1743
2261
|
const cloneMatch = useMatch(CLONE_PATH);
|
1744
2262
|
const isCloning = cloneMatch !== null;
|
1745
2263
|
const { formatMessage } = useIntl();
|
1746
|
-
const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
|
1747
|
-
canCreate: canCreate2,
|
1748
|
-
canUpdate: canUpdate2
|
1749
|
-
}));
|
1750
2264
|
const { create, update, clone } = useDocumentActions();
|
1751
2265
|
const [{ query, rawQuery }] = useQueryParams();
|
1752
2266
|
const params = React.useMemo(() => buildValidParams(query), [query]);
|
@@ -1763,18 +2277,18 @@ const UpdateAction = ({
|
|
1763
2277
|
* - the form is submitting
|
1764
2278
|
* - the document is not modified & we're not cloning (you can save a clone entity straight away)
|
1765
2279
|
* - the active tab is the published tab
|
1766
|
-
* - the user doesn't have the permission to create a new document
|
1767
|
-
* - the user doesn't have the permission to update the document
|
1768
2280
|
*/
|
1769
|
-
disabled: isSubmitting || !modified && !isCloning || activeTab === "published"
|
2281
|
+
disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
|
1770
2282
|
label: formatMessage({
|
1771
|
-
id: "
|
2283
|
+
id: "global.save",
|
1772
2284
|
defaultMessage: "Save"
|
1773
2285
|
}),
|
1774
2286
|
onClick: async () => {
|
1775
2287
|
setSubmitting(true);
|
1776
2288
|
try {
|
1777
|
-
const { errors } = await validate(
|
2289
|
+
const { errors } = await validate(true, {
|
2290
|
+
status: "draft"
|
2291
|
+
});
|
1778
2292
|
if (errors) {
|
1779
2293
|
toggleNotification({
|
1780
2294
|
type: "danger",
|
@@ -1792,13 +2306,16 @@ const UpdateAction = ({
|
|
1792
2306
|
documentId: cloneMatch.params.origin,
|
1793
2307
|
params
|
1794
2308
|
},
|
1795
|
-
document
|
2309
|
+
transformData(document)
|
1796
2310
|
);
|
1797
2311
|
if ("data" in res) {
|
1798
|
-
navigate(
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
2312
|
+
navigate(
|
2313
|
+
{
|
2314
|
+
pathname: `../${res.data.documentId}`,
|
2315
|
+
search: rawQuery
|
2316
|
+
},
|
2317
|
+
{ relative: "path" }
|
2318
|
+
);
|
1802
2319
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1803
2320
|
setErrors(formatValidationErrors(res.error));
|
1804
2321
|
}
|
@@ -1810,7 +2327,7 @@ const UpdateAction = ({
|
|
1810
2327
|
documentId,
|
1811
2328
|
params
|
1812
2329
|
},
|
1813
|
-
document
|
2330
|
+
transformData(document)
|
1814
2331
|
);
|
1815
2332
|
if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1816
2333
|
setErrors(formatValidationErrors(res.error));
|
@@ -1823,13 +2340,16 @@ const UpdateAction = ({
|
|
1823
2340
|
model,
|
1824
2341
|
params
|
1825
2342
|
},
|
1826
|
-
document
|
2343
|
+
transformData(document)
|
1827
2344
|
);
|
1828
2345
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1829
|
-
navigate(
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
2346
|
+
navigate(
|
2347
|
+
{
|
2348
|
+
pathname: `../${res.data.documentId}`,
|
2349
|
+
search: rawQuery
|
2350
|
+
},
|
2351
|
+
{ replace: true, relative: "path" }
|
2352
|
+
);
|
1833
2353
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1834
2354
|
setErrors(formatValidationErrors(res.error));
|
1835
2355
|
}
|
@@ -1841,6 +2361,7 @@ const UpdateAction = ({
|
|
1841
2361
|
};
|
1842
2362
|
};
|
1843
2363
|
UpdateAction.type = "update";
|
2364
|
+
UpdateAction.position = "panel";
|
1844
2365
|
const UNPUBLISH_DRAFT_OPTIONS = {
|
1845
2366
|
KEEP: "keep",
|
1846
2367
|
DISCARD: "discard"
|
@@ -1861,10 +2382,8 @@ const UnpublishAction$1 = ({
|
|
1861
2382
|
const { toggleNotification } = useNotification();
|
1862
2383
|
const [shouldKeepDraft, setShouldKeepDraft] = React.useState(true);
|
1863
2384
|
const isDocumentModified = document?.status === "modified";
|
1864
|
-
const handleChange = (
|
1865
|
-
|
1866
|
-
setShouldKeepDraft(e.target.value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1867
|
-
}
|
2385
|
+
const handleChange = (value) => {
|
2386
|
+
setShouldKeepDraft(value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1868
2387
|
};
|
1869
2388
|
if (!schema?.options?.draftAndPublish) {
|
1870
2389
|
return null;
|
@@ -1875,7 +2394,7 @@ const UnpublishAction$1 = ({
|
|
1875
2394
|
id: "app.utils.unpublish",
|
1876
2395
|
defaultMessage: "Unpublish"
|
1877
2396
|
}),
|
1878
|
-
icon: /* @__PURE__ */ jsx(
|
2397
|
+
icon: /* @__PURE__ */ jsx(Cross, {}),
|
1879
2398
|
onClick: async () => {
|
1880
2399
|
if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
|
1881
2400
|
if (!documentId) {
|
@@ -1914,40 +2433,24 @@ const UnpublishAction$1 = ({
|
|
1914
2433
|
}) })
|
1915
2434
|
] }),
|
1916
2435
|
/* @__PURE__ */ jsxs(
|
1917
|
-
|
2436
|
+
Radio.Group,
|
1918
2437
|
{
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
2438
|
+
defaultValue: UNPUBLISH_DRAFT_OPTIONS.KEEP,
|
2439
|
+
name: "discard-options",
|
2440
|
+
"aria-label": formatMessage({
|
2441
|
+
id: "content-manager.actions.unpublish.dialog.radio-label",
|
2442
|
+
defaultMessage: "Choose an option to unpublish the document."
|
2443
|
+
}),
|
2444
|
+
onValueChange: handleChange,
|
1925
2445
|
children: [
|
1926
|
-
/* @__PURE__ */ jsx(
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
1935
|
-
defaultMessage: "Keep draft"
|
1936
|
-
})
|
1937
|
-
}
|
1938
|
-
),
|
1939
|
-
/* @__PURE__ */ jsx(
|
1940
|
-
Radio,
|
1941
|
-
{
|
1942
|
-
checked: !shouldKeepDraft,
|
1943
|
-
value: UNPUBLISH_DRAFT_OPTIONS.DISCARD,
|
1944
|
-
name: "discard-options",
|
1945
|
-
children: formatMessage({
|
1946
|
-
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
1947
|
-
defaultMessage: "Replace draft"
|
1948
|
-
})
|
1949
|
-
}
|
1950
|
-
)
|
2446
|
+
/* @__PURE__ */ jsx(Radio.Item, { checked: shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.KEEP, children: formatMessage({
|
2447
|
+
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
2448
|
+
defaultMessage: "Keep draft"
|
2449
|
+
}) }),
|
2450
|
+
/* @__PURE__ */ jsx(Radio.Item, { checked: !shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.DISCARD, children: formatMessage({
|
2451
|
+
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
2452
|
+
defaultMessage: "Replace draft"
|
2453
|
+
}) })
|
1951
2454
|
]
|
1952
2455
|
}
|
1953
2456
|
)
|
@@ -1981,6 +2484,7 @@ const UnpublishAction$1 = ({
|
|
1981
2484
|
};
|
1982
2485
|
};
|
1983
2486
|
UnpublishAction$1.type = "unpublish";
|
2487
|
+
UnpublishAction$1.position = "panel";
|
1984
2488
|
const DiscardAction = ({
|
1985
2489
|
activeTab,
|
1986
2490
|
documentId,
|
@@ -2003,7 +2507,7 @@ const DiscardAction = ({
|
|
2003
2507
|
id: "content-manager.actions.discard.label",
|
2004
2508
|
defaultMessage: "Discard changes"
|
2005
2509
|
}),
|
2006
|
-
icon: /* @__PURE__ */ jsx(
|
2510
|
+
icon: /* @__PURE__ */ jsx(Cross, {}),
|
2007
2511
|
position: ["panel", "table-row"],
|
2008
2512
|
variant: "danger",
|
2009
2513
|
dialog: {
|
@@ -2031,11 +2535,7 @@ const DiscardAction = ({
|
|
2031
2535
|
};
|
2032
2536
|
};
|
2033
2537
|
DiscardAction.type = "discard";
|
2034
|
-
|
2035
|
-
path {
|
2036
|
-
fill: currentColor;
|
2037
|
-
}
|
2038
|
-
`;
|
2538
|
+
DiscardAction.position = "panel";
|
2039
2539
|
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
2040
2540
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
2041
2541
|
const RelativeTime = React.forwardRef(
|
@@ -2048,7 +2548,7 @@ const RelativeTime = React.forwardRef(
|
|
2048
2548
|
});
|
2049
2549
|
const unit = intervals.find((intervalUnit) => {
|
2050
2550
|
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
|
2051
|
-
});
|
2551
|
+
}) ?? "seconds";
|
2052
2552
|
const relativeTime = isPast(timestamp) ? -interval[unit] : interval[unit];
|
2053
2553
|
const customInterval = customIntervals.find(
|
2054
2554
|
(custom) => interval[custom.unit] < custom.threshold
|
@@ -2082,34 +2582,34 @@ const getDisplayName = ({
|
|
2082
2582
|
return email ?? "";
|
2083
2583
|
};
|
2084
2584
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2085
|
-
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2086
|
-
const statusVariant = status === "draft" ? "
|
2087
|
-
|
2585
|
+
const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
|
2586
|
+
const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
|
2587
|
+
const { formatMessage } = useIntl();
|
2588
|
+
return /* @__PURE__ */ jsx(Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
|
2589
|
+
id: `content-manager.containers.List.${status}`,
|
2590
|
+
defaultMessage: capitalise(status)
|
2591
|
+
}) }) });
|
2088
2592
|
};
|
2089
2593
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
2090
2594
|
const { formatMessage } = useIntl();
|
2091
2595
|
const isCloning = useMatch(CLONE_PATH) !== null;
|
2596
|
+
const params = useParams();
|
2092
2597
|
const title = isCreating ? formatMessage({
|
2093
2598
|
id: "content-manager.containers.edit.title.new",
|
2094
2599
|
defaultMessage: "Create an entry"
|
2095
2600
|
}) : documentTitle;
|
2096
|
-
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop:
|
2097
|
-
/* @__PURE__ */ jsx(
|
2098
|
-
|
2099
|
-
Flex,
|
2601
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2602
|
+
/* @__PURE__ */ jsx(
|
2603
|
+
BackButton,
|
2100
2604
|
{
|
2101
|
-
|
2102
|
-
justifyContent: "space-between",
|
2103
|
-
paddingTop: 1,
|
2104
|
-
gap: "80px",
|
2105
|
-
alignItems: "flex-start",
|
2106
|
-
children: [
|
2107
|
-
/* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
|
2108
|
-
/* @__PURE__ */ jsx(HeaderToolbar, {})
|
2109
|
-
]
|
2605
|
+
fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
|
2110
2606
|
}
|
2111
2607
|
),
|
2112
|
-
|
2608
|
+
/* @__PURE__ */ jsxs(Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2609
|
+
/* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
|
2610
|
+
/* @__PURE__ */ jsx(HeaderToolbar, {})
|
2611
|
+
] }),
|
2612
|
+
status ? /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
|
2113
2613
|
] });
|
2114
2614
|
};
|
2115
2615
|
const HeaderToolbar = () => {
|
@@ -2155,7 +2655,7 @@ const HeaderToolbar = () => {
|
|
2155
2655
|
meta: isCloning ? void 0 : meta,
|
2156
2656
|
collectionType
|
2157
2657
|
},
|
2158
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2658
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("header"),
|
2159
2659
|
children: (actions2) => {
|
2160
2660
|
const headerActions = actions2.filter((action) => {
|
2161
2661
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -2192,12 +2692,12 @@ const Information = ({ activeTab }) => {
|
|
2192
2692
|
isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
|
2193
2693
|
label: formatMessage({
|
2194
2694
|
id: "content-manager.containers.edit.information.last-published.label",
|
2195
|
-
defaultMessage: "
|
2695
|
+
defaultMessage: "Published"
|
2196
2696
|
}),
|
2197
2697
|
value: formatMessage(
|
2198
2698
|
{
|
2199
2699
|
id: "content-manager.containers.edit.information.last-published.value",
|
2200
|
-
defaultMessage: `
|
2700
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2201
2701
|
},
|
2202
2702
|
{
|
2203
2703
|
time: /* @__PURE__ */ jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
|
@@ -2210,12 +2710,12 @@ const Information = ({ activeTab }) => {
|
|
2210
2710
|
isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
|
2211
2711
|
label: formatMessage({
|
2212
2712
|
id: "content-manager.containers.edit.information.last-draft.label",
|
2213
|
-
defaultMessage: "
|
2713
|
+
defaultMessage: "Updated"
|
2214
2714
|
}),
|
2215
2715
|
value: formatMessage(
|
2216
2716
|
{
|
2217
2717
|
id: "content-manager.containers.edit.information.last-draft.value",
|
2218
|
-
defaultMessage: `
|
2718
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2219
2719
|
},
|
2220
2720
|
{
|
2221
2721
|
time: /* @__PURE__ */ jsx(
|
@@ -2233,12 +2733,12 @@ const Information = ({ activeTab }) => {
|
|
2233
2733
|
isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
|
2234
2734
|
label: formatMessage({
|
2235
2735
|
id: "content-manager.containers.edit.information.document.label",
|
2236
|
-
defaultMessage: "
|
2736
|
+
defaultMessage: "Created"
|
2237
2737
|
}),
|
2238
2738
|
value: formatMessage(
|
2239
2739
|
{
|
2240
2740
|
id: "content-manager.containers.edit.information.document.value",
|
2241
|
-
defaultMessage: `
|
2741
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2242
2742
|
},
|
2243
2743
|
{
|
2244
2744
|
time: /* @__PURE__ */ jsx(
|
@@ -2276,25 +2776,77 @@ const Information = ({ activeTab }) => {
|
|
2276
2776
|
);
|
2277
2777
|
};
|
2278
2778
|
const HeaderActions = ({ actions: actions2 }) => {
|
2279
|
-
|
2280
|
-
|
2779
|
+
const [dialogId, setDialogId] = React.useState(null);
|
2780
|
+
const handleClick = (action) => async (e) => {
|
2781
|
+
if (!("options" in action)) {
|
2782
|
+
const { onClick = () => false, dialog, id } = action;
|
2783
|
+
const muteDialog = await onClick(e);
|
2784
|
+
if (dialog && !muteDialog) {
|
2785
|
+
e.preventDefault();
|
2786
|
+
setDialogId(id);
|
2787
|
+
}
|
2788
|
+
}
|
2789
|
+
};
|
2790
|
+
const handleClose = () => {
|
2791
|
+
setDialogId(null);
|
2792
|
+
};
|
2793
|
+
return /* @__PURE__ */ jsx(Flex, { gap: 1, children: actions2.map((action) => {
|
2794
|
+
if (action.options) {
|
2281
2795
|
return /* @__PURE__ */ jsx(
|
2282
2796
|
SingleSelect,
|
2283
2797
|
{
|
2284
2798
|
size: "S",
|
2285
|
-
disabled: action.disabled,
|
2286
|
-
"aria-label": action.label,
|
2287
2799
|
onChange: action.onSelect,
|
2288
|
-
|
2800
|
+
"aria-label": action.label,
|
2801
|
+
...action,
|
2289
2802
|
children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsx(SingleSelectOption, { ...option, children: label }, option.value))
|
2290
2803
|
},
|
2291
2804
|
action.id
|
2292
2805
|
);
|
2293
2806
|
} else {
|
2294
|
-
|
2807
|
+
if (action.type === "icon") {
|
2808
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
2809
|
+
/* @__PURE__ */ jsx(
|
2810
|
+
IconButton,
|
2811
|
+
{
|
2812
|
+
disabled: action.disabled,
|
2813
|
+
label: action.label,
|
2814
|
+
size: "S",
|
2815
|
+
onClick: handleClick(action),
|
2816
|
+
children: action.icon
|
2817
|
+
}
|
2818
|
+
),
|
2819
|
+
action.dialog ? /* @__PURE__ */ jsx(
|
2820
|
+
HeaderActionDialog,
|
2821
|
+
{
|
2822
|
+
...action.dialog,
|
2823
|
+
isOpen: dialogId === action.id,
|
2824
|
+
onClose: handleClose
|
2825
|
+
}
|
2826
|
+
) : null
|
2827
|
+
] }, action.id);
|
2828
|
+
}
|
2295
2829
|
}
|
2296
2830
|
}) });
|
2297
2831
|
};
|
2832
|
+
const HeaderActionDialog = ({
|
2833
|
+
onClose,
|
2834
|
+
onCancel,
|
2835
|
+
title,
|
2836
|
+
content: Content,
|
2837
|
+
isOpen
|
2838
|
+
}) => {
|
2839
|
+
const handleClose = async () => {
|
2840
|
+
if (onCancel) {
|
2841
|
+
await onCancel();
|
2842
|
+
}
|
2843
|
+
onClose();
|
2844
|
+
};
|
2845
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
2846
|
+
/* @__PURE__ */ jsx(Dialog.Header, { children: title }),
|
2847
|
+
typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : Content
|
2848
|
+
] }) });
|
2849
|
+
};
|
2298
2850
|
const ConfigureTheViewAction = ({ collectionType, model }) => {
|
2299
2851
|
const navigate = useNavigate();
|
2300
2852
|
const { formatMessage } = useIntl();
|
@@ -2311,6 +2863,7 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
|
|
2311
2863
|
};
|
2312
2864
|
};
|
2313
2865
|
ConfigureTheViewAction.type = "configure-the-view";
|
2866
|
+
ConfigureTheViewAction.position = "header";
|
2314
2867
|
const EditTheModelAction = ({ model }) => {
|
2315
2868
|
const navigate = useNavigate();
|
2316
2869
|
const { formatMessage } = useIntl();
|
@@ -2327,6 +2880,7 @@ const EditTheModelAction = ({ model }) => {
|
|
2327
2880
|
};
|
2328
2881
|
};
|
2329
2882
|
EditTheModelAction.type = "edit-the-model";
|
2883
|
+
EditTheModelAction.position = "header";
|
2330
2884
|
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2331
2885
|
const navigate = useNavigate();
|
2332
2886
|
const { formatMessage } = useIntl();
|
@@ -2335,12 +2889,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2335
2889
|
const { delete: deleteAction } = useDocumentActions();
|
2336
2890
|
const { toggleNotification } = useNotification();
|
2337
2891
|
const setSubmitting = useForm("DeleteAction", (state) => state.setSubmitting);
|
2892
|
+
const isLocalized = document?.locale != null;
|
2338
2893
|
return {
|
2339
2894
|
disabled: !canDelete || !document,
|
2340
|
-
label: formatMessage(
|
2341
|
-
|
2342
|
-
|
2343
|
-
|
2895
|
+
label: formatMessage(
|
2896
|
+
{
|
2897
|
+
id: "content-manager.actions.delete.label",
|
2898
|
+
defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
|
2899
|
+
},
|
2900
|
+
{ isLocalized }
|
2901
|
+
),
|
2344
2902
|
icon: /* @__PURE__ */ jsx(Trash, {}),
|
2345
2903
|
dialog: {
|
2346
2904
|
type: "dialog",
|
@@ -2396,6 +2954,7 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2396
2954
|
};
|
2397
2955
|
};
|
2398
2956
|
DeleteAction$1.type = "delete";
|
2957
|
+
DeleteAction$1.position = ["header", "table-row"];
|
2399
2958
|
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2400
2959
|
const Panels = () => {
|
2401
2960
|
const isCloning = useMatch(CLONE_PATH) !== null;
|
@@ -2430,7 +2989,7 @@ const ActionsPanel = () => {
|
|
2430
2989
|
return {
|
2431
2990
|
title: formatMessage({
|
2432
2991
|
id: "content-manager.containers.edit.panels.default.title",
|
2433
|
-
defaultMessage: "
|
2992
|
+
defaultMessage: "Entry"
|
2434
2993
|
}),
|
2435
2994
|
content: /* @__PURE__ */ jsx(ActionsPanelContent, {})
|
2436
2995
|
};
|
@@ -2458,7 +3017,7 @@ const ActionsPanelContent = () => {
|
|
2458
3017
|
DescriptionComponentRenderer,
|
2459
3018
|
{
|
2460
3019
|
props,
|
2461
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3020
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("panel"),
|
2462
3021
|
children: (actions2) => /* @__PURE__ */ jsx(DocumentActions, { actions: actions2 })
|
2463
3022
|
}
|
2464
3023
|
),
|
@@ -2485,314 +3044,12 @@ const Panel = React.forwardRef(({ children, title }, ref) => {
|
|
2485
3044
|
justifyContent: "stretch",
|
2486
3045
|
alignItems: "flex-start",
|
2487
3046
|
children: [
|
2488
|
-
/* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
|
3047
|
+
/* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
|
2489
3048
|
children
|
2490
3049
|
]
|
2491
3050
|
}
|
2492
|
-
);
|
2493
|
-
});
|
2494
|
-
const HOOKS = {
|
2495
|
-
/**
|
2496
|
-
* Hook that allows to mutate the displayed headers of the list view table
|
2497
|
-
* @constant
|
2498
|
-
* @type {string}
|
2499
|
-
*/
|
2500
|
-
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
2501
|
-
/**
|
2502
|
-
* Hook that allows to mutate the CM's collection types links pre-set filters
|
2503
|
-
* @constant
|
2504
|
-
* @type {string}
|
2505
|
-
*/
|
2506
|
-
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
2507
|
-
/**
|
2508
|
-
* Hook that allows to mutate the CM's edit view layout
|
2509
|
-
* @constant
|
2510
|
-
* @type {string}
|
2511
|
-
*/
|
2512
|
-
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
2513
|
-
/**
|
2514
|
-
* Hook that allows to mutate the CM's single types links pre-set filters
|
2515
|
-
* @constant
|
2516
|
-
* @type {string}
|
2517
|
-
*/
|
2518
|
-
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
2519
|
-
};
|
2520
|
-
const contentTypesApi = contentManagerApi.injectEndpoints({
|
2521
|
-
endpoints: (builder) => ({
|
2522
|
-
getContentTypeConfiguration: builder.query({
|
2523
|
-
query: (uid) => ({
|
2524
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2525
|
-
method: "GET"
|
2526
|
-
}),
|
2527
|
-
transformResponse: (response) => response.data,
|
2528
|
-
providesTags: (_result, _error, uid) => [
|
2529
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2530
|
-
{ type: "ContentTypeSettings", id: "LIST" }
|
2531
|
-
]
|
2532
|
-
}),
|
2533
|
-
getAllContentTypeSettings: builder.query({
|
2534
|
-
query: () => "/content-manager/content-types-settings",
|
2535
|
-
transformResponse: (response) => response.data,
|
2536
|
-
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
2537
|
-
}),
|
2538
|
-
updateContentTypeConfiguration: builder.mutation({
|
2539
|
-
query: ({ uid, ...body }) => ({
|
2540
|
-
url: `/content-manager/content-types/${uid}/configuration`,
|
2541
|
-
method: "PUT",
|
2542
|
-
data: body
|
2543
|
-
}),
|
2544
|
-
transformResponse: (response) => response.data,
|
2545
|
-
invalidatesTags: (_result, _error, { uid }) => [
|
2546
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2547
|
-
{ type: "ContentTypeSettings", id: "LIST" },
|
2548
|
-
// Is this necessary?
|
2549
|
-
{ type: "InitialData" }
|
2550
|
-
]
|
2551
|
-
})
|
2552
|
-
})
|
2553
|
-
});
|
2554
|
-
const {
|
2555
|
-
useGetContentTypeConfigurationQuery,
|
2556
|
-
useGetAllContentTypeSettingsQuery,
|
2557
|
-
useUpdateContentTypeConfigurationMutation
|
2558
|
-
} = contentTypesApi;
|
2559
|
-
const checkIfAttributeIsDisplayable = (attribute) => {
|
2560
|
-
const { type } = attribute;
|
2561
|
-
if (type === "relation") {
|
2562
|
-
return !attribute.relation.toLowerCase().includes("morph");
|
2563
|
-
}
|
2564
|
-
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
2565
|
-
};
|
2566
|
-
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
2567
|
-
if (!mainFieldName) {
|
2568
|
-
return void 0;
|
2569
|
-
}
|
2570
|
-
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
2571
|
-
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
2572
|
-
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2573
|
-
);
|
2574
|
-
return {
|
2575
|
-
name: mainFieldName,
|
2576
|
-
type: mainFieldType ?? "string"
|
2577
|
-
};
|
2578
|
-
};
|
2579
|
-
const DEFAULT_SETTINGS = {
|
2580
|
-
bulkable: false,
|
2581
|
-
filterable: false,
|
2582
|
-
searchable: false,
|
2583
|
-
pagination: false,
|
2584
|
-
defaultSortBy: "",
|
2585
|
-
defaultSortOrder: "asc",
|
2586
|
-
mainField: "id",
|
2587
|
-
pageSize: 10
|
2588
|
-
};
|
2589
|
-
const useDocumentLayout = (model) => {
|
2590
|
-
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
2591
|
-
const [{ query }] = useQueryParams();
|
2592
|
-
const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
2593
|
-
const { toggleNotification } = useNotification();
|
2594
|
-
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
2595
|
-
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
2596
|
-
const {
|
2597
|
-
data,
|
2598
|
-
isLoading: isLoadingConfigs,
|
2599
|
-
error,
|
2600
|
-
isFetching: isFetchingConfigs
|
2601
|
-
} = useGetContentTypeConfigurationQuery(model);
|
2602
|
-
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
2603
|
-
React.useEffect(() => {
|
2604
|
-
if (error) {
|
2605
|
-
toggleNotification({
|
2606
|
-
type: "danger",
|
2607
|
-
message: formatAPIError(error)
|
2608
|
-
});
|
2609
|
-
}
|
2610
|
-
}, [error, formatAPIError, toggleNotification]);
|
2611
|
-
const editLayout = React.useMemo(
|
2612
|
-
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
2613
|
-
layout: [],
|
2614
|
-
components: {},
|
2615
|
-
metadatas: {},
|
2616
|
-
options: {},
|
2617
|
-
settings: DEFAULT_SETTINGS
|
2618
|
-
},
|
2619
|
-
[data, isLoading, schemas, schema, components]
|
2620
|
-
);
|
2621
|
-
const listLayout = React.useMemo(() => {
|
2622
|
-
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
2623
|
-
layout: [],
|
2624
|
-
metadatas: {},
|
2625
|
-
options: {},
|
2626
|
-
settings: DEFAULT_SETTINGS
|
2627
|
-
};
|
2628
|
-
}, [data, isLoading, schemas, schema, components]);
|
2629
|
-
const { layout: edit } = React.useMemo(
|
2630
|
-
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
2631
|
-
layout: editLayout,
|
2632
|
-
query
|
2633
|
-
}),
|
2634
|
-
[editLayout, query, runHookWaterfall]
|
2635
|
-
);
|
2636
|
-
return {
|
2637
|
-
error,
|
2638
|
-
isLoading,
|
2639
|
-
edit,
|
2640
|
-
list: listLayout
|
2641
|
-
};
|
2642
|
-
};
|
2643
|
-
const useDocLayout = () => {
|
2644
|
-
const { model } = useDoc();
|
2645
|
-
return useDocumentLayout(model);
|
2646
|
-
};
|
2647
|
-
const formatEditLayout = (data, {
|
2648
|
-
schemas,
|
2649
|
-
schema,
|
2650
|
-
components
|
2651
|
-
}) => {
|
2652
|
-
let currentPanelIndex = 0;
|
2653
|
-
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
2654
|
-
data.contentType.layouts.edit,
|
2655
|
-
schema?.attributes,
|
2656
|
-
data.contentType.metadatas,
|
2657
|
-
{ configurations: data.components, schemas: components },
|
2658
|
-
schemas
|
2659
|
-
).reduce((panels, row) => {
|
2660
|
-
if (row.some((field) => field.type === "dynamiczone")) {
|
2661
|
-
panels.push([row]);
|
2662
|
-
currentPanelIndex += 2;
|
2663
|
-
} else {
|
2664
|
-
if (!panels[currentPanelIndex]) {
|
2665
|
-
panels.push([]);
|
2666
|
-
}
|
2667
|
-
panels[currentPanelIndex].push(row);
|
2668
|
-
}
|
2669
|
-
return panels;
|
2670
|
-
}, []);
|
2671
|
-
const componentEditAttributes = Object.entries(data.components).reduce(
|
2672
|
-
(acc, [uid, configuration]) => {
|
2673
|
-
acc[uid] = {
|
2674
|
-
layout: convertEditLayoutToFieldLayouts(
|
2675
|
-
configuration.layouts.edit,
|
2676
|
-
components[uid].attributes,
|
2677
|
-
configuration.metadatas
|
2678
|
-
),
|
2679
|
-
settings: {
|
2680
|
-
...configuration.settings,
|
2681
|
-
icon: components[uid].info.icon,
|
2682
|
-
displayName: components[uid].info.displayName
|
2683
|
-
}
|
2684
|
-
};
|
2685
|
-
return acc;
|
2686
|
-
},
|
2687
|
-
{}
|
2688
|
-
);
|
2689
|
-
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2690
|
-
(acc, [attribute, metadata]) => {
|
2691
|
-
return {
|
2692
|
-
...acc,
|
2693
|
-
[attribute]: metadata.edit
|
2694
|
-
};
|
2695
|
-
},
|
2696
|
-
{}
|
2697
|
-
);
|
2698
|
-
return {
|
2699
|
-
layout: panelledEditAttributes,
|
2700
|
-
components: componentEditAttributes,
|
2701
|
-
metadatas: editMetadatas,
|
2702
|
-
settings: {
|
2703
|
-
...data.contentType.settings,
|
2704
|
-
displayName: schema?.info.displayName
|
2705
|
-
},
|
2706
|
-
options: {
|
2707
|
-
...schema?.options,
|
2708
|
-
...schema?.pluginOptions,
|
2709
|
-
...data.contentType.options
|
2710
|
-
}
|
2711
|
-
};
|
2712
|
-
};
|
2713
|
-
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
2714
|
-
return rows.map(
|
2715
|
-
(row) => row.map((field) => {
|
2716
|
-
const attribute = attributes[field.name];
|
2717
|
-
if (!attribute) {
|
2718
|
-
return null;
|
2719
|
-
}
|
2720
|
-
const { edit: metadata } = metadatas[field.name];
|
2721
|
-
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
2722
|
-
return {
|
2723
|
-
attribute,
|
2724
|
-
disabled: !metadata.editable,
|
2725
|
-
hint: metadata.description,
|
2726
|
-
label: metadata.label ?? "",
|
2727
|
-
name: field.name,
|
2728
|
-
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
2729
|
-
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
2730
|
-
schemas,
|
2731
|
-
components: components?.schemas ?? {}
|
2732
|
-
}),
|
2733
|
-
placeholder: metadata.placeholder ?? "",
|
2734
|
-
required: attribute.required ?? false,
|
2735
|
-
size: field.size,
|
2736
|
-
unique: "unique" in attribute ? attribute.unique : false,
|
2737
|
-
visible: metadata.visible ?? true,
|
2738
|
-
type: attribute.type
|
2739
|
-
};
|
2740
|
-
}).filter((field) => field !== null)
|
2741
|
-
);
|
2742
|
-
};
|
2743
|
-
const formatListLayout = (data, {
|
2744
|
-
schemas,
|
2745
|
-
schema,
|
2746
|
-
components
|
2747
|
-
}) => {
|
2748
|
-
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2749
|
-
(acc, [attribute, metadata]) => {
|
2750
|
-
return {
|
2751
|
-
...acc,
|
2752
|
-
[attribute]: metadata.list
|
2753
|
-
};
|
2754
|
-
},
|
2755
|
-
{}
|
2756
|
-
);
|
2757
|
-
const listAttributes = convertListLayoutToFieldLayouts(
|
2758
|
-
data.contentType.layouts.list,
|
2759
|
-
schema?.attributes,
|
2760
|
-
listMetadatas,
|
2761
|
-
{ configurations: data.components, schemas: components },
|
2762
|
-
schemas
|
2763
|
-
);
|
2764
|
-
return {
|
2765
|
-
layout: listAttributes,
|
2766
|
-
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
2767
|
-
metadatas: listMetadatas,
|
2768
|
-
options: {
|
2769
|
-
...schema?.options,
|
2770
|
-
...schema?.pluginOptions,
|
2771
|
-
...data.contentType.options
|
2772
|
-
}
|
2773
|
-
};
|
2774
|
-
};
|
2775
|
-
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
2776
|
-
return columns.map((name) => {
|
2777
|
-
const attribute = attributes[name];
|
2778
|
-
if (!attribute) {
|
2779
|
-
return null;
|
2780
|
-
}
|
2781
|
-
const metadata = metadatas[name];
|
2782
|
-
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
2783
|
-
return {
|
2784
|
-
attribute,
|
2785
|
-
label: metadata.label ?? "",
|
2786
|
-
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
2787
|
-
schemas,
|
2788
|
-
components: components?.schemas ?? {}
|
2789
|
-
}),
|
2790
|
-
name,
|
2791
|
-
searchable: metadata.searchable ?? true,
|
2792
|
-
sortable: metadata.sortable ?? true
|
2793
|
-
};
|
2794
|
-
}).filter((field) => field !== null);
|
2795
|
-
};
|
3051
|
+
);
|
3052
|
+
});
|
2796
3053
|
const ConfirmBulkActionDialog = ({
|
2797
3054
|
onToggleDialog,
|
2798
3055
|
isOpen = false,
|
@@ -2800,30 +3057,23 @@ const ConfirmBulkActionDialog = ({
|
|
2800
3057
|
endAction
|
2801
3058
|
}) => {
|
2802
3059
|
const { formatMessage } = useIntl();
|
2803
|
-
return /* @__PURE__ */ jsxs(
|
2804
|
-
Dialog,
|
2805
|
-
|
2806
|
-
|
2807
|
-
|
2808
|
-
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2812
|
-
|
2813
|
-
|
2814
|
-
|
2815
|
-
|
2816
|
-
|
2817
|
-
|
2818
|
-
|
2819
|
-
|
2820
|
-
}) }),
|
2821
|
-
endAction
|
2822
|
-
}
|
2823
|
-
)
|
2824
|
-
]
|
2825
|
-
}
|
2826
|
-
);
|
3060
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
3061
|
+
/* @__PURE__ */ jsx(Dialog.Header, { children: formatMessage({
|
3062
|
+
id: "app.components.ConfirmDialog.title",
|
3063
|
+
defaultMessage: "Confirmation"
|
3064
|
+
}) }),
|
3065
|
+
/* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3066
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3067
|
+
dialogBody
|
3068
|
+
] }) }),
|
3069
|
+
/* @__PURE__ */ jsxs(Dialog.Footer, { children: [
|
3070
|
+
/* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { fullWidth: true, onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
|
3071
|
+
id: "app.components.Button.cancel",
|
3072
|
+
defaultMessage: "Cancel"
|
3073
|
+
}) }) }),
|
3074
|
+
endAction
|
3075
|
+
] })
|
3076
|
+
] }) });
|
2827
3077
|
};
|
2828
3078
|
const BoldChunk$1 = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: chunks });
|
2829
3079
|
const ConfirmDialogPublishAll = ({
|
@@ -2838,6 +3088,7 @@ const ConfirmDialogPublishAll = ({
|
|
2838
3088
|
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler(getTranslation);
|
2839
3089
|
const { model, schema } = useDoc();
|
2840
3090
|
const [{ query }] = useQueryParams();
|
3091
|
+
const enableDraftRelationsCount = false;
|
2841
3092
|
const {
|
2842
3093
|
data: countDraftRelations = 0,
|
2843
3094
|
isLoading,
|
@@ -2849,7 +3100,7 @@ const ConfirmDialogPublishAll = ({
|
|
2849
3100
|
locale: query?.plugins?.i18n?.locale
|
2850
3101
|
},
|
2851
3102
|
{
|
2852
|
-
skip:
|
3103
|
+
skip: !enableDraftRelationsCount
|
2853
3104
|
}
|
2854
3105
|
);
|
2855
3106
|
React.useEffect(() => {
|
@@ -2928,16 +3179,30 @@ const formatErrorMessages = (errors, parentKey, formatMessage) => {
|
|
2928
3179
|
)
|
2929
3180
|
);
|
2930
3181
|
} else {
|
2931
|
-
messages.push(
|
3182
|
+
messages.push(
|
3183
|
+
...formatErrorMessages(
|
3184
|
+
// @ts-expect-error TODO: check why value is not compatible with FormErrors
|
3185
|
+
value,
|
3186
|
+
currentKey,
|
3187
|
+
formatMessage
|
3188
|
+
)
|
3189
|
+
);
|
2932
3190
|
}
|
3191
|
+
} else {
|
3192
|
+
messages.push(
|
3193
|
+
formatMessage(
|
3194
|
+
{
|
3195
|
+
id: `${value}.withField`,
|
3196
|
+
defaultMessage: value
|
3197
|
+
},
|
3198
|
+
{ field: currentKey }
|
3199
|
+
)
|
3200
|
+
);
|
2933
3201
|
}
|
2934
3202
|
});
|
2935
3203
|
return messages;
|
2936
3204
|
};
|
2937
|
-
const EntryValidationText = ({
|
2938
|
-
validationErrors,
|
2939
|
-
isPublished = false
|
2940
|
-
}) => {
|
3205
|
+
const EntryValidationText = ({ validationErrors, status }) => {
|
2941
3206
|
const { formatMessage } = useIntl();
|
2942
3207
|
if (validationErrors) {
|
2943
3208
|
const validationErrorsMessages = formatErrorMessages(validationErrors, "", formatMessage).join(
|
@@ -2948,7 +3213,7 @@ const EntryValidationText = ({
|
|
2948
3213
|
/* @__PURE__ */ jsx(Tooltip, { description: validationErrorsMessages, children: /* @__PURE__ */ jsx(TypographyMaxWidth, { textColor: "danger600", variant: "omega", fontWeight: "semiBold", ellipsis: true, children: validationErrorsMessages }) })
|
2949
3214
|
] });
|
2950
3215
|
}
|
2951
|
-
if (
|
3216
|
+
if (status === "published") {
|
2952
3217
|
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
2953
3218
|
/* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
2954
3219
|
/* @__PURE__ */ jsx(Typography, { textColor: "success600", fontWeight: "bold", children: formatMessage({
|
@@ -2957,6 +3222,15 @@ const EntryValidationText = ({
|
|
2957
3222
|
}) })
|
2958
3223
|
] });
|
2959
3224
|
}
|
3225
|
+
if (status === "modified") {
|
3226
|
+
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
3227
|
+
/* @__PURE__ */ jsx(ArrowsCounterClockwise, { fill: "alternative600" }),
|
3228
|
+
/* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
3229
|
+
id: "content-manager.bulk-publish.modified",
|
3230
|
+
defaultMessage: "Ready to publish changes"
|
3231
|
+
}) })
|
3232
|
+
] });
|
3233
|
+
}
|
2960
3234
|
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
2961
3235
|
/* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
2962
3236
|
/* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
@@ -3008,10 +3282,10 @@ const SelectedEntriesTableContent = ({
|
|
3008
3282
|
EntryValidationText,
|
3009
3283
|
{
|
3010
3284
|
validationErrors: validationErrors[row.documentId],
|
3011
|
-
|
3285
|
+
status: row.status
|
3012
3286
|
}
|
3013
3287
|
) }),
|
3014
|
-
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(
|
3288
|
+
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(
|
3015
3289
|
IconButton,
|
3016
3290
|
{
|
3017
3291
|
tag: Link,
|
@@ -3020,23 +3294,16 @@ const SelectedEntriesTableContent = ({
|
|
3020
3294
|
search: row.locale && `?plugins[i18n][locale]=${row.locale}`
|
3021
3295
|
},
|
3022
3296
|
state: { from: pathname },
|
3023
|
-
label: formatMessage(
|
3024
|
-
|
3025
|
-
|
3026
|
-
|
3027
|
-
{
|
3028
|
-
id: "content-manager.components.ListViewHelperPluginTable.row-line",
|
3029
|
-
defaultMessage: "item line {number}"
|
3030
|
-
},
|
3031
|
-
{ number: index2 + 1 }
|
3032
|
-
)
|
3033
|
-
}
|
3034
|
-
),
|
3297
|
+
label: formatMessage({
|
3298
|
+
id: "content-manager.bulk-publish.edit",
|
3299
|
+
defaultMessage: "Edit"
|
3300
|
+
}),
|
3035
3301
|
target: "_blank",
|
3036
3302
|
marginLeft: "auto",
|
3037
|
-
|
3303
|
+
variant: "ghost",
|
3304
|
+
children: /* @__PURE__ */ jsx(Pencil, { width: "1.6rem", height: "1.6rem" })
|
3038
3305
|
}
|
3039
|
-
) })
|
3306
|
+
) }) })
|
3040
3307
|
] }, row.id)) })
|
3041
3308
|
] });
|
3042
3309
|
};
|
@@ -3073,7 +3340,13 @@ const SelectedEntriesModalContent = ({
|
|
3073
3340
|
);
|
3074
3341
|
const { rows, validationErrors } = React.useMemo(() => {
|
3075
3342
|
if (data.length > 0 && schema) {
|
3076
|
-
const validate = createYupSchema(
|
3343
|
+
const validate = createYupSchema(
|
3344
|
+
schema.attributes,
|
3345
|
+
components,
|
3346
|
+
// Since this is the "Publish" action, the validation
|
3347
|
+
// schema must enforce the rules for published entities
|
3348
|
+
{ status: "published" }
|
3349
|
+
);
|
3077
3350
|
const validationErrors2 = {};
|
3078
3351
|
const rows2 = data.map((entry) => {
|
3079
3352
|
try {
|
@@ -3149,7 +3422,7 @@ const SelectedEntriesModalContent = ({
|
|
3149
3422
|
);
|
3150
3423
|
};
|
3151
3424
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
3152
|
-
/* @__PURE__ */ jsxs(
|
3425
|
+
/* @__PURE__ */ jsxs(Modal.Body, { children: [
|
3153
3426
|
/* @__PURE__ */ jsx(Typography, { children: getFormattedCountMessage() }),
|
3154
3427
|
/* @__PURE__ */ jsx(Box, { marginTop: 5, children: /* @__PURE__ */ jsx(
|
3155
3428
|
SelectedEntriesTableContent,
|
@@ -3161,27 +3434,24 @@ const SelectedEntriesModalContent = ({
|
|
3161
3434
|
}
|
3162
3435
|
) })
|
3163
3436
|
] }),
|
3164
|
-
/* @__PURE__ */
|
3165
|
-
|
3166
|
-
|
3167
|
-
|
3168
|
-
|
3169
|
-
|
3170
|
-
}) }),
|
3171
|
-
|
3172
|
-
|
3173
|
-
|
3174
|
-
|
3175
|
-
|
3176
|
-
|
3177
|
-
|
3178
|
-
|
3179
|
-
|
3180
|
-
|
3181
|
-
|
3182
|
-
] })
|
3183
|
-
}
|
3184
|
-
),
|
3437
|
+
/* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
3438
|
+
/* @__PURE__ */ jsx(Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
|
3439
|
+
id: "app.components.Button.cancel",
|
3440
|
+
defaultMessage: "Cancel"
|
3441
|
+
}) }),
|
3442
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
3443
|
+
/* @__PURE__ */ jsx(Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
|
3444
|
+
/* @__PURE__ */ jsx(
|
3445
|
+
Button,
|
3446
|
+
{
|
3447
|
+
onClick: toggleDialog,
|
3448
|
+
disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublished === selectedEntries.length || isLoading,
|
3449
|
+
loading: isSubmittingForm,
|
3450
|
+
children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
|
3451
|
+
}
|
3452
|
+
)
|
3453
|
+
] })
|
3454
|
+
] }),
|
3185
3455
|
/* @__PURE__ */ jsx(
|
3186
3456
|
ConfirmDialogPublishAll,
|
3187
3457
|
{
|
@@ -3201,8 +3471,7 @@ const PublishAction = ({ documents, model }) => {
|
|
3201
3471
|
const refetchList = () => {
|
3202
3472
|
contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
|
3203
3473
|
};
|
3204
|
-
if (!showPublishButton)
|
3205
|
-
return null;
|
3474
|
+
if (!showPublishButton) return null;
|
3206
3475
|
return {
|
3207
3476
|
actionType: "publish",
|
3208
3477
|
variant: "tertiary",
|
@@ -3246,143 +3515,10 @@ const BulkActionsRenderer = () => {
|
|
3246
3515
|
documents: selectedRows
|
3247
3516
|
},
|
3248
3517
|
descriptions: plugins["content-manager"].apis.getBulkActions(),
|
3249
|
-
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsx(
|
3518
|
+
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsx(DocumentActionButton, { ...action }, action.id))
|
3250
3519
|
}
|
3251
3520
|
) });
|
3252
3521
|
};
|
3253
|
-
const BulkActionAction = (action) => {
|
3254
|
-
const [dialogId, setDialogId] = React.useState(null);
|
3255
|
-
const { toggleNotification } = useNotification();
|
3256
|
-
const handleClick = (action2) => (e) => {
|
3257
|
-
const { onClick, dialog, id } = action2;
|
3258
|
-
if (onClick) {
|
3259
|
-
onClick(e);
|
3260
|
-
}
|
3261
|
-
if (dialog) {
|
3262
|
-
switch (dialog.type) {
|
3263
|
-
case "notification":
|
3264
|
-
toggleNotification({
|
3265
|
-
title: dialog.title,
|
3266
|
-
message: dialog.content,
|
3267
|
-
type: dialog.status,
|
3268
|
-
timeout: dialog.timeout,
|
3269
|
-
onClose: dialog.onClose
|
3270
|
-
});
|
3271
|
-
break;
|
3272
|
-
case "dialog":
|
3273
|
-
case "modal": {
|
3274
|
-
e.preventDefault();
|
3275
|
-
setDialogId(id);
|
3276
|
-
}
|
3277
|
-
}
|
3278
|
-
}
|
3279
|
-
};
|
3280
|
-
const handleClose = () => {
|
3281
|
-
setDialogId(null);
|
3282
|
-
if (action.dialog?.type === "modal" && action.dialog?.onClose) {
|
3283
|
-
action.dialog.onClose();
|
3284
|
-
}
|
3285
|
-
};
|
3286
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
3287
|
-
/* @__PURE__ */ jsx(
|
3288
|
-
Button,
|
3289
|
-
{
|
3290
|
-
disabled: action.disabled,
|
3291
|
-
startIcon: action.icon,
|
3292
|
-
variant: action.variant,
|
3293
|
-
onClick: handleClick(action),
|
3294
|
-
children: action.label
|
3295
|
-
}
|
3296
|
-
),
|
3297
|
-
action.dialog?.type === "dialog" ? /* @__PURE__ */ jsx(
|
3298
|
-
BulkActionConfirmDialog,
|
3299
|
-
{
|
3300
|
-
...action.dialog,
|
3301
|
-
variant: action.variant,
|
3302
|
-
isOpen: dialogId === action.id,
|
3303
|
-
onClose: handleClose
|
3304
|
-
}
|
3305
|
-
) : null,
|
3306
|
-
action.dialog?.type === "modal" ? /* @__PURE__ */ jsx(
|
3307
|
-
BulkActionModal,
|
3308
|
-
{
|
3309
|
-
...action.dialog,
|
3310
|
-
onModalClose: handleClose,
|
3311
|
-
isOpen: dialogId === action.id
|
3312
|
-
}
|
3313
|
-
) : null
|
3314
|
-
] });
|
3315
|
-
};
|
3316
|
-
const BulkActionConfirmDialog = ({
|
3317
|
-
onClose,
|
3318
|
-
onCancel,
|
3319
|
-
onConfirm,
|
3320
|
-
title,
|
3321
|
-
content,
|
3322
|
-
confirmButton,
|
3323
|
-
isOpen,
|
3324
|
-
variant = "secondary"
|
3325
|
-
}) => {
|
3326
|
-
const { formatMessage } = useIntl();
|
3327
|
-
const handleClose = async () => {
|
3328
|
-
if (onCancel) {
|
3329
|
-
await onCancel();
|
3330
|
-
}
|
3331
|
-
onClose();
|
3332
|
-
};
|
3333
|
-
const handleConfirm = async () => {
|
3334
|
-
if (onConfirm) {
|
3335
|
-
await onConfirm();
|
3336
|
-
}
|
3337
|
-
onClose();
|
3338
|
-
};
|
3339
|
-
return /* @__PURE__ */ jsxs(Dialog, { isOpen, title, onClose: handleClose, children: [
|
3340
|
-
/* @__PURE__ */ jsx(DialogBody, { icon: /* @__PURE__ */ jsx(WarningCircle, {}), children: content }),
|
3341
|
-
/* @__PURE__ */ jsx(
|
3342
|
-
DialogFooter,
|
3343
|
-
{
|
3344
|
-
startAction: /* @__PURE__ */ jsx(Button, { onClick: handleClose, variant: "tertiary", children: formatMessage({
|
3345
|
-
id: "app.components.Button.cancel",
|
3346
|
-
defaultMessage: "Cancel"
|
3347
|
-
}) }),
|
3348
|
-
endAction: /* @__PURE__ */ jsx(
|
3349
|
-
Button,
|
3350
|
-
{
|
3351
|
-
onClick: handleConfirm,
|
3352
|
-
variant: variant === "danger-light" ? variant : "secondary",
|
3353
|
-
startIcon: variant === "danger-light" ? /* @__PURE__ */ jsx(Trash, {}) : /* @__PURE__ */ jsx(Check, {}),
|
3354
|
-
children: confirmButton ? confirmButton : formatMessage({
|
3355
|
-
id: "app.components.Button.confirm",
|
3356
|
-
defaultMessage: "Confirm"
|
3357
|
-
})
|
3358
|
-
}
|
3359
|
-
)
|
3360
|
-
}
|
3361
|
-
)
|
3362
|
-
] });
|
3363
|
-
};
|
3364
|
-
const BulkActionModal = ({
|
3365
|
-
isOpen,
|
3366
|
-
title,
|
3367
|
-
onClose,
|
3368
|
-
content: Content,
|
3369
|
-
onModalClose
|
3370
|
-
}) => {
|
3371
|
-
const id = React.useId();
|
3372
|
-
if (!isOpen) {
|
3373
|
-
return null;
|
3374
|
-
}
|
3375
|
-
const handleClose = () => {
|
3376
|
-
if (onClose) {
|
3377
|
-
onClose();
|
3378
|
-
}
|
3379
|
-
onModalClose();
|
3380
|
-
};
|
3381
|
-
return /* @__PURE__ */ jsxs(ModalLayout, { borderRadius: "4px", overflow: "hidden", onClose: handleClose, labelledBy: id, children: [
|
3382
|
-
/* @__PURE__ */ jsx(ModalHeader, { children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "neutral800", tag: "h2", id, children: title }) }),
|
3383
|
-
/* @__PURE__ */ jsx(Content, { onClose: handleClose })
|
3384
|
-
] });
|
3385
|
-
};
|
3386
3522
|
const DeleteAction = ({ documents, model }) => {
|
3387
3523
|
const { formatMessage } = useIntl();
|
3388
3524
|
const { schema: contentType } = useDoc();
|
@@ -3403,8 +3539,7 @@ const DeleteAction = ({ documents, model }) => {
|
|
3403
3539
|
selectRow([]);
|
3404
3540
|
}
|
3405
3541
|
};
|
3406
|
-
if (!hasDeletePermission)
|
3407
|
-
return null;
|
3542
|
+
if (!hasDeletePermission) return null;
|
3408
3543
|
return {
|
3409
3544
|
variant: "danger-light",
|
3410
3545
|
label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
|
@@ -3415,6 +3550,7 @@ const DeleteAction = ({ documents, model }) => {
|
|
3415
3550
|
defaultMessage: "Confirmation"
|
3416
3551
|
}),
|
3417
3552
|
content: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3553
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3418
3554
|
/* @__PURE__ */ jsx(Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3419
3555
|
id: "popUpWarning.bodyMessage.contentType.delete.all",
|
3420
3556
|
defaultMessage: "Are you sure you want to delete these entries?"
|
@@ -3451,9 +3587,8 @@ const UnpublishAction = ({ documents, model }) => {
|
|
3451
3587
|
selectRow([]);
|
3452
3588
|
}
|
3453
3589
|
};
|
3454
|
-
const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published");
|
3455
|
-
if (!showUnpublishButton)
|
3456
|
-
return null;
|
3590
|
+
const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
|
3591
|
+
if (!showUnpublishButton) return null;
|
3457
3592
|
return {
|
3458
3593
|
variant: "tertiary",
|
3459
3594
|
label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
|
@@ -3464,6 +3599,7 @@ const UnpublishAction = ({ documents, model }) => {
|
|
3464
3599
|
defaultMessage: "Confirmation"
|
3465
3600
|
}),
|
3466
3601
|
content: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3602
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3467
3603
|
/* @__PURE__ */ jsx(Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3468
3604
|
id: "popUpWarning.bodyMessage.contentType.unpublish.all",
|
3469
3605
|
defaultMessage: "Are you sure you want to unpublish these entries?"
|
@@ -3557,7 +3693,7 @@ const TableActions = ({ document }) => {
|
|
3557
3693
|
DescriptionComponentRenderer,
|
3558
3694
|
{
|
3559
3695
|
props,
|
3560
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3696
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("table-row").filter((action) => action.name !== "PublishAction"),
|
3561
3697
|
children: (actions2) => {
|
3562
3698
|
const tableRowActions = actions2.filter((action) => {
|
3563
3699
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -3616,6 +3752,7 @@ const EditAction = ({ documentId }) => {
|
|
3616
3752
|
};
|
3617
3753
|
};
|
3618
3754
|
EditAction.type = "edit";
|
3755
|
+
EditAction.position = "table-row";
|
3619
3756
|
const StyledPencil = styled(Pencil)`
|
3620
3757
|
path {
|
3621
3758
|
fill: currentColor;
|
@@ -3668,7 +3805,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3668
3805
|
}),
|
3669
3806
|
content: /* @__PURE__ */ jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
3670
3807
|
footer: ({ onClose }) => {
|
3671
|
-
return /* @__PURE__ */ jsxs(
|
3808
|
+
return /* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
3672
3809
|
/* @__PURE__ */ jsx(Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
3673
3810
|
id: "cancel",
|
3674
3811
|
defaultMessage: "Cancel"
|
@@ -3692,6 +3829,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3692
3829
|
};
|
3693
3830
|
};
|
3694
3831
|
CloneAction.type = "clone";
|
3832
|
+
CloneAction.position = "table-row";
|
3695
3833
|
const StyledDuplicate = styled(Duplicate)`
|
3696
3834
|
path {
|
3697
3835
|
fill: currentColor;
|
@@ -3709,8 +3847,7 @@ class ContentManagerPlugin {
|
|
3709
3847
|
documentActions = [
|
3710
3848
|
...DEFAULT_ACTIONS,
|
3711
3849
|
...DEFAULT_TABLE_ROW_ACTIONS,
|
3712
|
-
...DEFAULT_HEADER_ACTIONS
|
3713
|
-
HistoryAction
|
3850
|
+
...DEFAULT_HEADER_ACTIONS
|
3714
3851
|
];
|
3715
3852
|
editViewSidePanels = [ActionsPanel];
|
3716
3853
|
headerActions = [];
|
@@ -3779,7 +3916,14 @@ class ContentManagerPlugin {
|
|
3779
3916
|
addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
|
3780
3917
|
addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
|
3781
3918
|
getBulkActions: () => this.bulkActions,
|
3782
|
-
getDocumentActions: () =>
|
3919
|
+
getDocumentActions: (position) => {
|
3920
|
+
if (position) {
|
3921
|
+
return this.documentActions.filter(
|
3922
|
+
(action) => action.position == void 0 || [action.position].flat().includes(position)
|
3923
|
+
);
|
3924
|
+
}
|
3925
|
+
return this.documentActions;
|
3926
|
+
},
|
3783
3927
|
getEditViewSidePanels: () => this.editViewSidePanels,
|
3784
3928
|
getHeaderActions: () => this.headerActions
|
3785
3929
|
}
|
@@ -3789,16 +3933,71 @@ class ContentManagerPlugin {
|
|
3789
3933
|
const getPrintableType = (value) => {
|
3790
3934
|
const nativeType = typeof value;
|
3791
3935
|
if (nativeType === "object") {
|
3792
|
-
if (value === null)
|
3793
|
-
|
3794
|
-
if (Array.isArray(value))
|
3795
|
-
return "array";
|
3936
|
+
if (value === null) return "null";
|
3937
|
+
if (Array.isArray(value)) return "array";
|
3796
3938
|
if (value instanceof Object && value.constructor.name !== "Object") {
|
3797
3939
|
return value.constructor.name;
|
3798
3940
|
}
|
3799
3941
|
}
|
3800
3942
|
return nativeType;
|
3801
3943
|
};
|
3944
|
+
const HistoryAction = ({ model, document }) => {
|
3945
|
+
const { formatMessage } = useIntl();
|
3946
|
+
const [{ query }] = useQueryParams();
|
3947
|
+
const navigate = useNavigate();
|
3948
|
+
const { trackUsage } = useTracking();
|
3949
|
+
const { pathname } = useLocation();
|
3950
|
+
const pluginsQueryParams = stringify({ plugins: query.plugins }, { encode: false });
|
3951
|
+
if (!window.strapi.features.isEnabled("cms-content-history")) {
|
3952
|
+
return null;
|
3953
|
+
}
|
3954
|
+
const handleOnClick = () => {
|
3955
|
+
const destination = { pathname: "history", search: pluginsQueryParams };
|
3956
|
+
trackUsage("willNavigate", {
|
3957
|
+
from: pathname,
|
3958
|
+
to: `${pathname}/${destination.pathname}`
|
3959
|
+
});
|
3960
|
+
navigate(destination);
|
3961
|
+
};
|
3962
|
+
return {
|
3963
|
+
icon: /* @__PURE__ */ jsx(ClockCounterClockwise, {}),
|
3964
|
+
label: formatMessage({
|
3965
|
+
id: "content-manager.history.document-action",
|
3966
|
+
defaultMessage: "Content History"
|
3967
|
+
}),
|
3968
|
+
onClick: handleOnClick,
|
3969
|
+
disabled: (
|
3970
|
+
/**
|
3971
|
+
* The user is creating a new document.
|
3972
|
+
* It hasn't been saved yet, so there's no history to go to
|
3973
|
+
*/
|
3974
|
+
!document || /**
|
3975
|
+
* The document has been created but the current dimension has never been saved.
|
3976
|
+
* For example, the user is creating a new locale in an existing document,
|
3977
|
+
* so there's no history for the document in that locale
|
3978
|
+
*/
|
3979
|
+
!document.id || /**
|
3980
|
+
* History is only available for content types created by the user.
|
3981
|
+
* These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
|
3982
|
+
* which start with `admin::` or `plugin::`
|
3983
|
+
*/
|
3984
|
+
!model.startsWith("api::")
|
3985
|
+
),
|
3986
|
+
position: "header"
|
3987
|
+
};
|
3988
|
+
};
|
3989
|
+
HistoryAction.type = "history";
|
3990
|
+
HistoryAction.position = "header";
|
3991
|
+
const historyAdmin = {
|
3992
|
+
bootstrap(app) {
|
3993
|
+
const { addDocumentAction } = app.getPlugin("content-manager").apis;
|
3994
|
+
addDocumentAction((actions2) => {
|
3995
|
+
const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
|
3996
|
+
actions2.splice(indexOfDeleteAction, 0, HistoryAction);
|
3997
|
+
return actions2;
|
3998
|
+
});
|
3999
|
+
}
|
4000
|
+
};
|
3802
4001
|
const initialState = {
|
3803
4002
|
collectionTypeLinks: [],
|
3804
4003
|
components: [],
|
@@ -3835,6 +4034,92 @@ const { setInitialData } = actions;
|
|
3835
4034
|
const reducer = combineReducers({
|
3836
4035
|
app: reducer$1
|
3837
4036
|
});
|
4037
|
+
const previewApi = contentManagerApi.injectEndpoints({
|
4038
|
+
endpoints: (builder) => ({
|
4039
|
+
getPreviewUrl: builder.query({
|
4040
|
+
query({ query, params }) {
|
4041
|
+
return {
|
4042
|
+
url: `/content-manager/preview/url/${params.contentType}`,
|
4043
|
+
method: "GET",
|
4044
|
+
config: {
|
4045
|
+
params: query
|
4046
|
+
}
|
4047
|
+
};
|
4048
|
+
}
|
4049
|
+
})
|
4050
|
+
})
|
4051
|
+
});
|
4052
|
+
const { useGetPreviewUrlQuery } = previewApi;
|
4053
|
+
const ConditionalTooltip = ({ isShown, label, children }) => {
|
4054
|
+
if (isShown) {
|
4055
|
+
return /* @__PURE__ */ jsx(Tooltip, { label, children });
|
4056
|
+
}
|
4057
|
+
return children;
|
4058
|
+
};
|
4059
|
+
const PreviewSidePanel = ({ model, documentId, document }) => {
|
4060
|
+
const { formatMessage } = useIntl();
|
4061
|
+
const { trackUsage } = useTracking();
|
4062
|
+
const { pathname } = useLocation();
|
4063
|
+
const [{ query }] = useQueryParams();
|
4064
|
+
const isModified = useForm("PreviewSidePanel", (state) => state.modified);
|
4065
|
+
const { data, error } = useGetPreviewUrlQuery({
|
4066
|
+
params: {
|
4067
|
+
contentType: model
|
4068
|
+
},
|
4069
|
+
query: {
|
4070
|
+
documentId,
|
4071
|
+
locale: document?.locale,
|
4072
|
+
status: document?.status
|
4073
|
+
}
|
4074
|
+
});
|
4075
|
+
if (!data?.data?.url || error) {
|
4076
|
+
return null;
|
4077
|
+
}
|
4078
|
+
const trackNavigation = () => {
|
4079
|
+
const destinationPathname = pathname.replace(/\/$/, "") + "/preview";
|
4080
|
+
trackUsage("willNavigate", { from: pathname, to: destinationPathname });
|
4081
|
+
};
|
4082
|
+
return {
|
4083
|
+
title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
|
4084
|
+
content: /* @__PURE__ */ jsx(
|
4085
|
+
ConditionalTooltip,
|
4086
|
+
{
|
4087
|
+
label: formatMessage({
|
4088
|
+
id: "content-manager.preview.panel.button-disabled-tooltip",
|
4089
|
+
defaultMessage: "Please save to open the preview"
|
4090
|
+
}),
|
4091
|
+
isShown: isModified,
|
4092
|
+
children: /* @__PURE__ */ jsx(Box, { cursor: "not-allowed", width: "100%", children: /* @__PURE__ */ jsx(
|
4093
|
+
Button,
|
4094
|
+
{
|
4095
|
+
variant: "tertiary",
|
4096
|
+
tag: Link,
|
4097
|
+
to: { pathname: "preview", search: stringify(query, { encode: false }) },
|
4098
|
+
onClick: trackNavigation,
|
4099
|
+
width: "100%",
|
4100
|
+
disabled: isModified,
|
4101
|
+
pointerEvents: isModified ? "none" : void 0,
|
4102
|
+
tabIndex: isModified ? -1 : void 0,
|
4103
|
+
children: formatMessage({
|
4104
|
+
id: "content-manager.preview.panel.button",
|
4105
|
+
defaultMessage: "Open preview"
|
4106
|
+
})
|
4107
|
+
}
|
4108
|
+
) })
|
4109
|
+
}
|
4110
|
+
)
|
4111
|
+
};
|
4112
|
+
};
|
4113
|
+
const FEATURE_ID = "preview";
|
4114
|
+
const previewAdmin = {
|
4115
|
+
bootstrap(app) {
|
4116
|
+
if (!window.strapi.future.isEnabled(FEATURE_ID)) {
|
4117
|
+
return;
|
4118
|
+
}
|
4119
|
+
const contentManagerPluginApis = app.getPlugin("content-manager").apis;
|
4120
|
+
contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
|
4121
|
+
}
|
4122
|
+
};
|
3838
4123
|
const index = {
|
3839
4124
|
register(app) {
|
3840
4125
|
const cm = new ContentManagerPlugin();
|
@@ -3849,15 +4134,32 @@ const index = {
|
|
3849
4134
|
defaultMessage: "Content Manager"
|
3850
4135
|
},
|
3851
4136
|
permissions: [],
|
3852
|
-
Component: () => import("./layout-CPn1PM6x.mjs").then((mod) => ({ default: mod.Layout })),
|
3853
4137
|
position: 1
|
3854
4138
|
});
|
4139
|
+
app.router.addRoute({
|
4140
|
+
path: "content-manager/*",
|
4141
|
+
lazy: async () => {
|
4142
|
+
const { Layout } = await import("./layout-CzSSEy9b.mjs");
|
4143
|
+
return {
|
4144
|
+
Component: Layout
|
4145
|
+
};
|
4146
|
+
},
|
4147
|
+
children: routes
|
4148
|
+
});
|
3855
4149
|
app.registerPlugin(cm.config);
|
3856
4150
|
},
|
4151
|
+
bootstrap(app) {
|
4152
|
+
if (typeof historyAdmin.bootstrap === "function") {
|
4153
|
+
historyAdmin.bootstrap(app);
|
4154
|
+
}
|
4155
|
+
if (typeof previewAdmin.bootstrap === "function") {
|
4156
|
+
previewAdmin.bootstrap(app);
|
4157
|
+
}
|
4158
|
+
},
|
3857
4159
|
async registerTrads({ locales }) {
|
3858
4160
|
const importedTrads = await Promise.all(
|
3859
4161
|
locales.map((locale) => {
|
3860
|
-
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-
|
4162
|
+
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-Dtk_ot79.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 }) => {
|
3861
4163
|
return {
|
3862
4164
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3863
4165
|
locale
|
@@ -3884,37 +4186,39 @@ export {
|
|
3884
4186
|
HOOKS as H,
|
3885
4187
|
InjectionZone as I,
|
3886
4188
|
useDocument as J,
|
3887
|
-
|
3888
|
-
|
4189
|
+
useGetPreviewUrlQuery as K,
|
4190
|
+
index as L,
|
4191
|
+
useContentManagerContext as M,
|
4192
|
+
useDocumentActions as N,
|
3889
4193
|
Panels as P,
|
3890
4194
|
RelativeTime as R,
|
3891
4195
|
SINGLE_TYPES as S,
|
3892
4196
|
TableActions as T,
|
3893
|
-
|
3894
|
-
|
3895
|
-
|
3896
|
-
|
3897
|
-
|
3898
|
-
|
4197
|
+
useGetInitialDataQuery as a,
|
4198
|
+
useGetAllContentTypeSettingsQuery as b,
|
4199
|
+
useDoc as c,
|
4200
|
+
buildValidParams as d,
|
4201
|
+
contentManagerApi as e,
|
4202
|
+
useDocumentRBAC as f,
|
3899
4203
|
getTranslation as g,
|
3900
|
-
|
3901
|
-
|
3902
|
-
|
3903
|
-
|
3904
|
-
|
3905
|
-
|
3906
|
-
|
3907
|
-
|
3908
|
-
|
3909
|
-
|
3910
|
-
|
4204
|
+
useDocumentLayout as h,
|
4205
|
+
createYupSchema as i,
|
4206
|
+
Header as j,
|
4207
|
+
PERMISSIONS as k,
|
4208
|
+
DocumentRBAC as l,
|
4209
|
+
DOCUMENT_META_FIELDS as m,
|
4210
|
+
CLONE_PATH as n,
|
4211
|
+
useDocLayout as o,
|
4212
|
+
useGetContentTypeConfigurationQuery as p,
|
4213
|
+
CREATOR_FIELDS as q,
|
4214
|
+
getMainField as r,
|
3911
4215
|
setInitialData as s,
|
3912
4216
|
getDisplayName as t,
|
3913
|
-
|
4217
|
+
useContentTypeSchema as u,
|
3914
4218
|
checkIfAttributeIsDisplayable as v,
|
3915
4219
|
useGetAllDocumentsQuery as w,
|
3916
4220
|
convertListLayoutToFieldLayouts as x,
|
3917
4221
|
capitalise as y,
|
3918
4222
|
useUpdateContentTypeConfigurationMutation as z
|
3919
4223
|
};
|
3920
|
-
//# sourceMappingURL=index-
|
4224
|
+
//# sourceMappingURL=index-BeYsz0Vi.mjs.map
|