@strapi/i18n 0.0.0-experimental.7afdc9b682bc83a53ce599c4fb7c9e4506b31fff → 0.0.0-experimental.7b750d18de359d0a42233cb8707e3c31c5983345
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-DNucKxbi.mjs → SettingsPage-BIZrSFGY.mjs} +93 -106
- package/dist/_chunks/SettingsPage-BIZrSFGY.mjs.map +1 -0
- package/dist/_chunks/{SettingsPage-CG_qq0Tx.js → SettingsPage-kMDCxWLw.js} +91 -104
- package/dist/_chunks/SettingsPage-kMDCxWLw.js.map +1 -0
- package/dist/_chunks/{en-Kv6y9zPQ.js → en-B6327hMz.js} +10 -2
- package/dist/_chunks/en-B6327hMz.js.map +1 -0
- package/dist/_chunks/{en-18tWw4P6.mjs → en-DZXpOMHo.mjs} +10 -2
- package/dist/_chunks/en-DZXpOMHo.mjs.map +1 -0
- package/dist/_chunks/{index-BYDzOiHE.mjs → index-DXrgAtCA.mjs} +381 -191
- package/dist/_chunks/index-DXrgAtCA.mjs.map +1 -0
- package/dist/_chunks/{index-DWAqdQ--.js → index-Dncj9Inq.js} +387 -197
- package/dist/_chunks/index-Dncj9Inq.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 +27 -3
- package/dist/admin/src/components/EditLocale.d.ts +5 -4
- 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 +63 -98
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +64 -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-CG_qq0Tx.js.map +0 -1
- package/dist/_chunks/SettingsPage-DNucKxbi.mjs.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-BYDzOiHE.mjs.map +0 -1
- package/dist/_chunks/index-DWAqdQ--.js.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,93 @@ 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
|
+
]);
|
257
|
+
const cleanedDataWithoutPasswordAndRelation = recursiveRemoveFieldTypes(
|
258
|
+
cleanedData,
|
259
|
+
schema,
|
260
|
+
components,
|
261
|
+
["relation", "password"]
|
262
|
+
);
|
263
|
+
return cleanedDataWithoutPasswordAndRelation;
|
264
|
+
};
|
265
|
+
const removeFields = (data, fields) => {
|
266
|
+
return Object.keys(data).reduce((acc, current) => {
|
267
|
+
if (fields.includes(current)) {
|
268
|
+
return acc;
|
269
|
+
}
|
270
|
+
acc[current] = data[current];
|
271
|
+
return acc;
|
272
|
+
}, {});
|
273
|
+
};
|
274
|
+
const recursiveRemoveFieldTypes = (data, schema, components, fields) => {
|
275
|
+
return Object.keys(data).reduce((acc, current) => {
|
276
|
+
const attribute = schema.attributes[current] ?? { type: void 0 };
|
277
|
+
if (fields.includes(attribute.type)) {
|
278
|
+
return acc;
|
279
|
+
}
|
280
|
+
if (attribute.type === "dynamiczone") {
|
281
|
+
acc[current] = data[current].map((componentValue, index2) => {
|
282
|
+
const { id: _, ...rest } = recursiveRemoveFieldTypes(
|
283
|
+
componentValue,
|
284
|
+
components[componentValue.__component],
|
285
|
+
components,
|
286
|
+
fields
|
287
|
+
);
|
288
|
+
return {
|
289
|
+
...rest,
|
290
|
+
__temp_key__: index2 + 1
|
291
|
+
};
|
292
|
+
});
|
293
|
+
} else if (attribute.type === "component") {
|
294
|
+
const { repeatable, component } = attribute;
|
295
|
+
if (repeatable) {
|
296
|
+
acc[current] = (data[current] ?? []).map((compoData, index2) => {
|
297
|
+
const { id: _, ...rest } = recursiveRemoveFieldTypes(
|
298
|
+
compoData,
|
299
|
+
components[component],
|
300
|
+
components,
|
301
|
+
fields
|
302
|
+
);
|
303
|
+
return {
|
304
|
+
...rest,
|
305
|
+
__temp_key__: index2 + 1
|
306
|
+
};
|
307
|
+
});
|
308
|
+
} else {
|
309
|
+
const { id: _, ...rest } = recursiveRemoveFieldTypes(
|
310
|
+
data[current] ?? {},
|
311
|
+
components[component],
|
312
|
+
components,
|
313
|
+
fields
|
314
|
+
);
|
315
|
+
acc[current] = rest;
|
316
|
+
}
|
317
|
+
} else {
|
318
|
+
acc[current] = data[current];
|
319
|
+
}
|
320
|
+
return acc;
|
321
|
+
}, {});
|
322
|
+
};
|
244
323
|
const isErrorMessageDescriptor = (object) => {
|
245
324
|
return typeof object === "object" && object !== null && "id" in object && "defaultMessage" in object;
|
246
325
|
};
|
247
|
-
const EntryValidationText = ({
|
326
|
+
const EntryValidationText = ({
|
327
|
+
status = "draft",
|
328
|
+
validationErrors,
|
329
|
+
action
|
330
|
+
}) => {
|
248
331
|
const { formatMessage } = reactIntl.useIntl();
|
249
332
|
const getErrorStr = (key, value) => {
|
250
333
|
if (typeof value === "string") {
|
@@ -278,30 +361,63 @@ const EntryValidationText = ({ status = "draft", validationErrors }) => {
|
|
278
361
|
) })
|
279
362
|
] });
|
280
363
|
}
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
364
|
+
const getStatusMessage = () => {
|
365
|
+
if (action === "bulk-publish") {
|
366
|
+
if (status === "published") {
|
367
|
+
return {
|
368
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
369
|
+
text: formatMessage({
|
370
|
+
id: "content-manager.bulk-publish.already-published",
|
371
|
+
defaultMessage: "Already Published"
|
372
|
+
}),
|
373
|
+
textColor: "success600",
|
374
|
+
fontWeight: "bold"
|
375
|
+
};
|
376
|
+
} else if (status === "modified") {
|
377
|
+
return {
|
378
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowsCounterClockwise, { fill: "alternative600" }),
|
379
|
+
text: formatMessage({
|
380
|
+
id: "app.utils.ready-to-publish-changes",
|
381
|
+
defaultMessage: "Ready to publish changes"
|
382
|
+
})
|
383
|
+
};
|
384
|
+
} else {
|
385
|
+
return {
|
386
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
387
|
+
text: formatMessage({
|
388
|
+
id: "app.utils.ready-to-publish",
|
389
|
+
defaultMessage: "Ready to publish"
|
390
|
+
})
|
391
|
+
};
|
392
|
+
}
|
393
|
+
} else {
|
394
|
+
if (status === "draft") {
|
395
|
+
return {
|
396
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
397
|
+
text: formatMessage({
|
398
|
+
id: "content-manager.bulk-unpublish.already-unpublished",
|
399
|
+
defaultMessage: "Already Unpublished"
|
400
|
+
}),
|
401
|
+
textColor: "success600",
|
402
|
+
fontWeight: "bold"
|
403
|
+
};
|
404
|
+
} else {
|
405
|
+
return {
|
406
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
407
|
+
text: formatMessage({
|
408
|
+
id: "app.utils.ready-to-unpublish-changes",
|
409
|
+
defaultMessage: "Ready to unpublish"
|
410
|
+
}),
|
411
|
+
textColor: "success600",
|
412
|
+
fontWeight: "bold"
|
413
|
+
};
|
414
|
+
}
|
415
|
+
}
|
416
|
+
};
|
417
|
+
const { icon, text, textColor = "success600", fontWeight = "normal" } = getStatusMessage();
|
299
418
|
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
|
-
}) })
|
419
|
+
icon,
|
420
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor, fontWeight, children: text })
|
305
421
|
] });
|
306
422
|
};
|
307
423
|
const BoldChunk = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
|
@@ -309,7 +425,8 @@ const BulkLocaleActionModal = ({
|
|
309
425
|
headers,
|
310
426
|
rows,
|
311
427
|
localesMetadata,
|
312
|
-
validationErrors = {}
|
428
|
+
validationErrors = {},
|
429
|
+
action
|
313
430
|
}) => {
|
314
431
|
const { formatMessage } = reactIntl.useIntl();
|
315
432
|
const selectedRows = strapiAdmin.useTable(
|
@@ -322,27 +439,29 @@ const BulkLocaleActionModal = ({
|
|
322
439
|
return acc;
|
323
440
|
}, {});
|
324
441
|
const localesWithErrors = Object.keys(validationErrors);
|
325
|
-
const
|
442
|
+
const publishedCount = selectedRows.filter(
|
326
443
|
({ locale }) => currentStatusByLocale[locale] === "published"
|
327
444
|
).length;
|
328
|
-
const
|
445
|
+
const draftCount = selectedRows.filter(
|
329
446
|
({ locale }) => (currentStatusByLocale[locale] === "draft" || currentStatusByLocale[locale] === "modified") && !localesWithErrors.includes(locale)
|
330
447
|
).length;
|
331
448
|
const withErrorsCount = localesWithErrors.length;
|
449
|
+
const messageId = action === "bulk-publish" ? "content-manager.containers.list.selectedEntriesModal.selectedCount.publish" : "content-manager.containers.list.selectedEntriesModal.selectedCount.unpublish";
|
450
|
+
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
451
|
return formatMessage(
|
333
452
|
{
|
334
|
-
id:
|
335
|
-
defaultMessage
|
453
|
+
id: messageId,
|
454
|
+
defaultMessage
|
336
455
|
},
|
337
456
|
{
|
338
457
|
withErrorsCount,
|
339
|
-
|
340
|
-
|
458
|
+
draftCount,
|
459
|
+
publishedCount,
|
341
460
|
b: BoldChunk
|
342
461
|
}
|
343
462
|
);
|
344
463
|
};
|
345
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
464
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Body, { children: [
|
346
465
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: getFormattedCountMessage() }),
|
347
466
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Content, { children: [
|
348
467
|
/* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Head, { children: [
|
@@ -369,7 +488,7 @@ const BulkLocaleActionModal = ({
|
|
369
488
|
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
370
489
|
}
|
371
490
|
) }) }),
|
372
|
-
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(EntryValidationText, { validationErrors: error, status }) }),
|
491
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(EntryValidationText, { validationErrors: error, status, action }) }),
|
373
492
|
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
374
493
|
designSystem.IconButton,
|
375
494
|
{
|
@@ -386,7 +505,7 @@ const BulkLocaleActionModal = ({
|
|
386
505
|
name: locale
|
387
506
|
}
|
388
507
|
),
|
389
|
-
|
508
|
+
variant: "ghost",
|
390
509
|
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {})
|
391
510
|
}
|
392
511
|
) })
|
@@ -403,42 +522,47 @@ const LocalePickerAction = ({
|
|
403
522
|
documentId
|
404
523
|
}) => {
|
405
524
|
const { formatMessage } = reactIntl.useIntl();
|
406
|
-
const [{ query }, setQuery] = strapiAdmin.useQueryParams();
|
525
|
+
const [{ query: query2 }, setQuery] = strapiAdmin.useQueryParams();
|
407
526
|
const { hasI18n, canCreate, canRead } = useI18n();
|
408
527
|
const { data: locales = [] } = useGetLocalesQuery();
|
409
|
-
const
|
528
|
+
const currentDesiredLocale = query2.plugins?.i18n?.locale;
|
529
|
+
const { schema } = strapiAdmin$1.unstable_useDocument({
|
530
|
+
model,
|
531
|
+
collectionType,
|
532
|
+
documentId,
|
533
|
+
params: { locale: currentDesiredLocale }
|
534
|
+
});
|
410
535
|
const handleSelect = React__namespace.useCallback(
|
411
536
|
(value) => {
|
412
537
|
setQuery({
|
413
538
|
plugins: {
|
414
|
-
...
|
539
|
+
...query2.plugins,
|
415
540
|
i18n: {
|
416
541
|
locale: value
|
417
542
|
}
|
418
543
|
}
|
419
544
|
});
|
420
545
|
},
|
421
|
-
[
|
546
|
+
[query2.plugins, setQuery]
|
422
547
|
);
|
423
548
|
React__namespace.useEffect(() => {
|
424
549
|
if (!Array.isArray(locales) || !hasI18n) {
|
425
550
|
return;
|
426
551
|
}
|
427
|
-
const currentDesiredLocale = query.plugins?.i18n?.locale;
|
428
552
|
const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
|
429
553
|
const defaultLocale = locales.find((locale) => locale.isDefault);
|
430
554
|
if (!doesLocaleExist && defaultLocale?.code) {
|
431
555
|
handleSelect(defaultLocale.code);
|
432
556
|
}
|
433
|
-
}, [handleSelect, hasI18n, locales,
|
434
|
-
|
435
|
-
return null;
|
436
|
-
}
|
437
|
-
const currentLocale = query.plugins?.i18n?.locale || locales.find((loc) => loc.isDefault)?.code;
|
557
|
+
}, [handleSelect, hasI18n, locales, currentDesiredLocale]);
|
558
|
+
const currentLocale = Array.isArray(locales) ? locales.find((locale) => locale.code === currentDesiredLocale)?.code : void 0;
|
438
559
|
const allCurrentLocales = [
|
439
560
|
{ status: getDocumentStatus(document, meta), locale: currentLocale },
|
440
561
|
...meta?.availableLocales ?? []
|
441
562
|
];
|
563
|
+
if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
|
564
|
+
return null;
|
565
|
+
}
|
442
566
|
return {
|
443
567
|
label: formatMessage({
|
444
568
|
id: getTranslation("Settings.locales.modal.locales.label"),
|
@@ -450,7 +574,7 @@ const LocalePickerAction = ({
|
|
450
574
|
);
|
451
575
|
const status = currentLocaleDoc?.status ?? "draft";
|
452
576
|
const permissionsToCheck = currentLocaleDoc ? canCreate : canRead;
|
453
|
-
const statusVariant = status === "draft" ? "
|
577
|
+
const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
|
454
578
|
return {
|
455
579
|
disabled: !permissionsToCheck.includes(locale.code),
|
456
580
|
value: locale.code,
|
@@ -486,6 +610,95 @@ const getDocumentStatus = (document, meta) => {
|
|
486
610
|
}
|
487
611
|
return docStatus;
|
488
612
|
};
|
613
|
+
const FillFromAnotherLocaleAction = ({
|
614
|
+
documentId,
|
615
|
+
meta,
|
616
|
+
model,
|
617
|
+
collectionType
|
618
|
+
}) => {
|
619
|
+
const { formatMessage } = reactIntl.useIntl();
|
620
|
+
const [{ query: query2 }] = strapiAdmin.useQueryParams();
|
621
|
+
const currentDesiredLocale = query2.plugins?.i18n?.locale;
|
622
|
+
const [localeSelected, setLocaleSelected] = React__namespace.useState(null);
|
623
|
+
const setValues = strapiAdmin.useForm("FillFromAnotherLocale", (state) => state.setValues);
|
624
|
+
const { getDocument } = strapiAdmin$1.unstable_useDocumentActions();
|
625
|
+
const { schema, components } = strapiAdmin$1.unstable_useDocument({
|
626
|
+
model,
|
627
|
+
documentId,
|
628
|
+
collectionType,
|
629
|
+
params: { locale: currentDesiredLocale }
|
630
|
+
});
|
631
|
+
const { data: locales = [] } = useGetLocalesQuery();
|
632
|
+
const availableLocales = Array.isArray(locales) ? locales.filter((locale) => meta?.availableLocales.some((l) => l.locale === locale.code)) : [];
|
633
|
+
const fillFromLocale = (onClose) => async () => {
|
634
|
+
const response = await getDocument({
|
635
|
+
collectionType,
|
636
|
+
model,
|
637
|
+
documentId,
|
638
|
+
params: { locale: localeSelected }
|
639
|
+
});
|
640
|
+
if (!response || !schema) {
|
641
|
+
return;
|
642
|
+
}
|
643
|
+
const { data } = response;
|
644
|
+
const cleanedData = cleanData(data, schema, components);
|
645
|
+
setValues(cleanedData);
|
646
|
+
onClose();
|
647
|
+
};
|
648
|
+
return {
|
649
|
+
type: "icon",
|
650
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Download, {}),
|
651
|
+
disabled: availableLocales.length === 0,
|
652
|
+
label: formatMessage({
|
653
|
+
id: getTranslation("CMEditViewCopyLocale.copy-text"),
|
654
|
+
defaultMessage: "Fill in from another locale"
|
655
|
+
}),
|
656
|
+
dialog: {
|
657
|
+
type: "dialog",
|
658
|
+
title: formatMessage({
|
659
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.title"),
|
660
|
+
defaultMessage: "Confirmation"
|
661
|
+
}),
|
662
|
+
content: ({ onClose }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
663
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, children: [
|
664
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
665
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textAlign: "center", children: formatMessage({
|
666
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.body"),
|
667
|
+
defaultMessage: "Your current content will be erased and filled by the content of the selected locale:"
|
668
|
+
}) }),
|
669
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { width: "100%", children: [
|
670
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
|
671
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.field.label"),
|
672
|
+
defaultMessage: "Locale"
|
673
|
+
}) }),
|
674
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
675
|
+
designSystem.SingleSelect,
|
676
|
+
{
|
677
|
+
value: localeSelected,
|
678
|
+
placeholder: formatMessage({
|
679
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.field.placeholder"),
|
680
|
+
defaultMessage: "Select one locale..."
|
681
|
+
}),
|
682
|
+
onChange: (value) => setLocaleSelected(value),
|
683
|
+
children: availableLocales.map((locale) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: locale.code, children: locale.name }, locale.code))
|
684
|
+
}
|
685
|
+
)
|
686
|
+
] })
|
687
|
+
] }) }),
|
688
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, width: "100%", children: [
|
689
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { flex: "auto", variant: "tertiary", onClick: onClose, children: formatMessage({
|
690
|
+
id: getTranslation("CMEditViewCopyLocale.cancel-text"),
|
691
|
+
defaultMessage: "No, cancel"
|
692
|
+
}) }),
|
693
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { flex: "auto", variant: "success", onClick: fillFromLocale(onClose), children: formatMessage({
|
694
|
+
id: getTranslation("CMEditViewCopyLocale.submit-text"),
|
695
|
+
defaultMessage: "Yes, fill in"
|
696
|
+
}) })
|
697
|
+
] }) })
|
698
|
+
] })
|
699
|
+
}
|
700
|
+
};
|
701
|
+
};
|
489
702
|
const DeleteLocaleAction = ({
|
490
703
|
document,
|
491
704
|
documentId,
|
@@ -497,16 +710,23 @@ const DeleteLocaleAction = ({
|
|
497
710
|
const { toggleNotification } = strapiAdmin.useNotification();
|
498
711
|
const { delete: deleteAction } = strapiAdmin$1.unstable_useDocumentActions();
|
499
712
|
const { hasI18n, canDelete } = useI18n();
|
713
|
+
const [{ query: query2 }] = strapiAdmin.useQueryParams();
|
714
|
+
const { data: locales = [] } = useGetLocalesQuery();
|
715
|
+
const currentDesiredLocale = query2.plugins?.i18n?.locale;
|
716
|
+
const locale = !("error" in locales) && locales.find((loc) => loc.code === currentDesiredLocale);
|
500
717
|
if (!hasI18n) {
|
501
718
|
return null;
|
502
719
|
}
|
503
720
|
return {
|
504
721
|
disabled: document?.locale && !canDelete.includes(document.locale) || !document || !document.id,
|
505
722
|
position: ["header", "table-row"],
|
506
|
-
label: formatMessage(
|
507
|
-
|
508
|
-
|
509
|
-
|
723
|
+
label: formatMessage(
|
724
|
+
{
|
725
|
+
id: getTranslation("actions.delete.label"),
|
726
|
+
defaultMessage: "Delete entry ({locale})"
|
727
|
+
},
|
728
|
+
{ locale: locale && locale.name }
|
729
|
+
),
|
510
730
|
icon: /* @__PURE__ */ jsxRuntime.jsx(StyledTrash, {}),
|
511
731
|
variant: "danger",
|
512
732
|
dialog: {
|
@@ -549,37 +769,43 @@ const DeleteLocaleAction = ({
|
|
549
769
|
}
|
550
770
|
};
|
551
771
|
};
|
552
|
-
const
|
772
|
+
const BulkLocaleAction = ({
|
553
773
|
document: baseDocument,
|
554
774
|
documentId,
|
555
775
|
model,
|
556
|
-
collectionType
|
776
|
+
collectionType,
|
777
|
+
action
|
557
778
|
}) => {
|
558
779
|
const baseLocale = baseDocument?.locale ?? null;
|
559
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
560
|
-
const params = React__namespace.useMemo(() => strapiAdmin$1.buildValidParams(query), [query]);
|
561
|
-
const
|
780
|
+
const [{ query: query$1 }] = strapiAdmin.useQueryParams();
|
781
|
+
const params = React__namespace.useMemo(() => strapiAdmin$1.buildValidParams(query$1), [query$1]);
|
782
|
+
const isOnPublishedTab = query$1.status === "published";
|
562
783
|
const { formatMessage } = reactIntl.useIntl();
|
563
784
|
const { hasI18n, canPublish } = useI18n();
|
564
785
|
const { toggleNotification } = strapiAdmin.useNotification();
|
565
786
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
566
787
|
const [selectedRows, setSelectedRows] = React__namespace.useState([]);
|
567
|
-
const [
|
568
|
-
const { publishMany: publishManyAction } = strapiAdmin$1.unstable_useDocumentActions();
|
788
|
+
const [isDraftRelationConfirmationOpen, setIsDraftRelationConfirmationOpen] = React__namespace.useState(false);
|
789
|
+
const { publishMany: publishManyAction, unpublishMany: unpublishManyAction } = strapiAdmin$1.unstable_useDocumentActions();
|
569
790
|
const {
|
570
791
|
document,
|
571
792
|
meta: documentMeta,
|
572
793
|
schema,
|
573
794
|
validate
|
574
|
-
} = strapiAdmin$1.unstable_useDocument(
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
795
|
+
} = strapiAdmin$1.unstable_useDocument(
|
796
|
+
{
|
797
|
+
model,
|
798
|
+
collectionType,
|
799
|
+
documentId,
|
800
|
+
params: {
|
801
|
+
locale: baseLocale
|
802
|
+
}
|
803
|
+
},
|
804
|
+
{
|
805
|
+
skip: !hasI18n || !baseLocale
|
580
806
|
}
|
581
|
-
|
582
|
-
const { data: localesMetadata = [] } = useGetLocalesQuery();
|
807
|
+
);
|
808
|
+
const { data: localesMetadata = [] } = useGetLocalesQuery(hasI18n ? void 0 : query.skipToken);
|
583
809
|
const headers = [
|
584
810
|
{
|
585
811
|
label: formatMessage({
|
@@ -628,12 +854,19 @@ const BulkLocalePublishAction = ({
|
|
628
854
|
}, {});
|
629
855
|
return [rowsFromMeta, errors];
|
630
856
|
}, [document, documentMeta?.availableLocales, validate]);
|
631
|
-
const
|
632
|
-
|
857
|
+
const isBulkPublish = action === "bulk-publish";
|
858
|
+
const localesForAction = selectedRows.reduce((acc, selectedRow) => {
|
859
|
+
const isValidLocale = (
|
860
|
+
// Validation errors are irrelevant if we are trying to unpublish
|
861
|
+
!isBulkPublish || !Object.keys(validationErrors).includes(selectedRow.locale)
|
862
|
+
);
|
863
|
+
const shouldAddLocale = isBulkPublish ? selectedRow.status !== "published" && isValidLocale : selectedRow.status !== "draft" && isValidLocale;
|
864
|
+
if (shouldAddLocale) {
|
633
865
|
acc.push(selectedRow.locale);
|
634
866
|
}
|
635
867
|
return acc;
|
636
868
|
}, []);
|
869
|
+
const enableDraftRelationsCount = false;
|
637
870
|
const {
|
638
871
|
data: draftRelationsCount = 0,
|
639
872
|
isLoading: isDraftRelationsLoading,
|
@@ -642,10 +875,10 @@ const BulkLocalePublishAction = ({
|
|
642
875
|
{
|
643
876
|
model,
|
644
877
|
documentIds: [documentId],
|
645
|
-
locale:
|
878
|
+
locale: localesForAction
|
646
879
|
},
|
647
880
|
{
|
648
|
-
skip: !
|
881
|
+
skip: !enableDraftRelationsCount
|
649
882
|
}
|
650
883
|
);
|
651
884
|
React__namespace.useEffect(() => {
|
@@ -671,23 +904,32 @@ const BulkLocalePublishAction = ({
|
|
671
904
|
documentIds: [documentId],
|
672
905
|
params: {
|
673
906
|
...params,
|
674
|
-
locale:
|
907
|
+
locale: localesForAction
|
908
|
+
}
|
909
|
+
});
|
910
|
+
setSelectedRows([]);
|
911
|
+
};
|
912
|
+
const unpublish = async () => {
|
913
|
+
await unpublishManyAction({
|
914
|
+
model,
|
915
|
+
documentIds: [documentId],
|
916
|
+
params: {
|
917
|
+
...params,
|
918
|
+
locale: localesForAction
|
675
919
|
}
|
676
920
|
});
|
677
921
|
setSelectedRows([]);
|
678
922
|
};
|
679
923
|
const handleAction = async () => {
|
680
924
|
if (draftRelationsCount > 0) {
|
681
|
-
|
682
|
-
} else {
|
925
|
+
setIsDraftRelationConfirmationOpen(true);
|
926
|
+
} else if (isBulkPublish) {
|
683
927
|
await publish();
|
928
|
+
} else {
|
929
|
+
await unpublish();
|
684
930
|
}
|
685
931
|
};
|
686
|
-
|
687
|
-
if (isUnpublish) {
|
688
|
-
console.warn(["I18N"], "Bulk locale unpublish modal not implemented");
|
689
|
-
}
|
690
|
-
if (isConfirmationOpen) {
|
932
|
+
if (isDraftRelationConfirmationOpen) {
|
691
933
|
return {
|
692
934
|
label: formatMessage({
|
693
935
|
id: "app.components.ConfirmDialog.title",
|
@@ -696,11 +938,11 @@ const BulkLocalePublishAction = ({
|
|
696
938
|
variant: "danger",
|
697
939
|
dialog: {
|
698
940
|
onCancel: () => {
|
699
|
-
|
941
|
+
setIsDraftRelationConfirmationOpen(false);
|
700
942
|
},
|
701
943
|
onConfirm: async () => {
|
702
944
|
await publish();
|
703
|
-
|
945
|
+
setIsDraftRelationConfirmationOpen(false);
|
704
946
|
},
|
705
947
|
type: "dialog",
|
706
948
|
title: formatMessage({
|
@@ -710,27 +952,32 @@ const BulkLocalePublishAction = ({
|
|
710
952
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "center", gap: 2, children: [
|
711
953
|
/* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, { width: "2.4rem", height: "2.4rem", fill: "danger600" }),
|
712
954
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textAlign: "center", children: formatMessage({
|
713
|
-
id: "
|
714
|
-
defaultMessage: "
|
955
|
+
id: getTranslation("CMEditViewBulkLocale.draft-relation-warning"),
|
956
|
+
defaultMessage: "Some locales are related to draft entries. Publishing them could leave broken links in your app."
|
957
|
+
}) }),
|
958
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textAlign: "center", children: formatMessage({
|
959
|
+
id: getTranslation("CMEditViewBulkLocale.continue-confirmation"),
|
960
|
+
defaultMessage: "Are you sure you want to continue?"
|
715
961
|
}) })
|
716
962
|
] })
|
717
963
|
}
|
718
964
|
};
|
719
965
|
}
|
966
|
+
const hasPermission = selectedRows.map(({ locale }) => locale).every((locale) => canPublish.includes(locale));
|
720
967
|
return {
|
721
968
|
label: formatMessage({
|
722
|
-
id: getTranslation("
|
723
|
-
defaultMessage: "Publish Multiple Locales
|
969
|
+
id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? "publish" : "unpublish"}-title`),
|
970
|
+
defaultMessage: `${isBulkPublish ? "Publish" : "Unpublish"} Multiple Locales`
|
724
971
|
}),
|
725
|
-
|
726
|
-
|
972
|
+
variant: isBulkPublish ? "secondary" : "danger",
|
973
|
+
icon: isBulkPublish ? /* @__PURE__ */ jsxRuntime.jsx(icons.ListPlus, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {}),
|
974
|
+
disabled: isOnPublishedTab || canPublish.length === 0,
|
727
975
|
position: ["panel"],
|
728
|
-
variant: "secondary",
|
729
976
|
dialog: {
|
730
977
|
type: "modal",
|
731
978
|
title: formatMessage({
|
732
|
-
id: getTranslation("
|
733
|
-
defaultMessage: "Publish Multiple Locales
|
979
|
+
id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? "publish" : "unpublish"}-title`),
|
980
|
+
defaultMessage: `${isBulkPublish ? "Publish" : "Unpublish"} Multiple Locales`
|
734
981
|
}),
|
735
982
|
content: () => {
|
736
983
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -749,28 +996,35 @@ const BulkLocalePublishAction = ({
|
|
749
996
|
validationErrors,
|
750
997
|
headers,
|
751
998
|
rows,
|
752
|
-
localesMetadata
|
999
|
+
localesMetadata,
|
1000
|
+
action: action ?? "bulk-publish"
|
753
1001
|
}
|
754
1002
|
)
|
755
1003
|
}
|
756
1004
|
);
|
757
1005
|
},
|
758
|
-
footer: () => /* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1006
|
+
footer: () => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Footer, { justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
|
759
1007
|
designSystem.Button,
|
760
1008
|
{
|
761
1009
|
loading: isDraftRelationsLoading,
|
762
|
-
disabled:
|
1010
|
+
disabled: !hasPermission || localesForAction.length === 0,
|
763
1011
|
variant: "default",
|
764
1012
|
onClick: handleAction,
|
765
1013
|
children: formatMessage({
|
766
|
-
id: "app.utils.publish",
|
767
|
-
defaultMessage: "Publish"
|
1014
|
+
id: isBulkPublish ? "app.utils.publish" : "app.utils.unpublish",
|
1015
|
+
defaultMessage: isBulkPublish ? "Publish" : "Unpublish"
|
768
1016
|
})
|
769
1017
|
}
|
770
1018
|
) })
|
771
1019
|
}
|
772
1020
|
};
|
773
1021
|
};
|
1022
|
+
const BulkLocalePublishAction = (props) => {
|
1023
|
+
return BulkLocaleAction({ action: "bulk-publish", ...props });
|
1024
|
+
};
|
1025
|
+
const BulkLocaleUnpublishAction = (props) => {
|
1026
|
+
return BulkLocaleAction({ action: "bulk-unpublish", ...props });
|
1027
|
+
};
|
774
1028
|
const StyledTrash = styledComponents.styled(icons.Trash)`
|
775
1029
|
path {
|
776
1030
|
fill: currentColor;
|
@@ -827,16 +1081,9 @@ const UnpublishModalAdditionalInfo = () => {
|
|
827
1081
|
}
|
828
1082
|
) });
|
829
1083
|
};
|
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
1084
|
const LocalePicker = () => {
|
838
1085
|
const { formatMessage } = reactIntl.useIntl();
|
839
|
-
const [{ query }, setQuery] = strapiAdmin.useQueryParams();
|
1086
|
+
const [{ query: query2 }, setQuery] = strapiAdmin.useQueryParams();
|
840
1087
|
const { hasI18n, canRead, canCreate } = useI18n();
|
841
1088
|
const { data: locales = [] } = useGetLocalesQuery(void 0, {
|
842
1089
|
skip: !hasI18n
|
@@ -846,25 +1093,25 @@ const LocalePicker = () => {
|
|
846
1093
|
setQuery(
|
847
1094
|
{
|
848
1095
|
page: 1,
|
849
|
-
plugins: { ...
|
1096
|
+
plugins: { ...query2.plugins, i18n: { locale: code } }
|
850
1097
|
},
|
851
1098
|
"push",
|
852
1099
|
replace
|
853
1100
|
);
|
854
1101
|
},
|
855
|
-
[
|
1102
|
+
[query2.plugins, setQuery]
|
856
1103
|
);
|
857
1104
|
React__namespace.useEffect(() => {
|
858
1105
|
if (!Array.isArray(locales) || !hasI18n) {
|
859
1106
|
return;
|
860
1107
|
}
|
861
|
-
const currentDesiredLocale =
|
1108
|
+
const currentDesiredLocale = query2.plugins?.i18n?.locale;
|
862
1109
|
const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
|
863
1110
|
const defaultLocale = locales.find((locale) => locale.isDefault);
|
864
1111
|
if (!doesLocaleExist && defaultLocale?.code) {
|
865
1112
|
handleChange(defaultLocale.code, true);
|
866
1113
|
}
|
867
|
-
}, [hasI18n, handleChange, locales,
|
1114
|
+
}, [hasI18n, handleChange, locales, query2.plugins?.i18n?.locale]);
|
868
1115
|
if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
|
869
1116
|
return null;
|
870
1117
|
}
|
@@ -879,7 +1126,7 @@ const LocalePicker = () => {
|
|
879
1126
|
id: getTranslation("actions.select-locale"),
|
880
1127
|
defaultMessage: "Select locale"
|
881
1128
|
}),
|
882
|
-
value:
|
1129
|
+
value: query2.plugins?.i18n?.locale || locales.find((locale) => locale.isDefault)?.code,
|
883
1130
|
onChange: handleChange,
|
884
1131
|
children: displayedLocales.map((locale) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: locale.code, children: locale.name }, locale.id))
|
885
1132
|
}
|
@@ -893,7 +1140,7 @@ const PERMISSIONS = {
|
|
893
1140
|
read: [{ action: "plugin::i18n.locale.read", subject: null }]
|
894
1141
|
};
|
895
1142
|
const mutateEditViewHook = ({ layout }) => {
|
896
|
-
if ("i18n" in layout.options
|
1143
|
+
if (!("i18n" in layout.options) || typeof layout.options.i18n === "object" && layout.options.i18n !== null && "localized" in layout.options.i18n && !layout.options.i18n.localized) {
|
897
1144
|
return { layout };
|
898
1145
|
}
|
899
1146
|
const components = Object.entries(layout.components).reduce(
|
@@ -939,7 +1186,7 @@ const doesFieldHaveI18nPluginOpt = (pluginOpts) => {
|
|
939
1186
|
const LabelAction = ({ title, icon }) => {
|
940
1187
|
const { formatMessage } = reactIntl.useIntl();
|
941
1188
|
return /* @__PURE__ */ jsxRuntime.jsxs(Span, { tag: "span", children: [
|
942
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "span", children:
|
1189
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "span", children: formatMessage(title) }),
|
943
1190
|
React__namespace.cloneElement(icon, {
|
944
1191
|
"aria-hidden": true,
|
945
1192
|
focusable: false
|
@@ -974,13 +1221,7 @@ const LocaleListCell = ({
|
|
974
1221
|
}
|
975
1222
|
});
|
976
1223
|
const { locale: language } = reactIntl.useIntl();
|
977
|
-
const [visible, setVisible] = React__namespace.useState(false);
|
978
|
-
const buttonRef = React__namespace.useRef(null);
|
979
1224
|
const { data: locales = [] } = useGetLocalesQuery();
|
980
|
-
const handleTogglePopover = (e) => {
|
981
|
-
e.stopPropagation();
|
982
|
-
setVisible((prev) => !prev);
|
983
|
-
};
|
984
1225
|
const formatter = designSystem.useCollator(language, {
|
985
1226
|
sensitivity: "base"
|
986
1227
|
});
|
@@ -1002,64 +1243,14 @@ const LocaleListCell = ({
|
|
1002
1243
|
}
|
1003
1244
|
return locale.name;
|
1004
1245
|
}).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
|
-
)
|
1246
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Popover.Root, { children: [
|
1247
|
+
/* @__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: [
|
1248
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", ellipsis: true, marginRight: 2, children: localesForDocument.join(", ") }),
|
1249
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(icons.CaretDown, { width: "1.2rem", height: "1.2rem" }) })
|
1250
|
+
] }) }) }),
|
1251
|
+
/* @__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
1252
|
] });
|
1031
1253
|
};
|
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
1254
|
const addColumnToTableHook = ({ displayedHeaders, layout }) => {
|
1064
1255
|
const { options } = layout;
|
1065
1256
|
const isFieldLocalized = doesPluginOptionsHaveI18nLocalized(options) ? options.i18n.localized : false;
|
@@ -1240,8 +1431,6 @@ const index = {
|
|
1240
1431
|
app.addRBACMiddleware([localeMiddleware]);
|
1241
1432
|
app.registerPlugin({
|
1242
1433
|
id: pluginId,
|
1243
|
-
initializer: Initializer,
|
1244
|
-
isReady: false,
|
1245
1434
|
name: pluginId
|
1246
1435
|
});
|
1247
1436
|
},
|
@@ -1259,11 +1448,11 @@ const index = {
|
|
1259
1448
|
},
|
1260
1449
|
id: "internationalization",
|
1261
1450
|
to: "internationalization",
|
1262
|
-
Component: () => Promise.resolve().then(() => require("./SettingsPage-
|
1451
|
+
Component: () => Promise.resolve().then(() => require("./SettingsPage-kMDCxWLw.js")).then((mod) => ({ default: mod.ProtectedSettingsPage })),
|
1263
1452
|
permissions: PERMISSIONS.accessMain
|
1264
1453
|
});
|
1265
1454
|
const contentManager = app.getPlugin("content-manager");
|
1266
|
-
contentManager.apis.addDocumentHeaderAction([LocalePickerAction]);
|
1455
|
+
contentManager.apis.addDocumentHeaderAction([LocalePickerAction, FillFromAnotherLocaleAction]);
|
1267
1456
|
contentManager.apis.addDocumentAction((actions) => {
|
1268
1457
|
const indexOfDeleteAction = actions.findIndex((action) => action.type === "delete");
|
1269
1458
|
actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);
|
@@ -1271,6 +1460,7 @@ const index = {
|
|
1271
1460
|
});
|
1272
1461
|
contentManager.apis.addDocumentAction((actions) => {
|
1273
1462
|
actions.splice(2, 0, BulkLocalePublishAction);
|
1463
|
+
actions.splice(5, 0, BulkLocaleUnpublishAction);
|
1274
1464
|
return actions;
|
1275
1465
|
});
|
1276
1466
|
contentManager.injectComponent("listView", "actions", {
|
@@ -1376,7 +1566,7 @@ const index = {
|
|
1376
1566
|
async registerTrads({ locales }) {
|
1377
1567
|
const importedTrads = await Promise.all(
|
1378
1568
|
locales.map((locale) => {
|
1379
|
-
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-
|
1569
|
+
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-B6327hMz.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 }) => {
|
1380
1570
|
return {
|
1381
1571
|
data: prefixPluginTranslations(data, pluginId),
|
1382
1572
|
locale
|
@@ -1400,4 +1590,4 @@ exports.useDeleteLocaleMutation = useDeleteLocaleMutation;
|
|
1400
1590
|
exports.useGetDefaultLocalesQuery = useGetDefaultLocalesQuery;
|
1401
1591
|
exports.useGetLocalesQuery = useGetLocalesQuery;
|
1402
1592
|
exports.useUpdateLocaleMutation = useUpdateLocaleMutation;
|
1403
|
-
//# sourceMappingURL=index-
|
1593
|
+
//# sourceMappingURL=index-Dncj9Inq.js.map
|