@strapi/i18n 0.0.0-experimental.c3e9d4b26f9fd3d9eb530b5c11f9baa1d09b13ad → 0.0.0-experimental.c592deb623aed3f74ef7fdacfad9757ed59d34f7
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/{SettingsPage-DjWupAff.js → SettingsPage-CJOMVQv5.js} +91 -104
- package/dist/_chunks/SettingsPage-CJOMVQv5.js.map +1 -0
- package/dist/_chunks/{SettingsPage-BWlXRGN7.mjs → SettingsPage-CnBFTsrq.mjs} +93 -106
- package/dist/_chunks/SettingsPage-CnBFTsrq.mjs.map +1 -0
- package/dist/_chunks/{en-18tWw4P6.mjs → en-BYRZFDBV.mjs} +11 -2
- package/dist/_chunks/en-BYRZFDBV.mjs.map +1 -0
- package/dist/_chunks/{en-Kv6y9zPQ.js → en-Dk9At9_Z.js} +11 -2
- package/dist/_chunks/en-Dk9At9_Z.js.map +1 -0
- package/dist/_chunks/{index-DVTdCB4M.mjs → index-BFk3nfTb.mjs} +436 -215
- package/dist/_chunks/index-BFk3nfTb.mjs.map +1 -0
- package/dist/_chunks/{index-D--YX2ZY.js → index-C5SImSYG.js} +442 -221
- package/dist/_chunks/index-C5SImSYG.js.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/BulkLocaleActionModal.d.ts +2 -1
- package/dist/admin/src/components/CMHeaderActions.d.ts +29 -3
- package/dist/admin/src/components/EditLocale.d.ts +5 -4
- package/dist/admin/src/contentReleasesHooks/releaseDetailsView.d.ts +9 -5
- package/dist/admin/src/utils/clean.d.ts +4 -0
- package/dist/admin/src/utils/schemas.d.ts +1 -0
- package/dist/server/index.js +62 -98
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +63 -99
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts +1 -4
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +15 -13
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +14 -10
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/permissions/actions.d.ts +14 -2
- package/dist/server/src/services/permissions/actions.d.ts.map +1 -1
- package/dist/server/src/services/permissions.d.ts +14 -2
- package/dist/server/src/services/permissions.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts +0 -2
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/_chunks/SettingsPage-BWlXRGN7.mjs.map +0 -1
- package/dist/_chunks/SettingsPage-DjWupAff.js.map +0 -1
- package/dist/_chunks/en-18tWw4P6.mjs.map +0 -1
- package/dist/_chunks/en-Kv6y9zPQ.js.map +0 -1
- package/dist/_chunks/index-D--YX2ZY.js.map +0 -1
- package/dist/_chunks/index-DVTdCB4M.mjs.map +0 -1
- package/dist/admin/src/components/Initializer.d.ts +0 -5
- package/dist/server/src/services/entity-service-decorator.d.ts +0 -29
- package/dist/server/src/services/entity-service-decorator.d.ts.map +0 -1
- package/strapi-server.js +0 -3
@@ -7,6 +7,7 @@ const designSystem = require("@strapi/design-system");
|
|
7
7
|
const icons = require("@strapi/icons");
|
8
8
|
const reactIntl = require("react-intl");
|
9
9
|
const styledComponents = require("styled-components");
|
10
|
+
const query = require("@reduxjs/toolkit/query");
|
10
11
|
const strapiAdmin = require("@strapi/admin/strapi-admin");
|
11
12
|
const strapiAdmin$1 = require("@strapi/content-manager/strapi-admin");
|
12
13
|
const reactRouterDom = require("react-router-dom");
|
@@ -71,9 +72,7 @@ const CheckboxConfirmation = ({
|
|
71
72
|
};
|
72
73
|
const handleConfirm = () => {
|
73
74
|
onChange({ target: { name, value: false, type: "checkbox" } });
|
74
|
-
setIsOpen(false);
|
75
75
|
};
|
76
|
-
const handleToggle = () => setIsOpen((prev) => !prev);
|
77
76
|
const label = intlLabel.id ? formatMessage(
|
78
77
|
{ id: intlLabel.id, defaultMessage: intlLabel.defaultMessage },
|
79
78
|
{ ...intlLabel.values }
|
@@ -82,35 +81,36 @@ const CheckboxConfirmation = ({
|
|
82
81
|
{ id: description.id, defaultMessage: description.defaultMessage },
|
83
82
|
{ ...description.values }
|
84
83
|
) : "";
|
85
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
84
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Root, { open: isOpen, onOpenChange: setIsOpen, children: [
|
86
85
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { hint, name, children: [
|
87
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Checkbox, {
|
86
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Checkbox, { onCheckedChange: handleChange, checked: value, children: label }),
|
88
87
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
|
89
88
|
] }),
|
90
|
-
|
91
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
92
|
-
|
89
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
90
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage({
|
91
|
+
id: getTranslation("CheckboxConfirmation.Modal.title"),
|
92
|
+
defaultMessage: "Disable localization"
|
93
|
+
}) }),
|
94
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { icon: /* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, {}), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
95
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(TextAlignTypography, { children: formatMessage({
|
93
96
|
id: getTranslation("CheckboxConfirmation.Modal.content"),
|
94
97
|
defaultMessage: "Disabling localization will engender the deletion of all your content but the one associated to your default locale (if existing)."
|
95
98
|
}) }) }),
|
96
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold",
|
99
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", children: formatMessage({
|
97
100
|
id: getTranslation("CheckboxConfirmation.Modal.body"),
|
98
101
|
defaultMessage: "Do you want to disable it?"
|
99
102
|
}) }) })
|
100
103
|
] }) }),
|
101
|
-
/* @__PURE__ */ jsxRuntime.
|
102
|
-
designSystem.
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
}) })
|
112
|
-
}
|
113
|
-
)
|
104
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
|
105
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
|
106
|
+
id: "components.popUpWarning.button.cancel",
|
107
|
+
defaultMessage: "No, cancel"
|
108
|
+
}) }) }),
|
109
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Action, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "danger-light", onClick: handleConfirm, children: formatMessage({
|
110
|
+
id: getTranslation("CheckboxConfirmation.Modal.button-confirm"),
|
111
|
+
defaultMessage: "Yes, disable"
|
112
|
+
}) }) })
|
113
|
+
] })
|
114
114
|
] })
|
115
115
|
] });
|
116
116
|
};
|
@@ -161,7 +161,7 @@ const useI18n = () => {
|
|
161
161
|
model: params.slug
|
162
162
|
},
|
163
163
|
{
|
164
|
-
skip:
|
164
|
+
skip: true
|
165
165
|
}
|
166
166
|
);
|
167
167
|
if (doesPluginOptionsHaveI18nLocalized(schema?.pluginOptions)) {
|
@@ -241,10 +241,94 @@ const relationsApi = i18nApi.injectEndpoints({
|
|
241
241
|
})
|
242
242
|
});
|
243
243
|
const { useGetManyDraftRelationCountQuery } = relationsApi;
|
244
|
+
const cleanData = (data, schema, components) => {
|
245
|
+
const cleanedData = removeFields(data, [
|
246
|
+
"createdAt",
|
247
|
+
"createdBy",
|
248
|
+
"updatedAt",
|
249
|
+
"updatedBy",
|
250
|
+
"id",
|
251
|
+
"documentId",
|
252
|
+
"publishedAt",
|
253
|
+
"strapi_stage",
|
254
|
+
"strapi_assignee",
|
255
|
+
"locale",
|
256
|
+
"status"
|
257
|
+
]);
|
258
|
+
const cleanedDataWithoutPasswordAndRelation = recursiveRemoveFieldTypes(
|
259
|
+
cleanedData,
|
260
|
+
schema,
|
261
|
+
components,
|
262
|
+
["relation", "password"]
|
263
|
+
);
|
264
|
+
return cleanedDataWithoutPasswordAndRelation;
|
265
|
+
};
|
266
|
+
const removeFields = (data, fields) => {
|
267
|
+
return Object.keys(data).reduce((acc, current) => {
|
268
|
+
if (fields.includes(current)) {
|
269
|
+
return acc;
|
270
|
+
}
|
271
|
+
acc[current] = data[current];
|
272
|
+
return acc;
|
273
|
+
}, {});
|
274
|
+
};
|
275
|
+
const recursiveRemoveFieldTypes = (data, schema, components, fields) => {
|
276
|
+
return Object.keys(data).reduce((acc, current) => {
|
277
|
+
const attribute = schema.attributes[current] ?? { type: void 0 };
|
278
|
+
if (fields.includes(attribute.type)) {
|
279
|
+
return acc;
|
280
|
+
}
|
281
|
+
if (attribute.type === "dynamiczone") {
|
282
|
+
acc[current] = data[current].map((componentValue, index2) => {
|
283
|
+
const { id: _, ...rest } = recursiveRemoveFieldTypes(
|
284
|
+
componentValue,
|
285
|
+
components[componentValue.__component],
|
286
|
+
components,
|
287
|
+
fields
|
288
|
+
);
|
289
|
+
return {
|
290
|
+
...rest,
|
291
|
+
__temp_key__: index2 + 1
|
292
|
+
};
|
293
|
+
});
|
294
|
+
} else if (attribute.type === "component") {
|
295
|
+
const { repeatable, component } = attribute;
|
296
|
+
if (repeatable) {
|
297
|
+
acc[current] = (data[current] ?? []).map((compoData, index2) => {
|
298
|
+
const { id: _, ...rest } = recursiveRemoveFieldTypes(
|
299
|
+
compoData,
|
300
|
+
components[component],
|
301
|
+
components,
|
302
|
+
fields
|
303
|
+
);
|
304
|
+
return {
|
305
|
+
...rest,
|
306
|
+
__temp_key__: index2 + 1
|
307
|
+
};
|
308
|
+
});
|
309
|
+
} else {
|
310
|
+
const { id: _, ...rest } = recursiveRemoveFieldTypes(
|
311
|
+
data[current] ?? {},
|
312
|
+
components[component],
|
313
|
+
components,
|
314
|
+
fields
|
315
|
+
);
|
316
|
+
acc[current] = rest;
|
317
|
+
}
|
318
|
+
} else {
|
319
|
+
acc[current] = data[current];
|
320
|
+
}
|
321
|
+
return acc;
|
322
|
+
}, {});
|
323
|
+
};
|
244
324
|
const isErrorMessageDescriptor = (object) => {
|
245
325
|
return typeof object === "object" && object !== null && "id" in object && "defaultMessage" in object;
|
246
326
|
};
|
247
|
-
const EntryValidationText = ({
|
327
|
+
const EntryValidationText = ({
|
328
|
+
status = "draft",
|
329
|
+
validationErrors,
|
330
|
+
action
|
331
|
+
}) => {
|
248
332
|
const { formatMessage } = reactIntl.useIntl();
|
249
333
|
const getErrorStr = (key, value) => {
|
250
334
|
if (typeof value === "string") {
|
@@ -278,30 +362,63 @@ const EntryValidationText = ({ status = "draft", validationErrors }) => {
|
|
278
362
|
) })
|
279
363
|
] });
|
280
364
|
}
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
365
|
+
const getStatusMessage = () => {
|
366
|
+
if (action === "bulk-publish") {
|
367
|
+
if (status === "published") {
|
368
|
+
return {
|
369
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
370
|
+
text: formatMessage({
|
371
|
+
id: "content-manager.bulk-publish.already-published",
|
372
|
+
defaultMessage: "Already Published"
|
373
|
+
}),
|
374
|
+
textColor: "success600",
|
375
|
+
fontWeight: "bold"
|
376
|
+
};
|
377
|
+
} else if (status === "modified") {
|
378
|
+
return {
|
379
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowsCounterClockwise, { fill: "alternative600" }),
|
380
|
+
text: formatMessage({
|
381
|
+
id: "app.utils.ready-to-publish-changes",
|
382
|
+
defaultMessage: "Ready to publish changes"
|
383
|
+
})
|
384
|
+
};
|
385
|
+
} else {
|
386
|
+
return {
|
387
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
388
|
+
text: formatMessage({
|
389
|
+
id: "app.utils.ready-to-publish",
|
390
|
+
defaultMessage: "Ready to publish"
|
391
|
+
})
|
392
|
+
};
|
393
|
+
}
|
394
|
+
} else {
|
395
|
+
if (status === "draft") {
|
396
|
+
return {
|
397
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
398
|
+
text: formatMessage({
|
399
|
+
id: "content-manager.bulk-unpublish.already-unpublished",
|
400
|
+
defaultMessage: "Already Unpublished"
|
401
|
+
}),
|
402
|
+
textColor: "success600",
|
403
|
+
fontWeight: "bold"
|
404
|
+
};
|
405
|
+
} else {
|
406
|
+
return {
|
407
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
408
|
+
text: formatMessage({
|
409
|
+
id: "app.utils.ready-to-unpublish-changes",
|
410
|
+
defaultMessage: "Ready to unpublish"
|
411
|
+
}),
|
412
|
+
textColor: "success600",
|
413
|
+
fontWeight: "bold"
|
414
|
+
};
|
415
|
+
}
|
416
|
+
}
|
417
|
+
};
|
418
|
+
const { icon, text, textColor = "success600", fontWeight = "normal" } = getStatusMessage();
|
299
419
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
300
|
-
|
301
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children:
|
302
|
-
id: "app.utils.ready-to-publish",
|
303
|
-
defaultMessage: "Ready to publish"
|
304
|
-
}) })
|
420
|
+
icon,
|
421
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor, fontWeight, children: text })
|
305
422
|
] });
|
306
423
|
};
|
307
424
|
const BoldChunk = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
|
@@ -309,7 +426,8 @@ const BulkLocaleActionModal = ({
|
|
309
426
|
headers,
|
310
427
|
rows,
|
311
428
|
localesMetadata,
|
312
|
-
validationErrors = {}
|
429
|
+
validationErrors = {},
|
430
|
+
action
|
313
431
|
}) => {
|
314
432
|
const { formatMessage } = reactIntl.useIntl();
|
315
433
|
const selectedRows = strapiAdmin.useTable(
|
@@ -322,27 +440,29 @@ const BulkLocaleActionModal = ({
|
|
322
440
|
return acc;
|
323
441
|
}, {});
|
324
442
|
const localesWithErrors = Object.keys(validationErrors);
|
325
|
-
const
|
443
|
+
const publishedCount = selectedRows.filter(
|
326
444
|
({ locale }) => currentStatusByLocale[locale] === "published"
|
327
445
|
).length;
|
328
|
-
const
|
446
|
+
const draftCount = selectedRows.filter(
|
329
447
|
({ locale }) => (currentStatusByLocale[locale] === "draft" || currentStatusByLocale[locale] === "modified") && !localesWithErrors.includes(locale)
|
330
448
|
).length;
|
331
449
|
const withErrorsCount = localesWithErrors.length;
|
450
|
+
const messageId = action === "bulk-publish" ? "content-manager.containers.list.selectedEntriesModal.selectedCount.publish" : "content-manager.containers.list.selectedEntriesModal.selectedCount.unpublish";
|
451
|
+
const defaultMessage = action === "bulk-publish" ? "<b>{publishedCount}</b> {publishedCount, plural, =0 {entries} one {entry} other {entries}} already published. <b>{draftCount}</b> {draftCount, plural, =0 {entries} one {entry} other {entries}} ready to publish. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action." : "<b>{draftCount}</b> {draftCount, plural, =0 {entries} one {entry} other {entries}} already unpublished. <b>{publishedCount}</b> {publishedCount, plural, =0 {entries} one {entry} other {entries}} ready to unpublish.";
|
332
452
|
return formatMessage(
|
333
453
|
{
|
334
|
-
id:
|
335
|
-
defaultMessage
|
454
|
+
id: messageId,
|
455
|
+
defaultMessage
|
336
456
|
},
|
337
457
|
{
|
338
458
|
withErrorsCount,
|
339
|
-
|
340
|
-
|
459
|
+
draftCount,
|
460
|
+
publishedCount,
|
341
461
|
b: BoldChunk
|
342
462
|
}
|
343
463
|
);
|
344
464
|
};
|
345
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
465
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Body, { children: [
|
346
466
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: getFormattedCountMessage() }),
|
347
467
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Content, { children: [
|
348
468
|
/* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Head, { children: [
|
@@ -369,7 +489,7 @@ const BulkLocaleActionModal = ({
|
|
369
489
|
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
370
490
|
}
|
371
491
|
) }) }),
|
372
|
-
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(EntryValidationText, { validationErrors: error, status }) }),
|
492
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(EntryValidationText, { validationErrors: error, status, action }) }),
|
373
493
|
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
374
494
|
designSystem.IconButton,
|
375
495
|
{
|
@@ -386,7 +506,7 @@ const BulkLocaleActionModal = ({
|
|
386
506
|
name: locale
|
387
507
|
}
|
388
508
|
),
|
389
|
-
|
509
|
+
variant: "ghost",
|
390
510
|
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {})
|
391
511
|
}
|
392
512
|
) })
|
@@ -395,6 +515,48 @@ const BulkLocaleActionModal = ({
|
|
395
515
|
] }) })
|
396
516
|
] });
|
397
517
|
};
|
518
|
+
const statusVariants = {
|
519
|
+
draft: "secondary",
|
520
|
+
published: "success",
|
521
|
+
modified: "alternative"
|
522
|
+
};
|
523
|
+
const LocaleOption = ({
|
524
|
+
isDraftAndPublishEnabled,
|
525
|
+
locale,
|
526
|
+
status,
|
527
|
+
entryExists
|
528
|
+
}) => {
|
529
|
+
const { formatMessage } = reactIntl.useIntl();
|
530
|
+
if (!entryExists) {
|
531
|
+
return formatMessage(
|
532
|
+
{
|
533
|
+
id: getTranslation("CMEditViewLocalePicker.locale.create"),
|
534
|
+
defaultMessage: "Create <bold>{locale}</bold> locale"
|
535
|
+
},
|
536
|
+
{
|
537
|
+
bold: (locale2) => /* @__PURE__ */ jsxRuntime.jsx("b", { children: locale2 }),
|
538
|
+
locale: locale.name
|
539
|
+
}
|
540
|
+
);
|
541
|
+
}
|
542
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", gap: 1, justifyContent: "space-between", children: [
|
543
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: locale.name }),
|
544
|
+
isDraftAndPublishEnabled ? /* @__PURE__ */ jsxRuntime.jsx(
|
545
|
+
designSystem.Status,
|
546
|
+
{
|
547
|
+
display: "flex",
|
548
|
+
paddingLeft: "6px",
|
549
|
+
paddingRight: "6px",
|
550
|
+
paddingTop: "2px",
|
551
|
+
paddingBottom: "2px",
|
552
|
+
showBullet: false,
|
553
|
+
size: "S",
|
554
|
+
variant: statusVariants[status],
|
555
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
556
|
+
}
|
557
|
+
) : null
|
558
|
+
] });
|
559
|
+
};
|
398
560
|
const LocalePickerAction = ({
|
399
561
|
document,
|
400
562
|
meta,
|
@@ -403,74 +565,74 @@ const LocalePickerAction = ({
|
|
403
565
|
documentId
|
404
566
|
}) => {
|
405
567
|
const { formatMessage } = reactIntl.useIntl();
|
406
|
-
const [{ query }, setQuery] = strapiAdmin.useQueryParams();
|
568
|
+
const [{ query: query2 }, setQuery] = strapiAdmin.useQueryParams();
|
407
569
|
const { hasI18n, canCreate, canRead } = useI18n();
|
408
570
|
const { data: locales = [] } = useGetLocalesQuery();
|
409
|
-
const
|
571
|
+
const currentDesiredLocale = query2.plugins?.i18n?.locale;
|
572
|
+
const { schema } = strapiAdmin$1.unstable_useDocument({
|
573
|
+
model,
|
574
|
+
collectionType,
|
575
|
+
documentId,
|
576
|
+
params: { locale: currentDesiredLocale }
|
577
|
+
});
|
410
578
|
const handleSelect = React__namespace.useCallback(
|
411
579
|
(value) => {
|
412
580
|
setQuery({
|
413
581
|
plugins: {
|
414
|
-
...
|
582
|
+
...query2.plugins,
|
415
583
|
i18n: {
|
416
584
|
locale: value
|
417
585
|
}
|
418
586
|
}
|
419
587
|
});
|
420
588
|
},
|
421
|
-
[
|
589
|
+
[query2.plugins, setQuery]
|
422
590
|
);
|
423
591
|
React__namespace.useEffect(() => {
|
424
592
|
if (!Array.isArray(locales) || !hasI18n) {
|
425
593
|
return;
|
426
594
|
}
|
427
|
-
const currentDesiredLocale = query.plugins?.i18n?.locale;
|
428
595
|
const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
|
429
596
|
const defaultLocale = locales.find((locale) => locale.isDefault);
|
430
597
|
if (!doesLocaleExist && defaultLocale?.code) {
|
431
598
|
handleSelect(defaultLocale.code);
|
432
599
|
}
|
433
|
-
}, [handleSelect, hasI18n, locales,
|
434
|
-
|
435
|
-
return null;
|
436
|
-
}
|
437
|
-
const currentLocale = query.plugins?.i18n?.locale || locales.find((loc) => loc.isDefault)?.code;
|
600
|
+
}, [handleSelect, hasI18n, locales, currentDesiredLocale]);
|
601
|
+
const currentLocale = Array.isArray(locales) ? locales.find((locale) => locale.code === currentDesiredLocale) : void 0;
|
438
602
|
const allCurrentLocales = [
|
439
|
-
{ status: getDocumentStatus(document, meta), locale: currentLocale },
|
603
|
+
{ status: getDocumentStatus(document, meta), locale: currentLocale?.code },
|
440
604
|
...meta?.availableLocales ?? []
|
441
605
|
];
|
606
|
+
if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
|
607
|
+
return null;
|
608
|
+
}
|
442
609
|
return {
|
443
610
|
label: formatMessage({
|
444
611
|
id: getTranslation("Settings.locales.modal.locales.label"),
|
445
612
|
defaultMessage: "Locales"
|
446
613
|
}),
|
447
614
|
options: locales.map((locale) => {
|
615
|
+
const entryWithLocaleExists = allCurrentLocales.some((doc) => doc.locale === locale.code);
|
448
616
|
const currentLocaleDoc = allCurrentLocales.find(
|
449
617
|
(doc) => "locale" in doc ? doc.locale === locale.code : false
|
450
618
|
);
|
451
|
-
const status = currentLocaleDoc?.status ?? "draft";
|
452
619
|
const permissionsToCheck = currentLocaleDoc ? canCreate : canRead;
|
453
|
-
const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
|
454
620
|
return {
|
455
621
|
disabled: !permissionsToCheck.includes(locale.code),
|
456
622
|
value: locale.code,
|
457
|
-
label:
|
458
|
-
|
459
|
-
designSystem.Status,
|
623
|
+
label: /* @__PURE__ */ jsxRuntime.jsx(
|
624
|
+
LocaleOption,
|
460
625
|
{
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
paddingBottom: "2px",
|
466
|
-
showBullet: false,
|
467
|
-
size: "S",
|
468
|
-
variant: statusVariant,
|
469
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
626
|
+
isDraftAndPublishEnabled: !!schema?.options?.draftAndPublish,
|
627
|
+
locale,
|
628
|
+
status: currentLocaleDoc?.status,
|
629
|
+
entryExists: entryWithLocaleExists
|
470
630
|
}
|
471
|
-
)
|
631
|
+
),
|
632
|
+
startIcon: !entryWithLocaleExists ? /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}) : null
|
472
633
|
};
|
473
634
|
}),
|
635
|
+
customizeContent: () => currentLocale?.name,
|
474
636
|
onSelect: handleSelect,
|
475
637
|
value: currentLocale
|
476
638
|
};
|
@@ -486,6 +648,95 @@ const getDocumentStatus = (document, meta) => {
|
|
486
648
|
}
|
487
649
|
return docStatus;
|
488
650
|
};
|
651
|
+
const FillFromAnotherLocaleAction = ({
|
652
|
+
documentId,
|
653
|
+
meta,
|
654
|
+
model,
|
655
|
+
collectionType
|
656
|
+
}) => {
|
657
|
+
const { formatMessage } = reactIntl.useIntl();
|
658
|
+
const [{ query: query2 }] = strapiAdmin.useQueryParams();
|
659
|
+
const currentDesiredLocale = query2.plugins?.i18n?.locale;
|
660
|
+
const [localeSelected, setLocaleSelected] = React__namespace.useState(null);
|
661
|
+
const setValues = strapiAdmin.useForm("FillFromAnotherLocale", (state) => state.setValues);
|
662
|
+
const { getDocument } = strapiAdmin$1.unstable_useDocumentActions();
|
663
|
+
const { schema, components } = strapiAdmin$1.unstable_useDocument({
|
664
|
+
model,
|
665
|
+
documentId,
|
666
|
+
collectionType,
|
667
|
+
params: { locale: currentDesiredLocale }
|
668
|
+
});
|
669
|
+
const { data: locales = [] } = useGetLocalesQuery();
|
670
|
+
const availableLocales = Array.isArray(locales) ? locales.filter((locale) => meta?.availableLocales.some((l) => l.locale === locale.code)) : [];
|
671
|
+
const fillFromLocale = (onClose) => async () => {
|
672
|
+
const response = await getDocument({
|
673
|
+
collectionType,
|
674
|
+
model,
|
675
|
+
documentId,
|
676
|
+
params: { locale: localeSelected }
|
677
|
+
});
|
678
|
+
if (!response || !schema) {
|
679
|
+
return;
|
680
|
+
}
|
681
|
+
const { data } = response;
|
682
|
+
const cleanedData = cleanData(data, schema, components);
|
683
|
+
setValues(cleanedData);
|
684
|
+
onClose();
|
685
|
+
};
|
686
|
+
return {
|
687
|
+
type: "icon",
|
688
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Download, {}),
|
689
|
+
disabled: availableLocales.length === 0,
|
690
|
+
label: formatMessage({
|
691
|
+
id: getTranslation("CMEditViewCopyLocale.copy-text"),
|
692
|
+
defaultMessage: "Fill in from another locale"
|
693
|
+
}),
|
694
|
+
dialog: {
|
695
|
+
type: "dialog",
|
696
|
+
title: formatMessage({
|
697
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.title"),
|
698
|
+
defaultMessage: "Confirmation"
|
699
|
+
}),
|
700
|
+
content: ({ onClose }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
701
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, children: [
|
702
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
703
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textAlign: "center", children: formatMessage({
|
704
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.body"),
|
705
|
+
defaultMessage: "Your current content will be erased and filled by the content of the selected locale:"
|
706
|
+
}) }),
|
707
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { width: "100%", children: [
|
708
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
|
709
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.field.label"),
|
710
|
+
defaultMessage: "Locale"
|
711
|
+
}) }),
|
712
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
713
|
+
designSystem.SingleSelect,
|
714
|
+
{
|
715
|
+
value: localeSelected,
|
716
|
+
placeholder: formatMessage({
|
717
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.field.placeholder"),
|
718
|
+
defaultMessage: "Select one locale..."
|
719
|
+
}),
|
720
|
+
onChange: (value) => setLocaleSelected(value),
|
721
|
+
children: availableLocales.map((locale) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: locale.code, children: locale.name }, locale.code))
|
722
|
+
}
|
723
|
+
)
|
724
|
+
] })
|
725
|
+
] }) }),
|
726
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, width: "100%", children: [
|
727
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { flex: "auto", variant: "tertiary", onClick: onClose, children: formatMessage({
|
728
|
+
id: getTranslation("CMEditViewCopyLocale.cancel-text"),
|
729
|
+
defaultMessage: "No, cancel"
|
730
|
+
}) }),
|
731
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { flex: "auto", variant: "success", onClick: fillFromLocale(onClose), children: formatMessage({
|
732
|
+
id: getTranslation("CMEditViewCopyLocale.submit-text"),
|
733
|
+
defaultMessage: "Yes, fill in"
|
734
|
+
}) })
|
735
|
+
] }) })
|
736
|
+
] })
|
737
|
+
}
|
738
|
+
};
|
739
|
+
};
|
489
740
|
const DeleteLocaleAction = ({
|
490
741
|
document,
|
491
742
|
documentId,
|
@@ -497,16 +748,23 @@ const DeleteLocaleAction = ({
|
|
497
748
|
const { toggleNotification } = strapiAdmin.useNotification();
|
498
749
|
const { delete: deleteAction } = strapiAdmin$1.unstable_useDocumentActions();
|
499
750
|
const { hasI18n, canDelete } = useI18n();
|
751
|
+
const [{ query: query2 }] = strapiAdmin.useQueryParams();
|
752
|
+
const { data: locales = [] } = useGetLocalesQuery();
|
753
|
+
const currentDesiredLocale = query2.plugins?.i18n?.locale;
|
754
|
+
const locale = !("error" in locales) && locales.find((loc) => loc.code === currentDesiredLocale);
|
500
755
|
if (!hasI18n) {
|
501
756
|
return null;
|
502
757
|
}
|
503
758
|
return {
|
504
759
|
disabled: document?.locale && !canDelete.includes(document.locale) || !document || !document.id,
|
505
760
|
position: ["header", "table-row"],
|
506
|
-
label: formatMessage(
|
507
|
-
|
508
|
-
|
509
|
-
|
761
|
+
label: formatMessage(
|
762
|
+
{
|
763
|
+
id: getTranslation("actions.delete.label"),
|
764
|
+
defaultMessage: "Delete entry ({locale})"
|
765
|
+
},
|
766
|
+
{ locale: locale && locale.name }
|
767
|
+
),
|
510
768
|
icon: /* @__PURE__ */ jsxRuntime.jsx(StyledTrash, {}),
|
511
769
|
variant: "danger",
|
512
770
|
dialog: {
|
@@ -549,37 +807,43 @@ const DeleteLocaleAction = ({
|
|
549
807
|
}
|
550
808
|
};
|
551
809
|
};
|
552
|
-
const
|
810
|
+
const BulkLocaleAction = ({
|
553
811
|
document: baseDocument,
|
554
812
|
documentId,
|
555
813
|
model,
|
556
|
-
collectionType
|
814
|
+
collectionType,
|
815
|
+
action
|
557
816
|
}) => {
|
558
817
|
const baseLocale = baseDocument?.locale ?? null;
|
559
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
560
|
-
const params = React__namespace.useMemo(() => strapiAdmin$1.buildValidParams(query), [query]);
|
561
|
-
const
|
818
|
+
const [{ query: query$1 }] = strapiAdmin.useQueryParams();
|
819
|
+
const params = React__namespace.useMemo(() => strapiAdmin$1.buildValidParams(query$1), [query$1]);
|
820
|
+
const isOnPublishedTab = query$1.status === "published";
|
562
821
|
const { formatMessage } = reactIntl.useIntl();
|
563
822
|
const { hasI18n, canPublish } = useI18n();
|
564
823
|
const { toggleNotification } = strapiAdmin.useNotification();
|
565
824
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
566
825
|
const [selectedRows, setSelectedRows] = React__namespace.useState([]);
|
567
|
-
const [
|
568
|
-
const { publishMany: publishManyAction } = strapiAdmin$1.unstable_useDocumentActions();
|
826
|
+
const [isDraftRelationConfirmationOpen, setIsDraftRelationConfirmationOpen] = React__namespace.useState(false);
|
827
|
+
const { publishMany: publishManyAction, unpublishMany: unpublishManyAction } = strapiAdmin$1.unstable_useDocumentActions();
|
569
828
|
const {
|
570
829
|
document,
|
571
830
|
meta: documentMeta,
|
572
831
|
schema,
|
573
832
|
validate
|
574
|
-
} = strapiAdmin$1.unstable_useDocument(
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
833
|
+
} = strapiAdmin$1.unstable_useDocument(
|
834
|
+
{
|
835
|
+
model,
|
836
|
+
collectionType,
|
837
|
+
documentId,
|
838
|
+
params: {
|
839
|
+
locale: baseLocale
|
840
|
+
}
|
841
|
+
},
|
842
|
+
{
|
843
|
+
skip: !hasI18n || !baseLocale
|
580
844
|
}
|
581
|
-
|
582
|
-
const { data: localesMetadata = [] } = useGetLocalesQuery();
|
845
|
+
);
|
846
|
+
const { data: localesMetadata = [] } = useGetLocalesQuery(hasI18n ? void 0 : query.skipToken);
|
583
847
|
const headers = [
|
584
848
|
{
|
585
849
|
label: formatMessage({
|
@@ -628,12 +892,19 @@ const BulkLocalePublishAction = ({
|
|
628
892
|
}, {});
|
629
893
|
return [rowsFromMeta, errors];
|
630
894
|
}, [document, documentMeta?.availableLocales, validate]);
|
631
|
-
const
|
632
|
-
|
895
|
+
const isBulkPublish = action === "bulk-publish";
|
896
|
+
const localesForAction = selectedRows.reduce((acc, selectedRow) => {
|
897
|
+
const isValidLocale = (
|
898
|
+
// Validation errors are irrelevant if we are trying to unpublish
|
899
|
+
!isBulkPublish || !Object.keys(validationErrors).includes(selectedRow.locale)
|
900
|
+
);
|
901
|
+
const shouldAddLocale = isBulkPublish ? selectedRow.status !== "published" && isValidLocale : selectedRow.status !== "draft" && isValidLocale;
|
902
|
+
if (shouldAddLocale) {
|
633
903
|
acc.push(selectedRow.locale);
|
634
904
|
}
|
635
905
|
return acc;
|
636
906
|
}, []);
|
907
|
+
const enableDraftRelationsCount = false;
|
637
908
|
const {
|
638
909
|
data: draftRelationsCount = 0,
|
639
910
|
isLoading: isDraftRelationsLoading,
|
@@ -642,10 +913,10 @@ const BulkLocalePublishAction = ({
|
|
642
913
|
{
|
643
914
|
model,
|
644
915
|
documentIds: [documentId],
|
645
|
-
locale:
|
916
|
+
locale: localesForAction
|
646
917
|
},
|
647
918
|
{
|
648
|
-
skip: !
|
919
|
+
skip: !enableDraftRelationsCount
|
649
920
|
}
|
650
921
|
);
|
651
922
|
React__namespace.useEffect(() => {
|
@@ -671,23 +942,32 @@ const BulkLocalePublishAction = ({
|
|
671
942
|
documentIds: [documentId],
|
672
943
|
params: {
|
673
944
|
...params,
|
674
|
-
locale:
|
945
|
+
locale: localesForAction
|
946
|
+
}
|
947
|
+
});
|
948
|
+
setSelectedRows([]);
|
949
|
+
};
|
950
|
+
const unpublish = async () => {
|
951
|
+
await unpublishManyAction({
|
952
|
+
model,
|
953
|
+
documentIds: [documentId],
|
954
|
+
params: {
|
955
|
+
...params,
|
956
|
+
locale: localesForAction
|
675
957
|
}
|
676
958
|
});
|
677
959
|
setSelectedRows([]);
|
678
960
|
};
|
679
961
|
const handleAction = async () => {
|
680
962
|
if (draftRelationsCount > 0) {
|
681
|
-
|
682
|
-
} else {
|
963
|
+
setIsDraftRelationConfirmationOpen(true);
|
964
|
+
} else if (isBulkPublish) {
|
683
965
|
await publish();
|
966
|
+
} else {
|
967
|
+
await unpublish();
|
684
968
|
}
|
685
969
|
};
|
686
|
-
|
687
|
-
if (isUnpublish) {
|
688
|
-
console.warn(["I18N"], "Bulk locale unpublish modal not implemented");
|
689
|
-
}
|
690
|
-
if (isConfirmationOpen) {
|
970
|
+
if (isDraftRelationConfirmationOpen) {
|
691
971
|
return {
|
692
972
|
label: formatMessage({
|
693
973
|
id: "app.components.ConfirmDialog.title",
|
@@ -696,11 +976,11 @@ const BulkLocalePublishAction = ({
|
|
696
976
|
variant: "danger",
|
697
977
|
dialog: {
|
698
978
|
onCancel: () => {
|
699
|
-
|
979
|
+
setIsDraftRelationConfirmationOpen(false);
|
700
980
|
},
|
701
981
|
onConfirm: async () => {
|
702
982
|
await publish();
|
703
|
-
|
983
|
+
setIsDraftRelationConfirmationOpen(false);
|
704
984
|
},
|
705
985
|
type: "dialog",
|
706
986
|
title: formatMessage({
|
@@ -710,27 +990,32 @@ const BulkLocalePublishAction = ({
|
|
710
990
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "center", gap: 2, children: [
|
711
991
|
/* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, { width: "2.4rem", height: "2.4rem", fill: "danger600" }),
|
712
992
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textAlign: "center", children: formatMessage({
|
713
|
-
id: "
|
714
|
-
defaultMessage: "
|
993
|
+
id: getTranslation("CMEditViewBulkLocale.draft-relation-warning"),
|
994
|
+
defaultMessage: "Some locales are related to draft entries. Publishing them could leave broken links in your app."
|
995
|
+
}) }),
|
996
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textAlign: "center", children: formatMessage({
|
997
|
+
id: getTranslation("CMEditViewBulkLocale.continue-confirmation"),
|
998
|
+
defaultMessage: "Are you sure you want to continue?"
|
715
999
|
}) })
|
716
1000
|
] })
|
717
1001
|
}
|
718
1002
|
};
|
719
1003
|
}
|
1004
|
+
const hasPermission = selectedRows.map(({ locale }) => locale).every((locale) => canPublish.includes(locale));
|
720
1005
|
return {
|
721
1006
|
label: formatMessage({
|
722
|
-
id: getTranslation("
|
723
|
-
defaultMessage: "Publish Multiple Locales
|
1007
|
+
id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? "publish" : "unpublish"}-title`),
|
1008
|
+
defaultMessage: `${isBulkPublish ? "Publish" : "Unpublish"} Multiple Locales`
|
724
1009
|
}),
|
725
|
-
|
726
|
-
|
1010
|
+
variant: isBulkPublish ? "secondary" : "danger",
|
1011
|
+
icon: isBulkPublish ? /* @__PURE__ */ jsxRuntime.jsx(icons.ListPlus, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {}),
|
1012
|
+
disabled: isOnPublishedTab || canPublish.length === 0,
|
727
1013
|
position: ["panel"],
|
728
|
-
variant: "secondary",
|
729
1014
|
dialog: {
|
730
1015
|
type: "modal",
|
731
1016
|
title: formatMessage({
|
732
|
-
id: getTranslation("
|
733
|
-
defaultMessage: "Publish Multiple Locales
|
1017
|
+
id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? "publish" : "unpublish"}-title`),
|
1018
|
+
defaultMessage: `${isBulkPublish ? "Publish" : "Unpublish"} Multiple Locales`
|
734
1019
|
}),
|
735
1020
|
content: () => {
|
736
1021
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -749,28 +1034,35 @@ const BulkLocalePublishAction = ({
|
|
749
1034
|
validationErrors,
|
750
1035
|
headers,
|
751
1036
|
rows,
|
752
|
-
localesMetadata
|
1037
|
+
localesMetadata,
|
1038
|
+
action: action ?? "bulk-publish"
|
753
1039
|
}
|
754
1040
|
)
|
755
1041
|
}
|
756
1042
|
);
|
757
1043
|
},
|
758
|
-
footer: () => /* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1044
|
+
footer: () => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Footer, { justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
|
759
1045
|
designSystem.Button,
|
760
1046
|
{
|
761
1047
|
loading: isDraftRelationsLoading,
|
762
|
-
disabled:
|
1048
|
+
disabled: !hasPermission || localesForAction.length === 0,
|
763
1049
|
variant: "default",
|
764
1050
|
onClick: handleAction,
|
765
1051
|
children: formatMessage({
|
766
|
-
id: "app.utils.publish",
|
767
|
-
defaultMessage: "Publish"
|
1052
|
+
id: isBulkPublish ? "app.utils.publish" : "app.utils.unpublish",
|
1053
|
+
defaultMessage: isBulkPublish ? "Publish" : "Unpublish"
|
768
1054
|
})
|
769
1055
|
}
|
770
1056
|
) })
|
771
1057
|
}
|
772
1058
|
};
|
773
1059
|
};
|
1060
|
+
const BulkLocalePublishAction = (props) => {
|
1061
|
+
return BulkLocaleAction({ action: "bulk-publish", ...props });
|
1062
|
+
};
|
1063
|
+
const BulkLocaleUnpublishAction = (props) => {
|
1064
|
+
return BulkLocaleAction({ action: "bulk-unpublish", ...props });
|
1065
|
+
};
|
774
1066
|
const StyledTrash = styledComponents.styled(icons.Trash)`
|
775
1067
|
path {
|
776
1068
|
fill: currentColor;
|
@@ -827,16 +1119,9 @@ const UnpublishModalAdditionalInfo = () => {
|
|
827
1119
|
}
|
828
1120
|
) });
|
829
1121
|
};
|
830
|
-
const Initializer = ({ setPlugin }) => {
|
831
|
-
const setPluginRef = React__namespace.useRef(setPlugin);
|
832
|
-
React__namespace.useEffect(() => {
|
833
|
-
setPluginRef.current(pluginId);
|
834
|
-
}, []);
|
835
|
-
return null;
|
836
|
-
};
|
837
1122
|
const LocalePicker = () => {
|
838
1123
|
const { formatMessage } = reactIntl.useIntl();
|
839
|
-
const [{ query }, setQuery] = strapiAdmin.useQueryParams();
|
1124
|
+
const [{ query: query2 }, setQuery] = strapiAdmin.useQueryParams();
|
840
1125
|
const { hasI18n, canRead, canCreate } = useI18n();
|
841
1126
|
const { data: locales = [] } = useGetLocalesQuery(void 0, {
|
842
1127
|
skip: !hasI18n
|
@@ -846,25 +1131,25 @@ const LocalePicker = () => {
|
|
846
1131
|
setQuery(
|
847
1132
|
{
|
848
1133
|
page: 1,
|
849
|
-
plugins: { ...
|
1134
|
+
plugins: { ...query2.plugins, i18n: { locale: code } }
|
850
1135
|
},
|
851
1136
|
"push",
|
852
1137
|
replace
|
853
1138
|
);
|
854
1139
|
},
|
855
|
-
[
|
1140
|
+
[query2.plugins, setQuery]
|
856
1141
|
);
|
857
1142
|
React__namespace.useEffect(() => {
|
858
1143
|
if (!Array.isArray(locales) || !hasI18n) {
|
859
1144
|
return;
|
860
1145
|
}
|
861
|
-
const currentDesiredLocale =
|
1146
|
+
const currentDesiredLocale = query2.plugins?.i18n?.locale;
|
862
1147
|
const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
|
863
1148
|
const defaultLocale = locales.find((locale) => locale.isDefault);
|
864
1149
|
if (!doesLocaleExist && defaultLocale?.code) {
|
865
1150
|
handleChange(defaultLocale.code, true);
|
866
1151
|
}
|
867
|
-
}, [hasI18n, handleChange, locales,
|
1152
|
+
}, [hasI18n, handleChange, locales, query2.plugins?.i18n?.locale]);
|
868
1153
|
if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
|
869
1154
|
return null;
|
870
1155
|
}
|
@@ -879,7 +1164,7 @@ const LocalePicker = () => {
|
|
879
1164
|
id: getTranslation("actions.select-locale"),
|
880
1165
|
defaultMessage: "Select locale"
|
881
1166
|
}),
|
882
|
-
value:
|
1167
|
+
value: query2.plugins?.i18n?.locale || locales.find((locale) => locale.isDefault)?.code,
|
883
1168
|
onChange: handleChange,
|
884
1169
|
children: displayedLocales.map((locale) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: locale.code, children: locale.name }, locale.id))
|
885
1170
|
}
|
@@ -974,13 +1259,7 @@ const LocaleListCell = ({
|
|
974
1259
|
}
|
975
1260
|
});
|
976
1261
|
const { locale: language } = reactIntl.useIntl();
|
977
|
-
const [visible, setVisible] = React__namespace.useState(false);
|
978
|
-
const buttonRef = React__namespace.useRef(null);
|
979
1262
|
const { data: locales = [] } = useGetLocalesQuery();
|
980
|
-
const handleTogglePopover = (e) => {
|
981
|
-
e.stopPropagation();
|
982
|
-
setVisible((prev) => !prev);
|
983
|
-
};
|
984
1263
|
const formatter = designSystem.useCollator(language, {
|
985
1264
|
sensitivity: "base"
|
986
1265
|
});
|
@@ -1002,64 +1281,14 @@ const LocaleListCell = ({
|
|
1002
1281
|
}
|
1003
1282
|
return locale.name;
|
1004
1283
|
}).toSorted((a, b) => formatter.compare(a, b));
|
1005
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
1006
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
1007
|
-
|
1008
|
-
{
|
1009
|
-
|
1010
|
-
|
1011
|
-
justifyContent: "center",
|
1012
|
-
height: "3.2rem",
|
1013
|
-
width: "3.2rem",
|
1014
|
-
children: [
|
1015
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", ellipsis: true, children: localesForDocument.join(", ") }),
|
1016
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(icons.CaretDown, {}) })
|
1017
|
-
]
|
1018
|
-
}
|
1019
|
-
),
|
1020
|
-
visible && /* @__PURE__ */ jsxRuntime.jsx(
|
1021
|
-
designSystem.Popover,
|
1022
|
-
{
|
1023
|
-
onDismiss: () => setVisible(false),
|
1024
|
-
source: buttonRef,
|
1025
|
-
spacing: 16,
|
1026
|
-
centered: true,
|
1027
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("ul", { children: localesForDocument.map((name) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 3, tag: "li", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: name }) }, name)) })
|
1028
|
-
}
|
1029
|
-
)
|
1284
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Popover.Root, { children: [
|
1285
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "ghost", type: "button", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { minWidth: "100%", alignItems: "center", justifyContent: "center", fontWeight: "regular", children: [
|
1286
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", ellipsis: true, marginRight: 2, children: localesForDocument.join(", ") }),
|
1287
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(icons.CaretDown, { width: "1.2rem", height: "1.2rem" }) })
|
1288
|
+
] }) }) }),
|
1289
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Content, { sideOffset: 16, children: /* @__PURE__ */ jsxRuntime.jsx("ul", { children: localesForDocument.map((name) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 3, tag: "li", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: name }) }, name)) }) })
|
1030
1290
|
] });
|
1031
1291
|
};
|
1032
|
-
const Button = styledComponents.styled.button`
|
1033
|
-
width: 100%;
|
1034
|
-
|
1035
|
-
svg {
|
1036
|
-
> g,
|
1037
|
-
path {
|
1038
|
-
fill: ${({ theme }) => theme.colors.neutral500};
|
1039
|
-
}
|
1040
|
-
}
|
1041
|
-
&:hover {
|
1042
|
-
svg {
|
1043
|
-
> g,
|
1044
|
-
path {
|
1045
|
-
fill: ${({ theme }) => theme.colors.neutral600};
|
1046
|
-
}
|
1047
|
-
}
|
1048
|
-
}
|
1049
|
-
&:active {
|
1050
|
-
svg {
|
1051
|
-
> g,
|
1052
|
-
path {
|
1053
|
-
fill: ${({ theme }) => theme.colors.neutral400};
|
1054
|
-
}
|
1055
|
-
}
|
1056
|
-
}
|
1057
|
-
`;
|
1058
|
-
const ActionWrapper = styledComponents.styled(designSystem.Flex)`
|
1059
|
-
svg {
|
1060
|
-
height: 0.4rem;
|
1061
|
-
}
|
1062
|
-
`;
|
1063
1292
|
const addColumnToTableHook = ({ displayedHeaders, layout }) => {
|
1064
1293
|
const { options } = layout;
|
1065
1294
|
const isFieldLocalized = doesPluginOptionsHaveI18nLocalized(options) ? options.i18n.localized : false;
|
@@ -1088,18 +1317,11 @@ const addColumnToTableHook = ({ displayedHeaders, layout }) => {
|
|
1088
1317
|
const addLocaleToReleasesHook = ({ displayedHeaders = [] }) => {
|
1089
1318
|
return {
|
1090
1319
|
displayedHeaders: [
|
1091
|
-
|
1092
|
-
// ...displayedHeaders,
|
1320
|
+
...displayedHeaders,
|
1093
1321
|
{
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
label: {
|
1098
|
-
id: "content-releases.page.ReleaseDetails.table.header.label.locale",
|
1099
|
-
defaultMessage: "locale"
|
1100
|
-
},
|
1101
|
-
searchable: false,
|
1102
|
-
sortable: false
|
1322
|
+
label: {
|
1323
|
+
id: "content-releases.page.ReleaseDetails.table.header.label.locale",
|
1324
|
+
defaultMessage: "locale"
|
1103
1325
|
},
|
1104
1326
|
name: "locale"
|
1105
1327
|
}
|
@@ -1247,8 +1469,6 @@ const index = {
|
|
1247
1469
|
app.addRBACMiddleware([localeMiddleware]);
|
1248
1470
|
app.registerPlugin({
|
1249
1471
|
id: pluginId,
|
1250
|
-
initializer: Initializer,
|
1251
|
-
isReady: false,
|
1252
1472
|
name: pluginId
|
1253
1473
|
});
|
1254
1474
|
},
|
@@ -1266,11 +1486,11 @@ const index = {
|
|
1266
1486
|
},
|
1267
1487
|
id: "internationalization",
|
1268
1488
|
to: "internationalization",
|
1269
|
-
Component: () => Promise.resolve().then(() => require("./SettingsPage-
|
1489
|
+
Component: () => Promise.resolve().then(() => require("./SettingsPage-CJOMVQv5.js")).then((mod) => ({ default: mod.ProtectedSettingsPage })),
|
1270
1490
|
permissions: PERMISSIONS.accessMain
|
1271
1491
|
});
|
1272
1492
|
const contentManager = app.getPlugin("content-manager");
|
1273
|
-
contentManager.apis.addDocumentHeaderAction([LocalePickerAction]);
|
1493
|
+
contentManager.apis.addDocumentHeaderAction([LocalePickerAction, FillFromAnotherLocaleAction]);
|
1274
1494
|
contentManager.apis.addDocumentAction((actions) => {
|
1275
1495
|
const indexOfDeleteAction = actions.findIndex((action) => action.type === "delete");
|
1276
1496
|
actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);
|
@@ -1278,6 +1498,7 @@ const index = {
|
|
1278
1498
|
});
|
1279
1499
|
contentManager.apis.addDocumentAction((actions) => {
|
1280
1500
|
actions.splice(2, 0, BulkLocalePublishAction);
|
1501
|
+
actions.splice(5, 0, BulkLocaleUnpublishAction);
|
1281
1502
|
return actions;
|
1282
1503
|
});
|
1283
1504
|
contentManager.injectComponent("listView", "actions", {
|
@@ -1383,7 +1604,7 @@ const index = {
|
|
1383
1604
|
async registerTrads({ locales }) {
|
1384
1605
|
const importedTrads = await Promise.all(
|
1385
1606
|
locales.map((locale) => {
|
1386
|
-
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-DtWiGdHl.js")), "./translations/dk.json": () => Promise.resolve().then(() => require("./dk-D8C-casx.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-
|
1607
|
+
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-DtWiGdHl.js")), "./translations/dk.json": () => Promise.resolve().then(() => require("./dk-D8C-casx.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-Dk9At9_Z.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-DS-XFGSw.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-BTjekDpq.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-DmcGUBQ3.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-Cn5RYonZ.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BMBgVL3s.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-CarUU76c.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-DSHIXAa3.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CukOviB0.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
|
1387
1608
|
return {
|
1388
1609
|
data: prefixPluginTranslations(data, pluginId),
|
1389
1610
|
locale
|
@@ -1407,4 +1628,4 @@ exports.useDeleteLocaleMutation = useDeleteLocaleMutation;
|
|
1407
1628
|
exports.useGetDefaultLocalesQuery = useGetDefaultLocalesQuery;
|
1408
1629
|
exports.useGetLocalesQuery = useGetLocalesQuery;
|
1409
1630
|
exports.useUpdateLocaleMutation = useUpdateLocaleMutation;
|
1410
|
-
//# sourceMappingURL=index-
|
1631
|
+
//# sourceMappingURL=index-C5SImSYG.js.map
|