@strapi/content-manager 0.0.0-experimental.f49f46a1c17445a39e8af3f63124bcccf73842e6 → 0.0.0-experimental.f6f58027a6338ed795382f2d1c8882158b242361
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/CardDragPreview-C0QyJgRA.js.map +1 -1
- package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-D3ZWDAHG.mjs → ComponentConfigurationPage-D4H-v0et.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-D3ZWDAHG.mjs.map → ComponentConfigurationPage-D4H-v0et.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-ClKl_TA2.js → ComponentConfigurationPage-DdkVGfXC.js} +4 -5
- package/dist/_chunks/{ComponentConfigurationPage-ClKl_TA2.js.map → ComponentConfigurationPage-DdkVGfXC.js.map} +1 -1
- package/dist/_chunks/{ComponentIcon-BXdiCGQp.js → ComponentIcon-CRbtQEUV.js} +2 -3
- package/dist/_chunks/{ComponentIcon-BXdiCGQp.js.map → ComponentIcon-CRbtQEUV.js.map} +1 -1
- package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -1
- package/dist/_chunks/{EditConfigurationPage-BYCBSJxP.mjs → EditConfigurationPage-D1nvB7Br.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-BYCBSJxP.mjs.map → EditConfigurationPage-D1nvB7Br.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-OWez0Kxp.js → EditConfigurationPage-LYEvR4fW.js} +4 -5
- package/dist/_chunks/{EditConfigurationPage-OWez0Kxp.js.map → EditConfigurationPage-LYEvR4fW.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-5pdbvsO_.mjs → EditViewPage-Bcnff6Vd.mjs} +11 -74
- package/dist/_chunks/EditViewPage-Bcnff6Vd.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-BEs5iGDi.js → EditViewPage-DqelJ9UK.js} +14 -78
- package/dist/_chunks/EditViewPage-DqelJ9UK.js.map +1 -0
- package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
- package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
- package/dist/_chunks/{Form-CoRxWJOz.js → Form-CnHfBeiB.js} +5 -6
- package/dist/_chunks/{Form-CoRxWJOz.js.map → Form-CnHfBeiB.js.map} +1 -1
- package/dist/_chunks/{Form-CGwM_-5c.mjs → Form-CzPCJi3B.mjs} +3 -3
- package/dist/_chunks/{Form-CGwM_-5c.mjs.map → Form-CzPCJi3B.mjs.map} +1 -1
- package/dist/_chunks/{History-DEvr3Q_V.mjs → History-CcmSn3Mj.mjs} +33 -9
- package/dist/_chunks/History-CcmSn3Mj.mjs.map +1 -0
- package/dist/_chunks/{History-BcUTQrfG.js → History-zArjENzj.js} +45 -22
- package/dist/_chunks/History-zArjENzj.js.map +1 -0
- package/dist/_chunks/{Field-DNHm4wHx.js → Input-CDHKQd7o.js} +1321 -1317
- package/dist/_chunks/Input-CDHKQd7o.js.map +1 -0
- package/dist/_chunks/{Field-DcKuFHYK.mjs → Input-aV8SSoTa.mjs} +1235 -1231
- package/dist/_chunks/Input-aV8SSoTa.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-BM4zZZcM.mjs → ListConfigurationPage-BPvzENJJ.mjs} +3 -3
- package/dist/_chunks/{ListConfigurationPage-BM4zZZcM.mjs.map → ListConfigurationPage-BPvzENJJ.mjs.map} +1 -1
- package/dist/_chunks/{ListConfigurationPage-BE_Ho7tV.js → ListConfigurationPage-ByZAO_9H.js} +4 -5
- package/dist/_chunks/{ListConfigurationPage-BE_Ho7tV.js.map → ListConfigurationPage-ByZAO_9H.js.map} +1 -1
- package/dist/_chunks/{ListViewPage-BkT8Eao0.js → ListViewPage-BVKBeQAA.js} +61 -58
- package/dist/_chunks/ListViewPage-BVKBeQAA.js.map +1 -0
- package/dist/_chunks/{ListViewPage-BK2mkrql.mjs → ListViewPage-HljQVnFH.mjs} +55 -51
- package/dist/_chunks/ListViewPage-HljQVnFH.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-C8mtyc4H.js → NoContentTypePage-BV5zfDxr.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-C8mtyc4H.js.map → NoContentTypePage-BV5zfDxr.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-BvcAutu9.mjs → NoContentTypePage-BfHaSM-K.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-BvcAutu9.mjs.map → NoContentTypePage-BfHaSM-K.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-BmbRz7PR.mjs → NoPermissionsPage-D6ze2nQL.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-BmbRz7PR.mjs.map → NoPermissionsPage-D6ze2nQL.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-B5Y9Y78B.js → NoPermissionsPage-vdNpc6jb.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-B5Y9Y78B.js.map → NoPermissionsPage-vdNpc6jb.js.map} +1 -1
- package/dist/_chunks/{Preview-BF8ZDYqS.js → Preview-DEHdENT1.js} +35 -16
- package/dist/_chunks/Preview-DEHdENT1.js.map +1 -0
- package/dist/_chunks/{Preview-DcexhKJE.mjs → Preview-vfWOtPG5.mjs} +36 -16
- package/dist/_chunks/Preview-vfWOtPG5.mjs.map +1 -0
- package/dist/_chunks/{Relations-BjIzc4EK.mjs → Relations-B7_hbF0w.mjs} +9 -10
- package/dist/_chunks/Relations-B7_hbF0w.mjs.map +1 -0
- package/dist/_chunks/{Relations-BKnoK1R0.js → Relations-DcoOBejP.js} +10 -12
- package/dist/_chunks/Relations-DcoOBejP.js.map +1 -0
- package/dist/_chunks/{en-DTWPCdTS.js → en-BR48D_RH.js} +11 -3
- package/dist/_chunks/{en-DTWPCdTS.js.map → en-BR48D_RH.js.map} +1 -1
- package/dist/_chunks/{en-CfIXaZf9.mjs → en-D65uIF6Y.mjs} +11 -3
- package/dist/_chunks/{en-CfIXaZf9.mjs.map → en-D65uIF6Y.mjs.map} +1 -1
- package/dist/_chunks/{fr-B2Kyv8Z9.js → fr-C43IbhA_.js} +4 -1
- package/dist/_chunks/{fr-B2Kyv8Z9.js.map → fr-C43IbhA_.js.map} +1 -1
- package/dist/_chunks/{fr--pg5jUbt.mjs → fr-DBseuRuB.mjs} +4 -1
- package/dist/_chunks/{fr--pg5jUbt.mjs.map → fr-DBseuRuB.mjs.map} +1 -1
- package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
- package/dist/_chunks/{index-DOzAG2cq.js → index-CxLSGwnk.js} +482 -188
- package/dist/_chunks/index-CxLSGwnk.js.map +1 -0
- package/dist/_chunks/{index-BW-rXkjn.mjs → index-EH8ZtHd5.mjs} +500 -205
- package/dist/_chunks/index-EH8ZtHd5.mjs.map +1 -0
- package/dist/_chunks/{layout-DFVbgjp2.mjs → layout-CxDMdJ13.mjs} +4 -4
- package/dist/_chunks/{layout-DFVbgjp2.mjs.map → layout-CxDMdJ13.mjs.map} +1 -1
- package/dist/_chunks/{layout-RC3W2obV.js → layout-DSeUTfMv.js} +5 -6
- package/dist/_chunks/{layout-RC3W2obV.js.map → layout-DSeUTfMv.js.map} +1 -1
- package/dist/_chunks/objects-BcXOv6_9.js.map +1 -1
- package/dist/_chunks/objects-D6yBsdmx.mjs.map +1 -1
- package/dist/_chunks/{relations-Dogh8HWI.mjs → relations-B8_Uu38Q.mjs} +17 -3
- package/dist/_chunks/relations-B8_Uu38Q.mjs.map +1 -0
- package/dist/_chunks/{relations-zam7-5H7.js → relations-S5nNKdN3.js} +16 -2
- package/dist/_chunks/relations-S5nNKdN3.js.map +1 -0
- package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
- package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
- package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
- package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
- package/dist/_chunks/{useDebounce-CtcjDB3L.js → usePrev-B9w_-eYc.js} +1 -14
- package/dist/_chunks/usePrev-B9w_-eYc.js.map +1 -0
- package/dist/_chunks/usePrev-DH6iah0A.mjs +16 -0
- package/dist/_chunks/usePrev-DH6iah0A.mjs.map +1 -0
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +6 -5
- package/dist/admin/src/content-manager.d.ts +3 -2
- package/dist/admin/src/exports.d.ts +1 -0
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +19 -2
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +1 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +27 -0
- package/dist/admin/src/pages/EditView/utils/data.d.ts +1 -0
- package/dist/admin/src/preview/pages/Preview.d.ts +1 -1
- package/dist/admin/src/preview/services/preview.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 +16 -19
- 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/server/index.js +230 -187
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +231 -187
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +1 -0
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts +3 -3
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +6 -10
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +3 -2
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -1
- package/dist/server/src/preview/index.d.ts.map +1 -1
- package/dist/server/src/preview/services/index.d.ts +1 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -1
- package/dist/server/src/preview/services/preview-config.d.ts +2 -0
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -1
- package/dist/server/src/preview/utils.d.ts +1 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -1
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +4 -2
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +3 -2
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
- package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
- package/dist/server/src/services/utils/populate.d.ts +2 -2
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/package.json +11 -10
- package/dist/_chunks/EditViewPage-5pdbvsO_.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-BEs5iGDi.js.map +0 -1
- package/dist/_chunks/Field-DNHm4wHx.js.map +0 -1
- package/dist/_chunks/Field-DcKuFHYK.mjs.map +0 -1
- package/dist/_chunks/History-BcUTQrfG.js.map +0 -1
- package/dist/_chunks/History-DEvr3Q_V.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-BK2mkrql.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-BkT8Eao0.js.map +0 -1
- package/dist/_chunks/Preview-BF8ZDYqS.js.map +0 -1
- package/dist/_chunks/Preview-DcexhKJE.mjs.map +0 -1
- package/dist/_chunks/Relations-BKnoK1R0.js.map +0 -1
- package/dist/_chunks/Relations-BjIzc4EK.mjs.map +0 -1
- package/dist/_chunks/index-BW-rXkjn.mjs.map +0 -1
- package/dist/_chunks/index-DOzAG2cq.js.map +0 -1
- package/dist/_chunks/relations-Dogh8HWI.mjs.map +0 -1
- package/dist/_chunks/relations-zam7-5H7.js.map +0 -1
- package/dist/_chunks/useDebounce-CtcjDB3L.js.map +0 -1
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs +0 -29
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +0 -1
- package/dist/admin/src/preview/constants.d.ts +0 -1
- package/dist/server/src/preview/constants.d.ts +0 -2
- package/dist/server/src/preview/constants.d.ts.map +0 -1
@@ -1,26 +1,34 @@
|
|
1
|
-
import { More, Cross, WarningCircle, ListPlus, Pencil, Trash, Check,
|
1
|
+
import { More, Cross, WarningCircle, ListPlus, Pencil, Trash, Check, CheckCircle, ArrowsCounterClockwise, CrossCircle, ChevronRight, Duplicate, ClockCounterClockwise, Feather } from "@strapi/icons";
|
2
2
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
3
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 { Menu, Button, VisuallyHidden, Flex, Dialog, Modal, Typography, Radio, Status, Box, SingleSelect, SingleSelectOption, IconButton, Loader, Tooltip, LinkButton } from "@strapi/design-system";
|
6
|
+
import { Menu, Button, VisuallyHidden, Flex, Dialog, Modal, Typography, Radio, Status, Box, SingleSelect, SingleSelectOption, IconButton, RawTable, Loader, Tbody, Tr, Td, Tooltip, LinkButton } from "@strapi/design-system";
|
7
7
|
import mapValues from "lodash/fp/mapValues";
|
8
8
|
import { useIntl } from "react-intl";
|
9
9
|
import { useParams, useNavigate, Navigate, useMatch, useLocation, Link, NavLink } from "react-router-dom";
|
10
10
|
import { styled } from "styled-components";
|
11
11
|
import * as yup from "yup";
|
12
12
|
import { ValidationError } from "yup";
|
13
|
+
import { generateNKeysBetween } from "fractional-indexing";
|
13
14
|
import pipe from "lodash/fp/pipe";
|
14
|
-
import { intervalToDuration, isPast } from "date-fns";
|
15
15
|
import { stringify } from "qs";
|
16
|
+
import { intervalToDuration, isPast } from "date-fns";
|
16
17
|
import { createSlice, combineReducers } from "@reduxjs/toolkit";
|
17
|
-
const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
18
|
+
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
18
19
|
const v = glob[path];
|
19
20
|
if (v) {
|
20
21
|
return typeof v === "function" ? v() : Promise.resolve(v);
|
21
22
|
}
|
22
23
|
return new Promise((_, reject) => {
|
23
|
-
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
24
|
+
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
25
|
+
reject.bind(
|
26
|
+
null,
|
27
|
+
new Error(
|
28
|
+
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
29
|
+
)
|
30
|
+
)
|
31
|
+
);
|
24
32
|
});
|
25
33
|
};
|
26
34
|
const PLUGIN_ID = "content-manager";
|
@@ -159,6 +167,113 @@ const extractAndDedupeFields = (permissions = []) => permissions.flatMap((permis
|
|
159
167
|
(field, index2, arr) => arr.indexOf(field) === index2 && typeof field === "string"
|
160
168
|
);
|
161
169
|
const removeNumericalStrings = (arr) => arr.filter((item) => isNaN(Number(item)));
|
170
|
+
const BLOCK_LIST_ATTRIBUTE_KEYS = ["__component", "__temp_key__"];
|
171
|
+
const traverseData = (predicate, transform) => (schema, components = {}) => (data = {}) => {
|
172
|
+
const traverse = (datum, attributes) => {
|
173
|
+
return Object.entries(datum).reduce((acc, [key, value]) => {
|
174
|
+
const attribute = attributes[key];
|
175
|
+
if (BLOCK_LIST_ATTRIBUTE_KEYS.includes(key) || value === null || value === void 0) {
|
176
|
+
acc[key] = value;
|
177
|
+
return acc;
|
178
|
+
}
|
179
|
+
if (attribute.type === "component") {
|
180
|
+
if (attribute.repeatable) {
|
181
|
+
const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
|
182
|
+
acc[key] = componentValue.map(
|
183
|
+
(componentData) => traverse(componentData, components[attribute.component]?.attributes ?? {})
|
184
|
+
);
|
185
|
+
} else {
|
186
|
+
const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
|
187
|
+
acc[key] = traverse(componentValue, components[attribute.component]?.attributes ?? {});
|
188
|
+
}
|
189
|
+
} else if (attribute.type === "dynamiczone") {
|
190
|
+
const dynamicZoneValue = predicate(attribute, value) ? transform(value, attribute) : value;
|
191
|
+
acc[key] = dynamicZoneValue.map(
|
192
|
+
(componentData) => traverse(componentData, components[componentData.__component]?.attributes ?? {})
|
193
|
+
);
|
194
|
+
} else if (predicate(attribute, value)) {
|
195
|
+
acc[key] = transform(value, attribute);
|
196
|
+
} else {
|
197
|
+
acc[key] = value;
|
198
|
+
}
|
199
|
+
return acc;
|
200
|
+
}, {});
|
201
|
+
};
|
202
|
+
return traverse(data, schema.attributes);
|
203
|
+
};
|
204
|
+
const removeProhibitedFields = (prohibitedFields) => traverseData(
|
205
|
+
(attribute) => prohibitedFields.includes(attribute.type),
|
206
|
+
() => ""
|
207
|
+
);
|
208
|
+
const prepareRelations = traverseData(
|
209
|
+
(attribute) => attribute.type === "relation",
|
210
|
+
() => ({
|
211
|
+
connect: [],
|
212
|
+
disconnect: []
|
213
|
+
})
|
214
|
+
);
|
215
|
+
const prepareTempKeys = traverseData(
|
216
|
+
(attribute) => attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone",
|
217
|
+
(data) => {
|
218
|
+
if (Array.isArray(data) && data.length > 0) {
|
219
|
+
const keys = generateNKeysBetween(void 0, void 0, data.length);
|
220
|
+
return data.map((datum, index2) => ({
|
221
|
+
...datum,
|
222
|
+
__temp_key__: keys[index2]
|
223
|
+
}));
|
224
|
+
}
|
225
|
+
return data;
|
226
|
+
}
|
227
|
+
);
|
228
|
+
const removeFieldsThatDontExistOnSchema = (schema) => (data) => {
|
229
|
+
const schemaKeys = Object.keys(schema.attributes);
|
230
|
+
const dataKeys = Object.keys(data);
|
231
|
+
const keysToRemove = dataKeys.filter((key) => !schemaKeys.includes(key));
|
232
|
+
const revisedData = [...keysToRemove, ...DOCUMENT_META_FIELDS].reduce((acc, key) => {
|
233
|
+
delete acc[key];
|
234
|
+
return acc;
|
235
|
+
}, structuredClone(data));
|
236
|
+
return revisedData;
|
237
|
+
};
|
238
|
+
const removeNullValues = (data) => {
|
239
|
+
return Object.entries(data).reduce((acc, [key, value]) => {
|
240
|
+
if (value === null) {
|
241
|
+
return acc;
|
242
|
+
}
|
243
|
+
acc[key] = value;
|
244
|
+
return acc;
|
245
|
+
}, {});
|
246
|
+
};
|
247
|
+
const transformDocument = (schema, components = {}) => (document) => {
|
248
|
+
const transformations = pipe(
|
249
|
+
removeFieldsThatDontExistOnSchema(schema),
|
250
|
+
removeProhibitedFields(["password"])(schema, components),
|
251
|
+
removeNullValues,
|
252
|
+
prepareRelations(schema, components),
|
253
|
+
prepareTempKeys(schema, components)
|
254
|
+
);
|
255
|
+
return transformations(document);
|
256
|
+
};
|
257
|
+
const createDefaultForm = (contentType, components = {}) => {
|
258
|
+
const traverseSchema = (attributes) => {
|
259
|
+
return Object.entries(attributes).reduce((acc, [key, attribute]) => {
|
260
|
+
if ("default" in attribute) {
|
261
|
+
acc[key] = attribute.default;
|
262
|
+
} else if (attribute.type === "component" && attribute.required) {
|
263
|
+
const defaultComponentForm = traverseSchema(components[attribute.component].attributes);
|
264
|
+
if (attribute.repeatable) {
|
265
|
+
acc[key] = attribute.min ? [...Array(attribute.min).fill(defaultComponentForm)] : [];
|
266
|
+
} else {
|
267
|
+
acc[key] = defaultComponentForm;
|
268
|
+
}
|
269
|
+
} else if (attribute.type === "dynamiczone" && attribute.required) {
|
270
|
+
acc[key] = [];
|
271
|
+
}
|
272
|
+
return acc;
|
273
|
+
}, {});
|
274
|
+
};
|
275
|
+
return traverseSchema(contentType.attributes);
|
276
|
+
};
|
162
277
|
const contentManagerApi = adminApi.enhanceEndpoints({
|
163
278
|
addTagTypes: [
|
164
279
|
"ComponentConfiguration",
|
@@ -168,7 +283,8 @@ const contentManagerApi = adminApi.enhanceEndpoints({
|
|
168
283
|
"InitialData",
|
169
284
|
"HistoryVersion",
|
170
285
|
"Relations",
|
171
|
-
"UidAvailability"
|
286
|
+
"UidAvailability",
|
287
|
+
"RecentDocumentList"
|
172
288
|
]
|
173
289
|
});
|
174
290
|
const documentApi = contentManagerApi.injectEndpoints({
|
@@ -186,7 +302,7 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
186
302
|
if (error) {
|
187
303
|
return [];
|
188
304
|
}
|
189
|
-
return [{ type: "Document", id: `${model}_LIST` }];
|
305
|
+
return [{ type: "Document", id: `${model}_LIST` }, "RecentDocumentList"];
|
190
306
|
}
|
191
307
|
}),
|
192
308
|
cloneDocument: builder.mutation({
|
@@ -200,7 +316,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
200
316
|
}),
|
201
317
|
invalidatesTags: (_result, _error, { model }) => [
|
202
318
|
{ type: "Document", id: `${model}_LIST` },
|
203
|
-
{ type: "UidAvailability", id: model }
|
319
|
+
{ type: "UidAvailability", id: model },
|
320
|
+
"RecentDocumentList"
|
204
321
|
]
|
205
322
|
}),
|
206
323
|
/**
|
@@ -219,8 +336,21 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
219
336
|
invalidatesTags: (result, _error, { model }) => [
|
220
337
|
{ type: "Document", id: `${model}_LIST` },
|
221
338
|
"Relations",
|
222
|
-
{ type: "UidAvailability", id: model }
|
223
|
-
|
339
|
+
{ type: "UidAvailability", id: model },
|
340
|
+
"RecentDocumentList"
|
341
|
+
],
|
342
|
+
transformResponse: (response, meta, arg) => {
|
343
|
+
if (!("data" in response) && arg.model === "plugin::users-permissions.user") {
|
344
|
+
return {
|
345
|
+
data: response,
|
346
|
+
meta: {
|
347
|
+
availableStatus: [],
|
348
|
+
availableLocales: []
|
349
|
+
}
|
350
|
+
};
|
351
|
+
}
|
352
|
+
return response;
|
353
|
+
}
|
224
354
|
}),
|
225
355
|
deleteDocument: builder.mutation({
|
226
356
|
query: ({ collectionType, model, documentId, params }) => ({
|
@@ -231,7 +361,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
231
361
|
}
|
232
362
|
}),
|
233
363
|
invalidatesTags: (_result, _error, { collectionType, model }) => [
|
234
|
-
{ type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model }
|
364
|
+
{ type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model },
|
365
|
+
"RecentDocumentList"
|
235
366
|
]
|
236
367
|
}),
|
237
368
|
deleteManyDocuments: builder.mutation({
|
@@ -243,7 +374,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
243
374
|
params
|
244
375
|
}
|
245
376
|
}),
|
246
|
-
invalidatesTags: (_res, _error, { model }) => [
|
377
|
+
invalidatesTags: (_res, _error, { model }) => [
|
378
|
+
{ type: "Document", id: `${model}_LIST` },
|
379
|
+
"RecentDocumentList"
|
380
|
+
]
|
247
381
|
}),
|
248
382
|
discardDocument: builder.mutation({
|
249
383
|
query: ({ collectionType, model, documentId, params }) => ({
|
@@ -261,7 +395,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
261
395
|
},
|
262
396
|
{ type: "Document", id: `${model}_LIST` },
|
263
397
|
"Relations",
|
264
|
-
{ type: "UidAvailability", id: model }
|
398
|
+
{ type: "UidAvailability", id: model },
|
399
|
+
"RecentDocumentList"
|
265
400
|
];
|
266
401
|
}
|
267
402
|
}),
|
@@ -274,7 +409,7 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
274
409
|
url: `/content-manager/collection-types/${model}`,
|
275
410
|
method: "GET",
|
276
411
|
config: {
|
277
|
-
params
|
412
|
+
params: stringify(params, { encode: true })
|
278
413
|
}
|
279
414
|
}),
|
280
415
|
providesTags: (result, _error, arg) => {
|
@@ -356,7 +491,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
356
491
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
357
492
|
},
|
358
493
|
{ type: "Document", id: `${model}_LIST` },
|
359
|
-
"Relations"
|
494
|
+
"Relations",
|
495
|
+
"RecentDocumentList"
|
360
496
|
];
|
361
497
|
}
|
362
498
|
}),
|
@@ -387,7 +523,9 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
387
523
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
388
524
|
},
|
389
525
|
"Relations",
|
390
|
-
{ type: "UidAvailability", id: model }
|
526
|
+
{ type: "UidAvailability", id: model },
|
527
|
+
"RecentDocumentList",
|
528
|
+
"RecentDocumentList"
|
391
529
|
];
|
392
530
|
},
|
393
531
|
async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
|
@@ -417,7 +555,8 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
417
555
|
{
|
418
556
|
type: "Document",
|
419
557
|
id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
|
420
|
-
}
|
558
|
+
},
|
559
|
+
"RecentDocumentList"
|
421
560
|
];
|
422
561
|
}
|
423
562
|
}),
|
@@ -430,7 +569,10 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
430
569
|
params
|
431
570
|
}
|
432
571
|
}),
|
433
|
-
invalidatesTags: (_res, _error, { model, documentIds }) =>
|
572
|
+
invalidatesTags: (_res, _error, { model, documentIds }) => [
|
573
|
+
...documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` })),
|
574
|
+
"RecentDocumentList"
|
575
|
+
]
|
434
576
|
})
|
435
577
|
})
|
436
578
|
});
|
@@ -453,8 +595,7 @@ const {
|
|
453
595
|
useUnpublishManyDocumentsMutation
|
454
596
|
} = documentApi;
|
455
597
|
const buildValidParams = (query) => {
|
456
|
-
if (!query)
|
457
|
-
return query;
|
598
|
+
if (!query) return query;
|
458
599
|
const { plugins: _, ...validQueryParams } = {
|
459
600
|
...query,
|
460
601
|
...Object.values(query?.plugins ?? {}).reduce(
|
@@ -462,9 +603,6 @@ const buildValidParams = (query) => {
|
|
462
603
|
{}
|
463
604
|
)
|
464
605
|
};
|
465
|
-
if ("_q" in validQueryParams) {
|
466
|
-
validQueryParams._q = encodeURIComponent(validQueryParams._q);
|
467
|
-
}
|
468
606
|
return validQueryParams;
|
469
607
|
};
|
470
608
|
const isBaseQueryError = (error) => {
|
@@ -1105,6 +1243,7 @@ const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, co
|
|
1105
1243
|
const useDocument = (args, opts) => {
|
1106
1244
|
const { toggleNotification } = useNotification();
|
1107
1245
|
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
1246
|
+
const { formatMessage } = useIntl();
|
1108
1247
|
const {
|
1109
1248
|
currentData: data,
|
1110
1249
|
isLoading: isLoadingDocument,
|
@@ -1114,12 +1253,27 @@ const useDocument = (args, opts) => {
|
|
1114
1253
|
...opts,
|
1115
1254
|
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
1116
1255
|
});
|
1256
|
+
const document = data?.data;
|
1257
|
+
const meta = data?.meta;
|
1117
1258
|
const {
|
1118
1259
|
components,
|
1119
1260
|
schema,
|
1120
1261
|
schemas,
|
1121
1262
|
isLoading: isLoadingSchema
|
1122
1263
|
} = useContentTypeSchema(args.model);
|
1264
|
+
const isSingleType = schema?.kind === "singleType";
|
1265
|
+
const getTitle = (mainField) => {
|
1266
|
+
if (mainField !== "id" && document?.[mainField]) {
|
1267
|
+
return document[mainField];
|
1268
|
+
}
|
1269
|
+
if (isSingleType && schema?.info.displayName) {
|
1270
|
+
return schema.info.displayName;
|
1271
|
+
}
|
1272
|
+
return formatMessage({
|
1273
|
+
id: "content-manager.containers.untitled",
|
1274
|
+
defaultMessage: "Untitled"
|
1275
|
+
});
|
1276
|
+
};
|
1123
1277
|
React.useEffect(() => {
|
1124
1278
|
if (error) {
|
1125
1279
|
toggleNotification({
|
@@ -1135,14 +1289,14 @@ const useDocument = (args, opts) => {
|
|
1135
1289
|
return createYupSchema(schema.attributes, components);
|
1136
1290
|
}, [schema, components]);
|
1137
1291
|
const validate = React.useCallback(
|
1138
|
-
(
|
1292
|
+
(document2) => {
|
1139
1293
|
if (!validationSchema) {
|
1140
1294
|
throw new Error(
|
1141
1295
|
"There is no validation schema generated, this is likely due to the schema not being loaded yet."
|
1142
1296
|
);
|
1143
1297
|
}
|
1144
1298
|
try {
|
1145
|
-
validationSchema.validateSync(
|
1299
|
+
validationSchema.validateSync(document2, { abortEarly: false, strict: true });
|
1146
1300
|
return null;
|
1147
1301
|
} catch (error2) {
|
1148
1302
|
if (error2 instanceof ValidationError) {
|
@@ -1153,17 +1307,29 @@ const useDocument = (args, opts) => {
|
|
1153
1307
|
},
|
1154
1308
|
[validationSchema]
|
1155
1309
|
);
|
1310
|
+
const getInitialFormValues = React.useCallback(
|
1311
|
+
(isCreatingDocument = false) => {
|
1312
|
+
if (!document && !isCreatingDocument && !isSingleType || !schema) {
|
1313
|
+
return void 0;
|
1314
|
+
}
|
1315
|
+
const form = document?.id ? document : createDefaultForm(schema, components);
|
1316
|
+
return transformDocument(schema, components)(form);
|
1317
|
+
},
|
1318
|
+
[document, isSingleType, schema, components]
|
1319
|
+
);
|
1156
1320
|
const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
|
1157
1321
|
const hasError = !!error;
|
1158
1322
|
return {
|
1159
1323
|
components,
|
1160
|
-
document
|
1161
|
-
meta
|
1324
|
+
document,
|
1325
|
+
meta,
|
1162
1326
|
isLoading,
|
1163
1327
|
hasError,
|
1164
1328
|
schema,
|
1165
1329
|
schemas,
|
1166
|
-
validate
|
1330
|
+
validate,
|
1331
|
+
getTitle,
|
1332
|
+
getInitialFormValues
|
1167
1333
|
};
|
1168
1334
|
};
|
1169
1335
|
const useDoc = () => {
|
@@ -1664,7 +1830,7 @@ const useDocumentActions = () => {
|
|
1664
1830
|
};
|
1665
1831
|
};
|
1666
1832
|
const ProtectedHistoryPage = React.lazy(
|
1667
|
-
() => import("./History-
|
1833
|
+
() => import("./History-CcmSn3Mj.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1668
1834
|
);
|
1669
1835
|
const routes$2 = [
|
1670
1836
|
{
|
@@ -1677,7 +1843,7 @@ const routes$2 = [
|
|
1677
1843
|
}
|
1678
1844
|
];
|
1679
1845
|
const ProtectedPreviewPage = React.lazy(
|
1680
|
-
() => import("./Preview-
|
1846
|
+
() => import("./Preview-vfWOtPG5.mjs").then((mod) => ({ default: mod.ProtectedPreviewPage }))
|
1681
1847
|
);
|
1682
1848
|
const routes$1 = [
|
1683
1849
|
{
|
@@ -1690,31 +1856,31 @@ const routes$1 = [
|
|
1690
1856
|
}
|
1691
1857
|
];
|
1692
1858
|
const ProtectedEditViewPage = lazy(
|
1693
|
-
() => import("./EditViewPage-
|
1859
|
+
() => import("./EditViewPage-Bcnff6Vd.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1694
1860
|
);
|
1695
1861
|
const ProtectedListViewPage = lazy(
|
1696
|
-
() => import("./ListViewPage-
|
1862
|
+
() => import("./ListViewPage-HljQVnFH.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1697
1863
|
);
|
1698
1864
|
const ProtectedListConfiguration = lazy(
|
1699
|
-
() => import("./ListConfigurationPage-
|
1865
|
+
() => import("./ListConfigurationPage-BPvzENJJ.mjs").then((mod) => ({
|
1700
1866
|
default: mod.ProtectedListConfiguration
|
1701
1867
|
}))
|
1702
1868
|
);
|
1703
1869
|
const ProtectedEditConfigurationPage = lazy(
|
1704
|
-
() => import("./EditConfigurationPage-
|
1870
|
+
() => import("./EditConfigurationPage-D1nvB7Br.mjs").then((mod) => ({
|
1705
1871
|
default: mod.ProtectedEditConfigurationPage
|
1706
1872
|
}))
|
1707
1873
|
);
|
1708
1874
|
const ProtectedComponentConfigurationPage = lazy(
|
1709
|
-
() => import("./ComponentConfigurationPage-
|
1875
|
+
() => import("./ComponentConfigurationPage-D4H-v0et.mjs").then((mod) => ({
|
1710
1876
|
default: mod.ProtectedComponentConfigurationPage
|
1711
1877
|
}))
|
1712
1878
|
);
|
1713
1879
|
const NoPermissions = lazy(
|
1714
|
-
() => import("./NoPermissionsPage-
|
1880
|
+
() => import("./NoPermissionsPage-D6ze2nQL.mjs").then((mod) => ({ default: mod.NoPermissions }))
|
1715
1881
|
);
|
1716
1882
|
const NoContentType = lazy(
|
1717
|
-
() => import("./NoContentTypePage-
|
1883
|
+
() => import("./NoContentTypePage-BfHaSM-K.mjs").then((mod) => ({ default: mod.NoContentType }))
|
1718
1884
|
);
|
1719
1885
|
const CollectionTypePages = () => {
|
1720
1886
|
const { collectionType } = useParams();
|
@@ -2084,6 +2250,7 @@ const PublishAction$1 = ({
|
|
2084
2250
|
const { _unstableFormatValidationErrors: formatValidationErrors } = useAPIErrorHandler();
|
2085
2251
|
const isListView = useMatch(LIST_PATH) !== null;
|
2086
2252
|
const isCloning = useMatch(CLONE_PATH) !== null;
|
2253
|
+
const { id } = useParams();
|
2087
2254
|
const { formatMessage } = useIntl();
|
2088
2255
|
const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
|
2089
2256
|
const { publish } = useDocumentActions();
|
@@ -2186,10 +2353,12 @@ const PublishAction$1 = ({
|
|
2186
2353
|
transformData(formValues)
|
2187
2354
|
);
|
2188
2355
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
2189
|
-
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2356
|
+
if (id === "create") {
|
2357
|
+
navigate({
|
2358
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
2359
|
+
search: rawQuery
|
2360
|
+
});
|
2361
|
+
}
|
2193
2362
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2194
2363
|
setErrors(formatValidationErrors(res.error));
|
2195
2364
|
}
|
@@ -2242,6 +2411,7 @@ const PublishAction$1 = ({
|
|
2242
2411
|
};
|
2243
2412
|
};
|
2244
2413
|
PublishAction$1.type = "publish";
|
2414
|
+
PublishAction$1.position = "panel";
|
2245
2415
|
const UpdateAction = ({
|
2246
2416
|
activeTab,
|
2247
2417
|
documentId,
|
@@ -2264,6 +2434,117 @@ const UpdateAction = ({
|
|
2264
2434
|
const validate = useForm("UpdateAction", (state) => state.validate);
|
2265
2435
|
const setErrors = useForm("UpdateAction", (state) => state.setErrors);
|
2266
2436
|
const resetForm = useForm("PublishAction", ({ resetForm: resetForm2 }) => resetForm2);
|
2437
|
+
const handleUpdate = React.useCallback(async () => {
|
2438
|
+
setSubmitting(true);
|
2439
|
+
try {
|
2440
|
+
if (!modified) {
|
2441
|
+
return;
|
2442
|
+
}
|
2443
|
+
const { errors } = await validate(true, {
|
2444
|
+
status: "draft"
|
2445
|
+
});
|
2446
|
+
if (errors) {
|
2447
|
+
toggleNotification({
|
2448
|
+
type: "danger",
|
2449
|
+
message: formatMessage({
|
2450
|
+
id: "content-manager.validation.error",
|
2451
|
+
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
2452
|
+
})
|
2453
|
+
});
|
2454
|
+
return;
|
2455
|
+
}
|
2456
|
+
if (isCloning) {
|
2457
|
+
const res = await clone(
|
2458
|
+
{
|
2459
|
+
model,
|
2460
|
+
documentId: cloneMatch.params.origin,
|
2461
|
+
params
|
2462
|
+
},
|
2463
|
+
transformData(document)
|
2464
|
+
);
|
2465
|
+
if ("data" in res) {
|
2466
|
+
navigate(
|
2467
|
+
{
|
2468
|
+
pathname: `../${res.data.documentId}`,
|
2469
|
+
search: rawQuery
|
2470
|
+
},
|
2471
|
+
{ relative: "path" }
|
2472
|
+
);
|
2473
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2474
|
+
setErrors(formatValidationErrors(res.error));
|
2475
|
+
}
|
2476
|
+
} else if (documentId || collectionType === SINGLE_TYPES) {
|
2477
|
+
const res = await update(
|
2478
|
+
{
|
2479
|
+
collectionType,
|
2480
|
+
model,
|
2481
|
+
documentId,
|
2482
|
+
params
|
2483
|
+
},
|
2484
|
+
transformData(document)
|
2485
|
+
);
|
2486
|
+
if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2487
|
+
setErrors(formatValidationErrors(res.error));
|
2488
|
+
} else {
|
2489
|
+
resetForm();
|
2490
|
+
}
|
2491
|
+
} else {
|
2492
|
+
const res = await create(
|
2493
|
+
{
|
2494
|
+
model,
|
2495
|
+
params
|
2496
|
+
},
|
2497
|
+
transformData(document)
|
2498
|
+
);
|
2499
|
+
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
2500
|
+
navigate(
|
2501
|
+
{
|
2502
|
+
pathname: `../${res.data.documentId}`,
|
2503
|
+
search: rawQuery
|
2504
|
+
},
|
2505
|
+
{ replace: true, relative: "path" }
|
2506
|
+
);
|
2507
|
+
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2508
|
+
setErrors(formatValidationErrors(res.error));
|
2509
|
+
}
|
2510
|
+
}
|
2511
|
+
} finally {
|
2512
|
+
setSubmitting(false);
|
2513
|
+
}
|
2514
|
+
}, [
|
2515
|
+
clone,
|
2516
|
+
cloneMatch?.params.origin,
|
2517
|
+
collectionType,
|
2518
|
+
create,
|
2519
|
+
document,
|
2520
|
+
documentId,
|
2521
|
+
formatMessage,
|
2522
|
+
formatValidationErrors,
|
2523
|
+
isCloning,
|
2524
|
+
model,
|
2525
|
+
modified,
|
2526
|
+
navigate,
|
2527
|
+
params,
|
2528
|
+
rawQuery,
|
2529
|
+
resetForm,
|
2530
|
+
setErrors,
|
2531
|
+
setSubmitting,
|
2532
|
+
toggleNotification,
|
2533
|
+
update,
|
2534
|
+
validate
|
2535
|
+
]);
|
2536
|
+
React.useEffect(() => {
|
2537
|
+
const handleKeyDown = (e) => {
|
2538
|
+
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
2539
|
+
e.preventDefault();
|
2540
|
+
handleUpdate();
|
2541
|
+
}
|
2542
|
+
};
|
2543
|
+
window.addEventListener("keydown", handleKeyDown);
|
2544
|
+
return () => {
|
2545
|
+
window.removeEventListener("keydown", handleKeyDown);
|
2546
|
+
};
|
2547
|
+
}, [handleUpdate]);
|
2267
2548
|
return {
|
2268
2549
|
/**
|
2269
2550
|
* Disabled when:
|
@@ -2276,84 +2557,11 @@ const UpdateAction = ({
|
|
2276
2557
|
id: "global.save",
|
2277
2558
|
defaultMessage: "Save"
|
2278
2559
|
}),
|
2279
|
-
onClick:
|
2280
|
-
setSubmitting(true);
|
2281
|
-
try {
|
2282
|
-
const { errors } = await validate(true, {
|
2283
|
-
status: "draft"
|
2284
|
-
});
|
2285
|
-
if (errors) {
|
2286
|
-
toggleNotification({
|
2287
|
-
type: "danger",
|
2288
|
-
message: formatMessage({
|
2289
|
-
id: "content-manager.validation.error",
|
2290
|
-
defaultMessage: "There are validation errors in your document. Please fix them before saving."
|
2291
|
-
})
|
2292
|
-
});
|
2293
|
-
return;
|
2294
|
-
}
|
2295
|
-
if (isCloning) {
|
2296
|
-
const res = await clone(
|
2297
|
-
{
|
2298
|
-
model,
|
2299
|
-
documentId: cloneMatch.params.origin,
|
2300
|
-
params
|
2301
|
-
},
|
2302
|
-
transformData(document)
|
2303
|
-
);
|
2304
|
-
if ("data" in res) {
|
2305
|
-
navigate(
|
2306
|
-
{
|
2307
|
-
pathname: `../${res.data.documentId}`,
|
2308
|
-
search: rawQuery
|
2309
|
-
},
|
2310
|
-
{ relative: "path" }
|
2311
|
-
);
|
2312
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2313
|
-
setErrors(formatValidationErrors(res.error));
|
2314
|
-
}
|
2315
|
-
} else if (documentId || collectionType === SINGLE_TYPES) {
|
2316
|
-
const res = await update(
|
2317
|
-
{
|
2318
|
-
collectionType,
|
2319
|
-
model,
|
2320
|
-
documentId,
|
2321
|
-
params
|
2322
|
-
},
|
2323
|
-
transformData(document)
|
2324
|
-
);
|
2325
|
-
if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2326
|
-
setErrors(formatValidationErrors(res.error));
|
2327
|
-
} else {
|
2328
|
-
resetForm();
|
2329
|
-
}
|
2330
|
-
} else {
|
2331
|
-
const res = await create(
|
2332
|
-
{
|
2333
|
-
model,
|
2334
|
-
params
|
2335
|
-
},
|
2336
|
-
transformData(document)
|
2337
|
-
);
|
2338
|
-
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
2339
|
-
navigate(
|
2340
|
-
{
|
2341
|
-
pathname: `../${res.data.documentId}`,
|
2342
|
-
search: rawQuery
|
2343
|
-
},
|
2344
|
-
{ replace: true, relative: "path" }
|
2345
|
-
);
|
2346
|
-
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
2347
|
-
setErrors(formatValidationErrors(res.error));
|
2348
|
-
}
|
2349
|
-
}
|
2350
|
-
} finally {
|
2351
|
-
setSubmitting(false);
|
2352
|
-
}
|
2353
|
-
}
|
2560
|
+
onClick: handleUpdate
|
2354
2561
|
};
|
2355
2562
|
};
|
2356
2563
|
UpdateAction.type = "update";
|
2564
|
+
UpdateAction.position = "panel";
|
2357
2565
|
const UNPUBLISH_DRAFT_OPTIONS = {
|
2358
2566
|
KEEP: "keep",
|
2359
2567
|
DISCARD: "discard"
|
@@ -2476,6 +2684,7 @@ const UnpublishAction$1 = ({
|
|
2476
2684
|
};
|
2477
2685
|
};
|
2478
2686
|
UnpublishAction$1.type = "unpublish";
|
2687
|
+
UnpublishAction$1.position = "panel";
|
2479
2688
|
const DiscardAction = ({
|
2480
2689
|
activeTab,
|
2481
2690
|
documentId,
|
@@ -2526,6 +2735,7 @@ const DiscardAction = ({
|
|
2526
2735
|
};
|
2527
2736
|
};
|
2528
2737
|
DiscardAction.type = "discard";
|
2738
|
+
DiscardAction.position = "panel";
|
2529
2739
|
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
2530
2740
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
2531
2741
|
const RelativeTime = React.forwardRef(
|
@@ -2645,7 +2855,7 @@ const HeaderToolbar = () => {
|
|
2645
2855
|
meta: isCloning ? void 0 : meta,
|
2646
2856
|
collectionType
|
2647
2857
|
},
|
2648
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2858
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("header"),
|
2649
2859
|
children: (actions2) => {
|
2650
2860
|
const headerActions = actions2.filter((action) => {
|
2651
2861
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -2853,6 +3063,7 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
|
|
2853
3063
|
};
|
2854
3064
|
};
|
2855
3065
|
ConfigureTheViewAction.type = "configure-the-view";
|
3066
|
+
ConfigureTheViewAction.position = "header";
|
2856
3067
|
const EditTheModelAction = ({ model }) => {
|
2857
3068
|
const navigate = useNavigate();
|
2858
3069
|
const { formatMessage } = useIntl();
|
@@ -2869,6 +3080,7 @@ const EditTheModelAction = ({ model }) => {
|
|
2869
3080
|
};
|
2870
3081
|
};
|
2871
3082
|
EditTheModelAction.type = "edit-the-model";
|
3083
|
+
EditTheModelAction.position = "header";
|
2872
3084
|
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2873
3085
|
const navigate = useNavigate();
|
2874
3086
|
const { formatMessage } = useIntl();
|
@@ -2942,6 +3154,7 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
|
2942
3154
|
};
|
2943
3155
|
};
|
2944
3156
|
DeleteAction$1.type = "delete";
|
3157
|
+
DeleteAction$1.position = ["header", "table-row"];
|
2945
3158
|
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2946
3159
|
const Panels = () => {
|
2947
3160
|
const isCloning = useMatch(CLONE_PATH) !== null;
|
@@ -3004,7 +3217,7 @@ const ActionsPanelContent = () => {
|
|
3004
3217
|
DescriptionComponentRenderer,
|
3005
3218
|
{
|
3006
3219
|
props,
|
3007
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3220
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("panel"),
|
3008
3221
|
children: (actions2) => /* @__PURE__ */ jsx(DocumentActions, { actions: actions2 })
|
3009
3222
|
}
|
3010
3223
|
),
|
@@ -3062,7 +3275,7 @@ const ConfirmBulkActionDialog = ({
|
|
3062
3275
|
] })
|
3063
3276
|
] }) });
|
3064
3277
|
};
|
3065
|
-
const BoldChunk
|
3278
|
+
const BoldChunk = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: chunks });
|
3066
3279
|
const ConfirmDialogPublishAll = ({
|
3067
3280
|
isOpen,
|
3068
3281
|
onToggleDialog,
|
@@ -3111,7 +3324,7 @@ const ConfirmDialogPublishAll = ({
|
|
3111
3324
|
defaultMessage: "<b>{count} {count, plural, one { relation } other { relations } } out of {entities} { entities, plural, one { entry } other { entries } } {count, plural, one { is } other { are } }</b> not published yet and might lead to unexpected behavior. "
|
3112
3325
|
},
|
3113
3326
|
{
|
3114
|
-
b: BoldChunk
|
3327
|
+
b: BoldChunk,
|
3115
3328
|
count: countDraftRelations,
|
3116
3329
|
entities: selectedEntries.length
|
3117
3330
|
}
|
@@ -3150,6 +3363,16 @@ const ConfirmDialogPublishAll = ({
|
|
3150
3363
|
const TypographyMaxWidth = styled(Typography)`
|
3151
3364
|
max-width: 300px;
|
3152
3365
|
`;
|
3366
|
+
const TableComponent = styled(RawTable)`
|
3367
|
+
width: 100%;
|
3368
|
+
table-layout: fixed;
|
3369
|
+
td:first-child {
|
3370
|
+
border-right: 1px solid ${({ theme }) => theme.colors.neutral150};
|
3371
|
+
}
|
3372
|
+
td:first-of-type {
|
3373
|
+
padding: ${({ theme }) => theme.spaces[4]};
|
3374
|
+
}
|
3375
|
+
`;
|
3153
3376
|
const formatErrorMessages = (errors, parentKey, formatMessage) => {
|
3154
3377
|
const messages = [];
|
3155
3378
|
Object.entries(errors).forEach(([key, value]) => {
|
@@ -3254,7 +3477,7 @@ const SelectedEntriesTableContent = ({
|
|
3254
3477
|
)
|
3255
3478
|
] }),
|
3256
3479
|
/* @__PURE__ */ jsx(Table.Loading, {}),
|
3257
|
-
/* @__PURE__ */ jsx(Table.Body, { children: rowsToDisplay.map((row
|
3480
|
+
/* @__PURE__ */ jsx(Table.Body, { children: rowsToDisplay.map((row) => /* @__PURE__ */ jsxs(Table.Row, { children: [
|
3258
3481
|
/* @__PURE__ */ jsx(Table.CheckboxCell, { id: row.id }),
|
3259
3482
|
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Typography, { children: row.id }) }),
|
3260
3483
|
shouldDisplayMainField && /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Typography, { children: row[mainField] }) }),
|
@@ -3294,7 +3517,73 @@ const SelectedEntriesTableContent = ({
|
|
3294
3517
|
] }, row.id)) })
|
3295
3518
|
] });
|
3296
3519
|
};
|
3297
|
-
const
|
3520
|
+
const PublicationStatusSummary = ({ count, icon, message }) => {
|
3521
|
+
return /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", flex: 1, gap: 3, children: [
|
3522
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
3523
|
+
icon,
|
3524
|
+
/* @__PURE__ */ jsx(Typography, { children: message })
|
3525
|
+
] }),
|
3526
|
+
/* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: count })
|
3527
|
+
] });
|
3528
|
+
};
|
3529
|
+
const PublicationStatusGrid = ({
|
3530
|
+
entriesReadyToPublishCount,
|
3531
|
+
entriesPublishedCount,
|
3532
|
+
entriesModifiedCount,
|
3533
|
+
entriesWithErrorsCount
|
3534
|
+
}) => {
|
3535
|
+
const { formatMessage } = useIntl();
|
3536
|
+
return /* @__PURE__ */ jsx(Box, { hasRadius: true, borderColor: "neutral150", children: /* @__PURE__ */ jsx(TableComponent, { colCount: 2, rowCount: 2, children: /* @__PURE__ */ jsxs(Tbody, { children: [
|
3537
|
+
/* @__PURE__ */ jsxs(Tr, { children: [
|
3538
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
3539
|
+
PublicationStatusSummary,
|
3540
|
+
{
|
3541
|
+
count: entriesReadyToPublishCount,
|
3542
|
+
icon: /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
3543
|
+
message: formatMessage({
|
3544
|
+
id: "app.utils.ready-to-publish",
|
3545
|
+
defaultMessage: "Ready to publish"
|
3546
|
+
})
|
3547
|
+
}
|
3548
|
+
) }),
|
3549
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
3550
|
+
PublicationStatusSummary,
|
3551
|
+
{
|
3552
|
+
count: entriesPublishedCount,
|
3553
|
+
icon: /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
3554
|
+
message: formatMessage({
|
3555
|
+
id: "app.utils.already-published",
|
3556
|
+
defaultMessage: "Already published"
|
3557
|
+
})
|
3558
|
+
}
|
3559
|
+
) })
|
3560
|
+
] }),
|
3561
|
+
/* @__PURE__ */ jsxs(Tr, { children: [
|
3562
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
3563
|
+
PublicationStatusSummary,
|
3564
|
+
{
|
3565
|
+
count: entriesModifiedCount,
|
3566
|
+
icon: /* @__PURE__ */ jsx(ArrowsCounterClockwise, { fill: "alternative600" }),
|
3567
|
+
message: formatMessage({
|
3568
|
+
id: "content-manager.bulk-publish.modified",
|
3569
|
+
defaultMessage: "Ready to publish changes"
|
3570
|
+
})
|
3571
|
+
}
|
3572
|
+
) }),
|
3573
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
3574
|
+
PublicationStatusSummary,
|
3575
|
+
{
|
3576
|
+
count: entriesWithErrorsCount,
|
3577
|
+
icon: /* @__PURE__ */ jsx(CrossCircle, { fill: "danger600" }),
|
3578
|
+
message: formatMessage({
|
3579
|
+
id: "content-manager.bulk-publish.waiting-for-action",
|
3580
|
+
defaultMessage: "Waiting for action"
|
3581
|
+
})
|
3582
|
+
}
|
3583
|
+
) })
|
3584
|
+
] })
|
3585
|
+
] }) }) });
|
3586
|
+
};
|
3298
3587
|
const SelectedEntriesModalContent = ({
|
3299
3588
|
listViewSelectedEntries,
|
3300
3589
|
toggleModal,
|
@@ -3353,7 +3642,6 @@ const SelectedEntriesModalContent = ({
|
|
3353
3642
|
validationErrors: {}
|
3354
3643
|
};
|
3355
3644
|
}, [components, data, schema]);
|
3356
|
-
const [publishedCount, setPublishedCount] = React.useState(0);
|
3357
3645
|
const [isDialogOpen, setIsDialogOpen] = React.useState(false);
|
3358
3646
|
const { publishMany: bulkPublishAction } = useDocumentActions();
|
3359
3647
|
const [, { isLoading: isSubmittingForm }] = usePublishManyDocumentsMutation();
|
@@ -3365,53 +3653,36 @@ const SelectedEntriesModalContent = ({
|
|
3365
3653
|
const selectedEntriesWithErrorsCount = selectedEntries.filter(
|
3366
3654
|
({ documentId }) => validationErrors[documentId]
|
3367
3655
|
).length;
|
3368
|
-
const
|
3656
|
+
const selectedEntriesPublishedCount = selectedEntries.filter(
|
3369
3657
|
({ status }) => status === "published"
|
3370
3658
|
).length;
|
3371
|
-
const
|
3659
|
+
const selectedEntriesModifiedCount = selectedEntries.filter(
|
3660
|
+
({ status, documentId }) => status === "modified" && !validationErrors[documentId]
|
3661
|
+
).length;
|
3662
|
+
const selectedEntriesWithNoErrorsCount = selectedEntries.length - selectedEntriesWithErrorsCount - selectedEntriesPublishedCount;
|
3372
3663
|
const toggleDialog = () => setIsDialogOpen((prev) => !prev);
|
3373
3664
|
const handleConfirmBulkPublish = async () => {
|
3374
3665
|
toggleDialog();
|
3375
3666
|
const res = await bulkPublishAction({ model, documentIds: entriesToPublish, params });
|
3376
3667
|
if (!("error" in res)) {
|
3377
|
-
setPublishedCount(res.count);
|
3378
3668
|
const unpublishedEntries = rows.filter((row) => {
|
3379
3669
|
return !entriesToPublish.includes(row.documentId);
|
3380
3670
|
});
|
3381
3671
|
setListViewSelectedDocuments(unpublishedEntries);
|
3382
3672
|
}
|
3383
3673
|
};
|
3384
|
-
const getFormattedCountMessage = () => {
|
3385
|
-
if (publishedCount) {
|
3386
|
-
return formatMessage(
|
3387
|
-
{
|
3388
|
-
id: getTranslation("containers.list.selectedEntriesModal.publishedCount"),
|
3389
|
-
defaultMessage: "<b>{publishedCount}</b> {publishedCount, plural, =0 {entries} one {entry} other {entries}} published. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action."
|
3390
|
-
},
|
3391
|
-
{
|
3392
|
-
publishedCount,
|
3393
|
-
withErrorsCount: selectedEntriesWithErrorsCount,
|
3394
|
-
b: BoldChunk
|
3395
|
-
}
|
3396
|
-
);
|
3397
|
-
}
|
3398
|
-
return formatMessage(
|
3399
|
-
{
|
3400
|
-
id: getTranslation("containers.list.selectedEntriesModal.selectedCount"),
|
3401
|
-
defaultMessage: "<b>{alreadyPublishedCount}</b> {alreadyPublishedCount, plural, =0 {entries} one {entry} other {entries}} already published. <b>{readyToPublishCount}</b> {readyToPublishCount, plural, =0 {entries} one {entry} other {entries}} ready to publish. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action."
|
3402
|
-
},
|
3403
|
-
{
|
3404
|
-
readyToPublishCount: selectedEntriesWithNoErrorsCount,
|
3405
|
-
withErrorsCount: selectedEntriesWithErrorsCount,
|
3406
|
-
alreadyPublishedCount: selectedEntriesPublished,
|
3407
|
-
b: BoldChunk
|
3408
|
-
}
|
3409
|
-
);
|
3410
|
-
};
|
3411
3674
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
3412
3675
|
/* @__PURE__ */ jsxs(Modal.Body, { children: [
|
3413
|
-
/* @__PURE__ */ jsx(
|
3414
|
-
|
3676
|
+
/* @__PURE__ */ jsx(
|
3677
|
+
PublicationStatusGrid,
|
3678
|
+
{
|
3679
|
+
entriesReadyToPublishCount: selectedEntriesWithNoErrorsCount - selectedEntriesModifiedCount,
|
3680
|
+
entriesPublishedCount: selectedEntriesPublishedCount,
|
3681
|
+
entriesModifiedCount: selectedEntriesModifiedCount,
|
3682
|
+
entriesWithErrorsCount: selectedEntriesWithErrorsCount
|
3683
|
+
}
|
3684
|
+
),
|
3685
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 7, children: /* @__PURE__ */ jsx(
|
3415
3686
|
SelectedEntriesTableContent,
|
3416
3687
|
{
|
3417
3688
|
isPublishing: isSubmittingForm,
|
@@ -3432,7 +3703,7 @@ const SelectedEntriesModalContent = ({
|
|
3432
3703
|
Button,
|
3433
3704
|
{
|
3434
3705
|
onClick: toggleDialog,
|
3435
|
-
disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount ||
|
3706
|
+
disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublishedCount === selectedEntries.length || isLoading,
|
3436
3707
|
loading: isSubmittingForm,
|
3437
3708
|
children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
|
3438
3709
|
}
|
@@ -3458,8 +3729,7 @@ const PublishAction = ({ documents, model }) => {
|
|
3458
3729
|
const refetchList = () => {
|
3459
3730
|
contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
|
3460
3731
|
};
|
3461
|
-
if (!showPublishButton)
|
3462
|
-
return null;
|
3732
|
+
if (!showPublishButton) return null;
|
3463
3733
|
return {
|
3464
3734
|
actionType: "publish",
|
3465
3735
|
variant: "tertiary",
|
@@ -3527,8 +3797,7 @@ const DeleteAction = ({ documents, model }) => {
|
|
3527
3797
|
selectRow([]);
|
3528
3798
|
}
|
3529
3799
|
};
|
3530
|
-
if (!hasDeletePermission)
|
3531
|
-
return null;
|
3800
|
+
if (!hasDeletePermission) return null;
|
3532
3801
|
return {
|
3533
3802
|
variant: "danger-light",
|
3534
3803
|
label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
|
@@ -3577,8 +3846,7 @@ const UnpublishAction = ({ documents, model }) => {
|
|
3577
3846
|
}
|
3578
3847
|
};
|
3579
3848
|
const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
|
3580
|
-
if (!showUnpublishButton)
|
3581
|
-
return null;
|
3849
|
+
if (!showUnpublishButton) return null;
|
3582
3850
|
return {
|
3583
3851
|
variant: "tertiary",
|
3584
3852
|
label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
|
@@ -3683,7 +3951,7 @@ const TableActions = ({ document }) => {
|
|
3683
3951
|
DescriptionComponentRenderer,
|
3684
3952
|
{
|
3685
3953
|
props,
|
3686
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
|
3954
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions("table-row").filter((action) => action.name !== "PublishAction"),
|
3687
3955
|
children: (actions2) => {
|
3688
3956
|
const tableRowActions = actions2.filter((action) => {
|
3689
3957
|
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
@@ -3742,6 +4010,7 @@ const EditAction = ({ documentId }) => {
|
|
3742
4010
|
};
|
3743
4011
|
};
|
3744
4012
|
EditAction.type = "edit";
|
4013
|
+
EditAction.position = "table-row";
|
3745
4014
|
const StyledPencil = styled(Pencil)`
|
3746
4015
|
path {
|
3747
4016
|
fill: currentColor;
|
@@ -3818,6 +4087,7 @@ const CloneAction = ({ model, documentId }) => {
|
|
3818
4087
|
};
|
3819
4088
|
};
|
3820
4089
|
CloneAction.type = "clone";
|
4090
|
+
CloneAction.position = "table-row";
|
3821
4091
|
const StyledDuplicate = styled(Duplicate)`
|
3822
4092
|
path {
|
3823
4093
|
fill: currentColor;
|
@@ -3904,7 +4174,14 @@ class ContentManagerPlugin {
|
|
3904
4174
|
addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
|
3905
4175
|
addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
|
3906
4176
|
getBulkActions: () => this.bulkActions,
|
3907
|
-
getDocumentActions: () =>
|
4177
|
+
getDocumentActions: (position) => {
|
4178
|
+
if (position) {
|
4179
|
+
return this.documentActions.filter(
|
4180
|
+
(action) => action.position == void 0 || [action.position].flat().includes(position)
|
4181
|
+
);
|
4182
|
+
}
|
4183
|
+
return this.documentActions;
|
4184
|
+
},
|
3908
4185
|
getEditViewSidePanels: () => this.editViewSidePanels,
|
3909
4186
|
getHeaderActions: () => this.headerActions
|
3910
4187
|
}
|
@@ -3914,10 +4191,8 @@ class ContentManagerPlugin {
|
|
3914
4191
|
const getPrintableType = (value) => {
|
3915
4192
|
const nativeType = typeof value;
|
3916
4193
|
if (nativeType === "object") {
|
3917
|
-
if (value === null)
|
3918
|
-
|
3919
|
-
if (Array.isArray(value))
|
3920
|
-
return "array";
|
4194
|
+
if (value === null) return "null";
|
4195
|
+
if (Array.isArray(value)) return "array";
|
3921
4196
|
if (value instanceof Object && value.constructor.name !== "Object") {
|
3922
4197
|
return value.constructor.name;
|
3923
4198
|
}
|
@@ -3970,6 +4245,7 @@ const HistoryAction = ({ model, document }) => {
|
|
3970
4245
|
};
|
3971
4246
|
};
|
3972
4247
|
HistoryAction.type = "history";
|
4248
|
+
HistoryAction.position = "header";
|
3973
4249
|
const historyAdmin = {
|
3974
4250
|
bootstrap(app) {
|
3975
4251
|
const { addDocumentAction } = app.getPlugin("content-manager").apis;
|
@@ -4032,11 +4308,18 @@ const previewApi = contentManagerApi.injectEndpoints({
|
|
4032
4308
|
})
|
4033
4309
|
});
|
4034
4310
|
const { useGetPreviewUrlQuery } = previewApi;
|
4311
|
+
const ConditionalTooltip = ({ isShown, label, children }) => {
|
4312
|
+
if (isShown) {
|
4313
|
+
return /* @__PURE__ */ jsx(Tooltip, { label, children });
|
4314
|
+
}
|
4315
|
+
return children;
|
4316
|
+
};
|
4035
4317
|
const PreviewSidePanel = ({ model, documentId, document }) => {
|
4036
4318
|
const { formatMessage } = useIntl();
|
4037
4319
|
const { trackUsage } = useTracking();
|
4038
4320
|
const { pathname } = useLocation();
|
4039
4321
|
const [{ query }] = useQueryParams();
|
4322
|
+
const isModified = useForm("PreviewSidePanel", (state) => state.modified);
|
4040
4323
|
const { data, error } = useGetPreviewUrlQuery({
|
4041
4324
|
params: {
|
4042
4325
|
contentType: model
|
@@ -4056,28 +4339,37 @@ const PreviewSidePanel = ({ model, documentId, document }) => {
|
|
4056
4339
|
};
|
4057
4340
|
return {
|
4058
4341
|
title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
|
4059
|
-
content: /* @__PURE__ */ jsx(
|
4060
|
-
|
4342
|
+
content: /* @__PURE__ */ jsx(
|
4343
|
+
ConditionalTooltip,
|
4061
4344
|
{
|
4062
|
-
|
4063
|
-
|
4064
|
-
|
4065
|
-
|
4066
|
-
|
4067
|
-
children:
|
4068
|
-
|
4069
|
-
|
4070
|
-
|
4345
|
+
label: formatMessage({
|
4346
|
+
id: "content-manager.preview.panel.button-disabled-tooltip",
|
4347
|
+
defaultMessage: "Please save to open the preview"
|
4348
|
+
}),
|
4349
|
+
isShown: isModified,
|
4350
|
+
children: /* @__PURE__ */ jsx(Box, { cursor: "not-allowed", width: "100%", children: /* @__PURE__ */ jsx(
|
4351
|
+
Button,
|
4352
|
+
{
|
4353
|
+
variant: "tertiary",
|
4354
|
+
tag: Link,
|
4355
|
+
to: { pathname: "preview", search: stringify(query, { encode: false }) },
|
4356
|
+
onClick: trackNavigation,
|
4357
|
+
width: "100%",
|
4358
|
+
disabled: isModified,
|
4359
|
+
pointerEvents: isModified ? "none" : void 0,
|
4360
|
+
tabIndex: isModified ? -1 : void 0,
|
4361
|
+
children: formatMessage({
|
4362
|
+
id: "content-manager.preview.panel.button",
|
4363
|
+
defaultMessage: "Open preview"
|
4364
|
+
})
|
4365
|
+
}
|
4366
|
+
) })
|
4071
4367
|
}
|
4072
|
-
)
|
4368
|
+
)
|
4073
4369
|
};
|
4074
4370
|
};
|
4075
|
-
const FEATURE_ID = "preview";
|
4076
4371
|
const previewAdmin = {
|
4077
4372
|
bootstrap(app) {
|
4078
|
-
if (!window.strapi.future.isEnabled(FEATURE_ID)) {
|
4079
|
-
return;
|
4080
|
-
}
|
4081
4373
|
const contentManagerPluginApis = app.getPlugin("content-manager").apis;
|
4082
4374
|
contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
|
4083
4375
|
}
|
@@ -4101,7 +4393,7 @@ const index = {
|
|
4101
4393
|
app.router.addRoute({
|
4102
4394
|
path: "content-manager/*",
|
4103
4395
|
lazy: async () => {
|
4104
|
-
const { Layout } = await import("./layout-
|
4396
|
+
const { Layout } = await import("./layout-CxDMdJ13.mjs");
|
4105
4397
|
return {
|
4106
4398
|
Component: Layout
|
4107
4399
|
};
|
@@ -4121,7 +4413,7 @@ const index = {
|
|
4121
4413
|
async registerTrads({ locales }) {
|
4122
4414
|
const importedTrads = await Promise.all(
|
4123
4415
|
locales.map((locale) => {
|
4124
|
-
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-
|
4416
|
+
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-D65uIF6Y.mjs"), "./translations/es.json": () => import("./es-D34tqjMw.mjs"), "./translations/eu.json": () => import("./eu-CdALomew.mjs"), "./translations/fr.json": () => import("./fr-DBseuRuB.mjs"), "./translations/gu.json": () => import("./gu-CNpaMDpH.mjs"), "./translations/hi.json": () => import("./hi-Dwvd04m3.mjs"), "./translations/hu.json": () => import("./hu-CeYvaaO0.mjs"), "./translations/id.json": () => import("./id-BtwA9WJT.mjs"), "./translations/it.json": () => import("./it-BrVPqaf1.mjs"), "./translations/ja.json": () => import("./ja-BHqhDq4V.mjs"), "./translations/ko.json": () => import("./ko-HVQRlfUI.mjs"), "./translations/ml.json": () => import("./ml-BihZwQit.mjs"), "./translations/ms.json": () => import("./ms-m_WjyWx7.mjs"), "./translations/nl.json": () => import("./nl-D4R9gHx5.mjs"), "./translations/pl.json": () => import("./pl-sbx9mSt_.mjs"), "./translations/pt-BR.json": () => import("./pt-BR-C71iDxnh.mjs"), "./translations/pt.json": () => import("./pt-BsaFvS8-.mjs"), "./translations/ru.json": () => import("./ru-BE6A4Exp.mjs"), "./translations/sa.json": () => import("./sa-Dag0k-Z8.mjs"), "./translations/sk.json": () => import("./sk-BFg-R8qJ.mjs"), "./translations/sv.json": () => import("./sv-CUnfWGsh.mjs"), "./translations/th.json": () => import("./th-BqbI8lIT.mjs"), "./translations/tr.json": () => import("./tr-CgeK3wJM.mjs"), "./translations/uk.json": () => import("./uk-CR-zDhAY.mjs"), "./translations/vi.json": () => import("./vi-DUXIk_fw.mjs"), "./translations/zh-Hans.json": () => import("./zh-Hans-BPQcRIyH.mjs"), "./translations/zh.json": () => import("./zh-BWZspA60.mjs") }), `./translations/${locale}.json`, 3).then(({ default: data }) => {
|
4125
4417
|
return {
|
4126
4418
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
4127
4419
|
locale
|
@@ -4138,24 +4430,27 @@ const index = {
|
|
4138
4430
|
}
|
4139
4431
|
};
|
4140
4432
|
export {
|
4141
|
-
|
4433
|
+
useUpdateContentTypeConfigurationMutation as A,
|
4142
4434
|
BulkActionsRenderer as B,
|
4143
4435
|
COLLECTION_TYPES as C,
|
4144
4436
|
DocumentStatus as D,
|
4145
|
-
|
4146
|
-
|
4147
|
-
|
4437
|
+
ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD as E,
|
4438
|
+
extractContentTypeComponents as F,
|
4439
|
+
DEFAULT_SETTINGS as G,
|
4148
4440
|
HOOKS as H,
|
4149
4441
|
InjectionZone as I,
|
4150
|
-
|
4151
|
-
|
4152
|
-
|
4153
|
-
|
4154
|
-
|
4442
|
+
convertEditLayoutToFieldLayouts as J,
|
4443
|
+
removeFieldsThatDontExistOnSchema as K,
|
4444
|
+
prepareTempKeys as L,
|
4445
|
+
useDocument as M,
|
4446
|
+
useGetPreviewUrlQuery as N,
|
4447
|
+
index as O,
|
4155
4448
|
Panels as P,
|
4449
|
+
useContentManagerContext as Q,
|
4156
4450
|
RelativeTime as R,
|
4157
4451
|
SINGLE_TYPES as S,
|
4158
4452
|
TableActions as T,
|
4453
|
+
useDocumentActions as U,
|
4159
4454
|
useGetInitialDataQuery as a,
|
4160
4455
|
useGetAllContentTypeSettingsQuery as b,
|
4161
4456
|
useDoc as c,
|
@@ -4168,19 +4463,19 @@ export {
|
|
4168
4463
|
Header as j,
|
4169
4464
|
PERMISSIONS as k,
|
4170
4465
|
DocumentRBAC as l,
|
4171
|
-
|
4172
|
-
|
4173
|
-
|
4466
|
+
useDocLayout as m,
|
4467
|
+
createDefaultForm as n,
|
4468
|
+
CLONE_PATH as o,
|
4174
4469
|
useGetContentTypeConfigurationQuery as p,
|
4175
4470
|
CREATOR_FIELDS as q,
|
4176
4471
|
getMainField as r,
|
4177
4472
|
setInitialData as s,
|
4178
|
-
|
4473
|
+
transformDocument as t,
|
4179
4474
|
useContentTypeSchema as u,
|
4180
|
-
|
4181
|
-
|
4182
|
-
|
4183
|
-
|
4184
|
-
|
4475
|
+
getDisplayName as v,
|
4476
|
+
checkIfAttributeIsDisplayable as w,
|
4477
|
+
useGetAllDocumentsQuery as x,
|
4478
|
+
convertListLayoutToFieldLayouts as y,
|
4479
|
+
capitalise as z
|
4185
4480
|
};
|
4186
|
-
//# sourceMappingURL=index-
|
4481
|
+
//# sourceMappingURL=index-EH8ZtHd5.mjs.map
|