@strapi/i18n 0.0.0-experimental.d954d57341a6623992a0d211daaec8e245c3517d → 0.0.0-experimental.dad3c50630ca4fd9eccdcbe549ee632fc572e23d
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-Dsi2qGtq.mjs → SettingsPage-B6QDUmu9.mjs} +17 -12
- package/dist/_chunks/SettingsPage-B6QDUmu9.mjs.map +1 -0
- package/dist/_chunks/{SettingsPage-VN7sTzkb.js → SettingsPage-BsHtr3lV.js} +18 -14
- package/dist/_chunks/SettingsPage-BsHtr3lV.js.map +1 -0
- package/dist/_chunks/{en-Kv6y9zPQ.js → en-BKBz3tro.js} +12 -3
- package/dist/_chunks/en-BKBz3tro.js.map +1 -0
- package/dist/_chunks/{en-18tWw4P6.mjs → en-DlXfy6Gy.mjs} +12 -3
- package/dist/_chunks/en-DlXfy6Gy.mjs.map +1 -0
- package/dist/_chunks/{index-kedPlCo6.js → index-3XgwXL6T.js} +459 -225
- package/dist/_chunks/index-3XgwXL6T.js.map +1 -0
- package/dist/_chunks/{index-DhtjJYrx.mjs → index-iEQ79W05.mjs} +454 -219
- package/dist/_chunks/index-iEQ79W05.mjs.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/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/components/LocaleListCell.d.ts +4 -4
- package/dist/admin/src/contentReleasesHooks/releaseDetailsView.d.ts +9 -5
- package/dist/admin/src/utils/clean.d.ts +4 -0
- package/dist/admin/src/utils/schemas.d.ts +1 -0
- package/dist/server/index.js +418 -478
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +419 -478
- 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 +13 -13
- package/dist/_chunks/SettingsPage-Dsi2qGtq.mjs.map +0 -1
- package/dist/_chunks/SettingsPage-VN7sTzkb.js.map +0 -1
- package/dist/_chunks/en-18tWw4P6.mjs.map +0 -1
- package/dist/_chunks/en-Kv6y9zPQ.js.map +0 -1
- package/dist/_chunks/index-DhtjJYrx.mjs.map +0 -1
- package/dist/_chunks/index-kedPlCo6.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");
|
@@ -14,8 +15,7 @@ const qs = require("qs");
|
|
14
15
|
const omit = require("lodash/omit");
|
15
16
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
16
17
|
function _interopNamespace(e) {
|
17
|
-
if (e && e.__esModule)
|
18
|
-
return e;
|
18
|
+
if (e && e.__esModule) return e;
|
19
19
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
20
20
|
if (e) {
|
21
21
|
for (const k in e) {
|
@@ -36,13 +36,20 @@ const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
|
|
36
36
|
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
37
37
|
const qs__namespace = /* @__PURE__ */ _interopNamespace(qs);
|
38
38
|
const omit__default = /* @__PURE__ */ _interopDefault(omit);
|
39
|
-
const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
39
|
+
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
40
40
|
const v = glob[path];
|
41
41
|
if (v) {
|
42
42
|
return typeof v === "function" ? v() : Promise.resolve(v);
|
43
43
|
}
|
44
44
|
return new Promise((_, reject) => {
|
45
|
-
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
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
|
+
);
|
46
53
|
});
|
47
54
|
};
|
48
55
|
const pluginId = "i18n";
|
@@ -160,7 +167,7 @@ const useI18n = () => {
|
|
160
167
|
model: params.slug
|
161
168
|
},
|
162
169
|
{
|
163
|
-
skip:
|
170
|
+
skip: true
|
164
171
|
}
|
165
172
|
);
|
166
173
|
if (doesPluginOptionsHaveI18nLocalized(schema?.pluginOptions)) {
|
@@ -240,10 +247,94 @@ const relationsApi = i18nApi.injectEndpoints({
|
|
240
247
|
})
|
241
248
|
});
|
242
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
|
+
};
|
243
330
|
const isErrorMessageDescriptor = (object) => {
|
244
331
|
return typeof object === "object" && object !== null && "id" in object && "defaultMessage" in object;
|
245
332
|
};
|
246
|
-
const EntryValidationText = ({
|
333
|
+
const EntryValidationText = ({
|
334
|
+
status = "draft",
|
335
|
+
validationErrors,
|
336
|
+
action
|
337
|
+
}) => {
|
247
338
|
const { formatMessage } = reactIntl.useIntl();
|
248
339
|
const getErrorStr = (key, value) => {
|
249
340
|
if (typeof value === "string") {
|
@@ -277,30 +368,63 @@ const EntryValidationText = ({ status = "draft", validationErrors }) => {
|
|
277
368
|
) })
|
278
369
|
] });
|
279
370
|
}
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
371
|
+
const getStatusMessage = () => {
|
372
|
+
if (action === "bulk-publish") {
|
373
|
+
if (status === "published") {
|
374
|
+
return {
|
375
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
376
|
+
text: formatMessage({
|
377
|
+
id: "content-manager.bulk-publish.already-published",
|
378
|
+
defaultMessage: "Already Published"
|
379
|
+
}),
|
380
|
+
textColor: "success600",
|
381
|
+
fontWeight: "bold"
|
382
|
+
};
|
383
|
+
} else if (status === "modified") {
|
384
|
+
return {
|
385
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowsCounterClockwise, { fill: "alternative600" }),
|
386
|
+
text: formatMessage({
|
387
|
+
id: "app.utils.ready-to-publish-changes",
|
388
|
+
defaultMessage: "Ready to publish changes"
|
389
|
+
})
|
390
|
+
};
|
391
|
+
} else {
|
392
|
+
return {
|
393
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
394
|
+
text: formatMessage({
|
395
|
+
id: "app.utils.ready-to-publish",
|
396
|
+
defaultMessage: "Ready to publish"
|
397
|
+
})
|
398
|
+
};
|
399
|
+
}
|
400
|
+
} else {
|
401
|
+
if (status === "draft") {
|
402
|
+
return {
|
403
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
404
|
+
text: formatMessage({
|
405
|
+
id: "content-manager.bulk-unpublish.already-unpublished",
|
406
|
+
defaultMessage: "Already Unpublished"
|
407
|
+
}),
|
408
|
+
textColor: "success600",
|
409
|
+
fontWeight: "bold"
|
410
|
+
};
|
411
|
+
} else {
|
412
|
+
return {
|
413
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
414
|
+
text: formatMessage({
|
415
|
+
id: "app.utils.ready-to-unpublish-changes",
|
416
|
+
defaultMessage: "Ready to unpublish"
|
417
|
+
}),
|
418
|
+
textColor: "success600",
|
419
|
+
fontWeight: "bold"
|
420
|
+
};
|
421
|
+
}
|
422
|
+
}
|
423
|
+
};
|
424
|
+
const { icon, text, textColor = "success600", fontWeight = "normal" } = getStatusMessage();
|
298
425
|
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
|
-
}) })
|
426
|
+
icon,
|
427
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor, fontWeight, children: text })
|
304
428
|
] });
|
305
429
|
};
|
306
430
|
const BoldChunk = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
|
@@ -308,7 +432,8 @@ const BulkLocaleActionModal = ({
|
|
308
432
|
headers,
|
309
433
|
rows,
|
310
434
|
localesMetadata,
|
311
|
-
validationErrors = {}
|
435
|
+
validationErrors = {},
|
436
|
+
action
|
312
437
|
}) => {
|
313
438
|
const { formatMessage } = reactIntl.useIntl();
|
314
439
|
const selectedRows = strapiAdmin.useTable(
|
@@ -321,27 +446,29 @@ const BulkLocaleActionModal = ({
|
|
321
446
|
return acc;
|
322
447
|
}, {});
|
323
448
|
const localesWithErrors = Object.keys(validationErrors);
|
324
|
-
const
|
449
|
+
const publishedCount = selectedRows.filter(
|
325
450
|
({ locale }) => currentStatusByLocale[locale] === "published"
|
326
451
|
).length;
|
327
|
-
const
|
452
|
+
const draftCount = selectedRows.filter(
|
328
453
|
({ locale }) => (currentStatusByLocale[locale] === "draft" || currentStatusByLocale[locale] === "modified") && !localesWithErrors.includes(locale)
|
329
454
|
).length;
|
330
455
|
const withErrorsCount = localesWithErrors.length;
|
456
|
+
const messageId = action === "bulk-publish" ? "content-manager.containers.list.selectedEntriesModal.selectedCount.publish" : "content-manager.containers.list.selectedEntriesModal.selectedCount.unpublish";
|
457
|
+
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
458
|
return formatMessage(
|
332
459
|
{
|
333
|
-
id:
|
334
|
-
defaultMessage
|
460
|
+
id: messageId,
|
461
|
+
defaultMessage
|
335
462
|
},
|
336
463
|
{
|
337
464
|
withErrorsCount,
|
338
|
-
|
339
|
-
|
465
|
+
draftCount,
|
466
|
+
publishedCount,
|
340
467
|
b: BoldChunk
|
341
468
|
}
|
342
469
|
);
|
343
470
|
};
|
344
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
471
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Body, { children: [
|
345
472
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: getFormattedCountMessage() }),
|
346
473
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Content, { children: [
|
347
474
|
/* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Head, { children: [
|
@@ -362,13 +489,12 @@ const BulkLocaleActionModal = ({
|
|
362
489
|
paddingRight: "6px",
|
363
490
|
paddingTop: "2px",
|
364
491
|
paddingBottom: "2px",
|
365
|
-
showBullet: false,
|
366
492
|
size: "S",
|
367
493
|
variant: statusVariant,
|
368
494
|
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
369
495
|
}
|
370
496
|
) }) }),
|
371
|
-
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(EntryValidationText, { validationErrors: error, status }) }),
|
497
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(EntryValidationText, { validationErrors: error, status, action }) }),
|
372
498
|
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
373
499
|
designSystem.IconButton,
|
374
500
|
{
|
@@ -385,7 +511,7 @@ const BulkLocaleActionModal = ({
|
|
385
511
|
name: locale
|
386
512
|
}
|
387
513
|
),
|
388
|
-
|
514
|
+
variant: "ghost",
|
389
515
|
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {})
|
390
516
|
}
|
391
517
|
) })
|
@@ -394,6 +520,47 @@ const BulkLocaleActionModal = ({
|
|
394
520
|
] }) })
|
395
521
|
] });
|
396
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
|
+
};
|
397
564
|
const LocalePickerAction = ({
|
398
565
|
document,
|
399
566
|
meta,
|
@@ -402,74 +569,77 @@ const LocalePickerAction = ({
|
|
402
569
|
documentId
|
403
570
|
}) => {
|
404
571
|
const { formatMessage } = reactIntl.useIntl();
|
405
|
-
const [{ query }, setQuery] = strapiAdmin.useQueryParams();
|
572
|
+
const [{ query: query2 }, setQuery] = strapiAdmin.useQueryParams();
|
406
573
|
const { hasI18n, canCreate, canRead } = useI18n();
|
407
574
|
const { data: locales = [] } = useGetLocalesQuery();
|
408
|
-
const
|
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
|
+
});
|
409
582
|
const handleSelect = React__namespace.useCallback(
|
410
583
|
(value) => {
|
411
584
|
setQuery({
|
412
585
|
plugins: {
|
413
|
-
...
|
586
|
+
...query2.plugins,
|
414
587
|
i18n: {
|
415
588
|
locale: value
|
416
589
|
}
|
417
590
|
}
|
418
591
|
});
|
419
592
|
},
|
420
|
-
[
|
593
|
+
[query2.plugins, setQuery]
|
421
594
|
);
|
422
595
|
React__namespace.useEffect(() => {
|
423
596
|
if (!Array.isArray(locales) || !hasI18n) {
|
424
597
|
return;
|
425
598
|
}
|
426
|
-
const currentDesiredLocale = query.plugins?.i18n?.locale;
|
427
599
|
const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
|
428
600
|
const defaultLocale = locales.find((locale) => locale.isDefault);
|
429
601
|
if (!doesLocaleExist && defaultLocale?.code) {
|
430
602
|
handleSelect(defaultLocale.code);
|
431
603
|
}
|
432
|
-
}, [handleSelect, hasI18n, locales,
|
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
|
+
];
|
433
610
|
if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
|
434
611
|
return null;
|
435
612
|
}
|
436
|
-
const
|
437
|
-
|
438
|
-
|
439
|
-
...meta?.availableLocales ?? []
|
440
|
-
];
|
613
|
+
const displayedLocales = locales.filter((locale) => {
|
614
|
+
return canRead.includes(locale.code);
|
615
|
+
});
|
441
616
|
return {
|
442
617
|
label: formatMessage({
|
443
618
|
id: getTranslation("Settings.locales.modal.locales.label"),
|
444
619
|
defaultMessage: "Locales"
|
445
620
|
}),
|
446
|
-
options:
|
621
|
+
options: displayedLocales.map((locale) => {
|
622
|
+
const entryWithLocaleExists = allCurrentLocales.some((doc) => doc.locale === locale.code);
|
447
623
|
const currentLocaleDoc = allCurrentLocales.find(
|
448
624
|
(doc) => "locale" in doc ? doc.locale === locale.code : false
|
449
625
|
);
|
450
|
-
const
|
451
|
-
const permissionsToCheck = currentLocaleDoc ? canCreate : canRead;
|
452
|
-
const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
|
626
|
+
const permissionsToCheck = currentLocaleDoc ? canRead : canCreate;
|
453
627
|
return {
|
454
628
|
disabled: !permissionsToCheck.includes(locale.code),
|
455
629
|
value: locale.code,
|
456
|
-
label:
|
457
|
-
|
458
|
-
designSystem.Status,
|
630
|
+
label: /* @__PURE__ */ jsxRuntime.jsx(
|
631
|
+
LocaleOption,
|
459
632
|
{
|
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) })
|
633
|
+
isDraftAndPublishEnabled: !!schema?.options?.draftAndPublish,
|
634
|
+
locale,
|
635
|
+
status: currentLocaleDoc?.status,
|
636
|
+
entryExists: entryWithLocaleExists
|
469
637
|
}
|
470
|
-
)
|
638
|
+
),
|
639
|
+
startIcon: !entryWithLocaleExists ? /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}) : null
|
471
640
|
};
|
472
641
|
}),
|
642
|
+
customizeContent: () => currentLocale?.name,
|
473
643
|
onSelect: handleSelect,
|
474
644
|
value: currentLocale
|
475
645
|
};
|
@@ -485,6 +655,99 @@ const getDocumentStatus = (document, meta) => {
|
|
485
655
|
}
|
486
656
|
return docStatus;
|
487
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
|
+
};
|
488
751
|
const DeleteLocaleAction = ({
|
489
752
|
document,
|
490
753
|
documentId,
|
@@ -496,16 +759,23 @@ const DeleteLocaleAction = ({
|
|
496
759
|
const { toggleNotification } = strapiAdmin.useNotification();
|
497
760
|
const { delete: deleteAction } = strapiAdmin$1.unstable_useDocumentActions();
|
498
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);
|
499
766
|
if (!hasI18n) {
|
500
767
|
return null;
|
501
768
|
}
|
502
769
|
return {
|
503
770
|
disabled: document?.locale && !canDelete.includes(document.locale) || !document || !document.id,
|
504
771
|
position: ["header", "table-row"],
|
505
|
-
label: formatMessage(
|
506
|
-
|
507
|
-
|
508
|
-
|
772
|
+
label: formatMessage(
|
773
|
+
{
|
774
|
+
id: getTranslation("actions.delete.label"),
|
775
|
+
defaultMessage: "Delete entry ({locale})"
|
776
|
+
},
|
777
|
+
{ locale: locale && locale.name }
|
778
|
+
),
|
509
779
|
icon: /* @__PURE__ */ jsxRuntime.jsx(StyledTrash, {}),
|
510
780
|
variant: "danger",
|
511
781
|
dialog: {
|
@@ -522,7 +792,12 @@ const DeleteLocaleAction = ({
|
|
522
792
|
}) })
|
523
793
|
] }),
|
524
794
|
onConfirm: async () => {
|
525
|
-
|
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) {
|
526
801
|
console.error(
|
527
802
|
"You're trying to delete a document without an id or locale, this is likely a bug with Strapi. Please open an issue."
|
528
803
|
);
|
@@ -548,37 +823,39 @@ const DeleteLocaleAction = ({
|
|
548
823
|
}
|
549
824
|
};
|
550
825
|
};
|
551
|
-
const
|
552
|
-
document
|
826
|
+
const BulkLocaleAction = ({
|
827
|
+
document,
|
553
828
|
documentId,
|
554
829
|
model,
|
555
|
-
collectionType
|
830
|
+
collectionType,
|
831
|
+
action
|
556
832
|
}) => {
|
557
|
-
const
|
558
|
-
const [{ query }] = strapiAdmin.useQueryParams();
|
559
|
-
const params = React__namespace.useMemo(() => strapiAdmin$1.buildValidParams(query), [query]);
|
560
|
-
const
|
833
|
+
const locale = document?.locale ?? null;
|
834
|
+
const [{ query: query$1 }] = strapiAdmin.useQueryParams();
|
835
|
+
const params = React__namespace.useMemo(() => strapiAdmin$1.buildValidParams(query$1), [query$1]);
|
836
|
+
const isOnPublishedTab = query$1.status === "published";
|
561
837
|
const { formatMessage } = reactIntl.useIntl();
|
562
838
|
const { hasI18n, canPublish } = useI18n();
|
563
839
|
const { toggleNotification } = strapiAdmin.useNotification();
|
564
840
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
565
841
|
const [selectedRows, setSelectedRows] = React__namespace.useState([]);
|
566
|
-
const [
|
567
|
-
const { publishMany: publishManyAction } = strapiAdmin$1.unstable_useDocumentActions();
|
568
|
-
const {
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
842
|
+
const [isDraftRelationConfirmationOpen, setIsDraftRelationConfirmationOpen] = React__namespace.useState(false);
|
843
|
+
const { publishMany: publishManyAction, unpublishMany: unpublishManyAction } = strapiAdmin$1.unstable_useDocumentActions();
|
844
|
+
const { schema, validate } = strapiAdmin$1.unstable_useDocument(
|
845
|
+
{
|
846
|
+
model,
|
847
|
+
collectionType,
|
848
|
+
documentId,
|
849
|
+
params: {
|
850
|
+
locale
|
851
|
+
}
|
852
|
+
},
|
853
|
+
{
|
854
|
+
// No need to fetch the document, the data is already available in the `document` prop
|
855
|
+
skip: true
|
579
856
|
}
|
580
|
-
|
581
|
-
const { data: localesMetadata = [] } = useGetLocalesQuery();
|
857
|
+
);
|
858
|
+
const { data: localesMetadata = [] } = useGetLocalesQuery(hasI18n ? void 0 : query.skipToken);
|
582
859
|
const headers = [
|
583
860
|
{
|
584
861
|
label: formatMessage({
|
@@ -603,18 +880,19 @@ const BulkLocalePublishAction = ({
|
|
603
880
|
}
|
604
881
|
];
|
605
882
|
const [rows, validationErrors] = React__namespace.useMemo(() => {
|
606
|
-
if (!document
|
883
|
+
if (!document) {
|
607
884
|
return [[], {}];
|
608
885
|
}
|
609
|
-
const
|
610
|
-
|
611
|
-
|
886
|
+
const localizations = document.localizations ?? [];
|
887
|
+
const locales = localizations.map((doc) => {
|
888
|
+
const { locale: locale2, status } = doc;
|
889
|
+
return { locale: locale2, status };
|
612
890
|
});
|
613
|
-
|
891
|
+
locales.unshift({
|
614
892
|
locale: document.locale,
|
615
893
|
status: document.status
|
616
894
|
});
|
617
|
-
const allDocuments = [document, ...
|
895
|
+
const allDocuments = [document, ...localizations];
|
618
896
|
const errors = allDocuments.reduce((errs, document2) => {
|
619
897
|
if (!document2) {
|
620
898
|
return errs;
|
@@ -625,14 +903,21 @@ const BulkLocalePublishAction = ({
|
|
625
903
|
}
|
626
904
|
return errs;
|
627
905
|
}, {});
|
628
|
-
return [
|
629
|
-
}, [document,
|
630
|
-
const
|
631
|
-
|
906
|
+
return [locales, errors];
|
907
|
+
}, [document, validate]);
|
908
|
+
const isBulkPublish = action === "bulk-publish";
|
909
|
+
const localesForAction = selectedRows.reduce((acc, selectedRow) => {
|
910
|
+
const isValidLocale = (
|
911
|
+
// Validation errors are irrelevant if we are trying to unpublish
|
912
|
+
!isBulkPublish || !Object.keys(validationErrors).includes(selectedRow.locale)
|
913
|
+
);
|
914
|
+
const shouldAddLocale = isBulkPublish ? selectedRow.status !== "published" && isValidLocale : selectedRow.status !== "draft" && isValidLocale;
|
915
|
+
if (shouldAddLocale) {
|
632
916
|
acc.push(selectedRow.locale);
|
633
917
|
}
|
634
918
|
return acc;
|
635
919
|
}, []);
|
920
|
+
const enableDraftRelationsCount = false;
|
636
921
|
const {
|
637
922
|
data: draftRelationsCount = 0,
|
638
923
|
isLoading: isDraftRelationsLoading,
|
@@ -641,10 +926,10 @@ const BulkLocalePublishAction = ({
|
|
641
926
|
{
|
642
927
|
model,
|
643
928
|
documentIds: [documentId],
|
644
|
-
locale:
|
929
|
+
locale: localesForAction
|
645
930
|
},
|
646
931
|
{
|
647
|
-
skip: !
|
932
|
+
skip: !enableDraftRelationsCount
|
648
933
|
}
|
649
934
|
);
|
650
935
|
React__namespace.useEffect(() => {
|
@@ -670,23 +955,32 @@ const BulkLocalePublishAction = ({
|
|
670
955
|
documentIds: [documentId],
|
671
956
|
params: {
|
672
957
|
...params,
|
673
|
-
locale:
|
958
|
+
locale: localesForAction
|
959
|
+
}
|
960
|
+
});
|
961
|
+
setSelectedRows([]);
|
962
|
+
};
|
963
|
+
const unpublish = async () => {
|
964
|
+
await unpublishManyAction({
|
965
|
+
model,
|
966
|
+
documentIds: [documentId],
|
967
|
+
params: {
|
968
|
+
...params,
|
969
|
+
locale: localesForAction
|
674
970
|
}
|
675
971
|
});
|
676
972
|
setSelectedRows([]);
|
677
973
|
};
|
678
974
|
const handleAction = async () => {
|
679
975
|
if (draftRelationsCount > 0) {
|
680
|
-
|
681
|
-
} else {
|
976
|
+
setIsDraftRelationConfirmationOpen(true);
|
977
|
+
} else if (isBulkPublish) {
|
682
978
|
await publish();
|
979
|
+
} else {
|
980
|
+
await unpublish();
|
683
981
|
}
|
684
982
|
};
|
685
|
-
|
686
|
-
if (isUnpublish) {
|
687
|
-
console.warn(["I18N"], "Bulk locale unpublish modal not implemented");
|
688
|
-
}
|
689
|
-
if (isConfirmationOpen) {
|
983
|
+
if (isDraftRelationConfirmationOpen) {
|
690
984
|
return {
|
691
985
|
label: formatMessage({
|
692
986
|
id: "app.components.ConfirmDialog.title",
|
@@ -695,11 +989,11 @@ const BulkLocalePublishAction = ({
|
|
695
989
|
variant: "danger",
|
696
990
|
dialog: {
|
697
991
|
onCancel: () => {
|
698
|
-
|
992
|
+
setIsDraftRelationConfirmationOpen(false);
|
699
993
|
},
|
700
994
|
onConfirm: async () => {
|
701
995
|
await publish();
|
702
|
-
|
996
|
+
setIsDraftRelationConfirmationOpen(false);
|
703
997
|
},
|
704
998
|
type: "dialog",
|
705
999
|
title: formatMessage({
|
@@ -709,27 +1003,32 @@ const BulkLocalePublishAction = ({
|
|
709
1003
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "center", gap: 2, children: [
|
710
1004
|
/* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, { width: "2.4rem", height: "2.4rem", fill: "danger600" }),
|
711
1005
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textAlign: "center", children: formatMessage({
|
712
|
-
id: "
|
713
|
-
defaultMessage: "
|
1006
|
+
id: getTranslation("CMEditViewBulkLocale.draft-relation-warning"),
|
1007
|
+
defaultMessage: "Some locales are related to draft entries. Publishing them could leave broken links in your app."
|
1008
|
+
}) }),
|
1009
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textAlign: "center", children: formatMessage({
|
1010
|
+
id: getTranslation("CMEditViewBulkLocale.continue-confirmation"),
|
1011
|
+
defaultMessage: "Are you sure you want to continue?"
|
714
1012
|
}) })
|
715
1013
|
] })
|
716
1014
|
}
|
717
1015
|
};
|
718
1016
|
}
|
1017
|
+
const hasPermission = selectedRows.map(({ locale: locale2 }) => locale2).every((locale2) => canPublish.includes(locale2));
|
719
1018
|
return {
|
720
1019
|
label: formatMessage({
|
721
|
-
id: getTranslation("
|
722
|
-
defaultMessage: "Publish Multiple Locales
|
1020
|
+
id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? "publish" : "unpublish"}-title`),
|
1021
|
+
defaultMessage: `${isBulkPublish ? "Publish" : "Unpublish"} Multiple Locales`
|
723
1022
|
}),
|
724
|
-
|
725
|
-
|
1023
|
+
variant: isBulkPublish ? "secondary" : "danger",
|
1024
|
+
icon: isBulkPublish ? /* @__PURE__ */ jsxRuntime.jsx(icons.ListPlus, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {}),
|
1025
|
+
disabled: isOnPublishedTab || canPublish.length === 0,
|
726
1026
|
position: ["panel"],
|
727
|
-
variant: "secondary",
|
728
1027
|
dialog: {
|
729
1028
|
type: "modal",
|
730
1029
|
title: formatMessage({
|
731
|
-
id: getTranslation("
|
732
|
-
defaultMessage: "Publish Multiple Locales
|
1030
|
+
id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? "publish" : "unpublish"}-title`),
|
1031
|
+
defaultMessage: `${isBulkPublish ? "Publish" : "Unpublish"} Multiple Locales`
|
733
1032
|
}),
|
734
1033
|
content: () => {
|
735
1034
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
@@ -748,28 +1047,35 @@ const BulkLocalePublishAction = ({
|
|
748
1047
|
validationErrors,
|
749
1048
|
headers,
|
750
1049
|
rows,
|
751
|
-
localesMetadata
|
1050
|
+
localesMetadata,
|
1051
|
+
action: action ?? "bulk-publish"
|
752
1052
|
}
|
753
1053
|
)
|
754
1054
|
}
|
755
1055
|
);
|
756
1056
|
},
|
757
|
-
footer: () => /* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
1057
|
+
footer: () => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Footer, { justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
|
758
1058
|
designSystem.Button,
|
759
1059
|
{
|
760
1060
|
loading: isDraftRelationsLoading,
|
761
|
-
disabled:
|
1061
|
+
disabled: !hasPermission || localesForAction.length === 0,
|
762
1062
|
variant: "default",
|
763
1063
|
onClick: handleAction,
|
764
1064
|
children: formatMessage({
|
765
|
-
id: "app.utils.publish",
|
766
|
-
defaultMessage: "Publish"
|
1065
|
+
id: isBulkPublish ? "app.utils.publish" : "app.utils.unpublish",
|
1066
|
+
defaultMessage: isBulkPublish ? "Publish" : "Unpublish"
|
767
1067
|
})
|
768
1068
|
}
|
769
1069
|
) })
|
770
1070
|
}
|
771
1071
|
};
|
772
1072
|
};
|
1073
|
+
const BulkLocalePublishAction = (props) => {
|
1074
|
+
return BulkLocaleAction({ action: "bulk-publish", ...props });
|
1075
|
+
};
|
1076
|
+
const BulkLocaleUnpublishAction = (props) => {
|
1077
|
+
return BulkLocaleAction({ action: "bulk-unpublish", ...props });
|
1078
|
+
};
|
773
1079
|
const StyledTrash = styledComponents.styled(icons.Trash)`
|
774
1080
|
path {
|
775
1081
|
fill: currentColor;
|
@@ -826,16 +1132,9 @@ const UnpublishModalAdditionalInfo = () => {
|
|
826
1132
|
}
|
827
1133
|
) });
|
828
1134
|
};
|
829
|
-
const Initializer = ({ setPlugin }) => {
|
830
|
-
const setPluginRef = React__namespace.useRef(setPlugin);
|
831
|
-
React__namespace.useEffect(() => {
|
832
|
-
setPluginRef.current(pluginId);
|
833
|
-
}, []);
|
834
|
-
return null;
|
835
|
-
};
|
836
1135
|
const LocalePicker = () => {
|
837
1136
|
const { formatMessage } = reactIntl.useIntl();
|
838
|
-
const [{ query }, setQuery] = strapiAdmin.useQueryParams();
|
1137
|
+
const [{ query: query2 }, setQuery] = strapiAdmin.useQueryParams();
|
839
1138
|
const { hasI18n, canRead, canCreate } = useI18n();
|
840
1139
|
const { data: locales = [] } = useGetLocalesQuery(void 0, {
|
841
1140
|
skip: !hasI18n
|
@@ -845,25 +1144,25 @@ const LocalePicker = () => {
|
|
845
1144
|
setQuery(
|
846
1145
|
{
|
847
1146
|
page: 1,
|
848
|
-
plugins: { ...
|
1147
|
+
plugins: { ...query2.plugins, i18n: { locale: code } }
|
849
1148
|
},
|
850
1149
|
"push",
|
851
1150
|
replace
|
852
1151
|
);
|
853
1152
|
},
|
854
|
-
[
|
1153
|
+
[query2.plugins, setQuery]
|
855
1154
|
);
|
856
1155
|
React__namespace.useEffect(() => {
|
857
1156
|
if (!Array.isArray(locales) || !hasI18n) {
|
858
1157
|
return;
|
859
1158
|
}
|
860
|
-
const currentDesiredLocale =
|
1159
|
+
const currentDesiredLocale = query2.plugins?.i18n?.locale;
|
861
1160
|
const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
|
862
1161
|
const defaultLocale = locales.find((locale) => locale.isDefault);
|
863
1162
|
if (!doesLocaleExist && defaultLocale?.code) {
|
864
1163
|
handleChange(defaultLocale.code, true);
|
865
1164
|
}
|
866
|
-
}, [hasI18n, handleChange, locales,
|
1165
|
+
}, [hasI18n, handleChange, locales, query2.plugins?.i18n?.locale]);
|
867
1166
|
if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
|
868
1167
|
return null;
|
869
1168
|
}
|
@@ -878,7 +1177,7 @@ const LocalePicker = () => {
|
|
878
1177
|
id: getTranslation("actions.select-locale"),
|
879
1178
|
defaultMessage: "Select locale"
|
880
1179
|
}),
|
881
|
-
value:
|
1180
|
+
value: query2.plugins?.i18n?.locale || locales.find((locale) => locale.isDefault)?.code,
|
882
1181
|
onChange: handleChange,
|
883
1182
|
children: displayedLocales.map((locale) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: locale.code, children: locale.name }, locale.id))
|
884
1183
|
}
|
@@ -958,29 +1257,16 @@ const Span = styledComponents.styled(designSystem.Flex)`
|
|
958
1257
|
}
|
959
1258
|
}
|
960
1259
|
`;
|
961
|
-
const LocaleListCell = ({
|
962
|
-
documentId,
|
963
|
-
locale: currentLocale,
|
964
|
-
collectionType,
|
965
|
-
model
|
966
|
-
}) => {
|
967
|
-
const { meta, isLoading } = strapiAdmin$1.unstable_useDocument({
|
968
|
-
documentId,
|
969
|
-
collectionType,
|
970
|
-
model,
|
971
|
-
params: {
|
972
|
-
locale: currentLocale
|
973
|
-
}
|
974
|
-
});
|
1260
|
+
const LocaleListCell = ({ locale: currentLocale, localizations }) => {
|
975
1261
|
const { locale: language } = reactIntl.useIntl();
|
976
1262
|
const { data: locales = [] } = useGetLocalesQuery();
|
977
1263
|
const formatter = designSystem.useCollator(language, {
|
978
1264
|
sensitivity: "base"
|
979
1265
|
});
|
980
|
-
if (!Array.isArray(locales) ||
|
1266
|
+
if (!Array.isArray(locales) || !localizations) {
|
981
1267
|
return null;
|
982
1268
|
}
|
983
|
-
const availableLocales =
|
1269
|
+
const availableLocales = localizations.map((loc) => loc.locale);
|
984
1270
|
const localesForDocument = locales.reduce((acc, locale) => {
|
985
1271
|
const createdLocale = [currentLocale, ...availableLocales].find((loc) => {
|
986
1272
|
return loc === locale.code;
|
@@ -996,54 +1282,13 @@ const LocaleListCell = ({
|
|
996
1282
|
return locale.name;
|
997
1283
|
}).toSorted((a, b) => formatter.compare(a, b));
|
998
1284
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Popover.Root, { children: [
|
999
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxRuntime.jsxs(
|
1000
|
-
|
1001
|
-
{
|
1002
|
-
|
1003
|
-
alignItems: "center",
|
1004
|
-
justifyContent: "center",
|
1005
|
-
height: "3.2rem",
|
1006
|
-
width: "3.2rem",
|
1007
|
-
children: [
|
1008
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", ellipsis: true, children: localesForDocument.join(", ") }),
|
1009
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(icons.CaretDown, {}) })
|
1010
|
-
]
|
1011
|
-
}
|
1012
|
-
) }) }),
|
1285
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "ghost", type: "button", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { minWidth: "100%", alignItems: "center", justifyContent: "center", fontWeight: "regular", children: [
|
1286
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", ellipsis: true, marginRight: 2, children: localesForDocument.join(", ") }),
|
1287
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(icons.CaretDown, { width: "1.2rem", height: "1.2rem" }) })
|
1288
|
+
] }) }) }),
|
1013
1289
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Content, { sideOffset: 16, children: /* @__PURE__ */ jsxRuntime.jsx("ul", { children: localesForDocument.map((name) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 3, tag: "li", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: name }) }, name)) }) })
|
1014
1290
|
] });
|
1015
1291
|
};
|
1016
|
-
const Button = styledComponents.styled.button`
|
1017
|
-
width: 100%;
|
1018
|
-
|
1019
|
-
svg {
|
1020
|
-
> g,
|
1021
|
-
path {
|
1022
|
-
fill: ${({ theme }) => theme.colors.neutral500};
|
1023
|
-
}
|
1024
|
-
}
|
1025
|
-
&:hover {
|
1026
|
-
svg {
|
1027
|
-
> g,
|
1028
|
-
path {
|
1029
|
-
fill: ${({ theme }) => theme.colors.neutral600};
|
1030
|
-
}
|
1031
|
-
}
|
1032
|
-
}
|
1033
|
-
&:active {
|
1034
|
-
svg {
|
1035
|
-
> g,
|
1036
|
-
path {
|
1037
|
-
fill: ${({ theme }) => theme.colors.neutral400};
|
1038
|
-
}
|
1039
|
-
}
|
1040
|
-
}
|
1041
|
-
`;
|
1042
|
-
const ActionWrapper = styledComponents.styled(designSystem.Flex)`
|
1043
|
-
svg {
|
1044
|
-
height: 0.4rem;
|
1045
|
-
}
|
1046
|
-
`;
|
1047
1292
|
const addColumnToTableHook = ({ displayedHeaders, layout }) => {
|
1048
1293
|
const { options } = layout;
|
1049
1294
|
const isFieldLocalized = doesPluginOptionsHaveI18nLocalized(options) ? options.i18n.localized : false;
|
@@ -1072,18 +1317,11 @@ const addColumnToTableHook = ({ displayedHeaders, layout }) => {
|
|
1072
1317
|
const addLocaleToReleasesHook = ({ displayedHeaders = [] }) => {
|
1073
1318
|
return {
|
1074
1319
|
displayedHeaders: [
|
1075
|
-
|
1076
|
-
// ...displayedHeaders,
|
1320
|
+
...displayedHeaders,
|
1077
1321
|
{
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
label: {
|
1082
|
-
id: "content-releases.page.ReleaseDetails.table.header.label.locale",
|
1083
|
-
defaultMessage: "locale"
|
1084
|
-
},
|
1085
|
-
searchable: false,
|
1086
|
-
sortable: false
|
1322
|
+
label: {
|
1323
|
+
id: "content-releases.page.ReleaseDetails.table.header.label.locale",
|
1324
|
+
defaultMessage: "locale"
|
1087
1325
|
},
|
1088
1326
|
name: "locale"
|
1089
1327
|
}
|
@@ -1176,9 +1414,6 @@ const localeMiddleware = (ctx) => (next) => (permissions) => {
|
|
1176
1414
|
return next(revisedPermissions);
|
1177
1415
|
};
|
1178
1416
|
const prefixPluginTranslations = (trad, pluginId2) => {
|
1179
|
-
if (!pluginId2) {
|
1180
|
-
throw new TypeError("pluginId can't be empty");
|
1181
|
-
}
|
1182
1417
|
return Object.keys(trad).reduce((acc, current) => {
|
1183
1418
|
acc[`${pluginId2}.${current}`] = trad[current];
|
1184
1419
|
return acc;
|
@@ -1231,8 +1466,6 @@ const index = {
|
|
1231
1466
|
app.addRBACMiddleware([localeMiddleware]);
|
1232
1467
|
app.registerPlugin({
|
1233
1468
|
id: pluginId,
|
1234
|
-
initializer: Initializer,
|
1235
|
-
isReady: false,
|
1236
1469
|
name: pluginId
|
1237
1470
|
});
|
1238
1471
|
},
|
@@ -1250,11 +1483,11 @@ const index = {
|
|
1250
1483
|
},
|
1251
1484
|
id: "internationalization",
|
1252
1485
|
to: "internationalization",
|
1253
|
-
Component: () => Promise.resolve().then(() => require("./SettingsPage-
|
1486
|
+
Component: () => Promise.resolve().then(() => require("./SettingsPage-BsHtr3lV.js")).then((mod) => ({ default: mod.ProtectedSettingsPage })),
|
1254
1487
|
permissions: PERMISSIONS.accessMain
|
1255
1488
|
});
|
1256
1489
|
const contentManager = app.getPlugin("content-manager");
|
1257
|
-
contentManager.apis.addDocumentHeaderAction([LocalePickerAction]);
|
1490
|
+
contentManager.apis.addDocumentHeaderAction([LocalePickerAction, FillFromAnotherLocaleAction]);
|
1258
1491
|
contentManager.apis.addDocumentAction((actions) => {
|
1259
1492
|
const indexOfDeleteAction = actions.findIndex((action) => action.type === "delete");
|
1260
1493
|
actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);
|
@@ -1262,6 +1495,7 @@ const index = {
|
|
1262
1495
|
});
|
1263
1496
|
contentManager.apis.addDocumentAction((actions) => {
|
1264
1497
|
actions.splice(2, 0, BulkLocalePublishAction);
|
1498
|
+
actions.splice(5, 0, BulkLocaleUnpublishAction);
|
1265
1499
|
return actions;
|
1266
1500
|
});
|
1267
1501
|
contentManager.injectComponent("listView", "actions", {
|
@@ -1367,7 +1601,7 @@ const index = {
|
|
1367
1601
|
async registerTrads({ locales }) {
|
1368
1602
|
const importedTrads = await Promise.all(
|
1369
1603
|
locales.map((locale) => {
|
1370
|
-
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-
|
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 }) => {
|
1371
1605
|
return {
|
1372
1606
|
data: prefixPluginTranslations(data, pluginId),
|
1373
1607
|
locale
|
@@ -1391,4 +1625,4 @@ exports.useDeleteLocaleMutation = useDeleteLocaleMutation;
|
|
1391
1625
|
exports.useGetDefaultLocalesQuery = useGetDefaultLocalesQuery;
|
1392
1626
|
exports.useGetLocalesQuery = useGetLocalesQuery;
|
1393
1627
|
exports.useUpdateLocaleMutation = useUpdateLocaleMutation;
|
1394
|
-
//# sourceMappingURL=index-
|
1628
|
+
//# sourceMappingURL=index-3XgwXL6T.js.map
|