@strapi/content-manager 5.0.0-beta.7 → 5.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{ComponentConfigurationPage-uTMkLI60.mjs → ComponentConfigurationPage-CuWgXugY.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-uTMkLI60.mjs.map → ComponentConfigurationPage-CuWgXugY.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-DMq0wvcL.js → ComponentConfigurationPage-by0e_kNd.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-DMq0wvcL.js.map → ComponentConfigurationPage-by0e_kNd.js.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-BFpQwwbc.js → EditConfigurationPage-CqBeCPGH.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-BFpQwwbc.js.map → EditConfigurationPage-CqBeCPGH.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-B2HhCh-b.mjs → EditConfigurationPage-DbI4KMyz.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-B2HhCh-b.mjs.map → EditConfigurationPage-DbI4KMyz.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-CXXue16T.js → EditViewPage-ChgloMyO.js} +5 -5
- package/dist/_chunks/{EditViewPage-CXXue16T.js.map → EditViewPage-ChgloMyO.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-BVIrgjyG.mjs → EditViewPage-dFPBya9U.mjs} +5 -5
- package/dist/_chunks/{EditViewPage-BVIrgjyG.mjs.map → EditViewPage-dFPBya9U.mjs.map} +1 -1
- package/dist/_chunks/{Field-0_2h1vuK.mjs → Field-C1nUKcdS.mjs} +240 -357
- package/dist/_chunks/Field-C1nUKcdS.mjs.map +1 -0
- package/dist/_chunks/{Field-ZgzKlgxR.js → Field-dLk-vgLL.js} +240 -357
- package/dist/_chunks/Field-dLk-vgLL.js.map +1 -0
- package/dist/_chunks/{Form-DgTc2qkx.js → Form-CbXtmHC_.js} +9 -6
- package/dist/_chunks/Form-CbXtmHC_.js.map +1 -0
- package/dist/_chunks/{Form-B7TUnQDd.mjs → Form-DOlpi7Js.mjs} +9 -6
- package/dist/_chunks/Form-DOlpi7Js.mjs.map +1 -0
- package/dist/_chunks/{History-Dug_4HIA.mjs → History-BFNUAiGc.mjs} +8 -8
- package/dist/_chunks/{History-Dug_4HIA.mjs.map → History-BFNUAiGc.mjs.map} +1 -1
- package/dist/_chunks/{History-DtHjQuqM.js → History-BjDfohBr.js} +8 -8
- package/dist/_chunks/{History-DtHjQuqM.js.map → History-BjDfohBr.js.map} +1 -1
- package/dist/_chunks/{ListConfigurationPage-CmEeNg6T.mjs → ListConfigurationPage-DDi0KqFm.mjs} +2 -2
- package/dist/_chunks/{ListConfigurationPage-CmEeNg6T.mjs.map → ListConfigurationPage-DDi0KqFm.mjs.map} +1 -1
- package/dist/_chunks/{ListConfigurationPage-BuSdTjfa.js → ListConfigurationPage-IQBgWTaa.js} +2 -2
- package/dist/_chunks/{ListConfigurationPage-BuSdTjfa.js.map → ListConfigurationPage-IQBgWTaa.js.map} +1 -1
- package/dist/_chunks/{ListViewPage-Dsoa3wEA.mjs → ListViewPage-BPjljUsH.mjs} +8 -16
- package/dist/_chunks/ListViewPage-BPjljUsH.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-CExWwa4S.js → ListViewPage-CZYGqlvF.js} +11 -18
- package/dist/_chunks/ListViewPage-CZYGqlvF.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DCUL8gVi.js → NoContentTypePage-BOAI6VZ1.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-DCUL8gVi.js.map → NoContentTypePage-BOAI6VZ1.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-Dh38hBXB.mjs → NoContentTypePage-DaWw67K-.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-Dh38hBXB.mjs.map → NoContentTypePage-DaWw67K-.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-Dt2O40ey.mjs → NoPermissionsPage-CZrJH00p.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-Dt2O40ey.mjs.map → NoPermissionsPage-CZrJH00p.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-BK-XCpIy.js → NoPermissionsPage-cYEtLc_e.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-BK-XCpIy.js.map → NoPermissionsPage-cYEtLc_e.js.map} +1 -1
- package/dist/_chunks/{Relations-DZyjWZHl.mjs → Relations-DTowyge2.mjs} +7 -5
- package/dist/_chunks/{Relations-DZyjWZHl.mjs.map → Relations-DTowyge2.mjs.map} +1 -1
- package/dist/_chunks/{Relations-CNypkp-g.js → Relations-DU6B7irU.js} +7 -5
- package/dist/_chunks/{Relations-CNypkp-g.js.map → Relations-DU6B7irU.js.map} +1 -1
- package/dist/_chunks/{en-C-V1_90f.js → en-DTULi5-d.js} +3 -1
- package/dist/_chunks/{en-C-V1_90f.js.map → en-DTULi5-d.js.map} +1 -1
- package/dist/_chunks/{en-MBPul9Su.mjs → en-GCOTL6jR.mjs} +3 -1
- package/dist/_chunks/{en-MBPul9Su.mjs.map → en-GCOTL6jR.mjs.map} +1 -1
- package/dist/_chunks/{index-B3c-4it4.mjs → index-BaGHmIir.mjs} +488 -196
- package/dist/_chunks/index-BaGHmIir.mjs.map +1 -0
- package/dist/_chunks/{index-DFK7LwDW.js → index-CCJeB7Rw.js} +480 -188
- package/dist/_chunks/index-CCJeB7Rw.js.map +1 -0
- package/dist/_chunks/{layout-B5cm7cZj.mjs → layout-BinjszSQ.mjs} +6 -6
- package/dist/_chunks/layout-BinjszSQ.mjs.map +1 -0
- package/dist/_chunks/{layout-DLih5-_W.js → layout-ni_L9kT1.js} +6 -6
- package/dist/_chunks/layout-ni_L9kT1.js.map +1 -0
- package/dist/_chunks/{relations-CTvkuINQ.js → relations-CeJAJc5I.js} +2 -2
- package/dist/_chunks/{relations-CTvkuINQ.js.map → relations-CeJAJc5I.js.map} +1 -1
- package/dist/_chunks/{relations-BZkrMa2z.mjs → relations-c91ji5eR.mjs} +2 -2
- package/dist/_chunks/{relations-BZkrMa2z.mjs.map → relations-c91ji5eR.mjs.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/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 +1 -1
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +3 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.d.ts +3 -3
- 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 +2 -15
- package/dist/admin/src/pages/EditView/components/FormInputs/UID.d.ts +2 -2
- 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 +56 -35
- package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +2 -10
- 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 -17
- package/dist/admin/src/utils/validation.d.ts +1 -6
- package/dist/server/index.js +232 -116
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +234 -118
- 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/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +12 -33
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts +6 -6
- 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 +12 -33
- 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 +11 -5
- 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 +11 -11
- package/dist/_chunks/ComponentIcon-BBQsYCVn.js.map +0 -1
- package/dist/_chunks/ComponentIcon-BOFnK76n.mjs.map +0 -1
- package/dist/_chunks/Field-0_2h1vuK.mjs.map +0 -1
- package/dist/_chunks/Field-ZgzKlgxR.js.map +0 -1
- package/dist/_chunks/Form-B7TUnQDd.mjs.map +0 -1
- package/dist/_chunks/Form-DgTc2qkx.js.map +0 -1
- package/dist/_chunks/ListViewPage-CExWwa4S.js.map +0 -1
- package/dist/_chunks/ListViewPage-Dsoa3wEA.mjs.map +0 -1
- package/dist/_chunks/index-B3c-4it4.mjs.map +0 -1
- package/dist/_chunks/index-DFK7LwDW.js.map +0 -1
- package/dist/_chunks/layout-B5cm7cZj.mjs.map +0 -1
- package/dist/_chunks/layout-DLih5-_W.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/admin/src/pages/ListView/components/BulkActions/PublishAction.d.ts +0 -31
- package/dist/server/src/controllers/utils/dimensions.d.ts +0 -5
- package/dist/server/src/controllers/utils/dimensions.d.ts.map +0 -1
@@ -9,7 +9,6 @@ const React = require("react");
|
|
9
9
|
const designSystem = require("@strapi/design-system");
|
10
10
|
const styledComponents = require("styled-components");
|
11
11
|
const yup = require("yup");
|
12
|
-
const react = require("@reduxjs/toolkit/query/react");
|
13
12
|
const pipe = require("lodash/fp/pipe");
|
14
13
|
const dateFns = require("date-fns");
|
15
14
|
const toolkit = require("@reduxjs/toolkit");
|
@@ -177,9 +176,8 @@ const DocumentRBAC = ({ children, permissions }) => {
|
|
177
176
|
const name = removeNumericalStrings(fieldName.split("."));
|
178
177
|
const componentFieldNames = fieldsUserCanAction.filter((field) => field.split(".").length > 1);
|
179
178
|
if (fieldType === "component") {
|
180
|
-
|
181
|
-
|
182
|
-
return field.includes(fieldName);
|
179
|
+
return componentFieldNames.some((field) => {
|
180
|
+
return field.includes(name.join("."));
|
183
181
|
});
|
184
182
|
}
|
185
183
|
if (name.length > 1) {
|
@@ -209,92 +207,8 @@ const extractAndDedupeFields = (permissions = []) => permissions.flatMap((permis
|
|
209
207
|
(field, index2, arr) => arr.indexOf(field) === index2 && typeof field === "string"
|
210
208
|
);
|
211
209
|
const removeNumericalStrings = (arr) => arr.filter((item) => isNaN(Number(item)));
|
212
|
-
const
|
213
|
-
|
214
|
-
return query;
|
215
|
-
const { plugins: _, ...validQueryParams } = {
|
216
|
-
...query,
|
217
|
-
...Object.values(query?.plugins ?? {}).reduce(
|
218
|
-
(acc, current) => Object.assign(acc, current),
|
219
|
-
{}
|
220
|
-
)
|
221
|
-
};
|
222
|
-
if ("_q" in validQueryParams) {
|
223
|
-
validQueryParams._q = encodeURIComponent(validQueryParams._q);
|
224
|
-
}
|
225
|
-
return validQueryParams;
|
226
|
-
};
|
227
|
-
const fetchBaseQuery = () => async (query, { signal }) => {
|
228
|
-
try {
|
229
|
-
const { get, post, del, put } = strapiAdmin.getFetchClient();
|
230
|
-
if (typeof query === "string") {
|
231
|
-
const result = await get(query, {
|
232
|
-
signal
|
233
|
-
});
|
234
|
-
return { data: result.data };
|
235
|
-
} else {
|
236
|
-
const { url, method = "GET", data, config } = query;
|
237
|
-
if (method === "POST") {
|
238
|
-
const result2 = await post(url, data, {
|
239
|
-
...config,
|
240
|
-
signal
|
241
|
-
});
|
242
|
-
return { data: result2.data };
|
243
|
-
}
|
244
|
-
if (method === "DELETE") {
|
245
|
-
const result2 = await del(url, {
|
246
|
-
...config,
|
247
|
-
signal
|
248
|
-
});
|
249
|
-
return { data: result2.data };
|
250
|
-
}
|
251
|
-
if (method === "PUT") {
|
252
|
-
const result2 = await put(url, data, {
|
253
|
-
...config,
|
254
|
-
signal
|
255
|
-
});
|
256
|
-
return { data: result2.data };
|
257
|
-
}
|
258
|
-
const result = await get(url, {
|
259
|
-
...config,
|
260
|
-
signal
|
261
|
-
});
|
262
|
-
return { data: result.data };
|
263
|
-
}
|
264
|
-
} catch (err) {
|
265
|
-
if (strapiAdmin.isFetchError(err)) {
|
266
|
-
if (typeof err.response?.data === "object" && err.response?.data !== null && "error" in err.response?.data) {
|
267
|
-
return { data: void 0, error: err.response?.data.error };
|
268
|
-
} else {
|
269
|
-
return {
|
270
|
-
data: void 0,
|
271
|
-
error: {
|
272
|
-
name: "UnknownError",
|
273
|
-
message: "There was an unknown error response from the API",
|
274
|
-
details: err.response,
|
275
|
-
status: err.status
|
276
|
-
}
|
277
|
-
};
|
278
|
-
}
|
279
|
-
}
|
280
|
-
const error = err;
|
281
|
-
return {
|
282
|
-
data: void 0,
|
283
|
-
error: {
|
284
|
-
name: error.name,
|
285
|
-
message: error.message,
|
286
|
-
stack: error.stack
|
287
|
-
}
|
288
|
-
};
|
289
|
-
}
|
290
|
-
};
|
291
|
-
const isBaseQueryError = (error) => {
|
292
|
-
return error.name !== void 0;
|
293
|
-
};
|
294
|
-
const contentManagerApi = react.createApi({
|
295
|
-
reducerPath: "contentManagerApi",
|
296
|
-
baseQuery: fetchBaseQuery(),
|
297
|
-
tagTypes: [
|
210
|
+
const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
|
211
|
+
addTagTypes: [
|
298
212
|
"ComponentConfiguration",
|
299
213
|
"ContentTypesConfiguration",
|
300
214
|
"ContentTypeSettings",
|
@@ -302,8 +216,7 @@ const contentManagerApi = react.createApi({
|
|
302
216
|
"InitialData",
|
303
217
|
"HistoryVersion",
|
304
218
|
"Relations"
|
305
|
-
]
|
306
|
-
endpoints: () => ({})
|
219
|
+
]
|
307
220
|
});
|
308
221
|
const documentApi = contentManagerApi.injectEndpoints({
|
309
222
|
endpoints: (builder) => ({
|
@@ -359,12 +272,15 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
359
272
|
]
|
360
273
|
}),
|
361
274
|
deleteManyDocuments: builder.mutation({
|
362
|
-
query: ({ model, ...body }) => ({
|
275
|
+
query: ({ model, params, ...body }) => ({
|
363
276
|
url: `/content-manager/collection-types/${model}/actions/bulkDelete`,
|
364
277
|
method: "POST",
|
365
|
-
data: body
|
278
|
+
data: body,
|
279
|
+
config: {
|
280
|
+
params
|
281
|
+
}
|
366
282
|
}),
|
367
|
-
invalidatesTags: (_res, _error, { model
|
283
|
+
invalidatesTags: (_res, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
|
368
284
|
}),
|
369
285
|
discardDocument: builder.mutation({
|
370
286
|
query: ({ collectionType, model, documentId, params }) => ({
|
@@ -475,10 +391,13 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
475
391
|
}
|
476
392
|
}),
|
477
393
|
publishManyDocuments: builder.mutation({
|
478
|
-
query: ({ model, ...body }) => ({
|
394
|
+
query: ({ model, params, ...body }) => ({
|
479
395
|
url: `/content-manager/collection-types/${model}/actions/bulkPublish`,
|
480
396
|
method: "POST",
|
481
|
-
data: body
|
397
|
+
data: body,
|
398
|
+
config: {
|
399
|
+
params
|
400
|
+
}
|
482
401
|
}),
|
483
402
|
invalidatesTags: (_res, _error, { model, documentIds }) => documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` }))
|
484
403
|
}),
|
@@ -520,10 +439,13 @@ const documentApi = contentManagerApi.injectEndpoints({
|
|
520
439
|
}
|
521
440
|
}),
|
522
441
|
unpublishManyDocuments: builder.mutation({
|
523
|
-
query: ({ model, ...body }) => ({
|
442
|
+
query: ({ model, params, ...body }) => ({
|
524
443
|
url: `/content-manager/collection-types/${model}/actions/bulkUnpublish`,
|
525
444
|
method: "POST",
|
526
|
-
data: body
|
445
|
+
data: body,
|
446
|
+
config: {
|
447
|
+
params
|
448
|
+
}
|
527
449
|
}),
|
528
450
|
invalidatesTags: (_res, _error, { model, documentIds }) => documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` }))
|
529
451
|
})
|
@@ -547,6 +469,24 @@ const {
|
|
547
469
|
useUnpublishDocumentMutation,
|
548
470
|
useUnpublishManyDocumentsMutation
|
549
471
|
} = documentApi;
|
472
|
+
const buildValidParams = (query) => {
|
473
|
+
if (!query)
|
474
|
+
return query;
|
475
|
+
const { plugins: _, ...validQueryParams } = {
|
476
|
+
...query,
|
477
|
+
...Object.values(query?.plugins ?? {}).reduce(
|
478
|
+
(acc, current) => Object.assign(acc, current),
|
479
|
+
{}
|
480
|
+
)
|
481
|
+
};
|
482
|
+
if ("_q" in validQueryParams) {
|
483
|
+
validQueryParams._q = encodeURIComponent(validQueryParams._q);
|
484
|
+
}
|
485
|
+
return validQueryParams;
|
486
|
+
};
|
487
|
+
const isBaseQueryError = (error) => {
|
488
|
+
return error.name !== void 0;
|
489
|
+
};
|
550
490
|
const createYupSchema = (attributes = {}, components = {}) => {
|
551
491
|
const createModelSchema = (attributes2) => yup__namespace.object().shape(
|
552
492
|
Object.entries(attributes2).reduce((acc, [name, attribute]) => {
|
@@ -586,10 +526,14 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
586
526
|
yup__namespace.array().of(
|
587
527
|
yup__namespace.lazy(
|
588
528
|
(data) => {
|
589
|
-
const
|
590
|
-
|
529
|
+
const attributes3 = components?.[data?.__component]?.attributes;
|
530
|
+
const validation = yup__namespace.object().shape({
|
591
531
|
__component: yup__namespace.string().required().oneOf(Object.keys(components))
|
592
|
-
}).nullable(false)
|
532
|
+
}).nullable(false);
|
533
|
+
if (!attributes3) {
|
534
|
+
return validation;
|
535
|
+
}
|
536
|
+
return validation.concat(createModelSchema(attributes3));
|
593
537
|
}
|
594
538
|
)
|
595
539
|
)
|
@@ -599,11 +543,25 @@ const createYupSchema = (attributes = {}, components = {}) => {
|
|
599
543
|
return {
|
600
544
|
...acc,
|
601
545
|
[name]: transformSchema(
|
602
|
-
yup__namespace.
|
603
|
-
|
604
|
-
|
605
|
-
})
|
606
|
-
|
546
|
+
yup__namespace.lazy((value) => {
|
547
|
+
if (!value) {
|
548
|
+
return yup__namespace.mixed().nullable(true);
|
549
|
+
} else if (Array.isArray(value)) {
|
550
|
+
return yup__namespace.array().of(
|
551
|
+
yup__namespace.object().shape({
|
552
|
+
id: yup__namespace.string().required()
|
553
|
+
})
|
554
|
+
);
|
555
|
+
} else if (typeof value === "object") {
|
556
|
+
return yup__namespace.object();
|
557
|
+
} else {
|
558
|
+
return yup__namespace.mixed().test(
|
559
|
+
"type-error",
|
560
|
+
"Relation values must be either null, an array of objects with {id} or an object.",
|
561
|
+
() => false
|
562
|
+
);
|
563
|
+
}
|
564
|
+
})
|
607
565
|
)
|
608
566
|
};
|
609
567
|
default:
|
@@ -668,7 +626,12 @@ const addRequiredValidation = (attribute) => (schema) => {
|
|
668
626
|
defaultMessage: "This field is required."
|
669
627
|
});
|
670
628
|
}
|
671
|
-
return schema.nullable()
|
629
|
+
return schema?.nullable ? schema.nullable() : (
|
630
|
+
// In some cases '.nullable' will not be available on the schema.
|
631
|
+
// e.g. when the schema has been built using yup.lazy (e.g. for relations).
|
632
|
+
// In these cases we should just return the schema as it is.
|
633
|
+
schema
|
634
|
+
);
|
672
635
|
};
|
673
636
|
const addMinLengthValidation = (attribute) => (schema) => {
|
674
637
|
if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
|
@@ -740,24 +703,6 @@ const addRegexValidation = (attribute) => (schema) => {
|
|
740
703
|
}
|
741
704
|
return schema;
|
742
705
|
};
|
743
|
-
const extractValuesFromYupError = (errorType, errorParams) => {
|
744
|
-
if (!errorType || !errorParams) {
|
745
|
-
return {};
|
746
|
-
}
|
747
|
-
return {
|
748
|
-
[errorType]: errorParams[errorType]
|
749
|
-
};
|
750
|
-
};
|
751
|
-
const getInnerErrors = (error) => (error?.inner || []).reduce((acc, currentError) => {
|
752
|
-
if (currentError.path) {
|
753
|
-
acc[currentError.path.split("[").join(".").split("]").join("")] = {
|
754
|
-
id: currentError.message,
|
755
|
-
defaultMessage: currentError.message,
|
756
|
-
values: extractValuesFromYupError(currentError?.type, currentError?.params)
|
757
|
-
};
|
758
|
-
}
|
759
|
-
return acc;
|
760
|
-
}, {});
|
761
706
|
const initApi = contentManagerApi.injectEndpoints({
|
762
707
|
endpoints: (builder) => ({
|
763
708
|
getInitialData: builder.query({
|
@@ -771,27 +716,20 @@ const { useGetInitialDataQuery } = initApi;
|
|
771
716
|
const useContentTypeSchema = (model) => {
|
772
717
|
const { toggleNotification } = strapiAdmin.useNotification();
|
773
718
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
774
|
-
const {
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
)
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
error: res.error,
|
789
|
-
components: Object.keys(components2).length === 0 ? void 0 : components2,
|
790
|
-
contentType: contentType2,
|
791
|
-
contentTypes: res.data?.contentTypes ?? []
|
792
|
-
};
|
793
|
-
}
|
794
|
-
});
|
719
|
+
const { data, error, isLoading, isFetching } = useGetInitialDataQuery(void 0);
|
720
|
+
const { components, contentType, contentTypes } = React__namespace.useMemo(() => {
|
721
|
+
const contentType2 = data?.contentTypes.find((ct) => ct.uid === model);
|
722
|
+
const componentsByKey = data?.components.reduce((acc, component) => {
|
723
|
+
acc[component.uid] = component;
|
724
|
+
return acc;
|
725
|
+
}, {});
|
726
|
+
const components2 = extractContentTypeComponents(contentType2?.attributes, componentsByKey);
|
727
|
+
return {
|
728
|
+
components: Object.keys(components2).length === 0 ? void 0 : components2,
|
729
|
+
contentType: contentType2,
|
730
|
+
contentTypes: data?.contentTypes ?? []
|
731
|
+
};
|
732
|
+
}, [model, data]);
|
795
733
|
React__namespace.useEffect(() => {
|
796
734
|
if (error) {
|
797
735
|
toggleNotification({
|
@@ -874,7 +812,7 @@ const useDocument = (args, opts) => {
|
|
874
812
|
return null;
|
875
813
|
} catch (error2) {
|
876
814
|
if (error2 instanceof yup.ValidationError) {
|
877
|
-
return
|
815
|
+
return strapiAdmin.getYupValidationErrors(error2);
|
878
816
|
}
|
879
817
|
throw error2;
|
880
818
|
}
|
@@ -970,6 +908,44 @@ const useDocumentActions = () => {
|
|
970
908
|
},
|
971
909
|
[trackUsage, deleteDocument, toggleNotification, formatMessage, formatAPIError]
|
972
910
|
);
|
911
|
+
const [deleteManyDocuments] = useDeleteManyDocumentsMutation();
|
912
|
+
const deleteMany = React__namespace.useCallback(
|
913
|
+
async ({ model, documentIds, params }) => {
|
914
|
+
try {
|
915
|
+
trackUsage("willBulkDeleteEntries");
|
916
|
+
const res = await deleteManyDocuments({
|
917
|
+
model,
|
918
|
+
documentIds,
|
919
|
+
params
|
920
|
+
});
|
921
|
+
if ("error" in res) {
|
922
|
+
toggleNotification({
|
923
|
+
type: "danger",
|
924
|
+
message: formatAPIError(res.error)
|
925
|
+
});
|
926
|
+
return { error: res.error };
|
927
|
+
}
|
928
|
+
toggleNotification({
|
929
|
+
type: "success",
|
930
|
+
title: formatMessage({
|
931
|
+
id: getTranslation("success.records.delete"),
|
932
|
+
defaultMessage: "Successfully deleted."
|
933
|
+
}),
|
934
|
+
message: ""
|
935
|
+
});
|
936
|
+
trackUsage("didBulkDeleteEntries");
|
937
|
+
return res.data;
|
938
|
+
} catch (err) {
|
939
|
+
toggleNotification({
|
940
|
+
type: "danger",
|
941
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
942
|
+
});
|
943
|
+
trackUsage("didNotBulkDeleteEntries");
|
944
|
+
throw err;
|
945
|
+
}
|
946
|
+
},
|
947
|
+
[trackUsage, deleteManyDocuments, toggleNotification, formatMessage, formatAPIError]
|
948
|
+
);
|
973
949
|
const [discardDocument] = useDiscardDocumentMutation();
|
974
950
|
const discard = React__namespace.useCallback(
|
975
951
|
async ({ collectionType, model, documentId }) => {
|
@@ -1039,6 +1015,43 @@ const useDocumentActions = () => {
|
|
1039
1015
|
},
|
1040
1016
|
[trackUsage, publishDocument, toggleNotification, formatMessage, formatAPIError]
|
1041
1017
|
);
|
1018
|
+
const [publishManyDocuments] = usePublishManyDocumentsMutation();
|
1019
|
+
const publishMany = React__namespace.useCallback(
|
1020
|
+
async ({ model, documentIds, params }) => {
|
1021
|
+
try {
|
1022
|
+
const res = await publishManyDocuments({
|
1023
|
+
model,
|
1024
|
+
documentIds,
|
1025
|
+
params
|
1026
|
+
});
|
1027
|
+
if ("error" in res) {
|
1028
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1029
|
+
return { error: res.error };
|
1030
|
+
}
|
1031
|
+
toggleNotification({
|
1032
|
+
type: "success",
|
1033
|
+
message: formatMessage({
|
1034
|
+
id: getTranslation("success.record.publish"),
|
1035
|
+
defaultMessage: "Published document"
|
1036
|
+
})
|
1037
|
+
});
|
1038
|
+
return res.data;
|
1039
|
+
} catch (err) {
|
1040
|
+
toggleNotification({
|
1041
|
+
type: "danger",
|
1042
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1043
|
+
});
|
1044
|
+
throw err;
|
1045
|
+
}
|
1046
|
+
},
|
1047
|
+
[
|
1048
|
+
// trackUsage,
|
1049
|
+
publishManyDocuments,
|
1050
|
+
toggleNotification,
|
1051
|
+
formatMessage,
|
1052
|
+
formatAPIError
|
1053
|
+
]
|
1054
|
+
);
|
1042
1055
|
const [updateDocument] = useUpdateDocumentMutation();
|
1043
1056
|
const update = React__namespace.useCallback(
|
1044
1057
|
async ({ collectionType, model, documentId, params }, data, trackerProperty) => {
|
@@ -1113,6 +1126,41 @@ const useDocumentActions = () => {
|
|
1113
1126
|
},
|
1114
1127
|
[trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
|
1115
1128
|
);
|
1129
|
+
const [unpublishManyDocuments] = useUnpublishManyDocumentsMutation();
|
1130
|
+
const unpublishMany = React__namespace.useCallback(
|
1131
|
+
async ({ model, documentIds, params }) => {
|
1132
|
+
try {
|
1133
|
+
trackUsage("willBulkUnpublishEntries");
|
1134
|
+
const res = await unpublishManyDocuments({
|
1135
|
+
model,
|
1136
|
+
documentIds,
|
1137
|
+
params
|
1138
|
+
});
|
1139
|
+
if ("error" in res) {
|
1140
|
+
toggleNotification({ type: "danger", message: formatAPIError(res.error) });
|
1141
|
+
return { error: res.error };
|
1142
|
+
}
|
1143
|
+
trackUsage("didBulkUnpublishEntries");
|
1144
|
+
toggleNotification({
|
1145
|
+
type: "success",
|
1146
|
+
title: formatMessage({
|
1147
|
+
id: getTranslation("success.records.unpublish"),
|
1148
|
+
defaultMessage: "Successfully unpublished."
|
1149
|
+
}),
|
1150
|
+
message: ""
|
1151
|
+
});
|
1152
|
+
return res.data;
|
1153
|
+
} catch (err) {
|
1154
|
+
toggleNotification({
|
1155
|
+
type: "danger",
|
1156
|
+
message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
|
1157
|
+
});
|
1158
|
+
trackUsage("didNotBulkUnpublishEntries");
|
1159
|
+
throw err;
|
1160
|
+
}
|
1161
|
+
},
|
1162
|
+
[trackUsage, unpublishManyDocuments, toggleNotification, formatMessage, formatAPIError]
|
1163
|
+
);
|
1116
1164
|
const [createDocument] = useCreateDocumentMutation();
|
1117
1165
|
const create = React__namespace.useCallback(
|
1118
1166
|
async ({ model, params }, data, trackerProperty) => {
|
@@ -1226,15 +1274,18 @@ const useDocumentActions = () => {
|
|
1226
1274
|
clone,
|
1227
1275
|
create,
|
1228
1276
|
delete: _delete,
|
1277
|
+
deleteMany,
|
1229
1278
|
discard,
|
1230
1279
|
getDocument,
|
1231
1280
|
publish,
|
1281
|
+
publishMany,
|
1232
1282
|
unpublish,
|
1283
|
+
unpublishMany,
|
1233
1284
|
update
|
1234
1285
|
};
|
1235
1286
|
};
|
1236
1287
|
const ProtectedHistoryPage = React.lazy(
|
1237
|
-
() => Promise.resolve().then(() => require("./History-
|
1288
|
+
() => Promise.resolve().then(() => require("./History-BjDfohBr.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
|
1238
1289
|
);
|
1239
1290
|
const routes$1 = [
|
1240
1291
|
{
|
@@ -1247,31 +1298,31 @@ const routes$1 = [
|
|
1247
1298
|
}
|
1248
1299
|
];
|
1249
1300
|
const ProtectedEditViewPage = React.lazy(
|
1250
|
-
() => Promise.resolve().then(() => require("./EditViewPage-
|
1301
|
+
() => Promise.resolve().then(() => require("./EditViewPage-ChgloMyO.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
|
1251
1302
|
);
|
1252
1303
|
const ProtectedListViewPage = React.lazy(
|
1253
|
-
() => Promise.resolve().then(() => require("./ListViewPage-
|
1304
|
+
() => Promise.resolve().then(() => require("./ListViewPage-CZYGqlvF.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
|
1254
1305
|
);
|
1255
1306
|
const ProtectedListConfiguration = React.lazy(
|
1256
|
-
() => Promise.resolve().then(() => require("./ListConfigurationPage-
|
1307
|
+
() => Promise.resolve().then(() => require("./ListConfigurationPage-IQBgWTaa.js")).then((mod) => ({
|
1257
1308
|
default: mod.ProtectedListConfiguration
|
1258
1309
|
}))
|
1259
1310
|
);
|
1260
1311
|
const ProtectedEditConfigurationPage = React.lazy(
|
1261
|
-
() => Promise.resolve().then(() => require("./EditConfigurationPage-
|
1312
|
+
() => Promise.resolve().then(() => require("./EditConfigurationPage-CqBeCPGH.js")).then((mod) => ({
|
1262
1313
|
default: mod.ProtectedEditConfigurationPage
|
1263
1314
|
}))
|
1264
1315
|
);
|
1265
1316
|
const ProtectedComponentConfigurationPage = React.lazy(
|
1266
|
-
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-
|
1317
|
+
() => Promise.resolve().then(() => require("./ComponentConfigurationPage-by0e_kNd.js")).then((mod) => ({
|
1267
1318
|
default: mod.ProtectedComponentConfigurationPage
|
1268
1319
|
}))
|
1269
1320
|
);
|
1270
1321
|
const NoPermissions = React.lazy(
|
1271
|
-
() => Promise.resolve().then(() => require("./NoPermissionsPage-
|
1322
|
+
() => Promise.resolve().then(() => require("./NoPermissionsPage-cYEtLc_e.js")).then((mod) => ({ default: mod.NoPermissions }))
|
1272
1323
|
);
|
1273
1324
|
const NoContentType = React.lazy(
|
1274
|
-
() => Promise.resolve().then(() => require("./NoContentTypePage-
|
1325
|
+
() => Promise.resolve().then(() => require("./NoContentTypePage-BOAI6VZ1.js")).then((mod) => ({ default: mod.NoContentType }))
|
1275
1326
|
);
|
1276
1327
|
const CollectionTypePages = () => {
|
1277
1328
|
const { collectionType } = reactRouterDom.useParams();
|
@@ -1583,7 +1634,7 @@ const DocumentActionModal = ({
|
|
1583
1634
|
title,
|
1584
1635
|
onClose,
|
1585
1636
|
footer: Footer,
|
1586
|
-
content,
|
1637
|
+
content: Content,
|
1587
1638
|
onModalClose
|
1588
1639
|
}) => {
|
1589
1640
|
const id = React__namespace.useId();
|
@@ -1598,7 +1649,7 @@ const DocumentActionModal = ({
|
|
1598
1649
|
};
|
1599
1650
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.ModalLayout, { borderRadius: "4px", overflow: "hidden", onClose: handleClose, labelledBy: id, children: [
|
1600
1651
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral800", tag: "h2", id, children: title }) }),
|
1601
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalBody, { children:
|
1652
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalBody, { children: typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content }),
|
1602
1653
|
/* @__PURE__ */ jsxRuntime.jsx(
|
1603
1654
|
designSystem.Box,
|
1604
1655
|
{
|
@@ -1815,7 +1866,7 @@ const UNPUBLISH_DRAFT_OPTIONS = {
|
|
1815
1866
|
KEEP: "keep",
|
1816
1867
|
DISCARD: "discard"
|
1817
1868
|
};
|
1818
|
-
const UnpublishAction = ({
|
1869
|
+
const UnpublishAction$1 = ({
|
1819
1870
|
activeTab,
|
1820
1871
|
documentId,
|
1821
1872
|
model,
|
@@ -1890,6 +1941,7 @@ const UnpublishAction = ({
|
|
1890
1941
|
direction: "column",
|
1891
1942
|
alignItems: "flex-start",
|
1892
1943
|
tag: "fieldset",
|
1944
|
+
borderWidth: 0,
|
1893
1945
|
gap: 3,
|
1894
1946
|
children: [
|
1895
1947
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "legend" }),
|
@@ -1949,7 +2001,7 @@ const UnpublishAction = ({
|
|
1949
2001
|
position: ["panel", "table-row"]
|
1950
2002
|
};
|
1951
2003
|
};
|
1952
|
-
UnpublishAction.type = "unpublish";
|
2004
|
+
UnpublishAction$1.type = "unpublish";
|
1953
2005
|
const DiscardAction = ({
|
1954
2006
|
activeTab,
|
1955
2007
|
documentId,
|
@@ -2005,7 +2057,7 @@ const StyledCrossCircle = styledComponents.styled(Icons.CrossCircle)`
|
|
2005
2057
|
fill: currentColor;
|
2006
2058
|
}
|
2007
2059
|
`;
|
2008
|
-
const DEFAULT_ACTIONS = [PublishAction, UpdateAction, UnpublishAction, DiscardAction];
|
2060
|
+
const DEFAULT_ACTIONS = [PublishAction, UpdateAction, UnpublishAction$1, DiscardAction];
|
2009
2061
|
const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
|
2010
2062
|
const RelativeTime = React__namespace.forwardRef(
|
2011
2063
|
({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {
|
@@ -2272,7 +2324,7 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
|
|
2272
2324
|
id: "app.links.configure-view",
|
2273
2325
|
defaultMessage: "Configure the view"
|
2274
2326
|
}),
|
2275
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2327
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ListPlus, {}),
|
2276
2328
|
onClick: () => {
|
2277
2329
|
navigate(`../${collectionType}/${model}/configurations/edit`);
|
2278
2330
|
},
|
@@ -2280,11 +2332,6 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
|
|
2280
2332
|
};
|
2281
2333
|
};
|
2282
2334
|
ConfigureTheViewAction.type = "configure-the-view";
|
2283
|
-
const StyledCog = styledComponents.styled(Icons.Cog)`
|
2284
|
-
path {
|
2285
|
-
fill: currentColor;
|
2286
|
-
}
|
2287
|
-
`;
|
2288
2335
|
const EditTheModelAction = ({ model }) => {
|
2289
2336
|
const navigate = reactRouterDom.useNavigate();
|
2290
2337
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -2293,7 +2340,7 @@ const EditTheModelAction = ({ model }) => {
|
|
2293
2340
|
id: "content-manager.link-to-ctb",
|
2294
2341
|
defaultMessage: "Edit the model"
|
2295
2342
|
}),
|
2296
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2343
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {}),
|
2297
2344
|
onClick: () => {
|
2298
2345
|
navigate(`/plugins/content-type-builder/content-types/${model}`);
|
2299
2346
|
},
|
@@ -2301,12 +2348,7 @@ const EditTheModelAction = ({ model }) => {
|
|
2301
2348
|
};
|
2302
2349
|
};
|
2303
2350
|
EditTheModelAction.type = "edit-the-model";
|
2304
|
-
const
|
2305
|
-
path {
|
2306
|
-
fill: currentColor;
|
2307
|
-
}
|
2308
|
-
`;
|
2309
|
-
const DeleteAction = ({ documentId, model, collectionType, document }) => {
|
2351
|
+
const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
|
2310
2352
|
const navigate = reactRouterDom.useNavigate();
|
2311
2353
|
const { formatMessage } = reactIntl.useIntl();
|
2312
2354
|
const listViewPathMatch = reactRouterDom.useMatch(LIST_PATH);
|
@@ -2320,7 +2362,7 @@ const DeleteAction = ({ documentId, model, collectionType, document }) => {
|
|
2320
2362
|
id: "content-manager.actions.delete.label",
|
2321
2363
|
defaultMessage: "Delete document"
|
2322
2364
|
}),
|
2323
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
2365
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
|
2324
2366
|
dialog: {
|
2325
2367
|
type: "dialog",
|
2326
2368
|
title: formatMessage({
|
@@ -2374,13 +2416,8 @@ const DeleteAction = ({ documentId, model, collectionType, document }) => {
|
|
2374
2416
|
position: ["header", "table-row"]
|
2375
2417
|
};
|
2376
2418
|
};
|
2377
|
-
DeleteAction.type = "delete";
|
2378
|
-
const
|
2379
|
-
path {
|
2380
|
-
fill: currentColor;
|
2381
|
-
}
|
2382
|
-
`;
|
2383
|
-
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction];
|
2419
|
+
DeleteAction$1.type = "delete";
|
2420
|
+
const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
|
2384
2421
|
const Panels = () => {
|
2385
2422
|
const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
|
2386
2423
|
const [
|
@@ -2475,7 +2512,262 @@ const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
|
|
2475
2512
|
}
|
2476
2513
|
);
|
2477
2514
|
});
|
2478
|
-
const
|
2515
|
+
const BulkActionsRenderer = () => {
|
2516
|
+
const plugins = strapiAdmin.useStrapiApp("BulkActionsRenderer", (state) => state.plugins);
|
2517
|
+
const { model, collectionType } = useDoc();
|
2518
|
+
const { selectedRows } = strapiAdmin.useTable("BulkActionsRenderer", (state) => state);
|
2519
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
2520
|
+
strapiAdmin.DescriptionComponentRenderer,
|
2521
|
+
{
|
2522
|
+
props: {
|
2523
|
+
model,
|
2524
|
+
collectionType,
|
2525
|
+
documents: selectedRows
|
2526
|
+
},
|
2527
|
+
descriptions: plugins["content-manager"].apis.getBulkActions(),
|
2528
|
+
children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsxRuntime.jsx(BulkActionAction, { ...action }, action.id))
|
2529
|
+
}
|
2530
|
+
) });
|
2531
|
+
};
|
2532
|
+
const BulkActionAction = (action) => {
|
2533
|
+
const [dialogId, setDialogId] = React__namespace.useState(null);
|
2534
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
2535
|
+
const handleClick = (action2) => (e) => {
|
2536
|
+
const { onClick, dialog, id } = action2;
|
2537
|
+
if (onClick) {
|
2538
|
+
onClick(e);
|
2539
|
+
}
|
2540
|
+
if (dialog) {
|
2541
|
+
switch (dialog.type) {
|
2542
|
+
case "notification":
|
2543
|
+
toggleNotification({
|
2544
|
+
title: dialog.title,
|
2545
|
+
message: dialog.content,
|
2546
|
+
type: dialog.status,
|
2547
|
+
timeout: dialog.timeout,
|
2548
|
+
onClose: dialog.onClose
|
2549
|
+
});
|
2550
|
+
break;
|
2551
|
+
case "dialog":
|
2552
|
+
case "modal": {
|
2553
|
+
e.preventDefault();
|
2554
|
+
setDialogId(id);
|
2555
|
+
}
|
2556
|
+
}
|
2557
|
+
}
|
2558
|
+
};
|
2559
|
+
const handleClose = () => {
|
2560
|
+
setDialogId(null);
|
2561
|
+
if (action.dialog?.type === "modal" && action.dialog?.onClose) {
|
2562
|
+
action.dialog.onClose();
|
2563
|
+
}
|
2564
|
+
};
|
2565
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
2566
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2567
|
+
designSystem.Button,
|
2568
|
+
{
|
2569
|
+
disabled: action.disabled,
|
2570
|
+
startIcon: action.icon,
|
2571
|
+
variant: action.variant,
|
2572
|
+
onClick: handleClick(action),
|
2573
|
+
children: action.label
|
2574
|
+
}
|
2575
|
+
),
|
2576
|
+
action.dialog?.type === "dialog" ? /* @__PURE__ */ jsxRuntime.jsx(
|
2577
|
+
BulkActionConfirmDialog,
|
2578
|
+
{
|
2579
|
+
...action.dialog,
|
2580
|
+
variant: action.variant,
|
2581
|
+
isOpen: dialogId === action.id,
|
2582
|
+
onClose: handleClose
|
2583
|
+
}
|
2584
|
+
) : null,
|
2585
|
+
action.dialog?.type === "modal" ? /* @__PURE__ */ jsxRuntime.jsx(
|
2586
|
+
BulkActionModal,
|
2587
|
+
{
|
2588
|
+
...action.dialog,
|
2589
|
+
onModalClose: handleClose,
|
2590
|
+
isOpen: dialogId === action.id
|
2591
|
+
}
|
2592
|
+
) : null
|
2593
|
+
] });
|
2594
|
+
};
|
2595
|
+
const BulkActionConfirmDialog = ({
|
2596
|
+
onClose,
|
2597
|
+
onCancel,
|
2598
|
+
onConfirm,
|
2599
|
+
title,
|
2600
|
+
content,
|
2601
|
+
confirmButton,
|
2602
|
+
isOpen,
|
2603
|
+
variant = "secondary"
|
2604
|
+
}) => {
|
2605
|
+
const { formatMessage } = reactIntl.useIntl();
|
2606
|
+
const handleClose = async () => {
|
2607
|
+
if (onCancel) {
|
2608
|
+
await onCancel();
|
2609
|
+
}
|
2610
|
+
onClose();
|
2611
|
+
};
|
2612
|
+
const handleConfirm = async () => {
|
2613
|
+
if (onConfirm) {
|
2614
|
+
await onConfirm();
|
2615
|
+
}
|
2616
|
+
onClose();
|
2617
|
+
};
|
2618
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog, { isOpen, title, onClose: handleClose, children: [
|
2619
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.DialogBody, { icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, {}), children: content }),
|
2620
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2621
|
+
designSystem.DialogFooter,
|
2622
|
+
{
|
2623
|
+
startAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleClose, variant: "tertiary", children: formatMessage({
|
2624
|
+
id: "app.components.Button.cancel",
|
2625
|
+
defaultMessage: "Cancel"
|
2626
|
+
}) }),
|
2627
|
+
endAction: /* @__PURE__ */ jsxRuntime.jsx(
|
2628
|
+
designSystem.Button,
|
2629
|
+
{
|
2630
|
+
onClick: handleConfirm,
|
2631
|
+
variant: variant === "danger-light" ? variant : "secondary",
|
2632
|
+
startIcon: variant === "danger-light" ? /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}) : /* @__PURE__ */ jsxRuntime.jsx(Icons.Check, {}),
|
2633
|
+
children: confirmButton ? confirmButton : formatMessage({
|
2634
|
+
id: "app.components.Button.confirm",
|
2635
|
+
defaultMessage: "Confirm"
|
2636
|
+
})
|
2637
|
+
}
|
2638
|
+
)
|
2639
|
+
}
|
2640
|
+
)
|
2641
|
+
] });
|
2642
|
+
};
|
2643
|
+
const BulkActionModal = ({
|
2644
|
+
isOpen,
|
2645
|
+
title,
|
2646
|
+
onClose,
|
2647
|
+
content: Content,
|
2648
|
+
onModalClose
|
2649
|
+
}) => {
|
2650
|
+
const id = React__namespace.useId();
|
2651
|
+
if (!isOpen) {
|
2652
|
+
return null;
|
2653
|
+
}
|
2654
|
+
const handleClose = () => {
|
2655
|
+
if (onClose) {
|
2656
|
+
onClose();
|
2657
|
+
}
|
2658
|
+
onModalClose();
|
2659
|
+
};
|
2660
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.ModalLayout, { borderRadius: "4px", overflow: "hidden", onClose: handleClose, labelledBy: id, children: [
|
2661
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral800", tag: "h2", id, children: title }) }),
|
2662
|
+
/* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose })
|
2663
|
+
] });
|
2664
|
+
};
|
2665
|
+
const DeleteAction = ({ documents, model }) => {
|
2666
|
+
const { formatMessage } = reactIntl.useIntl();
|
2667
|
+
const { schema: contentType } = useDoc();
|
2668
|
+
const selectRow = strapiAdmin.useTable("DeleteAction", (state) => state.selectRow);
|
2669
|
+
const hasI18nEnabled = Boolean(contentType?.pluginOptions?.i18n);
|
2670
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
2671
|
+
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
2672
|
+
const hasDeletePermission = useDocumentRBAC("deleteAction", (state) => state.canDelete);
|
2673
|
+
const { deleteMany: bulkDeleteAction } = useDocumentActions();
|
2674
|
+
const documentIds = documents.map(({ documentId }) => documentId);
|
2675
|
+
const handleConfirmBulkDelete = async () => {
|
2676
|
+
const res = await bulkDeleteAction({
|
2677
|
+
documentIds,
|
2678
|
+
model,
|
2679
|
+
params
|
2680
|
+
});
|
2681
|
+
if (!("error" in res)) {
|
2682
|
+
selectRow([]);
|
2683
|
+
}
|
2684
|
+
};
|
2685
|
+
if (!hasDeletePermission)
|
2686
|
+
return null;
|
2687
|
+
return {
|
2688
|
+
variant: "danger-light",
|
2689
|
+
label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
|
2690
|
+
dialog: {
|
2691
|
+
type: "dialog",
|
2692
|
+
title: formatMessage({
|
2693
|
+
id: "app.components.ConfirmDialog.title",
|
2694
|
+
defaultMessage: "Confirmation"
|
2695
|
+
}),
|
2696
|
+
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
2697
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
2698
|
+
id: "popUpWarning.bodyMessage.contentType.delete.all",
|
2699
|
+
defaultMessage: "Are you sure you want to delete these entries?"
|
2700
|
+
}) }),
|
2701
|
+
hasI18nEnabled && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { textAlign: "center", padding: 3, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", children: formatMessage(
|
2702
|
+
{
|
2703
|
+
id: getTranslation("Settings.list.actions.deleteAdditionalInfos"),
|
2704
|
+
defaultMessage: "This will delete the active locale versions <em>(from Internationalization)</em>"
|
2705
|
+
},
|
2706
|
+
{
|
2707
|
+
em: Emphasis
|
2708
|
+
}
|
2709
|
+
) }) })
|
2710
|
+
] }),
|
2711
|
+
onConfirm: handleConfirmBulkDelete
|
2712
|
+
}
|
2713
|
+
};
|
2714
|
+
};
|
2715
|
+
DeleteAction.type = "delete";
|
2716
|
+
const UnpublishAction = ({ documents, model }) => {
|
2717
|
+
const { formatMessage } = reactIntl.useIntl();
|
2718
|
+
const { schema } = useDoc();
|
2719
|
+
const selectRow = strapiAdmin.useTable("UnpublishAction", (state) => state.selectRow);
|
2720
|
+
const hasPublishPermission = useDocumentRBAC("unpublishAction", (state) => state.canPublish);
|
2721
|
+
const hasI18nEnabled = Boolean(schema?.pluginOptions?.i18n);
|
2722
|
+
const hasDraftAndPublishEnabled = Boolean(schema?.options?.draftAndPublish);
|
2723
|
+
const { unpublishMany: bulkUnpublishAction } = useDocumentActions();
|
2724
|
+
const documentIds = documents.map(({ documentId }) => documentId);
|
2725
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
2726
|
+
const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
|
2727
|
+
const handleConfirmBulkUnpublish = async () => {
|
2728
|
+
const data = await bulkUnpublishAction({ documentIds, model, params });
|
2729
|
+
if (!("error" in data)) {
|
2730
|
+
selectRow([]);
|
2731
|
+
}
|
2732
|
+
};
|
2733
|
+
const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published");
|
2734
|
+
if (!showUnpublishButton)
|
2735
|
+
return null;
|
2736
|
+
return {
|
2737
|
+
variant: "tertiary",
|
2738
|
+
label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
|
2739
|
+
dialog: {
|
2740
|
+
type: "dialog",
|
2741
|
+
title: formatMessage({
|
2742
|
+
id: "app.components.ConfirmDialog.title",
|
2743
|
+
defaultMessage: "Confirmation"
|
2744
|
+
}),
|
2745
|
+
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
2746
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
|
2747
|
+
id: "popUpWarning.bodyMessage.contentType.unpublish.all",
|
2748
|
+
defaultMessage: "Are you sure you want to unpublish these entries?"
|
2749
|
+
}) }),
|
2750
|
+
hasI18nEnabled && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { textAlign: "center", padding: 3, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", children: formatMessage(
|
2751
|
+
{
|
2752
|
+
id: getTranslation("Settings.list.actions.unpublishAdditionalInfos"),
|
2753
|
+
defaultMessage: "This will unpublish the active locale versions <em>(from Internationalization)</em>"
|
2754
|
+
},
|
2755
|
+
{
|
2756
|
+
em: Emphasis
|
2757
|
+
}
|
2758
|
+
) }) })
|
2759
|
+
] }),
|
2760
|
+
confirmButton: formatMessage({
|
2761
|
+
id: "app.utils.unpublish",
|
2762
|
+
defaultMessage: "Unpublish"
|
2763
|
+
}),
|
2764
|
+
onConfirm: handleConfirmBulkUnpublish
|
2765
|
+
}
|
2766
|
+
};
|
2767
|
+
};
|
2768
|
+
UnpublishAction.type = "unpublish";
|
2769
|
+
const Emphasis = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", textColor: "danger500", children: chunks });
|
2770
|
+
const DEFAULT_BULK_ACTIONS = [UnpublishAction, DeleteAction];
|
2479
2771
|
const AutoCloneFailureModalBody = ({ prohibitedFields }) => {
|
2480
2772
|
const { formatMessage } = reactIntl.useIntl();
|
2481
2773
|
const getDefaultErrorMessage = (reason) => {
|
@@ -3128,10 +3420,8 @@ const index = {
|
|
3128
3420
|
register(app) {
|
3129
3421
|
const cm = new ContentManagerPlugin();
|
3130
3422
|
app.addReducers({
|
3131
|
-
[contentManagerApi.reducerPath]: contentManagerApi.reducer,
|
3132
3423
|
[PLUGIN_ID]: reducer
|
3133
3424
|
});
|
3134
|
-
app.addMiddlewares([() => contentManagerApi.middleware]);
|
3135
3425
|
app.addMenuLink({
|
3136
3426
|
to: PLUGIN_ID,
|
3137
3427
|
icon: Icons.Feather,
|
@@ -3140,14 +3430,15 @@ const index = {
|
|
3140
3430
|
defaultMessage: "Content Manager"
|
3141
3431
|
},
|
3142
3432
|
permissions: [],
|
3143
|
-
Component: () => Promise.resolve().then(() => require("./layout-
|
3433
|
+
Component: () => Promise.resolve().then(() => require("./layout-ni_L9kT1.js")).then((mod) => ({ default: mod.Layout })),
|
3434
|
+
position: 1
|
3144
3435
|
});
|
3145
3436
|
app.registerPlugin(cm.config);
|
3146
3437
|
},
|
3147
3438
|
async registerTrads({ locales }) {
|
3148
3439
|
const importedTrads = await Promise.all(
|
3149
3440
|
locales.map((locale) => {
|
3150
|
-
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-
|
3441
|
+
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-DTULi5-d.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-EUonQTon.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-B7kGGg3E.js")), "./translations/gu.json": () => Promise.resolve().then(() => require("./gu-BRmF601H.js")), "./translations/hi.json": () => Promise.resolve().then(() => require("./hi-CCJBptSq.js")), "./translations/hu.json": () => Promise.resolve().then(() => require("./hu-sNV_yLYy.js")), "./translations/id.json": () => Promise.resolve().then(() => require("./id-B5Ser98A.js")), "./translations/it.json": () => Promise.resolve().then(() => require("./it-DkBIs7vD.js")), "./translations/ja.json": () => Promise.resolve().then(() => require("./ja-CcFe8diO.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-woFZPmLk.js")), "./translations/ml.json": () => Promise.resolve().then(() => require("./ml-C2W8N8k1.js")), "./translations/ms.json": () => Promise.resolve().then(() => require("./ms-BuFotyP_.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-bbEOHChV.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-uzwG-hk7.js")), "./translations/pt-BR.json": () => Promise.resolve().then(() => require("./pt-BR-BiOz37D9.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-CeXQuq50.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BT3ybNny.js")), "./translations/sa.json": () => Promise.resolve().then(() => require("./sa-CcvkYInH.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-CvY09Xjv.js")), "./translations/sv.json": () => Promise.resolve().then(() => require("./sv-MYDuzgvT.js")), "./translations/th.json": () => Promise.resolve().then(() => require("./th-D9_GfAjc.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-D9UH-O_R.js")), "./translations/uk.json": () => Promise.resolve().then(() => require("./uk-C8EiqJY7.js")), "./translations/vi.json": () => Promise.resolve().then(() => require("./vi-CJlYDheJ.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-9kOncHGw.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CQQfszqR.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
|
3151
3442
|
return {
|
3152
3443
|
data: prefixPluginTranslations(data, PLUGIN_ID),
|
3153
3444
|
locale
|
@@ -3164,6 +3455,7 @@ const index = {
|
|
3164
3455
|
}
|
3165
3456
|
};
|
3166
3457
|
exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
|
3458
|
+
exports.BulkActionsRenderer = BulkActionsRenderer;
|
3167
3459
|
exports.COLLECTION_TYPES = COLLECTION_TYPES;
|
3168
3460
|
exports.CREATOR_FIELDS = CREATOR_FIELDS;
|
3169
3461
|
exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
|
@@ -3204,4 +3496,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
|
|
3204
3496
|
exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
|
3205
3497
|
exports.useGetInitialDataQuery = useGetInitialDataQuery;
|
3206
3498
|
exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
|
3207
|
-
//# sourceMappingURL=index-
|
3499
|
+
//# sourceMappingURL=index-CCJeB7Rw.js.map
|