@strapi/i18n 5.0.0-beta.6 → 5.0.0-beta.8
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/dist/_chunks/{SettingsPage-pvdzbKEM.mjs → SettingsPage-0FFSTUW2.mjs} +34 -32
- package/dist/_chunks/SettingsPage-0FFSTUW2.mjs.map +1 -0
- package/dist/_chunks/{SettingsPage-B73NO_8-.js → SettingsPage-DnLLGeBa.js} +34 -32
- package/dist/_chunks/SettingsPage-DnLLGeBa.js.map +1 -0
- package/dist/_chunks/{en-CnrTsjWS.mjs → en-18tWw4P6.mjs} +4 -1
- package/dist/_chunks/en-18tWw4P6.mjs.map +1 -0
- package/dist/_chunks/{en-BuBc6LKZ.js → en-Kv6y9zPQ.js} +4 -1
- package/dist/_chunks/en-Kv6y9zPQ.js.map +1 -0
- package/dist/_chunks/{index-lckTPHiZ.mjs → index-BddUXwss.mjs} +421 -91
- package/dist/_chunks/index-BddUXwss.mjs.map +1 -0
- package/dist/_chunks/{index-kcYwoCdE.js → index-DtEKsPcR.js} +416 -88
- package/dist/_chunks/index-DtEKsPcR.js.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/admin/src/components/BulkLocaleActionModal.d.ts +15 -0
- package/dist/admin/src/components/CMHeaderActions.d.ts +7 -1
- package/dist/admin/src/services/api.d.ts +2 -3
- package/dist/admin/src/services/locales.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +7 -0
- package/dist/admin/src/utils/baseQuery.d.ts +4 -19
- package/dist/shared/contracts/content-manager.d.ts +20 -1
- package/package.json +15 -16
- package/dist/_chunks/SettingsPage-B73NO_8-.js.map +0 -1
- package/dist/_chunks/SettingsPage-pvdzbKEM.mjs.map +0 -1
- package/dist/_chunks/en-BuBc6LKZ.js.map +0 -1
- package/dist/_chunks/en-CnrTsjWS.mjs.map +0 -1
- package/dist/_chunks/index-kcYwoCdE.js.map +0 -1
- package/dist/_chunks/index-lckTPHiZ.mjs.map +0 -1
@@ -2,16 +2,15 @@ import get from "lodash/get";
|
|
2
2
|
import * as yup from "yup";
|
3
3
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
4
4
|
import * as React from "react";
|
5
|
-
import { Typography, Checkbox, Dialog, DialogBody, Flex, DialogFooter, Button as Button$1, Status, SingleSelect, SingleSelectOption, VisuallyHidden, useCollator, Popover
|
6
|
-
import { WarningCircle, Trash, Earth, EarthStriked, CaretDown } from "@strapi/icons";
|
5
|
+
import { Typography, Field, Checkbox, Dialog, DialogBody, Flex, DialogFooter, Button as Button$1, Box, Status, IconButton, Tooltip, SingleSelect, SingleSelectOption, VisuallyHidden, useCollator, Popover } from "@strapi/design-system";
|
6
|
+
import { WarningCircle, Pencil, CrossCircle, CheckCircle, ArrowsCounterClockwise, Trash, ListPlus, Earth, EarthStriked, CaretDown } from "@strapi/icons";
|
7
7
|
import { useIntl } from "react-intl";
|
8
|
-
import styled from "styled-components";
|
9
|
-
import { useAuth,
|
10
|
-
import { unstable_useDocument, unstable_useDocumentActions } from "@strapi/content-manager/strapi-admin";
|
11
|
-
import { useParams, useNavigate, matchPath } from "react-router-dom";
|
12
|
-
import { createApi } from "@reduxjs/toolkit/query/react";
|
13
|
-
import { isAxiosError } from "axios";
|
8
|
+
import { styled } from "styled-components";
|
9
|
+
import { useAuth, adminApi, useTable, Table, useQueryParams, useNotification, useAPIErrorHandler } from "@strapi/admin/strapi-admin";
|
10
|
+
import { unstable_useDocument, unstable_useDocumentActions, buildValidParams } from "@strapi/content-manager/strapi-admin";
|
11
|
+
import { useParams, Link, useNavigate, matchPath } from "react-router-dom";
|
14
12
|
import * as qs from "qs";
|
13
|
+
import { stringify } from "qs";
|
15
14
|
import omit from "lodash/omit";
|
16
15
|
const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
17
16
|
const v = glob[path];
|
@@ -60,18 +59,10 @@ const CheckboxConfirmation = ({
|
|
60
59
|
{ ...description.values }
|
61
60
|
) : "";
|
62
61
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
63
|
-
/* @__PURE__ */
|
64
|
-
Checkbox,
|
65
|
-
{
|
66
|
-
|
67
|
-
id: name,
|
68
|
-
name,
|
69
|
-
onValueChange: handleChange,
|
70
|
-
value,
|
71
|
-
type: "checkbox",
|
72
|
-
children: label
|
73
|
-
}
|
74
|
-
),
|
62
|
+
/* @__PURE__ */ jsxs(Field.Root, { hint, name, children: [
|
63
|
+
/* @__PURE__ */ jsx(Checkbox, { onValueChange: handleChange, value, type: "checkbox", children: label }),
|
64
|
+
/* @__PURE__ */ jsx(Field.Hint, {})
|
65
|
+
] }),
|
75
66
|
isOpen && /* @__PURE__ */ jsxs(Dialog, { onClose: handleToggle, title: "Confirmation", isOpen, children: [
|
76
67
|
/* @__PURE__ */ jsx(DialogBody, { icon: /* @__PURE__ */ jsx(WarningCircle, {}), children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
77
68
|
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(TextAlignTypography, { id: "confirm-description", children: formatMessage({
|
@@ -160,64 +151,8 @@ const useI18n = () => {
|
|
160
151
|
...actions
|
161
152
|
};
|
162
153
|
};
|
163
|
-
const
|
164
|
-
|
165
|
-
const { get: get2, post, del, put } = getFetchClient();
|
166
|
-
if (typeof query === "string") {
|
167
|
-
const result = await get2(query, { signal });
|
168
|
-
return { data: result.data };
|
169
|
-
} else {
|
170
|
-
const { url, method = "GET", data, config } = query;
|
171
|
-
if (method === "POST") {
|
172
|
-
const result2 = await post(url, data, { ...config, signal });
|
173
|
-
return { data: result2.data };
|
174
|
-
}
|
175
|
-
if (method === "DELETE") {
|
176
|
-
const result2 = await del(url, { ...config, signal });
|
177
|
-
return { data: result2.data };
|
178
|
-
}
|
179
|
-
if (method === "PUT") {
|
180
|
-
const result2 = await put(url, data, { ...config, signal });
|
181
|
-
return { data: result2.data };
|
182
|
-
}
|
183
|
-
const result = await get2(url, { ...config, signal });
|
184
|
-
return { data: result.data };
|
185
|
-
}
|
186
|
-
} catch (err) {
|
187
|
-
if (isAxiosError(err)) {
|
188
|
-
if (typeof err.response?.data === "object" && err.response?.data !== null && "error" in err.response?.data) {
|
189
|
-
return { data: void 0, error: err.response?.data.error };
|
190
|
-
} else {
|
191
|
-
return {
|
192
|
-
data: void 0,
|
193
|
-
error: {
|
194
|
-
name: "UnknownError",
|
195
|
-
message: "There was an unknown error response from the API",
|
196
|
-
details: err.response?.data,
|
197
|
-
status: err.response?.status
|
198
|
-
}
|
199
|
-
};
|
200
|
-
}
|
201
|
-
}
|
202
|
-
const error = err;
|
203
|
-
return {
|
204
|
-
data: void 0,
|
205
|
-
error: {
|
206
|
-
name: error.name,
|
207
|
-
message: error.message,
|
208
|
-
stack: error.stack
|
209
|
-
}
|
210
|
-
};
|
211
|
-
}
|
212
|
-
};
|
213
|
-
const isBaseQueryError = (error) => {
|
214
|
-
return error.name !== void 0;
|
215
|
-
};
|
216
|
-
const i18nApi = createApi({
|
217
|
-
reducerPath: "i18nApi",
|
218
|
-
baseQuery: axiosBaseQuery(),
|
219
|
-
tagTypes: ["Locale"],
|
220
|
-
endpoints: () => ({})
|
154
|
+
const i18nApi = adminApi.enhanceEndpoints({
|
155
|
+
addTagTypes: ["Locale"]
|
221
156
|
});
|
222
157
|
const localesApi = i18nApi.injectEndpoints({
|
223
158
|
endpoints: (builder) => ({
|
@@ -266,6 +201,176 @@ const {
|
|
266
201
|
useGetDefaultLocalesQuery,
|
267
202
|
useUpdateLocaleMutation
|
268
203
|
} = localesApi;
|
204
|
+
const relationsApi = i18nApi.injectEndpoints({
|
205
|
+
overrideExisting: true,
|
206
|
+
endpoints: (builder) => ({
|
207
|
+
getManyDraftRelationCount: builder.query({
|
208
|
+
query: ({ model, ...params }) => ({
|
209
|
+
url: `/content-manager/collection-types/${model}/actions/countManyEntriesDraftRelations`,
|
210
|
+
method: "GET",
|
211
|
+
config: {
|
212
|
+
params
|
213
|
+
}
|
214
|
+
}),
|
215
|
+
transformResponse: (response) => response.data
|
216
|
+
})
|
217
|
+
})
|
218
|
+
});
|
219
|
+
const { useGetManyDraftRelationCountQuery } = relationsApi;
|
220
|
+
const isErrorMessageDescriptor = (object) => {
|
221
|
+
return typeof object === "object" && object !== null && "id" in object && "defaultMessage" in object;
|
222
|
+
};
|
223
|
+
const EntryValidationText = ({ status = "draft", validationErrors }) => {
|
224
|
+
const { formatMessage } = useIntl();
|
225
|
+
const getErrorStr = (key, value) => {
|
226
|
+
if (typeof value === "string") {
|
227
|
+
return `${key}: ${value}`;
|
228
|
+
} else if (isErrorMessageDescriptor(value)) {
|
229
|
+
return `${key}: ${formatMessage(value)}`;
|
230
|
+
} else if (Array.isArray(value)) {
|
231
|
+
return value.map((v) => getErrorStr(key, v)).join(" ");
|
232
|
+
} else if (typeof value === "object" && !Array.isArray(value)) {
|
233
|
+
return Object.entries(value).map(([k, v]) => getErrorStr(k, v)).join(" ");
|
234
|
+
} else {
|
235
|
+
return "";
|
236
|
+
}
|
237
|
+
};
|
238
|
+
if (validationErrors) {
|
239
|
+
const validationErrorsMessages = Object.entries(validationErrors).map(([key, value]) => {
|
240
|
+
return getErrorStr(key, value);
|
241
|
+
}).join(" ");
|
242
|
+
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
243
|
+
/* @__PURE__ */ jsx(CrossCircle, { fill: "danger600" }),
|
244
|
+
/* @__PURE__ */ jsx(Tooltip, { label: validationErrorsMessages, children: /* @__PURE__ */ jsx(
|
245
|
+
Typography,
|
246
|
+
{
|
247
|
+
maxWidth: "30rem",
|
248
|
+
textColor: "danger600",
|
249
|
+
variant: "omega",
|
250
|
+
fontWeight: "semiBold",
|
251
|
+
ellipsis: true,
|
252
|
+
children: validationErrorsMessages
|
253
|
+
}
|
254
|
+
) })
|
255
|
+
] });
|
256
|
+
}
|
257
|
+
if (status === "published") {
|
258
|
+
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
259
|
+
/* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
260
|
+
/* @__PURE__ */ jsx(Typography, { textColor: "success600", fontWeight: "bold", children: formatMessage({
|
261
|
+
id: "content-manager.bulk-publish.already-published",
|
262
|
+
defaultMessage: "Already Published"
|
263
|
+
}) })
|
264
|
+
] });
|
265
|
+
}
|
266
|
+
if (status === "modified") {
|
267
|
+
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
268
|
+
/* @__PURE__ */ jsx(ArrowsCounterClockwise, { fill: "alternative600" }),
|
269
|
+
/* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
270
|
+
id: "app.utils.ready-to-publish-changes",
|
271
|
+
defaultMessage: "Ready to publish changes"
|
272
|
+
}) })
|
273
|
+
] });
|
274
|
+
}
|
275
|
+
return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
276
|
+
/* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
|
277
|
+
/* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
278
|
+
id: "app.utils.ready-to-publish",
|
279
|
+
defaultMessage: "Ready to publish"
|
280
|
+
}) })
|
281
|
+
] });
|
282
|
+
};
|
283
|
+
const BoldChunk = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: chunks });
|
284
|
+
const BulkLocaleActionModal = ({
|
285
|
+
headers,
|
286
|
+
rows,
|
287
|
+
localesMetadata,
|
288
|
+
validationErrors = {}
|
289
|
+
}) => {
|
290
|
+
const { formatMessage } = useIntl();
|
291
|
+
const selectedRows = useTable(
|
292
|
+
"BulkLocaleActionModal",
|
293
|
+
(state) => state.selectedRows
|
294
|
+
);
|
295
|
+
const getFormattedCountMessage = () => {
|
296
|
+
const currentStatusByLocale = rows.reduce((acc, { locale, status }) => {
|
297
|
+
acc[locale] = status;
|
298
|
+
return acc;
|
299
|
+
}, {});
|
300
|
+
const localesWithErrors = Object.keys(validationErrors);
|
301
|
+
const alreadyPublishedCount = selectedRows.filter(
|
302
|
+
({ locale }) => currentStatusByLocale[locale] === "published"
|
303
|
+
).length;
|
304
|
+
const readyToPublishCount = selectedRows.filter(
|
305
|
+
({ locale }) => (currentStatusByLocale[locale] === "draft" || currentStatusByLocale[locale] === "modified") && !localesWithErrors.includes(locale)
|
306
|
+
).length;
|
307
|
+
const withErrorsCount = localesWithErrors.length;
|
308
|
+
return formatMessage(
|
309
|
+
{
|
310
|
+
id: "content-manager.containers.list.selectedEntriesModal.selectedCount",
|
311
|
+
defaultMessage: "<b>{alreadyPublishedCount}</b> {alreadyPublishedCount, plural, =0 {entries} one {entry} other {entries}} already published. <b>{readyToPublishCount}</b> {readyToPublishCount, plural, =0 {entries} one {entry} other {entries}} ready to publish. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action."
|
312
|
+
},
|
313
|
+
{
|
314
|
+
withErrorsCount,
|
315
|
+
readyToPublishCount,
|
316
|
+
alreadyPublishedCount,
|
317
|
+
b: BoldChunk
|
318
|
+
}
|
319
|
+
);
|
320
|
+
};
|
321
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
322
|
+
/* @__PURE__ */ jsx(Typography, { children: getFormattedCountMessage() }),
|
323
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 5, children: /* @__PURE__ */ jsxs(Table.Content, { children: [
|
324
|
+
/* @__PURE__ */ jsxs(Table.Head, { children: [
|
325
|
+
/* @__PURE__ */ jsx(Table.HeaderCheckboxCell, {}),
|
326
|
+
headers.map((head) => /* @__PURE__ */ jsx(Table.HeaderCell, { ...head }, head.name))
|
327
|
+
] }),
|
328
|
+
/* @__PURE__ */ jsx(Table.Body, { children: rows.map(({ locale, status }, index2) => {
|
329
|
+
const error = validationErrors?.[locale] ?? null;
|
330
|
+
const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
|
331
|
+
return /* @__PURE__ */ jsxs(Table.Row, { children: [
|
332
|
+
/* @__PURE__ */ jsx(Table.CheckboxCell, { id: locale, "aria-label": `Select ${locale}` }),
|
333
|
+
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: Array.isArray(localesMetadata) ? localesMetadata.find((localeEntry) => localeEntry.code === locale)?.name : locale }) }),
|
334
|
+
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Box, { display: "flex", children: /* @__PURE__ */ jsx(
|
335
|
+
Status,
|
336
|
+
{
|
337
|
+
display: "flex",
|
338
|
+
paddingLeft: "6px",
|
339
|
+
paddingRight: "6px",
|
340
|
+
paddingTop: "2px",
|
341
|
+
paddingBottom: "2px",
|
342
|
+
showBullet: false,
|
343
|
+
size: "S",
|
344
|
+
variant: statusVariant,
|
345
|
+
children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
346
|
+
}
|
347
|
+
) }) }),
|
348
|
+
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(EntryValidationText, { validationErrors: error, status }) }),
|
349
|
+
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(
|
350
|
+
IconButton,
|
351
|
+
{
|
352
|
+
tag: Link,
|
353
|
+
to: {
|
354
|
+
search: stringify({ plugins: { i18n: { locale } } })
|
355
|
+
},
|
356
|
+
label: formatMessage(
|
357
|
+
{
|
358
|
+
id: getTranslation("Settings.list.actions.edit"),
|
359
|
+
defaultMessage: "Edit {name} locale"
|
360
|
+
},
|
361
|
+
{
|
362
|
+
name: locale
|
363
|
+
}
|
364
|
+
),
|
365
|
+
borderWidth: 0,
|
366
|
+
children: /* @__PURE__ */ jsx(Pencil, {})
|
367
|
+
}
|
368
|
+
) })
|
369
|
+
] }, index2);
|
370
|
+
}) })
|
371
|
+
] }) })
|
372
|
+
] });
|
373
|
+
};
|
269
374
|
const LocalePickerAction = ({
|
270
375
|
document,
|
271
376
|
meta,
|
@@ -337,7 +442,7 @@ const LocalePickerAction = ({
|
|
337
442
|
showBullet: false,
|
338
443
|
size: "S",
|
339
444
|
variant: statusVariant,
|
340
|
-
children: /* @__PURE__ */ jsx(Typography, {
|
445
|
+
children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
341
446
|
}
|
342
447
|
) : null
|
343
448
|
};
|
@@ -388,7 +493,7 @@ const DeleteLocaleAction = ({
|
|
388
493
|
}),
|
389
494
|
content: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
|
390
495
|
/* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
391
|
-
/* @__PURE__ */ jsx(Typography, {
|
496
|
+
/* @__PURE__ */ jsx(Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
392
497
|
id: getTranslation("actions.delete.dialog.body"),
|
393
498
|
defaultMessage: "Are you sure?"
|
394
499
|
}) })
|
@@ -420,6 +525,228 @@ const DeleteLocaleAction = ({
|
|
420
525
|
}
|
421
526
|
};
|
422
527
|
};
|
528
|
+
const BulkLocalePublishAction = ({
|
529
|
+
document: baseDocument,
|
530
|
+
documentId,
|
531
|
+
model,
|
532
|
+
collectionType
|
533
|
+
}) => {
|
534
|
+
const baseLocale = baseDocument?.locale ?? null;
|
535
|
+
const [{ query }] = useQueryParams();
|
536
|
+
const params = React.useMemo(() => buildValidParams(query), [query]);
|
537
|
+
const isPublishedTab = query.status === "published";
|
538
|
+
const { formatMessage } = useIntl();
|
539
|
+
const { hasI18n, canPublish } = useI18n();
|
540
|
+
const { toggleNotification } = useNotification();
|
541
|
+
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
542
|
+
const [selectedRows, setSelectedRows] = React.useState([]);
|
543
|
+
const [isConfirmationOpen, setIsConfirmationOpen] = React.useState(false);
|
544
|
+
const { publishMany: publishManyAction } = unstable_useDocumentActions();
|
545
|
+
const {
|
546
|
+
document,
|
547
|
+
meta: documentMeta,
|
548
|
+
schema,
|
549
|
+
validate
|
550
|
+
} = unstable_useDocument({
|
551
|
+
model,
|
552
|
+
collectionType,
|
553
|
+
documentId,
|
554
|
+
params: {
|
555
|
+
locale: baseLocale
|
556
|
+
}
|
557
|
+
});
|
558
|
+
const { data: localesMetadata = [] } = useGetLocalesQuery();
|
559
|
+
const headers = [
|
560
|
+
{
|
561
|
+
label: formatMessage({
|
562
|
+
id: "global.name",
|
563
|
+
defaultMessage: "Name"
|
564
|
+
}),
|
565
|
+
name: "name"
|
566
|
+
},
|
567
|
+
{
|
568
|
+
label: formatMessage({
|
569
|
+
id: getTranslation("CMEditViewBulkLocale.status"),
|
570
|
+
defaultMessage: "Status"
|
571
|
+
}),
|
572
|
+
name: "status"
|
573
|
+
},
|
574
|
+
{
|
575
|
+
label: formatMessage({
|
576
|
+
id: getTranslation("CMEditViewBulkLocale.publication-status"),
|
577
|
+
defaultMessage: "Publication Status"
|
578
|
+
}),
|
579
|
+
name: "publication-status"
|
580
|
+
}
|
581
|
+
];
|
582
|
+
const [rows, validationErrors] = React.useMemo(() => {
|
583
|
+
if (!document || !documentMeta?.availableLocales) {
|
584
|
+
return [[], {}];
|
585
|
+
}
|
586
|
+
const rowsFromMeta = documentMeta?.availableLocales.map((doc) => {
|
587
|
+
const { locale, status } = doc;
|
588
|
+
return { locale, status };
|
589
|
+
});
|
590
|
+
rowsFromMeta.unshift({
|
591
|
+
locale: document.locale,
|
592
|
+
status: document.status
|
593
|
+
});
|
594
|
+
const allDocuments = [document, ...documentMeta?.availableLocales ?? []];
|
595
|
+
const errors = allDocuments.reduce((errs, document2) => {
|
596
|
+
if (!document2) {
|
597
|
+
return errs;
|
598
|
+
}
|
599
|
+
const validation = validate(document2);
|
600
|
+
if (validation !== null) {
|
601
|
+
errs[document2.locale] = validation;
|
602
|
+
}
|
603
|
+
return errs;
|
604
|
+
}, {});
|
605
|
+
return [rowsFromMeta, errors];
|
606
|
+
}, [document, documentMeta?.availableLocales, validate]);
|
607
|
+
const localesToPublish = selectedRows.reduce((acc, selectedRow) => {
|
608
|
+
if (selectedRow.status !== "published" && !Object.keys(validationErrors).includes(selectedRow.locale)) {
|
609
|
+
acc.push(selectedRow.locale);
|
610
|
+
}
|
611
|
+
return acc;
|
612
|
+
}, []);
|
613
|
+
const {
|
614
|
+
data: draftRelationsCount = 0,
|
615
|
+
isLoading: isDraftRelationsLoading,
|
616
|
+
error: isDraftRelationsError
|
617
|
+
} = useGetManyDraftRelationCountQuery(
|
618
|
+
{
|
619
|
+
model,
|
620
|
+
documentIds: [documentId],
|
621
|
+
locale: localesToPublish
|
622
|
+
},
|
623
|
+
{
|
624
|
+
skip: !documentId || localesToPublish.length === 0
|
625
|
+
}
|
626
|
+
);
|
627
|
+
React.useEffect(() => {
|
628
|
+
if (isDraftRelationsError) {
|
629
|
+
toggleNotification({
|
630
|
+
type: "danger",
|
631
|
+
message: formatAPIError(isDraftRelationsError)
|
632
|
+
});
|
633
|
+
}
|
634
|
+
}, [isDraftRelationsError, toggleNotification, formatAPIError]);
|
635
|
+
if (!schema?.options?.draftAndPublish) {
|
636
|
+
return null;
|
637
|
+
}
|
638
|
+
if (!hasI18n) {
|
639
|
+
return null;
|
640
|
+
}
|
641
|
+
if (!documentId) {
|
642
|
+
return null;
|
643
|
+
}
|
644
|
+
const publish = async () => {
|
645
|
+
await publishManyAction({
|
646
|
+
model,
|
647
|
+
documentIds: [documentId],
|
648
|
+
params: {
|
649
|
+
...params,
|
650
|
+
locale: localesToPublish
|
651
|
+
}
|
652
|
+
});
|
653
|
+
setSelectedRows([]);
|
654
|
+
};
|
655
|
+
const handleAction = async () => {
|
656
|
+
if (draftRelationsCount > 0) {
|
657
|
+
setIsConfirmationOpen(true);
|
658
|
+
} else {
|
659
|
+
await publish();
|
660
|
+
}
|
661
|
+
};
|
662
|
+
const isUnpublish = document?.status === "published";
|
663
|
+
if (isUnpublish) {
|
664
|
+
console.warn(["I18N"], "Bulk locale unpublish modal not implemented");
|
665
|
+
}
|
666
|
+
if (isConfirmationOpen) {
|
667
|
+
return {
|
668
|
+
label: formatMessage({
|
669
|
+
id: "app.components.ConfirmDialog.title",
|
670
|
+
defaultMessage: "Confirmation"
|
671
|
+
}),
|
672
|
+
variant: "danger",
|
673
|
+
dialog: {
|
674
|
+
onCancel: () => {
|
675
|
+
setIsConfirmationOpen(false);
|
676
|
+
},
|
677
|
+
onConfirm: async () => {
|
678
|
+
await publish();
|
679
|
+
setIsConfirmationOpen(false);
|
680
|
+
},
|
681
|
+
type: "dialog",
|
682
|
+
title: formatMessage({
|
683
|
+
id: getTranslation("actions.publish.dialog.title"),
|
684
|
+
defaultMessage: "Confirmation"
|
685
|
+
}),
|
686
|
+
content: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "center", gap: 2, children: [
|
687
|
+
/* @__PURE__ */ jsx(WarningCircle, { width: "2.4rem", height: "2.4rem", fill: "danger600" }),
|
688
|
+
/* @__PURE__ */ jsx(Typography, { textAlign: "center", children: formatMessage({
|
689
|
+
id: "content-manager.actions.discard.dialog.body",
|
690
|
+
defaultMessage: "Are you sure you want to discard the changes? This action is irreversible."
|
691
|
+
}) })
|
692
|
+
] })
|
693
|
+
}
|
694
|
+
};
|
695
|
+
}
|
696
|
+
return {
|
697
|
+
label: formatMessage({
|
698
|
+
id: getTranslation("CMEditViewBulkLocale.publish-title"),
|
699
|
+
defaultMessage: "Publish Multiple Locales"
|
700
|
+
}),
|
701
|
+
icon: /* @__PURE__ */ jsx(ListPlus, {}),
|
702
|
+
disabled: isPublishedTab || !canPublish,
|
703
|
+
position: ["panel"],
|
704
|
+
variant: "secondary",
|
705
|
+
dialog: {
|
706
|
+
type: "modal",
|
707
|
+
title: formatMessage({
|
708
|
+
id: getTranslation("CMEditViewBulkLocale.publish-title"),
|
709
|
+
defaultMessage: "Publish Multiple Locales"
|
710
|
+
}),
|
711
|
+
content: () => {
|
712
|
+
return /* @__PURE__ */ jsx(
|
713
|
+
Table.Root,
|
714
|
+
{
|
715
|
+
headers,
|
716
|
+
rows: rows.map((row) => ({
|
717
|
+
...row,
|
718
|
+
id: row.locale
|
719
|
+
})),
|
720
|
+
selectedRows,
|
721
|
+
onSelectedRowsChange: (tableSelectedRows) => setSelectedRows(tableSelectedRows),
|
722
|
+
children: /* @__PURE__ */ jsx(
|
723
|
+
BulkLocaleActionModal,
|
724
|
+
{
|
725
|
+
validationErrors,
|
726
|
+
headers,
|
727
|
+
rows,
|
728
|
+
localesMetadata
|
729
|
+
}
|
730
|
+
)
|
731
|
+
}
|
732
|
+
);
|
733
|
+
},
|
734
|
+
footer: () => /* @__PURE__ */ jsx(Flex, { justifyContent: "flex-end", children: /* @__PURE__ */ jsx(
|
735
|
+
Button$1,
|
736
|
+
{
|
737
|
+
loading: isDraftRelationsLoading,
|
738
|
+
disabled: localesToPublish.length === 0,
|
739
|
+
variant: "default",
|
740
|
+
onClick: handleAction,
|
741
|
+
children: formatMessage({
|
742
|
+
id: "app.utils.publish",
|
743
|
+
defaultMessage: "Publish"
|
744
|
+
})
|
745
|
+
}
|
746
|
+
) })
|
747
|
+
}
|
748
|
+
};
|
749
|
+
};
|
423
750
|
const StyledTrash = styled(Trash)`
|
424
751
|
path {
|
425
752
|
fill: currentColor;
|
@@ -587,8 +914,8 @@ const doesFieldHaveI18nPluginOpt = (pluginOpts) => {
|
|
587
914
|
};
|
588
915
|
const LabelAction = ({ title, icon }) => {
|
589
916
|
const { formatMessage } = useIntl();
|
590
|
-
return /* @__PURE__ */ jsxs(Span, {
|
591
|
-
/* @__PURE__ */ jsx(VisuallyHidden, {
|
917
|
+
return /* @__PURE__ */ jsxs(Span, { tag: "span", children: [
|
918
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { tag: "span", children: `(${formatMessage(title)})` }),
|
592
919
|
React.cloneElement(icon, {
|
593
920
|
"aria-hidden": true,
|
594
921
|
focusable: false
|
@@ -673,7 +1000,7 @@ const LocaleListCell = ({
|
|
673
1000
|
source: buttonRef,
|
674
1001
|
spacing: 16,
|
675
1002
|
centered: true,
|
676
|
-
children: /* @__PURE__ */ jsx("ul", { children: localesForDocument.map((name) => /* @__PURE__ */ jsx(Box, { padding: 3,
|
1003
|
+
children: /* @__PURE__ */ jsx("ul", { children: localesForDocument.map((name) => /* @__PURE__ */ jsx(Box, { padding: 3, tag: "li", children: /* @__PURE__ */ jsx(Typography, { children: name }) }, name)) })
|
677
1004
|
}
|
678
1005
|
)
|
679
1006
|
] });
|
@@ -915,7 +1242,7 @@ const index = {
|
|
915
1242
|
},
|
916
1243
|
id: "internationalization",
|
917
1244
|
to: "internationalization",
|
918
|
-
Component: () => import("./SettingsPage-
|
1245
|
+
Component: () => import("./SettingsPage-0FFSTUW2.mjs").then((mod) => ({ default: mod.ProtectedSettingsPage })),
|
919
1246
|
permissions: PERMISSIONS.accessMain
|
920
1247
|
});
|
921
1248
|
const contentManager = app.getPlugin("content-manager");
|
@@ -925,6 +1252,10 @@ const index = {
|
|
925
1252
|
actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);
|
926
1253
|
return actions;
|
927
1254
|
});
|
1255
|
+
contentManager.apis.addDocumentAction((actions) => {
|
1256
|
+
actions.splice(2, 0, BulkLocalePublishAction);
|
1257
|
+
return actions;
|
1258
|
+
});
|
928
1259
|
contentManager.injectComponent("listView", "actions", {
|
929
1260
|
name: "i18n-locale-filter",
|
930
1261
|
Component: LocalePicker
|
@@ -1028,7 +1359,7 @@ const index = {
|
|
1028
1359
|
async registerTrads({ locales }) {
|
1029
1360
|
const importedTrads = await Promise.all(
|
1030
1361
|
locales.map((locale) => {
|
1031
|
-
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-
|
1362
|
+
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-18tWw4P6.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 }) => {
|
1032
1363
|
return {
|
1033
1364
|
data: prefixPluginTranslations(data, pluginId),
|
1034
1365
|
locale
|
@@ -1047,12 +1378,11 @@ const index = {
|
|
1047
1378
|
export {
|
1048
1379
|
PERMISSIONS as P,
|
1049
1380
|
useGetDefaultLocalesQuery as a,
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
index as e,
|
1381
|
+
useDeleteLocaleMutation as b,
|
1382
|
+
useUpdateLocaleMutation as c,
|
1383
|
+
useGetLocalesQuery as d,
|
1054
1384
|
getTranslation as g,
|
1055
|
-
|
1385
|
+
index as i,
|
1056
1386
|
useCreateLocaleMutation as u
|
1057
1387
|
};
|
1058
|
-
//# sourceMappingURL=index-
|
1388
|
+
//# sourceMappingURL=index-BddUXwss.mjs.map
|