@strapi/content-manager 0.0.0-experimental.a65a85fdea97faae8679d3ffc5f9d79af61abd26 → 0.0.0-experimental.bd712ad3930045f4a5d2144c119e0b7856e97fc4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +18 -3
- package/dist/_chunks/{CardDragPreview-DSVYodBX.js → CardDragPreview-C0QyJgRA.js} +10 -14
- package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -0
- package/dist/_chunks/{CardDragPreview-ikSG4M46.mjs → CardDragPreview-DOxamsuj.mjs} +7 -9
- package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -0
- package/dist/_chunks/{ComponentConfigurationPage-43KmCNQE.js → ComponentConfigurationPage-BWQv6yRj.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-43KmCNQE.js.map → ComponentConfigurationPage-BWQv6yRj.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage--2aLCv-G.mjs → ComponentConfigurationPage-C7ImeKGM.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage--2aLCv-G.mjs.map → ComponentConfigurationPage-C7ImeKGM.mjs.map} +1 -1
- package/dist/_chunks/{ComponentIcon-BBQsYCVn.js → ComponentIcon-BXdiCGQp.js} +8 -2
- package/dist/_chunks/ComponentIcon-BXdiCGQp.js.map +1 -0
- package/dist/_chunks/{ComponentIcon-BOFnK76n.mjs → ComponentIcon-u4bIXTFY.mjs} +9 -3
- package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -0
- package/dist/_chunks/{EditConfigurationPage-BfFzJ4Br.js → EditConfigurationPage-CEGwxV-L.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-BfFzJ4Br.js.map → EditConfigurationPage-CEGwxV-L.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CUcGHHvQ.mjs → EditConfigurationPage-MItFGzT9.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-CUcGHHvQ.mjs.map → EditConfigurationPage-MItFGzT9.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-CzOT5Kpj.js → EditViewPage-CmMi2Xsn.js} +46 -48
- package/dist/_chunks/EditViewPage-CmMi2Xsn.js.map +1 -0
- package/dist/_chunks/{EditViewPage-Bm8lgcm6.mjs → EditViewPage-DhmAg0NK.mjs} +47 -47
- package/dist/_chunks/EditViewPage-DhmAg0NK.mjs.map +1 -0
- package/dist/_chunks/{Field-Caef4JjM.js → Field-1DLtcLAI.js} +948 -777
- package/dist/_chunks/Field-1DLtcLAI.js.map +1 -0
- package/dist/_chunks/{Field-Dlh0uGnL.mjs → Field-Cs62u5pl.mjs} +896 -724
- package/dist/_chunks/Field-Cs62u5pl.mjs.map +1 -0
- package/dist/_chunks/{Form-BzuAjtRq.js → Form-CqFA7F_V.js} +42 -41
- package/dist/_chunks/Form-CqFA7F_V.js.map +1 -0
- package/dist/_chunks/{Form-EnaQL_6L.mjs → Form-zYHtzGUX.mjs} +43 -41
- package/dist/_chunks/Form-zYHtzGUX.mjs.map +1 -0
- package/dist/_chunks/{History-C17LiyRg.js → History-BblwXv7-.js} +149 -66
- package/dist/_chunks/History-BblwXv7-.js.map +1 -0
- package/dist/_chunks/{History-D6sbCJvo.mjs → History-DalgFQ3D.mjs} +149 -65
- package/dist/_chunks/History-DalgFQ3D.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-Dks5SX6f.js → ListConfigurationPage-Cpy4QqNd.js} +61 -62
- package/dist/_chunks/ListConfigurationPage-Cpy4QqNd.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-Ce4qs7qE.mjs → ListConfigurationPage-DWy-vRzs.mjs} +58 -58
- package/dist/_chunks/ListConfigurationPage-DWy-vRzs.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-Be7S5aKL.mjs → ListViewPage-BkAwIW9s.mjs} +90 -106
- package/dist/_chunks/ListViewPage-BkAwIW9s.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-BwrZrPsh.js → ListViewPage-DFjn1DNW.js} +95 -111
- package/dist/_chunks/ListViewPage-DFjn1DNW.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-CIPmYQMm.mjs → NoContentTypePage-B9BCNNdL.mjs} +7 -7
- package/dist/_chunks/NoContentTypePage-B9BCNNdL.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-Cu5r1-JT.js → NoContentTypePage-C-3ykoxs.js} +5 -5
- package/dist/_chunks/NoContentTypePage-C-3ykoxs.js.map +1 -0
- package/dist/_chunks/{NoPermissionsPage-DhJ7LYrr.mjs → NoPermissionsPage-Bt_HWGat.mjs} +5 -6
- package/dist/_chunks/NoPermissionsPage-Bt_HWGat.mjs.map +1 -0
- package/dist/_chunks/{NoPermissionsPage-C-j6TEUF.js → NoPermissionsPage-DKLmDZnZ.js} +4 -5
- package/dist/_chunks/NoPermissionsPage-DKLmDZnZ.js.map +1 -0
- package/dist/_chunks/{Relations-CY7AtkDA.mjs → Relations-CJmTbZ8T.mjs} +66 -56
- package/dist/_chunks/Relations-CJmTbZ8T.mjs.map +1 -0
- package/dist/_chunks/{Relations-Czs-uZ-s.js → Relations-CrxfoH2n.js} +70 -61
- package/dist/_chunks/Relations-CrxfoH2n.js.map +1 -0
- package/dist/_chunks/{en-MBPul9Su.mjs → en-Ux26r5pl.mjs} +7 -1
- package/dist/_chunks/{en-MBPul9Su.mjs.map → en-Ux26r5pl.mjs.map} +1 -1
- package/dist/_chunks/{en-C-V1_90f.js → en-fbKQxLGn.js} +7 -1
- package/dist/_chunks/{en-C-V1_90f.js.map → en-fbKQxLGn.js.map} +1 -1
- package/dist/_chunks/{index-X_2tafck.js → index-Buwn78Rt.js} +1507 -868
- package/dist/_chunks/index-Buwn78Rt.js.map +1 -0
- package/dist/_chunks/{index-DNVx8ssZ.mjs → index-D1344xdw.mjs} +1476 -836
- package/dist/_chunks/index-D1344xdw.mjs.map +1 -0
- package/dist/_chunks/{layout-Dnh0PNp9.mjs → layout-ChVuUpa1.mjs} +32 -27
- package/dist/_chunks/layout-ChVuUpa1.mjs.map +1 -0
- package/dist/_chunks/{layout-dBc7wN7L.js → layout-DRuJUpas.js} +32 -29
- package/dist/_chunks/layout-DRuJUpas.js.map +1 -0
- package/dist/_chunks/{relations-Dx7tMKJN.mjs → relations-B-deMCy4.mjs} +2 -2
- package/dist/_chunks/{relations-Dx7tMKJN.mjs.map → relations-B-deMCy4.mjs.map} +1 -1
- package/dist/_chunks/{relations-4pHtBrHJ.js → relations-DuoUwyJr.js} +2 -2
- package/dist/_chunks/{relations-4pHtBrHJ.js.map → relations-DuoUwyJr.js.map} +1 -1
- package/dist/_chunks/useDragAndDrop-DdHgKsqq.mjs.map +1 -1
- package/dist/_chunks/useDragAndDrop-J0TUUbR6.js.map +1 -1
- package/dist/_chunks/usePrev-B9w_-eYc.js +15 -0
- 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 +5 -4
- package/dist/admin/src/components/ComponentIcon.d.ts +6 -3
- package/dist/admin/src/content-manager.d.ts +3 -3
- package/dist/admin/src/exports.d.ts +1 -0
- package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +5 -8
- package/dist/admin/src/hooks/useDocumentActions.d.ts +24 -3
- package/dist/admin/src/hooks/useDocumentLayout.d.ts +2 -2
- package/dist/admin/src/hooks/useDragAndDrop.d.ts +4 -4
- package/dist/admin/src/hooks/useKeyboardDragAndDrop.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +10 -4
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.d.ts +3 -3
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Component/Input.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.d.ts +3 -5
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +10 -18
- package/dist/admin/src/pages/EditView/components/FormInputs/UID.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +3 -49
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Field.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +59 -52
- package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +2 -10
- package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
- package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
- package/dist/admin/src/pages/ListView/components/BulkActions/PublishAction.d.ts +9 -26
- package/dist/admin/src/services/api.d.ts +2 -3
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +5 -5
- package/dist/admin/src/services/documents.d.ts +29 -17
- package/dist/admin/src/services/init.d.ts +2 -2
- package/dist/admin/src/services/relations.d.ts +3 -3
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/admin/src/utils/api.d.ts +4 -18
- package/dist/admin/src/utils/validation.d.ts +1 -6
- package/dist/server/index.js +547 -416
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +555 -424
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/single-types.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +8 -0
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -0
- package/dist/server/src/controllers/validation/dimensions.d.ts +9 -0
- package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -0
- package/dist/server/src/controllers/validation/index.d.ts +1 -1
- package/dist/server/src/history/services/history.d.ts +2 -4
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/index.d.ts +6 -2
- package/dist/server/src/history/services/index.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts +9 -0
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -0
- package/dist/server/src/history/services/utils.d.ts +41 -9
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/history/utils.d.ts +6 -2
- package/dist/server/src/history/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +18 -39
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts +13 -12
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +8 -29
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +18 -39
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/utils/populate.d.ts +8 -1
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/dist/shared/contracts/collection-types.d.ts +14 -6
- package/dist/shared/contracts/collection-types.d.ts.map +1 -1
- package/dist/shared/contracts/relations.d.ts +2 -2
- package/dist/shared/contracts/relations.d.ts.map +1 -1
- package/package.json +13 -14
- package/dist/_chunks/CardDragPreview-DSVYodBX.js.map +0 -1
- package/dist/_chunks/CardDragPreview-ikSG4M46.mjs.map +0 -1
- package/dist/_chunks/ComponentIcon-BBQsYCVn.js.map +0 -1
- package/dist/_chunks/ComponentIcon-BOFnK76n.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-Bm8lgcm6.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-CzOT5Kpj.js.map +0 -1
- package/dist/_chunks/Field-Caef4JjM.js.map +0 -1
- package/dist/_chunks/Field-Dlh0uGnL.mjs.map +0 -1
- package/dist/_chunks/Form-BzuAjtRq.js.map +0 -1
- package/dist/_chunks/Form-EnaQL_6L.mjs.map +0 -1
- package/dist/_chunks/History-C17LiyRg.js.map +0 -1
- package/dist/_chunks/History-D6sbCJvo.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-Ce4qs7qE.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-Dks5SX6f.js.map +0 -1
- package/dist/_chunks/ListViewPage-Be7S5aKL.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-BwrZrPsh.js.map +0 -1
- package/dist/_chunks/NoContentTypePage-CIPmYQMm.mjs.map +0 -1
- package/dist/_chunks/NoContentTypePage-Cu5r1-JT.js.map +0 -1
- package/dist/_chunks/NoPermissionsPage-C-j6TEUF.js.map +0 -1
- package/dist/_chunks/NoPermissionsPage-DhJ7LYrr.mjs.map +0 -1
- package/dist/_chunks/Relations-CY7AtkDA.mjs.map +0 -1
- package/dist/_chunks/Relations-Czs-uZ-s.js.map +0 -1
- package/dist/_chunks/index-DNVx8ssZ.mjs.map +0 -1
- package/dist/_chunks/index-X_2tafck.js.map +0 -1
- package/dist/_chunks/layout-Dnh0PNp9.mjs.map +0 -1
- package/dist/_chunks/layout-dBc7wN7L.js.map +0 -1
- package/dist/_chunks/urls-CbOsUOoW.mjs +0 -7
- package/dist/_chunks/urls-CbOsUOoW.mjs.map +0 -1
- package/dist/_chunks/urls-DzZya_gm.js +0 -6
- package/dist/_chunks/urls-DzZya_gm.js.map +0 -1
- package/dist/server/src/controllers/utils/dimensions.d.ts +0 -5
- package/dist/server/src/controllers/utils/dimensions.d.ts.map +0 -1
@@ -1,17 +1,15 @@
|
|
1
|
-
import { ClockCounterClockwise, CrossCircle, More, WarningCircle,
|
1
|
+
import { ClockCounterClockwise, CrossCircle, More, WarningCircle, ListPlus, Pencil, Trash, Check, CheckCircle, ArrowsCounterClockwise, ChevronRight, Duplicate, Feather } from "@strapi/icons";
|
2
2
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
3
|
-
import { useStrapiApp, useQueryParams, createContext, useAuth, useRBAC, Page,
|
3
|
+
import { useStrapiApp, useQueryParams, createContext, useAuth, useRBAC, Page, adminApi, translatedErrors, useNotification, useAPIErrorHandler, getYupValidationErrors, useTracking, useForm, BackButton, DescriptionComponentRenderer, useTable, Table } from "@strapi/admin/strapi-admin";
|
4
4
|
import { stringify } from "qs";
|
5
5
|
import { useIntl } from "react-intl";
|
6
|
-
import { useNavigate, useParams, Navigate, useMatch, NavLink } from "react-router-dom";
|
6
|
+
import { useNavigate, useParams, Navigate, useMatch, useLocation, Link, NavLink } from "react-router-dom";
|
7
7
|
import * as React from "react";
|
8
8
|
import { lazy } from "react";
|
9
|
-
import { Menu, VisuallyHidden, Flex, Typography, Dialog,
|
10
|
-
import styled from "styled-components";
|
9
|
+
import { Button, Menu, VisuallyHidden, Flex, Box, Typography, Dialog, Modal, Radio, Status, SingleSelect, SingleSelectOption, Loader, IconButton, Tooltip, LinkButton } from "@strapi/design-system";
|
10
|
+
import { styled } from "styled-components";
|
11
11
|
import * as yup from "yup";
|
12
12
|
import { ValidationError } from "yup";
|
13
|
-
import { createApi } from "@reduxjs/toolkit/query/react";
|
14
|
-
import { isAxiosError } from "axios";
|
15
13
|
import pipe from "lodash/fp/pipe";
|
16
14
|
import { intervalToDuration, isPast } from "date-fns";
|
17
15
|
import { createSlice, combineReducers } from "@reduxjs/toolkit";
|
@@ -157,9 +155,8 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
157
155
|
const name = removeNumericalStrings(fieldName.split("."));
|
158
156
|
const componentFieldNames = fieldsUserCanAction.filter((field) => field.split(".").length > 1);
|
159
157
|
if (fieldType === "component") {
|
160
|
-
|
161
|
-
|
162
|
-
return field.includes(fieldName);
|
158
|
+
return componentFieldNames.some((field) => {
|
159
|
+
return field.includes(name.join("."));
|
163
160
|
});
|
164
161
|
}
|
165
162
|
if (name.length > 1) {
|
@@ -189,78 +186,8 @@ const extractAndDedupeFields = (permissions = []) => permissions.flatMap((permis
|
|
189
186
|
(field, index2, arr) => arr.indexOf(field) === index2 && typeof field === "string"
|
190
187
|
);
|
191
188
|
const removeNumericalStrings = (arr) => arr.filter((item) => isNaN(Number(item)));
|
192
|
-
const
|
193
|
-
|
194
|
-
return query;
|
195
|
-
const { plugins: _, ...validQueryParams } = {
|
196
|
-
...query,
|
197
|
-
...Object.values(query?.plugins ?? {}).reduce(
|
198
|
-
(acc, current) => Object.assign(acc, current),
|
199
|
-
{}
|
200
|
-
)
|
201
|
-
};
|
202
|
-
if ("_q" in validQueryParams) {
|
203
|
-
validQueryParams._q = encodeURIComponent(validQueryParams._q);
|
204
|
-
}
|
205
|
-
return validQueryParams;
|
206
|
-
};
|
207
|
-
const axiosBaseQuery = () => async (query, { signal }) => {
|
208
|
-
try {
|
209
|
-
const { get, post, del, put } = getFetchClient();
|
210
|
-
if (typeof query === "string") {
|
211
|
-
const result = await get(query, { signal });
|
212
|
-
return { data: result.data };
|
213
|
-
} else {
|
214
|
-
const { url, method = "GET", data, config } = query;
|
215
|
-
if (method === "POST") {
|
216
|
-
const result2 = await post(url, data, { ...config, signal });
|
217
|
-
return { data: result2.data };
|
218
|
-
}
|
219
|
-
if (method === "DELETE") {
|
220
|
-
const result2 = await del(url, { ...config, signal });
|
221
|
-
return { data: result2.data };
|
222
|
-
}
|
223
|
-
if (method === "PUT") {
|
224
|
-
const result2 = await put(url, data, { ...config, signal });
|
225
|
-
return { data: result2.data };
|
226
|
-
}
|
227
|
-
const result = await get(url, { ...config, signal });
|
228
|
-
return { data: result.data };
|
229
|
-
}
|
230
|
-
} catch (err) {
|
231
|
-
if (isAxiosError(err)) {
|
232
|
-
if (typeof err.response?.data === "object" && err.response?.data !== null && "error" in err.response?.data) {
|
233
|
-
return { data: void 0, error: err.response?.data.error };
|
234
|
-
} else {
|
235
|
-
return {
|
236
|
-
data: void 0,
|
237
|
-
error: {
|
238
|
-
name: "UnknownError",
|
239
|
-
message: "There was an unknown error response from the API",
|
240
|
-
details: err.response?.data,
|
241
|
-
status: err.response?.status
|
242
|
-
}
|
243
|
-
};
|
244
|
-
}
|
245
|
-
}
|
246
|
-
const error = err;
|
247
|
-
return {
|
248
|
-
data: void 0,
|
249
|
-
error: {
|
250
|
-
name: error.name,
|
251
|
-
message: error.message,
|
252
|
-
stack: error.stack
|
253
|
-
}
|
254
|
-
};
|
255
|
-
}
|
256
|
-
};
|
257
|
-
const isBaseQueryError = (error) => {
|
258
|
-
return error.name !== void 0;
|
259
|
-
};
|
260
|
-
const contentManagerApi = createApi({
|
261
|
-
reducerPath: "contentManagerApi",
|
262
|
-
baseQuery: axiosBaseQuery(),
|
263
|
-
tagTypes: [
|
189
|
+
const contentManagerApi = adminApi.enhanceEndpoints({
|
190
|
+
addTagTypes: [
|
264
191
|
"ComponentConfiguration",
|
265
192
|
"ContentTypesConfiguration",
|
266
193
|
"ContentTypeSettings",
|
@@ -268,10 +195,10 @@ const contentManagerApi = createApi({
|
|
268
195
|
"InitialData",
|
269
196
|
"HistoryVersion",
|
270
197
|
"Relations"
|
271
|
-
]
|
272
|
-
endpoints: () => ({})
|
198
|
+
]
|
273
199
|
});
|
274
200
|
const documentApi = contentManagerApi.injectEndpoints({
|
201
|
+
overrideExisting: true,
|
275
202
|
endpoints: (builder) => ({
|
276
203
|
autoCloneDocument: builder.mutation({
|
277
204
|
query: ({ model, sourceId, query }) => ({
|
@@ -325,12 +252,15 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
325
252
|
]
|
326
253
|
}),
|
327
254
|
deleteManyDocuments: builder.mutation({
|
328
|
-
query: ({ model, ...body }) => ({
|
255
|
+
query: ({ model, params, ...body }) => ({
|
329
256
|
url: `/content-manager/collection-types/${model}/actions/bulkDelete`,
|
330
257
|
method: "POST",
|
331
|
-
data: body
|
258
|
+
data: body,
|
259
|
+
config: {
|
260
|
+
params
|
261
|
+
}
|
332
262
|
}),
|
333
|
-
invalidatesTags: (_res, _error, { model
|
263
|
+
invalidatesTags: (_res, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
|
334
264
|
}),
|
335
265
|
discardDocument: builder.mutation({
|
336
266
|
query: ({ collectionType, model, documentId, params }) => ({
|
@@ -441,10 +371,13 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
441
371
|
}
|
442
372
|
}),
|
443
373
|
publishManyDocuments: builder.mutation({
|
444
|
-
query: ({ model, ...body }) => ({
|
374
|
+
query: ({ model, params, ...body }) => ({
|
445
375
|
url: `/content-manager/collection-types/${model}/actions/bulkPublish`,
|
446
376
|
method: "POST",
|
447
|
-
data: body
|
377
|
+
data: body,
|
378
|
+
config: {
|
379
|
+
params
|
380
|
+
}
|
448
381
|
}),
|
449
382
|
invalidatesTags: (_res, _error, { model, documentIds }) => documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` }))
|
450
383
|
}),
|
@@ -486,10 +419,13 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
486
419
|
}
|
487
420
|
}),
|
488
421
|
unpublishManyDocuments: builder.mutation({
|
489
|
-
query: ({ model, ...body }) => ({
|
422
|
+
query: ({ model, params, ...body }) => ({
|
490
423
|
url: `/content-manager/collection-types/${model}/actions/bulkUnpublish`,
|
491
424
|
method: "POST",
|
492
|
-
data: body
|
425
|
+
data: body,
|
426
|
+
config: {
|
427
|
+
params
|
428
|
+
}
|
493
429
|
}),
|
494
430
|
invalidatesTags: (_res, _error, { model, documentIds }) => documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` }))
|
495
431
|
})
|
@@ -513,6 +449,24 @@ const {
|
|
513
449
|
useUnpublishDocumentMutation,
|
514
450
|
useUnpublishManyDocumentsMutation
|
515
451
|
} = documentApi;
|
452
|
+
const buildValidParams = (query) => {
|
453
|
+
if (!query)
|
454
|
+
return query;
|
455
|
+
const { plugins: _, ...validQueryParams } = {
|
456
|
+
...query,
|
457
|
+
...Object.values(query?.plugins ?? {}).reduce(
|
458
|
+
(acc, current) => Object.assign(acc, current),
|
459
|
+
{}
|
460
|
+
)
|
461
|
+
};
|
462
|
+
if ("_q" in validQueryParams) {
|
463
|
+
validQueryParams._q = encodeURIComponent(validQueryParams._q);
|
464
|
+
}
|
465
|
+
return validQueryParams;
|
466
|
+
};
|
467
|
+
const isBaseQueryError = (error) => {
|
468
|
+
return error.name !== void 0;
|
469
|
+
};
|
516
470
|
const createYupSchema = (attributes = {}, components = {}) => {
|
517
471
|
const createModelSchema = (attributes2) => yup.object().shape(
|
518
472
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
@@ -552,10 +506,14 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
552
506
|
yup.array().of(
|
553
507
|
yup.lazy(
|
554
508
|
(data) => {
|
555
|
-
const
|
556
|
-
|
509
|
+
const attributes3 = components?.[data?.__component]?.attributes;
|
510
|
+
const validation = yup.object().shape({
|
557
511
|
__component: yup.string().required().oneOf(Object.keys(components))
|
558
|
-
}).nullable(false)
|
512
|
+
}).nullable(false);
|
513
|
+
if (!attributes3) {
|
514
|
+
return validation;
|
515
|
+
}
|
516
|
+
return validation.concat(createModelSchema(attributes3));
|
559
517
|
}
|
560
518
|
)
|
561
519
|
)
|
@@ -565,11 +523,25 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
565
523
|
return {
|
566
524
|
...acc,
|
567
525
|
[name]: transformSchema(
|
568
|
-
yup.
|
569
|
-
|
570
|
-
|
571
|
-
})
|
572
|
-
|
526
|
+
yup.lazy((value) => {
|
527
|
+
if (!value) {
|
528
|
+
return yup.mixed().nullable(true);
|
529
|
+
} else if (Array.isArray(value)) {
|
530
|
+
return yup.array().of(
|
531
|
+
yup.object().shape({
|
532
|
+
id: yup.string().required()
|
533
|
+
})
|
534
|
+
);
|
535
|
+
} else if (typeof value === "object") {
|
536
|
+
return yup.object();
|
537
|
+
} else {
|
538
|
+
return yup.mixed().test(
|
539
|
+
"type-error",
|
540
|
+
"Relation values must be either null, an array of objects with {id} or an object.",
|
541
|
+
() => false
|
542
|
+
);
|
543
|
+
}
|
544
|
+
})
|
573
545
|
)
|
574
546
|
};
|
575
547
|
default:
|
@@ -628,13 +600,18 @@ const createAttributeSchema = (attribute) => {
|
|
628
600
|
}
|
629
601
|
};
|
630
602
|
const addRequiredValidation = (attribute) => (schema) => {
|
631
|
-
if (attribute.required) {
|
632
|
-
return schema.required
|
633
|
-
id: translatedErrors.required.id,
|
634
|
-
defaultMessage: "This field is required."
|
635
|
-
});
|
603
|
+
if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
|
604
|
+
return schema.min(1, translatedErrors.required);
|
636
605
|
}
|
637
|
-
|
606
|
+
if (attribute.required && attribute.type !== "relation") {
|
607
|
+
return schema.required(translatedErrors.required);
|
608
|
+
}
|
609
|
+
return schema?.nullable ? schema.nullable() : (
|
610
|
+
// In some cases '.nullable' will not be available on the schema.
|
611
|
+
// e.g. when the schema has been built using yup.lazy (e.g. for relations).
|
612
|
+
// In these cases we should just return the schema as it is.
|
613
|
+
schema
|
614
|
+
);
|
638
615
|
};
|
639
616
|
const addMinLengthValidation = (attribute) => (schema) => {
|
640
617
|
if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
|
@@ -661,6 +638,28 @@ const addMaxLengthValidation = (attribute) => (schema) => {
|
|
661
638
|
const addMinValidation = (attribute) => (schema) => {
|
662
639
|
if ("min" in attribute) {
|
663
640
|
const min = toInteger(attribute.min);
|
641
|
+
if (attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") {
|
642
|
+
if (!attribute.required && "test" in schema && min) {
|
643
|
+
return schema.test(
|
644
|
+
"custom-min",
|
645
|
+
{
|
646
|
+
...translatedErrors.min,
|
647
|
+
values: {
|
648
|
+
min: attribute.min
|
649
|
+
}
|
650
|
+
},
|
651
|
+
(value) => {
|
652
|
+
if (!value) {
|
653
|
+
return true;
|
654
|
+
}
|
655
|
+
if (Array.isArray(value) && value.length === 0) {
|
656
|
+
return true;
|
657
|
+
}
|
658
|
+
return value.length >= min;
|
659
|
+
}
|
660
|
+
);
|
661
|
+
}
|
662
|
+
}
|
664
663
|
if ("min" in schema && min) {
|
665
664
|
return schema.min(min, {
|
666
665
|
...translatedErrors.min,
|
@@ -706,24 +705,6 @@ const addRegexValidation = (attribute) => (schema) => {
|
|
706
705
|
}
|
707
706
|
return schema;
|
708
707
|
};
|
709
|
-
const extractValuesFromYupError = (errorType, errorParams) => {
|
710
|
-
if (!errorType || !errorParams) {
|
711
|
-
return {};
|
712
|
-
}
|
713
|
-
return {
|
714
|
-
[errorType]: errorParams[errorType]
|
715
|
-
};
|
716
|
-
};
|
717
|
-
const getInnerErrors = (error) => (error?.inner || []).reduce((acc, currentError) => {
|
718
|
-
if (currentError.path) {
|
719
|
-
acc[currentError.path.split("[").join(".").split("]").join("")] = {
|
720
|
-
id: currentError.message,
|
721
|
-
defaultMessage: currentError.message,
|
722
|
-
values: extractValuesFromYupError(currentError?.type, currentError?.params)
|
723
|
-
};
|
724
|
-
}
|
725
|
-
return acc;
|
726
|
-
}, {});
|
727
708
|
const initApi = contentManagerApi.injectEndpoints({
|
728
709
|
endpoints: (builder) => ({
|
729
710
|
getInitialData: builder.query({
|
@@ -737,27 +718,20 @@ const { useGetInitialDataQuery } = initApi;
|
|
737
718
|
const useContentTypeSchema = (model) => {
|
738
719
|
const { toggleNotification } = useNotification();
|
739
720
|
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
740
|
-
const {
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
)
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
error: res.error,
|
755
|
-
components: Object.keys(components2).length === 0 ? void 0 : components2,
|
756
|
-
contentType: contentType2,
|
757
|
-
contentTypes: res.data?.contentTypes ?? []
|
758
|
-
};
|
759
|
-
}
|
760
|
-
});
|
721
|
+
const { data, error, isLoading, isFetching } = useGetInitialDataQuery(void 0);
|
722
|
+
const { components, contentType, contentTypes } = React.useMemo(() => {
|
723
|
+
const contentType2 = data?.contentTypes.find((ct) => ct.uid === model);
|
724
|
+
const componentsByKey = data?.components.reduce((acc, component) => {
|
725
|
+
acc[component.uid] = component;
|
726
|
+
return acc;
|
727
|
+
}, {});
|
728
|
+
const components2 = extractContentTypeComponents(contentType2?.attributes, componentsByKey);
|
729
|
+
return {
|
730
|
+
components: Object.keys(components2).length === 0 ? void 0 : components2,
|
731
|
+
contentType: contentType2,
|
732
|
+
contentTypes: data?.contentTypes ?? []
|
733
|
+
};
|
734
|
+
}, [model, data]);
|
761
735
|
React.useEffect(() => {
|
762
736
|
if (error) {
|
763
737
|
toggleNotification({
|
@@ -812,7 +786,10 @@ const useDocument = (args, opts) => {
|
|
812
786
|
isLoading: isLoadingDocument,
|
813
787
|
isFetching: isFetchingDocument,
|
814
788
|
error
|
815
|
-
} = useGetDocumentQuery(args,
|
789
|
+
} = useGetDocumentQuery(args, {
|
790
|
+
...opts,
|
791
|
+
skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
|
792
|
+
});
|
816
793
|
const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
|
817
794
|
React.useEffect(() => {
|
818
795
|
if (error) {
|
@@ -840,7 +817,7 @@ const useDocument = (args, opts) => {
|
|
840
817
|
return null;
|
841
818
|
} catch (error2) {
|
842
819
|
if (error2 instanceof ValidationError) {
|
843
|
-
return
|
820
|
+
return getYupValidationErrors(error2);
|
844
821
|
}
|
845
822
|
throw error2;
|
846
823
|
}
|
@@ -936,14 +913,53 @@ const useDocumentActions = () => {
|
|
936
913
|
},
|
937
914
|
[trackUsage, deleteDocument, toggleNotification, formatMessage, formatAPIError]
|
938
915
|
);
|
916
|
+
const [deleteManyDocuments] = useDeleteManyDocumentsMutation();
|
917
|
+
const deleteMany = React.useCallback(
|
918
|
+
async ({ model, documentIds, params }) => {
|
919
|
+
try {
|
920
|
+
trackUsage("willBulkDeleteEntries");
|
921
|
+
const res = await deleteManyDocuments({
|
922
|
+
model,
|
923
|
+
documentIds,
|
924
|
+
params
|
925
|
+
});
|
926
|
+
if ("error" in res) {
|
927
|
+
toggleNotification({
|
928
|
+
type: "danger",
|
929
|
+
message: formatAPIError(res.error)
|
930
|
+
});
|
931
|
+
return { error: res.error };
|
932
|
+
}
|
933
|
+
toggleNotification({
|
934
|
+
type: "success",
|
935
|
+
title: formatMessage({
|
936
|
+
id: getTranslation("success.records.delete"),
|
937
|
+
defaultMessage: "Successfully deleted."
|
938
|
+
}),
|
939
|
+
message: ""
|
940
|
+
});
|
941
|
+
trackUsage("didBulkDeleteEntries");
|
942
|
+
return res.data;
|
943
|
+
} catch (err) {
|
944
|
+
toggleNotification({
|
945
|
+
type: "danger",
|
946
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
947
|
+
});
|
948
|
+
trackUsage("didNotBulkDeleteEntries");
|
949
|
+
throw err;
|
950
|
+
}
|
951
|
+
},
|
952
|
+
[trackUsage, deleteManyDocuments, toggleNotification, formatMessage, formatAPIError]
|
953
|
+
);
|
939
954
|
const [discardDocument] = useDiscardDocumentMutation();
|
940
955
|
const discard = React.useCallback(
|
941
|
-
async ({ collectionType, model, documentId }) => {
|
956
|
+
async ({ collectionType, model, documentId, params }) => {
|
942
957
|
try {
|
943
958
|
const res = await discardDocument({
|
944
959
|
collectionType,
|
945
960
|
model,
|
946
|
-
documentId
|
961
|
+
documentId,
|
962
|
+
params
|
947
963
|
});
|
948
964
|
if ("error" in res) {
|
949
965
|
toggleNotification({
|
@@ -1005,6 +1021,43 @@ const useDocumentActions = () => {
|
|
1005
1021
|
},
|
1006
1022
|
[trackUsage, publishDocument, toggleNotification, formatMessage, formatAPIError]
|
1007
1023
|
);
|
1024
|
+
const [publishManyDocuments] = usePublishManyDocumentsMutation();
|
1025
|
+
const publishMany = React.useCallback(
|
1026
|
+
async ({ model, documentIds, params }) => {
|
1027
|
+
try {
|
1028
|
+
const res = await publishManyDocuments({
|
1029
|
+
model,
|
1030
|
+
documentIds,
|
1031
|
+
params
|
1032
|
+
});
|
1033
|
+
if ("error" in res) {
|
1034
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1035
|
+
return { error: res.error };
|
1036
|
+
}
|
1037
|
+
toggleNotification({
|
1038
|
+
type: "success",
|
1039
|
+
message: formatMessage({
|
1040
|
+
id: getTranslation("success.record.publish"),
|
1041
|
+
defaultMessage: "Published document"
|
1042
|
+
})
|
1043
|
+
});
|
1044
|
+
return res.data;
|
1045
|
+
} catch (err) {
|
1046
|
+
toggleNotification({
|
1047
|
+
type: "danger",
|
1048
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1049
|
+
});
|
1050
|
+
throw err;
|
1051
|
+
}
|
1052
|
+
},
|
1053
|
+
[
|
1054
|
+
// trackUsage,
|
1055
|
+
publishManyDocuments,
|
1056
|
+
toggleNotification,
|
1057
|
+
formatMessage,
|
1058
|
+
formatAPIError
|
1059
|
+
]
|
1060
|
+
);
|
1008
1061
|
const [updateDocument] = useUpdateDocumentMutation();
|
1009
1062
|
const update = React.useCallback(
|
1010
1063
|
async ({ collectionType, model, documentId, params }, data, trackerProperty) => {
|
@@ -1079,6 +1132,41 @@ const useDocumentActions = () => {
|
|
1079
1132
|
},
|
1080
1133
|
[trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
|
1081
1134
|
);
|
1135
|
+
const [unpublishManyDocuments] = useUnpublishManyDocumentsMutation();
|
1136
|
+
const unpublishMany = React.useCallback(
|
1137
|
+
async ({ model, documentIds, params }) => {
|
1138
|
+
try {
|
1139
|
+
trackUsage("willBulkUnpublishEntries");
|
1140
|
+
const res = await unpublishManyDocuments({
|
1141
|
+
model,
|
1142
|
+
documentIds,
|
1143
|
+
params
|
1144
|
+
});
|
1145
|
+
if ("error" in res) {
|
1146
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1147
|
+
return { error: res.error };
|
1148
|
+
}
|
1149
|
+
trackUsage("didBulkUnpublishEntries");
|
1150
|
+
toggleNotification({
|
1151
|
+
type: "success",
|
1152
|
+
title: formatMessage({
|
1153
|
+
id: getTranslation("success.records.unpublish"),
|
1154
|
+
defaultMessage: "Successfully unpublished."
|
1155
|
+
}),
|
1156
|
+
message: ""
|
1157
|
+
});
|
1158
|
+
return res.data;
|
1159
|
+
} catch (err) {
|
1160
|
+
toggleNotification({
|
1161
|
+
type: "danger",
|
1162
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1163
|
+
});
|
1164
|
+
trackUsage("didNotBulkUnpublishEntries");
|
1165
|
+
throw err;
|
1166
|
+
}
|
1167
|
+
},
|
1168
|
+
[trackUsage, unpublishManyDocuments, toggleNotification, formatMessage, formatAPIError]
|
1169
|
+
);
|
1082
1170
|
const [createDocument] = useCreateDocumentMutation();
|
1083
1171
|
const create = React.useCallback(
|
1084
1172
|
async ({ model, params }, data, trackerProperty) => {
|
@@ -1192,15 +1280,18 @@ const useDocumentActions = () => {
|
|
1192
1280
|
clone,
|
1193
1281
|
create,
|
1194
1282
|
delete: _delete,
|
1283
|
+
deleteMany,
|
1195
1284
|
discard,
|
1196
1285
|
getDocument,
|
1197
1286
|
publish,
|
1287
|
+
publishMany,
|
1198
1288
|
unpublish,
|
1289
|
+
unpublishMany,
|
1199
1290
|
update
|
1200
1291
|
};
|
1201
1292
|
};
|
1202
1293
|
const ProtectedHistoryPage = lazy(
|
1203
|
-
() => import("./History-
|
1294
|
+
() => import("./History-DalgFQ3D.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1204
1295
|
);
|
1205
1296
|
const routes$1 = [
|
1206
1297
|
{
|
@@ -1213,31 +1304,31 @@ const routes$1 = [
|
|
1213
1304
|
}
|
1214
1305
|
];
|
1215
1306
|
const ProtectedEditViewPage = lazy(
|
1216
|
-
() => import("./EditViewPage-
|
1307
|
+
() => import("./EditViewPage-DhmAg0NK.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1217
1308
|
);
|
1218
1309
|
const ProtectedListViewPage = lazy(
|
1219
|
-
() => import("./ListViewPage-
|
1310
|
+
() => import("./ListViewPage-BkAwIW9s.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1220
1311
|
);
|
1221
1312
|
const ProtectedListConfiguration = lazy(
|
1222
|
-
() => import("./ListConfigurationPage-
|
1313
|
+
() => import("./ListConfigurationPage-DWy-vRzs.mjs").then((mod) => ({
|
1223
1314
|
default: mod.ProtectedListConfiguration
|
1224
1315
|
}))
|
1225
1316
|
);
|
1226
1317
|
const ProtectedEditConfigurationPage = lazy(
|
1227
|
-
() => import("./EditConfigurationPage-
|
1318
|
+
() => import("./EditConfigurationPage-MItFGzT9.mjs").then((mod) => ({
|
1228
1319
|
default: mod.ProtectedEditConfigurationPage
|
1229
1320
|
}))
|
1230
1321
|
);
|
1231
1322
|
const ProtectedComponentConfigurationPage = lazy(
|
1232
|
-
() => import("./ComponentConfigurationPage
|
1323
|
+
() => import("./ComponentConfigurationPage-C7ImeKGM.mjs").then((mod) => ({
|
1233
1324
|
default: mod.ProtectedComponentConfigurationPage
|
1234
1325
|
}))
|
1235
1326
|
);
|
1236
1327
|
const NoPermissions = lazy(
|
1237
|
-
() => import("./NoPermissionsPage-
|
1328
|
+
() => import("./NoPermissionsPage-Bt_HWGat.mjs").then((mod) => ({ default: mod.NoPermissions }))
|
1238
1329
|
);
|
1239
1330
|
const NoContentType = lazy(
|
1240
|
-
() => import("./NoContentTypePage-
|
1331
|
+
() => import("./NoContentTypePage-B9BCNNdL.mjs").then((mod) => ({ default: mod.NoContentType }))
|
1241
1332
|
);
|
1242
1333
|
const CollectionTypePages = () => {
|
1243
1334
|
const { collectionType } = useParams();
|
@@ -1427,7 +1518,7 @@ const DocumentActionsMenu = ({
|
|
1427
1518
|
variant,
|
1428
1519
|
children: [
|
1429
1520
|
/* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
|
1430
|
-
/* @__PURE__ */ jsx(VisuallyHidden, {
|
1521
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { tag: "span", children: label || formatMessage({
|
1431
1522
|
id: "content-manager.containers.edit.panels.default.more-actions",
|
1432
1523
|
defaultMessage: "More document actions"
|
1433
1524
|
}) })
|
@@ -1443,8 +1534,8 @@ const DocumentActionsMenu = ({
|
|
1443
1534
|
onSelect: handleClick(action),
|
1444
1535
|
display: "block",
|
1445
1536
|
children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", gap: 4, children: [
|
1446
|
-
/* @__PURE__ */ jsxs(Flex, { color: convertActionVariantToColor(action.variant), gap: 2,
|
1447
|
-
action.icon,
|
1537
|
+
/* @__PURE__ */ jsxs(Flex, { color: convertActionVariantToColor(action.variant), gap: 2, tag: "span", children: [
|
1538
|
+
/* @__PURE__ */ jsx(Box, { tag: "span", color: convertActionVariantToIconColor(action.variant), children: action.icon }),
|
1448
1539
|
action.label
|
1449
1540
|
] }),
|
1450
1541
|
action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsx(
|
@@ -1505,6 +1596,18 @@ const convertActionVariantToColor = (variant = "secondary") => {
|
|
1505
1596
|
return "primary600";
|
1506
1597
|
}
|
1507
1598
|
};
|
1599
|
+
const convertActionVariantToIconColor = (variant = "secondary") => {
|
1600
|
+
switch (variant) {
|
1601
|
+
case "danger":
|
1602
|
+
return "danger600";
|
1603
|
+
case "secondary":
|
1604
|
+
return "neutral500";
|
1605
|
+
case "success":
|
1606
|
+
return "success600";
|
1607
|
+
default:
|
1608
|
+
return "primary600";
|
1609
|
+
}
|
1610
|
+
};
|
1508
1611
|
const DocumentActionConfirmDialog = ({
|
1509
1612
|
onClose,
|
1510
1613
|
onCancel,
|
@@ -1527,61 +1630,42 @@ const DocumentActionConfirmDialog = ({
|
|
1527
1630
|
}
|
1528
1631
|
onClose();
|
1529
1632
|
};
|
1530
|
-
return /* @__PURE__ */
|
1531
|
-
/* @__PURE__ */ jsx(
|
1532
|
-
/* @__PURE__ */ jsx(
|
1533
|
-
|
1534
|
-
{
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
)
|
1545
|
-
] });
|
1633
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
1634
|
+
/* @__PURE__ */ jsx(Dialog.Header, { children: title }),
|
1635
|
+
/* @__PURE__ */ jsx(Dialog.Body, { children: content }),
|
1636
|
+
/* @__PURE__ */ jsxs(Dialog.Footer, { children: [
|
1637
|
+
/* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: formatMessage({
|
1638
|
+
id: "app.components.Button.cancel",
|
1639
|
+
defaultMessage: "Cancel"
|
1640
|
+
}) }) }),
|
1641
|
+
/* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, children: formatMessage({
|
1642
|
+
id: "app.components.Button.confirm",
|
1643
|
+
defaultMessage: "Confirm"
|
1644
|
+
}) })
|
1645
|
+
] })
|
1646
|
+
] }) });
|
1546
1647
|
};
|
1547
1648
|
const DocumentActionModal = ({
|
1548
1649
|
isOpen,
|
1549
1650
|
title,
|
1550
1651
|
onClose,
|
1551
1652
|
footer: Footer,
|
1552
|
-
content,
|
1653
|
+
content: Content,
|
1553
1654
|
onModalClose
|
1554
1655
|
}) => {
|
1555
|
-
const id = React.useId();
|
1556
|
-
if (!isOpen) {
|
1557
|
-
return null;
|
1558
|
-
}
|
1559
1656
|
const handleClose = () => {
|
1560
1657
|
if (onClose) {
|
1561
1658
|
onClose();
|
1562
1659
|
}
|
1563
1660
|
onModalClose();
|
1564
1661
|
};
|
1565
|
-
return /* @__PURE__ */
|
1566
|
-
/* @__PURE__ */ jsx(
|
1567
|
-
/* @__PURE__ */ jsx(
|
1568
|
-
/* @__PURE__ */ jsx(
|
1569
|
-
|
1570
|
-
{
|
1571
|
-
paddingTop: 4,
|
1572
|
-
paddingBottom: 4,
|
1573
|
-
paddingLeft: 5,
|
1574
|
-
paddingRight: 5,
|
1575
|
-
borderWidth: "1px 0 0 0",
|
1576
|
-
borderStyle: "solid",
|
1577
|
-
borderColor: "neutral150",
|
1578
|
-
background: "neutral100",
|
1579
|
-
children: typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
|
1580
|
-
}
|
1581
|
-
)
|
1582
|
-
] });
|
1662
|
+
return /* @__PURE__ */ jsx(Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Modal.Content, { children: [
|
1663
|
+
/* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: title }) }),
|
1664
|
+
/* @__PURE__ */ jsx(Modal.Body, { children: typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : Content }),
|
1665
|
+
/* @__PURE__ */ jsx(Modal.Footer, { children: typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer })
|
1666
|
+
] }) });
|
1583
1667
|
};
|
1584
|
-
const PublishAction = ({
|
1668
|
+
const PublishAction$1 = ({
|
1585
1669
|
activeTab,
|
1586
1670
|
documentId,
|
1587
1671
|
model,
|
@@ -1666,7 +1750,7 @@ const PublishAction = ({
|
|
1666
1750
|
}
|
1667
1751
|
};
|
1668
1752
|
};
|
1669
|
-
PublishAction.type = "publish";
|
1753
|
+
PublishAction$1.type = "publish";
|
1670
1754
|
const UpdateAction = ({
|
1671
1755
|
activeTab,
|
1672
1756
|
documentId,
|
@@ -1762,10 +1846,13 @@ const UpdateAction = ({
|
|
1762
1846
|
document
|
1763
1847
|
);
|
1764
1848
|
if ("data" in res && collectionType !== SINGLE_TYPES) {
|
1765
|
-
navigate(
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1849
|
+
navigate(
|
1850
|
+
{
|
1851
|
+
pathname: `../${collectionType}/${model}/${res.data.documentId}`,
|
1852
|
+
search: rawQuery
|
1853
|
+
},
|
1854
|
+
{ replace: true }
|
1855
|
+
);
|
1769
1856
|
} else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
|
1770
1857
|
setErrors(formatValidationErrors(res.error));
|
1771
1858
|
}
|
@@ -1781,7 +1868,7 @@ const UNPUBLISH_DRAFT_OPTIONS = {
|
|
1781
1868
|
KEEP: "keep",
|
1782
1869
|
DISCARD: "discard"
|
1783
1870
|
};
|
1784
|
-
const UnpublishAction = ({
|
1871
|
+
const UnpublishAction$1 = ({
|
1785
1872
|
activeTab,
|
1786
1873
|
documentId,
|
1787
1874
|
model,
|
@@ -1797,10 +1884,8 @@ const UnpublishAction = ({
|
|
1797
1884
|
const { toggleNotification } = useNotification();
|
1798
1885
|
const [shouldKeepDraft, setShouldKeepDraft] = React.useState(true);
|
1799
1886
|
const isDocumentModified = document?.status === "modified";
|
1800
|
-
const handleChange = (
|
1801
|
-
|
1802
|
-
setShouldKeepDraft(e.target.value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1803
|
-
}
|
1887
|
+
const handleChange = (value) => {
|
1888
|
+
setShouldKeepDraft(value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
|
1804
1889
|
};
|
1805
1890
|
if (!schema?.options?.draftAndPublish) {
|
1806
1891
|
return null;
|
@@ -1844,45 +1929,30 @@ const UnpublishAction = ({
|
|
1844
1929
|
content: /* @__PURE__ */ jsxs(Flex, { alignItems: "flex-start", direction: "column", gap: 6, children: [
|
1845
1930
|
/* @__PURE__ */ jsxs(Flex, { width: "100%", direction: "column", gap: 2, children: [
|
1846
1931
|
/* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
1847
|
-
/* @__PURE__ */ jsx(Typography, {
|
1932
|
+
/* @__PURE__ */ jsx(Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
1848
1933
|
id: "content-manager.actions.unpublish.dialog.body",
|
1849
1934
|
defaultMessage: "Are you sure?"
|
1850
1935
|
}) })
|
1851
1936
|
] }),
|
1852
1937
|
/* @__PURE__ */ jsxs(
|
1853
|
-
|
1938
|
+
Radio.Group,
|
1854
1939
|
{
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1940
|
+
defaultValue: UNPUBLISH_DRAFT_OPTIONS.KEEP,
|
1941
|
+
name: "discard-options",
|
1942
|
+
"aria-label": formatMessage({
|
1943
|
+
id: "content-manager.actions.unpublish.dialog.radio-label",
|
1944
|
+
defaultMessage: "Choose an option to unpublish the document."
|
1945
|
+
}),
|
1946
|
+
onValueChange: handleChange,
|
1860
1947
|
children: [
|
1861
|
-
/* @__PURE__ */ jsx(
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
1870
|
-
defaultMessage: "Keep draft"
|
1871
|
-
})
|
1872
|
-
}
|
1873
|
-
),
|
1874
|
-
/* @__PURE__ */ jsx(
|
1875
|
-
Radio,
|
1876
|
-
{
|
1877
|
-
checked: !shouldKeepDraft,
|
1878
|
-
value: UNPUBLISH_DRAFT_OPTIONS.DISCARD,
|
1879
|
-
name: "discard-options",
|
1880
|
-
children: formatMessage({
|
1881
|
-
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
1882
|
-
defaultMessage: "Replace draft"
|
1883
|
-
})
|
1884
|
-
}
|
1885
|
-
)
|
1948
|
+
/* @__PURE__ */ jsx(Radio.Item, { checked: shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.KEEP, children: formatMessage({
|
1949
|
+
id: "content-manager.actions.unpublish.dialog.option.keep-draft",
|
1950
|
+
defaultMessage: "Keep draft"
|
1951
|
+
}) }),
|
1952
|
+
/* @__PURE__ */ jsx(Radio.Item, { checked: !shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.DISCARD, children: formatMessage({
|
1953
|
+
id: "content-manager.actions.unpublish.dialog.option.replace-draft",
|
1954
|
+
defaultMessage: "Replace draft"
|
1955
|
+
}) })
|
1886
1956
|
]
|
1887
1957
|
}
|
1888
1958
|
)
|
@@ -1915,7 +1985,7 @@ const UnpublishAction = ({
|
|
1915
1985
|
position: ["panel", "table-row"]
|
1916
1986
|
};
|
1917
1987
|
};
|
1918
|
-
UnpublishAction.type = "unpublish";
|
1988
|
+
UnpublishAction$1.type = "unpublish";
|
1919
1989
|
const DiscardAction = ({
|
1920
1990
|
activeTab,
|
1921
1991
|
documentId,
|
@@ -1949,7 +2019,7 @@ const DiscardAction = ({
|
|
1949
2019
|
}),
|
1950
2020
|
content: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
|
1951
2021
|
/* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
1952
|
-
/* @__PURE__ */ jsx(Typography, {
|
2022
|
+
/* @__PURE__ */ jsx(Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
1953
2023
|
id: "content-manager.actions.discard.dialog.body",
|
1954
2024
|
defaultMessage: "Are you sure?"
|
1955
2025
|
}) })
|
@@ -1971,7 +2041,7 @@ const StyledCrossCircle = styled(CrossCircle)`
|
|
1971
2041
|
fill: currentColor;
|
1972
2042
|
}
|
1973
2043
|
`;
|
1974
|
-
const DEFAULT_ACTIONS = [PublishAction, UpdateAction, UnpublishAction, DiscardAction];
|
2044
|
+
const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
|
1975
2045
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
1976
2046
|
const RelativeTime = React.forwardRef(
|
1977
2047
|
({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {
|
@@ -2019,7 +2089,7 @@ const getDisplayName = ({
|
|
2019
2089
|
const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2020
2090
|
const DocumentStatus = ({ status = "draft", ...restProps }) => {
|
2021
2091
|
const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
|
2022
|
-
return /* @__PURE__ */ jsx(Status, { ...restProps, showBullet: false, size: "S", variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, {
|
2092
|
+
return /* @__PURE__ */ jsx(Status, { ...restProps, showBullet: false, size: "S", variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: capitalise(status) }) });
|
2023
2093
|
};
|
2024
2094
|
const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
2025
2095
|
const { formatMessage } = useIntl();
|
@@ -2039,7 +2109,7 @@ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
|
|
2039
2109
|
gap: "80px",
|
2040
2110
|
alignItems: "flex-start",
|
2041
2111
|
children: [
|
2042
|
-
/* @__PURE__ */ jsx(Typography, { variant: "alpha",
|
2112
|
+
/* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
|
2043
2113
|
/* @__PURE__ */ jsx(HeaderToolbar, {})
|
2044
2114
|
]
|
2045
2115
|
}
|
@@ -2196,7 +2266,7 @@ const Information = ({ activeTab }) => {
|
|
2196
2266
|
borderColor: "neutral150",
|
2197
2267
|
direction: "column",
|
2198
2268
|
marginTop: 2,
|
2199
|
-
|
2269
|
+
tag: "dl",
|
2200
2270
|
padding: 5,
|
2201
2271
|
gap: 3,
|
2202
2272
|
alignItems: "flex-start",
|
@@ -2204,8 +2274,8 @@ const Information = ({ activeTab }) => {
|
|
2204
2274
|
marginRight: "-0.4rem",
|
2205
2275
|
width: "calc(100% + 8px)",
|
2206
2276
|
children: information.map((info) => /* @__PURE__ */ jsxs(Flex, { gap: 1, direction: "column", alignItems: "flex-start", children: [
|
2207
|
-
/* @__PURE__ */ jsx(Typography, {
|
2208
|
-
/* @__PURE__ */ jsx(Typography, {
|
2277
|
+
/* @__PURE__ */ jsx(Typography, { tag: "dt", variant: "pi", fontWeight: "bold", children: info.label }),
|
2278
|
+
/* @__PURE__ */ jsx(Typography, { tag: "dd", variant: "pi", textColor: "neutral600", children: info.value })
|
2209
2279
|
] }, info.label))
|
2210
2280
|
}
|
2211
2281
|
);
|
@@ -2238,7 +2308,7 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
|
|
2238
2308
|
id: "app.links.configure-view",
|
2239
2309
|
defaultMessage: "Configure the view"
|
2240
2310
|
}),
|
2241
|
-
icon: /* @__PURE__ */ jsx(
|
2311
|
+
icon: /* @__PURE__ */ jsx(ListPlus, {}),
|
2242
2312
|
onClick: () => {
|
2243
2313
|
navigate(`../${collectionType}/${model}/configurations/edit`);
|
2244
2314
|
},
|
@@ -2246,11 +2316,6 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
|
|
2246
2316
|
};
|
2247
2317
|
};
|
2248
2318
|
ConfigureTheViewAction.type = "configure-the-view";
|
2249
|
-
const StyledCog = styled(Cog)`
|
2250
|
-
path {
|
2251
|
-
fill: currentColor;
|
2252
|
-
}
|
2253
|
-
`;
|
2254
2319
|
const EditTheModelAction = ({ model }) => {
|
2255
2320
|
const navigate = useNavigate();
|
2256
2321
|
const { formatMessage } = useIntl();
|
@@ -2259,7 +2324,7 @@ const EditTheModelAction = ({ model }) => {
|
|
2259
2324
|
id: "content-manager.link-to-ctb",
|
2260
2325
|
defaultMessage: "Edit the model"
|
2261
2326
|
}),
|
2262
|
-
icon: /* @__PURE__ */ jsx(
|
2327
|
+
icon: /* @__PURE__ */ jsx(Pencil, {}),
|
2263
2328
|
onClick: () => {
|
2264
2329
|
navigate(`/plugins/content-type-builder/content-types/${model}`);
|
2265
2330
|
},
|
@@ -2267,12 +2332,7 @@ const EditTheModelAction = ({ model }) => {
|
|
2267
2332
|
};
|
2268
2333
|
};
|
2269
2334
|
EditTheModelAction.type = "edit-the-model";
|
2270
|
-
const
|
2271
|
-
path {
|
2272
|
-
fill: currentColor;
|
2273
|
-
}
|
2274
|
-
`;
|
2275
|
-
const DeleteAction = ({ documentId, model, collectionType, document }) => {
|
2335
|
+
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2276
2336
|
const navigate = useNavigate();
|
2277
2337
|
const { formatMessage } = useIntl();
|
2278
2338
|
const listViewPathMatch = useMatch(LIST_PATH);
|
@@ -2286,7 +2346,7 @@ const DeleteAction = ({ documentId, model, collectionType, document }) => {
|
|
2286
2346
|
id: "content-manager.actions.delete.label",
|
2287
2347
|
defaultMessage: "Delete document"
|
2288
2348
|
}),
|
2289
|
-
icon: /* @__PURE__ */ jsx(
|
2349
|
+
icon: /* @__PURE__ */ jsx(Trash, {}),
|
2290
2350
|
dialog: {
|
2291
2351
|
type: "dialog",
|
2292
2352
|
title: formatMessage({
|
@@ -2295,7 +2355,7 @@ const DeleteAction = ({ documentId, model, collectionType, document }) => {
|
|
2295
2355
|
}),
|
2296
2356
|
content: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
|
2297
2357
|
/* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
2298
|
-
/* @__PURE__ */ jsx(Typography, {
|
2358
|
+
/* @__PURE__ */ jsx(Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
2299
2359
|
id: "content-manager.actions.delete.dialog.body",
|
2300
2360
|
defaultMessage: "Are you sure?"
|
2301
2361
|
}) })
|
@@ -2340,13 +2400,8 @@ const DeleteAction = ({ documentId, model, collectionType, document }) => {
|
|
2340
2400
|
position: ["header", "table-row"]
|
2341
2401
|
};
|
2342
2402
|
};
|
2343
|
-
DeleteAction.type = "delete";
|
2344
|
-
const
|
2345
|
-
path {
|
2346
|
-
fill: currentColor;
|
2347
|
-
}
|
2348
|
-
`;
|
2349
|
-
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction];
|
2403
|
+
DeleteAction$1.type = "delete";
|
2404
|
+
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2350
2405
|
const Panels = () => {
|
2351
2406
|
const isCloning = useMatch(CLONE_PATH) !== null;
|
2352
2407
|
const [
|
@@ -2420,7 +2475,7 @@ const Panel = React.forwardRef(({ children, title }, ref) => {
|
|
2420
2475
|
Flex,
|
2421
2476
|
{
|
2422
2477
|
ref,
|
2423
|
-
|
2478
|
+
tag: "aside",
|
2424
2479
|
"aria-labelledby": "additional-information",
|
2425
2480
|
background: "neutral0",
|
2426
2481
|
borderColor: "neutral150",
|
@@ -2435,359 +2490,12 @@ const Panel = React.forwardRef(({ children, title }, ref) => {
|
|
2435
2490
|
justifyContent: "stretch",
|
2436
2491
|
alignItems: "flex-start",
|
2437
2492
|
children: [
|
2438
|
-
/* @__PURE__ */ jsx(Typography, {
|
2493
|
+
/* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
|
2439
2494
|
children
|
2440
2495
|
]
|
2441
2496
|
}
|
2442
2497
|
);
|
2443
2498
|
});
|
2444
|
-
const DEFAULT_BULK_ACTIONS = [];
|
2445
|
-
const AutoCloneFailureModalBody = ({ prohibitedFields }) => {
|
2446
|
-
const { formatMessage } = useIntl();
|
2447
|
-
const getDefaultErrorMessage = (reason) => {
|
2448
|
-
switch (reason) {
|
2449
|
-
case "relation":
|
2450
|
-
return "Duplicating the relation could remove it from the original entry.";
|
2451
|
-
case "unique":
|
2452
|
-
return "Identical values in a unique field are not allowed";
|
2453
|
-
default:
|
2454
|
-
return reason;
|
2455
|
-
}
|
2456
|
-
};
|
2457
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
2458
|
-
/* @__PURE__ */ jsx(Typography, { variant: "beta", children: formatMessage({
|
2459
|
-
id: getTranslation("containers.list.autoCloneModal.title"),
|
2460
|
-
defaultMessage: "This entry can't be duplicated directly."
|
2461
|
-
}) }),
|
2462
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 2, children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatMessage({
|
2463
|
-
id: getTranslation("containers.list.autoCloneModal.description"),
|
2464
|
-
defaultMessage: "A new entry will be created with the same content, but you'll have to change the following fields to save it."
|
2465
|
-
}) }) }),
|
2466
|
-
/* @__PURE__ */ jsx(Flex, { marginTop: 6, gap: 2, direction: "column", alignItems: "stretch", children: prohibitedFields.map(([fieldPath, reason]) => /* @__PURE__ */ jsxs(
|
2467
|
-
Flex,
|
2468
|
-
{
|
2469
|
-
direction: "column",
|
2470
|
-
gap: 2,
|
2471
|
-
alignItems: "flex-start",
|
2472
|
-
borderColor: "neutral200",
|
2473
|
-
hasRadius: true,
|
2474
|
-
padding: 6,
|
2475
|
-
children: [
|
2476
|
-
/* @__PURE__ */ jsx(Flex, { direction: "row", as: "ol", children: fieldPath.map((pathSegment, index2) => /* @__PURE__ */ jsxs(Typography, { fontWeight: "semiBold", as: "li", children: [
|
2477
|
-
pathSegment,
|
2478
|
-
index2 !== fieldPath.length - 1 && /* @__PURE__ */ jsx(
|
2479
|
-
ChevronRight,
|
2480
|
-
{
|
2481
|
-
fill: "neutral500",
|
2482
|
-
height: "0.8rem",
|
2483
|
-
width: "0.8rem",
|
2484
|
-
style: { margin: "0 0.8rem" }
|
2485
|
-
}
|
2486
|
-
)
|
2487
|
-
] }, index2)) }),
|
2488
|
-
/* @__PURE__ */ jsx(Typography, { as: "p", textColor: "neutral600", children: formatMessage({
|
2489
|
-
id: getTranslation(`containers.list.autoCloneModal.error.${reason}`),
|
2490
|
-
defaultMessage: getDefaultErrorMessage(reason)
|
2491
|
-
}) })
|
2492
|
-
]
|
2493
|
-
},
|
2494
|
-
fieldPath.join()
|
2495
|
-
)) })
|
2496
|
-
] });
|
2497
|
-
};
|
2498
|
-
const TableActions = ({ document }) => {
|
2499
|
-
const { formatMessage } = useIntl();
|
2500
|
-
const { model, collectionType } = useDoc();
|
2501
|
-
const plugins = useStrapiApp("TableActions", (state) => state.plugins);
|
2502
|
-
const props = {
|
2503
|
-
activeTab: null,
|
2504
|
-
model,
|
2505
|
-
documentId: document.documentId,
|
2506
|
-
collectionType,
|
2507
|
-
document
|
2508
|
-
};
|
2509
|
-
return /* @__PURE__ */ jsx(
|
2510
|
-
DescriptionComponentRenderer,
|
2511
|
-
{
|
2512
|
-
props,
|
2513
|
-
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
2514
|
-
children: (actions2) => {
|
2515
|
-
const tableRowActions = actions2.filter((action) => {
|
2516
|
-
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
2517
|
-
return positions.includes("table-row");
|
2518
|
-
});
|
2519
|
-
return /* @__PURE__ */ jsx(
|
2520
|
-
DocumentActionsMenu,
|
2521
|
-
{
|
2522
|
-
actions: tableRowActions,
|
2523
|
-
label: formatMessage({
|
2524
|
-
id: "content-manager.containers.list.table.row-actions",
|
2525
|
-
defaultMessage: "Row action"
|
2526
|
-
}),
|
2527
|
-
variant: "ghost"
|
2528
|
-
}
|
2529
|
-
);
|
2530
|
-
}
|
2531
|
-
}
|
2532
|
-
);
|
2533
|
-
};
|
2534
|
-
const EditAction = ({ documentId }) => {
|
2535
|
-
const navigate = useNavigate();
|
2536
|
-
const { formatMessage } = useIntl();
|
2537
|
-
const { canRead } = useDocumentRBAC("EditAction", ({ canRead: canRead2 }) => ({ canRead: canRead2 }));
|
2538
|
-
const { toggleNotification } = useNotification();
|
2539
|
-
const [{ query }] = useQueryParams();
|
2540
|
-
return {
|
2541
|
-
disabled: !canRead,
|
2542
|
-
icon: /* @__PURE__ */ jsx(StyledPencil, {}),
|
2543
|
-
label: formatMessage({
|
2544
|
-
id: "content-manager.actions.edit.label",
|
2545
|
-
defaultMessage: "Edit"
|
2546
|
-
}),
|
2547
|
-
position: "table-row",
|
2548
|
-
onClick: async () => {
|
2549
|
-
if (!documentId) {
|
2550
|
-
console.error(
|
2551
|
-
"You're trying to edit a document without an id, this is likely a bug with Strapi. Please open an issue."
|
2552
|
-
);
|
2553
|
-
toggleNotification({
|
2554
|
-
message: formatMessage({
|
2555
|
-
id: "content-manager.actions.edit.error",
|
2556
|
-
defaultMessage: "An error occurred while trying to edit the document."
|
2557
|
-
}),
|
2558
|
-
type: "danger"
|
2559
|
-
});
|
2560
|
-
return;
|
2561
|
-
}
|
2562
|
-
navigate({
|
2563
|
-
pathname: documentId,
|
2564
|
-
search: stringify({
|
2565
|
-
plugins: query.plugins
|
2566
|
-
})
|
2567
|
-
});
|
2568
|
-
}
|
2569
|
-
};
|
2570
|
-
};
|
2571
|
-
EditAction.type = "edit";
|
2572
|
-
const StyledPencil = styled(Pencil)`
|
2573
|
-
path {
|
2574
|
-
fill: currentColor;
|
2575
|
-
}
|
2576
|
-
`;
|
2577
|
-
const CloneAction = ({ model, documentId }) => {
|
2578
|
-
const navigate = useNavigate();
|
2579
|
-
const { formatMessage } = useIntl();
|
2580
|
-
const { canCreate } = useDocumentRBAC("CloneAction", ({ canCreate: canCreate2 }) => ({ canCreate: canCreate2 }));
|
2581
|
-
const { toggleNotification } = useNotification();
|
2582
|
-
const { autoClone } = useDocumentActions();
|
2583
|
-
const [prohibitedFields, setProhibitedFields] = React.useState([]);
|
2584
|
-
return {
|
2585
|
-
disabled: !canCreate,
|
2586
|
-
icon: /* @__PURE__ */ jsx(StyledDuplicate, {}),
|
2587
|
-
label: formatMessage({
|
2588
|
-
id: "content-manager.actions.clone.label",
|
2589
|
-
defaultMessage: "Duplicate"
|
2590
|
-
}),
|
2591
|
-
position: "table-row",
|
2592
|
-
onClick: async () => {
|
2593
|
-
if (!documentId) {
|
2594
|
-
console.error(
|
2595
|
-
"You're trying to clone a document in the table without an id, this is likely a bug with Strapi. Please open an issue."
|
2596
|
-
);
|
2597
|
-
toggleNotification({
|
2598
|
-
message: formatMessage({
|
2599
|
-
id: "content-manager.actions.clone.error",
|
2600
|
-
defaultMessage: "An error occurred while trying to clone the document."
|
2601
|
-
}),
|
2602
|
-
type: "danger"
|
2603
|
-
});
|
2604
|
-
return;
|
2605
|
-
}
|
2606
|
-
const res = await autoClone({ model, sourceId: documentId });
|
2607
|
-
if ("data" in res) {
|
2608
|
-
navigate(res.data.documentId);
|
2609
|
-
return true;
|
2610
|
-
}
|
2611
|
-
if (isBaseQueryError(res.error) && res.error.details && typeof res.error.details === "object" && "prohibitedFields" in res.error.details && Array.isArray(res.error.details.prohibitedFields)) {
|
2612
|
-
const prohibitedFields2 = res.error.details.prohibitedFields;
|
2613
|
-
setProhibitedFields(prohibitedFields2);
|
2614
|
-
}
|
2615
|
-
},
|
2616
|
-
dialog: {
|
2617
|
-
type: "modal",
|
2618
|
-
title: formatMessage({
|
2619
|
-
id: "content-manager.containers.list.autoCloneModal.header",
|
2620
|
-
defaultMessage: "Duplicate"
|
2621
|
-
}),
|
2622
|
-
content: /* @__PURE__ */ jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
2623
|
-
footer: ({ onClose }) => {
|
2624
|
-
return /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
|
2625
|
-
/* @__PURE__ */ jsx(Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
2626
|
-
id: "cancel",
|
2627
|
-
defaultMessage: "Cancel"
|
2628
|
-
}) }),
|
2629
|
-
/* @__PURE__ */ jsx(
|
2630
|
-
LinkButton,
|
2631
|
-
{
|
2632
|
-
as: NavLink,
|
2633
|
-
to: {
|
2634
|
-
pathname: `clone/${documentId}`
|
2635
|
-
},
|
2636
|
-
children: formatMessage({
|
2637
|
-
id: "content-manager.containers.list.autoCloneModal.create",
|
2638
|
-
defaultMessage: "Create"
|
2639
|
-
})
|
2640
|
-
}
|
2641
|
-
)
|
2642
|
-
] });
|
2643
|
-
}
|
2644
|
-
}
|
2645
|
-
};
|
2646
|
-
};
|
2647
|
-
CloneAction.type = "clone";
|
2648
|
-
const StyledDuplicate = styled(Duplicate)`
|
2649
|
-
path {
|
2650
|
-
fill: currentColor;
|
2651
|
-
}
|
2652
|
-
`;
|
2653
|
-
const DEFAULT_TABLE_ROW_ACTIONS = [EditAction, CloneAction];
|
2654
|
-
class ContentManagerPlugin {
|
2655
|
-
/**
|
2656
|
-
* The following properties are the stored ones provided by any plugins registering with
|
2657
|
-
* the content-manager. The function calls however, need to be called at runtime in the
|
2658
|
-
* application, so instead we collate them and run them later with the complete list incl.
|
2659
|
-
* ones already registered & the context of the view.
|
2660
|
-
*/
|
2661
|
-
bulkActions = [...DEFAULT_BULK_ACTIONS];
|
2662
|
-
documentActions = [
|
2663
|
-
...DEFAULT_ACTIONS,
|
2664
|
-
...DEFAULT_TABLE_ROW_ACTIONS,
|
2665
|
-
...DEFAULT_HEADER_ACTIONS,
|
2666
|
-
HistoryAction
|
2667
|
-
];
|
2668
|
-
editViewSidePanels = [ActionsPanel];
|
2669
|
-
headerActions = [];
|
2670
|
-
constructor() {
|
2671
|
-
}
|
2672
|
-
addEditViewSidePanel(panels) {
|
2673
|
-
if (Array.isArray(panels)) {
|
2674
|
-
this.editViewSidePanels = [...this.editViewSidePanels, ...panels];
|
2675
|
-
} else if (typeof panels === "function") {
|
2676
|
-
this.editViewSidePanels = panels(this.editViewSidePanels);
|
2677
|
-
} else {
|
2678
|
-
throw new Error(
|
2679
|
-
`Expected the \`panels\` passed to \`addEditViewSidePanel\` to be an array or a function, but received ${getPrintableType(
|
2680
|
-
panels
|
2681
|
-
)}`
|
2682
|
-
);
|
2683
|
-
}
|
2684
|
-
}
|
2685
|
-
addDocumentAction(actions2) {
|
2686
|
-
if (Array.isArray(actions2)) {
|
2687
|
-
this.documentActions = [...this.documentActions, ...actions2];
|
2688
|
-
} else if (typeof actions2 === "function") {
|
2689
|
-
this.documentActions = actions2(this.documentActions);
|
2690
|
-
} else {
|
2691
|
-
throw new Error(
|
2692
|
-
`Expected the \`actions\` passed to \`addDocumentAction\` to be an array or a function, but received ${getPrintableType(
|
2693
|
-
actions2
|
2694
|
-
)}`
|
2695
|
-
);
|
2696
|
-
}
|
2697
|
-
}
|
2698
|
-
addDocumentHeaderAction(actions2) {
|
2699
|
-
if (Array.isArray(actions2)) {
|
2700
|
-
this.headerActions = [...this.headerActions, ...actions2];
|
2701
|
-
} else if (typeof actions2 === "function") {
|
2702
|
-
this.headerActions = actions2(this.headerActions);
|
2703
|
-
} else {
|
2704
|
-
throw new Error(
|
2705
|
-
`Expected the \`actions\` passed to \`addDocumentHeaderAction\` to be an array or a function, but received ${getPrintableType(
|
2706
|
-
actions2
|
2707
|
-
)}`
|
2708
|
-
);
|
2709
|
-
}
|
2710
|
-
}
|
2711
|
-
addBulkAction(actions2) {
|
2712
|
-
if (Array.isArray(actions2)) {
|
2713
|
-
this.bulkActions = [...this.bulkActions, ...actions2];
|
2714
|
-
} else if (typeof actions2 === "function") {
|
2715
|
-
this.bulkActions = actions2(this.bulkActions);
|
2716
|
-
} else {
|
2717
|
-
throw new Error(
|
2718
|
-
`Expected the \`actions\` passed to \`addBulkAction\` to be an array or a function, but received ${getPrintableType(
|
2719
|
-
actions2
|
2720
|
-
)}`
|
2721
|
-
);
|
2722
|
-
}
|
2723
|
-
}
|
2724
|
-
get config() {
|
2725
|
-
return {
|
2726
|
-
id: PLUGIN_ID,
|
2727
|
-
name: "Content Manager",
|
2728
|
-
injectionZones: INJECTION_ZONES,
|
2729
|
-
apis: {
|
2730
|
-
addBulkAction: this.addBulkAction.bind(this),
|
2731
|
-
addDocumentAction: this.addDocumentAction.bind(this),
|
2732
|
-
addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
|
2733
|
-
addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
|
2734
|
-
getBulkActions: () => this.bulkActions,
|
2735
|
-
getDocumentActions: () => this.documentActions,
|
2736
|
-
getEditViewSidePanels: () => this.editViewSidePanels,
|
2737
|
-
getHeaderActions: () => this.headerActions
|
2738
|
-
}
|
2739
|
-
};
|
2740
|
-
}
|
2741
|
-
}
|
2742
|
-
const getPrintableType = (value) => {
|
2743
|
-
const nativeType = typeof value;
|
2744
|
-
if (nativeType === "object") {
|
2745
|
-
if (value === null)
|
2746
|
-
return "null";
|
2747
|
-
if (Array.isArray(value))
|
2748
|
-
return "array";
|
2749
|
-
if (value instanceof Object && value.constructor.name !== "Object") {
|
2750
|
-
return value.constructor.name;
|
2751
|
-
}
|
2752
|
-
}
|
2753
|
-
return nativeType;
|
2754
|
-
};
|
2755
|
-
const initialState = {
|
2756
|
-
collectionTypeLinks: [],
|
2757
|
-
components: [],
|
2758
|
-
fieldSizes: {},
|
2759
|
-
models: [],
|
2760
|
-
singleTypeLinks: [],
|
2761
|
-
isLoading: true
|
2762
|
-
};
|
2763
|
-
const appSlice = createSlice({
|
2764
|
-
name: "app",
|
2765
|
-
initialState,
|
2766
|
-
reducers: {
|
2767
|
-
setInitialData(state, action) {
|
2768
|
-
const {
|
2769
|
-
authorizedCollectionTypeLinks,
|
2770
|
-
authorizedSingleTypeLinks,
|
2771
|
-
components,
|
2772
|
-
contentTypeSchemas,
|
2773
|
-
fieldSizes
|
2774
|
-
} = action.payload;
|
2775
|
-
state.collectionTypeLinks = authorizedCollectionTypeLinks.filter(
|
2776
|
-
({ isDisplayed }) => isDisplayed
|
2777
|
-
);
|
2778
|
-
state.singleTypeLinks = authorizedSingleTypeLinks.filter(({ isDisplayed }) => isDisplayed);
|
2779
|
-
state.components = components;
|
2780
|
-
state.models = contentTypeSchemas;
|
2781
|
-
state.fieldSizes = fieldSizes;
|
2782
|
-
state.isLoading = false;
|
2783
|
-
}
|
2784
|
-
}
|
2785
|
-
});
|
2786
|
-
const { actions, reducer: reducer$1 } = appSlice;
|
2787
|
-
const { setInitialData } = actions;
|
2788
|
-
const reducer = combineReducers({
|
2789
|
-
app: reducer$1
|
2790
|
-
});
|
2791
2499
|
const HOOKS = {
|
2792
2500
|
/**
|
2793
2501
|
* Hook that allows to mutate the displayed headers of the list view table
|
@@ -2869,235 +2577,1157 @@ const getMainField = (attribute, mainFieldName, { schemas, components }) => {
|
|
2869
2577
|
schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
|
2870
2578
|
);
|
2871
2579
|
return {
|
2872
|
-
name: mainFieldName,
|
2873
|
-
type: mainFieldType ?? "string"
|
2580
|
+
name: mainFieldName,
|
2581
|
+
type: mainFieldType ?? "string"
|
2582
|
+
};
|
2583
|
+
};
|
2584
|
+
const DEFAULT_SETTINGS = {
|
2585
|
+
bulkable: false,
|
2586
|
+
filterable: false,
|
2587
|
+
searchable: false,
|
2588
|
+
pagination: false,
|
2589
|
+
defaultSortBy: "",
|
2590
|
+
defaultSortOrder: "asc",
|
2591
|
+
mainField: "id",
|
2592
|
+
pageSize: 10
|
2593
|
+
};
|
2594
|
+
const useDocumentLayout = (model) => {
|
2595
|
+
const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
|
2596
|
+
const [{ query }] = useQueryParams();
|
2597
|
+
const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
|
2598
|
+
const { toggleNotification } = useNotification();
|
2599
|
+
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
2600
|
+
const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
|
2601
|
+
const {
|
2602
|
+
data,
|
2603
|
+
isLoading: isLoadingConfigs,
|
2604
|
+
error,
|
2605
|
+
isFetching: isFetchingConfigs
|
2606
|
+
} = useGetContentTypeConfigurationQuery(model);
|
2607
|
+
const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
|
2608
|
+
React.useEffect(() => {
|
2609
|
+
if (error) {
|
2610
|
+
toggleNotification({
|
2611
|
+
type: "danger",
|
2612
|
+
message: formatAPIError(error)
|
2613
|
+
});
|
2614
|
+
}
|
2615
|
+
}, [error, formatAPIError, toggleNotification]);
|
2616
|
+
const editLayout = React.useMemo(
|
2617
|
+
() => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
|
2618
|
+
layout: [],
|
2619
|
+
components: {},
|
2620
|
+
metadatas: {},
|
2621
|
+
options: {},
|
2622
|
+
settings: DEFAULT_SETTINGS
|
2623
|
+
},
|
2624
|
+
[data, isLoading, schemas, schema, components]
|
2625
|
+
);
|
2626
|
+
const listLayout = React.useMemo(() => {
|
2627
|
+
return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
|
2628
|
+
layout: [],
|
2629
|
+
metadatas: {},
|
2630
|
+
options: {},
|
2631
|
+
settings: DEFAULT_SETTINGS
|
2632
|
+
};
|
2633
|
+
}, [data, isLoading, schemas, schema, components]);
|
2634
|
+
const { layout: edit } = React.useMemo(
|
2635
|
+
() => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
|
2636
|
+
layout: editLayout,
|
2637
|
+
query
|
2638
|
+
}),
|
2639
|
+
[editLayout, query, runHookWaterfall]
|
2640
|
+
);
|
2641
|
+
return {
|
2642
|
+
error,
|
2643
|
+
isLoading,
|
2644
|
+
edit,
|
2645
|
+
list: listLayout
|
2646
|
+
};
|
2647
|
+
};
|
2648
|
+
const useDocLayout = () => {
|
2649
|
+
const { model } = useDoc();
|
2650
|
+
return useDocumentLayout(model);
|
2651
|
+
};
|
2652
|
+
const formatEditLayout = (data, {
|
2653
|
+
schemas,
|
2654
|
+
schema,
|
2655
|
+
components
|
2656
|
+
}) => {
|
2657
|
+
let currentPanelIndex = 0;
|
2658
|
+
const panelledEditAttributes = convertEditLayoutToFieldLayouts(
|
2659
|
+
data.contentType.layouts.edit,
|
2660
|
+
schema?.attributes,
|
2661
|
+
data.contentType.metadatas,
|
2662
|
+
{ configurations: data.components, schemas: components },
|
2663
|
+
schemas
|
2664
|
+
).reduce((panels, row) => {
|
2665
|
+
if (row.some((field) => field.type === "dynamiczone")) {
|
2666
|
+
panels.push([row]);
|
2667
|
+
currentPanelIndex += 2;
|
2668
|
+
} else {
|
2669
|
+
if (!panels[currentPanelIndex]) {
|
2670
|
+
panels.push([]);
|
2671
|
+
}
|
2672
|
+
panels[currentPanelIndex].push(row);
|
2673
|
+
}
|
2674
|
+
return panels;
|
2675
|
+
}, []);
|
2676
|
+
const componentEditAttributes = Object.entries(data.components).reduce(
|
2677
|
+
(acc, [uid, configuration]) => {
|
2678
|
+
acc[uid] = {
|
2679
|
+
layout: convertEditLayoutToFieldLayouts(
|
2680
|
+
configuration.layouts.edit,
|
2681
|
+
components[uid].attributes,
|
2682
|
+
configuration.metadatas
|
2683
|
+
),
|
2684
|
+
settings: {
|
2685
|
+
...configuration.settings,
|
2686
|
+
icon: components[uid].info.icon,
|
2687
|
+
displayName: components[uid].info.displayName
|
2688
|
+
}
|
2689
|
+
};
|
2690
|
+
return acc;
|
2691
|
+
},
|
2692
|
+
{}
|
2693
|
+
);
|
2694
|
+
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2695
|
+
(acc, [attribute, metadata]) => {
|
2696
|
+
return {
|
2697
|
+
...acc,
|
2698
|
+
[attribute]: metadata.edit
|
2699
|
+
};
|
2700
|
+
},
|
2701
|
+
{}
|
2702
|
+
);
|
2703
|
+
return {
|
2704
|
+
layout: panelledEditAttributes,
|
2705
|
+
components: componentEditAttributes,
|
2706
|
+
metadatas: editMetadatas,
|
2707
|
+
settings: {
|
2708
|
+
...data.contentType.settings,
|
2709
|
+
displayName: schema?.info.displayName
|
2710
|
+
},
|
2711
|
+
options: {
|
2712
|
+
...schema?.options,
|
2713
|
+
...schema?.pluginOptions,
|
2714
|
+
...data.contentType.options
|
2715
|
+
}
|
2716
|
+
};
|
2717
|
+
};
|
2718
|
+
const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
|
2719
|
+
return rows.map(
|
2720
|
+
(row) => row.map((field) => {
|
2721
|
+
const attribute = attributes[field.name];
|
2722
|
+
if (!attribute) {
|
2723
|
+
return null;
|
2724
|
+
}
|
2725
|
+
const { edit: metadata } = metadatas[field.name];
|
2726
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
2727
|
+
return {
|
2728
|
+
attribute,
|
2729
|
+
disabled: !metadata.editable,
|
2730
|
+
hint: metadata.description,
|
2731
|
+
label: metadata.label ?? "",
|
2732
|
+
name: field.name,
|
2733
|
+
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
2734
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
2735
|
+
schemas,
|
2736
|
+
components: components?.schemas ?? {}
|
2737
|
+
}),
|
2738
|
+
placeholder: metadata.placeholder ?? "",
|
2739
|
+
required: attribute.required ?? false,
|
2740
|
+
size: field.size,
|
2741
|
+
unique: "unique" in attribute ? attribute.unique : false,
|
2742
|
+
visible: metadata.visible ?? true,
|
2743
|
+
type: attribute.type
|
2744
|
+
};
|
2745
|
+
}).filter((field) => field !== null)
|
2746
|
+
);
|
2747
|
+
};
|
2748
|
+
const formatListLayout = (data, {
|
2749
|
+
schemas,
|
2750
|
+
schema,
|
2751
|
+
components
|
2752
|
+
}) => {
|
2753
|
+
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2754
|
+
(acc, [attribute, metadata]) => {
|
2755
|
+
return {
|
2756
|
+
...acc,
|
2757
|
+
[attribute]: metadata.list
|
2758
|
+
};
|
2759
|
+
},
|
2760
|
+
{}
|
2761
|
+
);
|
2762
|
+
const listAttributes = convertListLayoutToFieldLayouts(
|
2763
|
+
data.contentType.layouts.list,
|
2764
|
+
schema?.attributes,
|
2765
|
+
listMetadatas,
|
2766
|
+
{ configurations: data.components, schemas: components },
|
2767
|
+
schemas
|
2768
|
+
);
|
2769
|
+
return {
|
2770
|
+
layout: listAttributes,
|
2771
|
+
settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
|
2772
|
+
metadatas: listMetadatas,
|
2773
|
+
options: {
|
2774
|
+
...schema?.options,
|
2775
|
+
...schema?.pluginOptions,
|
2776
|
+
...data.contentType.options
|
2777
|
+
}
|
2874
2778
|
};
|
2875
2779
|
};
|
2876
|
-
const
|
2877
|
-
|
2878
|
-
|
2879
|
-
|
2880
|
-
|
2881
|
-
|
2882
|
-
|
2883
|
-
|
2884
|
-
|
2780
|
+
const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
|
2781
|
+
return columns.map((name) => {
|
2782
|
+
const attribute = attributes[name];
|
2783
|
+
if (!attribute) {
|
2784
|
+
return null;
|
2785
|
+
}
|
2786
|
+
const metadata = metadatas[name];
|
2787
|
+
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
2788
|
+
return {
|
2789
|
+
attribute,
|
2790
|
+
label: metadata.label ?? "",
|
2791
|
+
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
2792
|
+
schemas,
|
2793
|
+
components: components?.schemas ?? {}
|
2794
|
+
}),
|
2795
|
+
name,
|
2796
|
+
searchable: metadata.searchable ?? true,
|
2797
|
+
sortable: metadata.sortable ?? true
|
2798
|
+
};
|
2799
|
+
}).filter((field) => field !== null);
|
2885
2800
|
};
|
2886
|
-
const
|
2887
|
-
|
2888
|
-
|
2889
|
-
|
2801
|
+
const ConfirmBulkActionDialog = ({
|
2802
|
+
onToggleDialog,
|
2803
|
+
isOpen = false,
|
2804
|
+
dialogBody,
|
2805
|
+
endAction
|
2806
|
+
}) => {
|
2807
|
+
const { formatMessage } = useIntl();
|
2808
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { onOpenChange: onToggleDialog, open: isOpen, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
2809
|
+
/* @__PURE__ */ jsx(Dialog.Header, { children: formatMessage({
|
2810
|
+
id: "app.components.ConfirmDialog.title",
|
2811
|
+
defaultMessage: "Confirmation"
|
2812
|
+
}) }),
|
2813
|
+
/* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
2814
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
2815
|
+
dialogBody
|
2816
|
+
] }) }),
|
2817
|
+
/* @__PURE__ */ jsxs(Dialog.Footer, { children: [
|
2818
|
+
/* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { fullWidth: true, onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
|
2819
|
+
id: "app.components.Button.cancel",
|
2820
|
+
defaultMessage: "Cancel"
|
2821
|
+
}) }) }),
|
2822
|
+
endAction
|
2823
|
+
] })
|
2824
|
+
] }) });
|
2825
|
+
};
|
2826
|
+
const BoldChunk$1 = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: chunks });
|
2827
|
+
const ConfirmDialogPublishAll = ({
|
2828
|
+
isOpen,
|
2829
|
+
onToggleDialog,
|
2830
|
+
isConfirmButtonLoading = false,
|
2831
|
+
onConfirm
|
2832
|
+
}) => {
|
2833
|
+
const { formatMessage } = useIntl();
|
2834
|
+
const selectedEntries = useTable("ConfirmDialogPublishAll", (state) => state.selectedRows);
|
2890
2835
|
const { toggleNotification } = useNotification();
|
2891
|
-
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
2892
|
-
const {
|
2836
|
+
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler(getTranslation);
|
2837
|
+
const { model, schema } = useDoc();
|
2838
|
+
const [{ query }] = useQueryParams();
|
2893
2839
|
const {
|
2894
|
-
data,
|
2895
|
-
isLoading
|
2896
|
-
error
|
2897
|
-
|
2898
|
-
|
2899
|
-
|
2840
|
+
data: countDraftRelations = 0,
|
2841
|
+
isLoading,
|
2842
|
+
error
|
2843
|
+
} = useGetManyDraftRelationCountQuery(
|
2844
|
+
{
|
2845
|
+
model,
|
2846
|
+
documentIds: selectedEntries.map((entry) => entry.documentId),
|
2847
|
+
locale: query?.plugins?.i18n?.locale
|
2848
|
+
},
|
2849
|
+
{
|
2850
|
+
skip: selectedEntries.length === 0
|
2851
|
+
}
|
2852
|
+
);
|
2900
2853
|
React.useEffect(() => {
|
2901
2854
|
if (error) {
|
2902
|
-
toggleNotification({
|
2903
|
-
type: "danger",
|
2904
|
-
message: formatAPIError(error)
|
2905
|
-
});
|
2855
|
+
toggleNotification({ type: "danger", message: formatAPIError(error) });
|
2906
2856
|
}
|
2907
2857
|
}, [error, formatAPIError, toggleNotification]);
|
2908
|
-
|
2909
|
-
|
2910
|
-
|
2911
|
-
|
2912
|
-
|
2913
|
-
|
2914
|
-
|
2858
|
+
if (error) {
|
2859
|
+
return null;
|
2860
|
+
}
|
2861
|
+
return /* @__PURE__ */ jsx(
|
2862
|
+
ConfirmBulkActionDialog,
|
2863
|
+
{
|
2864
|
+
isOpen: isOpen && !isLoading,
|
2865
|
+
onToggleDialog,
|
2866
|
+
dialogBody: /* @__PURE__ */ jsxs(Fragment, { children: [
|
2867
|
+
/* @__PURE__ */ jsxs(Typography, { id: "confirm-description", textAlign: "center", children: [
|
2868
|
+
countDraftRelations > 0 && formatMessage(
|
2869
|
+
{
|
2870
|
+
id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
|
2871
|
+
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. "
|
2872
|
+
},
|
2873
|
+
{
|
2874
|
+
b: BoldChunk$1,
|
2875
|
+
count: countDraftRelations,
|
2876
|
+
entities: selectedEntries.length
|
2877
|
+
}
|
2878
|
+
),
|
2879
|
+
formatMessage({
|
2880
|
+
id: getTranslation("popUpWarning.bodyMessage.contentType.publish.all"),
|
2881
|
+
defaultMessage: "Are you sure you want to publish these entries?"
|
2882
|
+
})
|
2883
|
+
] }),
|
2884
|
+
schema?.pluginOptions && "i18n" in schema.pluginOptions && schema?.pluginOptions.i18n && /* @__PURE__ */ jsx(Typography, { textColor: "danger500", textAlign: "center", children: formatMessage(
|
2885
|
+
{
|
2886
|
+
id: getTranslation("Settings.list.actions.publishAdditionalInfos"),
|
2887
|
+
defaultMessage: "This will publish the active locale versions <em>(from Internationalization)</em>"
|
2888
|
+
},
|
2889
|
+
{
|
2890
|
+
em: Emphasis
|
2891
|
+
}
|
2892
|
+
) })
|
2893
|
+
] }),
|
2894
|
+
endAction: /* @__PURE__ */ jsx(
|
2895
|
+
Button,
|
2896
|
+
{
|
2897
|
+
onClick: onConfirm,
|
2898
|
+
variant: "secondary",
|
2899
|
+
startIcon: /* @__PURE__ */ jsx(Check, {}),
|
2900
|
+
loading: isConfirmButtonLoading,
|
2901
|
+
children: formatMessage({
|
2902
|
+
id: "app.utils.publish",
|
2903
|
+
defaultMessage: "Publish"
|
2904
|
+
})
|
2905
|
+
}
|
2906
|
+
)
|
2907
|
+
}
|
2908
|
+
);
|
2909
|
+
};
|
2910
|
+
const TypographyMaxWidth = styled(Typography)`
|
2911
|
+
max-width: 300px;
|
2912
|
+
`;
|
2913
|
+
const formatErrorMessages = (errors, parentKey, formatMessage) => {
|
2914
|
+
const messages = [];
|
2915
|
+
Object.entries(errors).forEach(([key, value]) => {
|
2916
|
+
const currentKey = parentKey ? `${parentKey}.${key}` : key;
|
2917
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
2918
|
+
if ("id" in value && "defaultMessage" in value) {
|
2919
|
+
messages.push(
|
2920
|
+
formatMessage(
|
2921
|
+
{
|
2922
|
+
id: `${value.id}.withField`,
|
2923
|
+
defaultMessage: value.defaultMessage
|
2924
|
+
},
|
2925
|
+
{ field: currentKey }
|
2926
|
+
)
|
2927
|
+
);
|
2928
|
+
} else {
|
2929
|
+
messages.push(
|
2930
|
+
...formatErrorMessages(
|
2931
|
+
// @ts-expect-error TODO: check why value is not compatible with FormErrors
|
2932
|
+
value,
|
2933
|
+
currentKey,
|
2934
|
+
formatMessage
|
2935
|
+
)
|
2936
|
+
);
|
2937
|
+
}
|
2938
|
+
} else {
|
2939
|
+
messages.push(
|
2940
|
+
formatMessage(
|
2941
|
+
{
|
2942
|
+
id: `${value}.withField`,
|
2943
|
+
defaultMessage: value
|
2944
|
+
},
|
2945
|
+
{ field: currentKey }
|
2946
|
+
)
|
2947
|
+
);
|
2948
|
+
}
|
2949
|
+
});
|
2950
|
+
return messages;
|
2951
|
+
};
|
2952
|
+
const EntryValidationText = ({ validationErrors, status }) => {
|
2953
|
+
const { formatMessage } = useIntl();
|
2954
|
+
if (validationErrors) {
|
2955
|
+
const validationErrorsMessages = formatErrorMessages(validationErrors, "", formatMessage).join(
|
2956
|
+
" "
|
2957
|
+
);
|
2958
|
+
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
2959
|
+
/* @__PURE__ */ jsx(CrossCircle, { fill: "danger600" }),
|
2960
|
+
/* @__PURE__ */ jsx(Tooltip, { description: validationErrorsMessages, children: /* @__PURE__ */ jsx(TypographyMaxWidth, { textColor: "danger600", variant: "omega", fontWeight: "semiBold", ellipsis: true, children: validationErrorsMessages }) })
|
2961
|
+
] });
|
2962
|
+
}
|
2963
|
+
if (status === "published") {
|
2964
|
+
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
2965
|
+
/* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
2966
|
+
/* @__PURE__ */ jsx(Typography, { textColor: "success600", fontWeight: "bold", children: formatMessage({
|
2967
|
+
id: "content-manager.bulk-publish.already-published",
|
2968
|
+
defaultMessage: "Already Published"
|
2969
|
+
}) })
|
2970
|
+
] });
|
2971
|
+
}
|
2972
|
+
if (status === "modified") {
|
2973
|
+
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
2974
|
+
/* @__PURE__ */ jsx(ArrowsCounterClockwise, { fill: "alternative600" }),
|
2975
|
+
/* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
2976
|
+
id: "content-manager.bulk-publish.modified",
|
2977
|
+
defaultMessage: "Ready to publish changes"
|
2978
|
+
}) })
|
2979
|
+
] });
|
2980
|
+
}
|
2981
|
+
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
2982
|
+
/* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
2983
|
+
/* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
2984
|
+
id: "app.utils.ready-to-publish",
|
2985
|
+
defaultMessage: "Ready to publish"
|
2986
|
+
}) })
|
2987
|
+
] });
|
2988
|
+
};
|
2989
|
+
const TABLE_HEADERS = [
|
2990
|
+
{ name: "id", label: "id" },
|
2991
|
+
{ name: "name", label: "name" },
|
2992
|
+
{ name: "status", label: "status" },
|
2993
|
+
{ name: "publicationStatus", label: "Publication status" }
|
2994
|
+
];
|
2995
|
+
const SelectedEntriesTableContent = ({
|
2996
|
+
isPublishing,
|
2997
|
+
rowsToDisplay = [],
|
2998
|
+
entriesToPublish = [],
|
2999
|
+
validationErrors = {}
|
3000
|
+
}) => {
|
3001
|
+
const { pathname } = useLocation();
|
3002
|
+
const { formatMessage } = useIntl();
|
3003
|
+
const {
|
3004
|
+
list: {
|
3005
|
+
settings: { mainField }
|
3006
|
+
}
|
3007
|
+
} = useDocLayout();
|
3008
|
+
const shouldDisplayMainField = mainField != null && mainField !== "id";
|
3009
|
+
return /* @__PURE__ */ jsxs(Table.Content, { children: [
|
3010
|
+
/* @__PURE__ */ jsxs(Table.Head, { children: [
|
3011
|
+
/* @__PURE__ */ jsx(Table.HeaderCheckboxCell, {}),
|
3012
|
+
TABLE_HEADERS.filter((head) => head.name !== "name" || shouldDisplayMainField).map(
|
3013
|
+
(head) => /* @__PURE__ */ jsx(Table.HeaderCell, { ...head }, head.name)
|
3014
|
+
)
|
3015
|
+
] }),
|
3016
|
+
/* @__PURE__ */ jsx(Table.Loading, {}),
|
3017
|
+
/* @__PURE__ */ jsx(Table.Body, { children: rowsToDisplay.map((row, index2) => /* @__PURE__ */ jsxs(Table.Row, { children: [
|
3018
|
+
/* @__PURE__ */ jsx(Table.CheckboxCell, { id: row.id }),
|
3019
|
+
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Typography, { children: row.id }) }),
|
3020
|
+
shouldDisplayMainField && /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Typography, { children: row[mainField] }) }),
|
3021
|
+
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(DocumentStatus, { status: row.status, maxWidth: "min-content" }) }),
|
3022
|
+
/* @__PURE__ */ jsx(Table.Cell, { children: isPublishing && entriesToPublish.includes(row.documentId) ? /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
3023
|
+
/* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
3024
|
+
id: "content-manager.success.record.publishing",
|
3025
|
+
defaultMessage: "Publishing..."
|
3026
|
+
}) }),
|
3027
|
+
/* @__PURE__ */ jsx(Loader, { small: true })
|
3028
|
+
] }) : /* @__PURE__ */ jsx(
|
3029
|
+
EntryValidationText,
|
3030
|
+
{
|
3031
|
+
validationErrors: validationErrors[row.documentId],
|
3032
|
+
status: row.status
|
3033
|
+
}
|
3034
|
+
) }),
|
3035
|
+
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(
|
3036
|
+
IconButton,
|
3037
|
+
{
|
3038
|
+
tag: Link,
|
3039
|
+
to: {
|
3040
|
+
pathname: `${pathname}/${row.documentId}`,
|
3041
|
+
search: row.locale && `?plugins[i18n][locale]=${row.locale}`
|
3042
|
+
},
|
3043
|
+
state: { from: pathname },
|
3044
|
+
label: formatMessage(
|
3045
|
+
{ id: "app.component.HelperPluginTable.edit", defaultMessage: "Edit {target}" },
|
3046
|
+
{
|
3047
|
+
target: formatMessage(
|
3048
|
+
{
|
3049
|
+
id: "content-manager.components.ListViewHelperPluginTable.row-line",
|
3050
|
+
defaultMessage: "item line {number}"
|
3051
|
+
},
|
3052
|
+
{ number: index2 + 1 }
|
3053
|
+
)
|
3054
|
+
}
|
3055
|
+
),
|
3056
|
+
target: "_blank",
|
3057
|
+
marginLeft: "auto",
|
3058
|
+
children: /* @__PURE__ */ jsx(Pencil, {})
|
3059
|
+
}
|
3060
|
+
) })
|
3061
|
+
] }, row.id)) })
|
3062
|
+
] });
|
3063
|
+
};
|
3064
|
+
const BoldChunk = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: chunks });
|
3065
|
+
const SelectedEntriesModalContent = ({
|
3066
|
+
listViewSelectedEntries,
|
3067
|
+
toggleModal,
|
3068
|
+
setListViewSelectedDocuments,
|
3069
|
+
model
|
3070
|
+
}) => {
|
3071
|
+
const { formatMessage } = useIntl();
|
3072
|
+
const { schema, components } = useContentTypeSchema(model);
|
3073
|
+
const documentIds = listViewSelectedEntries.map(({ documentId }) => documentId);
|
3074
|
+
const [{ query }] = useQueryParams();
|
3075
|
+
const params = React.useMemo(() => buildValidParams(query), [query]);
|
3076
|
+
const { data, isLoading, isFetching, refetch } = useGetAllDocumentsQuery(
|
3077
|
+
{
|
3078
|
+
model,
|
3079
|
+
params: {
|
3080
|
+
page: "1",
|
3081
|
+
pageSize: documentIds.length.toString(),
|
3082
|
+
sort: query.sort,
|
3083
|
+
filters: {
|
3084
|
+
documentId: {
|
3085
|
+
$in: documentIds
|
3086
|
+
}
|
3087
|
+
},
|
3088
|
+
locale: query.plugins?.i18n?.locale
|
3089
|
+
}
|
2915
3090
|
},
|
2916
|
-
|
3091
|
+
{
|
3092
|
+
selectFromResult: ({ data: data2, ...restRes }) => ({ data: data2?.results ?? [], ...restRes })
|
3093
|
+
}
|
2917
3094
|
);
|
2918
|
-
const
|
2919
|
-
|
2920
|
-
|
2921
|
-
|
2922
|
-
|
2923
|
-
|
3095
|
+
const { rows, validationErrors } = React.useMemo(() => {
|
3096
|
+
if (data.length > 0 && schema) {
|
3097
|
+
const validate = createYupSchema(schema.attributes, components);
|
3098
|
+
const validationErrors2 = {};
|
3099
|
+
const rows2 = data.map((entry) => {
|
3100
|
+
try {
|
3101
|
+
validate.validateSync(entry, { abortEarly: false });
|
3102
|
+
return entry;
|
3103
|
+
} catch (e) {
|
3104
|
+
if (e instanceof ValidationError) {
|
3105
|
+
validationErrors2[entry.documentId] = getYupValidationErrors(e);
|
3106
|
+
}
|
3107
|
+
return entry;
|
3108
|
+
}
|
3109
|
+
});
|
3110
|
+
return { rows: rows2, validationErrors: validationErrors2 };
|
3111
|
+
}
|
3112
|
+
return {
|
3113
|
+
rows: [],
|
3114
|
+
validationErrors: {}
|
2924
3115
|
};
|
2925
|
-
}, [
|
2926
|
-
const
|
2927
|
-
|
2928
|
-
|
2929
|
-
|
2930
|
-
|
2931
|
-
|
3116
|
+
}, [components, data, schema]);
|
3117
|
+
const [publishedCount, setPublishedCount] = React.useState(0);
|
3118
|
+
const [isDialogOpen, setIsDialogOpen] = React.useState(false);
|
3119
|
+
const { publishMany: bulkPublishAction } = useDocumentActions();
|
3120
|
+
const [, { isLoading: isSubmittingForm }] = usePublishManyDocumentsMutation();
|
3121
|
+
const selectedRows = useTable("publishAction", (state) => state.selectedRows);
|
3122
|
+
const selectedEntries = rows.filter(
|
3123
|
+
(entry) => selectedRows.some((selectedEntry) => selectedEntry.documentId === entry.documentId)
|
2932
3124
|
);
|
3125
|
+
const entriesToPublish = selectedEntries.filter((entry) => !validationErrors[entry.documentId]).map((entry) => entry.documentId);
|
3126
|
+
const selectedEntriesWithErrorsCount = selectedEntries.filter(
|
3127
|
+
({ documentId }) => validationErrors[documentId]
|
3128
|
+
).length;
|
3129
|
+
const selectedEntriesPublished = selectedEntries.filter(
|
3130
|
+
({ status }) => status === "published"
|
3131
|
+
).length;
|
3132
|
+
const selectedEntriesWithNoErrorsCount = selectedEntries.length - selectedEntriesWithErrorsCount - selectedEntriesPublished;
|
3133
|
+
const toggleDialog = () => setIsDialogOpen((prev) => !prev);
|
3134
|
+
const handleConfirmBulkPublish = async () => {
|
3135
|
+
toggleDialog();
|
3136
|
+
const res = await bulkPublishAction({ model, documentIds: entriesToPublish, params });
|
3137
|
+
if (!("error" in res)) {
|
3138
|
+
setPublishedCount(res.count);
|
3139
|
+
const unpublishedEntries = rows.filter((row) => {
|
3140
|
+
return !entriesToPublish.includes(row.documentId);
|
3141
|
+
});
|
3142
|
+
setListViewSelectedDocuments(unpublishedEntries);
|
3143
|
+
}
|
3144
|
+
};
|
3145
|
+
const getFormattedCountMessage = () => {
|
3146
|
+
if (publishedCount) {
|
3147
|
+
return formatMessage(
|
3148
|
+
{
|
3149
|
+
id: getTranslation("containers.list.selectedEntriesModal.publishedCount"),
|
3150
|
+
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."
|
3151
|
+
},
|
3152
|
+
{
|
3153
|
+
publishedCount,
|
3154
|
+
withErrorsCount: selectedEntriesWithErrorsCount,
|
3155
|
+
b: BoldChunk
|
3156
|
+
}
|
3157
|
+
);
|
3158
|
+
}
|
3159
|
+
return formatMessage(
|
3160
|
+
{
|
3161
|
+
id: getTranslation("containers.list.selectedEntriesModal.selectedCount"),
|
3162
|
+
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."
|
3163
|
+
},
|
3164
|
+
{
|
3165
|
+
readyToPublishCount: selectedEntriesWithNoErrorsCount,
|
3166
|
+
withErrorsCount: selectedEntriesWithErrorsCount,
|
3167
|
+
alreadyPublishedCount: selectedEntriesPublished,
|
3168
|
+
b: BoldChunk
|
3169
|
+
}
|
3170
|
+
);
|
3171
|
+
};
|
3172
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
3173
|
+
/* @__PURE__ */ jsxs(Modal.Body, { children: [
|
3174
|
+
/* @__PURE__ */ jsx(Typography, { children: getFormattedCountMessage() }),
|
3175
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 5, children: /* @__PURE__ */ jsx(
|
3176
|
+
SelectedEntriesTableContent,
|
3177
|
+
{
|
3178
|
+
isPublishing: isSubmittingForm,
|
3179
|
+
rowsToDisplay: rows,
|
3180
|
+
entriesToPublish,
|
3181
|
+
validationErrors
|
3182
|
+
}
|
3183
|
+
) })
|
3184
|
+
] }),
|
3185
|
+
/* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
3186
|
+
/* @__PURE__ */ jsx(Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
|
3187
|
+
id: "app.components.Button.cancel",
|
3188
|
+
defaultMessage: "Cancel"
|
3189
|
+
}) }),
|
3190
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
3191
|
+
/* @__PURE__ */ jsx(Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
|
3192
|
+
/* @__PURE__ */ jsx(
|
3193
|
+
Button,
|
3194
|
+
{
|
3195
|
+
onClick: toggleDialog,
|
3196
|
+
disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublished === selectedEntries.length || isLoading,
|
3197
|
+
loading: isSubmittingForm,
|
3198
|
+
children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
|
3199
|
+
}
|
3200
|
+
)
|
3201
|
+
] })
|
3202
|
+
] }),
|
3203
|
+
/* @__PURE__ */ jsx(
|
3204
|
+
ConfirmDialogPublishAll,
|
3205
|
+
{
|
3206
|
+
isOpen: isDialogOpen,
|
3207
|
+
onToggleDialog: toggleDialog,
|
3208
|
+
isConfirmButtonLoading: isSubmittingForm,
|
3209
|
+
onConfirm: handleConfirmBulkPublish
|
3210
|
+
}
|
3211
|
+
)
|
3212
|
+
] });
|
3213
|
+
};
|
3214
|
+
const PublishAction = ({ documents, model }) => {
|
3215
|
+
const { formatMessage } = useIntl();
|
3216
|
+
const hasPublishPermission = useDocumentRBAC("unpublishAction", (state) => state.canPublish);
|
3217
|
+
const showPublishButton = hasPublishPermission && documents.some(({ status }) => status !== "published");
|
3218
|
+
const setListViewSelectedDocuments = useTable("publishAction", (state) => state.selectRow);
|
3219
|
+
const refetchList = () => {
|
3220
|
+
contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
|
3221
|
+
};
|
3222
|
+
if (!showPublishButton)
|
3223
|
+
return null;
|
3224
|
+
return {
|
3225
|
+
actionType: "publish",
|
3226
|
+
variant: "tertiary",
|
3227
|
+
label: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" }),
|
3228
|
+
dialog: {
|
3229
|
+
type: "modal",
|
3230
|
+
title: formatMessage({
|
3231
|
+
id: getTranslation("containers.ListPage.selectedEntriesModal.title"),
|
3232
|
+
defaultMessage: "Publish entries"
|
3233
|
+
}),
|
3234
|
+
content: ({ onClose }) => {
|
3235
|
+
return /* @__PURE__ */ jsx(Table.Root, { rows: documents, defaultSelectedRows: documents, headers: TABLE_HEADERS, children: /* @__PURE__ */ jsx(
|
3236
|
+
SelectedEntriesModalContent,
|
3237
|
+
{
|
3238
|
+
listViewSelectedEntries: documents,
|
3239
|
+
toggleModal: () => {
|
3240
|
+
onClose();
|
3241
|
+
refetchList();
|
3242
|
+
},
|
3243
|
+
setListViewSelectedDocuments,
|
3244
|
+
model
|
3245
|
+
}
|
3246
|
+
) });
|
3247
|
+
},
|
3248
|
+
onClose: () => {
|
3249
|
+
refetchList();
|
3250
|
+
}
|
3251
|
+
}
|
3252
|
+
};
|
3253
|
+
};
|
3254
|
+
const BulkActionsRenderer = () => {
|
3255
|
+
const plugins = useStrapiApp("BulkActionsRenderer", (state) => state.plugins);
|
3256
|
+
const { model, collectionType } = useDoc();
|
3257
|
+
const { selectedRows } = useTable("BulkActionsRenderer", (state) => state);
|
3258
|
+
return /* @__PURE__ */ jsx(Flex, { gap: 2, children: /* @__PURE__ */ jsx(
|
3259
|
+
DescriptionComponentRenderer,
|
3260
|
+
{
|
3261
|
+
props: {
|
3262
|
+
model,
|
3263
|
+
collectionType,
|
3264
|
+
documents: selectedRows
|
3265
|
+
},
|
3266
|
+
descriptions: plugins["content-manager"].apis.getBulkActions(),
|
3267
|
+
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsx(DocumentActionButton, { ...action }, action.id))
|
3268
|
+
}
|
3269
|
+
) });
|
3270
|
+
};
|
3271
|
+
const DeleteAction = ({ documents, model }) => {
|
3272
|
+
const { formatMessage } = useIntl();
|
3273
|
+
const { schema: contentType } = useDoc();
|
3274
|
+
const selectRow = useTable("DeleteAction", (state) => state.selectRow);
|
3275
|
+
const hasI18nEnabled = Boolean(contentType?.pluginOptions?.i18n);
|
3276
|
+
const [{ query }] = useQueryParams();
|
3277
|
+
const params = React.useMemo(() => buildValidParams(query), [query]);
|
3278
|
+
const hasDeletePermission = useDocumentRBAC("deleteAction", (state) => state.canDelete);
|
3279
|
+
const { deleteMany: bulkDeleteAction } = useDocumentActions();
|
3280
|
+
const documentIds = documents.map(({ documentId }) => documentId);
|
3281
|
+
const handleConfirmBulkDelete = async () => {
|
3282
|
+
const res = await bulkDeleteAction({
|
3283
|
+
documentIds,
|
3284
|
+
model,
|
3285
|
+
params
|
3286
|
+
});
|
3287
|
+
if (!("error" in res)) {
|
3288
|
+
selectRow([]);
|
3289
|
+
}
|
3290
|
+
};
|
3291
|
+
if (!hasDeletePermission)
|
3292
|
+
return null;
|
2933
3293
|
return {
|
2934
|
-
|
2935
|
-
|
2936
|
-
|
2937
|
-
|
3294
|
+
variant: "danger-light",
|
3295
|
+
label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
|
3296
|
+
dialog: {
|
3297
|
+
type: "dialog",
|
3298
|
+
title: formatMessage({
|
3299
|
+
id: "app.components.ConfirmDialog.title",
|
3300
|
+
defaultMessage: "Confirmation"
|
3301
|
+
}),
|
3302
|
+
content: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3303
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3304
|
+
/* @__PURE__ */ jsx(Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3305
|
+
id: "popUpWarning.bodyMessage.contentType.delete.all",
|
3306
|
+
defaultMessage: "Are you sure you want to delete these entries?"
|
3307
|
+
}) }),
|
3308
|
+
hasI18nEnabled && /* @__PURE__ */ jsx(Box, { textAlign: "center", padding: 3, children: /* @__PURE__ */ jsx(Typography, { textColor: "danger500", children: formatMessage(
|
3309
|
+
{
|
3310
|
+
id: getTranslation("Settings.list.actions.deleteAdditionalInfos"),
|
3311
|
+
defaultMessage: "This will delete the active locale versions <em>(from Internationalization)</em>"
|
3312
|
+
},
|
3313
|
+
{
|
3314
|
+
em: Emphasis
|
3315
|
+
}
|
3316
|
+
) }) })
|
3317
|
+
] }),
|
3318
|
+
onConfirm: handleConfirmBulkDelete
|
3319
|
+
}
|
2938
3320
|
};
|
2939
3321
|
};
|
2940
|
-
|
2941
|
-
|
2942
|
-
|
3322
|
+
DeleteAction.type = "delete";
|
3323
|
+
const UnpublishAction = ({ documents, model }) => {
|
3324
|
+
const { formatMessage } = useIntl();
|
3325
|
+
const { schema } = useDoc();
|
3326
|
+
const selectRow = useTable("UnpublishAction", (state) => state.selectRow);
|
3327
|
+
const hasPublishPermission = useDocumentRBAC("unpublishAction", (state) => state.canPublish);
|
3328
|
+
const hasI18nEnabled = Boolean(schema?.pluginOptions?.i18n);
|
3329
|
+
const hasDraftAndPublishEnabled = Boolean(schema?.options?.draftAndPublish);
|
3330
|
+
const { unpublishMany: bulkUnpublishAction } = useDocumentActions();
|
3331
|
+
const documentIds = documents.map(({ documentId }) => documentId);
|
3332
|
+
const [{ query }] = useQueryParams();
|
3333
|
+
const params = React.useMemo(() => buildValidParams(query), [query]);
|
3334
|
+
const handleConfirmBulkUnpublish = async () => {
|
3335
|
+
const data = await bulkUnpublishAction({ documentIds, model, params });
|
3336
|
+
if (!("error" in data)) {
|
3337
|
+
selectRow([]);
|
3338
|
+
}
|
3339
|
+
};
|
3340
|
+
const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
|
3341
|
+
if (!showUnpublishButton)
|
3342
|
+
return null;
|
3343
|
+
return {
|
3344
|
+
variant: "tertiary",
|
3345
|
+
label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
|
3346
|
+
dialog: {
|
3347
|
+
type: "dialog",
|
3348
|
+
title: formatMessage({
|
3349
|
+
id: "app.components.ConfirmDialog.title",
|
3350
|
+
defaultMessage: "Confirmation"
|
3351
|
+
}),
|
3352
|
+
content: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
3353
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
|
3354
|
+
/* @__PURE__ */ jsx(Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
3355
|
+
id: "popUpWarning.bodyMessage.contentType.unpublish.all",
|
3356
|
+
defaultMessage: "Are you sure you want to unpublish these entries?"
|
3357
|
+
}) }),
|
3358
|
+
hasI18nEnabled && /* @__PURE__ */ jsx(Box, { textAlign: "center", padding: 3, children: /* @__PURE__ */ jsx(Typography, { textColor: "danger500", children: formatMessage(
|
3359
|
+
{
|
3360
|
+
id: getTranslation("Settings.list.actions.unpublishAdditionalInfos"),
|
3361
|
+
defaultMessage: "This will unpublish the active locale versions <em>(from Internationalization)</em>"
|
3362
|
+
},
|
3363
|
+
{
|
3364
|
+
em: Emphasis
|
3365
|
+
}
|
3366
|
+
) }) })
|
3367
|
+
] }),
|
3368
|
+
confirmButton: formatMessage({
|
3369
|
+
id: "app.utils.unpublish",
|
3370
|
+
defaultMessage: "Unpublish"
|
3371
|
+
}),
|
3372
|
+
onConfirm: handleConfirmBulkUnpublish
|
3373
|
+
}
|
3374
|
+
};
|
2943
3375
|
};
|
2944
|
-
|
2945
|
-
|
2946
|
-
|
2947
|
-
|
2948
|
-
}
|
2949
|
-
|
2950
|
-
|
2951
|
-
|
2952
|
-
|
2953
|
-
|
2954
|
-
|
2955
|
-
|
2956
|
-
|
2957
|
-
|
2958
|
-
|
2959
|
-
|
2960
|
-
|
2961
|
-
|
2962
|
-
|
3376
|
+
UnpublishAction.type = "unpublish";
|
3377
|
+
const Emphasis = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "semiBold", textColor: "danger500", children: chunks });
|
3378
|
+
const DEFAULT_BULK_ACTIONS = [PublishAction, UnpublishAction, DeleteAction];
|
3379
|
+
const AutoCloneFailureModalBody = ({ prohibitedFields }) => {
|
3380
|
+
const { formatMessage } = useIntl();
|
3381
|
+
const getDefaultErrorMessage = (reason) => {
|
3382
|
+
switch (reason) {
|
3383
|
+
case "relation":
|
3384
|
+
return "Duplicating the relation could remove it from the original entry.";
|
3385
|
+
case "unique":
|
3386
|
+
return "Identical values in a unique field are not allowed";
|
3387
|
+
default:
|
3388
|
+
return reason;
|
3389
|
+
}
|
3390
|
+
};
|
3391
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
3392
|
+
/* @__PURE__ */ jsx(Typography, { variant: "beta", children: formatMessage({
|
3393
|
+
id: getTranslation("containers.list.autoCloneModal.title"),
|
3394
|
+
defaultMessage: "This entry can't be duplicated directly."
|
3395
|
+
}) }),
|
3396
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 2, children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatMessage({
|
3397
|
+
id: getTranslation("containers.list.autoCloneModal.description"),
|
3398
|
+
defaultMessage: "A new entry will be created with the same content, but you'll have to change the following fields to save it."
|
3399
|
+
}) }) }),
|
3400
|
+
/* @__PURE__ */ jsx(Flex, { marginTop: 6, gap: 2, direction: "column", alignItems: "stretch", children: prohibitedFields.map(([fieldPath, reason]) => /* @__PURE__ */ jsxs(
|
3401
|
+
Flex,
|
3402
|
+
{
|
3403
|
+
direction: "column",
|
3404
|
+
gap: 2,
|
3405
|
+
alignItems: "flex-start",
|
3406
|
+
borderColor: "neutral200",
|
3407
|
+
hasRadius: true,
|
3408
|
+
padding: 6,
|
3409
|
+
children: [
|
3410
|
+
/* @__PURE__ */ jsx(Flex, { direction: "row", tag: "ol", children: fieldPath.map((pathSegment, index2) => /* @__PURE__ */ jsxs(Typography, { fontWeight: "semiBold", tag: "li", children: [
|
3411
|
+
pathSegment,
|
3412
|
+
index2 !== fieldPath.length - 1 && /* @__PURE__ */ jsx(
|
3413
|
+
ChevronRight,
|
3414
|
+
{
|
3415
|
+
fill: "neutral500",
|
3416
|
+
height: "0.8rem",
|
3417
|
+
width: "0.8rem",
|
3418
|
+
style: { margin: "0 0.8rem" }
|
3419
|
+
}
|
3420
|
+
)
|
3421
|
+
] }, index2)) }),
|
3422
|
+
/* @__PURE__ */ jsx(Typography, { tag: "p", textColor: "neutral600", children: formatMessage({
|
3423
|
+
id: getTranslation(`containers.list.autoCloneModal.error.${reason}`),
|
3424
|
+
defaultMessage: getDefaultErrorMessage(reason)
|
3425
|
+
}) })
|
3426
|
+
]
|
3427
|
+
},
|
3428
|
+
fieldPath.join()
|
3429
|
+
)) })
|
3430
|
+
] });
|
3431
|
+
};
|
3432
|
+
const TableActions = ({ document }) => {
|
3433
|
+
const { formatMessage } = useIntl();
|
3434
|
+
const { model, collectionType } = useDoc();
|
3435
|
+
const plugins = useStrapiApp("TableActions", (state) => state.plugins);
|
3436
|
+
const props = {
|
3437
|
+
activeTab: null,
|
3438
|
+
model,
|
3439
|
+
documentId: document.documentId,
|
3440
|
+
collectionType,
|
3441
|
+
document
|
3442
|
+
};
|
3443
|
+
return /* @__PURE__ */ jsx(
|
3444
|
+
DescriptionComponentRenderer,
|
3445
|
+
{
|
3446
|
+
props,
|
3447
|
+
descriptions: plugins["content-manager"].apis.getDocumentActions(),
|
3448
|
+
children: (actions2) => {
|
3449
|
+
const tableRowActions = actions2.filter((action) => {
|
3450
|
+
const positions = Array.isArray(action.position) ? action.position : [action.position];
|
3451
|
+
return positions.includes("table-row");
|
3452
|
+
});
|
3453
|
+
return /* @__PURE__ */ jsx(
|
3454
|
+
DocumentActionsMenu,
|
3455
|
+
{
|
3456
|
+
actions: tableRowActions,
|
3457
|
+
label: formatMessage({
|
3458
|
+
id: "content-manager.containers.list.table.row-actions",
|
3459
|
+
defaultMessage: "Row action"
|
3460
|
+
}),
|
3461
|
+
variant: "ghost"
|
3462
|
+
}
|
3463
|
+
);
|
2963
3464
|
}
|
2964
|
-
panels[currentPanelIndex].push(row);
|
2965
3465
|
}
|
2966
|
-
return panels;
|
2967
|
-
}, []);
|
2968
|
-
const componentEditAttributes = Object.entries(data.components).reduce(
|
2969
|
-
(acc, [uid, configuration]) => {
|
2970
|
-
acc[uid] = {
|
2971
|
-
layout: convertEditLayoutToFieldLayouts(
|
2972
|
-
configuration.layouts.edit,
|
2973
|
-
components[uid].attributes,
|
2974
|
-
configuration.metadatas
|
2975
|
-
),
|
2976
|
-
settings: {
|
2977
|
-
...configuration.settings,
|
2978
|
-
icon: components[uid].info.icon,
|
2979
|
-
displayName: components[uid].info.displayName
|
2980
|
-
}
|
2981
|
-
};
|
2982
|
-
return acc;
|
2983
|
-
},
|
2984
|
-
{}
|
2985
|
-
);
|
2986
|
-
const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
2987
|
-
(acc, [attribute, metadata]) => {
|
2988
|
-
return {
|
2989
|
-
...acc,
|
2990
|
-
[attribute]: metadata.edit
|
2991
|
-
};
|
2992
|
-
},
|
2993
|
-
{}
|
2994
3466
|
);
|
3467
|
+
};
|
3468
|
+
const EditAction = ({ documentId }) => {
|
3469
|
+
const navigate = useNavigate();
|
3470
|
+
const { formatMessage } = useIntl();
|
3471
|
+
const { canRead } = useDocumentRBAC("EditAction", ({ canRead: canRead2 }) => ({ canRead: canRead2 }));
|
3472
|
+
const { toggleNotification } = useNotification();
|
3473
|
+
const [{ query }] = useQueryParams();
|
2995
3474
|
return {
|
2996
|
-
|
2997
|
-
|
2998
|
-
|
2999
|
-
|
3000
|
-
|
3001
|
-
|
3002
|
-
|
3003
|
-
|
3004
|
-
|
3005
|
-
|
3006
|
-
|
3475
|
+
disabled: !canRead,
|
3476
|
+
icon: /* @__PURE__ */ jsx(StyledPencil, {}),
|
3477
|
+
label: formatMessage({
|
3478
|
+
id: "content-manager.actions.edit.label",
|
3479
|
+
defaultMessage: "Edit"
|
3480
|
+
}),
|
3481
|
+
position: "table-row",
|
3482
|
+
onClick: async () => {
|
3483
|
+
if (!documentId) {
|
3484
|
+
console.error(
|
3485
|
+
"You're trying to edit a document without an id, this is likely a bug with Strapi. Please open an issue."
|
3486
|
+
);
|
3487
|
+
toggleNotification({
|
3488
|
+
message: formatMessage({
|
3489
|
+
id: "content-manager.actions.edit.error",
|
3490
|
+
defaultMessage: "An error occurred while trying to edit the document."
|
3491
|
+
}),
|
3492
|
+
type: "danger"
|
3493
|
+
});
|
3494
|
+
return;
|
3495
|
+
}
|
3496
|
+
navigate({
|
3497
|
+
pathname: documentId,
|
3498
|
+
search: stringify({
|
3499
|
+
plugins: query.plugins
|
3500
|
+
})
|
3501
|
+
});
|
3007
3502
|
}
|
3008
3503
|
};
|
3009
3504
|
};
|
3010
|
-
|
3011
|
-
|
3012
|
-
|
3013
|
-
|
3014
|
-
|
3015
|
-
|
3505
|
+
EditAction.type = "edit";
|
3506
|
+
const StyledPencil = styled(Pencil)`
|
3507
|
+
path {
|
3508
|
+
fill: currentColor;
|
3509
|
+
}
|
3510
|
+
`;
|
3511
|
+
const CloneAction = ({ model, documentId }) => {
|
3512
|
+
const navigate = useNavigate();
|
3513
|
+
const { formatMessage } = useIntl();
|
3514
|
+
const { canCreate } = useDocumentRBAC("CloneAction", ({ canCreate: canCreate2 }) => ({ canCreate: canCreate2 }));
|
3515
|
+
const { toggleNotification } = useNotification();
|
3516
|
+
const { autoClone } = useDocumentActions();
|
3517
|
+
const [prohibitedFields, setProhibitedFields] = React.useState([]);
|
3518
|
+
return {
|
3519
|
+
disabled: !canCreate,
|
3520
|
+
icon: /* @__PURE__ */ jsx(StyledDuplicate, {}),
|
3521
|
+
label: formatMessage({
|
3522
|
+
id: "content-manager.actions.clone.label",
|
3523
|
+
defaultMessage: "Duplicate"
|
3524
|
+
}),
|
3525
|
+
position: "table-row",
|
3526
|
+
onClick: async () => {
|
3527
|
+
if (!documentId) {
|
3528
|
+
console.error(
|
3529
|
+
"You're trying to clone a document in the table without an id, this is likely a bug with Strapi. Please open an issue."
|
3530
|
+
);
|
3531
|
+
toggleNotification({
|
3532
|
+
message: formatMessage({
|
3533
|
+
id: "content-manager.actions.clone.error",
|
3534
|
+
defaultMessage: "An error occurred while trying to clone the document."
|
3535
|
+
}),
|
3536
|
+
type: "danger"
|
3537
|
+
});
|
3538
|
+
return;
|
3539
|
+
}
|
3540
|
+
const res = await autoClone({ model, sourceId: documentId });
|
3541
|
+
if ("data" in res) {
|
3542
|
+
navigate(res.data.documentId);
|
3543
|
+
return true;
|
3544
|
+
}
|
3545
|
+
if (isBaseQueryError(res.error) && res.error.details && typeof res.error.details === "object" && "prohibitedFields" in res.error.details && Array.isArray(res.error.details.prohibitedFields)) {
|
3546
|
+
const prohibitedFields2 = res.error.details.prohibitedFields;
|
3547
|
+
setProhibitedFields(prohibitedFields2);
|
3016
3548
|
}
|
3017
|
-
const { edit: metadata } = metadatas[field.name];
|
3018
|
-
const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
|
3019
|
-
return {
|
3020
|
-
attribute,
|
3021
|
-
disabled: !metadata.editable,
|
3022
|
-
hint: metadata.description,
|
3023
|
-
label: metadata.label ?? "",
|
3024
|
-
name: field.name,
|
3025
|
-
// @ts-expect-error – mainField does exist on the metadata for a relation.
|
3026
|
-
mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
|
3027
|
-
schemas,
|
3028
|
-
components: components?.schemas ?? {}
|
3029
|
-
}),
|
3030
|
-
placeholder: metadata.placeholder ?? "",
|
3031
|
-
required: attribute.required ?? false,
|
3032
|
-
size: field.size,
|
3033
|
-
unique: "unique" in attribute ? attribute.unique : false,
|
3034
|
-
visible: metadata.visible ?? true,
|
3035
|
-
type: attribute.type
|
3036
|
-
};
|
3037
|
-
}).filter((field) => field !== null)
|
3038
|
-
);
|
3039
|
-
};
|
3040
|
-
const formatListLayout = (data, {
|
3041
|
-
schemas,
|
3042
|
-
schema,
|
3043
|
-
components
|
3044
|
-
}) => {
|
3045
|
-
const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
|
3046
|
-
(acc, [attribute, metadata]) => {
|
3047
|
-
return {
|
3048
|
-
...acc,
|
3049
|
-
[attribute]: metadata.list
|
3050
|
-
};
|
3051
3549
|
},
|
3052
|
-
{
|
3053
|
-
|
3054
|
-
|
3055
|
-
|
3056
|
-
|
3057
|
-
|
3058
|
-
|
3059
|
-
|
3060
|
-
|
3061
|
-
|
3062
|
-
|
3063
|
-
|
3064
|
-
|
3065
|
-
|
3066
|
-
|
3067
|
-
|
3068
|
-
|
3550
|
+
dialog: {
|
3551
|
+
type: "modal",
|
3552
|
+
title: formatMessage({
|
3553
|
+
id: "content-manager.containers.list.autoCloneModal.header",
|
3554
|
+
defaultMessage: "Duplicate"
|
3555
|
+
}),
|
3556
|
+
content: /* @__PURE__ */ jsx(AutoCloneFailureModalBody, { prohibitedFields }),
|
3557
|
+
footer: ({ onClose }) => {
|
3558
|
+
return /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
|
3559
|
+
/* @__PURE__ */ jsx(Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
|
3560
|
+
id: "cancel",
|
3561
|
+
defaultMessage: "Cancel"
|
3562
|
+
}) }),
|
3563
|
+
/* @__PURE__ */ jsx(
|
3564
|
+
LinkButton,
|
3565
|
+
{
|
3566
|
+
tag: NavLink,
|
3567
|
+
to: {
|
3568
|
+
pathname: `clone/${documentId}`
|
3569
|
+
},
|
3570
|
+
children: formatMessage({
|
3571
|
+
id: "content-manager.containers.list.autoCloneModal.create",
|
3572
|
+
defaultMessage: "Create"
|
3573
|
+
})
|
3574
|
+
}
|
3575
|
+
)
|
3576
|
+
] });
|
3577
|
+
}
|
3069
3578
|
}
|
3070
3579
|
};
|
3071
3580
|
};
|
3072
|
-
|
3073
|
-
|
3074
|
-
|
3075
|
-
|
3076
|
-
|
3581
|
+
CloneAction.type = "clone";
|
3582
|
+
const StyledDuplicate = styled(Duplicate)`
|
3583
|
+
path {
|
3584
|
+
fill: currentColor;
|
3585
|
+
}
|
3586
|
+
`;
|
3587
|
+
const DEFAULT_TABLE_ROW_ACTIONS = [EditAction, CloneAction];
|
3588
|
+
class ContentManagerPlugin {
|
3589
|
+
/**
|
3590
|
+
* The following properties are the stored ones provided by any plugins registering with
|
3591
|
+
* the content-manager. The function calls however, need to be called at runtime in the
|
3592
|
+
* application, so instead we collate them and run them later with the complete list incl.
|
3593
|
+
* ones already registered & the context of the view.
|
3594
|
+
*/
|
3595
|
+
bulkActions = [...DEFAULT_BULK_ACTIONS];
|
3596
|
+
documentActions = [
|
3597
|
+
...DEFAULT_ACTIONS,
|
3598
|
+
...DEFAULT_TABLE_ROW_ACTIONS,
|
3599
|
+
...DEFAULT_HEADER_ACTIONS,
|
3600
|
+
HistoryAction
|
3601
|
+
];
|
3602
|
+
editViewSidePanels = [ActionsPanel];
|
3603
|
+
headerActions = [];
|
3604
|
+
constructor() {
|
3605
|
+
}
|
3606
|
+
addEditViewSidePanel(panels) {
|
3607
|
+
if (Array.isArray(panels)) {
|
3608
|
+
this.editViewSidePanels = [...this.editViewSidePanels, ...panels];
|
3609
|
+
} else if (typeof panels === "function") {
|
3610
|
+
this.editViewSidePanels = panels(this.editViewSidePanels);
|
3611
|
+
} else {
|
3612
|
+
throw new Error(
|
3613
|
+
`Expected the \`panels\` passed to \`addEditViewSidePanel\` to be an array or a function, but received ${getPrintableType(
|
3614
|
+
panels
|
3615
|
+
)}`
|
3616
|
+
);
|
3077
3617
|
}
|
3078
|
-
|
3079
|
-
|
3618
|
+
}
|
3619
|
+
addDocumentAction(actions2) {
|
3620
|
+
if (Array.isArray(actions2)) {
|
3621
|
+
this.documentActions = [...this.documentActions, ...actions2];
|
3622
|
+
} else if (typeof actions2 === "function") {
|
3623
|
+
this.documentActions = actions2(this.documentActions);
|
3624
|
+
} else {
|
3625
|
+
throw new Error(
|
3626
|
+
`Expected the \`actions\` passed to \`addDocumentAction\` to be an array or a function, but received ${getPrintableType(
|
3627
|
+
actions2
|
3628
|
+
)}`
|
3629
|
+
);
|
3630
|
+
}
|
3631
|
+
}
|
3632
|
+
addDocumentHeaderAction(actions2) {
|
3633
|
+
if (Array.isArray(actions2)) {
|
3634
|
+
this.headerActions = [...this.headerActions, ...actions2];
|
3635
|
+
} else if (typeof actions2 === "function") {
|
3636
|
+
this.headerActions = actions2(this.headerActions);
|
3637
|
+
} else {
|
3638
|
+
throw new Error(
|
3639
|
+
`Expected the \`actions\` passed to \`addDocumentHeaderAction\` to be an array or a function, but received ${getPrintableType(
|
3640
|
+
actions2
|
3641
|
+
)}`
|
3642
|
+
);
|
3643
|
+
}
|
3644
|
+
}
|
3645
|
+
addBulkAction(actions2) {
|
3646
|
+
if (Array.isArray(actions2)) {
|
3647
|
+
this.bulkActions = [...this.bulkActions, ...actions2];
|
3648
|
+
} else if (typeof actions2 === "function") {
|
3649
|
+
this.bulkActions = actions2(this.bulkActions);
|
3650
|
+
} else {
|
3651
|
+
throw new Error(
|
3652
|
+
`Expected the \`actions\` passed to \`addBulkAction\` to be an array or a function, but received ${getPrintableType(
|
3653
|
+
actions2
|
3654
|
+
)}`
|
3655
|
+
);
|
3656
|
+
}
|
3657
|
+
}
|
3658
|
+
get config() {
|
3080
3659
|
return {
|
3081
|
-
|
3082
|
-
|
3083
|
-
|
3084
|
-
|
3085
|
-
|
3086
|
-
|
3087
|
-
|
3088
|
-
|
3089
|
-
|
3660
|
+
id: PLUGIN_ID,
|
3661
|
+
name: "Content Manager",
|
3662
|
+
injectionZones: INJECTION_ZONES,
|
3663
|
+
apis: {
|
3664
|
+
addBulkAction: this.addBulkAction.bind(this),
|
3665
|
+
addDocumentAction: this.addDocumentAction.bind(this),
|
3666
|
+
addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
|
3667
|
+
addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
|
3668
|
+
getBulkActions: () => this.bulkActions,
|
3669
|
+
getDocumentActions: () => this.documentActions,
|
3670
|
+
getEditViewSidePanels: () => this.editViewSidePanels,
|
3671
|
+
getHeaderActions: () => this.headerActions
|
3672
|
+
}
|
3090
3673
|
};
|
3091
|
-
}
|
3674
|
+
}
|
3675
|
+
}
|
3676
|
+
const getPrintableType = (value) => {
|
3677
|
+
const nativeType = typeof value;
|
3678
|
+
if (nativeType === "object") {
|
3679
|
+
if (value === null)
|
3680
|
+
return "null";
|
3681
|
+
if (Array.isArray(value))
|
3682
|
+
return "array";
|
3683
|
+
if (value instanceof Object && value.constructor.name !== "Object") {
|
3684
|
+
return value.constructor.name;
|
3685
|
+
}
|
3686
|
+
}
|
3687
|
+
return nativeType;
|
3688
|
+
};
|
3689
|
+
const initialState = {
|
3690
|
+
collectionTypeLinks: [],
|
3691
|
+
components: [],
|
3692
|
+
fieldSizes: {},
|
3693
|
+
models: [],
|
3694
|
+
singleTypeLinks: [],
|
3695
|
+
isLoading: true
|
3092
3696
|
};
|
3697
|
+
const appSlice = createSlice({
|
3698
|
+
name: "app",
|
3699
|
+
initialState,
|
3700
|
+
reducers: {
|
3701
|
+
setInitialData(state, action) {
|
3702
|
+
const {
|
3703
|
+
authorizedCollectionTypeLinks,
|
3704
|
+
authorizedSingleTypeLinks,
|
3705
|
+
components,
|
3706
|
+
contentTypeSchemas,
|
3707
|
+
fieldSizes
|
3708
|
+
} = action.payload;
|
3709
|
+
state.collectionTypeLinks = authorizedCollectionTypeLinks.filter(
|
3710
|
+
({ isDisplayed }) => isDisplayed
|
3711
|
+
);
|
3712
|
+
state.singleTypeLinks = authorizedSingleTypeLinks.filter(({ isDisplayed }) => isDisplayed);
|
3713
|
+
state.components = components;
|
3714
|
+
state.models = contentTypeSchemas;
|
3715
|
+
state.fieldSizes = fieldSizes;
|
3716
|
+
state.isLoading = false;
|
3717
|
+
}
|
3718
|
+
}
|
3719
|
+
});
|
3720
|
+
const { actions, reducer: reducer$1 } = appSlice;
|
3721
|
+
const { setInitialData } = actions;
|
3722
|
+
const reducer = combineReducers({
|
3723
|
+
app: reducer$1
|
3724
|
+
});
|
3093
3725
|
const index = {
|
3094
3726
|
register(app) {
|
3095
3727
|
const cm = new ContentManagerPlugin();
|
3096
3728
|
app.addReducers({
|
3097
|
-
[contentManagerApi.reducerPath]: contentManagerApi.reducer,
|
3098
3729
|
[PLUGIN_ID]: reducer
|
3099
3730
|
});
|
3100
|
-
app.addMiddlewares([() => contentManagerApi.middleware]);
|
3101
3731
|
app.addMenuLink({
|
3102
3732
|
to: PLUGIN_ID,
|
3103
3733
|
icon: Feather,
|
@@ -3106,14 +3736,24 @@ const index = {
|
|
3106
3736
|
defaultMessage: "Content Manager"
|
3107
3737
|
},
|
3108
3738
|
permissions: [],
|
3109
|
-
|
3739
|
+
position: 1
|
3740
|
+
});
|
3741
|
+
app.router.addRoute({
|
3742
|
+
path: "content-manager/*",
|
3743
|
+
lazy: async () => {
|
3744
|
+
const { Layout } = await import("./layout-ChVuUpa1.mjs");
|
3745
|
+
return {
|
3746
|
+
Component: Layout
|
3747
|
+
};
|
3748
|
+
},
|
3749
|
+
children: routes
|
3110
3750
|
});
|
3111
3751
|
app.registerPlugin(cm.config);
|
3112
3752
|
},
|
3113
3753
|
async registerTrads({ locales }) {
|
3114
3754
|
const importedTrads = await Promise.all(
|
3115
3755
|
locales.map((locale) => {
|
3116
|
-
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-
|
3756
|
+
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-Ux26r5pl.mjs"), "./translations/es.json": () => import("./es-CeXiYflN.mjs"), "./translations/eu.json": () => import("./eu-CdALomew.mjs"), "./translations/fr.json": () => import("./fr-CD9VFbPM.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-CtsUxOvk.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 }) => {
|
3117
3757
|
return {
|
3118
3758
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3119
3759
|
locale
|
@@ -3131,7 +3771,7 @@ const index = {
|
|
3131
3771
|
};
|
3132
3772
|
export {
|
3133
3773
|
ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD as A,
|
3134
|
-
|
3774
|
+
BulkActionsRenderer as B,
|
3135
3775
|
COLLECTION_TYPES as C,
|
3136
3776
|
DocumentStatus as D,
|
3137
3777
|
DEFAULT_SETTINGS as E,
|
@@ -3145,31 +3785,31 @@ export {
|
|
3145
3785
|
RelativeTime as R,
|
3146
3786
|
SINGLE_TYPES as S,
|
3147
3787
|
TableActions as T,
|
3148
|
-
|
3149
|
-
|
3150
|
-
|
3151
|
-
|
3152
|
-
|
3153
|
-
|
3788
|
+
useGetInitialDataQuery as a,
|
3789
|
+
useGetAllContentTypeSettingsQuery as b,
|
3790
|
+
useDoc as c,
|
3791
|
+
buildValidParams as d,
|
3792
|
+
contentManagerApi as e,
|
3793
|
+
useDocumentRBAC as f,
|
3154
3794
|
getTranslation as g,
|
3155
|
-
|
3156
|
-
|
3157
|
-
|
3158
|
-
|
3159
|
-
|
3160
|
-
|
3161
|
-
|
3795
|
+
useDocumentLayout as h,
|
3796
|
+
createYupSchema as i,
|
3797
|
+
Header as j,
|
3798
|
+
PERMISSIONS as k,
|
3799
|
+
DocumentRBAC as l,
|
3800
|
+
DOCUMENT_META_FIELDS as m,
|
3801
|
+
useDocLayout as n,
|
3162
3802
|
useGetContentTypeConfigurationQuery as o,
|
3163
3803
|
CREATOR_FIELDS as p,
|
3164
3804
|
getMainField as q,
|
3165
|
-
|
3805
|
+
getDisplayName as r,
|
3166
3806
|
setInitialData as s,
|
3167
|
-
|
3168
|
-
|
3169
|
-
|
3170
|
-
|
3171
|
-
|
3172
|
-
|
3173
|
-
|
3174
|
-
};
|
3175
|
-
//# sourceMappingURL=index-
|
3807
|
+
checkIfAttributeIsDisplayable as t,
|
3808
|
+
useContentTypeSchema as u,
|
3809
|
+
useGetAllDocumentsQuery as v,
|
3810
|
+
convertListLayoutToFieldLayouts as w,
|
3811
|
+
capitalise as x,
|
3812
|
+
useUpdateContentTypeConfigurationMutation as y,
|
3813
|
+
extractContentTypeComponents as z
|
3814
|
+
};
|
3815
|
+
//# sourceMappingURL=index-D1344xdw.mjs.map
|