@strapi/i18n 0.0.0-experimental.9df68962083938acba06546a7901c68a63266aec → 0.0.0-experimental.a13c58eec89ab119f0e381fb79c0252979e9c125
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-DT1sxWa2.js → SettingsPage-D0hqaut-.js} +8 -8
- package/dist/_chunks/SettingsPage-D0hqaut-.js.map +1 -0
- package/dist/_chunks/{SettingsPage-B5sTcP82.mjs → SettingsPage-D67CaQAB.mjs} +8 -8
- package/dist/_chunks/SettingsPage-D67CaQAB.mjs.map +1 -0
- package/dist/_chunks/{en-BsOU9o5z.js → en-BKBz3tro.js} +10 -3
- package/dist/_chunks/en-BKBz3tro.js.map +1 -0
- package/dist/_chunks/{en-CM6Pjfyv.mjs → en-DlXfy6Gy.mjs} +10 -3
- package/dist/_chunks/en-DlXfy6Gy.mjs.map +1 -0
- package/dist/_chunks/{index-jMrzaEb9.js → index-46DNtLCn.js} +415 -171
- package/dist/_chunks/index-46DNtLCn.js.map +1 -0
- package/dist/_chunks/{index-DsNqyQKx.mjs → index-CNR8i3KM.mjs} +411 -167
- package/dist/_chunks/index-CNR8i3KM.mjs.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/BulkLocaleActionModal.d.ts +2 -1
- package/dist/admin/src/components/CMHeaderActions.d.ts +29 -3
- package/dist/admin/src/components/CreateLocale.d.ts +6 -6
- 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 +413 -480
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +415 -482
- 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 +21 -13
- 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 +20 -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/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 +10 -10
- package/dist/_chunks/SettingsPage-B5sTcP82.mjs.map +0 -1
- package/dist/_chunks/SettingsPage-DT1sxWa2.js.map +0 -1
- package/dist/_chunks/en-BsOU9o5z.js.map +0 -1
- package/dist/_chunks/en-CM6Pjfyv.mjs.map +0 -1
- package/dist/_chunks/index-DsNqyQKx.mjs.map +0 -1
- package/dist/_chunks/index-jMrzaEb9.js.map +0 -1
- package/dist/admin/src/components/Initializer.d.ts +0 -5
- 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
@@ -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");
|
@@ -160,7 +161,7 @@ const useI18n = () => {
|
|
160
161
|
model: params.slug
|
161
162
|
},
|
162
163
|
{
|
163
|
-
skip:
|
164
|
+
skip: true
|
164
165
|
}
|
165
166
|
);
|
166
167
|
if (doesPluginOptionsHaveI18nLocalized(schema?.pluginOptions)) {
|
@@ -240,10 +241,94 @@ const relationsApi = i18nApi.injectEndpoints({
|
|
240
241
|
})
|
241
242
|
});
|
242
243
|
const { useGetManyDraftRelationCountQuery } = relationsApi;
|
244
|
+
const cleanData = (data, schema, components) => {
|
245
|
+
const cleanedData = removeFields(data, [
|
246
|
+
"createdAt",
|
247
|
+
"createdBy",
|
248
|
+
"updatedAt",
|
249
|
+
"updatedBy",
|
250
|
+
"id",
|
251
|
+
"documentId",
|
252
|
+
"publishedAt",
|
253
|
+
"strapi_stage",
|
254
|
+
"strapi_assignee",
|
255
|
+
"locale",
|
256
|
+
"status"
|
257
|
+
]);
|
258
|
+
const cleanedDataWithoutPasswordAndRelation = recursiveRemoveFieldTypes(
|
259
|
+
cleanedData,
|
260
|
+
schema,
|
261
|
+
components,
|
262
|
+
["relation", "password"]
|
263
|
+
);
|
264
|
+
return cleanedDataWithoutPasswordAndRelation;
|
265
|
+
};
|
266
|
+
const removeFields = (data, fields) => {
|
267
|
+
return Object.keys(data).reduce((acc, current) => {
|
268
|
+
if (fields.includes(current)) {
|
269
|
+
return acc;
|
270
|
+
}
|
271
|
+
acc[current] = data[current];
|
272
|
+
return acc;
|
273
|
+
}, {});
|
274
|
+
};
|
275
|
+
const recursiveRemoveFieldTypes = (data, schema, components, fields) => {
|
276
|
+
return Object.keys(data).reduce((acc, current) => {
|
277
|
+
const attribute = schema.attributes[current] ?? { type: void 0 };
|
278
|
+
if (fields.includes(attribute.type)) {
|
279
|
+
return acc;
|
280
|
+
}
|
281
|
+
if (attribute.type === "dynamiczone") {
|
282
|
+
acc[current] = data[current].map((componentValue, index2) => {
|
283
|
+
const { id: _, ...rest } = recursiveRemoveFieldTypes(
|
284
|
+
componentValue,
|
285
|
+
components[componentValue.__component],
|
286
|
+
components,
|
287
|
+
fields
|
288
|
+
);
|
289
|
+
return {
|
290
|
+
...rest,
|
291
|
+
__temp_key__: index2 + 1
|
292
|
+
};
|
293
|
+
});
|
294
|
+
} else if (attribute.type === "component") {
|
295
|
+
const { repeatable, component } = attribute;
|
296
|
+
if (repeatable) {
|
297
|
+
acc[current] = (data[current] ?? []).map((compoData, index2) => {
|
298
|
+
const { id: _, ...rest } = recursiveRemoveFieldTypes(
|
299
|
+
compoData,
|
300
|
+
components[component],
|
301
|
+
components,
|
302
|
+
fields
|
303
|
+
);
|
304
|
+
return {
|
305
|
+
...rest,
|
306
|
+
__temp_key__: index2 + 1
|
307
|
+
};
|
308
|
+
});
|
309
|
+
} else {
|
310
|
+
const { id: _, ...rest } = recursiveRemoveFieldTypes(
|
311
|
+
data[current] ?? {},
|
312
|
+
components[component],
|
313
|
+
components,
|
314
|
+
fields
|
315
|
+
);
|
316
|
+
acc[current] = rest;
|
317
|
+
}
|
318
|
+
} else {
|
319
|
+
acc[current] = data[current];
|
320
|
+
}
|
321
|
+
return acc;
|
322
|
+
}, {});
|
323
|
+
};
|
243
324
|
const isErrorMessageDescriptor = (object) => {
|
244
325
|
return typeof object === "object" && object !== null && "id" in object && "defaultMessage" in object;
|
245
326
|
};
|
246
|
-
const EntryValidationText = ({
|
327
|
+
const EntryValidationText = ({
|
328
|
+
status = "draft",
|
329
|
+
validationErrors,
|
330
|
+
action
|
331
|
+
}) => {
|
247
332
|
const { formatMessage } = reactIntl.useIntl();
|
248
333
|
const getErrorStr = (key, value) => {
|
249
334
|
if (typeof value === "string") {
|
@@ -277,30 +362,63 @@ const EntryValidationText = ({ status = "draft", validationErrors }) => {
|
|
277
362
|
) })
|
278
363
|
] });
|
279
364
|
}
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
365
|
+
const getStatusMessage = () => {
|
366
|
+
if (action === "bulk-publish") {
|
367
|
+
if (status === "published") {
|
368
|
+
return {
|
369
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
370
|
+
text: formatMessage({
|
371
|
+
id: "content-manager.bulk-publish.already-published",
|
372
|
+
defaultMessage: "Already Published"
|
373
|
+
}),
|
374
|
+
textColor: "success600",
|
375
|
+
fontWeight: "bold"
|
376
|
+
};
|
377
|
+
} else if (status === "modified") {
|
378
|
+
return {
|
379
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowsCounterClockwise, { fill: "alternative600" }),
|
380
|
+
text: formatMessage({
|
381
|
+
id: "app.utils.ready-to-publish-changes",
|
382
|
+
defaultMessage: "Ready to publish changes"
|
383
|
+
})
|
384
|
+
};
|
385
|
+
} else {
|
386
|
+
return {
|
387
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
388
|
+
text: formatMessage({
|
389
|
+
id: "app.utils.ready-to-publish",
|
390
|
+
defaultMessage: "Ready to publish"
|
391
|
+
})
|
392
|
+
};
|
393
|
+
}
|
394
|
+
} else {
|
395
|
+
if (status === "draft") {
|
396
|
+
return {
|
397
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
398
|
+
text: formatMessage({
|
399
|
+
id: "content-manager.bulk-unpublish.already-unpublished",
|
400
|
+
defaultMessage: "Already Unpublished"
|
401
|
+
}),
|
402
|
+
textColor: "success600",
|
403
|
+
fontWeight: "bold"
|
404
|
+
};
|
405
|
+
} else {
|
406
|
+
return {
|
407
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
408
|
+
text: formatMessage({
|
409
|
+
id: "app.utils.ready-to-unpublish-changes",
|
410
|
+
defaultMessage: "Ready to unpublish"
|
411
|
+
}),
|
412
|
+
textColor: "success600",
|
413
|
+
fontWeight: "bold"
|
414
|
+
};
|
415
|
+
}
|
416
|
+
}
|
417
|
+
};
|
418
|
+
const { icon, text, textColor = "success600", fontWeight = "normal" } = getStatusMessage();
|
298
419
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
299
|
-
|
300
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children:
|
301
|
-
id: "app.utils.ready-to-publish",
|
302
|
-
defaultMessage: "Ready to publish"
|
303
|
-
}) })
|
420
|
+
icon,
|
421
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor, fontWeight, children: text })
|
304
422
|
] });
|
305
423
|
};
|
306
424
|
const BoldChunk = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
|
@@ -308,7 +426,8 @@ const BulkLocaleActionModal = ({
|
|
308
426
|
headers,
|
309
427
|
rows,
|
310
428
|
localesMetadata,
|
311
|
-
validationErrors = {}
|
429
|
+
validationErrors = {},
|
430
|
+
action
|
312
431
|
}) => {
|
313
432
|
const { formatMessage } = reactIntl.useIntl();
|
314
433
|
const selectedRows = strapiAdmin.useTable(
|
@@ -321,27 +440,29 @@ const BulkLocaleActionModal = ({
|
|
321
440
|
return acc;
|
322
441
|
}, {});
|
323
442
|
const localesWithErrors = Object.keys(validationErrors);
|
324
|
-
const
|
443
|
+
const publishedCount = selectedRows.filter(
|
325
444
|
({ locale }) => currentStatusByLocale[locale] === "published"
|
326
445
|
).length;
|
327
|
-
const
|
446
|
+
const draftCount = selectedRows.filter(
|
328
447
|
({ locale }) => (currentStatusByLocale[locale] === "draft" || currentStatusByLocale[locale] === "modified") && !localesWithErrors.includes(locale)
|
329
448
|
).length;
|
330
449
|
const withErrorsCount = localesWithErrors.length;
|
450
|
+
const messageId = action === "bulk-publish" ? "content-manager.containers.list.selectedEntriesModal.selectedCount.publish" : "content-manager.containers.list.selectedEntriesModal.selectedCount.unpublish";
|
451
|
+
const defaultMessage = action === "bulk-publish" ? "<b>{publishedCount}</b> {publishedCount, plural, =0 {entries} one {entry} other {entries}} already published. <b>{draftCount}</b> {draftCount, plural, =0 {entries} one {entry} other {entries}} ready to publish. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action." : "<b>{draftCount}</b> {draftCount, plural, =0 {entries} one {entry} other {entries}} already unpublished. <b>{publishedCount}</b> {publishedCount, plural, =0 {entries} one {entry} other {entries}} ready to unpublish.";
|
331
452
|
return formatMessage(
|
332
453
|
{
|
333
|
-
id:
|
334
|
-
defaultMessage
|
454
|
+
id: messageId,
|
455
|
+
defaultMessage
|
335
456
|
},
|
336
457
|
{
|
337
458
|
withErrorsCount,
|
338
|
-
|
339
|
-
|
459
|
+
draftCount,
|
460
|
+
publishedCount,
|
340
461
|
b: BoldChunk
|
341
462
|
}
|
342
463
|
);
|
343
464
|
};
|
344
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
465
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Body, { children: [
|
345
466
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: getFormattedCountMessage() }),
|
346
467
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Content, { children: [
|
347
468
|
/* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Head, { children: [
|
@@ -362,13 +483,12 @@ const BulkLocaleActionModal = ({
|
|
362
483
|
paddingRight: "6px",
|
363
484
|
paddingTop: "2px",
|
364
485
|
paddingBottom: "2px",
|
365
|
-
showBullet: false,
|
366
486
|
size: "S",
|
367
487
|
variant: statusVariant,
|
368
488
|
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
369
489
|
}
|
370
490
|
) }) }),
|
371
|
-
/* @__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 }) }),
|
372
492
|
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
373
493
|
designSystem.IconButton,
|
374
494
|
{
|
@@ -385,7 +505,7 @@ const BulkLocaleActionModal = ({
|
|
385
505
|
name: locale
|
386
506
|
}
|
387
507
|
),
|
388
|
-
|
508
|
+
variant: "ghost",
|
389
509
|
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {})
|
390
510
|
}
|
391
511
|
) })
|
@@ -394,6 +514,47 @@ const BulkLocaleActionModal = ({
|
|
394
514
|
] }) })
|
395
515
|
] });
|
396
516
|
};
|
517
|
+
const statusVariants = {
|
518
|
+
draft: "secondary",
|
519
|
+
published: "success",
|
520
|
+
modified: "alternative"
|
521
|
+
};
|
522
|
+
const LocaleOption = ({
|
523
|
+
isDraftAndPublishEnabled,
|
524
|
+
locale,
|
525
|
+
status,
|
526
|
+
entryExists
|
527
|
+
}) => {
|
528
|
+
const { formatMessage } = reactIntl.useIntl();
|
529
|
+
if (!entryExists) {
|
530
|
+
return formatMessage(
|
531
|
+
{
|
532
|
+
id: getTranslation("CMEditViewLocalePicker.locale.create"),
|
533
|
+
defaultMessage: "Create <bold>{locale}</bold> locale"
|
534
|
+
},
|
535
|
+
{
|
536
|
+
bold: (locale2) => /* @__PURE__ */ jsxRuntime.jsx("b", { children: locale2 }),
|
537
|
+
locale: locale.name
|
538
|
+
}
|
539
|
+
);
|
540
|
+
}
|
541
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", gap: 1, justifyContent: "space-between", children: [
|
542
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: locale.name }),
|
543
|
+
isDraftAndPublishEnabled ? /* @__PURE__ */ jsxRuntime.jsx(
|
544
|
+
designSystem.Status,
|
545
|
+
{
|
546
|
+
display: "flex",
|
547
|
+
paddingLeft: "6px",
|
548
|
+
paddingRight: "6px",
|
549
|
+
paddingTop: "2px",
|
550
|
+
paddingBottom: "2px",
|
551
|
+
size: "S",
|
552
|
+
variant: statusVariants[status],
|
553
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
554
|
+
}
|
555
|
+
) : null
|
556
|
+
] });
|
557
|
+
};
|
397
558
|
const LocalePickerAction = ({
|
398
559
|
document,
|
399
560
|
meta,
|
@@ -402,74 +563,74 @@ const LocalePickerAction = ({
|
|
402
563
|
documentId
|
403
564
|
}) => {
|
404
565
|
const { formatMessage } = reactIntl.useIntl();
|
405
|
-
const [{ query }, setQuery] = strapiAdmin.useQueryParams();
|
566
|
+
const [{ query: query2 }, setQuery] = strapiAdmin.useQueryParams();
|
406
567
|
const { hasI18n, canCreate, canRead } = useI18n();
|
407
568
|
const { data: locales = [] } = useGetLocalesQuery();
|
408
|
-
const
|
569
|
+
const currentDesiredLocale = query2.plugins?.i18n?.locale;
|
570
|
+
const { schema } = strapiAdmin$1.unstable_useDocument({
|
571
|
+
model,
|
572
|
+
collectionType,
|
573
|
+
documentId,
|
574
|
+
params: { locale: currentDesiredLocale }
|
575
|
+
});
|
409
576
|
const handleSelect = React__namespace.useCallback(
|
410
577
|
(value) => {
|
411
578
|
setQuery({
|
412
579
|
plugins: {
|
413
|
-
...
|
580
|
+
...query2.plugins,
|
414
581
|
i18n: {
|
415
582
|
locale: value
|
416
583
|
}
|
417
584
|
}
|
418
585
|
});
|
419
586
|
},
|
420
|
-
[
|
587
|
+
[query2.plugins, setQuery]
|
421
588
|
);
|
422
589
|
React__namespace.useEffect(() => {
|
423
590
|
if (!Array.isArray(locales) || !hasI18n) {
|
424
591
|
return;
|
425
592
|
}
|
426
|
-
const currentDesiredLocale = query.plugins?.i18n?.locale;
|
427
593
|
const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
|
428
594
|
const defaultLocale = locales.find((locale) => locale.isDefault);
|
429
595
|
if (!doesLocaleExist && defaultLocale?.code) {
|
430
596
|
handleSelect(defaultLocale.code);
|
431
597
|
}
|
432
|
-
}, [handleSelect, hasI18n, locales,
|
433
|
-
|
434
|
-
return null;
|
435
|
-
}
|
436
|
-
const currentLocale = query.plugins?.i18n?.locale || locales.find((loc) => loc.isDefault)?.code;
|
598
|
+
}, [handleSelect, hasI18n, locales, currentDesiredLocale]);
|
599
|
+
const currentLocale = Array.isArray(locales) ? locales.find((locale) => locale.code === currentDesiredLocale) : void 0;
|
437
600
|
const allCurrentLocales = [
|
438
|
-
{ status: getDocumentStatus(document, meta), locale: currentLocale },
|
601
|
+
{ status: getDocumentStatus(document, meta), locale: currentLocale?.code },
|
439
602
|
...meta?.availableLocales ?? []
|
440
603
|
];
|
604
|
+
if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
|
605
|
+
return null;
|
606
|
+
}
|
441
607
|
return {
|
442
608
|
label: formatMessage({
|
443
609
|
id: getTranslation("Settings.locales.modal.locales.label"),
|
444
610
|
defaultMessage: "Locales"
|
445
611
|
}),
|
446
612
|
options: locales.map((locale) => {
|
613
|
+
const entryWithLocaleExists = allCurrentLocales.some((doc) => doc.locale === locale.code);
|
447
614
|
const currentLocaleDoc = allCurrentLocales.find(
|
448
615
|
(doc) => "locale" in doc ? doc.locale === locale.code : false
|
449
616
|
);
|
450
|
-
const
|
451
|
-
const permissionsToCheck = currentLocaleDoc ? canCreate : canRead;
|
452
|
-
const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
|
617
|
+
const permissionsToCheck = currentLocaleDoc ? canRead : canCreate;
|
453
618
|
return {
|
454
619
|
disabled: !permissionsToCheck.includes(locale.code),
|
455
620
|
value: locale.code,
|
456
|
-
label:
|
457
|
-
|
458
|
-
designSystem.Status,
|
621
|
+
label: /* @__PURE__ */ jsxRuntime.jsx(
|
622
|
+
LocaleOption,
|
459
623
|
{
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
paddingBottom: "2px",
|
465
|
-
showBullet: false,
|
466
|
-
size: "S",
|
467
|
-
variant: statusVariant,
|
468
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
624
|
+
isDraftAndPublishEnabled: !!schema?.options?.draftAndPublish,
|
625
|
+
locale,
|
626
|
+
status: currentLocaleDoc?.status,
|
627
|
+
entryExists: entryWithLocaleExists
|
469
628
|
}
|
470
|
-
)
|
629
|
+
),
|
630
|
+
startIcon: !entryWithLocaleExists ? /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}) : null
|
471
631
|
};
|
472
632
|
}),
|
633
|
+
customizeContent: () => currentLocale?.name,
|
473
634
|
onSelect: handleSelect,
|
474
635
|
value: currentLocale
|
475
636
|
};
|
@@ -485,6 +646,99 @@ const getDocumentStatus = (document, meta) => {
|
|
485
646
|
}
|
486
647
|
return docStatus;
|
487
648
|
};
|
649
|
+
const FillFromAnotherLocaleAction = ({
|
650
|
+
documentId,
|
651
|
+
meta,
|
652
|
+
model,
|
653
|
+
collectionType
|
654
|
+
}) => {
|
655
|
+
const { formatMessage } = reactIntl.useIntl();
|
656
|
+
const [{ query: query2 }] = strapiAdmin.useQueryParams();
|
657
|
+
const { hasI18n } = useI18n();
|
658
|
+
const currentDesiredLocale = query2.plugins?.i18n?.locale;
|
659
|
+
const [localeSelected, setLocaleSelected] = React__namespace.useState(null);
|
660
|
+
const setValues = strapiAdmin.useForm("FillFromAnotherLocale", (state) => state.setValues);
|
661
|
+
const { getDocument } = strapiAdmin$1.unstable_useDocumentActions();
|
662
|
+
const { schema, components } = strapiAdmin$1.unstable_useDocument({
|
663
|
+
model,
|
664
|
+
documentId,
|
665
|
+
collectionType,
|
666
|
+
params: { locale: currentDesiredLocale }
|
667
|
+
});
|
668
|
+
const { data: locales = [] } = useGetLocalesQuery();
|
669
|
+
const availableLocales = Array.isArray(locales) ? locales.filter((locale) => meta?.availableLocales.some((l) => l.locale === locale.code)) : [];
|
670
|
+
const fillFromLocale = (onClose) => async () => {
|
671
|
+
const response = await getDocument({
|
672
|
+
collectionType,
|
673
|
+
model,
|
674
|
+
documentId,
|
675
|
+
params: { locale: localeSelected }
|
676
|
+
});
|
677
|
+
if (!response || !schema) {
|
678
|
+
return;
|
679
|
+
}
|
680
|
+
const { data } = response;
|
681
|
+
const cleanedData = cleanData(data, schema, components);
|
682
|
+
setValues(cleanedData);
|
683
|
+
onClose();
|
684
|
+
};
|
685
|
+
if (!hasI18n) {
|
686
|
+
return null;
|
687
|
+
}
|
688
|
+
return {
|
689
|
+
type: "icon",
|
690
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Download, {}),
|
691
|
+
disabled: availableLocales.length === 0,
|
692
|
+
label: formatMessage({
|
693
|
+
id: getTranslation("CMEditViewCopyLocale.copy-text"),
|
694
|
+
defaultMessage: "Fill in from another locale"
|
695
|
+
}),
|
696
|
+
dialog: {
|
697
|
+
type: "dialog",
|
698
|
+
title: formatMessage({
|
699
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.title"),
|
700
|
+
defaultMessage: "Confirmation"
|
701
|
+
}),
|
702
|
+
content: ({ onClose }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
703
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, children: [
|
704
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
705
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textAlign: "center", children: formatMessage({
|
706
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.body"),
|
707
|
+
defaultMessage: "Your current content will be erased and filled by the content of the selected locale:"
|
708
|
+
}) }),
|
709
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { width: "100%", children: [
|
710
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
|
711
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.field.label"),
|
712
|
+
defaultMessage: "Locale"
|
713
|
+
}) }),
|
714
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
715
|
+
designSystem.SingleSelect,
|
716
|
+
{
|
717
|
+
value: localeSelected,
|
718
|
+
placeholder: formatMessage({
|
719
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.field.placeholder"),
|
720
|
+
defaultMessage: "Select one locale..."
|
721
|
+
}),
|
722
|
+
onChange: (value) => setLocaleSelected(value),
|
723
|
+
children: availableLocales.map((locale) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: locale.code, children: locale.name }, locale.code))
|
724
|
+
}
|
725
|
+
)
|
726
|
+
] })
|
727
|
+
] }) }),
|
728
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, width: "100%", children: [
|
729
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { flex: "auto", variant: "tertiary", onClick: onClose, children: formatMessage({
|
730
|
+
id: getTranslation("CMEditViewCopyLocale.cancel-text"),
|
731
|
+
defaultMessage: "No, cancel"
|
732
|
+
}) }),
|
733
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { flex: "auto", variant: "success", onClick: fillFromLocale(onClose), children: formatMessage({
|
734
|
+
id: getTranslation("CMEditViewCopyLocale.submit-text"),
|
735
|
+
defaultMessage: "Yes, fill in"
|
736
|
+
}) })
|
737
|
+
] }) })
|
738
|
+
] })
|
739
|
+
}
|
740
|
+
};
|
741
|
+
};
|
488
742
|
const DeleteLocaleAction = ({
|
489
743
|
document,
|
490
744
|
documentId,
|
@@ -496,16 +750,23 @@ const DeleteLocaleAction = ({
|
|
496
750
|
const { toggleNotification } = strapiAdmin.useNotification();
|
497
751
|
const { delete: deleteAction } = strapiAdmin$1.unstable_useDocumentActions();
|
498
752
|
const { hasI18n, canDelete } = useI18n();
|
753
|
+
const [{ query: query2 }] = strapiAdmin.useQueryParams();
|
754
|
+
const { data: locales = [] } = useGetLocalesQuery();
|
755
|
+
const currentDesiredLocale = query2.plugins?.i18n?.locale;
|
756
|
+
const locale = !("error" in locales) && locales.find((loc) => loc.code === currentDesiredLocale);
|
499
757
|
if (!hasI18n) {
|
500
758
|
return null;
|
501
759
|
}
|
502
760
|
return {
|
503
761
|
disabled: document?.locale && !canDelete.includes(document.locale) || !document || !document.id,
|
504
762
|
position: ["header", "table-row"],
|
505
|
-
label: formatMessage(
|
506
|
-
|
507
|
-
|
508
|
-
|
763
|
+
label: formatMessage(
|
764
|
+
{
|
765
|
+
id: getTranslation("actions.delete.label"),
|
766
|
+
defaultMessage: "Delete entry ({locale})"
|
767
|
+
},
|
768
|
+
{ locale: locale && locale.name }
|
769
|
+
),
|
509
770
|
icon: /* @__PURE__ */ jsxRuntime.jsx(StyledTrash, {}),
|
510
771
|
variant: "danger",
|
511
772
|
dialog: {
|
@@ -522,7 +783,12 @@ const DeleteLocaleAction = ({
|
|
522
783
|
}) })
|
523
784
|
] }),
|
524
785
|
onConfirm: async () => {
|
525
|
-
|
786
|
+
const unableToDelete = (
|
787
|
+
// We are unable to delete a collection type without a document ID
|
788
|
+
// & unable to delete generally if there is no document locale
|
789
|
+
collectionType !== "single-types" && !documentId || !document?.locale
|
790
|
+
);
|
791
|
+
if (unableToDelete) {
|
526
792
|
console.error(
|
527
793
|
"You're trying to delete a document without an id or locale, this is likely a bug with Strapi. Please open an issue."
|
528
794
|
);
|
@@ -548,37 +814,43 @@ const DeleteLocaleAction = ({
|
|
548
814
|
}
|
549
815
|
};
|
550
816
|
};
|
551
|
-
const
|
817
|
+
const BulkLocaleAction = ({
|
552
818
|
document: baseDocument,
|
553
819
|
documentId,
|
554
820
|
model,
|
555
|
-
collectionType
|
821
|
+
collectionType,
|
822
|
+
action
|
556
823
|
}) => {
|
557
824
|
const baseLocale = baseDocument?.locale ?? null;
|
558
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
559
|
-
const params = React__namespace.useMemo(() => strapiAdmin$1.buildValidParams(query), [query]);
|
560
|
-
const
|
825
|
+
const [{ query: query$1 }] = strapiAdmin.useQueryParams();
|
826
|
+
const params = React__namespace.useMemo(() => strapiAdmin$1.buildValidParams(query$1), [query$1]);
|
827
|
+
const isOnPublishedTab = query$1.status === "published";
|
561
828
|
const { formatMessage } = reactIntl.useIntl();
|
562
829
|
const { hasI18n, canPublish } = useI18n();
|
563
830
|
const { toggleNotification } = strapiAdmin.useNotification();
|
564
831
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
565
832
|
const [selectedRows, setSelectedRows] = React__namespace.useState([]);
|
566
833
|
const [isDraftRelationConfirmationOpen, setIsDraftRelationConfirmationOpen] = React__namespace.useState(false);
|
567
|
-
const { publishMany: publishManyAction } = strapiAdmin$1.unstable_useDocumentActions();
|
834
|
+
const { publishMany: publishManyAction, unpublishMany: unpublishManyAction } = strapiAdmin$1.unstable_useDocumentActions();
|
568
835
|
const {
|
569
836
|
document,
|
570
837
|
meta: documentMeta,
|
571
838
|
schema,
|
572
839
|
validate
|
573
|
-
} = strapiAdmin$1.unstable_useDocument(
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
840
|
+
} = strapiAdmin$1.unstable_useDocument(
|
841
|
+
{
|
842
|
+
model,
|
843
|
+
collectionType,
|
844
|
+
documentId,
|
845
|
+
params: {
|
846
|
+
locale: baseLocale
|
847
|
+
}
|
848
|
+
},
|
849
|
+
{
|
850
|
+
skip: !hasI18n || !baseLocale
|
579
851
|
}
|
580
|
-
|
581
|
-
const { data: localesMetadata = [] } = useGetLocalesQuery();
|
852
|
+
);
|
853
|
+
const { data: localesMetadata = [] } = useGetLocalesQuery(hasI18n ? void 0 : query.skipToken);
|
582
854
|
const headers = [
|
583
855
|
{
|
584
856
|
label: formatMessage({
|
@@ -627,12 +899,19 @@ const BulkLocalePublishAction = ({
|
|
627
899
|
}, {});
|
628
900
|
return [rowsFromMeta, errors];
|
629
901
|
}, [document, documentMeta?.availableLocales, validate]);
|
630
|
-
const
|
631
|
-
|
902
|
+
const isBulkPublish = action === "bulk-publish";
|
903
|
+
const localesForAction = selectedRows.reduce((acc, selectedRow) => {
|
904
|
+
const isValidLocale = (
|
905
|
+
// Validation errors are irrelevant if we are trying to unpublish
|
906
|
+
!isBulkPublish || !Object.keys(validationErrors).includes(selectedRow.locale)
|
907
|
+
);
|
908
|
+
const shouldAddLocale = isBulkPublish ? selectedRow.status !== "published" && isValidLocale : selectedRow.status !== "draft" && isValidLocale;
|
909
|
+
if (shouldAddLocale) {
|
632
910
|
acc.push(selectedRow.locale);
|
633
911
|
}
|
634
912
|
return acc;
|
635
913
|
}, []);
|
914
|
+
const enableDraftRelationsCount = false;
|
636
915
|
const {
|
637
916
|
data: draftRelationsCount = 0,
|
638
917
|
isLoading: isDraftRelationsLoading,
|
@@ -641,10 +920,10 @@ const BulkLocalePublishAction = ({
|
|
641
920
|
{
|
642
921
|
model,
|
643
922
|
documentIds: [documentId],
|
644
|
-
locale:
|
923
|
+
locale: localesForAction
|
645
924
|
},
|
646
925
|
{
|
647
|
-
skip: !
|
926
|
+
skip: !enableDraftRelationsCount
|
648
927
|
}
|
649
928
|
);
|
650
929
|
React__namespace.useEffect(() => {
|
@@ -670,7 +949,18 @@ const BulkLocalePublishAction = ({
|
|
670
949
|
documentIds: [documentId],
|
671
950
|
params: {
|
672
951
|
...params,
|
673
|
-
locale:
|
952
|
+
locale: localesForAction
|
953
|
+
}
|
954
|
+
});
|
955
|
+
setSelectedRows([]);
|
956
|
+
};
|
957
|
+
const unpublish = async () => {
|
958
|
+
await unpublishManyAction({
|
959
|
+
model,
|
960
|
+
documentIds: [documentId],
|
961
|
+
params: {
|
962
|
+
...params,
|
963
|
+
locale: localesForAction
|
674
964
|
}
|
675
965
|
});
|
676
966
|
setSelectedRows([]);
|
@@ -678,14 +968,12 @@ const BulkLocalePublishAction = ({
|
|
678
968
|
const handleAction = async () => {
|
679
969
|
if (draftRelationsCount > 0) {
|
680
970
|
setIsDraftRelationConfirmationOpen(true);
|
681
|
-
} else {
|
971
|
+
} else if (isBulkPublish) {
|
682
972
|
await publish();
|
973
|
+
} else {
|
974
|
+
await unpublish();
|
683
975
|
}
|
684
976
|
};
|
685
|
-
const isUnpublish = document?.status === "published";
|
686
|
-
if (isUnpublish) {
|
687
|
-
console.warn(["I18N"], "Bulk locale unpublish modal not implemented");
|
688
|
-
}
|
689
977
|
if (isDraftRelationConfirmationOpen) {
|
690
978
|
return {
|
691
979
|
label: formatMessage({
|
@@ -720,20 +1008,21 @@ const BulkLocalePublishAction = ({
|
|
720
1008
|
}
|
721
1009
|
};
|
722
1010
|
}
|
1011
|
+
const hasPermission = selectedRows.map(({ locale }) => locale).every((locale) => canPublish.includes(locale));
|
723
1012
|
return {
|
724
1013
|
label: formatMessage({
|
725
|
-
id: getTranslation("
|
726
|
-
defaultMessage: "Publish Multiple Locales
|
1014
|
+
id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? "publish" : "unpublish"}-title`),
|
1015
|
+
defaultMessage: `${isBulkPublish ? "Publish" : "Unpublish"} Multiple Locales`
|
727
1016
|
}),
|
728
|
-
|
729
|
-
|
1017
|
+
variant: isBulkPublish ? "secondary" : "danger",
|
1018
|
+
icon: isBulkPublish ? /* @__PURE__ */ jsxRuntime.jsx(icons.ListPlus, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {}),
|
1019
|
+
disabled: isOnPublishedTab || canPublish.length === 0,
|
730
1020
|
position: ["panel"],
|
731
|
-
variant: "secondary",
|
732
1021
|
dialog: {
|
733
1022
|
type: "modal",
|
734
1023
|
title: formatMessage({
|
735
|
-
id: getTranslation("
|
736
|
-
defaultMessage: "Publish Multiple Locales
|
1024
|
+
id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? "publish" : "unpublish"}-title`),
|
1025
|
+
defaultMessage: `${isBulkPublish ? "Publish" : "Unpublish"} Multiple Locales`
|
737
1026
|
}),
|
738
1027
|
content: () => {
|
739
1028
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -752,28 +1041,35 @@ const BulkLocalePublishAction = ({
|
|
752
1041
|
validationErrors,
|
753
1042
|
headers,
|
754
1043
|
rows,
|
755
|
-
localesMetadata
|
1044
|
+
localesMetadata,
|
1045
|
+
action: action ?? "bulk-publish"
|
756
1046
|
}
|
757
1047
|
)
|
758
1048
|
}
|
759
1049
|
);
|
760
1050
|
},
|
761
|
-
footer: () => /* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1051
|
+
footer: () => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Footer, { justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
|
762
1052
|
designSystem.Button,
|
763
1053
|
{
|
764
1054
|
loading: isDraftRelationsLoading,
|
765
|
-
disabled:
|
1055
|
+
disabled: !hasPermission || localesForAction.length === 0,
|
766
1056
|
variant: "default",
|
767
1057
|
onClick: handleAction,
|
768
1058
|
children: formatMessage({
|
769
|
-
id: "app.utils.publish",
|
770
|
-
defaultMessage: "Publish"
|
1059
|
+
id: isBulkPublish ? "app.utils.publish" : "app.utils.unpublish",
|
1060
|
+
defaultMessage: isBulkPublish ? "Publish" : "Unpublish"
|
771
1061
|
})
|
772
1062
|
}
|
773
1063
|
) })
|
774
1064
|
}
|
775
1065
|
};
|
776
1066
|
};
|
1067
|
+
const BulkLocalePublishAction = (props) => {
|
1068
|
+
return BulkLocaleAction({ action: "bulk-publish", ...props });
|
1069
|
+
};
|
1070
|
+
const BulkLocaleUnpublishAction = (props) => {
|
1071
|
+
return BulkLocaleAction({ action: "bulk-unpublish", ...props });
|
1072
|
+
};
|
777
1073
|
const StyledTrash = styledComponents.styled(icons.Trash)`
|
778
1074
|
path {
|
779
1075
|
fill: currentColor;
|
@@ -830,16 +1126,9 @@ const UnpublishModalAdditionalInfo = () => {
|
|
830
1126
|
}
|
831
1127
|
) });
|
832
1128
|
};
|
833
|
-
const Initializer = ({ setPlugin }) => {
|
834
|
-
const setPluginRef = React__namespace.useRef(setPlugin);
|
835
|
-
React__namespace.useEffect(() => {
|
836
|
-
setPluginRef.current(pluginId);
|
837
|
-
}, []);
|
838
|
-
return null;
|
839
|
-
};
|
840
1129
|
const LocalePicker = () => {
|
841
1130
|
const { formatMessage } = reactIntl.useIntl();
|
842
|
-
const [{ query }, setQuery] = strapiAdmin.useQueryParams();
|
1131
|
+
const [{ query: query2 }, setQuery] = strapiAdmin.useQueryParams();
|
843
1132
|
const { hasI18n, canRead, canCreate } = useI18n();
|
844
1133
|
const { data: locales = [] } = useGetLocalesQuery(void 0, {
|
845
1134
|
skip: !hasI18n
|
@@ -849,25 +1138,25 @@ const LocalePicker = () => {
|
|
849
1138
|
setQuery(
|
850
1139
|
{
|
851
1140
|
page: 1,
|
852
|
-
plugins: { ...
|
1141
|
+
plugins: { ...query2.plugins, i18n: { locale: code } }
|
853
1142
|
},
|
854
1143
|
"push",
|
855
1144
|
replace
|
856
1145
|
);
|
857
1146
|
},
|
858
|
-
[
|
1147
|
+
[query2.plugins, setQuery]
|
859
1148
|
);
|
860
1149
|
React__namespace.useEffect(() => {
|
861
1150
|
if (!Array.isArray(locales) || !hasI18n) {
|
862
1151
|
return;
|
863
1152
|
}
|
864
|
-
const currentDesiredLocale =
|
1153
|
+
const currentDesiredLocale = query2.plugins?.i18n?.locale;
|
865
1154
|
const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
|
866
1155
|
const defaultLocale = locales.find((locale) => locale.isDefault);
|
867
1156
|
if (!doesLocaleExist && defaultLocale?.code) {
|
868
1157
|
handleChange(defaultLocale.code, true);
|
869
1158
|
}
|
870
|
-
}, [hasI18n, handleChange, locales,
|
1159
|
+
}, [hasI18n, handleChange, locales, query2.plugins?.i18n?.locale]);
|
871
1160
|
if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
|
872
1161
|
return null;
|
873
1162
|
}
|
@@ -882,7 +1171,7 @@ const LocalePicker = () => {
|
|
882
1171
|
id: getTranslation("actions.select-locale"),
|
883
1172
|
defaultMessage: "Select locale"
|
884
1173
|
}),
|
885
|
-
value:
|
1174
|
+
value: query2.plugins?.i18n?.locale || locales.find((locale) => locale.isDefault)?.code,
|
886
1175
|
onChange: handleChange,
|
887
1176
|
children: displayedLocales.map((locale) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: locale.code, children: locale.name }, locale.id))
|
888
1177
|
}
|
@@ -1000,54 +1289,13 @@ const LocaleListCell = ({
|
|
1000
1289
|
return locale.name;
|
1001
1290
|
}).toSorted((a, b) => formatter.compare(a, b));
|
1002
1291
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Popover.Root, { children: [
|
1003
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxRuntime.jsxs(
|
1004
|
-
|
1005
|
-
{
|
1006
|
-
|
1007
|
-
alignItems: "center",
|
1008
|
-
justifyContent: "center",
|
1009
|
-
height: "3.2rem",
|
1010
|
-
width: "3.2rem",
|
1011
|
-
children: [
|
1012
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", ellipsis: true, children: localesForDocument.join(", ") }),
|
1013
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(icons.CaretDown, {}) })
|
1014
|
-
]
|
1015
|
-
}
|
1016
|
-
) }) }),
|
1292
|
+
/* @__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: [
|
1293
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", ellipsis: true, marginRight: 2, children: localesForDocument.join(", ") }),
|
1294
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(icons.CaretDown, { width: "1.2rem", height: "1.2rem" }) })
|
1295
|
+
] }) }) }),
|
1017
1296
|
/* @__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)) }) })
|
1018
1297
|
] });
|
1019
1298
|
};
|
1020
|
-
const Button = styledComponents.styled.button`
|
1021
|
-
width: 100%;
|
1022
|
-
|
1023
|
-
svg {
|
1024
|
-
> g,
|
1025
|
-
path {
|
1026
|
-
fill: ${({ theme }) => theme.colors.neutral500};
|
1027
|
-
}
|
1028
|
-
}
|
1029
|
-
&:hover {
|
1030
|
-
svg {
|
1031
|
-
> g,
|
1032
|
-
path {
|
1033
|
-
fill: ${({ theme }) => theme.colors.neutral600};
|
1034
|
-
}
|
1035
|
-
}
|
1036
|
-
}
|
1037
|
-
&:active {
|
1038
|
-
svg {
|
1039
|
-
> g,
|
1040
|
-
path {
|
1041
|
-
fill: ${({ theme }) => theme.colors.neutral400};
|
1042
|
-
}
|
1043
|
-
}
|
1044
|
-
}
|
1045
|
-
`;
|
1046
|
-
const ActionWrapper = styledComponents.styled(designSystem.Flex)`
|
1047
|
-
svg {
|
1048
|
-
height: 0.4rem;
|
1049
|
-
}
|
1050
|
-
`;
|
1051
1299
|
const addColumnToTableHook = ({ displayedHeaders, layout }) => {
|
1052
1300
|
const { options } = layout;
|
1053
1301
|
const isFieldLocalized = doesPluginOptionsHaveI18nLocalized(options) ? options.i18n.localized : false;
|
@@ -1173,9 +1421,6 @@ const localeMiddleware = (ctx) => (next) => (permissions) => {
|
|
1173
1421
|
return next(revisedPermissions);
|
1174
1422
|
};
|
1175
1423
|
const prefixPluginTranslations = (trad, pluginId2) => {
|
1176
|
-
if (!pluginId2) {
|
1177
|
-
throw new TypeError("pluginId can't be empty");
|
1178
|
-
}
|
1179
1424
|
return Object.keys(trad).reduce((acc, current) => {
|
1180
1425
|
acc[`${pluginId2}.${current}`] = trad[current];
|
1181
1426
|
return acc;
|
@@ -1228,8 +1473,6 @@ const index = {
|
|
1228
1473
|
app.addRBACMiddleware([localeMiddleware]);
|
1229
1474
|
app.registerPlugin({
|
1230
1475
|
id: pluginId,
|
1231
|
-
initializer: Initializer,
|
1232
|
-
isReady: false,
|
1233
1476
|
name: pluginId
|
1234
1477
|
});
|
1235
1478
|
},
|
@@ -1247,11 +1490,11 @@ const index = {
|
|
1247
1490
|
},
|
1248
1491
|
id: "internationalization",
|
1249
1492
|
to: "internationalization",
|
1250
|
-
Component: () => Promise.resolve().then(() => require("./SettingsPage-
|
1493
|
+
Component: () => Promise.resolve().then(() => require("./SettingsPage-D0hqaut-.js")).then((mod) => ({ default: mod.ProtectedSettingsPage })),
|
1251
1494
|
permissions: PERMISSIONS.accessMain
|
1252
1495
|
});
|
1253
1496
|
const contentManager = app.getPlugin("content-manager");
|
1254
|
-
contentManager.apis.addDocumentHeaderAction([LocalePickerAction]);
|
1497
|
+
contentManager.apis.addDocumentHeaderAction([LocalePickerAction, FillFromAnotherLocaleAction]);
|
1255
1498
|
contentManager.apis.addDocumentAction((actions) => {
|
1256
1499
|
const indexOfDeleteAction = actions.findIndex((action) => action.type === "delete");
|
1257
1500
|
actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);
|
@@ -1259,6 +1502,7 @@ const index = {
|
|
1259
1502
|
});
|
1260
1503
|
contentManager.apis.addDocumentAction((actions) => {
|
1261
1504
|
actions.splice(2, 0, BulkLocalePublishAction);
|
1505
|
+
actions.splice(5, 0, BulkLocaleUnpublishAction);
|
1262
1506
|
return actions;
|
1263
1507
|
});
|
1264
1508
|
contentManager.injectComponent("listView", "actions", {
|
@@ -1364,7 +1608,7 @@ const index = {
|
|
1364
1608
|
async registerTrads({ locales }) {
|
1365
1609
|
const importedTrads = await Promise.all(
|
1366
1610
|
locales.map((locale) => {
|
1367
|
-
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-
|
1611
|
+
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`).then(({ default: data }) => {
|
1368
1612
|
return {
|
1369
1613
|
data: prefixPluginTranslations(data, pluginId),
|
1370
1614
|
locale
|
@@ -1388,4 +1632,4 @@ exports.useDeleteLocaleMutation = useDeleteLocaleMutation;
|
|
1388
1632
|
exports.useGetDefaultLocalesQuery = useGetDefaultLocalesQuery;
|
1389
1633
|
exports.useGetLocalesQuery = useGetLocalesQuery;
|
1390
1634
|
exports.useUpdateLocaleMutation = useUpdateLocaleMutation;
|
1391
|
-
//# sourceMappingURL=index-
|
1635
|
+
//# sourceMappingURL=index-46DNtLCn.js.map
|