@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
@@ -6,12 +6,10 @@ const React = require("react");
|
|
6
6
|
const designSystem = require("@strapi/design-system");
|
7
7
|
const icons = require("@strapi/icons");
|
8
8
|
const reactIntl = require("react-intl");
|
9
|
-
const
|
9
|
+
const styledComponents = require("styled-components");
|
10
10
|
const strapiAdmin = require("@strapi/admin/strapi-admin");
|
11
11
|
const strapiAdmin$1 = require("@strapi/content-manager/strapi-admin");
|
12
12
|
const reactRouterDom = require("react-router-dom");
|
13
|
-
const react = require("@reduxjs/toolkit/query/react");
|
14
|
-
const axios = require("axios");
|
15
13
|
const qs = require("qs");
|
16
14
|
const omit = require("lodash/omit");
|
17
15
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
@@ -36,7 +34,6 @@ function _interopNamespace(e) {
|
|
36
34
|
const get__default = /* @__PURE__ */ _interopDefault(get);
|
37
35
|
const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
|
38
36
|
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
39
|
-
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
40
37
|
const qs__namespace = /* @__PURE__ */ _interopNamespace(qs);
|
41
38
|
const omit__default = /* @__PURE__ */ _interopDefault(omit);
|
42
39
|
const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
@@ -50,7 +47,7 @@ const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
|
50
47
|
};
|
51
48
|
const pluginId = "i18n";
|
52
49
|
const getTranslation = (id) => `${pluginId}.${id}`;
|
53
|
-
const TextAlignTypography =
|
50
|
+
const TextAlignTypography = styledComponents.styled(designSystem.Typography)`
|
54
51
|
text-align: center;
|
55
52
|
`;
|
56
53
|
const CheckboxConfirmation = ({
|
@@ -86,18 +83,10 @@ const CheckboxConfirmation = ({
|
|
86
83
|
{ ...description.values }
|
87
84
|
) : "";
|
88
85
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
89
|
-
/* @__PURE__ */ jsxRuntime.
|
90
|
-
designSystem.Checkbox,
|
91
|
-
{
|
92
|
-
|
93
|
-
id: name,
|
94
|
-
name,
|
95
|
-
onValueChange: handleChange,
|
96
|
-
value,
|
97
|
-
type: "checkbox",
|
98
|
-
children: label
|
99
|
-
}
|
100
|
-
),
|
86
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { hint, name, children: [
|
87
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Checkbox, { onValueChange: handleChange, value, type: "checkbox", children: label }),
|
88
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
|
89
|
+
] }),
|
101
90
|
isOpen && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog, { onClose: handleToggle, title: "Confirmation", isOpen, children: [
|
102
91
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.DialogBody, { icon: /* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, {}), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
103
92
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(TextAlignTypography, { id: "confirm-description", children: formatMessage({
|
@@ -186,64 +175,8 @@ const useI18n = () => {
|
|
186
175
|
...actions
|
187
176
|
};
|
188
177
|
};
|
189
|
-
const
|
190
|
-
|
191
|
-
const { get: get2, post, del, put } = strapiAdmin.getFetchClient();
|
192
|
-
if (typeof query === "string") {
|
193
|
-
const result = await get2(query, { signal });
|
194
|
-
return { data: result.data };
|
195
|
-
} else {
|
196
|
-
const { url, method = "GET", data, config } = query;
|
197
|
-
if (method === "POST") {
|
198
|
-
const result2 = await post(url, data, { ...config, signal });
|
199
|
-
return { data: result2.data };
|
200
|
-
}
|
201
|
-
if (method === "DELETE") {
|
202
|
-
const result2 = await del(url, { ...config, signal });
|
203
|
-
return { data: result2.data };
|
204
|
-
}
|
205
|
-
if (method === "PUT") {
|
206
|
-
const result2 = await put(url, data, { ...config, signal });
|
207
|
-
return { data: result2.data };
|
208
|
-
}
|
209
|
-
const result = await get2(url, { ...config, signal });
|
210
|
-
return { data: result.data };
|
211
|
-
}
|
212
|
-
} catch (err) {
|
213
|
-
if (axios.isAxiosError(err)) {
|
214
|
-
if (typeof err.response?.data === "object" && err.response?.data !== null && "error" in err.response?.data) {
|
215
|
-
return { data: void 0, error: err.response?.data.error };
|
216
|
-
} else {
|
217
|
-
return {
|
218
|
-
data: void 0,
|
219
|
-
error: {
|
220
|
-
name: "UnknownError",
|
221
|
-
message: "There was an unknown error response from the API",
|
222
|
-
details: err.response?.data,
|
223
|
-
status: err.response?.status
|
224
|
-
}
|
225
|
-
};
|
226
|
-
}
|
227
|
-
}
|
228
|
-
const error = err;
|
229
|
-
return {
|
230
|
-
data: void 0,
|
231
|
-
error: {
|
232
|
-
name: error.name,
|
233
|
-
message: error.message,
|
234
|
-
stack: error.stack
|
235
|
-
}
|
236
|
-
};
|
237
|
-
}
|
238
|
-
};
|
239
|
-
const isBaseQueryError = (error) => {
|
240
|
-
return error.name !== void 0;
|
241
|
-
};
|
242
|
-
const i18nApi = react.createApi({
|
243
|
-
reducerPath: "i18nApi",
|
244
|
-
baseQuery: axiosBaseQuery(),
|
245
|
-
tagTypes: ["Locale"],
|
246
|
-
endpoints: () => ({})
|
178
|
+
const i18nApi = strapiAdmin.adminApi.enhanceEndpoints({
|
179
|
+
addTagTypes: ["Locale"]
|
247
180
|
});
|
248
181
|
const localesApi = i18nApi.injectEndpoints({
|
249
182
|
endpoints: (builder) => ({
|
@@ -292,6 +225,176 @@ const {
|
|
292
225
|
useGetDefaultLocalesQuery,
|
293
226
|
useUpdateLocaleMutation
|
294
227
|
} = localesApi;
|
228
|
+
const relationsApi = i18nApi.injectEndpoints({
|
229
|
+
overrideExisting: true,
|
230
|
+
endpoints: (builder) => ({
|
231
|
+
getManyDraftRelationCount: builder.query({
|
232
|
+
query: ({ model, ...params }) => ({
|
233
|
+
url: `/content-manager/collection-types/${model}/actions/countManyEntriesDraftRelations`,
|
234
|
+
method: "GET",
|
235
|
+
config: {
|
236
|
+
params
|
237
|
+
}
|
238
|
+
}),
|
239
|
+
transformResponse: (response) => response.data
|
240
|
+
})
|
241
|
+
})
|
242
|
+
});
|
243
|
+
const { useGetManyDraftRelationCountQuery } = relationsApi;
|
244
|
+
const isErrorMessageDescriptor = (object) => {
|
245
|
+
return typeof object === "object" && object !== null && "id" in object && "defaultMessage" in object;
|
246
|
+
};
|
247
|
+
const EntryValidationText = ({ status = "draft", validationErrors }) => {
|
248
|
+
const { formatMessage } = reactIntl.useIntl();
|
249
|
+
const getErrorStr = (key, value) => {
|
250
|
+
if (typeof value === "string") {
|
251
|
+
return `${key}: ${value}`;
|
252
|
+
} else if (isErrorMessageDescriptor(value)) {
|
253
|
+
return `${key}: ${formatMessage(value)}`;
|
254
|
+
} else if (Array.isArray(value)) {
|
255
|
+
return value.map((v) => getErrorStr(key, v)).join(" ");
|
256
|
+
} else if (typeof value === "object" && !Array.isArray(value)) {
|
257
|
+
return Object.entries(value).map(([k, v]) => getErrorStr(k, v)).join(" ");
|
258
|
+
} else {
|
259
|
+
return "";
|
260
|
+
}
|
261
|
+
};
|
262
|
+
if (validationErrors) {
|
263
|
+
const validationErrorsMessages = Object.entries(validationErrors).map(([key, value]) => {
|
264
|
+
return getErrorStr(key, value);
|
265
|
+
}).join(" ");
|
266
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
267
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.CrossCircle, { fill: "danger600" }),
|
268
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { label: validationErrorsMessages, children: /* @__PURE__ */ jsxRuntime.jsx(
|
269
|
+
designSystem.Typography,
|
270
|
+
{
|
271
|
+
maxWidth: "30rem",
|
272
|
+
textColor: "danger600",
|
273
|
+
variant: "omega",
|
274
|
+
fontWeight: "semiBold",
|
275
|
+
ellipsis: true,
|
276
|
+
children: validationErrorsMessages
|
277
|
+
}
|
278
|
+
) })
|
279
|
+
] });
|
280
|
+
}
|
281
|
+
if (status === "published") {
|
282
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
283
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
284
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "success600", fontWeight: "bold", children: formatMessage({
|
285
|
+
id: "content-manager.bulk-publish.already-published",
|
286
|
+
defaultMessage: "Already Published"
|
287
|
+
}) })
|
288
|
+
] });
|
289
|
+
}
|
290
|
+
if (status === "modified") {
|
291
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
292
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowsCounterClockwise, { fill: "alternative600" }),
|
293
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
|
294
|
+
id: "app.utils.ready-to-publish-changes",
|
295
|
+
defaultMessage: "Ready to publish changes"
|
296
|
+
}) })
|
297
|
+
] });
|
298
|
+
}
|
299
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
300
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
|
301
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
|
302
|
+
id: "app.utils.ready-to-publish",
|
303
|
+
defaultMessage: "Ready to publish"
|
304
|
+
}) })
|
305
|
+
] });
|
306
|
+
};
|
307
|
+
const BoldChunk = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
|
308
|
+
const BulkLocaleActionModal = ({
|
309
|
+
headers,
|
310
|
+
rows,
|
311
|
+
localesMetadata,
|
312
|
+
validationErrors = {}
|
313
|
+
}) => {
|
314
|
+
const { formatMessage } = reactIntl.useIntl();
|
315
|
+
const selectedRows = strapiAdmin.useTable(
|
316
|
+
"BulkLocaleActionModal",
|
317
|
+
(state) => state.selectedRows
|
318
|
+
);
|
319
|
+
const getFormattedCountMessage = () => {
|
320
|
+
const currentStatusByLocale = rows.reduce((acc, { locale, status }) => {
|
321
|
+
acc[locale] = status;
|
322
|
+
return acc;
|
323
|
+
}, {});
|
324
|
+
const localesWithErrors = Object.keys(validationErrors);
|
325
|
+
const alreadyPublishedCount = selectedRows.filter(
|
326
|
+
({ locale }) => currentStatusByLocale[locale] === "published"
|
327
|
+
).length;
|
328
|
+
const readyToPublishCount = selectedRows.filter(
|
329
|
+
({ locale }) => (currentStatusByLocale[locale] === "draft" || currentStatusByLocale[locale] === "modified") && !localesWithErrors.includes(locale)
|
330
|
+
).length;
|
331
|
+
const withErrorsCount = localesWithErrors.length;
|
332
|
+
return formatMessage(
|
333
|
+
{
|
334
|
+
id: "content-manager.containers.list.selectedEntriesModal.selectedCount",
|
335
|
+
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."
|
336
|
+
},
|
337
|
+
{
|
338
|
+
withErrorsCount,
|
339
|
+
readyToPublishCount,
|
340
|
+
alreadyPublishedCount,
|
341
|
+
b: BoldChunk
|
342
|
+
}
|
343
|
+
);
|
344
|
+
};
|
345
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
|
346
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: getFormattedCountMessage() }),
|
347
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Content, { children: [
|
348
|
+
/* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Head, { children: [
|
349
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.HeaderCheckboxCell, {}),
|
350
|
+
headers.map((head) => /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.HeaderCell, { ...head }, head.name))
|
351
|
+
] }),
|
352
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Body, { children: rows.map(({ locale, status }, index2) => {
|
353
|
+
const error = validationErrors?.[locale] ?? null;
|
354
|
+
const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
|
355
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Row, { children: [
|
356
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.CheckboxCell, { id: locale, "aria-label": `Select ${locale}` }),
|
357
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: Array.isArray(localesMetadata) ? localesMetadata.find((localeEntry) => localeEntry.code === locale)?.name : locale }) }),
|
358
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { display: "flex", children: /* @__PURE__ */ jsxRuntime.jsx(
|
359
|
+
designSystem.Status,
|
360
|
+
{
|
361
|
+
display: "flex",
|
362
|
+
paddingLeft: "6px",
|
363
|
+
paddingRight: "6px",
|
364
|
+
paddingTop: "2px",
|
365
|
+
paddingBottom: "2px",
|
366
|
+
showBullet: false,
|
367
|
+
size: "S",
|
368
|
+
variant: statusVariant,
|
369
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
370
|
+
}
|
371
|
+
) }) }),
|
372
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(EntryValidationText, { validationErrors: error, status }) }),
|
373
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
374
|
+
designSystem.IconButton,
|
375
|
+
{
|
376
|
+
tag: reactRouterDom.Link,
|
377
|
+
to: {
|
378
|
+
search: qs.stringify({ plugins: { i18n: { locale } } })
|
379
|
+
},
|
380
|
+
label: formatMessage(
|
381
|
+
{
|
382
|
+
id: getTranslation("Settings.list.actions.edit"),
|
383
|
+
defaultMessage: "Edit {name} locale"
|
384
|
+
},
|
385
|
+
{
|
386
|
+
name: locale
|
387
|
+
}
|
388
|
+
),
|
389
|
+
borderWidth: 0,
|
390
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {})
|
391
|
+
}
|
392
|
+
) })
|
393
|
+
] }, index2);
|
394
|
+
}) })
|
395
|
+
] }) })
|
396
|
+
] });
|
397
|
+
};
|
295
398
|
const LocalePickerAction = ({
|
296
399
|
document,
|
297
400
|
meta,
|
@@ -363,7 +466,7 @@ const LocalePickerAction = ({
|
|
363
466
|
showBullet: false,
|
364
467
|
size: "S",
|
365
468
|
variant: statusVariant,
|
366
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
|
469
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
|
367
470
|
}
|
368
471
|
) : null
|
369
472
|
};
|
@@ -414,7 +517,7 @@ const DeleteLocaleAction = ({
|
|
414
517
|
}),
|
415
518
|
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
|
416
519
|
/* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
|
417
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, {
|
520
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
|
418
521
|
id: getTranslation("actions.delete.dialog.body"),
|
419
522
|
defaultMessage: "Are you sure?"
|
420
523
|
}) })
|
@@ -446,7 +549,229 @@ const DeleteLocaleAction = ({
|
|
446
549
|
}
|
447
550
|
};
|
448
551
|
};
|
449
|
-
const
|
552
|
+
const BulkLocalePublishAction = ({
|
553
|
+
document: baseDocument,
|
554
|
+
documentId,
|
555
|
+
model,
|
556
|
+
collectionType
|
557
|
+
}) => {
|
558
|
+
const baseLocale = baseDocument?.locale ?? null;
|
559
|
+
const [{ query }] = strapiAdmin.useQueryParams();
|
560
|
+
const params = React__namespace.useMemo(() => strapiAdmin$1.buildValidParams(query), [query]);
|
561
|
+
const isPublishedTab = query.status === "published";
|
562
|
+
const { formatMessage } = reactIntl.useIntl();
|
563
|
+
const { hasI18n, canPublish } = useI18n();
|
564
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
565
|
+
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
566
|
+
const [selectedRows, setSelectedRows] = React__namespace.useState([]);
|
567
|
+
const [isConfirmationOpen, setIsConfirmationOpen] = React__namespace.useState(false);
|
568
|
+
const { publishMany: publishManyAction } = strapiAdmin$1.unstable_useDocumentActions();
|
569
|
+
const {
|
570
|
+
document,
|
571
|
+
meta: documentMeta,
|
572
|
+
schema,
|
573
|
+
validate
|
574
|
+
} = strapiAdmin$1.unstable_useDocument({
|
575
|
+
model,
|
576
|
+
collectionType,
|
577
|
+
documentId,
|
578
|
+
params: {
|
579
|
+
locale: baseLocale
|
580
|
+
}
|
581
|
+
});
|
582
|
+
const { data: localesMetadata = [] } = useGetLocalesQuery();
|
583
|
+
const headers = [
|
584
|
+
{
|
585
|
+
label: formatMessage({
|
586
|
+
id: "global.name",
|
587
|
+
defaultMessage: "Name"
|
588
|
+
}),
|
589
|
+
name: "name"
|
590
|
+
},
|
591
|
+
{
|
592
|
+
label: formatMessage({
|
593
|
+
id: getTranslation("CMEditViewBulkLocale.status"),
|
594
|
+
defaultMessage: "Status"
|
595
|
+
}),
|
596
|
+
name: "status"
|
597
|
+
},
|
598
|
+
{
|
599
|
+
label: formatMessage({
|
600
|
+
id: getTranslation("CMEditViewBulkLocale.publication-status"),
|
601
|
+
defaultMessage: "Publication Status"
|
602
|
+
}),
|
603
|
+
name: "publication-status"
|
604
|
+
}
|
605
|
+
];
|
606
|
+
const [rows, validationErrors] = React__namespace.useMemo(() => {
|
607
|
+
if (!document || !documentMeta?.availableLocales) {
|
608
|
+
return [[], {}];
|
609
|
+
}
|
610
|
+
const rowsFromMeta = documentMeta?.availableLocales.map((doc) => {
|
611
|
+
const { locale, status } = doc;
|
612
|
+
return { locale, status };
|
613
|
+
});
|
614
|
+
rowsFromMeta.unshift({
|
615
|
+
locale: document.locale,
|
616
|
+
status: document.status
|
617
|
+
});
|
618
|
+
const allDocuments = [document, ...documentMeta?.availableLocales ?? []];
|
619
|
+
const errors = allDocuments.reduce((errs, document2) => {
|
620
|
+
if (!document2) {
|
621
|
+
return errs;
|
622
|
+
}
|
623
|
+
const validation = validate(document2);
|
624
|
+
if (validation !== null) {
|
625
|
+
errs[document2.locale] = validation;
|
626
|
+
}
|
627
|
+
return errs;
|
628
|
+
}, {});
|
629
|
+
return [rowsFromMeta, errors];
|
630
|
+
}, [document, documentMeta?.availableLocales, validate]);
|
631
|
+
const localesToPublish = selectedRows.reduce((acc, selectedRow) => {
|
632
|
+
if (selectedRow.status !== "published" && !Object.keys(validationErrors).includes(selectedRow.locale)) {
|
633
|
+
acc.push(selectedRow.locale);
|
634
|
+
}
|
635
|
+
return acc;
|
636
|
+
}, []);
|
637
|
+
const {
|
638
|
+
data: draftRelationsCount = 0,
|
639
|
+
isLoading: isDraftRelationsLoading,
|
640
|
+
error: isDraftRelationsError
|
641
|
+
} = useGetManyDraftRelationCountQuery(
|
642
|
+
{
|
643
|
+
model,
|
644
|
+
documentIds: [documentId],
|
645
|
+
locale: localesToPublish
|
646
|
+
},
|
647
|
+
{
|
648
|
+
skip: !documentId || localesToPublish.length === 0
|
649
|
+
}
|
650
|
+
);
|
651
|
+
React__namespace.useEffect(() => {
|
652
|
+
if (isDraftRelationsError) {
|
653
|
+
toggleNotification({
|
654
|
+
type: "danger",
|
655
|
+
message: formatAPIError(isDraftRelationsError)
|
656
|
+
});
|
657
|
+
}
|
658
|
+
}, [isDraftRelationsError, toggleNotification, formatAPIError]);
|
659
|
+
if (!schema?.options?.draftAndPublish) {
|
660
|
+
return null;
|
661
|
+
}
|
662
|
+
if (!hasI18n) {
|
663
|
+
return null;
|
664
|
+
}
|
665
|
+
if (!documentId) {
|
666
|
+
return null;
|
667
|
+
}
|
668
|
+
const publish = async () => {
|
669
|
+
await publishManyAction({
|
670
|
+
model,
|
671
|
+
documentIds: [documentId],
|
672
|
+
params: {
|
673
|
+
...params,
|
674
|
+
locale: localesToPublish
|
675
|
+
}
|
676
|
+
});
|
677
|
+
setSelectedRows([]);
|
678
|
+
};
|
679
|
+
const handleAction = async () => {
|
680
|
+
if (draftRelationsCount > 0) {
|
681
|
+
setIsConfirmationOpen(true);
|
682
|
+
} else {
|
683
|
+
await publish();
|
684
|
+
}
|
685
|
+
};
|
686
|
+
const isUnpublish = document?.status === "published";
|
687
|
+
if (isUnpublish) {
|
688
|
+
console.warn(["I18N"], "Bulk locale unpublish modal not implemented");
|
689
|
+
}
|
690
|
+
if (isConfirmationOpen) {
|
691
|
+
return {
|
692
|
+
label: formatMessage({
|
693
|
+
id: "app.components.ConfirmDialog.title",
|
694
|
+
defaultMessage: "Confirmation"
|
695
|
+
}),
|
696
|
+
variant: "danger",
|
697
|
+
dialog: {
|
698
|
+
onCancel: () => {
|
699
|
+
setIsConfirmationOpen(false);
|
700
|
+
},
|
701
|
+
onConfirm: async () => {
|
702
|
+
await publish();
|
703
|
+
setIsConfirmationOpen(false);
|
704
|
+
},
|
705
|
+
type: "dialog",
|
706
|
+
title: formatMessage({
|
707
|
+
id: getTranslation("actions.publish.dialog.title"),
|
708
|
+
defaultMessage: "Confirmation"
|
709
|
+
}),
|
710
|
+
content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "center", gap: 2, children: [
|
711
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, { width: "2.4rem", height: "2.4rem", fill: "danger600" }),
|
712
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textAlign: "center", children: formatMessage({
|
713
|
+
id: "content-manager.actions.discard.dialog.body",
|
714
|
+
defaultMessage: "Are you sure you want to discard the changes? This action is irreversible."
|
715
|
+
}) })
|
716
|
+
] })
|
717
|
+
}
|
718
|
+
};
|
719
|
+
}
|
720
|
+
return {
|
721
|
+
label: formatMessage({
|
722
|
+
id: getTranslation("CMEditViewBulkLocale.publish-title"),
|
723
|
+
defaultMessage: "Publish Multiple Locales"
|
724
|
+
}),
|
725
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.ListPlus, {}),
|
726
|
+
disabled: isPublishedTab || !canPublish,
|
727
|
+
position: ["panel"],
|
728
|
+
variant: "secondary",
|
729
|
+
dialog: {
|
730
|
+
type: "modal",
|
731
|
+
title: formatMessage({
|
732
|
+
id: getTranslation("CMEditViewBulkLocale.publish-title"),
|
733
|
+
defaultMessage: "Publish Multiple Locales"
|
734
|
+
}),
|
735
|
+
content: () => {
|
736
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
737
|
+
strapiAdmin.Table.Root,
|
738
|
+
{
|
739
|
+
headers,
|
740
|
+
rows: rows.map((row) => ({
|
741
|
+
...row,
|
742
|
+
id: row.locale
|
743
|
+
})),
|
744
|
+
selectedRows,
|
745
|
+
onSelectedRowsChange: (tableSelectedRows) => setSelectedRows(tableSelectedRows),
|
746
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
747
|
+
BulkLocaleActionModal,
|
748
|
+
{
|
749
|
+
validationErrors,
|
750
|
+
headers,
|
751
|
+
rows,
|
752
|
+
localesMetadata
|
753
|
+
}
|
754
|
+
)
|
755
|
+
}
|
756
|
+
);
|
757
|
+
},
|
758
|
+
footer: () => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
|
759
|
+
designSystem.Button,
|
760
|
+
{
|
761
|
+
loading: isDraftRelationsLoading,
|
762
|
+
disabled: localesToPublish.length === 0,
|
763
|
+
variant: "default",
|
764
|
+
onClick: handleAction,
|
765
|
+
children: formatMessage({
|
766
|
+
id: "app.utils.publish",
|
767
|
+
defaultMessage: "Publish"
|
768
|
+
})
|
769
|
+
}
|
770
|
+
) })
|
771
|
+
}
|
772
|
+
};
|
773
|
+
};
|
774
|
+
const StyledTrash = styledComponents.styled(icons.Trash)`
|
450
775
|
path {
|
451
776
|
fill: currentColor;
|
452
777
|
}
|
@@ -613,8 +938,8 @@ const doesFieldHaveI18nPluginOpt = (pluginOpts) => {
|
|
613
938
|
};
|
614
939
|
const LabelAction = ({ title, icon }) => {
|
615
940
|
const { formatMessage } = reactIntl.useIntl();
|
616
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Span, {
|
617
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, {
|
941
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Span, { tag: "span", children: [
|
942
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "span", children: `(${formatMessage(title)})` }),
|
618
943
|
React__namespace.cloneElement(icon, {
|
619
944
|
"aria-hidden": true,
|
620
945
|
focusable: false
|
@@ -622,7 +947,7 @@ const LabelAction = ({ title, icon }) => {
|
|
622
947
|
})
|
623
948
|
] });
|
624
949
|
};
|
625
|
-
const Span =
|
950
|
+
const Span = styledComponents.styled(designSystem.Flex)`
|
626
951
|
svg {
|
627
952
|
width: 12px;
|
628
953
|
height: 12px;
|
@@ -699,12 +1024,12 @@ const LocaleListCell = ({
|
|
699
1024
|
source: buttonRef,
|
700
1025
|
spacing: 16,
|
701
1026
|
centered: true,
|
702
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("ul", { children: localesForDocument.map((name) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 3,
|
1027
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("ul", { children: localesForDocument.map((name) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 3, tag: "li", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: name }) }, name)) })
|
703
1028
|
}
|
704
1029
|
)
|
705
1030
|
] });
|
706
1031
|
};
|
707
|
-
const Button =
|
1032
|
+
const Button = styledComponents.styled.button`
|
708
1033
|
width: 100%;
|
709
1034
|
|
710
1035
|
svg {
|
@@ -730,7 +1055,7 @@ const Button = styled__default.default.button`
|
|
730
1055
|
}
|
731
1056
|
}
|
732
1057
|
`;
|
733
|
-
const ActionWrapper =
|
1058
|
+
const ActionWrapper = styledComponents.styled(designSystem.Flex)`
|
734
1059
|
svg {
|
735
1060
|
height: 0.4rem;
|
736
1061
|
}
|
@@ -941,7 +1266,7 @@ const index = {
|
|
941
1266
|
},
|
942
1267
|
id: "internationalization",
|
943
1268
|
to: "internationalization",
|
944
|
-
Component: () => Promise.resolve().then(() => require("./SettingsPage-
|
1269
|
+
Component: () => Promise.resolve().then(() => require("./SettingsPage-DnLLGeBa.js")).then((mod) => ({ default: mod.ProtectedSettingsPage })),
|
945
1270
|
permissions: PERMISSIONS.accessMain
|
946
1271
|
});
|
947
1272
|
const contentManager = app.getPlugin("content-manager");
|
@@ -951,6 +1276,10 @@ const index = {
|
|
951
1276
|
actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);
|
952
1277
|
return actions;
|
953
1278
|
});
|
1279
|
+
contentManager.apis.addDocumentAction((actions) => {
|
1280
|
+
actions.splice(2, 0, BulkLocalePublishAction);
|
1281
|
+
return actions;
|
1282
|
+
});
|
954
1283
|
contentManager.injectComponent("listView", "actions", {
|
955
1284
|
name: "i18n-locale-filter",
|
956
1285
|
Component: LocalePicker
|
@@ -1054,7 +1383,7 @@ const index = {
|
|
1054
1383
|
async registerTrads({ locales }) {
|
1055
1384
|
const importedTrads = await Promise.all(
|
1056
1385
|
locales.map((locale) => {
|
1057
|
-
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-
|
1386
|
+
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-Kv6y9zPQ.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-DS-XFGSw.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-BTjekDpq.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-DmcGUBQ3.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-Cn5RYonZ.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BMBgVL3s.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-CarUU76c.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-DSHIXAa3.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CukOviB0.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
|
1058
1387
|
return {
|
1059
1388
|
data: prefixPluginTranslations(data, pluginId),
|
1060
1389
|
locale
|
@@ -1073,10 +1402,9 @@ const index = {
|
|
1073
1402
|
exports.PERMISSIONS = PERMISSIONS;
|
1074
1403
|
exports.getTranslation = getTranslation;
|
1075
1404
|
exports.index = index;
|
1076
|
-
exports.isBaseQueryError = isBaseQueryError;
|
1077
1405
|
exports.useCreateLocaleMutation = useCreateLocaleMutation;
|
1078
1406
|
exports.useDeleteLocaleMutation = useDeleteLocaleMutation;
|
1079
1407
|
exports.useGetDefaultLocalesQuery = useGetDefaultLocalesQuery;
|
1080
1408
|
exports.useGetLocalesQuery = useGetLocalesQuery;
|
1081
1409
|
exports.useUpdateLocaleMutation = useUpdateLocaleMutation;
|
1082
|
-
//# sourceMappingURL=index-
|
1410
|
+
//# sourceMappingURL=index-DtEKsPcR.js.map
|