@strapi/i18n 0.0.0-experimental.145e7d7ddefd1aef71aaf3d9bb86440d013035bf → 0.0.0-experimental.15989d13d8be058bf37afc84b7a8377ef1da3263

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.
Files changed (47) hide show
  1. package/dist/_chunks/{SettingsPage-CPNFX0bZ.mjs → SettingsPage-B6QDUmu9.mjs} +4 -4
  2. package/dist/_chunks/SettingsPage-B6QDUmu9.mjs.map +1 -0
  3. package/dist/_chunks/{SettingsPage-C-1h_H38.js → SettingsPage-BsHtr3lV.js} +5 -6
  4. package/dist/_chunks/SettingsPage-BsHtr3lV.js.map +1 -0
  5. package/dist/_chunks/{en-CwI88-PP.js → en-BKBz3tro.js} +10 -4
  6. package/dist/_chunks/en-BKBz3tro.js.map +1 -0
  7. package/dist/_chunks/{en-CtekP_47.mjs → en-DlXfy6Gy.mjs} +10 -4
  8. package/dist/_chunks/en-DlXfy6Gy.mjs.map +1 -0
  9. package/dist/_chunks/{index-jpk39Rxo.js → index-3XgwXL6T.js} +292 -77
  10. package/dist/_chunks/index-3XgwXL6T.js.map +1 -0
  11. package/dist/_chunks/{index-CgjpU2bY.mjs → index-iEQ79W05.mjs} +294 -78
  12. package/dist/_chunks/index-iEQ79W05.mjs.map +1 -0
  13. package/dist/admin/index.js +1 -1
  14. package/dist/admin/index.mjs +1 -1
  15. package/dist/admin/src/components/CMHeaderActions.d.ts +28 -3
  16. package/dist/admin/src/components/CreateLocale.d.ts +6 -6
  17. package/dist/admin/src/components/LocaleListCell.d.ts +4 -4
  18. package/dist/admin/src/utils/clean.d.ts +4 -0
  19. package/dist/server/index.js +398 -487
  20. package/dist/server/index.js.map +1 -1
  21. package/dist/server/index.mjs +399 -487
  22. package/dist/server/index.mjs.map +1 -1
  23. package/dist/server/src/bootstrap.d.ts +1 -4
  24. package/dist/server/src/bootstrap.d.ts.map +1 -1
  25. package/dist/server/src/index.d.ts +7 -11
  26. package/dist/server/src/index.d.ts.map +1 -1
  27. package/dist/server/src/register.d.ts.map +1 -1
  28. package/dist/server/src/services/index.d.ts +6 -8
  29. package/dist/server/src/services/index.d.ts.map +1 -1
  30. package/dist/server/src/services/sanitize/index.d.ts +11 -0
  31. package/dist/server/src/services/sanitize/index.d.ts.map +1 -0
  32. package/dist/server/src/utils/index.d.ts +2 -2
  33. package/dist/server/src/utils/index.d.ts.map +1 -1
  34. package/package.json +13 -13
  35. package/dist/_chunks/SettingsPage-C-1h_H38.js.map +0 -1
  36. package/dist/_chunks/SettingsPage-CPNFX0bZ.mjs.map +0 -1
  37. package/dist/_chunks/en-CtekP_47.mjs.map +0 -1
  38. package/dist/_chunks/en-CwI88-PP.js.map +0 -1
  39. package/dist/_chunks/index-CgjpU2bY.mjs.map +0 -1
  40. package/dist/_chunks/index-jpk39Rxo.js.map +0 -1
  41. package/dist/server/src/migrations/content-type/disable/index.d.ts +0 -3
  42. package/dist/server/src/migrations/content-type/disable/index.d.ts.map +0 -1
  43. package/dist/server/src/migrations/content-type/enable/index.d.ts +0 -3
  44. package/dist/server/src/migrations/content-type/enable/index.d.ts.map +0 -1
  45. package/dist/server/src/services/entity-service-decorator.d.ts +0 -29
  46. package/dist/server/src/services/entity-service-decorator.d.ts.map +0 -1
  47. package/strapi-server.js +0 -3
@@ -15,8 +15,7 @@ const qs = require("qs");
15
15
  const omit = require("lodash/omit");
16
16
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
17
17
  function _interopNamespace(e) {
18
- if (e && e.__esModule)
19
- return e;
18
+ if (e && e.__esModule) return e;
20
19
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
21
20
  if (e) {
22
21
  for (const k in e) {
@@ -37,13 +36,20 @@ const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
37
36
  const React__namespace = /* @__PURE__ */ _interopNamespace(React);
38
37
  const qs__namespace = /* @__PURE__ */ _interopNamespace(qs);
39
38
  const omit__default = /* @__PURE__ */ _interopDefault(omit);
40
- const __variableDynamicImportRuntimeHelper = (glob, path) => {
39
+ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
41
40
  const v = glob[path];
42
41
  if (v) {
43
42
  return typeof v === "function" ? v() : Promise.resolve(v);
44
43
  }
45
44
  return new Promise((_, reject) => {
46
- (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(reject.bind(null, new Error("Unknown variable dynamic import: " + path)));
45
+ (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
46
+ reject.bind(
47
+ null,
48
+ new Error(
49
+ "Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
50
+ )
51
+ )
52
+ );
47
53
  });
48
54
  };
49
55
  const pluginId = "i18n";
@@ -241,6 +247,86 @@ const relationsApi = i18nApi.injectEndpoints({
241
247
  })
242
248
  });
243
249
  const { useGetManyDraftRelationCountQuery } = relationsApi;
250
+ const cleanData = (data, schema, components) => {
251
+ const cleanedData = removeFields(data, [
252
+ "createdAt",
253
+ "createdBy",
254
+ "updatedAt",
255
+ "updatedBy",
256
+ "id",
257
+ "documentId",
258
+ "publishedAt",
259
+ "strapi_stage",
260
+ "strapi_assignee",
261
+ "locale",
262
+ "status"
263
+ ]);
264
+ const cleanedDataWithoutPasswordAndRelation = recursiveRemoveFieldTypes(
265
+ cleanedData,
266
+ schema,
267
+ components,
268
+ ["relation", "password"]
269
+ );
270
+ return cleanedDataWithoutPasswordAndRelation;
271
+ };
272
+ const removeFields = (data, fields) => {
273
+ return Object.keys(data).reduce((acc, current) => {
274
+ if (fields.includes(current)) {
275
+ return acc;
276
+ }
277
+ acc[current] = data[current];
278
+ return acc;
279
+ }, {});
280
+ };
281
+ const recursiveRemoveFieldTypes = (data, schema, components, fields) => {
282
+ return Object.keys(data).reduce((acc, current) => {
283
+ const attribute = schema.attributes[current] ?? { type: void 0 };
284
+ if (fields.includes(attribute.type)) {
285
+ return acc;
286
+ }
287
+ if (attribute.type === "dynamiczone") {
288
+ acc[current] = data[current].map((componentValue, index2) => {
289
+ const { id: _, ...rest } = recursiveRemoveFieldTypes(
290
+ componentValue,
291
+ components[componentValue.__component],
292
+ components,
293
+ fields
294
+ );
295
+ return {
296
+ ...rest,
297
+ __temp_key__: index2 + 1
298
+ };
299
+ });
300
+ } else if (attribute.type === "component") {
301
+ const { repeatable, component } = attribute;
302
+ if (repeatable) {
303
+ acc[current] = (data[current] ?? []).map((compoData, index2) => {
304
+ const { id: _, ...rest } = recursiveRemoveFieldTypes(
305
+ compoData,
306
+ components[component],
307
+ components,
308
+ fields
309
+ );
310
+ return {
311
+ ...rest,
312
+ __temp_key__: index2 + 1
313
+ };
314
+ });
315
+ } else {
316
+ const { id: _, ...rest } = recursiveRemoveFieldTypes(
317
+ data[current] ?? {},
318
+ components[component],
319
+ components,
320
+ fields
321
+ );
322
+ acc[current] = rest;
323
+ }
324
+ } else {
325
+ acc[current] = data[current];
326
+ }
327
+ return acc;
328
+ }, {});
329
+ };
244
330
  const isErrorMessageDescriptor = (object) => {
245
331
  return typeof object === "object" && object !== null && "id" in object && "defaultMessage" in object;
246
332
  };
@@ -403,7 +489,6 @@ const BulkLocaleActionModal = ({
403
489
  paddingRight: "6px",
404
490
  paddingTop: "2px",
405
491
  paddingBottom: "2px",
406
- showBullet: false,
407
492
  size: "S",
408
493
  variant: statusVariant,
409
494
  children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
@@ -435,6 +520,47 @@ const BulkLocaleActionModal = ({
435
520
  ] }) })
436
521
  ] });
437
522
  };
523
+ const statusVariants = {
524
+ draft: "secondary",
525
+ published: "success",
526
+ modified: "alternative"
527
+ };
528
+ const LocaleOption = ({
529
+ isDraftAndPublishEnabled,
530
+ locale,
531
+ status,
532
+ entryExists
533
+ }) => {
534
+ const { formatMessage } = reactIntl.useIntl();
535
+ if (!entryExists) {
536
+ return formatMessage(
537
+ {
538
+ id: getTranslation("CMEditViewLocalePicker.locale.create"),
539
+ defaultMessage: "Create <bold>{locale}</bold> locale"
540
+ },
541
+ {
542
+ bold: (locale2) => /* @__PURE__ */ jsxRuntime.jsx("b", { children: locale2 }),
543
+ locale: locale.name
544
+ }
545
+ );
546
+ }
547
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", gap: 1, justifyContent: "space-between", children: [
548
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: locale.name }),
549
+ isDraftAndPublishEnabled ? /* @__PURE__ */ jsxRuntime.jsx(
550
+ designSystem.Status,
551
+ {
552
+ display: "flex",
553
+ paddingLeft: "6px",
554
+ paddingRight: "6px",
555
+ paddingTop: "2px",
556
+ paddingBottom: "2px",
557
+ size: "S",
558
+ variant: statusVariants[status],
559
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
560
+ }
561
+ ) : null
562
+ ] });
563
+ };
438
564
  const LocalePickerAction = ({
439
565
  document,
440
566
  meta,
@@ -446,7 +572,13 @@ const LocalePickerAction = ({
446
572
  const [{ query: query2 }, setQuery] = strapiAdmin.useQueryParams();
447
573
  const { hasI18n, canCreate, canRead } = useI18n();
448
574
  const { data: locales = [] } = useGetLocalesQuery();
449
- const { schema } = strapiAdmin$1.unstable_useDocument({ model, collectionType, documentId });
575
+ const currentDesiredLocale = query2.plugins?.i18n?.locale;
576
+ const { schema } = strapiAdmin$1.unstable_useDocument({
577
+ model,
578
+ collectionType,
579
+ documentId,
580
+ params: { locale: currentDesiredLocale }
581
+ });
450
582
  const handleSelect = React__namespace.useCallback(
451
583
  (value) => {
452
584
  setQuery({
@@ -464,53 +596,50 @@ const LocalePickerAction = ({
464
596
  if (!Array.isArray(locales) || !hasI18n) {
465
597
  return;
466
598
  }
467
- const currentDesiredLocale = query2.plugins?.i18n?.locale;
468
599
  const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
469
600
  const defaultLocale = locales.find((locale) => locale.isDefault);
470
601
  if (!doesLocaleExist && defaultLocale?.code) {
471
602
  handleSelect(defaultLocale.code);
472
603
  }
473
- }, [handleSelect, hasI18n, locales, query2.plugins?.i18n?.locale]);
604
+ }, [handleSelect, hasI18n, locales, currentDesiredLocale]);
605
+ const currentLocale = Array.isArray(locales) ? locales.find((locale) => locale.code === currentDesiredLocale) : void 0;
606
+ const allCurrentLocales = [
607
+ { status: getDocumentStatus(document, meta), locale: currentLocale?.code },
608
+ ...document?.localizations ?? []
609
+ ];
474
610
  if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
475
611
  return null;
476
612
  }
477
- const currentLocale = query2.plugins?.i18n?.locale || locales.find((loc) => loc.isDefault)?.code;
478
- const allCurrentLocales = [
479
- { status: getDocumentStatus(document, meta), locale: currentLocale },
480
- ...meta?.availableLocales ?? []
481
- ];
613
+ const displayedLocales = locales.filter((locale) => {
614
+ return canRead.includes(locale.code);
615
+ });
482
616
  return {
483
617
  label: formatMessage({
484
618
  id: getTranslation("Settings.locales.modal.locales.label"),
485
619
  defaultMessage: "Locales"
486
620
  }),
487
- options: locales.map((locale) => {
621
+ options: displayedLocales.map((locale) => {
622
+ const entryWithLocaleExists = allCurrentLocales.some((doc) => doc.locale === locale.code);
488
623
  const currentLocaleDoc = allCurrentLocales.find(
489
624
  (doc) => "locale" in doc ? doc.locale === locale.code : false
490
625
  );
491
- const status = currentLocaleDoc?.status ?? "draft";
492
- const permissionsToCheck = currentLocaleDoc ? canCreate : canRead;
493
- const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
626
+ const permissionsToCheck = currentLocaleDoc ? canRead : canCreate;
494
627
  return {
495
628
  disabled: !permissionsToCheck.includes(locale.code),
496
629
  value: locale.code,
497
- label: locale.name,
498
- startIcon: schema?.options?.draftAndPublish ? /* @__PURE__ */ jsxRuntime.jsx(
499
- designSystem.Status,
630
+ label: /* @__PURE__ */ jsxRuntime.jsx(
631
+ LocaleOption,
500
632
  {
501
- display: "flex",
502
- paddingLeft: "6px",
503
- paddingRight: "6px",
504
- paddingTop: "2px",
505
- paddingBottom: "2px",
506
- showBullet: false,
507
- size: "S",
508
- variant: statusVariant,
509
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
633
+ isDraftAndPublishEnabled: !!schema?.options?.draftAndPublish,
634
+ locale,
635
+ status: currentLocaleDoc?.status,
636
+ entryExists: entryWithLocaleExists
510
637
  }
511
- ) : null
638
+ ),
639
+ startIcon: !entryWithLocaleExists ? /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}) : null
512
640
  };
513
641
  }),
642
+ customizeContent: () => currentLocale?.name,
514
643
  onSelect: handleSelect,
515
644
  value: currentLocale
516
645
  };
@@ -526,6 +655,99 @@ const getDocumentStatus = (document, meta) => {
526
655
  }
527
656
  return docStatus;
528
657
  };
658
+ const FillFromAnotherLocaleAction = ({
659
+ documentId,
660
+ meta,
661
+ model,
662
+ collectionType
663
+ }) => {
664
+ const { formatMessage } = reactIntl.useIntl();
665
+ const [{ query: query2 }] = strapiAdmin.useQueryParams();
666
+ const { hasI18n } = useI18n();
667
+ const currentDesiredLocale = query2.plugins?.i18n?.locale;
668
+ const [localeSelected, setLocaleSelected] = React__namespace.useState(null);
669
+ const setValues = strapiAdmin.useForm("FillFromAnotherLocale", (state) => state.setValues);
670
+ const { getDocument } = strapiAdmin$1.unstable_useDocumentActions();
671
+ const { schema, components } = strapiAdmin$1.unstable_useDocument({
672
+ model,
673
+ documentId,
674
+ collectionType,
675
+ params: { locale: currentDesiredLocale }
676
+ });
677
+ const { data: locales = [] } = useGetLocalesQuery();
678
+ const availableLocales = Array.isArray(locales) ? locales.filter((locale) => meta?.availableLocales.some((l) => l.locale === locale.code)) : [];
679
+ const fillFromLocale = (onClose) => async () => {
680
+ const response = await getDocument({
681
+ collectionType,
682
+ model,
683
+ documentId,
684
+ params: { locale: localeSelected }
685
+ });
686
+ if (!response || !schema) {
687
+ return;
688
+ }
689
+ const { data } = response;
690
+ const cleanedData = cleanData(data, schema, components);
691
+ setValues(cleanedData);
692
+ onClose();
693
+ };
694
+ if (!hasI18n) {
695
+ return null;
696
+ }
697
+ return {
698
+ type: "icon",
699
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Download, {}),
700
+ disabled: availableLocales.length === 0,
701
+ label: formatMessage({
702
+ id: getTranslation("CMEditViewCopyLocale.copy-text"),
703
+ defaultMessage: "Fill in from another locale"
704
+ }),
705
+ dialog: {
706
+ type: "dialog",
707
+ title: formatMessage({
708
+ id: getTranslation("CMEditViewCopyLocale.dialog.title"),
709
+ defaultMessage: "Confirmation"
710
+ }),
711
+ content: ({ onClose }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
712
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, children: [
713
+ /* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
714
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textAlign: "center", children: formatMessage({
715
+ id: getTranslation("CMEditViewCopyLocale.dialog.body"),
716
+ defaultMessage: "Your current content will be erased and filled by the content of the selected locale:"
717
+ }) }),
718
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { width: "100%", children: [
719
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
720
+ id: getTranslation("CMEditViewCopyLocale.dialog.field.label"),
721
+ defaultMessage: "Locale"
722
+ }) }),
723
+ /* @__PURE__ */ jsxRuntime.jsx(
724
+ designSystem.SingleSelect,
725
+ {
726
+ value: localeSelected,
727
+ placeholder: formatMessage({
728
+ id: getTranslation("CMEditViewCopyLocale.dialog.field.placeholder"),
729
+ defaultMessage: "Select one locale..."
730
+ }),
731
+ onChange: (value) => setLocaleSelected(value),
732
+ children: availableLocales.map((locale) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: locale.code, children: locale.name }, locale.code))
733
+ }
734
+ )
735
+ ] })
736
+ ] }) }),
737
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, width: "100%", children: [
738
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { flex: "auto", variant: "tertiary", onClick: onClose, children: formatMessage({
739
+ id: getTranslation("CMEditViewCopyLocale.cancel-text"),
740
+ defaultMessage: "No, cancel"
741
+ }) }),
742
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { flex: "auto", variant: "success", onClick: fillFromLocale(onClose), children: formatMessage({
743
+ id: getTranslation("CMEditViewCopyLocale.submit-text"),
744
+ defaultMessage: "Yes, fill in"
745
+ }) })
746
+ ] }) })
747
+ ] })
748
+ }
749
+ };
750
+ };
529
751
  const DeleteLocaleAction = ({
530
752
  document,
531
753
  documentId,
@@ -537,16 +759,23 @@ const DeleteLocaleAction = ({
537
759
  const { toggleNotification } = strapiAdmin.useNotification();
538
760
  const { delete: deleteAction } = strapiAdmin$1.unstable_useDocumentActions();
539
761
  const { hasI18n, canDelete } = useI18n();
762
+ const [{ query: query2 }] = strapiAdmin.useQueryParams();
763
+ const { data: locales = [] } = useGetLocalesQuery();
764
+ const currentDesiredLocale = query2.plugins?.i18n?.locale;
765
+ const locale = !("error" in locales) && locales.find((loc) => loc.code === currentDesiredLocale);
540
766
  if (!hasI18n) {
541
767
  return null;
542
768
  }
543
769
  return {
544
770
  disabled: document?.locale && !canDelete.includes(document.locale) || !document || !document.id,
545
771
  position: ["header", "table-row"],
546
- label: formatMessage({
547
- id: getTranslation("actions.delete.label"),
548
- defaultMessage: "Delete locale"
549
- }),
772
+ label: formatMessage(
773
+ {
774
+ id: getTranslation("actions.delete.label"),
775
+ defaultMessage: "Delete entry ({locale})"
776
+ },
777
+ { locale: locale && locale.name }
778
+ ),
550
779
  icon: /* @__PURE__ */ jsxRuntime.jsx(StyledTrash, {}),
551
780
  variant: "danger",
552
781
  dialog: {
@@ -563,7 +792,12 @@ const DeleteLocaleAction = ({
563
792
  }) })
564
793
  ] }),
565
794
  onConfirm: async () => {
566
- if (!documentId || !document?.locale) {
795
+ const unableToDelete = (
796
+ // We are unable to delete a collection type without a document ID
797
+ // & unable to delete generally if there is no document locale
798
+ collectionType !== "single-types" && !documentId || !document?.locale
799
+ );
800
+ if (unableToDelete) {
567
801
  console.error(
568
802
  "You're trying to delete a document without an id or locale, this is likely a bug with Strapi. Please open an issue."
569
803
  );
@@ -590,13 +824,13 @@ const DeleteLocaleAction = ({
590
824
  };
591
825
  };
592
826
  const BulkLocaleAction = ({
593
- document: baseDocument,
827
+ document,
594
828
  documentId,
595
829
  model,
596
830
  collectionType,
597
831
  action
598
832
  }) => {
599
- const baseLocale = baseDocument?.locale ?? null;
833
+ const locale = document?.locale ?? null;
600
834
  const [{ query: query$1 }] = strapiAdmin.useQueryParams();
601
835
  const params = React__namespace.useMemo(() => strapiAdmin$1.buildValidParams(query$1), [query$1]);
602
836
  const isOnPublishedTab = query$1.status === "published";
@@ -607,22 +841,18 @@ const BulkLocaleAction = ({
607
841
  const [selectedRows, setSelectedRows] = React__namespace.useState([]);
608
842
  const [isDraftRelationConfirmationOpen, setIsDraftRelationConfirmationOpen] = React__namespace.useState(false);
609
843
  const { publishMany: publishManyAction, unpublishMany: unpublishManyAction } = strapiAdmin$1.unstable_useDocumentActions();
610
- const {
611
- document,
612
- meta: documentMeta,
613
- schema,
614
- validate
615
- } = strapiAdmin$1.unstable_useDocument(
844
+ const { schema, validate } = strapiAdmin$1.unstable_useDocument(
616
845
  {
617
846
  model,
618
847
  collectionType,
619
848
  documentId,
620
849
  params: {
621
- locale: baseLocale
850
+ locale
622
851
  }
623
852
  },
624
853
  {
625
- skip: !hasI18n
854
+ // No need to fetch the document, the data is already available in the `document` prop
855
+ skip: true
626
856
  }
627
857
  );
628
858
  const { data: localesMetadata = [] } = useGetLocalesQuery(hasI18n ? void 0 : query.skipToken);
@@ -650,18 +880,19 @@ const BulkLocaleAction = ({
650
880
  }
651
881
  ];
652
882
  const [rows, validationErrors] = React__namespace.useMemo(() => {
653
- if (!document || !documentMeta?.availableLocales) {
883
+ if (!document) {
654
884
  return [[], {}];
655
885
  }
656
- const rowsFromMeta = documentMeta?.availableLocales.map((doc) => {
657
- const { locale, status } = doc;
658
- return { locale, status };
886
+ const localizations = document.localizations ?? [];
887
+ const locales = localizations.map((doc) => {
888
+ const { locale: locale2, status } = doc;
889
+ return { locale: locale2, status };
659
890
  });
660
- rowsFromMeta.unshift({
891
+ locales.unshift({
661
892
  locale: document.locale,
662
893
  status: document.status
663
894
  });
664
- const allDocuments = [document, ...documentMeta?.availableLocales ?? []];
895
+ const allDocuments = [document, ...localizations];
665
896
  const errors = allDocuments.reduce((errs, document2) => {
666
897
  if (!document2) {
667
898
  return errs;
@@ -672,8 +903,8 @@ const BulkLocaleAction = ({
672
903
  }
673
904
  return errs;
674
905
  }, {});
675
- return [rowsFromMeta, errors];
676
- }, [document, documentMeta?.availableLocales, validate]);
906
+ return [locales, errors];
907
+ }, [document, validate]);
677
908
  const isBulkPublish = action === "bulk-publish";
678
909
  const localesForAction = selectedRows.reduce((acc, selectedRow) => {
679
910
  const isValidLocale = (
@@ -783,7 +1014,7 @@ const BulkLocaleAction = ({
783
1014
  }
784
1015
  };
785
1016
  }
786
- const hasPermission = selectedRows.map(({ locale }) => locale).every((locale) => canPublish.includes(locale));
1017
+ const hasPermission = selectedRows.map(({ locale: locale2 }) => locale2).every((locale2) => canPublish.includes(locale2));
787
1018
  return {
788
1019
  label: formatMessage({
789
1020
  id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? "publish" : "unpublish"}-title`),
@@ -1026,29 +1257,16 @@ const Span = styledComponents.styled(designSystem.Flex)`
1026
1257
  }
1027
1258
  }
1028
1259
  `;
1029
- const LocaleListCell = ({
1030
- documentId,
1031
- locale: currentLocale,
1032
- collectionType,
1033
- model
1034
- }) => {
1035
- const { meta, isLoading } = strapiAdmin$1.unstable_useDocument({
1036
- documentId,
1037
- collectionType,
1038
- model,
1039
- params: {
1040
- locale: currentLocale
1041
- }
1042
- });
1260
+ const LocaleListCell = ({ locale: currentLocale, localizations }) => {
1043
1261
  const { locale: language } = reactIntl.useIntl();
1044
1262
  const { data: locales = [] } = useGetLocalesQuery();
1045
1263
  const formatter = designSystem.useCollator(language, {
1046
1264
  sensitivity: "base"
1047
1265
  });
1048
- if (!Array.isArray(locales) || isLoading) {
1266
+ if (!Array.isArray(locales) || !localizations) {
1049
1267
  return null;
1050
1268
  }
1051
- const availableLocales = meta?.availableLocales.map((doc) => doc.locale) ?? [];
1269
+ const availableLocales = localizations.map((loc) => loc.locale);
1052
1270
  const localesForDocument = locales.reduce((acc, locale) => {
1053
1271
  const createdLocale = [currentLocale, ...availableLocales].find((loc) => {
1054
1272
  return loc === locale.code;
@@ -1196,9 +1414,6 @@ const localeMiddleware = (ctx) => (next) => (permissions) => {
1196
1414
  return next(revisedPermissions);
1197
1415
  };
1198
1416
  const prefixPluginTranslations = (trad, pluginId2) => {
1199
- if (!pluginId2) {
1200
- throw new TypeError("pluginId can't be empty");
1201
- }
1202
1417
  return Object.keys(trad).reduce((acc, current) => {
1203
1418
  acc[`${pluginId2}.${current}`] = trad[current];
1204
1419
  return acc;
@@ -1268,11 +1483,11 @@ const index = {
1268
1483
  },
1269
1484
  id: "internationalization",
1270
1485
  to: "internationalization",
1271
- Component: () => Promise.resolve().then(() => require("./SettingsPage-C-1h_H38.js")).then((mod) => ({ default: mod.ProtectedSettingsPage })),
1486
+ Component: () => Promise.resolve().then(() => require("./SettingsPage-BsHtr3lV.js")).then((mod) => ({ default: mod.ProtectedSettingsPage })),
1272
1487
  permissions: PERMISSIONS.accessMain
1273
1488
  });
1274
1489
  const contentManager = app.getPlugin("content-manager");
1275
- contentManager.apis.addDocumentHeaderAction([LocalePickerAction]);
1490
+ contentManager.apis.addDocumentHeaderAction([LocalePickerAction, FillFromAnotherLocaleAction]);
1276
1491
  contentManager.apis.addDocumentAction((actions) => {
1277
1492
  const indexOfDeleteAction = actions.findIndex((action) => action.type === "delete");
1278
1493
  actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);
@@ -1386,7 +1601,7 @@ const index = {
1386
1601
  async registerTrads({ locales }) {
1387
1602
  const importedTrads = await Promise.all(
1388
1603
  locales.map((locale) => {
1389
- 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-CwI88-PP.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 }) => {
1604
+ 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-BKBz3tro.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`, 3).then(({ default: data }) => {
1390
1605
  return {
1391
1606
  data: prefixPluginTranslations(data, pluginId),
1392
1607
  locale
@@ -1410,4 +1625,4 @@ exports.useDeleteLocaleMutation = useDeleteLocaleMutation;
1410
1625
  exports.useGetDefaultLocalesQuery = useGetDefaultLocalesQuery;
1411
1626
  exports.useGetLocalesQuery = useGetLocalesQuery;
1412
1627
  exports.useUpdateLocaleMutation = useUpdateLocaleMutation;
1413
- //# sourceMappingURL=index-jpk39Rxo.js.map
1628
+ //# sourceMappingURL=index-3XgwXL6T.js.map