@strapi/i18n 0.0.0-experimental.25e22c6cc9bc6b35392bb55d09f641a0a65e7403 → 0.0.0-experimental.2bad311ac375d1115d085a9cee4fdbe11a455caf
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-VN7sTzkb.js → SettingsPage-CJOMVQv5.js} +15 -10
- package/dist/_chunks/SettingsPage-CJOMVQv5.js.map +1 -0
- package/dist/_chunks/{SettingsPage-Dsi2qGtq.mjs → SettingsPage-CnBFTsrq.mjs} +15 -10
- package/dist/_chunks/SettingsPage-CnBFTsrq.mjs.map +1 -0
- package/dist/_chunks/{en-18tWw4P6.mjs → en-BYRZFDBV.mjs} +11 -2
- package/dist/_chunks/en-BYRZFDBV.mjs.map +1 -0
- package/dist/_chunks/{en-Kv6y9zPQ.js → en-Dk9At9_Z.js} +11 -2
- package/dist/_chunks/en-Dk9At9_Z.js.map +1 -0
- package/dist/_chunks/{index-DhtjJYrx.mjs → index-BFk3nfTb.mjs} +416 -179
- package/dist/_chunks/index-BFk3nfTb.mjs.map +1 -0
- package/dist/_chunks/{index-kedPlCo6.js → index-C5SImSYG.js} +420 -183
- package/dist/_chunks/index-C5SImSYG.js.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/BulkLocaleActionModal.d.ts +2 -1
- package/dist/admin/src/components/CMHeaderActions.d.ts +29 -3
- 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 +62 -98
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +63 -99
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts +1 -4
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +15 -13
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +14 -10
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/permissions/actions.d.ts +14 -2
- package/dist/server/src/services/permissions/actions.d.ts.map +1 -1
- package/dist/server/src/services/permissions.d.ts +14 -2
- package/dist/server/src/services/permissions.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts +0 -2
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/_chunks/SettingsPage-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/services/entity-service-decorator.d.ts +0 -29
- package/dist/server/src/services/entity-service-decorator.d.ts.map +0 -1
- package/strapi-server.js +0 -3
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import get from "lodash/get";
|
|
2
2
|
import * as yup from "yup";
|
|
3
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
4
4
|
import * as React from "react";
|
|
5
|
-
import { Typography, Dialog, Field, Checkbox, Flex, Button
|
|
6
|
-
import { WarningCircle, Pencil, CrossCircle, CheckCircle, ArrowsCounterClockwise, Trash, ListPlus, Earth, EarthStriked, CaretDown } from "@strapi/icons";
|
|
5
|
+
import { Typography, Dialog, Field, Checkbox, Flex, Button, Modal, Box, Status, IconButton, Tooltip, SingleSelect, SingleSelectOption, VisuallyHidden, useCollator, Popover } from "@strapi/design-system";
|
|
6
|
+
import { WarningCircle, Pencil, CrossCircle, CheckCircle, ArrowsCounterClockwise, Trash, Plus, Download, ListPlus, Cross, Earth, EarthStriked, CaretDown } from "@strapi/icons";
|
|
7
7
|
import { useIntl } from "react-intl";
|
|
8
8
|
import { styled } from "styled-components";
|
|
9
|
-
import {
|
|
9
|
+
import { skipToken } from "@reduxjs/toolkit/query";
|
|
10
|
+
import { useAuth, adminApi, useTable, Table, useQueryParams, useForm, useNotification, useAPIErrorHandler } from "@strapi/admin/strapi-admin";
|
|
10
11
|
import { unstable_useDocument, unstable_useDocumentActions, buildValidParams } from "@strapi/content-manager/strapi-admin";
|
|
11
12
|
import { useParams, Link, useNavigate, matchPath } from "react-router-dom";
|
|
12
13
|
import * as qs from "qs";
|
|
@@ -77,11 +78,11 @@ const CheckboxConfirmation = ({
|
|
|
77
78
|
}) }) })
|
|
78
79
|
] }) }),
|
|
79
80
|
/* @__PURE__ */ jsxs(Dialog.Footer, { children: [
|
|
80
|
-
/* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button
|
|
81
|
+
/* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: formatMessage({
|
|
81
82
|
id: "components.popUpWarning.button.cancel",
|
|
82
83
|
defaultMessage: "No, cancel"
|
|
83
84
|
}) }) }),
|
|
84
|
-
/* @__PURE__ */ jsx(Dialog.Action, { children: /* @__PURE__ */ jsx(Button
|
|
85
|
+
/* @__PURE__ */ jsx(Dialog.Action, { children: /* @__PURE__ */ jsx(Button, { variant: "danger-light", onClick: handleConfirm, children: formatMessage({
|
|
85
86
|
id: getTranslation("CheckboxConfirmation.Modal.button-confirm"),
|
|
86
87
|
defaultMessage: "Yes, disable"
|
|
87
88
|
}) }) })
|
|
@@ -136,7 +137,7 @@ const useI18n = () => {
|
|
|
136
137
|
model: params.slug
|
|
137
138
|
},
|
|
138
139
|
{
|
|
139
|
-
skip:
|
|
140
|
+
skip: true
|
|
140
141
|
}
|
|
141
142
|
);
|
|
142
143
|
if (doesPluginOptionsHaveI18nLocalized(schema?.pluginOptions)) {
|
|
@@ -216,10 +217,94 @@ const relationsApi = i18nApi.injectEndpoints({
|
|
|
216
217
|
})
|
|
217
218
|
});
|
|
218
219
|
const { useGetManyDraftRelationCountQuery } = relationsApi;
|
|
220
|
+
const cleanData = (data, schema, components) => {
|
|
221
|
+
const cleanedData = removeFields(data, [
|
|
222
|
+
"createdAt",
|
|
223
|
+
"createdBy",
|
|
224
|
+
"updatedAt",
|
|
225
|
+
"updatedBy",
|
|
226
|
+
"id",
|
|
227
|
+
"documentId",
|
|
228
|
+
"publishedAt",
|
|
229
|
+
"strapi_stage",
|
|
230
|
+
"strapi_assignee",
|
|
231
|
+
"locale",
|
|
232
|
+
"status"
|
|
233
|
+
]);
|
|
234
|
+
const cleanedDataWithoutPasswordAndRelation = recursiveRemoveFieldTypes(
|
|
235
|
+
cleanedData,
|
|
236
|
+
schema,
|
|
237
|
+
components,
|
|
238
|
+
["relation", "password"]
|
|
239
|
+
);
|
|
240
|
+
return cleanedDataWithoutPasswordAndRelation;
|
|
241
|
+
};
|
|
242
|
+
const removeFields = (data, fields) => {
|
|
243
|
+
return Object.keys(data).reduce((acc, current) => {
|
|
244
|
+
if (fields.includes(current)) {
|
|
245
|
+
return acc;
|
|
246
|
+
}
|
|
247
|
+
acc[current] = data[current];
|
|
248
|
+
return acc;
|
|
249
|
+
}, {});
|
|
250
|
+
};
|
|
251
|
+
const recursiveRemoveFieldTypes = (data, schema, components, fields) => {
|
|
252
|
+
return Object.keys(data).reduce((acc, current) => {
|
|
253
|
+
const attribute = schema.attributes[current] ?? { type: void 0 };
|
|
254
|
+
if (fields.includes(attribute.type)) {
|
|
255
|
+
return acc;
|
|
256
|
+
}
|
|
257
|
+
if (attribute.type === "dynamiczone") {
|
|
258
|
+
acc[current] = data[current].map((componentValue, index2) => {
|
|
259
|
+
const { id: _, ...rest } = recursiveRemoveFieldTypes(
|
|
260
|
+
componentValue,
|
|
261
|
+
components[componentValue.__component],
|
|
262
|
+
components,
|
|
263
|
+
fields
|
|
264
|
+
);
|
|
265
|
+
return {
|
|
266
|
+
...rest,
|
|
267
|
+
__temp_key__: index2 + 1
|
|
268
|
+
};
|
|
269
|
+
});
|
|
270
|
+
} else if (attribute.type === "component") {
|
|
271
|
+
const { repeatable, component } = attribute;
|
|
272
|
+
if (repeatable) {
|
|
273
|
+
acc[current] = (data[current] ?? []).map((compoData, index2) => {
|
|
274
|
+
const { id: _, ...rest } = recursiveRemoveFieldTypes(
|
|
275
|
+
compoData,
|
|
276
|
+
components[component],
|
|
277
|
+
components,
|
|
278
|
+
fields
|
|
279
|
+
);
|
|
280
|
+
return {
|
|
281
|
+
...rest,
|
|
282
|
+
__temp_key__: index2 + 1
|
|
283
|
+
};
|
|
284
|
+
});
|
|
285
|
+
} else {
|
|
286
|
+
const { id: _, ...rest } = recursiveRemoveFieldTypes(
|
|
287
|
+
data[current] ?? {},
|
|
288
|
+
components[component],
|
|
289
|
+
components,
|
|
290
|
+
fields
|
|
291
|
+
);
|
|
292
|
+
acc[current] = rest;
|
|
293
|
+
}
|
|
294
|
+
} else {
|
|
295
|
+
acc[current] = data[current];
|
|
296
|
+
}
|
|
297
|
+
return acc;
|
|
298
|
+
}, {});
|
|
299
|
+
};
|
|
219
300
|
const isErrorMessageDescriptor = (object) => {
|
|
220
301
|
return typeof object === "object" && object !== null && "id" in object && "defaultMessage" in object;
|
|
221
302
|
};
|
|
222
|
-
const EntryValidationText = ({
|
|
303
|
+
const EntryValidationText = ({
|
|
304
|
+
status = "draft",
|
|
305
|
+
validationErrors,
|
|
306
|
+
action
|
|
307
|
+
}) => {
|
|
223
308
|
const { formatMessage } = useIntl();
|
|
224
309
|
const getErrorStr = (key, value) => {
|
|
225
310
|
if (typeof value === "string") {
|
|
@@ -253,30 +338,63 @@ const EntryValidationText = ({ status = "draft", validationErrors }) => {
|
|
|
253
338
|
) })
|
|
254
339
|
] });
|
|
255
340
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
341
|
+
const getStatusMessage = () => {
|
|
342
|
+
if (action === "bulk-publish") {
|
|
343
|
+
if (status === "published") {
|
|
344
|
+
return {
|
|
345
|
+
icon: /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
|
346
|
+
text: formatMessage({
|
|
347
|
+
id: "content-manager.bulk-publish.already-published",
|
|
348
|
+
defaultMessage: "Already Published"
|
|
349
|
+
}),
|
|
350
|
+
textColor: "success600",
|
|
351
|
+
fontWeight: "bold"
|
|
352
|
+
};
|
|
353
|
+
} else if (status === "modified") {
|
|
354
|
+
return {
|
|
355
|
+
icon: /* @__PURE__ */ jsx(ArrowsCounterClockwise, { fill: "alternative600" }),
|
|
356
|
+
text: formatMessage({
|
|
357
|
+
id: "app.utils.ready-to-publish-changes",
|
|
358
|
+
defaultMessage: "Ready to publish changes"
|
|
359
|
+
})
|
|
360
|
+
};
|
|
361
|
+
} else {
|
|
362
|
+
return {
|
|
363
|
+
icon: /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
|
364
|
+
text: formatMessage({
|
|
365
|
+
id: "app.utils.ready-to-publish",
|
|
366
|
+
defaultMessage: "Ready to publish"
|
|
367
|
+
})
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
} else {
|
|
371
|
+
if (status === "draft") {
|
|
372
|
+
return {
|
|
373
|
+
icon: /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
|
374
|
+
text: formatMessage({
|
|
375
|
+
id: "content-manager.bulk-unpublish.already-unpublished",
|
|
376
|
+
defaultMessage: "Already Unpublished"
|
|
377
|
+
}),
|
|
378
|
+
textColor: "success600",
|
|
379
|
+
fontWeight: "bold"
|
|
380
|
+
};
|
|
381
|
+
} else {
|
|
382
|
+
return {
|
|
383
|
+
icon: /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
|
384
|
+
text: formatMessage({
|
|
385
|
+
id: "app.utils.ready-to-unpublish-changes",
|
|
386
|
+
defaultMessage: "Ready to unpublish"
|
|
387
|
+
}),
|
|
388
|
+
textColor: "success600",
|
|
389
|
+
fontWeight: "bold"
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
const { icon, text, textColor = "success600", fontWeight = "normal" } = getStatusMessage();
|
|
274
395
|
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
275
|
-
|
|
276
|
-
/* @__PURE__ */ jsx(Typography, { children:
|
|
277
|
-
id: "app.utils.ready-to-publish",
|
|
278
|
-
defaultMessage: "Ready to publish"
|
|
279
|
-
}) })
|
|
396
|
+
icon,
|
|
397
|
+
/* @__PURE__ */ jsx(Typography, { textColor, fontWeight, children: text })
|
|
280
398
|
] });
|
|
281
399
|
};
|
|
282
400
|
const BoldChunk = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: chunks });
|
|
@@ -284,7 +402,8 @@ const BulkLocaleActionModal = ({
|
|
|
284
402
|
headers,
|
|
285
403
|
rows,
|
|
286
404
|
localesMetadata,
|
|
287
|
-
validationErrors = {}
|
|
405
|
+
validationErrors = {},
|
|
406
|
+
action
|
|
288
407
|
}) => {
|
|
289
408
|
const { formatMessage } = useIntl();
|
|
290
409
|
const selectedRows = useTable(
|
|
@@ -297,27 +416,29 @@ const BulkLocaleActionModal = ({
|
|
|
297
416
|
return acc;
|
|
298
417
|
}, {});
|
|
299
418
|
const localesWithErrors = Object.keys(validationErrors);
|
|
300
|
-
const
|
|
419
|
+
const publishedCount = selectedRows.filter(
|
|
301
420
|
({ locale }) => currentStatusByLocale[locale] === "published"
|
|
302
421
|
).length;
|
|
303
|
-
const
|
|
422
|
+
const draftCount = selectedRows.filter(
|
|
304
423
|
({ locale }) => (currentStatusByLocale[locale] === "draft" || currentStatusByLocale[locale] === "modified") && !localesWithErrors.includes(locale)
|
|
305
424
|
).length;
|
|
306
425
|
const withErrorsCount = localesWithErrors.length;
|
|
426
|
+
const messageId = action === "bulk-publish" ? "content-manager.containers.list.selectedEntriesModal.selectedCount.publish" : "content-manager.containers.list.selectedEntriesModal.selectedCount.unpublish";
|
|
427
|
+
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.";
|
|
307
428
|
return formatMessage(
|
|
308
429
|
{
|
|
309
|
-
id:
|
|
310
|
-
defaultMessage
|
|
430
|
+
id: messageId,
|
|
431
|
+
defaultMessage
|
|
311
432
|
},
|
|
312
433
|
{
|
|
313
434
|
withErrorsCount,
|
|
314
|
-
|
|
315
|
-
|
|
435
|
+
draftCount,
|
|
436
|
+
publishedCount,
|
|
316
437
|
b: BoldChunk
|
|
317
438
|
}
|
|
318
439
|
);
|
|
319
440
|
};
|
|
320
|
-
return /* @__PURE__ */ jsxs(
|
|
441
|
+
return /* @__PURE__ */ jsxs(Modal.Body, { children: [
|
|
321
442
|
/* @__PURE__ */ jsx(Typography, { children: getFormattedCountMessage() }),
|
|
322
443
|
/* @__PURE__ */ jsx(Box, { marginTop: 5, children: /* @__PURE__ */ jsxs(Table.Content, { children: [
|
|
323
444
|
/* @__PURE__ */ jsxs(Table.Head, { children: [
|
|
@@ -344,7 +465,7 @@ const BulkLocaleActionModal = ({
|
|
|
344
465
|
children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
|
345
466
|
}
|
|
346
467
|
) }) }),
|
|
347
|
-
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(EntryValidationText, { validationErrors: error, status }) }),
|
|
468
|
+
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(EntryValidationText, { validationErrors: error, status, action }) }),
|
|
348
469
|
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(
|
|
349
470
|
IconButton,
|
|
350
471
|
{
|
|
@@ -361,7 +482,7 @@ const BulkLocaleActionModal = ({
|
|
|
361
482
|
name: locale
|
|
362
483
|
}
|
|
363
484
|
),
|
|
364
|
-
|
|
485
|
+
variant: "ghost",
|
|
365
486
|
children: /* @__PURE__ */ jsx(Pencil, {})
|
|
366
487
|
}
|
|
367
488
|
) })
|
|
@@ -370,6 +491,48 @@ const BulkLocaleActionModal = ({
|
|
|
370
491
|
] }) })
|
|
371
492
|
] });
|
|
372
493
|
};
|
|
494
|
+
const statusVariants = {
|
|
495
|
+
draft: "secondary",
|
|
496
|
+
published: "success",
|
|
497
|
+
modified: "alternative"
|
|
498
|
+
};
|
|
499
|
+
const LocaleOption = ({
|
|
500
|
+
isDraftAndPublishEnabled,
|
|
501
|
+
locale,
|
|
502
|
+
status,
|
|
503
|
+
entryExists
|
|
504
|
+
}) => {
|
|
505
|
+
const { formatMessage } = useIntl();
|
|
506
|
+
if (!entryExists) {
|
|
507
|
+
return formatMessage(
|
|
508
|
+
{
|
|
509
|
+
id: getTranslation("CMEditViewLocalePicker.locale.create"),
|
|
510
|
+
defaultMessage: "Create <bold>{locale}</bold> locale"
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
bold: (locale2) => /* @__PURE__ */ jsx("b", { children: locale2 }),
|
|
514
|
+
locale: locale.name
|
|
515
|
+
}
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
return /* @__PURE__ */ jsxs(Flex, { width: "100%", gap: 1, justifyContent: "space-between", children: [
|
|
519
|
+
/* @__PURE__ */ jsx(Typography, { children: locale.name }),
|
|
520
|
+
isDraftAndPublishEnabled ? /* @__PURE__ */ jsx(
|
|
521
|
+
Status,
|
|
522
|
+
{
|
|
523
|
+
display: "flex",
|
|
524
|
+
paddingLeft: "6px",
|
|
525
|
+
paddingRight: "6px",
|
|
526
|
+
paddingTop: "2px",
|
|
527
|
+
paddingBottom: "2px",
|
|
528
|
+
showBullet: false,
|
|
529
|
+
size: "S",
|
|
530
|
+
variant: statusVariants[status],
|
|
531
|
+
children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
|
532
|
+
}
|
|
533
|
+
) : null
|
|
534
|
+
] });
|
|
535
|
+
};
|
|
373
536
|
const LocalePickerAction = ({
|
|
374
537
|
document,
|
|
375
538
|
meta,
|
|
@@ -381,7 +544,13 @@ const LocalePickerAction = ({
|
|
|
381
544
|
const [{ query }, setQuery] = useQueryParams();
|
|
382
545
|
const { hasI18n, canCreate, canRead } = useI18n();
|
|
383
546
|
const { data: locales = [] } = useGetLocalesQuery();
|
|
384
|
-
const
|
|
547
|
+
const currentDesiredLocale = query.plugins?.i18n?.locale;
|
|
548
|
+
const { schema } = unstable_useDocument({
|
|
549
|
+
model,
|
|
550
|
+
collectionType,
|
|
551
|
+
documentId,
|
|
552
|
+
params: { locale: currentDesiredLocale }
|
|
553
|
+
});
|
|
385
554
|
const handleSelect = React.useCallback(
|
|
386
555
|
(value) => {
|
|
387
556
|
setQuery({
|
|
@@ -399,53 +568,47 @@ const LocalePickerAction = ({
|
|
|
399
568
|
if (!Array.isArray(locales) || !hasI18n) {
|
|
400
569
|
return;
|
|
401
570
|
}
|
|
402
|
-
const currentDesiredLocale = query.plugins?.i18n?.locale;
|
|
403
571
|
const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
|
|
404
572
|
const defaultLocale = locales.find((locale) => locale.isDefault);
|
|
405
573
|
if (!doesLocaleExist && defaultLocale?.code) {
|
|
406
574
|
handleSelect(defaultLocale.code);
|
|
407
575
|
}
|
|
408
|
-
}, [handleSelect, hasI18n, locales,
|
|
409
|
-
|
|
410
|
-
return null;
|
|
411
|
-
}
|
|
412
|
-
const currentLocale = query.plugins?.i18n?.locale || locales.find((loc) => loc.isDefault)?.code;
|
|
576
|
+
}, [handleSelect, hasI18n, locales, currentDesiredLocale]);
|
|
577
|
+
const currentLocale = Array.isArray(locales) ? locales.find((locale) => locale.code === currentDesiredLocale) : void 0;
|
|
413
578
|
const allCurrentLocales = [
|
|
414
|
-
{ status: getDocumentStatus(document, meta), locale: currentLocale },
|
|
579
|
+
{ status: getDocumentStatus(document, meta), locale: currentLocale?.code },
|
|
415
580
|
...meta?.availableLocales ?? []
|
|
416
581
|
];
|
|
582
|
+
if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
|
|
583
|
+
return null;
|
|
584
|
+
}
|
|
417
585
|
return {
|
|
418
586
|
label: formatMessage({
|
|
419
587
|
id: getTranslation("Settings.locales.modal.locales.label"),
|
|
420
588
|
defaultMessage: "Locales"
|
|
421
589
|
}),
|
|
422
590
|
options: locales.map((locale) => {
|
|
591
|
+
const entryWithLocaleExists = allCurrentLocales.some((doc) => doc.locale === locale.code);
|
|
423
592
|
const currentLocaleDoc = allCurrentLocales.find(
|
|
424
593
|
(doc) => "locale" in doc ? doc.locale === locale.code : false
|
|
425
594
|
);
|
|
426
|
-
const status = currentLocaleDoc?.status ?? "draft";
|
|
427
595
|
const permissionsToCheck = currentLocaleDoc ? canCreate : canRead;
|
|
428
|
-
const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
|
|
429
596
|
return {
|
|
430
597
|
disabled: !permissionsToCheck.includes(locale.code),
|
|
431
598
|
value: locale.code,
|
|
432
|
-
label:
|
|
433
|
-
|
|
434
|
-
Status,
|
|
599
|
+
label: /* @__PURE__ */ jsx(
|
|
600
|
+
LocaleOption,
|
|
435
601
|
{
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
paddingBottom: "2px",
|
|
441
|
-
showBullet: false,
|
|
442
|
-
size: "S",
|
|
443
|
-
variant: statusVariant,
|
|
444
|
-
children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
|
602
|
+
isDraftAndPublishEnabled: !!schema?.options?.draftAndPublish,
|
|
603
|
+
locale,
|
|
604
|
+
status: currentLocaleDoc?.status,
|
|
605
|
+
entryExists: entryWithLocaleExists
|
|
445
606
|
}
|
|
446
|
-
)
|
|
607
|
+
),
|
|
608
|
+
startIcon: !entryWithLocaleExists ? /* @__PURE__ */ jsx(Plus, {}) : null
|
|
447
609
|
};
|
|
448
610
|
}),
|
|
611
|
+
customizeContent: () => currentLocale?.name,
|
|
449
612
|
onSelect: handleSelect,
|
|
450
613
|
value: currentLocale
|
|
451
614
|
};
|
|
@@ -461,6 +624,95 @@ const getDocumentStatus = (document, meta) => {
|
|
|
461
624
|
}
|
|
462
625
|
return docStatus;
|
|
463
626
|
};
|
|
627
|
+
const FillFromAnotherLocaleAction = ({
|
|
628
|
+
documentId,
|
|
629
|
+
meta,
|
|
630
|
+
model,
|
|
631
|
+
collectionType
|
|
632
|
+
}) => {
|
|
633
|
+
const { formatMessage } = useIntl();
|
|
634
|
+
const [{ query }] = useQueryParams();
|
|
635
|
+
const currentDesiredLocale = query.plugins?.i18n?.locale;
|
|
636
|
+
const [localeSelected, setLocaleSelected] = React.useState(null);
|
|
637
|
+
const setValues = useForm("FillFromAnotherLocale", (state) => state.setValues);
|
|
638
|
+
const { getDocument } = unstable_useDocumentActions();
|
|
639
|
+
const { schema, components } = unstable_useDocument({
|
|
640
|
+
model,
|
|
641
|
+
documentId,
|
|
642
|
+
collectionType,
|
|
643
|
+
params: { locale: currentDesiredLocale }
|
|
644
|
+
});
|
|
645
|
+
const { data: locales = [] } = useGetLocalesQuery();
|
|
646
|
+
const availableLocales = Array.isArray(locales) ? locales.filter((locale) => meta?.availableLocales.some((l) => l.locale === locale.code)) : [];
|
|
647
|
+
const fillFromLocale = (onClose) => async () => {
|
|
648
|
+
const response = await getDocument({
|
|
649
|
+
collectionType,
|
|
650
|
+
model,
|
|
651
|
+
documentId,
|
|
652
|
+
params: { locale: localeSelected }
|
|
653
|
+
});
|
|
654
|
+
if (!response || !schema) {
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
const { data } = response;
|
|
658
|
+
const cleanedData = cleanData(data, schema, components);
|
|
659
|
+
setValues(cleanedData);
|
|
660
|
+
onClose();
|
|
661
|
+
};
|
|
662
|
+
return {
|
|
663
|
+
type: "icon",
|
|
664
|
+
icon: /* @__PURE__ */ jsx(Download, {}),
|
|
665
|
+
disabled: availableLocales.length === 0,
|
|
666
|
+
label: formatMessage({
|
|
667
|
+
id: getTranslation("CMEditViewCopyLocale.copy-text"),
|
|
668
|
+
defaultMessage: "Fill in from another locale"
|
|
669
|
+
}),
|
|
670
|
+
dialog: {
|
|
671
|
+
type: "dialog",
|
|
672
|
+
title: formatMessage({
|
|
673
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.title"),
|
|
674
|
+
defaultMessage: "Confirmation"
|
|
675
|
+
}),
|
|
676
|
+
content: ({ onClose }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
677
|
+
/* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, children: [
|
|
678
|
+
/* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
|
679
|
+
/* @__PURE__ */ jsx(Typography, { textAlign: "center", children: formatMessage({
|
|
680
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.body"),
|
|
681
|
+
defaultMessage: "Your current content will be erased and filled by the content of the selected locale:"
|
|
682
|
+
}) }),
|
|
683
|
+
/* @__PURE__ */ jsxs(Field.Root, { width: "100%", children: [
|
|
684
|
+
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
|
|
685
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.field.label"),
|
|
686
|
+
defaultMessage: "Locale"
|
|
687
|
+
}) }),
|
|
688
|
+
/* @__PURE__ */ jsx(
|
|
689
|
+
SingleSelect,
|
|
690
|
+
{
|
|
691
|
+
value: localeSelected,
|
|
692
|
+
placeholder: formatMessage({
|
|
693
|
+
id: getTranslation("CMEditViewCopyLocale.dialog.field.placeholder"),
|
|
694
|
+
defaultMessage: "Select one locale..."
|
|
695
|
+
}),
|
|
696
|
+
onChange: (value) => setLocaleSelected(value),
|
|
697
|
+
children: availableLocales.map((locale) => /* @__PURE__ */ jsx(SingleSelectOption, { value: locale.code, children: locale.name }, locale.code))
|
|
698
|
+
}
|
|
699
|
+
)
|
|
700
|
+
] })
|
|
701
|
+
] }) }),
|
|
702
|
+
/* @__PURE__ */ jsx(Dialog.Footer, { children: /* @__PURE__ */ jsxs(Flex, { gap: 2, width: "100%", children: [
|
|
703
|
+
/* @__PURE__ */ jsx(Button, { flex: "auto", variant: "tertiary", onClick: onClose, children: formatMessage({
|
|
704
|
+
id: getTranslation("CMEditViewCopyLocale.cancel-text"),
|
|
705
|
+
defaultMessage: "No, cancel"
|
|
706
|
+
}) }),
|
|
707
|
+
/* @__PURE__ */ jsx(Button, { flex: "auto", variant: "success", onClick: fillFromLocale(onClose), children: formatMessage({
|
|
708
|
+
id: getTranslation("CMEditViewCopyLocale.submit-text"),
|
|
709
|
+
defaultMessage: "Yes, fill in"
|
|
710
|
+
}) })
|
|
711
|
+
] }) })
|
|
712
|
+
] })
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
};
|
|
464
716
|
const DeleteLocaleAction = ({
|
|
465
717
|
document,
|
|
466
718
|
documentId,
|
|
@@ -472,16 +724,23 @@ const DeleteLocaleAction = ({
|
|
|
472
724
|
const { toggleNotification } = useNotification();
|
|
473
725
|
const { delete: deleteAction } = unstable_useDocumentActions();
|
|
474
726
|
const { hasI18n, canDelete } = useI18n();
|
|
727
|
+
const [{ query }] = useQueryParams();
|
|
728
|
+
const { data: locales = [] } = useGetLocalesQuery();
|
|
729
|
+
const currentDesiredLocale = query.plugins?.i18n?.locale;
|
|
730
|
+
const locale = !("error" in locales) && locales.find((loc) => loc.code === currentDesiredLocale);
|
|
475
731
|
if (!hasI18n) {
|
|
476
732
|
return null;
|
|
477
733
|
}
|
|
478
734
|
return {
|
|
479
735
|
disabled: document?.locale && !canDelete.includes(document.locale) || !document || !document.id,
|
|
480
736
|
position: ["header", "table-row"],
|
|
481
|
-
label: formatMessage(
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
737
|
+
label: formatMessage(
|
|
738
|
+
{
|
|
739
|
+
id: getTranslation("actions.delete.label"),
|
|
740
|
+
defaultMessage: "Delete entry ({locale})"
|
|
741
|
+
},
|
|
742
|
+
{ locale: locale && locale.name }
|
|
743
|
+
),
|
|
485
744
|
icon: /* @__PURE__ */ jsx(StyledTrash, {}),
|
|
486
745
|
variant: "danger",
|
|
487
746
|
dialog: {
|
|
@@ -524,37 +783,43 @@ const DeleteLocaleAction = ({
|
|
|
524
783
|
}
|
|
525
784
|
};
|
|
526
785
|
};
|
|
527
|
-
const
|
|
786
|
+
const BulkLocaleAction = ({
|
|
528
787
|
document: baseDocument,
|
|
529
788
|
documentId,
|
|
530
789
|
model,
|
|
531
|
-
collectionType
|
|
790
|
+
collectionType,
|
|
791
|
+
action
|
|
532
792
|
}) => {
|
|
533
793
|
const baseLocale = baseDocument?.locale ?? null;
|
|
534
794
|
const [{ query }] = useQueryParams();
|
|
535
795
|
const params = React.useMemo(() => buildValidParams(query), [query]);
|
|
536
|
-
const
|
|
796
|
+
const isOnPublishedTab = query.status === "published";
|
|
537
797
|
const { formatMessage } = useIntl();
|
|
538
798
|
const { hasI18n, canPublish } = useI18n();
|
|
539
799
|
const { toggleNotification } = useNotification();
|
|
540
800
|
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
|
541
801
|
const [selectedRows, setSelectedRows] = React.useState([]);
|
|
542
|
-
const [
|
|
543
|
-
const { publishMany: publishManyAction } = unstable_useDocumentActions();
|
|
802
|
+
const [isDraftRelationConfirmationOpen, setIsDraftRelationConfirmationOpen] = React.useState(false);
|
|
803
|
+
const { publishMany: publishManyAction, unpublishMany: unpublishManyAction } = unstable_useDocumentActions();
|
|
544
804
|
const {
|
|
545
805
|
document,
|
|
546
806
|
meta: documentMeta,
|
|
547
807
|
schema,
|
|
548
808
|
validate
|
|
549
|
-
} = unstable_useDocument(
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
809
|
+
} = unstable_useDocument(
|
|
810
|
+
{
|
|
811
|
+
model,
|
|
812
|
+
collectionType,
|
|
813
|
+
documentId,
|
|
814
|
+
params: {
|
|
815
|
+
locale: baseLocale
|
|
816
|
+
}
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
skip: !hasI18n || !baseLocale
|
|
555
820
|
}
|
|
556
|
-
|
|
557
|
-
const { data: localesMetadata = [] } = useGetLocalesQuery();
|
|
821
|
+
);
|
|
822
|
+
const { data: localesMetadata = [] } = useGetLocalesQuery(hasI18n ? void 0 : skipToken);
|
|
558
823
|
const headers = [
|
|
559
824
|
{
|
|
560
825
|
label: formatMessage({
|
|
@@ -603,12 +868,19 @@ const BulkLocalePublishAction = ({
|
|
|
603
868
|
}, {});
|
|
604
869
|
return [rowsFromMeta, errors];
|
|
605
870
|
}, [document, documentMeta?.availableLocales, validate]);
|
|
606
|
-
const
|
|
607
|
-
|
|
871
|
+
const isBulkPublish = action === "bulk-publish";
|
|
872
|
+
const localesForAction = selectedRows.reduce((acc, selectedRow) => {
|
|
873
|
+
const isValidLocale = (
|
|
874
|
+
// Validation errors are irrelevant if we are trying to unpublish
|
|
875
|
+
!isBulkPublish || !Object.keys(validationErrors).includes(selectedRow.locale)
|
|
876
|
+
);
|
|
877
|
+
const shouldAddLocale = isBulkPublish ? selectedRow.status !== "published" && isValidLocale : selectedRow.status !== "draft" && isValidLocale;
|
|
878
|
+
if (shouldAddLocale) {
|
|
608
879
|
acc.push(selectedRow.locale);
|
|
609
880
|
}
|
|
610
881
|
return acc;
|
|
611
882
|
}, []);
|
|
883
|
+
const enableDraftRelationsCount = false;
|
|
612
884
|
const {
|
|
613
885
|
data: draftRelationsCount = 0,
|
|
614
886
|
isLoading: isDraftRelationsLoading,
|
|
@@ -617,10 +889,10 @@ const BulkLocalePublishAction = ({
|
|
|
617
889
|
{
|
|
618
890
|
model,
|
|
619
891
|
documentIds: [documentId],
|
|
620
|
-
locale:
|
|
892
|
+
locale: localesForAction
|
|
621
893
|
},
|
|
622
894
|
{
|
|
623
|
-
skip: !
|
|
895
|
+
skip: !enableDraftRelationsCount
|
|
624
896
|
}
|
|
625
897
|
);
|
|
626
898
|
React.useEffect(() => {
|
|
@@ -646,23 +918,32 @@ const BulkLocalePublishAction = ({
|
|
|
646
918
|
documentIds: [documentId],
|
|
647
919
|
params: {
|
|
648
920
|
...params,
|
|
649
|
-
locale:
|
|
921
|
+
locale: localesForAction
|
|
922
|
+
}
|
|
923
|
+
});
|
|
924
|
+
setSelectedRows([]);
|
|
925
|
+
};
|
|
926
|
+
const unpublish = async () => {
|
|
927
|
+
await unpublishManyAction({
|
|
928
|
+
model,
|
|
929
|
+
documentIds: [documentId],
|
|
930
|
+
params: {
|
|
931
|
+
...params,
|
|
932
|
+
locale: localesForAction
|
|
650
933
|
}
|
|
651
934
|
});
|
|
652
935
|
setSelectedRows([]);
|
|
653
936
|
};
|
|
654
937
|
const handleAction = async () => {
|
|
655
938
|
if (draftRelationsCount > 0) {
|
|
656
|
-
|
|
657
|
-
} else {
|
|
939
|
+
setIsDraftRelationConfirmationOpen(true);
|
|
940
|
+
} else if (isBulkPublish) {
|
|
658
941
|
await publish();
|
|
942
|
+
} else {
|
|
943
|
+
await unpublish();
|
|
659
944
|
}
|
|
660
945
|
};
|
|
661
|
-
|
|
662
|
-
if (isUnpublish) {
|
|
663
|
-
console.warn(["I18N"], "Bulk locale unpublish modal not implemented");
|
|
664
|
-
}
|
|
665
|
-
if (isConfirmationOpen) {
|
|
946
|
+
if (isDraftRelationConfirmationOpen) {
|
|
666
947
|
return {
|
|
667
948
|
label: formatMessage({
|
|
668
949
|
id: "app.components.ConfirmDialog.title",
|
|
@@ -671,11 +952,11 @@ const BulkLocalePublishAction = ({
|
|
|
671
952
|
variant: "danger",
|
|
672
953
|
dialog: {
|
|
673
954
|
onCancel: () => {
|
|
674
|
-
|
|
955
|
+
setIsDraftRelationConfirmationOpen(false);
|
|
675
956
|
},
|
|
676
957
|
onConfirm: async () => {
|
|
677
958
|
await publish();
|
|
678
|
-
|
|
959
|
+
setIsDraftRelationConfirmationOpen(false);
|
|
679
960
|
},
|
|
680
961
|
type: "dialog",
|
|
681
962
|
title: formatMessage({
|
|
@@ -685,27 +966,32 @@ const BulkLocalePublishAction = ({
|
|
|
685
966
|
content: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "center", gap: 2, children: [
|
|
686
967
|
/* @__PURE__ */ jsx(WarningCircle, { width: "2.4rem", height: "2.4rem", fill: "danger600" }),
|
|
687
968
|
/* @__PURE__ */ jsx(Typography, { textAlign: "center", children: formatMessage({
|
|
688
|
-
id: "
|
|
689
|
-
defaultMessage: "
|
|
969
|
+
id: getTranslation("CMEditViewBulkLocale.draft-relation-warning"),
|
|
970
|
+
defaultMessage: "Some locales are related to draft entries. Publishing them could leave broken links in your app."
|
|
971
|
+
}) }),
|
|
972
|
+
/* @__PURE__ */ jsx(Typography, { textAlign: "center", children: formatMessage({
|
|
973
|
+
id: getTranslation("CMEditViewBulkLocale.continue-confirmation"),
|
|
974
|
+
defaultMessage: "Are you sure you want to continue?"
|
|
690
975
|
}) })
|
|
691
976
|
] })
|
|
692
977
|
}
|
|
693
978
|
};
|
|
694
979
|
}
|
|
980
|
+
const hasPermission = selectedRows.map(({ locale }) => locale).every((locale) => canPublish.includes(locale));
|
|
695
981
|
return {
|
|
696
982
|
label: formatMessage({
|
|
697
|
-
id: getTranslation("
|
|
698
|
-
defaultMessage: "Publish Multiple Locales
|
|
983
|
+
id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? "publish" : "unpublish"}-title`),
|
|
984
|
+
defaultMessage: `${isBulkPublish ? "Publish" : "Unpublish"} Multiple Locales`
|
|
699
985
|
}),
|
|
700
|
-
|
|
701
|
-
|
|
986
|
+
variant: isBulkPublish ? "secondary" : "danger",
|
|
987
|
+
icon: isBulkPublish ? /* @__PURE__ */ jsx(ListPlus, {}) : /* @__PURE__ */ jsx(Cross, {}),
|
|
988
|
+
disabled: isOnPublishedTab || canPublish.length === 0,
|
|
702
989
|
position: ["panel"],
|
|
703
|
-
variant: "secondary",
|
|
704
990
|
dialog: {
|
|
705
991
|
type: "modal",
|
|
706
992
|
title: formatMessage({
|
|
707
|
-
id: getTranslation("
|
|
708
|
-
defaultMessage: "Publish Multiple Locales
|
|
993
|
+
id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? "publish" : "unpublish"}-title`),
|
|
994
|
+
defaultMessage: `${isBulkPublish ? "Publish" : "Unpublish"} Multiple Locales`
|
|
709
995
|
}),
|
|
710
996
|
content: () => {
|
|
711
997
|
return /* @__PURE__ */ jsx(
|
|
@@ -724,28 +1010,35 @@ const BulkLocalePublishAction = ({
|
|
|
724
1010
|
validationErrors,
|
|
725
1011
|
headers,
|
|
726
1012
|
rows,
|
|
727
|
-
localesMetadata
|
|
1013
|
+
localesMetadata,
|
|
1014
|
+
action: action ?? "bulk-publish"
|
|
728
1015
|
}
|
|
729
1016
|
)
|
|
730
1017
|
}
|
|
731
1018
|
);
|
|
732
1019
|
},
|
|
733
|
-
footer: () => /* @__PURE__ */ jsx(
|
|
734
|
-
Button
|
|
1020
|
+
footer: () => /* @__PURE__ */ jsx(Modal.Footer, { justifyContent: "flex-end", children: /* @__PURE__ */ jsx(
|
|
1021
|
+
Button,
|
|
735
1022
|
{
|
|
736
1023
|
loading: isDraftRelationsLoading,
|
|
737
|
-
disabled:
|
|
1024
|
+
disabled: !hasPermission || localesForAction.length === 0,
|
|
738
1025
|
variant: "default",
|
|
739
1026
|
onClick: handleAction,
|
|
740
1027
|
children: formatMessage({
|
|
741
|
-
id: "app.utils.publish",
|
|
742
|
-
defaultMessage: "Publish"
|
|
1028
|
+
id: isBulkPublish ? "app.utils.publish" : "app.utils.unpublish",
|
|
1029
|
+
defaultMessage: isBulkPublish ? "Publish" : "Unpublish"
|
|
743
1030
|
})
|
|
744
1031
|
}
|
|
745
1032
|
) })
|
|
746
1033
|
}
|
|
747
1034
|
};
|
|
748
1035
|
};
|
|
1036
|
+
const BulkLocalePublishAction = (props) => {
|
|
1037
|
+
return BulkLocaleAction({ action: "bulk-publish", ...props });
|
|
1038
|
+
};
|
|
1039
|
+
const BulkLocaleUnpublishAction = (props) => {
|
|
1040
|
+
return BulkLocaleAction({ action: "bulk-unpublish", ...props });
|
|
1041
|
+
};
|
|
749
1042
|
const StyledTrash = styled(Trash)`
|
|
750
1043
|
path {
|
|
751
1044
|
fill: currentColor;
|
|
@@ -802,13 +1095,6 @@ const UnpublishModalAdditionalInfo = () => {
|
|
|
802
1095
|
}
|
|
803
1096
|
) });
|
|
804
1097
|
};
|
|
805
|
-
const Initializer = ({ setPlugin }) => {
|
|
806
|
-
const setPluginRef = React.useRef(setPlugin);
|
|
807
|
-
React.useEffect(() => {
|
|
808
|
-
setPluginRef.current(pluginId);
|
|
809
|
-
}, []);
|
|
810
|
-
return null;
|
|
811
|
-
};
|
|
812
1098
|
const LocalePicker = () => {
|
|
813
1099
|
const { formatMessage } = useIntl();
|
|
814
1100
|
const [{ query }, setQuery] = useQueryParams();
|
|
@@ -972,54 +1258,13 @@ const LocaleListCell = ({
|
|
|
972
1258
|
return locale.name;
|
|
973
1259
|
}).toSorted((a, b) => formatter.compare(a, b));
|
|
974
1260
|
return /* @__PURE__ */ jsxs(Popover.Root, { children: [
|
|
975
|
-
/* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(Button, { type: "button", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxs(
|
|
976
|
-
|
|
977
|
-
{
|
|
978
|
-
|
|
979
|
-
alignItems: "center",
|
|
980
|
-
justifyContent: "center",
|
|
981
|
-
height: "3.2rem",
|
|
982
|
-
width: "3.2rem",
|
|
983
|
-
children: [
|
|
984
|
-
/* @__PURE__ */ jsx(Typography, { textColor: "neutral800", ellipsis: true, children: localesForDocument.join(", ") }),
|
|
985
|
-
/* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(CaretDown, {}) })
|
|
986
|
-
]
|
|
987
|
-
}
|
|
988
|
-
) }) }),
|
|
1261
|
+
/* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(Button, { variant: "ghost", type: "button", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxs(Flex, { minWidth: "100%", alignItems: "center", justifyContent: "center", fontWeight: "regular", children: [
|
|
1262
|
+
/* @__PURE__ */ jsx(Typography, { textColor: "neutral800", ellipsis: true, marginRight: 2, children: localesForDocument.join(", ") }),
|
|
1263
|
+
/* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(CaretDown, { width: "1.2rem", height: "1.2rem" }) })
|
|
1264
|
+
] }) }) }),
|
|
989
1265
|
/* @__PURE__ */ jsx(Popover.Content, { sideOffset: 16, children: /* @__PURE__ */ jsx("ul", { children: localesForDocument.map((name) => /* @__PURE__ */ jsx(Box, { padding: 3, tag: "li", children: /* @__PURE__ */ jsx(Typography, { children: name }) }, name)) }) })
|
|
990
1266
|
] });
|
|
991
1267
|
};
|
|
992
|
-
const Button = styled.button`
|
|
993
|
-
width: 100%;
|
|
994
|
-
|
|
995
|
-
svg {
|
|
996
|
-
> g,
|
|
997
|
-
path {
|
|
998
|
-
fill: ${({ theme }) => theme.colors.neutral500};
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
&:hover {
|
|
1002
|
-
svg {
|
|
1003
|
-
> g,
|
|
1004
|
-
path {
|
|
1005
|
-
fill: ${({ theme }) => theme.colors.neutral600};
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
&:active {
|
|
1010
|
-
svg {
|
|
1011
|
-
> g,
|
|
1012
|
-
path {
|
|
1013
|
-
fill: ${({ theme }) => theme.colors.neutral400};
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
`;
|
|
1018
|
-
const ActionWrapper = styled(Flex)`
|
|
1019
|
-
svg {
|
|
1020
|
-
height: 0.4rem;
|
|
1021
|
-
}
|
|
1022
|
-
`;
|
|
1023
1268
|
const addColumnToTableHook = ({ displayedHeaders, layout }) => {
|
|
1024
1269
|
const { options } = layout;
|
|
1025
1270
|
const isFieldLocalized = doesPluginOptionsHaveI18nLocalized(options) ? options.i18n.localized : false;
|
|
@@ -1048,18 +1293,11 @@ const addColumnToTableHook = ({ displayedHeaders, layout }) => {
|
|
|
1048
1293
|
const addLocaleToReleasesHook = ({ displayedHeaders = [] }) => {
|
|
1049
1294
|
return {
|
|
1050
1295
|
displayedHeaders: [
|
|
1051
|
-
|
|
1052
|
-
// ...displayedHeaders,
|
|
1296
|
+
...displayedHeaders,
|
|
1053
1297
|
{
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
label: {
|
|
1058
|
-
id: "content-releases.page.ReleaseDetails.table.header.label.locale",
|
|
1059
|
-
defaultMessage: "locale"
|
|
1060
|
-
},
|
|
1061
|
-
searchable: false,
|
|
1062
|
-
sortable: false
|
|
1298
|
+
label: {
|
|
1299
|
+
id: "content-releases.page.ReleaseDetails.table.header.label.locale",
|
|
1300
|
+
defaultMessage: "locale"
|
|
1063
1301
|
},
|
|
1064
1302
|
name: "locale"
|
|
1065
1303
|
}
|
|
@@ -1207,8 +1445,6 @@ const index = {
|
|
|
1207
1445
|
app.addRBACMiddleware([localeMiddleware]);
|
|
1208
1446
|
app.registerPlugin({
|
|
1209
1447
|
id: pluginId,
|
|
1210
|
-
initializer: Initializer,
|
|
1211
|
-
isReady: false,
|
|
1212
1448
|
name: pluginId
|
|
1213
1449
|
});
|
|
1214
1450
|
},
|
|
@@ -1226,11 +1462,11 @@ const index = {
|
|
|
1226
1462
|
},
|
|
1227
1463
|
id: "internationalization",
|
|
1228
1464
|
to: "internationalization",
|
|
1229
|
-
Component: () => import("./SettingsPage-
|
|
1465
|
+
Component: () => import("./SettingsPage-CnBFTsrq.mjs").then((mod) => ({ default: mod.ProtectedSettingsPage })),
|
|
1230
1466
|
permissions: PERMISSIONS.accessMain
|
|
1231
1467
|
});
|
|
1232
1468
|
const contentManager = app.getPlugin("content-manager");
|
|
1233
|
-
contentManager.apis.addDocumentHeaderAction([LocalePickerAction]);
|
|
1469
|
+
contentManager.apis.addDocumentHeaderAction([LocalePickerAction, FillFromAnotherLocaleAction]);
|
|
1234
1470
|
contentManager.apis.addDocumentAction((actions) => {
|
|
1235
1471
|
const indexOfDeleteAction = actions.findIndex((action) => action.type === "delete");
|
|
1236
1472
|
actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);
|
|
@@ -1238,6 +1474,7 @@ const index = {
|
|
|
1238
1474
|
});
|
|
1239
1475
|
contentManager.apis.addDocumentAction((actions) => {
|
|
1240
1476
|
actions.splice(2, 0, BulkLocalePublishAction);
|
|
1477
|
+
actions.splice(5, 0, BulkLocaleUnpublishAction);
|
|
1241
1478
|
return actions;
|
|
1242
1479
|
});
|
|
1243
1480
|
contentManager.injectComponent("listView", "actions", {
|
|
@@ -1343,7 +1580,7 @@ const index = {
|
|
|
1343
1580
|
async registerTrads({ locales }) {
|
|
1344
1581
|
const importedTrads = await Promise.all(
|
|
1345
1582
|
locales.map((locale) => {
|
|
1346
|
-
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-9eCAqqrB.mjs"), "./translations/dk.json": () => import("./dk-2qBjxt-P.mjs"), "./translations/en.json": () => import("./en-
|
|
1583
|
+
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-9eCAqqrB.mjs"), "./translations/dk.json": () => import("./dk-2qBjxt-P.mjs"), "./translations/en.json": () => import("./en-BYRZFDBV.mjs"), "./translations/es.json": () => import("./es-DlmMVaBG.mjs"), "./translations/fr.json": () => import("./fr-3S6ke71d.mjs"), "./translations/ko.json": () => import("./ko-qTjQ8IMw.mjs"), "./translations/pl.json": () => import("./pl-B67TSHqT.mjs"), "./translations/ru.json": () => import("./ru-hagMa57T.mjs"), "./translations/tr.json": () => import("./tr-Dw_jmkG-.mjs"), "./translations/zh-Hans.json": () => import("./zh-Hans-Dyc-aR-h.mjs"), "./translations/zh.json": () => import("./zh-57YM4amO.mjs") }), `./translations/${locale}.json`).then(({ default: data }) => {
|
|
1347
1584
|
return {
|
|
1348
1585
|
data: prefixPluginTranslations(data, pluginId),
|
|
1349
1586
|
locale
|
|
@@ -1369,4 +1606,4 @@ export {
|
|
|
1369
1606
|
index as i,
|
|
1370
1607
|
useCreateLocaleMutation as u
|
|
1371
1608
|
};
|
|
1372
|
-
//# sourceMappingURL=index-
|
|
1609
|
+
//# sourceMappingURL=index-BFk3nfTb.mjs.map
|