@strapi/i18n 0.0.0-experimental.145e7d7ddefd1aef71aaf3d9bb86440d013035bf → 0.0.0-experimental.14fd433d38456a5899dff3ea799f80d8757a85e3
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/{SettingsPage-CPNFX0bZ.mjs → SettingsPage-B6QDUmu9.mjs} +4 -4
- package/dist/_chunks/SettingsPage-B6QDUmu9.mjs.map +1 -0
- package/dist/_chunks/{SettingsPage-C-1h_H38.js → SettingsPage-BsHtr3lV.js} +5 -6
- package/dist/_chunks/SettingsPage-BsHtr3lV.js.map +1 -0
- package/dist/_chunks/{en-CwI88-PP.js → en-BKBz3tro.js} +10 -4
- package/dist/_chunks/en-BKBz3tro.js.map +1 -0
- package/dist/_chunks/{en-CtekP_47.mjs → en-DlXfy6Gy.mjs} +10 -4
- package/dist/_chunks/en-DlXfy6Gy.mjs.map +1 -0
- package/dist/_chunks/{index-jpk39Rxo.js → index-3XgwXL6T.js} +292 -77
- package/dist/_chunks/index-3XgwXL6T.js.map +1 -0
- package/dist/_chunks/{index-CgjpU2bY.mjs → index-iEQ79W05.mjs} +294 -78
- package/dist/_chunks/index-iEQ79W05.mjs.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/CMHeaderActions.d.ts +28 -3
- package/dist/admin/src/components/CreateLocale.d.ts +6 -6
- package/dist/admin/src/components/LocaleListCell.d.ts +4 -4
- package/dist/admin/src/utils/clean.d.ts +4 -0
- package/dist/server/index.js +398 -487
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +399 -487
- 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 +7 -11
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +6 -8
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/sanitize/index.d.ts +11 -0
- package/dist/server/src/services/sanitize/index.d.ts.map +1 -0
- package/dist/server/src/utils/index.d.ts +2 -2
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/package.json +13 -13
- package/dist/_chunks/SettingsPage-C-1h_H38.js.map +0 -1
- package/dist/_chunks/SettingsPage-CPNFX0bZ.mjs.map +0 -1
- package/dist/_chunks/en-CtekP_47.mjs.map +0 -1
- package/dist/_chunks/en-CwI88-PP.js.map +0 -1
- package/dist/_chunks/index-CgjpU2bY.mjs.map +0 -1
- package/dist/_chunks/index-jpk39Rxo.js.map +0 -1
- package/dist/server/src/migrations/content-type/disable/index.d.ts +0 -3
- package/dist/server/src/migrations/content-type/disable/index.d.ts.map +0 -1
- package/dist/server/src/migrations/content-type/enable/index.d.ts +0 -3
- package/dist/server/src/migrations/content-type/enable/index.d.ts.map +0 -1
- 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
@@ -1,25 +1,32 @@
|
|
1
1
|
import get from "lodash/get";
|
2
2
|
import * as yup from "yup";
|
3
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
3
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
4
4
|
import * as React from "react";
|
5
5
|
import { Typography, Dialog, Field, Checkbox, Flex, Button, Modal, Box, Status, IconButton, Tooltip, SingleSelect, SingleSelectOption, VisuallyHidden, useCollator, Popover } from "@strapi/design-system";
|
6
|
-
import { WarningCircle, Pencil, CrossCircle, CheckCircle, ArrowsCounterClockwise, Trash, ListPlus, Cross, Earth, EarthStriked, CaretDown } from "@strapi/icons";
|
6
|
+
import { WarningCircle, Pencil, CrossCircle, CheckCircle, ArrowsCounterClockwise, Trash, Plus, Download, ListPlus, Cross, Earth, EarthStriked, CaretDown } from "@strapi/icons";
|
7
7
|
import { useIntl } from "react-intl";
|
8
8
|
import { styled } from "styled-components";
|
9
9
|
import { skipToken } from "@reduxjs/toolkit/query";
|
10
|
-
import { useAuth, adminApi, useTable, Table, useQueryParams, useNotification, useAPIErrorHandler } from "@strapi/admin/strapi-admin";
|
10
|
+
import { useAuth, adminApi, useTable, Table, useQueryParams, useForm, useNotification, useAPIErrorHandler } from "@strapi/admin/strapi-admin";
|
11
11
|
import { unstable_useDocument, unstable_useDocumentActions, buildValidParams } from "@strapi/content-manager/strapi-admin";
|
12
12
|
import { useParams, Link, useNavigate, matchPath } from "react-router-dom";
|
13
13
|
import * as qs from "qs";
|
14
14
|
import { stringify } from "qs";
|
15
15
|
import omit from "lodash/omit";
|
16
|
-
const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
16
|
+
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
17
17
|
const v = glob[path];
|
18
18
|
if (v) {
|
19
19
|
return typeof v === "function" ? v() : Promise.resolve(v);
|
20
20
|
}
|
21
21
|
return new Promise((_, reject) => {
|
22
|
-
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
22
|
+
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
23
|
+
reject.bind(
|
24
|
+
null,
|
25
|
+
new Error(
|
26
|
+
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
27
|
+
)
|
28
|
+
)
|
29
|
+
);
|
23
30
|
});
|
24
31
|
};
|
25
32
|
const pluginId = "i18n";
|
@@ -217,6 +224,86 @@ const relationsApi = i18nApi.injectEndpoints({
|
|
217
224
|
})
|
218
225
|
});
|
219
226
|
const { useGetManyDraftRelationCountQuery } = relationsApi;
|
227
|
+
const cleanData = (data, schema, components) => {
|
228
|
+
const cleanedData = removeFields(data, [
|
229
|
+
"createdAt",
|
230
|
+
"createdBy",
|
231
|
+
"updatedAt",
|
232
|
+
"updatedBy",
|
233
|
+
"id",
|
234
|
+
"documentId",
|
235
|
+
"publishedAt",
|
236
|
+
"strapi_stage",
|
237
|
+
"strapi_assignee",
|
238
|
+
"locale",
|
239
|
+
"status"
|
240
|
+
]);
|
241
|
+
const cleanedDataWithoutPasswordAndRelation = recursiveRemoveFieldTypes(
|
242
|
+
cleanedData,
|
243
|
+
schema,
|
244
|
+
components,
|
245
|
+
["relation", "password"]
|
246
|
+
);
|
247
|
+
return cleanedDataWithoutPasswordAndRelation;
|
248
|
+
};
|
249
|
+
const removeFields = (data, fields) => {
|
250
|
+
return Object.keys(data).reduce((acc, current) => {
|
251
|
+
if (fields.includes(current)) {
|
252
|
+
return acc;
|
253
|
+
}
|
254
|
+
acc[current] = data[current];
|
255
|
+
return acc;
|
256
|
+
}, {});
|
257
|
+
};
|
258
|
+
const recursiveRemoveFieldTypes = (data, schema, components, fields) => {
|
259
|
+
return Object.keys(data).reduce((acc, current) => {
|
260
|
+
const attribute = schema.attributes[current] ?? { type: void 0 };
|
261
|
+
if (fields.includes(attribute.type)) {
|
262
|
+
return acc;
|
263
|
+
}
|
264
|
+
if (attribute.type === "dynamiczone") {
|
265
|
+
acc[current] = data[current].map((componentValue, index2) => {
|
266
|
+
const { id: _, ...rest } = recursiveRemoveFieldTypes(
|
267
|
+
componentValue,
|
268
|
+
components[componentValue.__component],
|
269
|
+
components,
|
270
|
+
fields
|
271
|
+
);
|
272
|
+
return {
|
273
|
+
...rest,
|
274
|
+
__temp_key__: index2 + 1
|
275
|
+
};
|
276
|
+
});
|
277
|
+
} else if (attribute.type === "component") {
|
278
|
+
const { repeatable, component } = attribute;
|
279
|
+
if (repeatable) {
|
280
|
+
acc[current] = (data[current] ?? []).map((compoData, index2) => {
|
281
|
+
const { id: _, ...rest } = recursiveRemoveFieldTypes(
|
282
|
+
compoData,
|
283
|
+
components[component],
|
284
|
+
components,
|
285
|
+
fields
|
286
|
+
);
|
287
|
+
return {
|
288
|
+
...rest,
|
289
|
+
__temp_key__: index2 + 1
|
290
|
+
};
|
291
|
+
});
|
292
|
+
} else {
|
293
|
+
const { id: _, ...rest } = recursiveRemoveFieldTypes(
|
294
|
+
data[current] ?? {},
|
295
|
+
components[component],
|
296
|
+
components,
|
297
|
+
fields
|
298
|
+
);
|
299
|
+
acc[current] = rest;
|
300
|
+
}
|
301
|
+
} else {
|
302
|
+
acc[current] = data[current];
|
303
|
+
}
|
304
|
+
return acc;
|
305
|
+
}, {});
|
306
|
+
};
|
220
307
|
const isErrorMessageDescriptor = (object) => {
|
221
308
|
return typeof object === "object" && object !== null && "id" in object && "defaultMessage" in object;
|
222
309
|
};
|
@@ -379,7 +466,6 @@ const BulkLocaleActionModal = ({
|
|
379
466
|
paddingRight: "6px",
|
380
467
|
paddingTop: "2px",
|
381
468
|
paddingBottom: "2px",
|
382
|
-
showBullet: false,
|
383
469
|
size: "S",
|
384
470
|
variant: statusVariant,
|
385
471
|
children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
@@ -411,6 +497,47 @@ const BulkLocaleActionModal = ({
|
|
411
497
|
] }) })
|
412
498
|
] });
|
413
499
|
};
|
500
|
+
const statusVariants = {
|
501
|
+
draft: "secondary",
|
502
|
+
published: "success",
|
503
|
+
modified: "alternative"
|
504
|
+
};
|
505
|
+
const LocaleOption = ({
|
506
|
+
isDraftAndPublishEnabled,
|
507
|
+
locale,
|
508
|
+
status,
|
509
|
+
entryExists
|
510
|
+
}) => {
|
511
|
+
const { formatMessage } = useIntl();
|
512
|
+
if (!entryExists) {
|
513
|
+
return formatMessage(
|
514
|
+
{
|
515
|
+
id: getTranslation("CMEditViewLocalePicker.locale.create"),
|
516
|
+
defaultMessage: "Create <bold>{locale}</bold> locale"
|
517
|
+
},
|
518
|
+
{
|
519
|
+
bold: (locale2) => /* @__PURE__ */ jsx("b", { children: locale2 }),
|
520
|
+
locale: locale.name
|
521
|
+
}
|
522
|
+
);
|
523
|
+
}
|
524
|
+
return /* @__PURE__ */ jsxs(Flex, { width: "100%", gap: 1, justifyContent: "space-between", children: [
|
525
|
+
/* @__PURE__ */ jsx(Typography, { children: locale.name }),
|
526
|
+
isDraftAndPublishEnabled ? /* @__PURE__ */ jsx(
|
527
|
+
Status,
|
528
|
+
{
|
529
|
+
display: "flex",
|
530
|
+
paddingLeft: "6px",
|
531
|
+
paddingRight: "6px",
|
532
|
+
paddingTop: "2px",
|
533
|
+
paddingBottom: "2px",
|
534
|
+
size: "S",
|
535
|
+
variant: statusVariants[status],
|
536
|
+
children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
537
|
+
}
|
538
|
+
) : null
|
539
|
+
] });
|
540
|
+
};
|
414
541
|
const LocalePickerAction = ({
|
415
542
|
document,
|
416
543
|
meta,
|
@@ -422,7 +549,13 @@ const LocalePickerAction = ({
|
|
422
549
|
const [{ query }, setQuery] = useQueryParams();
|
423
550
|
const { hasI18n, canCreate, canRead } = useI18n();
|
424
551
|
const { data: locales = [] } = useGetLocalesQuery();
|
425
|
-
const
|
552
|
+
const currentDesiredLocale = query.plugins?.i18n?.locale;
|
553
|
+
const { schema } = unstable_useDocument({
|
554
|
+
model,
|
555
|
+
collectionType,
|
556
|
+
documentId,
|
557
|
+
params: { locale: currentDesiredLocale }
|
558
|
+
});
|
426
559
|
const handleSelect = React.useCallback(
|
427
560
|
(value) => {
|
428
561
|
setQuery({
|
@@ -440,53 +573,50 @@ const LocalePickerAction = ({
|
|
440
573
|
if (!Array.isArray(locales) || !hasI18n) {
|
441
574
|
return;
|
442
575
|
}
|
443
|
-
const currentDesiredLocale = query.plugins?.i18n?.locale;
|
444
576
|
const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
|
445
577
|
const defaultLocale = locales.find((locale) => locale.isDefault);
|
446
578
|
if (!doesLocaleExist && defaultLocale?.code) {
|
447
579
|
handleSelect(defaultLocale.code);
|
448
580
|
}
|
449
|
-
}, [handleSelect, hasI18n, locales,
|
581
|
+
}, [handleSelect, hasI18n, locales, currentDesiredLocale]);
|
582
|
+
const currentLocale = Array.isArray(locales) ? locales.find((locale) => locale.code === currentDesiredLocale) : void 0;
|
583
|
+
const allCurrentLocales = [
|
584
|
+
{ status: getDocumentStatus(document, meta), locale: currentLocale?.code },
|
585
|
+
...document?.localizations ?? []
|
586
|
+
];
|
450
587
|
if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
|
451
588
|
return null;
|
452
589
|
}
|
453
|
-
const
|
454
|
-
|
455
|
-
|
456
|
-
...meta?.availableLocales ?? []
|
457
|
-
];
|
590
|
+
const displayedLocales = locales.filter((locale) => {
|
591
|
+
return canRead.includes(locale.code);
|
592
|
+
});
|
458
593
|
return {
|
459
594
|
label: formatMessage({
|
460
595
|
id: getTranslation("Settings.locales.modal.locales.label"),
|
461
596
|
defaultMessage: "Locales"
|
462
597
|
}),
|
463
|
-
options:
|
598
|
+
options: displayedLocales.map((locale) => {
|
599
|
+
const entryWithLocaleExists = allCurrentLocales.some((doc) => doc.locale === locale.code);
|
464
600
|
const currentLocaleDoc = allCurrentLocales.find(
|
465
601
|
(doc) => "locale" in doc ? doc.locale === locale.code : false
|
466
602
|
);
|
467
|
-
const
|
468
|
-
const permissionsToCheck = currentLocaleDoc ? canCreate : canRead;
|
469
|
-
const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
|
603
|
+
const permissionsToCheck = currentLocaleDoc ? canRead : canCreate;
|
470
604
|
return {
|
471
605
|
disabled: !permissionsToCheck.includes(locale.code),
|
472
606
|
value: locale.code,
|
473
|
-
label:
|
474
|
-
|
475
|
-
Status,
|
607
|
+
label: /* @__PURE__ */ jsx(
|
608
|
+
LocaleOption,
|
476
609
|
{
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
paddingBottom: "2px",
|
482
|
-
showBullet: false,
|
483
|
-
size: "S",
|
484
|
-
variant: statusVariant,
|
485
|
-
children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
610
|
+
isDraftAndPublishEnabled: !!schema?.options?.draftAndPublish,
|
611
|
+
locale,
|
612
|
+
status: currentLocaleDoc?.status,
|
613
|
+
entryExists: entryWithLocaleExists
|
486
614
|
}
|
487
|
-
)
|
615
|
+
),
|
616
|
+
startIcon: !entryWithLocaleExists ? /* @__PURE__ */ jsx(Plus, {}) : null
|
488
617
|
};
|
489
618
|
}),
|
619
|
+
customizeContent: () => currentLocale?.name,
|
490
620
|
onSelect: handleSelect,
|
491
621
|
value: currentLocale
|
492
622
|
};
|
@@ -502,6 +632,99 @@ const getDocumentStatus = (document, meta) => {
|
|
502
632
|
}
|
503
633
|
return docStatus;
|
504
634
|
};
|
635
|
+
const FillFromAnotherLocaleAction = ({
|
636
|
+
documentId,
|
637
|
+
meta,
|
638
|
+
model,
|
639
|
+
collectionType
|
640
|
+
}) => {
|
641
|
+
const { formatMessage } = useIntl();
|
642
|
+
const [{ query }] = useQueryParams();
|
643
|
+
const { hasI18n } = useI18n();
|
644
|
+
const currentDesiredLocale = query.plugins?.i18n?.locale;
|
645
|
+
const [localeSelected, setLocaleSelected] = React.useState(null);
|
646
|
+
const setValues = useForm("FillFromAnotherLocale", (state) => state.setValues);
|
647
|
+
const { getDocument } = unstable_useDocumentActions();
|
648
|
+
const { schema, components } = unstable_useDocument({
|
649
|
+
model,
|
650
|
+
documentId,
|
651
|
+
collectionType,
|
652
|
+
params: { locale: currentDesiredLocale }
|
653
|
+
});
|
654
|
+
const { data: locales = [] } = useGetLocalesQuery();
|
655
|
+
const availableLocales = Array.isArray(locales) ? locales.filter((locale) => meta?.availableLocales.some((l) => l.locale === locale.code)) : [];
|
656
|
+
const fillFromLocale = (onClose) => async () => {
|
657
|
+
const response = await getDocument({
|
658
|
+
collectionType,
|
659
|
+
model,
|
660
|
+
documentId,
|
661
|
+
params: { locale: localeSelected }
|
662
|
+
});
|
663
|
+
if (!response || !schema) {
|
664
|
+
return;
|
665
|
+
}
|
666
|
+
const { data } = response;
|
667
|
+
const cleanedData = cleanData(data, schema, components);
|
668
|
+
setValues(cleanedData);
|
669
|
+
onClose();
|
670
|
+
};
|
671
|
+
if (!hasI18n) {
|
672
|
+
return null;
|
673
|
+
}
|
674
|
+
return {
|
675
|
+
type: "icon",
|
676
|
+
icon: /* @__PURE__ */ jsx(Download, {}),
|
677
|
+
disabled: availableLocales.length === 0,
|
678
|
+
label: formatMessage({
|
679
|
+
id: getTranslation("CMEditViewCopyLocale.copy-text"),
|
680
|
+
defaultMessage: "Fill in from another locale"
|
681
|
+
}),
|
682
|
+
dialog: {
|
683
|
+
type: "dialog",
|
684
|
+
title: formatMessage({
|
685
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.title"),
|
686
|
+
defaultMessage: "Confirmation"
|
687
|
+
}),
|
688
|
+
content: ({ onClose }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
689
|
+
/* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, children: [
|
690
|
+
/* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
691
|
+
/* @__PURE__ */ jsx(Typography, { textAlign: "center", children: formatMessage({
|
692
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.body"),
|
693
|
+
defaultMessage: "Your current content will be erased and filled by the content of the selected locale:"
|
694
|
+
}) }),
|
695
|
+
/* @__PURE__ */ jsxs(Field.Root, { width: "100%", children: [
|
696
|
+
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
|
697
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.field.label"),
|
698
|
+
defaultMessage: "Locale"
|
699
|
+
}) }),
|
700
|
+
/* @__PURE__ */ jsx(
|
701
|
+
SingleSelect,
|
702
|
+
{
|
703
|
+
value: localeSelected,
|
704
|
+
placeholder: formatMessage({
|
705
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.field.placeholder"),
|
706
|
+
defaultMessage: "Select one locale..."
|
707
|
+
}),
|
708
|
+
onChange: (value) => setLocaleSelected(value),
|
709
|
+
children: availableLocales.map((locale) => /* @__PURE__ */ jsx(SingleSelectOption, { value: locale.code, children: locale.name }, locale.code))
|
710
|
+
}
|
711
|
+
)
|
712
|
+
] })
|
713
|
+
] }) }),
|
714
|
+
/* @__PURE__ */ jsx(Dialog.Footer, { children: /* @__PURE__ */ jsxs(Flex, { gap: 2, width: "100%", children: [
|
715
|
+
/* @__PURE__ */ jsx(Button, { flex: "auto", variant: "tertiary", onClick: onClose, children: formatMessage({
|
716
|
+
id: getTranslation("CMEditViewCopyLocale.cancel-text"),
|
717
|
+
defaultMessage: "No, cancel"
|
718
|
+
}) }),
|
719
|
+
/* @__PURE__ */ jsx(Button, { flex: "auto", variant: "success", onClick: fillFromLocale(onClose), children: formatMessage({
|
720
|
+
id: getTranslation("CMEditViewCopyLocale.submit-text"),
|
721
|
+
defaultMessage: "Yes, fill in"
|
722
|
+
}) })
|
723
|
+
] }) })
|
724
|
+
] })
|
725
|
+
}
|
726
|
+
};
|
727
|
+
};
|
505
728
|
const DeleteLocaleAction = ({
|
506
729
|
document,
|
507
730
|
documentId,
|
@@ -513,16 +736,23 @@ const DeleteLocaleAction = ({
|
|
513
736
|
const { toggleNotification } = useNotification();
|
514
737
|
const { delete: deleteAction } = unstable_useDocumentActions();
|
515
738
|
const { hasI18n, canDelete } = useI18n();
|
739
|
+
const [{ query }] = useQueryParams();
|
740
|
+
const { data: locales = [] } = useGetLocalesQuery();
|
741
|
+
const currentDesiredLocale = query.plugins?.i18n?.locale;
|
742
|
+
const locale = !("error" in locales) && locales.find((loc) => loc.code === currentDesiredLocale);
|
516
743
|
if (!hasI18n) {
|
517
744
|
return null;
|
518
745
|
}
|
519
746
|
return {
|
520
747
|
disabled: document?.locale && !canDelete.includes(document.locale) || !document || !document.id,
|
521
748
|
position: ["header", "table-row"],
|
522
|
-
label: formatMessage(
|
523
|
-
|
524
|
-
|
525
|
-
|
749
|
+
label: formatMessage(
|
750
|
+
{
|
751
|
+
id: getTranslation("actions.delete.label"),
|
752
|
+
defaultMessage: "Delete entry ({locale})"
|
753
|
+
},
|
754
|
+
{ locale: locale && locale.name }
|
755
|
+
),
|
526
756
|
icon: /* @__PURE__ */ jsx(StyledTrash, {}),
|
527
757
|
variant: "danger",
|
528
758
|
dialog: {
|
@@ -539,7 +769,12 @@ const DeleteLocaleAction = ({
|
|
539
769
|
}) })
|
540
770
|
] }),
|
541
771
|
onConfirm: async () => {
|
542
|
-
|
772
|
+
const unableToDelete = (
|
773
|
+
// We are unable to delete a collection type without a document ID
|
774
|
+
// & unable to delete generally if there is no document locale
|
775
|
+
collectionType !== "single-types" && !documentId || !document?.locale
|
776
|
+
);
|
777
|
+
if (unableToDelete) {
|
543
778
|
console.error(
|
544
779
|
"You're trying to delete a document without an id or locale, this is likely a bug with Strapi. Please open an issue."
|
545
780
|
);
|
@@ -566,13 +801,13 @@ const DeleteLocaleAction = ({
|
|
566
801
|
};
|
567
802
|
};
|
568
803
|
const BulkLocaleAction = ({
|
569
|
-
document
|
804
|
+
document,
|
570
805
|
documentId,
|
571
806
|
model,
|
572
807
|
collectionType,
|
573
808
|
action
|
574
809
|
}) => {
|
575
|
-
const
|
810
|
+
const locale = document?.locale ?? null;
|
576
811
|
const [{ query }] = useQueryParams();
|
577
812
|
const params = React.useMemo(() => buildValidParams(query), [query]);
|
578
813
|
const isOnPublishedTab = query.status === "published";
|
@@ -583,22 +818,18 @@ const BulkLocaleAction = ({
|
|
583
818
|
const [selectedRows, setSelectedRows] = React.useState([]);
|
584
819
|
const [isDraftRelationConfirmationOpen, setIsDraftRelationConfirmationOpen] = React.useState(false);
|
585
820
|
const { publishMany: publishManyAction, unpublishMany: unpublishManyAction } = unstable_useDocumentActions();
|
586
|
-
const {
|
587
|
-
document,
|
588
|
-
meta: documentMeta,
|
589
|
-
schema,
|
590
|
-
validate
|
591
|
-
} = unstable_useDocument(
|
821
|
+
const { schema, validate } = unstable_useDocument(
|
592
822
|
{
|
593
823
|
model,
|
594
824
|
collectionType,
|
595
825
|
documentId,
|
596
826
|
params: {
|
597
|
-
locale
|
827
|
+
locale
|
598
828
|
}
|
599
829
|
},
|
600
830
|
{
|
601
|
-
|
831
|
+
// No need to fetch the document, the data is already available in the `document` prop
|
832
|
+
skip: true
|
602
833
|
}
|
603
834
|
);
|
604
835
|
const { data: localesMetadata = [] } = useGetLocalesQuery(hasI18n ? void 0 : skipToken);
|
@@ -626,18 +857,19 @@ const BulkLocaleAction = ({
|
|
626
857
|
}
|
627
858
|
];
|
628
859
|
const [rows, validationErrors] = React.useMemo(() => {
|
629
|
-
if (!document
|
860
|
+
if (!document) {
|
630
861
|
return [[], {}];
|
631
862
|
}
|
632
|
-
const
|
633
|
-
|
634
|
-
|
863
|
+
const localizations = document.localizations ?? [];
|
864
|
+
const locales = localizations.map((doc) => {
|
865
|
+
const { locale: locale2, status } = doc;
|
866
|
+
return { locale: locale2, status };
|
635
867
|
});
|
636
|
-
|
868
|
+
locales.unshift({
|
637
869
|
locale: document.locale,
|
638
870
|
status: document.status
|
639
871
|
});
|
640
|
-
const allDocuments = [document, ...
|
872
|
+
const allDocuments = [document, ...localizations];
|
641
873
|
const errors = allDocuments.reduce((errs, document2) => {
|
642
874
|
if (!document2) {
|
643
875
|
return errs;
|
@@ -648,8 +880,8 @@ const BulkLocaleAction = ({
|
|
648
880
|
}
|
649
881
|
return errs;
|
650
882
|
}, {});
|
651
|
-
return [
|
652
|
-
}, [document,
|
883
|
+
return [locales, errors];
|
884
|
+
}, [document, validate]);
|
653
885
|
const isBulkPublish = action === "bulk-publish";
|
654
886
|
const localesForAction = selectedRows.reduce((acc, selectedRow) => {
|
655
887
|
const isValidLocale = (
|
@@ -759,7 +991,7 @@ const BulkLocaleAction = ({
|
|
759
991
|
}
|
760
992
|
};
|
761
993
|
}
|
762
|
-
const hasPermission = selectedRows.map(({ locale }) =>
|
994
|
+
const hasPermission = selectedRows.map(({ locale: locale2 }) => locale2).every((locale2) => canPublish.includes(locale2));
|
763
995
|
return {
|
764
996
|
label: formatMessage({
|
765
997
|
id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? "publish" : "unpublish"}-title`),
|
@@ -1002,29 +1234,16 @@ const Span = styled(Flex)`
|
|
1002
1234
|
}
|
1003
1235
|
}
|
1004
1236
|
`;
|
1005
|
-
const LocaleListCell = ({
|
1006
|
-
documentId,
|
1007
|
-
locale: currentLocale,
|
1008
|
-
collectionType,
|
1009
|
-
model
|
1010
|
-
}) => {
|
1011
|
-
const { meta, isLoading } = unstable_useDocument({
|
1012
|
-
documentId,
|
1013
|
-
collectionType,
|
1014
|
-
model,
|
1015
|
-
params: {
|
1016
|
-
locale: currentLocale
|
1017
|
-
}
|
1018
|
-
});
|
1237
|
+
const LocaleListCell = ({ locale: currentLocale, localizations }) => {
|
1019
1238
|
const { locale: language } = useIntl();
|
1020
1239
|
const { data: locales = [] } = useGetLocalesQuery();
|
1021
1240
|
const formatter = useCollator(language, {
|
1022
1241
|
sensitivity: "base"
|
1023
1242
|
});
|
1024
|
-
if (!Array.isArray(locales) ||
|
1243
|
+
if (!Array.isArray(locales) || !localizations) {
|
1025
1244
|
return null;
|
1026
1245
|
}
|
1027
|
-
const availableLocales =
|
1246
|
+
const availableLocales = localizations.map((loc) => loc.locale);
|
1028
1247
|
const localesForDocument = locales.reduce((acc, locale) => {
|
1029
1248
|
const createdLocale = [currentLocale, ...availableLocales].find((loc) => {
|
1030
1249
|
return loc === locale.code;
|
@@ -1172,9 +1391,6 @@ const localeMiddleware = (ctx) => (next) => (permissions) => {
|
|
1172
1391
|
return next(revisedPermissions);
|
1173
1392
|
};
|
1174
1393
|
const prefixPluginTranslations = (trad, pluginId2) => {
|
1175
|
-
if (!pluginId2) {
|
1176
|
-
throw new TypeError("pluginId can't be empty");
|
1177
|
-
}
|
1178
1394
|
return Object.keys(trad).reduce((acc, current) => {
|
1179
1395
|
acc[`${pluginId2}.${current}`] = trad[current];
|
1180
1396
|
return acc;
|
@@ -1244,11 +1460,11 @@ const index = {
|
|
1244
1460
|
},
|
1245
1461
|
id: "internationalization",
|
1246
1462
|
to: "internationalization",
|
1247
|
-
Component: () => import("./SettingsPage-
|
1463
|
+
Component: () => import("./SettingsPage-B6QDUmu9.mjs").then((mod) => ({ default: mod.ProtectedSettingsPage })),
|
1248
1464
|
permissions: PERMISSIONS.accessMain
|
1249
1465
|
});
|
1250
1466
|
const contentManager = app.getPlugin("content-manager");
|
1251
|
-
contentManager.apis.addDocumentHeaderAction([LocalePickerAction]);
|
1467
|
+
contentManager.apis.addDocumentHeaderAction([LocalePickerAction, FillFromAnotherLocaleAction]);
|
1252
1468
|
contentManager.apis.addDocumentAction((actions) => {
|
1253
1469
|
const indexOfDeleteAction = actions.findIndex((action) => action.type === "delete");
|
1254
1470
|
actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);
|
@@ -1362,7 +1578,7 @@ const index = {
|
|
1362
1578
|
async registerTrads({ locales }) {
|
1363
1579
|
const importedTrads = await Promise.all(
|
1364
1580
|
locales.map((locale) => {
|
1365
|
-
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-9eCAqqrB.mjs"), "./translations/dk.json": () => import("./dk-2qBjxt-P.mjs"), "./translations/en.json": () => import("./en-
|
1581
|
+
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-9eCAqqrB.mjs"), "./translations/dk.json": () => import("./dk-2qBjxt-P.mjs"), "./translations/en.json": () => import("./en-DlXfy6Gy.mjs"), "./translations/es.json": () => import("./es-DlmMVaBG.mjs"), "./translations/fr.json": () => import("./fr-3S6ke71d.mjs"), "./translations/ko.json": () => import("./ko-qTjQ8IMw.mjs"), "./translations/pl.json": () => import("./pl-B67TSHqT.mjs"), "./translations/ru.json": () => import("./ru-hagMa57T.mjs"), "./translations/tr.json": () => import("./tr-Dw_jmkG-.mjs"), "./translations/zh-Hans.json": () => import("./zh-Hans-Dyc-aR-h.mjs"), "./translations/zh.json": () => import("./zh-57YM4amO.mjs") }), `./translations/${locale}.json`, 3).then(({ default: data }) => {
|
1366
1582
|
return {
|
1367
1583
|
data: prefixPluginTranslations(data, pluginId),
|
1368
1584
|
locale
|
@@ -1388,4 +1604,4 @@ export {
|
|
1388
1604
|
index as i,
|
1389
1605
|
useCreateLocaleMutation as u
|
1390
1606
|
};
|
1391
|
-
//# sourceMappingURL=index-
|
1607
|
+
//# sourceMappingURL=index-iEQ79W05.mjs.map
|