@strapi/content-manager 0.0.0-experimental.abc → 0.0.0-experimental.af7e4e2471a04cc7f17b8ed3474530810efc02bc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{ComponentConfigurationPage-KXSuLnQD.js → ComponentConfigurationPage-_EzKh4uq.js} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-KXSuLnQD.js.map → ComponentConfigurationPage-_EzKh4uq.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-B3yDbeU1.mjs → ComponentConfigurationPage-aeNlfgi9.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-B3yDbeU1.mjs.map → ComponentConfigurationPage-aeNlfgi9.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-D7PrLO8j.mjs → EditConfigurationPage-DBVSBjCB.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-D7PrLO8j.mjs.map → EditConfigurationPage-DBVSBjCB.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-BQ17--5R.js → EditConfigurationPage-DaK5-ltL.js} +4 -4
- package/dist/_chunks/{EditConfigurationPage-BQ17--5R.js.map → EditConfigurationPage-DaK5-ltL.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-B7VgwJaG.mjs → EditViewPage-BeRi9xCR.mjs} +50 -10
- package/dist/_chunks/EditViewPage-BeRi9xCR.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-BgjdnGz2.js → EditViewPage-C3qKSunQ.js} +49 -9
- package/dist/_chunks/EditViewPage-C3qKSunQ.js.map +1 -0
- package/dist/_chunks/{Field-CdK7ZLmv.js → Field-BwLr5b0V.js} +124 -91
- package/dist/_chunks/Field-BwLr5b0V.js.map +1 -0
- package/dist/_chunks/{Field-tHCw4lGA.mjs → Field-CfbMEZLv.mjs} +121 -88
- package/dist/_chunks/Field-CfbMEZLv.mjs.map +1 -0
- package/dist/_chunks/{Form-C_0KTVvV.js → Form-BSInvgp4.js} +16 -8
- package/dist/_chunks/Form-BSInvgp4.js.map +1 -0
- package/dist/_chunks/{Form-BJxdTv3Q.mjs → Form-Br-9I4vG.mjs} +16 -8
- package/dist/_chunks/Form-Br-9I4vG.mjs.map +1 -0
- package/dist/_chunks/{History-nuEzM5qm.js → History-BHH0axCz.js} +38 -97
- package/dist/_chunks/History-BHH0axCz.js.map +1 -0
- package/dist/_chunks/{History-DR2txJLE.mjs → History-BQ721fHN.mjs} +39 -98
- package/dist/_chunks/History-BQ721fHN.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-CnB86Psm.js → ListConfigurationPage-B7VtZkjG.js} +5 -4
- package/dist/_chunks/ListConfigurationPage-B7VtZkjG.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-voFVtXu6.mjs → ListConfigurationPage-BVtVADtP.mjs} +6 -5
- package/dist/_chunks/ListConfigurationPage-BVtVADtP.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-SXIXm-RM.js → ListViewPage-C4UCZKeD.js} +68 -42
- package/dist/_chunks/ListViewPage-C4UCZKeD.js.map +1 -0
- package/dist/_chunks/{ListViewPage-B_GaWgRH.mjs → ListViewPage-Dq7nBEKD.mjs} +65 -39
- package/dist/_chunks/ListViewPage-Dq7nBEKD.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-CYiGpsbj.mjs → NoContentTypePage-CQlgc_9h.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-CYiGpsbj.mjs.map → NoContentTypePage-CQlgc_9h.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-BzsQ3hLZ.js → NoContentTypePage-YNlmMHbx.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-BzsQ3hLZ.js.map → NoContentTypePage-YNlmMHbx.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-IGkId4C5.js → NoPermissionsPage-CERDW9_P.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-IGkId4C5.js.map → NoPermissionsPage-CERDW9_P.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-B5baIHal.mjs → NoPermissionsPage-CT2YbxJK.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-B5baIHal.mjs.map → NoPermissionsPage-CT2YbxJK.mjs.map} +1 -1
- package/dist/_chunks/Preview-D9FlX2H8.js +275 -0
- package/dist/_chunks/Preview-D9FlX2H8.js.map +1 -0
- package/dist/_chunks/Preview-GZFXtAgo.mjs +256 -0
- package/dist/_chunks/Preview-GZFXtAgo.mjs.map +1 -0
- package/dist/_chunks/{Relations-CIYDdKU-.mjs → Relations-49C4HPsL.mjs} +72 -36
- package/dist/_chunks/Relations-49C4HPsL.mjs.map +1 -0
- package/dist/_chunks/{Relations-Dhuurpx2.js → Relations-CcJBqH7I.js} +71 -35
- package/dist/_chunks/Relations-CcJBqH7I.js.map +1 -0
- package/dist/_chunks/{en-BrCTWlZv.mjs → en-CfIXaZf9.mjs} +26 -14
- package/dist/_chunks/{en-BrCTWlZv.mjs.map → en-CfIXaZf9.mjs.map} +1 -1
- package/dist/_chunks/{en-uOUIxfcQ.js → en-DTWPCdTS.js} +26 -14
- package/dist/_chunks/{en-uOUIxfcQ.js.map → en-DTWPCdTS.js.map} +1 -1
- package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
- package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
- package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
- package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
- package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
- package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
- package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
- package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
- package/dist/_chunks/{index-C9TJPyni.mjs → index-CP5EOEiH.mjs} +985 -777
- package/dist/_chunks/index-CP5EOEiH.mjs.map +1 -0
- package/dist/_chunks/{index-CdT0kHZ8.js → index-DUjGm1xz.js} +966 -757
- package/dist/_chunks/index-DUjGm1xz.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-BNqvLR_b.mjs → layout-B3LdnMTA.mjs} +5 -4
- package/dist/_chunks/{layout-BNqvLR_b.mjs.map → layout-B3LdnMTA.mjs.map} +1 -1
- package/dist/_chunks/{layout-C6dxWYT7.js → layout-zHc8BsKI.js} +5 -4
- package/dist/_chunks/{layout-C6dxWYT7.js.map → layout-zHc8BsKI.js.map} +1 -1
- package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
- package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
- package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
- package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
- package/dist/_chunks/{relations-CkKqKw65.mjs → relations-DnT2jc-S.mjs} +6 -7
- package/dist/_chunks/relations-DnT2jc-S.mjs.map +1 -0
- package/dist/_chunks/{relations-DtFaDnP1.js → relations-DrsZXRl-.js} +6 -7
- package/dist/_chunks/relations-DrsZXRl-.js.map +1 -0
- package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
- package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +5 -4
- package/dist/admin/src/exports.d.ts +1 -1
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +32 -1
- package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +0 -32
- package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
- package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
- package/dist/admin/src/preview/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 -17
- 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 +421 -183
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +421 -183
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +3 -3
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +4 -4
- package/dist/server/src/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 +15 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts +30 -0
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview.d.ts +12 -0
- package/dist/server/src/preview/services/preview.d.ts.map +1 -0
- package/dist/server/src/preview/utils.d.ts +18 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -0
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/dist/server/src/services/document-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/utils/index.d.ts +2 -0
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/shared/contracts/collection-types.d.ts +3 -1
- package/dist/shared/contracts/collection-types.d.ts.map +1 -1
- package/dist/shared/contracts/index.d.ts +1 -0
- package/dist/shared/contracts/index.d.ts.map +1 -1
- package/dist/shared/contracts/preview.d.ts +27 -0
- package/dist/shared/contracts/preview.d.ts.map +1 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +4 -0
- package/dist/shared/index.mjs.map +1 -1
- package/package.json +13 -13
- package/dist/_chunks/EditViewPage-B7VgwJaG.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-BgjdnGz2.js.map +0 -1
- package/dist/_chunks/Field-CdK7ZLmv.js.map +0 -1
- package/dist/_chunks/Field-tHCw4lGA.mjs.map +0 -1
- package/dist/_chunks/Form-BJxdTv3Q.mjs.map +0 -1
- package/dist/_chunks/Form-C_0KTVvV.js.map +0 -1
- package/dist/_chunks/History-DR2txJLE.mjs.map +0 -1
- package/dist/_chunks/History-nuEzM5qm.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-CnB86Psm.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-voFVtXu6.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-B_GaWgRH.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-SXIXm-RM.js.map +0 -1
- package/dist/_chunks/Relations-CIYDdKU-.mjs.map +0 -1
- package/dist/_chunks/Relations-Dhuurpx2.js.map +0 -1
- package/dist/_chunks/index-C9TJPyni.mjs.map +0 -1
- package/dist/_chunks/index-CdT0kHZ8.js.map +0 -1
- package/dist/_chunks/relations-CkKqKw65.mjs.map +0 -1
- package/dist/_chunks/relations-DtFaDnP1.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,16 +1,17 @@
|
|
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, createContext, useAuth, useRBAC, Page, adminApi, translatedErrors, useNotification, useAPIErrorHandler, getYupValidationErrors,
|
3
|
+
import { useStrapiApp, createContext, useQueryParams, useAuth, useRBAC, Page, adminApi, translatedErrors, useNotification, useAPIErrorHandler, getYupValidationErrors, useForm, useTracking, useGuidedTour, BackButton, DescriptionComponentRenderer, useTable, Table } from "@strapi/admin/strapi-admin";
|
4
4
|
import * as React from "react";
|
5
5
|
import { lazy } from "react";
|
6
|
-
import {
|
6
|
+
import { Button, Menu, 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";
|
7
8
|
import { useIntl } from "react-intl";
|
8
|
-
import { useParams,
|
9
|
-
import { styled } from "styled-components";
|
9
|
+
import { useParams, useNavigate, Navigate, useMatch, useLocation, Link, NavLink } from "react-router-dom";
|
10
10
|
import * as yup from "yup";
|
11
11
|
import { ValidationError } from "yup";
|
12
12
|
import pipe from "lodash/fp/pipe";
|
13
13
|
import { intervalToDuration, isPast } from "date-fns";
|
14
|
+
import { styled } from "styled-components";
|
14
15
|
import { stringify } from "qs";
|
15
16
|
import { createSlice, combineReducers } from "@reduxjs/toolkit";
|
16
17
|
const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
@@ -100,6 +101,7 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
100
101
|
if (!slug) {
|
101
102
|
throw new Error("Cannot find the slug param in the URL");
|
102
103
|
}
|
104
|
+
const [{ rawQuery }] = useQueryParams();
|
103
105
|
const userPermissions = useAuth("DocumentRBAC", (state) => state.permissions);
|
104
106
|
const contentTypePermissions = React.useMemo(() => {
|
105
107
|
const contentTypePermissions2 = userPermissions.filter(
|
@@ -110,7 +112,14 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
110
112
|
return { ...acc, [action]: [permission] };
|
111
113
|
}, {});
|
112
114
|
}, [slug, userPermissions]);
|
113
|
-
const { isLoading, allowedActions } = useRBAC(
|
115
|
+
const { isLoading, allowedActions } = useRBAC(
|
116
|
+
contentTypePermissions,
|
117
|
+
permissions ?? void 0,
|
118
|
+
// TODO: useRBAC context should be typed and built differently
|
119
|
+
// We are passing raw query as context to the hook so that it can
|
120
|
+
// rely on the locale provided from DocumentRBAC for its permission calculations.
|
121
|
+
rawQuery
|
122
|
+
);
|
114
123
|
const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
|
115
124
|
const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
|
116
125
|
const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
|
@@ -158,7 +167,8 @@ const contentManagerApi = adminApi.enhanceEndpoints({
|
|
158
167
|
"Document",
|
159
168
|
"InitialData",
|
160
169
|
"HistoryVersion",
|
161
|
-
"Relations"
|
170
|
+
"Relations",
|
171
|
+
"UidAvailability"
|
162
172
|
]
|
163
173
|
});
|
164
174
|
const documentApi = contentManagerApi.injectEndpoints({
|
@@ -188,7 +198,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
188
198
|
params
|
189
199
|
}
|
190
200
|
}),
|
191
|
-
invalidatesTags: (_result, _error, { model }) => [
|
201
|
+
invalidatesTags: (_result, _error, { model }) => [
|
202
|
+
{ type: "Document", id: `${model}_LIST` },
|
203
|
+
{ type: "UidAvailability", id: model }
|
204
|
+
]
|
192
205
|
}),
|
193
206
|
/**
|
194
207
|
* Creates a new collection-type document. This should ONLY be used for collection-types.
|
@@ -205,7 +218,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
205
218
|
}),
|
206
219
|
invalidatesTags: (result, _error, { model }) => [
|
207
220
|
{ type: "Document", id: `${model}_LIST` },
|
208
|
-
"Relations"
|
221
|
+
"Relations",
|
222
|
+
{ type: "UidAvailability", id: model }
|
209
223
|
]
|
210
224
|
}),
|
211
225
|
deleteDocument: builder.mutation({
|
@@ -246,7 +260,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
246
260
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
247
261
|
},
|
248
262
|
{ type: "Document", id: `${model}_LIST` },
|
249
|
-
"Relations"
|
263
|
+
"Relations",
|
264
|
+
{ type: "UidAvailability", id: model }
|
250
265
|
];
|
251
266
|
}
|
252
267
|
}),
|
@@ -371,7 +386,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
371
386
|
type: "Document",
|
372
387
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
373
388
|
},
|
374
|
-
"Relations"
|
389
|
+
"Relations",
|
390
|
+
{ type: "UidAvailability", id: model }
|
375
391
|
];
|
376
392
|
},
|
377
393
|
async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
|
@@ -454,20 +470,39 @@ const buildValidParams = (query) => {
|
|
454
470
|
const isBaseQueryError = (error) => {
|
455
471
|
return error.name !== void 0;
|
456
472
|
};
|
457
|
-
const
|
473
|
+
const arrayValidator = (attribute, options) => ({
|
474
|
+
message: translatedErrors.required,
|
475
|
+
test(value) {
|
476
|
+
if (options.status === "draft") {
|
477
|
+
return true;
|
478
|
+
}
|
479
|
+
if (!attribute.required) {
|
480
|
+
return true;
|
481
|
+
}
|
482
|
+
if (!value) {
|
483
|
+
return false;
|
484
|
+
}
|
485
|
+
if (Array.isArray(value) && value.length === 0) {
|
486
|
+
return false;
|
487
|
+
}
|
488
|
+
return true;
|
489
|
+
}
|
490
|
+
});
|
491
|
+
const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
|
458
492
|
const createModelSchema = (attributes2) => yup.object().shape(
|
459
493
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
460
494
|
if (DOCUMENT_META_FIELDS.includes(name)) {
|
461
495
|
return acc;
|
462
496
|
}
|
463
497
|
const validations = [
|
498
|
+
addNullableValidation,
|
464
499
|
addRequiredValidation,
|
465
500
|
addMinLengthValidation,
|
466
501
|
addMaxLengthValidation,
|
467
502
|
addMinValidation,
|
468
503
|
addMaxValidation,
|
469
504
|
addRegexValidation
|
470
|
-
].map((fn) => fn(attribute));
|
505
|
+
].map((fn) => fn(attribute, options));
|
471
506
|
const transformSchema = pipe(...validations);
|
472
507
|
switch (attribute.type) {
|
473
508
|
case "component": {
|
@@ -477,12 +512,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
477
512
|
...acc,
|
478
513
|
[name]: transformSchema(
|
479
514
|
yup.array().of(createModelSchema(attributes3).nullable(false))
|
480
|
-
)
|
515
|
+
).test(arrayValidator(attribute, options))
|
481
516
|
};
|
482
517
|
} else {
|
483
518
|
return {
|
484
519
|
...acc,
|
485
|
-
[name]: transformSchema(createModelSchema(attributes3))
|
520
|
+
[name]: transformSchema(createModelSchema(attributes3).nullable())
|
486
521
|
};
|
487
522
|
}
|
488
523
|
}
|
@@ -504,7 +539,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
504
539
|
}
|
505
540
|
)
|
506
541
|
)
|
507
|
-
)
|
542
|
+
).test(arrayValidator(attribute, options))
|
508
543
|
};
|
509
544
|
case "relation":
|
510
545
|
return {
|
@@ -516,7 +551,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
516
551
|
} else if (Array.isArray(value)) {
|
517
552
|
return yup.array().of(
|
518
553
|
yup.object().shape({
|
519
|
-
id: yup.
|
554
|
+
id: yup.number().required()
|
520
555
|
})
|
521
556
|
);
|
522
557
|
} else if (typeof value === "object") {
|
@@ -594,13 +629,7 @@ const createAttributeSchema = (attribute) => {
|
|
594
629
|
return yup.mixed();
|
595
630
|
}
|
596
631
|
};
|
597
|
-
const
|
598
|
-
if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
|
599
|
-
return schema.min(1, translatedErrors.required);
|
600
|
-
}
|
601
|
-
if (attribute.required && attribute.type !== "relation") {
|
602
|
-
return schema.required(translatedErrors.required);
|
603
|
-
}
|
632
|
+
const nullableSchema = (schema) => {
|
604
633
|
return schema?.nullable ? schema.nullable() : (
|
605
634
|
// In some cases '.nullable' will not be available on the schema.
|
606
635
|
// e.g. when the schema has been built using yup.lazy (e.g. for relations).
|
@@ -608,7 +637,22 @@ const addRequiredValidation = (attribute) => (schema) => {
|
|
608
637
|
schema
|
609
638
|
);
|
610
639
|
};
|
611
|
-
const
|
640
|
+
const addNullableValidation = () => (schema) => {
|
641
|
+
return nullableSchema(schema);
|
642
|
+
};
|
643
|
+
const addRequiredValidation = (attribute, options) => (schema) => {
|
644
|
+
if (options.status === "draft" || !attribute.required) {
|
645
|
+
return schema;
|
646
|
+
}
|
647
|
+
if (attribute.required && "required" in schema) {
|
648
|
+
return schema.required(translatedErrors.required);
|
649
|
+
}
|
650
|
+
return schema;
|
651
|
+
};
|
652
|
+
const addMinLengthValidation = (attribute, options) => (schema) => {
|
653
|
+
if (options.status === "draft") {
|
654
|
+
return schema;
|
655
|
+
}
|
612
656
|
if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
|
613
657
|
return schema.min(attribute.minLength, {
|
614
658
|
...translatedErrors.minLength,
|
@@ -630,32 +674,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
630
674
|
}
|
631
675
|
return schema;
|
632
676
|
};
|
633
|
-
const addMinValidation = (attribute) => (schema) => {
|
634
|
-
if ("
|
677
|
+
const addMinValidation = (attribute, options) => (schema) => {
|
678
|
+
if (options.status === "draft") {
|
679
|
+
return schema;
|
680
|
+
}
|
681
|
+
if ("min" in attribute && "min" in schema) {
|
635
682
|
const min = toInteger(attribute.min);
|
636
|
-
if (
|
637
|
-
if (!attribute.required && "test" in schema && min) {
|
638
|
-
return schema.test(
|
639
|
-
"custom-min",
|
640
|
-
{
|
641
|
-
...translatedErrors.min,
|
642
|
-
values: {
|
643
|
-
min: attribute.min
|
644
|
-
}
|
645
|
-
},
|
646
|
-
(value) => {
|
647
|
-
if (!value) {
|
648
|
-
return true;
|
649
|
-
}
|
650
|
-
if (Array.isArray(value) && value.length === 0) {
|
651
|
-
return true;
|
652
|
-
}
|
653
|
-
return value.length >= min;
|
654
|
-
}
|
655
|
-
);
|
656
|
-
}
|
657
|
-
}
|
658
|
-
if ("min" in schema && min) {
|
683
|
+
if (min) {
|
659
684
|
return schema.min(min, {
|
660
685
|
...translatedErrors.min,
|
661
686
|
values: {
|
@@ -773,19 +798,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
|
|
773
798
|
}, {});
|
774
799
|
return componentsByKey;
|
775
800
|
};
|
776
|
-
const
|
801
|
+
const HOOKS = {
|
802
|
+
/**
|
803
|
+
* Hook that allows to mutate the displayed headers of the list view table
|
804
|
+
* @constant
|
805
|
+
* @type {string}
|
806
|
+
*/
|
807
|
+
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
808
|
+
/**
|
809
|
+
* Hook that allows to mutate the CM's collection types links pre-set filters
|
810
|
+
* @constant
|
811
|
+
* @type {string}
|
812
|
+
*/
|
813
|
+
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
814
|
+
/**
|
815
|
+
* Hook that allows to mutate the CM's edit view layout
|
816
|
+
* @constant
|
817
|
+
* @type {string}
|
818
|
+
*/
|
819
|
+
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
820
|
+
/**
|
821
|
+
* Hook that allows to mutate the CM's single types links pre-set filters
|
822
|
+
* @constant
|
823
|
+
* @type {string}
|
824
|
+
*/
|
825
|
+
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
826
|
+
};
|
827
|
+
const contentTypesApi = contentManagerApi.injectEndpoints({
|
828
|
+
endpoints: (builder) => ({
|
829
|
+
getContentTypeConfiguration: builder.query({
|
830
|
+
query: (uid) => ({
|
831
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
832
|
+
method: "GET"
|
833
|
+
}),
|
834
|
+
transformResponse: (response) => response.data,
|
835
|
+
providesTags: (_result, _error, uid) => [
|
836
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
837
|
+
{ type: "ContentTypeSettings", id: "LIST" }
|
838
|
+
]
|
839
|
+
}),
|
840
|
+
getAllContentTypeSettings: builder.query({
|
841
|
+
query: () => "/content-manager/content-types-settings",
|
842
|
+
transformResponse: (response) => response.data,
|
843
|
+
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
844
|
+
}),
|
845
|
+
updateContentTypeConfiguration: builder.mutation({
|
846
|
+
query: ({ uid, ...body }) => ({
|
847
|
+
url: `/content-manager/content-types/${uid}/configuration`,
|
848
|
+
method: "PUT",
|
849
|
+
data: body
|
850
|
+
}),
|
851
|
+
transformResponse: (response) => response.data,
|
852
|
+
invalidatesTags: (_result, _error, { uid }) => [
|
853
|
+
{ type: "ContentTypesConfiguration", id: uid },
|
854
|
+
{ type: "ContentTypeSettings", id: "LIST" },
|
855
|
+
// Is this necessary?
|
856
|
+
{ type: "InitialData" }
|
857
|
+
]
|
858
|
+
})
|
859
|
+
})
|
860
|
+
});
|
861
|
+
const {
|
862
|
+
useGetContentTypeConfigurationQuery,
|
863
|
+
useGetAllContentTypeSettingsQuery,
|
864
|
+
useUpdateContentTypeConfigurationMutation
|
865
|
+
} = contentTypesApi;
|
866
|
+
const checkIfAttributeIsDisplayable = (attribute) => {
|
867
|
+
const { type } = attribute;
|
868
|
+
if (type === "relation") {
|
869
|
+
return !attribute.relation.toLowerCase().includes("morph");
|
870
|
+
}
|
871
|
+
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
872
|
+
};
|
873
|
+
const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
874
|
+
if (!mainFieldName) {
|
875
|
+
return void 0;
|
876
|
+
}
|
877
|
+
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
878
|
+
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
879
|
+
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
880
|
+
);
|
881
|
+
return {
|
882
|
+
name: mainFieldName,
|
883
|
+
type: mainFieldType ?? "string"
|
884
|
+
};
|
885
|
+
};
|
886
|
+
const DEFAULT_SETTINGS = {
|
887
|
+
bulkable: false,
|
888
|
+
filterable: false,
|
889
|
+
searchable: false,
|
890
|
+
pagination: false,
|
891
|
+
defaultSortBy: "",
|
892
|
+
defaultSortOrder: "asc",
|
893
|
+
mainField: "id",
|
894
|
+
pageSize: 10
|
895
|
+
};
|
896
|
+
const useDocumentLayout = (model) => {
|
897
|
+
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
898
|
+
const [{ query }] = useQueryParams();
|
899
|
+
const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
777
900
|
const { toggleNotification } = useNotification();
|
778
901
|
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
902
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
779
903
|
const {
|
780
|
-
|
781
|
-
isLoading:
|
782
|
-
|
783
|
-
|
784
|
-
} =
|
785
|
-
|
786
|
-
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
787
|
-
});
|
788
|
-
const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
|
904
|
+
data,
|
905
|
+
isLoading: isLoadingConfigs,
|
906
|
+
error,
|
907
|
+
isFetching: isFetchingConfigs
|
908
|
+
} = useGetContentTypeConfigurationQuery(model);
|
909
|
+
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
789
910
|
React.useEffect(() => {
|
790
911
|
if (error) {
|
791
912
|
toggleNotification({
|
@@ -793,93 +914,349 @@ const useDocument = (args, opts) => {
|
|
793
914
|
message: formatAPIError(error)
|
794
915
|
});
|
795
916
|
}
|
796
|
-
}, [
|
797
|
-
const
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
(document) => {
|
805
|
-
if (!validationSchema) {
|
806
|
-
throw new Error(
|
807
|
-
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
808
|
-
);
|
809
|
-
}
|
810
|
-
try {
|
811
|
-
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
812
|
-
return null;
|
813
|
-
} catch (error2) {
|
814
|
-
if (error2 instanceof ValidationError) {
|
815
|
-
return getYupValidationErrors(error2);
|
816
|
-
}
|
817
|
-
throw error2;
|
818
|
-
}
|
917
|
+
}, [error, formatAPIError, toggleNotification]);
|
918
|
+
const editLayout = React.useMemo(
|
919
|
+
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
920
|
+
layout: [],
|
921
|
+
components: {},
|
922
|
+
metadatas: {},
|
923
|
+
options: {},
|
924
|
+
settings: DEFAULT_SETTINGS
|
819
925
|
},
|
820
|
-
[
|
926
|
+
[data, isLoading, schemas, schema, components]
|
927
|
+
);
|
928
|
+
const listLayout = React.useMemo(() => {
|
929
|
+
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
930
|
+
layout: [],
|
931
|
+
metadatas: {},
|
932
|
+
options: {},
|
933
|
+
settings: DEFAULT_SETTINGS
|
934
|
+
};
|
935
|
+
}, [data, isLoading, schemas, schema, components]);
|
936
|
+
const { layout: edit } = React.useMemo(
|
937
|
+
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
938
|
+
layout: editLayout,
|
939
|
+
query
|
940
|
+
}),
|
941
|
+
[editLayout, query, runHookWaterfall]
|
821
942
|
);
|
822
|
-
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
823
943
|
return {
|
824
|
-
|
825
|
-
document: data?.data,
|
826
|
-
meta: data?.meta,
|
944
|
+
error,
|
827
945
|
isLoading,
|
828
|
-
|
829
|
-
|
830
|
-
};
|
831
|
-
};
|
832
|
-
const useDoc = () => {
|
833
|
-
const { id, slug, collectionType, origin } = useParams();
|
834
|
-
const [{ query }] = useQueryParams();
|
835
|
-
const params = React.useMemo(() => buildValidParams(query), [query]);
|
836
|
-
if (!collectionType) {
|
837
|
-
throw new Error("Could not find collectionType in url params");
|
838
|
-
}
|
839
|
-
if (!slug) {
|
840
|
-
throw new Error("Could not find model in url params");
|
841
|
-
}
|
842
|
-
return {
|
843
|
-
collectionType,
|
844
|
-
model: slug,
|
845
|
-
id: origin || id === "create" ? void 0 : id,
|
846
|
-
...useDocument(
|
847
|
-
{ documentId: origin || id, model: slug, collectionType, params },
|
848
|
-
{
|
849
|
-
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
850
|
-
}
|
851
|
-
)
|
946
|
+
edit,
|
947
|
+
list: listLayout
|
852
948
|
};
|
853
949
|
};
|
854
|
-
const
|
855
|
-
|
856
|
-
|
857
|
-
}
|
858
|
-
return Object.keys(trad).reduce((acc, current) => {
|
859
|
-
acc[`${pluginId}.${current}`] = trad[current];
|
860
|
-
return acc;
|
861
|
-
}, {});
|
862
|
-
};
|
863
|
-
const getTranslation = (id) => `content-manager.${id}`;
|
864
|
-
const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
865
|
-
id: "notification.error",
|
866
|
-
defaultMessage: "An error occurred, please try again"
|
950
|
+
const useDocLayout = () => {
|
951
|
+
const { model } = useDoc();
|
952
|
+
return useDocumentLayout(model);
|
867
953
|
};
|
868
|
-
const
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
const
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
954
|
+
const formatEditLayout = (data, {
|
955
|
+
schemas,
|
956
|
+
schema,
|
957
|
+
components
|
958
|
+
}) => {
|
959
|
+
let currentPanelIndex = 0;
|
960
|
+
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
961
|
+
data.contentType.layouts.edit,
|
962
|
+
schema?.attributes,
|
963
|
+
data.contentType.metadatas,
|
964
|
+
{ configurations: data.components, schemas: components },
|
965
|
+
schemas
|
966
|
+
).reduce((panels, row) => {
|
967
|
+
if (row.some((field) => field.type === "dynamiczone")) {
|
968
|
+
panels.push([row]);
|
969
|
+
currentPanelIndex += 2;
|
970
|
+
} else {
|
971
|
+
if (!panels[currentPanelIndex]) {
|
972
|
+
panels.push([row]);
|
973
|
+
} else {
|
974
|
+
panels[currentPanelIndex].push(row);
|
975
|
+
}
|
976
|
+
}
|
977
|
+
return panels;
|
978
|
+
}, []);
|
979
|
+
const componentEditAttributes = Object.entries(data.components).reduce(
|
980
|
+
(acc, [uid, configuration]) => {
|
981
|
+
acc[uid] = {
|
982
|
+
layout: convertEditLayoutToFieldLayouts(
|
983
|
+
configuration.layouts.edit,
|
984
|
+
components[uid].attributes,
|
985
|
+
configuration.metadatas,
|
986
|
+
{ configurations: data.components, schemas: components }
|
987
|
+
),
|
988
|
+
settings: {
|
989
|
+
...configuration.settings,
|
990
|
+
icon: components[uid].info.icon,
|
991
|
+
displayName: components[uid].info.displayName
|
992
|
+
}
|
993
|
+
};
|
994
|
+
return acc;
|
995
|
+
},
|
996
|
+
{}
|
997
|
+
);
|
998
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
999
|
+
(acc, [attribute, metadata]) => {
|
1000
|
+
return {
|
1001
|
+
...acc,
|
1002
|
+
[attribute]: metadata.edit
|
1003
|
+
};
|
1004
|
+
},
|
1005
|
+
{}
|
1006
|
+
);
|
1007
|
+
return {
|
1008
|
+
layout: panelledEditAttributes,
|
1009
|
+
components: componentEditAttributes,
|
1010
|
+
metadatas: editMetadatas,
|
1011
|
+
settings: {
|
1012
|
+
...data.contentType.settings,
|
1013
|
+
displayName: schema?.info.displayName
|
1014
|
+
},
|
1015
|
+
options: {
|
1016
|
+
...schema?.options,
|
1017
|
+
...schema?.pluginOptions,
|
1018
|
+
...data.contentType.options
|
1019
|
+
}
|
1020
|
+
};
|
1021
|
+
};
|
1022
|
+
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
1023
|
+
return rows.map(
|
1024
|
+
(row) => row.map((field) => {
|
1025
|
+
const attribute = attributes[field.name];
|
1026
|
+
if (!attribute) {
|
1027
|
+
return null;
|
1028
|
+
}
|
1029
|
+
const { edit: metadata } = metadatas[field.name];
|
1030
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1031
|
+
return {
|
1032
|
+
attribute,
|
1033
|
+
disabled: !metadata.editable,
|
1034
|
+
hint: metadata.description,
|
1035
|
+
label: metadata.label ?? "",
|
1036
|
+
name: field.name,
|
1037
|
+
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
1038
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1039
|
+
schemas,
|
1040
|
+
components: components?.schemas ?? {}
|
1041
|
+
}),
|
1042
|
+
placeholder: metadata.placeholder ?? "",
|
1043
|
+
required: attribute.required ?? false,
|
1044
|
+
size: field.size,
|
1045
|
+
unique: "unique" in attribute ? attribute.unique : false,
|
1046
|
+
visible: metadata.visible ?? true,
|
1047
|
+
type: attribute.type
|
1048
|
+
};
|
1049
|
+
}).filter((field) => field !== null)
|
1050
|
+
);
|
1051
|
+
};
|
1052
|
+
const formatListLayout = (data, {
|
1053
|
+
schemas,
|
1054
|
+
schema,
|
1055
|
+
components
|
1056
|
+
}) => {
|
1057
|
+
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
1058
|
+
(acc, [attribute, metadata]) => {
|
1059
|
+
return {
|
1060
|
+
...acc,
|
1061
|
+
[attribute]: metadata.list
|
1062
|
+
};
|
1063
|
+
},
|
1064
|
+
{}
|
1065
|
+
);
|
1066
|
+
const listAttributes = convertListLayoutToFieldLayouts(
|
1067
|
+
data.contentType.layouts.list,
|
1068
|
+
schema?.attributes,
|
1069
|
+
listMetadatas,
|
1070
|
+
{ configurations: data.components, schemas: components },
|
1071
|
+
schemas
|
1072
|
+
);
|
1073
|
+
return {
|
1074
|
+
layout: listAttributes,
|
1075
|
+
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
1076
|
+
metadatas: listMetadatas,
|
1077
|
+
options: {
|
1078
|
+
...schema?.options,
|
1079
|
+
...schema?.pluginOptions,
|
1080
|
+
...data.contentType.options
|
1081
|
+
}
|
1082
|
+
};
|
1083
|
+
};
|
1084
|
+
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
1085
|
+
return columns.map((name) => {
|
1086
|
+
const attribute = attributes[name];
|
1087
|
+
if (!attribute) {
|
1088
|
+
return null;
|
1089
|
+
}
|
1090
|
+
const metadata = metadatas[name];
|
1091
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
1092
|
+
return {
|
1093
|
+
attribute,
|
1094
|
+
label: metadata.label ?? "",
|
1095
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
1096
|
+
schemas,
|
1097
|
+
components: components?.schemas ?? {}
|
1098
|
+
}),
|
1099
|
+
name,
|
1100
|
+
searchable: metadata.searchable ?? true,
|
1101
|
+
sortable: metadata.sortable ?? true
|
1102
|
+
};
|
1103
|
+
}).filter((field) => field !== null);
|
1104
|
+
};
|
1105
|
+
const useDocument = (args, opts) => {
|
1106
|
+
const { toggleNotification } = useNotification();
|
1107
|
+
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
1108
|
+
const {
|
1109
|
+
currentData: data,
|
1110
|
+
isLoading: isLoadingDocument,
|
1111
|
+
isFetching: isFetchingDocument,
|
1112
|
+
error
|
1113
|
+
} = useGetDocumentQuery(args, {
|
1114
|
+
...opts,
|
1115
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
1116
|
+
});
|
1117
|
+
const {
|
1118
|
+
components,
|
1119
|
+
schema,
|
1120
|
+
schemas,
|
1121
|
+
isLoading: isLoadingSchema
|
1122
|
+
} = useContentTypeSchema(args.model);
|
1123
|
+
React.useEffect(() => {
|
1124
|
+
if (error) {
|
1125
|
+
toggleNotification({
|
1126
|
+
type: "danger",
|
1127
|
+
message: formatAPIError(error)
|
1128
|
+
});
|
1129
|
+
}
|
1130
|
+
}, [toggleNotification, error, formatAPIError, args.collectionType]);
|
1131
|
+
const validationSchema = React.useMemo(() => {
|
1132
|
+
if (!schema) {
|
1133
|
+
return null;
|
1134
|
+
}
|
1135
|
+
return createYupSchema(schema.attributes, components);
|
1136
|
+
}, [schema, components]);
|
1137
|
+
const validate = React.useCallback(
|
1138
|
+
(document) => {
|
1139
|
+
if (!validationSchema) {
|
1140
|
+
throw new Error(
|
1141
|
+
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
1142
|
+
);
|
1143
|
+
}
|
1144
|
+
try {
|
1145
|
+
validationSchema.validateSync(document, { abortEarly: false, strict: true });
|
1146
|
+
return null;
|
1147
|
+
} catch (error2) {
|
1148
|
+
if (error2 instanceof ValidationError) {
|
1149
|
+
return getYupValidationErrors(error2);
|
1150
|
+
}
|
1151
|
+
throw error2;
|
1152
|
+
}
|
1153
|
+
},
|
1154
|
+
[validationSchema]
|
1155
|
+
);
|
1156
|
+
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
1157
|
+
const hasError = !!error;
|
1158
|
+
return {
|
1159
|
+
components,
|
1160
|
+
document: data?.data,
|
1161
|
+
meta: data?.meta,
|
1162
|
+
isLoading,
|
1163
|
+
hasError,
|
1164
|
+
schema,
|
1165
|
+
schemas,
|
1166
|
+
validate
|
1167
|
+
};
|
1168
|
+
};
|
1169
|
+
const useDoc = () => {
|
1170
|
+
const { id, slug, collectionType, origin } = useParams();
|
1171
|
+
const [{ query }] = useQueryParams();
|
1172
|
+
const params = React.useMemo(() => buildValidParams(query), [query]);
|
1173
|
+
if (!collectionType) {
|
1174
|
+
throw new Error("Could not find collectionType in url params");
|
1175
|
+
}
|
1176
|
+
if (!slug) {
|
1177
|
+
throw new Error("Could not find model in url params");
|
1178
|
+
}
|
1179
|
+
const document = useDocument(
|
1180
|
+
{ documentId: origin || id, model: slug, collectionType, params },
|
1181
|
+
{
|
1182
|
+
skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
|
1183
|
+
}
|
1184
|
+
);
|
1185
|
+
const returnId = origin || id === "create" ? void 0 : id;
|
1186
|
+
return {
|
1187
|
+
collectionType,
|
1188
|
+
model: slug,
|
1189
|
+
id: returnId,
|
1190
|
+
...document
|
1191
|
+
};
|
1192
|
+
};
|
1193
|
+
const useContentManagerContext = () => {
|
1194
|
+
const {
|
1195
|
+
collectionType,
|
1196
|
+
model,
|
1197
|
+
id,
|
1198
|
+
components,
|
1199
|
+
isLoading: isLoadingDoc,
|
1200
|
+
schema,
|
1201
|
+
schemas
|
1202
|
+
} = useDoc();
|
1203
|
+
const layout = useDocumentLayout(model);
|
1204
|
+
const form = useForm("useContentManagerContext", (state) => state);
|
1205
|
+
const isSingleType = collectionType === SINGLE_TYPES;
|
1206
|
+
const slug = model;
|
1207
|
+
const isCreatingEntry = id === "create";
|
1208
|
+
useContentTypeSchema();
|
1209
|
+
const isLoading = isLoadingDoc || layout.isLoading;
|
1210
|
+
const error = layout.error;
|
1211
|
+
return {
|
1212
|
+
error,
|
1213
|
+
isLoading,
|
1214
|
+
// Base metadata
|
1215
|
+
model,
|
1216
|
+
collectionType,
|
1217
|
+
id,
|
1218
|
+
slug,
|
1219
|
+
isCreatingEntry,
|
1220
|
+
isSingleType,
|
1221
|
+
hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
|
1222
|
+
// All schema infos
|
1223
|
+
components,
|
1224
|
+
contentType: schema,
|
1225
|
+
contentTypes: schemas,
|
1226
|
+
// Form state
|
1227
|
+
form,
|
1228
|
+
// layout infos
|
1229
|
+
layout
|
1230
|
+
};
|
1231
|
+
};
|
1232
|
+
const prefixPluginTranslations = (trad, pluginId) => {
|
1233
|
+
return Object.keys(trad).reduce((acc, current) => {
|
1234
|
+
acc[`${pluginId}.${current}`] = trad[current];
|
1235
|
+
return acc;
|
1236
|
+
}, {});
|
1237
|
+
};
|
1238
|
+
const getTranslation = (id) => `content-manager.${id}`;
|
1239
|
+
const DEFAULT_UNEXPECTED_ERROR_MSG = {
|
1240
|
+
id: "notification.error",
|
1241
|
+
defaultMessage: "An error occurred, please try again"
|
1242
|
+
};
|
1243
|
+
const useDocumentActions = () => {
|
1244
|
+
const { toggleNotification } = useNotification();
|
1245
|
+
const { formatMessage } = useIntl();
|
1246
|
+
const { trackUsage } = useTracking();
|
1247
|
+
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
1248
|
+
const navigate = useNavigate();
|
1249
|
+
const setCurrentStep = useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
|
1250
|
+
const [deleteDocument] = useDeleteDocumentMutation();
|
1251
|
+
const _delete = React.useCallback(
|
1252
|
+
async ({ collectionType, model, documentId, params }, trackerProperty) => {
|
1253
|
+
try {
|
1254
|
+
trackUsage("willDeleteEntry", trackerProperty);
|
1255
|
+
const res = await deleteDocument({
|
1256
|
+
collectionType,
|
1257
|
+
model,
|
1258
|
+
documentId,
|
1259
|
+
params
|
883
1260
|
});
|
884
1261
|
if ("error" in res) {
|
885
1262
|
toggleNotification({
|
@@ -1184,6 +1561,7 @@ const useDocumentActions = () => {
|
|
1184
1561
|
defaultMessage: "Saved document"
|
1185
1562
|
})
|
1186
1563
|
});
|
1564
|
+
setCurrentStep("contentManager.success");
|
1187
1565
|
return res.data;
|
1188
1566
|
} catch (err) {
|
1189
1567
|
toggleNotification({
|
@@ -1223,7 +1601,7 @@ const useDocumentActions = () => {
|
|
1223
1601
|
throw err;
|
1224
1602
|
}
|
1225
1603
|
},
|
1226
|
-
[autoCloneDocument,
|
1604
|
+
[autoCloneDocument, formatMessage, toggleNotification]
|
1227
1605
|
);
|
1228
1606
|
const [cloneDocument] = useCloneDocumentMutation();
|
1229
1607
|
const clone = React.useCallback(
|
@@ -1249,6 +1627,7 @@ const useDocumentActions = () => {
|
|
1249
1627
|
defaultMessage: "Cloned document"
|
1250
1628
|
})
|
1251
1629
|
});
|
1630
|
+
navigate(`../../${res.data.data.documentId}`, { relative: "path" });
|
1252
1631
|
return res.data;
|
1253
1632
|
} catch (err) {
|
1254
1633
|
toggleNotification({
|
@@ -1259,7 +1638,7 @@ const useDocumentActions = () => {
|
|
1259
1638
|
throw err;
|
1260
1639
|
}
|
1261
1640
|
},
|
1262
|
-
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
|
1641
|
+
[cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
|
1263
1642
|
);
|
1264
1643
|
const [getDoc] = useLazyGetDocumentQuery();
|
1265
1644
|
const getDocument = React.useCallback(
|
@@ -1284,45 +1663,58 @@ const useDocumentActions = () => {
|
|
1284
1663
|
update
|
1285
1664
|
};
|
1286
1665
|
};
|
1287
|
-
const ProtectedHistoryPage = lazy(
|
1288
|
-
() => import("./History-
|
1666
|
+
const ProtectedHistoryPage = React.lazy(
|
1667
|
+
() => import("./History-BQ721fHN.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1668
|
+
);
|
1669
|
+
const routes$2 = [
|
1670
|
+
{
|
1671
|
+
path: ":collectionType/:slug/:id/history",
|
1672
|
+
Component: ProtectedHistoryPage
|
1673
|
+
},
|
1674
|
+
{
|
1675
|
+
path: ":collectionType/:slug/history",
|
1676
|
+
Component: ProtectedHistoryPage
|
1677
|
+
}
|
1678
|
+
];
|
1679
|
+
const ProtectedPreviewPage = React.lazy(
|
1680
|
+
() => import("./Preview-GZFXtAgo.mjs").then((mod) => ({ default: mod.ProtectedPreviewPage }))
|
1289
1681
|
);
|
1290
1682
|
const routes$1 = [
|
1291
1683
|
{
|
1292
|
-
path: ":collectionType/:slug/:id/
|
1293
|
-
Component:
|
1684
|
+
path: ":collectionType/:slug/:id/preview",
|
1685
|
+
Component: ProtectedPreviewPage
|
1294
1686
|
},
|
1295
1687
|
{
|
1296
|
-
path: ":collectionType/:slug/
|
1297
|
-
Component:
|
1688
|
+
path: ":collectionType/:slug/preview",
|
1689
|
+
Component: ProtectedPreviewPage
|
1298
1690
|
}
|
1299
1691
|
];
|
1300
1692
|
const ProtectedEditViewPage = lazy(
|
1301
|
-
() => import("./EditViewPage-
|
1693
|
+
() => import("./EditViewPage-BeRi9xCR.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1302
1694
|
);
|
1303
1695
|
const ProtectedListViewPage = lazy(
|
1304
|
-
() => import("./ListViewPage-
|
1696
|
+
() => import("./ListViewPage-Dq7nBEKD.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1305
1697
|
);
|
1306
1698
|
const ProtectedListConfiguration = lazy(
|
1307
|
-
() => import("./ListConfigurationPage-
|
1699
|
+
() => import("./ListConfigurationPage-BVtVADtP.mjs").then((mod) => ({
|
1308
1700
|
default: mod.ProtectedListConfiguration
|
1309
1701
|
}))
|
1310
1702
|
);
|
1311
1703
|
const ProtectedEditConfigurationPage = lazy(
|
1312
|
-
() => import("./EditConfigurationPage-
|
1704
|
+
() => import("./EditConfigurationPage-DBVSBjCB.mjs").then((mod) => ({
|
1313
1705
|
default: mod.ProtectedEditConfigurationPage
|
1314
1706
|
}))
|
1315
1707
|
);
|
1316
1708
|
const ProtectedComponentConfigurationPage = lazy(
|
1317
|
-
() => import("./ComponentConfigurationPage-
|
1709
|
+
() => import("./ComponentConfigurationPage-aeNlfgi9.mjs").then((mod) => ({
|
1318
1710
|
default: mod.ProtectedComponentConfigurationPage
|
1319
1711
|
}))
|
1320
1712
|
);
|
1321
1713
|
const NoPermissions = lazy(
|
1322
|
-
() => import("./NoPermissionsPage-
|
1714
|
+
() => import("./NoPermissionsPage-CT2YbxJK.mjs").then((mod) => ({ default: mod.NoPermissions }))
|
1323
1715
|
);
|
1324
1716
|
const NoContentType = lazy(
|
1325
|
-
() => import("./NoContentTypePage-
|
1717
|
+
() => import("./NoContentTypePage-CQlgc_9h.mjs").then((mod) => ({ default: mod.NoContentType }))
|
1326
1718
|
);
|
1327
1719
|
const CollectionTypePages = () => {
|
1328
1720
|
const { collectionType } = useParams();
|
@@ -1334,7 +1726,7 @@ const CollectionTypePages = () => {
|
|
1334
1726
|
const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
|
1335
1727
|
const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
|
1336
1728
|
const LIST_RELATIVE_PATH = ":collectionType/:slug";
|
1337
|
-
const LIST_PATH = `/content-manager
|
1729
|
+
const LIST_PATH = `/content-manager/collection-types/:slug`;
|
1338
1730
|
const routes = [
|
1339
1731
|
{
|
1340
1732
|
path: LIST_RELATIVE_PATH,
|
@@ -1368,6 +1760,7 @@ const routes = [
|
|
1368
1760
|
path: "no-content-types",
|
1369
1761
|
Component: NoContentType
|
1370
1762
|
},
|
1763
|
+
...routes$2,
|
1371
1764
|
...routes$1
|
1372
1765
|
];
|
1373
1766
|
const DocumentActions = ({ actions: actions2 }) => {
|
@@ -1503,7 +1896,7 @@ const DocumentActionsMenu = ({
|
|
1503
1896
|
};
|
1504
1897
|
return /* @__PURE__ */ jsxs(Menu.Root, { open: isOpen, onOpenChange: setIsOpen, children: [
|
1505
1898
|
/* @__PURE__ */ jsxs(
|
1506
|
-
|
1899
|
+
Menu.Trigger,
|
1507
1900
|
{
|
1508
1901
|
disabled: isDisabled,
|
1509
1902
|
size: "S",
|
@@ -1521,7 +1914,7 @@ const DocumentActionsMenu = ({
|
|
1521
1914
|
]
|
1522
1915
|
}
|
1523
1916
|
),
|
1524
|
-
/* @__PURE__ */ jsxs(Menu.Content, {
|
1917
|
+
/* @__PURE__ */ jsxs(Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
|
1525
1918
|
actions2.map((action) => {
|
1526
1919
|
return /* @__PURE__ */ jsx(
|
1527
1920
|
Menu.Item,
|
@@ -1529,43 +1922,25 @@ const DocumentActionsMenu = ({
|
|
1529
1922
|
disabled: action.disabled,
|
1530
1923
|
onSelect: handleClick(action),
|
1531
1924
|
display: "block",
|
1532
|
-
children: /* @__PURE__ */
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
),
|
1552
|
-
action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsx(
|
1553
|
-
Flex,
|
1554
|
-
{
|
1555
|
-
alignItems: "center",
|
1556
|
-
background: "alternative100",
|
1557
|
-
borderStyle: "solid",
|
1558
|
-
borderColor: "alternative200",
|
1559
|
-
borderWidth: "1px",
|
1560
|
-
height: 5,
|
1561
|
-
paddingLeft: 2,
|
1562
|
-
paddingRight: 2,
|
1563
|
-
hasRadius: true,
|
1564
|
-
color: "alternative600",
|
1565
|
-
children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", fontWeight: "bold", lineHeight: 1, children: formatMessage({ id: "global.new", defaultMessage: "New" }) })
|
1566
|
-
}
|
1567
|
-
)
|
1568
|
-
] })
|
1925
|
+
children: /* @__PURE__ */ jsx(Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxs(
|
1926
|
+
Flex,
|
1927
|
+
{
|
1928
|
+
color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
|
1929
|
+
gap: 2,
|
1930
|
+
tag: "span",
|
1931
|
+
children: [
|
1932
|
+
/* @__PURE__ */ jsx(
|
1933
|
+
Flex,
|
1934
|
+
{
|
1935
|
+
tag: "span",
|
1936
|
+
color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
|
1937
|
+
children: action.icon
|
1938
|
+
}
|
1939
|
+
),
|
1940
|
+
action.label
|
1941
|
+
]
|
1942
|
+
}
|
1943
|
+
) })
|
1569
1944
|
},
|
1570
1945
|
action.id
|
1571
1946
|
);
|
@@ -1619,11 +1994,6 @@ const convertActionVariantToIconColor = (variant = "secondary") => {
|
|
1619
1994
|
return "primary600";
|
1620
1995
|
}
|
1621
1996
|
};
|
1622
|
-
const StyledMoreButton = styled(Menu.Trigger)`
|
1623
|
-
& > span {
|
1624
|
-
display: flex;
|
1625
|
-
}
|
1626
|
-
`;
|
1627
1997
|
const DocumentActionConfirmDialog = ({
|
1628
1998
|
onClose,
|
1629
1999
|
onCancel,
|
@@ -1650,11 +2020,11 @@ const DocumentActionConfirmDialog = ({
|
|
1650
2020
|
/* @__PURE__ */ jsx(Dialog.Header, { children: title }),
|
1651
2021
|
/* @__PURE__ */ jsx(Dialog.Body, { children: content }),
|
1652
2022
|
/* @__PURE__ */ jsxs(Dialog.Footer, { children: [
|
1653
|
-
/* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: formatMessage({
|
2023
|
+
/* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
|
1654
2024
|
id: "app.components.Button.cancel",
|
1655
2025
|
defaultMessage: "Cancel"
|
1656
2026
|
}) }) }),
|
1657
|
-
/* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, children: formatMessage({
|
2027
|
+
/* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
|
1658
2028
|
id: "app.components.Button.confirm",
|
1659
2029
|
defaultMessage: "Confirm"
|
1660
2030
|
}) })
|
@@ -1681,6 +2051,18 @@ const DocumentActionModal = ({
|
|
1681
2051
|
typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
|
1682
2052
|
] }) });
|
1683
2053
|
};
|
2054
|
+
const transformData = (data) => {
|
2055
|
+
if (Array.isArray(data)) {
|
2056
|
+
return data.map(transformData);
|
2057
|
+
}
|
2058
|
+
if (typeof data === "object" && data !== null) {
|
2059
|
+
if ("apiData" in data) {
|
2060
|
+
return data.apiData;
|
2061
|
+
}
|
2062
|
+
return mapValues(transformData)(data);
|
2063
|
+
}
|
2064
|
+
return data;
|
2065
|
+
};
|
1684
2066
|
const PublishAction$1 = ({
|
1685
2067
|
activeTab,
|
1686
2068
|
documentId,
|
@@ -1693,12 +2075,10 @@ const PublishAction$1 = ({
|
|
1693
2075
|
const navigate = useNavigate();
|
1694
2076
|
const { toggleNotification } = useNotification();
|
1695
2077
|
const { _unstableFormatValidationErrors: formatValidationErrors } = useAPIErrorHandler();
|
2078
|
+
const isListView = useMatch(LIST_PATH) !== null;
|
1696
2079
|
const isCloning = useMatch(CLONE_PATH) !== null;
|
1697
2080
|
const { formatMessage } = useIntl();
|
1698
|
-
const { canPublish
|
1699
|
-
"PublishAction",
|
1700
|
-
({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
|
1701
|
-
);
|
2081
|
+
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
1702
2082
|
const { publish } = useDocumentActions();
|
1703
2083
|
const [
|
1704
2084
|
countDraftRelations,
|
@@ -1750,24 +2130,25 @@ const PublishAction$1 = ({
|
|
1750
2130
|
}
|
1751
2131
|
}, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
|
1752
2132
|
React.useEffect(() => {
|
1753
|
-
if (documentId) {
|
1754
|
-
|
1755
|
-
const { data, error } = await countDraftRelations({
|
1756
|
-
collectionType,
|
1757
|
-
model,
|
1758
|
-
documentId,
|
1759
|
-
params
|
1760
|
-
});
|
1761
|
-
if (error) {
|
1762
|
-
throw error;
|
1763
|
-
}
|
1764
|
-
if (data) {
|
1765
|
-
setServerCountOfDraftRelations(data.data);
|
1766
|
-
}
|
1767
|
-
};
|
1768
|
-
fetchDraftRelationsCount();
|
2133
|
+
if (!document || !document.documentId || isListView) {
|
2134
|
+
return;
|
1769
2135
|
}
|
1770
|
-
|
2136
|
+
const fetchDraftRelationsCount = async () => {
|
2137
|
+
const { data, error } = await countDraftRelations({
|
2138
|
+
collectionType,
|
2139
|
+
model,
|
2140
|
+
documentId,
|
2141
|
+
params
|
2142
|
+
});
|
2143
|
+
if (error) {
|
2144
|
+
throw error;
|
2145
|
+
}
|
2146
|
+
if (data) {
|
2147
|
+
setServerCountOfDraftRelations(data.data);
|
2148
|
+
}
|
2149
|
+
};
|
2150
|
+
fetchDraftRelationsCount();
|
2151
|
+
}, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
|
1771
2152
|
const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
|
1772
2153
|
if (!schema?.options?.draftAndPublish) {
|
1773
2154
|
return null;
|
@@ -1775,7 +2156,9 @@ const PublishAction$1 = ({
|
|
1775
2156
|
const performPublish = async () => {
|
1776
2157
|
setSubmitting(true);
|
1777
2158
|
try {
|
1778
|
-
const { errors } = await validate(
|
2159
|
+
const { errors } = await validate(true, {
|
2160
|
+
status: "published"
|
2161
|
+
});
|
1779
2162
|
if (errors) {
|
1780
2163
|
toggleNotification({
|
1781
2164
|
type: "danger",
|
@@ -1793,7 +2176,7 @@ const PublishAction$1 = ({
|
|
1793
2176
|
documentId,
|
1794
2177
|
params
|
1795
2178
|
},
|
1796
|
-
formValues
|
2179
|
+
transformData(formValues)
|
1797
2180
|
);
|
1798
2181
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1799
2182
|
navigate({
|
@@ -1808,7 +2191,8 @@ const PublishAction$1 = ({
|
|
1808
2191
|
}
|
1809
2192
|
};
|
1810
2193
|
const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
|
1811
|
-
const
|
2194
|
+
const enableDraftRelationsCount = false;
|
2195
|
+
const hasDraftRelations = enableDraftRelationsCount;
|
1812
2196
|
return {
|
1813
2197
|
/**
|
1814
2198
|
* Disabled when:
|
@@ -1825,9 +2209,6 @@ const PublishAction$1 = ({
|
|
1825
2209
|
defaultMessage: "Publish"
|
1826
2210
|
}),
|
1827
2211
|
onClick: async () => {
|
1828
|
-
if (hasDraftRelations) {
|
1829
|
-
return;
|
1830
|
-
}
|
1831
2212
|
await performPublish();
|
1832
2213
|
},
|
1833
2214
|
dialog: hasDraftRelations ? {
|
@@ -1866,10 +2247,6 @@ const UpdateAction = ({
|
|
1866
2247
|
const cloneMatch = useMatch(CLONE_PATH);
|
1867
2248
|
const isCloning = cloneMatch !== null;
|
1868
2249
|
const { formatMessage } = useIntl();
|
1869
|
-
useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
|
1870
|
-
canCreate: canCreate2,
|
1871
|
-
canUpdate: canUpdate2
|
1872
|
-
}));
|
1873
2250
|
const { create, update, clone } = useDocumentActions();
|
1874
2251
|
const [{ query, rawQuery }] = useQueryParams();
|
1875
2252
|
const params = React.useMemo(() => buildValidParams(query), [query]);
|
@@ -1895,7 +2272,9 @@ const UpdateAction = ({
|
|
1895
2272
|
onClick: async () => {
|
1896
2273
|
setSubmitting(true);
|
1897
2274
|
try {
|
1898
|
-
const { errors } = await validate(
|
2275
|
+
const { errors } = await validate(true, {
|
2276
|
+
status: "draft"
|
2277
|
+
});
|
1899
2278
|
if (errors) {
|
1900
2279
|
toggleNotification({
|
1901
2280
|
type: "danger",
|
@@ -1913,7 +2292,7 @@ const UpdateAction = ({
|
|
1913
2292
|
documentId: cloneMatch.params.origin,
|
1914
2293
|
params
|
1915
2294
|
},
|
1916
|
-
document
|
2295
|
+
transformData(document)
|
1917
2296
|
);
|
1918
2297
|
if ("data" in res) {
|
1919
2298
|
navigate(
|
@@ -1934,7 +2313,7 @@ const UpdateAction = ({
|
|
1934
2313
|
documentId,
|
1935
2314
|
params
|
1936
2315
|
},
|
1937
|
-
document
|
2316
|
+
transformData(document)
|
1938
2317
|
);
|
1939
2318
|
if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1940
2319
|
setErrors(formatValidationErrors(res.error));
|
@@ -1947,7 +2326,7 @@ const UpdateAction = ({
|
|
1947
2326
|
model,
|
1948
2327
|
params
|
1949
2328
|
},
|
1950
|
-
document
|
2329
|
+
transformData(document)
|
1951
2330
|
);
|
1952
2331
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1953
2332
|
navigate(
|
@@ -2000,7 +2379,7 @@ const UnpublishAction$1 = ({
|
|
2000
2379
|
id: "app.utils.unpublish",
|
2001
2380
|
defaultMessage: "Unpublish"
|
2002
2381
|
}),
|
2003
|
-
icon: /* @__PURE__ */ jsx(
|
2382
|
+
icon: /* @__PURE__ */ jsx(Cross, {}),
|
2004
2383
|
onClick: async () => {
|
2005
2384
|
if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
|
2006
2385
|
if (!documentId) {
|
@@ -2112,7 +2491,7 @@ const DiscardAction = ({
|
|
2112
2491
|
id: "content-manager.actions.discard.label",
|
2113
2492
|
defaultMessage: "Discard changes"
|
2114
2493
|
}),
|
2115
|
-
icon: /* @__PURE__ */ jsx(
|
2494
|
+
icon: /* @__PURE__ */ jsx(Cross, {}),
|
2116
2495
|
position: ["panel", "table-row"],
|
2117
2496
|
variant: "danger",
|
2118
2497
|
dialog: {
|
@@ -2140,11 +2519,6 @@ const DiscardAction = ({
|
|
2140
2519
|
};
|
2141
2520
|
};
|
2142
2521
|
DiscardAction.type = "discard";
|
2143
|
-
const StyledCrossCircle = styled(CrossCircle)`
|
2144
|
-
path {
|
2145
|
-
fill: currentColor;
|
2146
|
-
}
|
2147
|
-
`;
|
2148
2522
|
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
2149
2523
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
2150
2524
|
const RelativeTime = React.forwardRef(
|
@@ -2157,7 +2531,7 @@ const RelativeTime = React.forwardRef(
|
|
2157
2531
|
});
|
2158
2532
|
const unit = intervals.find((intervalUnit) => {
|
2159
2533
|
return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
|
2160
|
-
});
|
2534
|
+
}) ?? "seconds";
|
2161
2535
|
const relativeTime = isPast(timestamp) ? -interval[unit] : interval[unit];
|
2162
2536
|
const customInterval = customIntervals.find(
|
2163
2537
|
(custom) => interval[custom.unit] < custom.threshold
|
@@ -2191,19 +2565,29 @@ const getDisplayName = ({
|
|
2191
2565
|
return email ?? "";
|
2192
2566
|
};
|
2193
2567
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2194
|
-
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2195
|
-
const statusVariant = status === "draft" ? "
|
2196
|
-
|
2568
|
+
const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
|
2569
|
+
const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
|
2570
|
+
const { formatMessage } = useIntl();
|
2571
|
+
return /* @__PURE__ */ jsx(Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
|
2572
|
+
id: `content-manager.containers.List.${status}`,
|
2573
|
+
defaultMessage: capitalise(status)
|
2574
|
+
}) }) });
|
2197
2575
|
};
|
2198
2576
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
2199
2577
|
const { formatMessage } = useIntl();
|
2200
2578
|
const isCloning = useMatch(CLONE_PATH) !== null;
|
2579
|
+
const params = useParams();
|
2201
2580
|
const title = isCreating ? formatMessage({
|
2202
2581
|
id: "content-manager.containers.edit.title.new",
|
2203
2582
|
defaultMessage: "Create an entry"
|
2204
2583
|
}) : documentTitle;
|
2205
2584
|
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
|
2206
|
-
/* @__PURE__ */ jsx(
|
2585
|
+
/* @__PURE__ */ jsx(
|
2586
|
+
BackButton,
|
2587
|
+
{
|
2588
|
+
fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
|
2589
|
+
}
|
2590
|
+
),
|
2207
2591
|
/* @__PURE__ */ jsxs(Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
|
2208
2592
|
/* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
|
2209
2593
|
/* @__PURE__ */ jsx(HeaderToolbar, {})
|
@@ -2291,12 +2675,12 @@ const Information = ({ activeTab }) => {
|
|
2291
2675
|
isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
|
2292
2676
|
label: formatMessage({
|
2293
2677
|
id: "content-manager.containers.edit.information.last-published.label",
|
2294
|
-
defaultMessage: "
|
2678
|
+
defaultMessage: "Published"
|
2295
2679
|
}),
|
2296
2680
|
value: formatMessage(
|
2297
2681
|
{
|
2298
2682
|
id: "content-manager.containers.edit.information.last-published.value",
|
2299
|
-
defaultMessage: `
|
2683
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2300
2684
|
},
|
2301
2685
|
{
|
2302
2686
|
time: /* @__PURE__ */ jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
|
@@ -2309,12 +2693,12 @@ const Information = ({ activeTab }) => {
|
|
2309
2693
|
isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
|
2310
2694
|
label: formatMessage({
|
2311
2695
|
id: "content-manager.containers.edit.information.last-draft.label",
|
2312
|
-
defaultMessage: "
|
2696
|
+
defaultMessage: "Updated"
|
2313
2697
|
}),
|
2314
2698
|
value: formatMessage(
|
2315
2699
|
{
|
2316
2700
|
id: "content-manager.containers.edit.information.last-draft.value",
|
2317
|
-
defaultMessage: `
|
2701
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2318
2702
|
},
|
2319
2703
|
{
|
2320
2704
|
time: /* @__PURE__ */ jsx(
|
@@ -2332,12 +2716,12 @@ const Information = ({ activeTab }) => {
|
|
2332
2716
|
isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
|
2333
2717
|
label: formatMessage({
|
2334
2718
|
id: "content-manager.containers.edit.information.document.label",
|
2335
|
-
defaultMessage: "
|
2719
|
+
defaultMessage: "Created"
|
2336
2720
|
}),
|
2337
2721
|
value: formatMessage(
|
2338
2722
|
{
|
2339
2723
|
id: "content-manager.containers.edit.information.document.value",
|
2340
|
-
defaultMessage: `
|
2724
|
+
defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
|
2341
2725
|
},
|
2342
2726
|
{
|
2343
2727
|
time: /* @__PURE__ */ jsx(
|
@@ -2375,523 +2759,277 @@ const Information = ({ activeTab }) => {
|
|
2375
2759
|
);
|
2376
2760
|
};
|
2377
2761
|
const HeaderActions = ({ actions: actions2 }) => {
|
2378
|
-
|
2379
|
-
|
2762
|
+
const [dialogId, setDialogId] = React.useState(null);
|
2763
|
+
const handleClick = (action) => async (e) => {
|
2764
|
+
if (!("options" in action)) {
|
2765
|
+
const { onClick = () => false, dialog, id } = action;
|
2766
|
+
const muteDialog = await onClick(e);
|
2767
|
+
if (dialog && !muteDialog) {
|
2768
|
+
e.preventDefault();
|
2769
|
+
setDialogId(id);
|
2770
|
+
}
|
2771
|
+
}
|
2772
|
+
};
|
2773
|
+
const handleClose = () => {
|
2774
|
+
setDialogId(null);
|
2775
|
+
};
|
2776
|
+
return /* @__PURE__ */ jsx(Flex, { gap: 1, children: actions2.map((action) => {
|
2777
|
+
if (action.options) {
|
2380
2778
|
return /* @__PURE__ */ jsx(
|
2381
2779
|
SingleSelect,
|
2382
2780
|
{
|
2383
2781
|
size: "S",
|
2384
|
-
disabled: action.disabled,
|
2385
|
-
"aria-label": action.label,
|
2386
2782
|
onChange: action.onSelect,
|
2387
|
-
|
2783
|
+
"aria-label": action.label,
|
2784
|
+
...action,
|
2388
2785
|
children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsx(SingleSelectOption, { ...option, children: label }, option.value))
|
2389
2786
|
},
|
2390
2787
|
action.id
|
2391
2788
|
);
|
2392
2789
|
} else {
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2396
|
-
|
2397
|
-
|
2398
|
-
|
2399
|
-
|
2400
|
-
|
2401
|
-
|
2402
|
-
|
2403
|
-
defaultMessage: "Configure the view"
|
2404
|
-
}),
|
2405
|
-
icon: /* @__PURE__ */ jsx(ListPlus, {}),
|
2406
|
-
onClick: () => {
|
2407
|
-
navigate(`../${collectionType}/${model}/configurations/edit`);
|
2408
|
-
},
|
2409
|
-
position: "header"
|
2410
|
-
};
|
2411
|
-
};
|
2412
|
-
ConfigureTheViewAction.type = "configure-the-view";
|
2413
|
-
const EditTheModelAction = ({ model }) => {
|
2414
|
-
const navigate = useNavigate();
|
2415
|
-
const { formatMessage } = useIntl();
|
2416
|
-
return {
|
2417
|
-
label: formatMessage({
|
2418
|
-
id: "content-manager.link-to-ctb",
|
2419
|
-
defaultMessage: "Edit the model"
|
2420
|
-
}),
|
2421
|
-
icon: /* @__PURE__ */ jsx(Pencil, {}),
|
2422
|
-
onClick: () => {
|
2423
|
-
navigate(`/plugins/content-type-builder/content-types/${model}`);
|
2424
|
-
},
|
2425
|
-
position: "header"
|
2426
|
-
};
|
2427
|
-
};
|
2428
|
-
EditTheModelAction.type = "edit-the-model";
|
2429
|
-
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2430
|
-
const navigate = useNavigate();
|
2431
|
-
const { formatMessage } = useIntl();
|
2432
|
-
const listViewPathMatch = useMatch(LIST_PATH);
|
2433
|
-
const canDelete = useDocumentRBAC("DeleteAction", (state) => state.canDelete);
|
2434
|
-
const { delete: deleteAction } = useDocumentActions();
|
2435
|
-
const { toggleNotification } = useNotification();
|
2436
|
-
const setSubmitting = useForm("DeleteAction", (state) => state.setSubmitting);
|
2437
|
-
return {
|
2438
|
-
disabled: !canDelete || !document,
|
2439
|
-
label: formatMessage({
|
2440
|
-
id: "content-manager.actions.delete.label",
|
2441
|
-
defaultMessage: "Delete document"
|
2442
|
-
}),
|
2443
|
-
icon: /* @__PURE__ */ jsx(Trash, {}),
|
2444
|
-
dialog: {
|
2445
|
-
type: "dialog",
|
2446
|
-
title: formatMessage({
|
2447
|
-
id: "app.components.ConfirmDialog.title",
|
2448
|
-
defaultMessage: "Confirmation"
|
2449
|
-
}),
|
2450
|
-
content: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
|
2451
|
-
/* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
2452
|
-
/* @__PURE__ */ jsx(Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
2453
|
-
id: "content-manager.actions.delete.dialog.body",
|
2454
|
-
defaultMessage: "Are you sure?"
|
2455
|
-
}) })
|
2456
|
-
] }),
|
2457
|
-
onConfirm: async () => {
|
2458
|
-
if (!listViewPathMatch) {
|
2459
|
-
setSubmitting(true);
|
2460
|
-
}
|
2461
|
-
try {
|
2462
|
-
if (!documentId && collectionType !== SINGLE_TYPES) {
|
2463
|
-
console.error(
|
2464
|
-
"You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue."
|
2465
|
-
);
|
2466
|
-
toggleNotification({
|
2467
|
-
message: formatMessage({
|
2468
|
-
id: "content-manager.actions.delete.error",
|
2469
|
-
defaultMessage: "An error occurred while trying to delete the document."
|
2470
|
-
}),
|
2471
|
-
type: "danger"
|
2472
|
-
});
|
2473
|
-
return;
|
2474
|
-
}
|
2475
|
-
const res = await deleteAction({
|
2476
|
-
documentId,
|
2477
|
-
model,
|
2478
|
-
collectionType,
|
2479
|
-
params: {
|
2480
|
-
locale: "*"
|
2790
|
+
if (action.type === "icon") {
|
2791
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
2792
|
+
/* @__PURE__ */ jsx(
|
2793
|
+
IconButton,
|
2794
|
+
{
|
2795
|
+
disabled: action.disabled,
|
2796
|
+
label: action.label,
|
2797
|
+
size: "S",
|
2798
|
+
onClick: handleClick(action),
|
2799
|
+
children: action.icon
|
2481
2800
|
}
|
2482
|
-
|
2483
|
-
|
2484
|
-
|
2485
|
-
|
2486
|
-
|
2487
|
-
|
2488
|
-
|
2489
|
-
|
2490
|
-
|
2801
|
+
),
|
2802
|
+
action.dialog ? /* @__PURE__ */ jsx(
|
2803
|
+
HeaderActionDialog,
|
2804
|
+
{
|
2805
|
+
...action.dialog,
|
2806
|
+
isOpen: dialogId === action.id,
|
2807
|
+
onClose: handleClose
|
2808
|
+
}
|
2809
|
+
) : null
|
2810
|
+
] }, action.id);
|
2491
2811
|
}
|
2492
|
-
},
|
2493
|
-
variant: "danger",
|
2494
|
-
position: ["header", "table-row"]
|
2495
|
-
};
|
2496
|
-
};
|
2497
|
-
DeleteAction$1.type = "delete";
|
2498
|
-
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2499
|
-
const Panels = () => {
|
2500
|
-
const isCloning = useMatch(CLONE_PATH) !== null;
|
2501
|
-
const [
|
2502
|
-
{
|
2503
|
-
query: { status }
|
2504
|
-
}
|
2505
|
-
] = useQueryParams({
|
2506
|
-
status: "draft"
|
2507
|
-
});
|
2508
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2509
|
-
const plugins = useStrapiApp("Panels", (state) => state.plugins);
|
2510
|
-
const props = {
|
2511
|
-
activeTab: status,
|
2512
|
-
model,
|
2513
|
-
documentId: id,
|
2514
|
-
document: isCloning ? void 0 : document,
|
2515
|
-
meta: isCloning ? void 0 : meta,
|
2516
|
-
collectionType
|
2517
|
-
};
|
2518
|
-
return /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsx(
|
2519
|
-
DescriptionComponentRenderer,
|
2520
|
-
{
|
2521
|
-
props,
|
2522
|
-
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
2523
|
-
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsx(Panel, { ...description, children: content }, id2))
|
2524
2812
|
}
|
2525
|
-
) });
|
2526
|
-
};
|
2527
|
-
const ActionsPanel = () => {
|
2528
|
-
const { formatMessage } = useIntl();
|
2529
|
-
return {
|
2530
|
-
title: formatMessage({
|
2531
|
-
id: "content-manager.containers.edit.panels.default.title",
|
2532
|
-
defaultMessage: "Document"
|
2533
|
-
}),
|
2534
|
-
content: /* @__PURE__ */ jsx(ActionsPanelContent, {})
|
2535
|
-
};
|
2536
|
-
};
|
2537
|
-
ActionsPanel.type = "actions";
|
2538
|
-
const ActionsPanelContent = () => {
|
2539
|
-
const isCloning = useMatch(CLONE_PATH) !== null;
|
2540
|
-
const [
|
2541
|
-
{
|
2542
|
-
query: { status = "draft" }
|
2543
|
-
}
|
2544
|
-
] = useQueryParams();
|
2545
|
-
const { model, id, document, meta, collectionType } = useDoc();
|
2546
|
-
const plugins = useStrapiApp("ActionsPanel", (state) => state.plugins);
|
2547
|
-
const props = {
|
2548
|
-
activeTab: status,
|
2549
|
-
model,
|
2550
|
-
documentId: id,
|
2551
|
-
document: isCloning ? void 0 : document,
|
2552
|
-
meta: isCloning ? void 0 : meta,
|
2553
|
-
collectionType
|
2554
|
-
};
|
2555
|
-
return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, width: "100%", children: [
|
2556
|
-
/* @__PURE__ */ jsx(
|
2557
|
-
DescriptionComponentRenderer,
|
2558
|
-
{
|
2559
|
-
props,
|
2560
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2561
|
-
children: (actions2) => /* @__PURE__ */ jsx(DocumentActions, { actions: actions2 })
|
2562
|
-
}
|
2563
|
-
),
|
2564
|
-
/* @__PURE__ */ jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
2565
|
-
] });
|
2813
|
+
}) });
|
2566
2814
|
};
|
2567
|
-
const
|
2568
|
-
|
2569
|
-
|
2570
|
-
|
2571
|
-
|
2572
|
-
|
2573
|
-
|
2574
|
-
|
2575
|
-
|
2576
|
-
|
2577
|
-
paddingBottom: 4,
|
2578
|
-
paddingLeft: 4,
|
2579
|
-
paddingRight: 4,
|
2580
|
-
paddingTop: 4,
|
2581
|
-
shadow: "tableShadow",
|
2582
|
-
gap: 3,
|
2583
|
-
direction: "column",
|
2584
|
-
justifyContent: "stretch",
|
2585
|
-
alignItems: "flex-start",
|
2586
|
-
children: [
|
2587
|
-
/* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
|
2588
|
-
children
|
2589
|
-
]
|
2815
|
+
const HeaderActionDialog = ({
|
2816
|
+
onClose,
|
2817
|
+
onCancel,
|
2818
|
+
title,
|
2819
|
+
content: Content,
|
2820
|
+
isOpen
|
2821
|
+
}) => {
|
2822
|
+
const handleClose = async () => {
|
2823
|
+
if (onCancel) {
|
2824
|
+
await onCancel();
|
2590
2825
|
}
|
2591
|
-
|
2592
|
-
}
|
2593
|
-
|
2594
|
-
|
2595
|
-
|
2596
|
-
|
2597
|
-
* @type {string}
|
2598
|
-
*/
|
2599
|
-
INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
|
2600
|
-
/**
|
2601
|
-
* Hook that allows to mutate the CM's collection types links pre-set filters
|
2602
|
-
* @constant
|
2603
|
-
* @type {string}
|
2604
|
-
*/
|
2605
|
-
MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
|
2606
|
-
/**
|
2607
|
-
* Hook that allows to mutate the CM's edit view layout
|
2608
|
-
* @constant
|
2609
|
-
* @type {string}
|
2610
|
-
*/
|
2611
|
-
MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
|
2612
|
-
/**
|
2613
|
-
* Hook that allows to mutate the CM's single types links pre-set filters
|
2614
|
-
* @constant
|
2615
|
-
* @type {string}
|
2616
|
-
*/
|
2617
|
-
MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
|
2826
|
+
onClose();
|
2827
|
+
};
|
2828
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
2829
|
+
/* @__PURE__ */ jsx(Dialog.Header, { children: title }),
|
2830
|
+
typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : Content
|
2831
|
+
] }) });
|
2618
2832
|
};
|
2619
|
-
const
|
2620
|
-
|
2621
|
-
|
2622
|
-
|
2623
|
-
|
2624
|
-
|
2625
|
-
|
2626
|
-
transformResponse: (response) => response.data,
|
2627
|
-
providesTags: (_result, _error, uid) => [
|
2628
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2629
|
-
{ type: "ContentTypeSettings", id: "LIST" }
|
2630
|
-
]
|
2631
|
-
}),
|
2632
|
-
getAllContentTypeSettings: builder.query({
|
2633
|
-
query: () => "/content-manager/content-types-settings",
|
2634
|
-
transformResponse: (response) => response.data,
|
2635
|
-
providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
|
2833
|
+
const ConfigureTheViewAction = ({ collectionType, model }) => {
|
2834
|
+
const navigate = useNavigate();
|
2835
|
+
const { formatMessage } = useIntl();
|
2836
|
+
return {
|
2837
|
+
label: formatMessage({
|
2838
|
+
id: "app.links.configure-view",
|
2839
|
+
defaultMessage: "Configure the view"
|
2636
2840
|
}),
|
2637
|
-
|
2638
|
-
|
2639
|
-
|
2640
|
-
|
2641
|
-
|
2642
|
-
|
2643
|
-
transformResponse: (response) => response.data,
|
2644
|
-
invalidatesTags: (_result, _error, { uid }) => [
|
2645
|
-
{ type: "ContentTypesConfiguration", id: uid },
|
2646
|
-
{ type: "ContentTypeSettings", id: "LIST" },
|
2647
|
-
// Is this necessary?
|
2648
|
-
{ type: "InitialData" }
|
2649
|
-
]
|
2650
|
-
})
|
2651
|
-
})
|
2652
|
-
});
|
2653
|
-
const {
|
2654
|
-
useGetContentTypeConfigurationQuery,
|
2655
|
-
useGetAllContentTypeSettingsQuery,
|
2656
|
-
useUpdateContentTypeConfigurationMutation
|
2657
|
-
} = contentTypesApi;
|
2658
|
-
const checkIfAttributeIsDisplayable = (attribute) => {
|
2659
|
-
const { type } = attribute;
|
2660
|
-
if (type === "relation") {
|
2661
|
-
return !attribute.relation.toLowerCase().includes("morph");
|
2662
|
-
}
|
2663
|
-
return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
|
2841
|
+
icon: /* @__PURE__ */ jsx(ListPlus, {}),
|
2842
|
+
onClick: () => {
|
2843
|
+
navigate(`../${collectionType}/${model}/configurations/edit`);
|
2844
|
+
},
|
2845
|
+
position: "header"
|
2846
|
+
};
|
2664
2847
|
};
|
2665
|
-
|
2666
|
-
|
2667
|
-
|
2668
|
-
}
|
2669
|
-
const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
|
2670
|
-
// @ts-expect-error – `targetModel` does exist on the attribute for a relation.
|
2671
|
-
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2672
|
-
);
|
2848
|
+
ConfigureTheViewAction.type = "configure-the-view";
|
2849
|
+
const EditTheModelAction = ({ model }) => {
|
2850
|
+
const navigate = useNavigate();
|
2851
|
+
const { formatMessage } = useIntl();
|
2673
2852
|
return {
|
2674
|
-
|
2675
|
-
|
2853
|
+
label: formatMessage({
|
2854
|
+
id: "content-manager.link-to-ctb",
|
2855
|
+
defaultMessage: "Edit the model"
|
2856
|
+
}),
|
2857
|
+
icon: /* @__PURE__ */ jsx(Pencil, {}),
|
2858
|
+
onClick: () => {
|
2859
|
+
navigate(`/plugins/content-type-builder/content-types/${model}`);
|
2860
|
+
},
|
2861
|
+
position: "header"
|
2676
2862
|
};
|
2677
2863
|
};
|
2678
|
-
|
2679
|
-
|
2680
|
-
|
2681
|
-
|
2682
|
-
|
2683
|
-
|
2684
|
-
|
2685
|
-
mainField: "id",
|
2686
|
-
pageSize: 10
|
2687
|
-
};
|
2688
|
-
const useDocumentLayout = (model) => {
|
2689
|
-
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
2690
|
-
const [{ query }] = useQueryParams();
|
2691
|
-
const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
2864
|
+
EditTheModelAction.type = "edit-the-model";
|
2865
|
+
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2866
|
+
const navigate = useNavigate();
|
2867
|
+
const { formatMessage } = useIntl();
|
2868
|
+
const listViewPathMatch = useMatch(LIST_PATH);
|
2869
|
+
const canDelete = useDocumentRBAC("DeleteAction", (state) => state.canDelete);
|
2870
|
+
const { delete: deleteAction } = useDocumentActions();
|
2692
2871
|
const { toggleNotification } = useNotification();
|
2693
|
-
const
|
2694
|
-
const
|
2695
|
-
const {
|
2696
|
-
data,
|
2697
|
-
isLoading: isLoadingConfigs,
|
2698
|
-
error,
|
2699
|
-
isFetching: isFetchingConfigs
|
2700
|
-
} = useGetContentTypeConfigurationQuery(model);
|
2701
|
-
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
2702
|
-
React.useEffect(() => {
|
2703
|
-
if (error) {
|
2704
|
-
toggleNotification({
|
2705
|
-
type: "danger",
|
2706
|
-
message: formatAPIError(error)
|
2707
|
-
});
|
2708
|
-
}
|
2709
|
-
}, [error, formatAPIError, toggleNotification]);
|
2710
|
-
const editLayout = React.useMemo(
|
2711
|
-
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
2712
|
-
layout: [],
|
2713
|
-
components: {},
|
2714
|
-
metadatas: {},
|
2715
|
-
options: {},
|
2716
|
-
settings: DEFAULT_SETTINGS
|
2717
|
-
},
|
2718
|
-
[data, isLoading, schemas, schema, components]
|
2719
|
-
);
|
2720
|
-
const listLayout = React.useMemo(() => {
|
2721
|
-
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
2722
|
-
layout: [],
|
2723
|
-
metadatas: {},
|
2724
|
-
options: {},
|
2725
|
-
settings: DEFAULT_SETTINGS
|
2726
|
-
};
|
2727
|
-
}, [data, isLoading, schemas, schema, components]);
|
2728
|
-
const { layout: edit } = React.useMemo(
|
2729
|
-
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
2730
|
-
layout: editLayout,
|
2731
|
-
query
|
2732
|
-
}),
|
2733
|
-
[editLayout, query, runHookWaterfall]
|
2734
|
-
);
|
2872
|
+
const setSubmitting = useForm("DeleteAction", (state) => state.setSubmitting);
|
2873
|
+
const isLocalized = document?.locale != null;
|
2735
2874
|
return {
|
2736
|
-
|
2737
|
-
|
2738
|
-
|
2739
|
-
|
2740
|
-
|
2741
|
-
}
|
2742
|
-
|
2743
|
-
|
2744
|
-
|
2745
|
-
|
2746
|
-
|
2747
|
-
|
2748
|
-
|
2749
|
-
|
2750
|
-
})
|
2751
|
-
|
2752
|
-
|
2753
|
-
|
2754
|
-
|
2755
|
-
|
2756
|
-
|
2757
|
-
|
2758
|
-
|
2759
|
-
|
2760
|
-
|
2761
|
-
|
2762
|
-
|
2763
|
-
|
2764
|
-
|
2765
|
-
|
2766
|
-
|
2767
|
-
|
2768
|
-
|
2769
|
-
|
2770
|
-
|
2771
|
-
|
2772
|
-
|
2773
|
-
|
2774
|
-
|
2775
|
-
|
2776
|
-
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2875
|
+
disabled: !canDelete || !document,
|
2876
|
+
label: formatMessage(
|
2877
|
+
{
|
2878
|
+
id: "content-manager.actions.delete.label",
|
2879
|
+
defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
|
2880
|
+
},
|
2881
|
+
{ isLocalized }
|
2882
|
+
),
|
2883
|
+
icon: /* @__PURE__ */ jsx(Trash, {}),
|
2884
|
+
dialog: {
|
2885
|
+
type: "dialog",
|
2886
|
+
title: formatMessage({
|
2887
|
+
id: "app.components.ConfirmDialog.title",
|
2888
|
+
defaultMessage: "Confirmation"
|
2889
|
+
}),
|
2890
|
+
content: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
|
2891
|
+
/* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
2892
|
+
/* @__PURE__ */ jsx(Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
2893
|
+
id: "content-manager.actions.delete.dialog.body",
|
2894
|
+
defaultMessage: "Are you sure?"
|
2895
|
+
}) })
|
2896
|
+
] }),
|
2897
|
+
onConfirm: async () => {
|
2898
|
+
if (!listViewPathMatch) {
|
2899
|
+
setSubmitting(true);
|
2900
|
+
}
|
2901
|
+
try {
|
2902
|
+
if (!documentId && collectionType !== SINGLE_TYPES) {
|
2903
|
+
console.error(
|
2904
|
+
"You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue."
|
2905
|
+
);
|
2906
|
+
toggleNotification({
|
2907
|
+
message: formatMessage({
|
2908
|
+
id: "content-manager.actions.delete.error",
|
2909
|
+
defaultMessage: "An error occurred while trying to delete the document."
|
2910
|
+
}),
|
2911
|
+
type: "danger"
|
2912
|
+
});
|
2913
|
+
return;
|
2914
|
+
}
|
2915
|
+
const res = await deleteAction({
|
2916
|
+
documentId,
|
2917
|
+
model,
|
2918
|
+
collectionType,
|
2919
|
+
params: {
|
2920
|
+
locale: "*"
|
2921
|
+
}
|
2922
|
+
});
|
2923
|
+
if (!("error" in res)) {
|
2924
|
+
navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
|
2925
|
+
}
|
2926
|
+
} finally {
|
2927
|
+
if (!listViewPathMatch) {
|
2928
|
+
setSubmitting(false);
|
2929
|
+
}
|
2782
2930
|
}
|
2783
|
-
}
|
2784
|
-
return acc;
|
2785
|
-
},
|
2786
|
-
{}
|
2787
|
-
);
|
2788
|
-
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2789
|
-
(acc, [attribute, metadata]) => {
|
2790
|
-
return {
|
2791
|
-
...acc,
|
2792
|
-
[attribute]: metadata.edit
|
2793
|
-
};
|
2794
|
-
},
|
2795
|
-
{}
|
2796
|
-
);
|
2797
|
-
return {
|
2798
|
-
layout: panelledEditAttributes,
|
2799
|
-
components: componentEditAttributes,
|
2800
|
-
metadatas: editMetadatas,
|
2801
|
-
settings: {
|
2802
|
-
...data.contentType.settings,
|
2803
|
-
displayName: schema?.info.displayName
|
2931
|
+
}
|
2804
2932
|
},
|
2805
|
-
|
2806
|
-
|
2807
|
-
...schema?.pluginOptions,
|
2808
|
-
...data.contentType.options
|
2809
|
-
}
|
2933
|
+
variant: "danger",
|
2934
|
+
position: ["header", "table-row"]
|
2810
2935
|
};
|
2811
2936
|
};
|
2812
|
-
|
2813
|
-
|
2814
|
-
|
2815
|
-
|
2816
|
-
|
2817
|
-
|
2818
|
-
}
|
2819
|
-
|
2820
|
-
|
2821
|
-
|
2822
|
-
|
2823
|
-
|
2824
|
-
|
2825
|
-
|
2826
|
-
|
2827
|
-
|
2828
|
-
|
2829
|
-
|
2830
|
-
|
2831
|
-
|
2832
|
-
|
2833
|
-
|
2834
|
-
|
2835
|
-
|
2836
|
-
|
2837
|
-
|
2838
|
-
}
|
2839
|
-
}
|
2840
|
-
);
|
2937
|
+
DeleteAction$1.type = "delete";
|
2938
|
+
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2939
|
+
const Panels = () => {
|
2940
|
+
const isCloning = useMatch(CLONE_PATH) !== null;
|
2941
|
+
const [
|
2942
|
+
{
|
2943
|
+
query: { status }
|
2944
|
+
}
|
2945
|
+
] = useQueryParams({
|
2946
|
+
status: "draft"
|
2947
|
+
});
|
2948
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
2949
|
+
const plugins = useStrapiApp("Panels", (state) => state.plugins);
|
2950
|
+
const props = {
|
2951
|
+
activeTab: status,
|
2952
|
+
model,
|
2953
|
+
documentId: id,
|
2954
|
+
document: isCloning ? void 0 : document,
|
2955
|
+
meta: isCloning ? void 0 : meta,
|
2956
|
+
collectionType
|
2957
|
+
};
|
2958
|
+
return /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsx(
|
2959
|
+
DescriptionComponentRenderer,
|
2960
|
+
{
|
2961
|
+
props,
|
2962
|
+
descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
|
2963
|
+
children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsx(Panel, { ...description, children: content }, id2))
|
2964
|
+
}
|
2965
|
+
) });
|
2841
2966
|
};
|
2842
|
-
const
|
2843
|
-
|
2844
|
-
schema,
|
2845
|
-
components
|
2846
|
-
}) => {
|
2847
|
-
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2848
|
-
(acc, [attribute, metadata]) => {
|
2849
|
-
return {
|
2850
|
-
...acc,
|
2851
|
-
[attribute]: metadata.list
|
2852
|
-
};
|
2853
|
-
},
|
2854
|
-
{}
|
2855
|
-
);
|
2856
|
-
const listAttributes = convertListLayoutToFieldLayouts(
|
2857
|
-
data.contentType.layouts.list,
|
2858
|
-
schema?.attributes,
|
2859
|
-
listMetadatas,
|
2860
|
-
{ configurations: data.components, schemas: components },
|
2861
|
-
schemas
|
2862
|
-
);
|
2967
|
+
const ActionsPanel = () => {
|
2968
|
+
const { formatMessage } = useIntl();
|
2863
2969
|
return {
|
2864
|
-
|
2865
|
-
|
2866
|
-
|
2867
|
-
|
2868
|
-
|
2869
|
-
...schema?.pluginOptions,
|
2870
|
-
...data.contentType.options
|
2871
|
-
}
|
2970
|
+
title: formatMessage({
|
2971
|
+
id: "content-manager.containers.edit.panels.default.title",
|
2972
|
+
defaultMessage: "Entry"
|
2973
|
+
}),
|
2974
|
+
content: /* @__PURE__ */ jsx(ActionsPanelContent, {})
|
2872
2975
|
};
|
2873
2976
|
};
|
2874
|
-
|
2875
|
-
|
2876
|
-
|
2877
|
-
|
2878
|
-
|
2977
|
+
ActionsPanel.type = "actions";
|
2978
|
+
const ActionsPanelContent = () => {
|
2979
|
+
const isCloning = useMatch(CLONE_PATH) !== null;
|
2980
|
+
const [
|
2981
|
+
{
|
2982
|
+
query: { status = "draft" }
|
2879
2983
|
}
|
2880
|
-
|
2881
|
-
|
2882
|
-
|
2883
|
-
|
2884
|
-
|
2885
|
-
|
2886
|
-
|
2887
|
-
|
2888
|
-
|
2889
|
-
|
2890
|
-
|
2891
|
-
|
2892
|
-
|
2893
|
-
|
2984
|
+
] = useQueryParams();
|
2985
|
+
const { model, id, document, meta, collectionType } = useDoc();
|
2986
|
+
const plugins = useStrapiApp("ActionsPanel", (state) => state.plugins);
|
2987
|
+
const props = {
|
2988
|
+
activeTab: status,
|
2989
|
+
model,
|
2990
|
+
documentId: id,
|
2991
|
+
document: isCloning ? void 0 : document,
|
2992
|
+
meta: isCloning ? void 0 : meta,
|
2993
|
+
collectionType
|
2994
|
+
};
|
2995
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, width: "100%", children: [
|
2996
|
+
/* @__PURE__ */ jsx(
|
2997
|
+
DescriptionComponentRenderer,
|
2998
|
+
{
|
2999
|
+
props,
|
3000
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3001
|
+
children: (actions2) => /* @__PURE__ */ jsx(DocumentActions, { actions: actions2 })
|
3002
|
+
}
|
3003
|
+
),
|
3004
|
+
/* @__PURE__ */ jsx(InjectionZone, { area: "editView.right-links", slug: model })
|
3005
|
+
] });
|
2894
3006
|
};
|
3007
|
+
const Panel = React.forwardRef(({ children, title }, ref) => {
|
3008
|
+
return /* @__PURE__ */ jsxs(
|
3009
|
+
Flex,
|
3010
|
+
{
|
3011
|
+
ref,
|
3012
|
+
tag: "aside",
|
3013
|
+
"aria-labelledby": "additional-information",
|
3014
|
+
background: "neutral0",
|
3015
|
+
borderColor: "neutral150",
|
3016
|
+
hasRadius: true,
|
3017
|
+
paddingBottom: 4,
|
3018
|
+
paddingLeft: 4,
|
3019
|
+
paddingRight: 4,
|
3020
|
+
paddingTop: 4,
|
3021
|
+
shadow: "tableShadow",
|
3022
|
+
gap: 3,
|
3023
|
+
direction: "column",
|
3024
|
+
justifyContent: "stretch",
|
3025
|
+
alignItems: "flex-start",
|
3026
|
+
children: [
|
3027
|
+
/* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
|
3028
|
+
children
|
3029
|
+
]
|
3030
|
+
}
|
3031
|
+
);
|
3032
|
+
});
|
2895
3033
|
const ConfirmBulkActionDialog = ({
|
2896
3034
|
onToggleDialog,
|
2897
3035
|
isOpen = false,
|
@@ -2930,6 +3068,7 @@ const ConfirmDialogPublishAll = ({
|
|
2930
3068
|
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler(getTranslation);
|
2931
3069
|
const { model, schema } = useDoc();
|
2932
3070
|
const [{ query }] = useQueryParams();
|
3071
|
+
const enableDraftRelationsCount = false;
|
2933
3072
|
const {
|
2934
3073
|
data: countDraftRelations = 0,
|
2935
3074
|
isLoading,
|
@@ -2941,7 +3080,7 @@ const ConfirmDialogPublishAll = ({
|
|
2941
3080
|
locale: query?.plugins?.i18n?.locale
|
2942
3081
|
},
|
2943
3082
|
{
|
2944
|
-
skip:
|
3083
|
+
skip: !enableDraftRelationsCount
|
2945
3084
|
}
|
2946
3085
|
);
|
2947
3086
|
React.useEffect(() => {
|
@@ -3126,7 +3265,7 @@ const SelectedEntriesTableContent = ({
|
|
3126
3265
|
status: row.status
|
3127
3266
|
}
|
3128
3267
|
) }),
|
3129
|
-
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(
|
3268
|
+
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(
|
3130
3269
|
IconButton,
|
3131
3270
|
{
|
3132
3271
|
tag: Link,
|
@@ -3135,23 +3274,16 @@ const SelectedEntriesTableContent = ({
|
|
3135
3274
|
search: row.locale && `?plugins[i18n][locale]=${row.locale}`
|
3136
3275
|
},
|
3137
3276
|
state: { from: pathname },
|
3138
|
-
label: formatMessage(
|
3139
|
-
|
3140
|
-
|
3141
|
-
|
3142
|
-
{
|
3143
|
-
id: "content-manager.components.ListViewHelperPluginTable.row-line",
|
3144
|
-
defaultMessage: "item line {number}"
|
3145
|
-
},
|
3146
|
-
{ number: index2 + 1 }
|
3147
|
-
)
|
3148
|
-
}
|
3149
|
-
),
|
3277
|
+
label: formatMessage({
|
3278
|
+
id: "content-manager.bulk-publish.edit",
|
3279
|
+
defaultMessage: "Edit"
|
3280
|
+
}),
|
3150
3281
|
target: "_blank",
|
3151
3282
|
marginLeft: "auto",
|
3152
|
-
|
3283
|
+
variant: "ghost",
|
3284
|
+
children: /* @__PURE__ */ jsx(Pencil, { width: "1.6rem", height: "1.6rem" })
|
3153
3285
|
}
|
3154
|
-
) })
|
3286
|
+
) }) })
|
3155
3287
|
] }, row.id)) })
|
3156
3288
|
] });
|
3157
3289
|
};
|
@@ -3188,7 +3320,13 @@ const SelectedEntriesModalContent = ({
|
|
3188
3320
|
);
|
3189
3321
|
const { rows, validationErrors } = React.useMemo(() => {
|
3190
3322
|
if (data.length > 0 && schema) {
|
3191
|
-
const validate = createYupSchema(
|
3323
|
+
const validate = createYupSchema(
|
3324
|
+
schema.attributes,
|
3325
|
+
components,
|
3326
|
+
// Since this is the "Publish" action, the validation
|
3327
|
+
// schema must enforce the rules for published entities
|
3328
|
+
{ status: "published" }
|
3329
|
+
);
|
3192
3330
|
const validationErrors2 = {};
|
3193
3331
|
const rows2 = data.map((entry) => {
|
3194
3332
|
try {
|
@@ -3538,7 +3676,7 @@ const TableActions = ({ document }) => {
|
|
3538
3676
|
DescriptionComponentRenderer,
|
3539
3677
|
{
|
3540
3678
|
props,
|
3541
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3679
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
|
3542
3680
|
children: (actions2) => {
|
3543
3681
|
const tableRowActions = actions2.filter((action) => {
|
3544
3682
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -3649,7 +3787,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3649
3787
|
}),
|
3650
3788
|
content: /* @__PURE__ */ jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
3651
3789
|
footer: ({ onClose }) => {
|
3652
|
-
return /* @__PURE__ */ jsxs(
|
3790
|
+
return /* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
3653
3791
|
/* @__PURE__ */ jsx(Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
3654
3792
|
id: "cancel",
|
3655
3793
|
defaultMessage: "Cancel"
|
@@ -3861,6 +3999,70 @@ const { setInitialData } = actions;
|
|
3861
3999
|
const reducer = combineReducers({
|
3862
4000
|
app: reducer$1
|
3863
4001
|
});
|
4002
|
+
const previewApi = contentManagerApi.injectEndpoints({
|
4003
|
+
endpoints: (builder) => ({
|
4004
|
+
getPreviewUrl: builder.query({
|
4005
|
+
query({ query, params }) {
|
4006
|
+
return {
|
4007
|
+
url: `/content-manager/preview/url/${params.contentType}`,
|
4008
|
+
method: "GET",
|
4009
|
+
config: {
|
4010
|
+
params: query
|
4011
|
+
}
|
4012
|
+
};
|
4013
|
+
}
|
4014
|
+
})
|
4015
|
+
})
|
4016
|
+
});
|
4017
|
+
const { useGetPreviewUrlQuery } = previewApi;
|
4018
|
+
const PreviewSidePanel = ({ model, documentId, document }) => {
|
4019
|
+
const { formatMessage } = useIntl();
|
4020
|
+
const { trackUsage } = useTracking();
|
4021
|
+
const [{ query }] = useQueryParams();
|
4022
|
+
const { data, error } = useGetPreviewUrlQuery({
|
4023
|
+
params: {
|
4024
|
+
contentType: model
|
4025
|
+
},
|
4026
|
+
query: {
|
4027
|
+
documentId,
|
4028
|
+
locale: document?.locale,
|
4029
|
+
status: document?.status
|
4030
|
+
}
|
4031
|
+
});
|
4032
|
+
if (!data?.data?.url || error) {
|
4033
|
+
return null;
|
4034
|
+
}
|
4035
|
+
const handleClick = () => {
|
4036
|
+
trackUsage("willOpenPreview");
|
4037
|
+
};
|
4038
|
+
return {
|
4039
|
+
title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
|
4040
|
+
content: /* @__PURE__ */ jsx(Flex, { gap: 2, width: "100%", children: /* @__PURE__ */ jsx(
|
4041
|
+
Button,
|
4042
|
+
{
|
4043
|
+
variant: "tertiary",
|
4044
|
+
tag: Link,
|
4045
|
+
to: { pathname: "preview", search: stringify(query, { encode: false }) },
|
4046
|
+
onClick: handleClick,
|
4047
|
+
flex: "auto",
|
4048
|
+
children: formatMessage({
|
4049
|
+
id: "content-manager.preview.panel.button",
|
4050
|
+
defaultMessage: "Open preview"
|
4051
|
+
})
|
4052
|
+
}
|
4053
|
+
) })
|
4054
|
+
};
|
4055
|
+
};
|
4056
|
+
const FEATURE_ID = "preview";
|
4057
|
+
const previewAdmin = {
|
4058
|
+
bootstrap(app) {
|
4059
|
+
if (!window.strapi.future.isEnabled(FEATURE_ID)) {
|
4060
|
+
return;
|
4061
|
+
}
|
4062
|
+
const contentManagerPluginApis = app.getPlugin("content-manager").apis;
|
4063
|
+
contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
|
4064
|
+
}
|
4065
|
+
};
|
3864
4066
|
const index = {
|
3865
4067
|
register(app) {
|
3866
4068
|
const cm = new ContentManagerPlugin();
|
@@ -3880,7 +4082,7 @@ const index = {
|
|
3880
4082
|
app.router.addRoute({
|
3881
4083
|
path: "content-manager/*",
|
3882
4084
|
lazy: async () => {
|
3883
|
-
const { Layout } = await import("./layout-
|
4085
|
+
const { Layout } = await import("./layout-B3LdnMTA.mjs");
|
3884
4086
|
return {
|
3885
4087
|
Component: Layout
|
3886
4088
|
};
|
@@ -3893,11 +4095,14 @@ const index = {
|
|
3893
4095
|
if (typeof historyAdmin.bootstrap === "function") {
|
3894
4096
|
historyAdmin.bootstrap(app);
|
3895
4097
|
}
|
4098
|
+
if (typeof previewAdmin.bootstrap === "function") {
|
4099
|
+
previewAdmin.bootstrap(app);
|
4100
|
+
}
|
3896
4101
|
},
|
3897
4102
|
async registerTrads({ locales }) {
|
3898
4103
|
const importedTrads = await Promise.all(
|
3899
4104
|
locales.map((locale) => {
|
3900
|
-
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-
|
4105
|
+
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-CfIXaZf9.mjs"), "./translations/es.json": () => import("./es-D34tqjMw.mjs"), "./translations/eu.json": () => import("./eu-CdALomew.mjs"), "./translations/fr.json": () => import("./fr--pg5jUbt.mjs"), "./translations/gu.json": () => import("./gu-CNpaMDpH.mjs"), "./translations/hi.json": () => import("./hi-Dwvd04m3.mjs"), "./translations/hu.json": () => import("./hu-CeYvaaO0.mjs"), "./translations/id.json": () => import("./id-BtwA9WJT.mjs"), "./translations/it.json": () => import("./it-BrVPqaf1.mjs"), "./translations/ja.json": () => import("./ja-BHqhDq4V.mjs"), "./translations/ko.json": () => import("./ko-HVQRlfUI.mjs"), "./translations/ml.json": () => import("./ml-BihZwQit.mjs"), "./translations/ms.json": () => import("./ms-m_WjyWx7.mjs"), "./translations/nl.json": () => import("./nl-D4R9gHx5.mjs"), "./translations/pl.json": () => import("./pl-sbx9mSt_.mjs"), "./translations/pt-BR.json": () => import("./pt-BR-C71iDxnh.mjs"), "./translations/pt.json": () => import("./pt-BsaFvS8-.mjs"), "./translations/ru.json": () => import("./ru-BE6A4Exp.mjs"), "./translations/sa.json": () => import("./sa-Dag0k-Z8.mjs"), "./translations/sk.json": () => import("./sk-BFg-R8qJ.mjs"), "./translations/sv.json": () => import("./sv-CUnfWGsh.mjs"), "./translations/th.json": () => import("./th-BqbI8lIT.mjs"), "./translations/tr.json": () => import("./tr-CgeK3wJM.mjs"), "./translations/uk.json": () => import("./uk-CR-zDhAY.mjs"), "./translations/vi.json": () => import("./vi-DUXIk_fw.mjs"), "./translations/zh-Hans.json": () => import("./zh-Hans-BPQcRIyH.mjs"), "./translations/zh.json": () => import("./zh-BWZspA60.mjs") }), `./translations/${locale}.json`).then(({ default: data }) => {
|
3901
4106
|
return {
|
3902
4107
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3903
4108
|
locale
|
@@ -3918,13 +4123,16 @@ export {
|
|
3918
4123
|
BulkActionsRenderer as B,
|
3919
4124
|
COLLECTION_TYPES as C,
|
3920
4125
|
DocumentStatus as D,
|
3921
|
-
|
3922
|
-
|
3923
|
-
|
4126
|
+
extractContentTypeComponents as E,
|
4127
|
+
DEFAULT_SETTINGS as F,
|
4128
|
+
convertEditLayoutToFieldLayouts as G,
|
3924
4129
|
HOOKS as H,
|
3925
4130
|
InjectionZone as I,
|
3926
|
-
|
3927
|
-
|
4131
|
+
useDocument as J,
|
4132
|
+
useGetPreviewUrlQuery as K,
|
4133
|
+
index as L,
|
4134
|
+
useContentManagerContext as M,
|
4135
|
+
useDocumentActions as N,
|
3928
4136
|
Panels as P,
|
3929
4137
|
RelativeTime as R,
|
3930
4138
|
SINGLE_TYPES as S,
|
@@ -3942,18 +4150,18 @@ export {
|
|
3942
4150
|
PERMISSIONS as k,
|
3943
4151
|
DocumentRBAC as l,
|
3944
4152
|
DOCUMENT_META_FIELDS as m,
|
3945
|
-
|
3946
|
-
|
3947
|
-
|
3948
|
-
|
3949
|
-
|
4153
|
+
CLONE_PATH as n,
|
4154
|
+
useDocLayout as o,
|
4155
|
+
useGetContentTypeConfigurationQuery as p,
|
4156
|
+
CREATOR_FIELDS as q,
|
4157
|
+
getMainField as r,
|
3950
4158
|
setInitialData as s,
|
3951
|
-
|
4159
|
+
getDisplayName as t,
|
3952
4160
|
useContentTypeSchema as u,
|
3953
|
-
|
3954
|
-
|
3955
|
-
|
3956
|
-
|
3957
|
-
|
4161
|
+
checkIfAttributeIsDisplayable as v,
|
4162
|
+
useGetAllDocumentsQuery as w,
|
4163
|
+
convertListLayoutToFieldLayouts as x,
|
4164
|
+
capitalise as y,
|
4165
|
+
useUpdateContentTypeConfigurationMutation as z
|
3958
4166
|
};
|
3959
|
-
//# sourceMappingURL=index-
|
4167
|
+
//# sourceMappingURL=index-CP5EOEiH.mjs.map
|