gt-sanity 2.0.13 → 2.0.15
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/{index.mjs → index.cjs} +337 -325
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.mts → index.d.cts} +43 -43
- package/dist/index.d.ts +43 -43
- package/dist/index.js +324 -336
- package/dist/index.js.map +1 -1
- package/package.json +18 -20
- package/sanity.json +1 -1
- package/src/adapter/createTask.ts +3 -3
- package/src/adapter/getLocales.ts +1 -1
- package/src/components/TranslationsProvider.tsx +1 -1
- package/src/components/page/TranslationsTool.tsx +0 -1
- package/src/configuration/baseDocumentLevelConfig/helpers/createI18nDocAndPatchMetadata.ts +1 -1
- package/src/configuration/baseDocumentLevelConfig/helpers/patchI18nDoc.ts +1 -3
- package/src/configuration/baseFieldLevelConfig.ts +1 -8
- package/src/sanity-api/resolveRefs.ts +0 -10
- package/src/serialization/BaseSerializationConfig.ts +1 -1
- package/src/serialization/__tests__/BaseDocumentSerializer/documentInlineMarks.test.ts +3 -8
- package/src/serialization/__tests__/README +1 -1
- package/src/serialization/__tests__/__fixtures__/inlineSchema.ts +1 -1
- package/src/serialization/__tests__/__fixtures__/messy-html.html +5 -1
- package/src/serialization/__tests__/__fixtures__/schema.ts +1 -1
- package/src/serialization/serialize/fieldFilters.ts +1 -1
- package/src/serialization/types.ts +1 -1
- package/src/translation/downloadTranslations.ts +1 -1
- package/src/translation/initProject.ts +2 -0
- package/{v2-incompatible.js → v2-incompatible.cjs} +2 -2
- package/dist/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { documentInternationalization } from "@sanity/document-internationalization";
|
|
2
|
+
import { DocumentInternationalizationMenu, documentInternationalization as documentInternationalization2, useDeleteTranslationAction, useDocumentInternationalizationContext, useDuplicateWithTranslationsAction } from "@sanity/document-internationalization";
|
|
3
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
4
|
+
import { ThemeProvider, ToastProvider, Box, Flex, Spinner, Card, Text, useToast, Label, Grid, Button, Switch, Stack, Tooltip, Dialog, Container, Heading } from "@sanity/ui";
|
|
5
|
+
import { buildTheme } from "@sanity/ui/theme";
|
|
6
|
+
import o, { useState, useEffect, createContext, useRef, useCallback, useContext, useDebugValue, createElement, useMemo } from "react";
|
|
7
|
+
import { useClient as useClient$1, useSchema, definePlugin } from "sanity";
|
|
8
|
+
import { GT, getLocaleProperties } from "generaltranslation";
|
|
9
|
+
import { libraryDefaultLocale } from "generaltranslation/internal";
|
|
10
|
+
import { htmlToBlocks } from "@portabletext/block-tools";
|
|
11
|
+
import { Schema } from "@sanity/schema";
|
|
12
|
+
import { toHTML } from "@portabletext/to-html";
|
|
13
|
+
import merge from "lodash.merge";
|
|
14
|
+
import { JSONPath } from "jsonpath-plus";
|
|
15
|
+
import JSONPointer from "jsonpointer";
|
|
16
|
+
import { extractWithPath, arrayToJSONMatchPath } from "@sanity/mutator";
|
|
17
|
+
import { CheckmarkCircleIcon, DownloadIcon, LinkIcon, PublishIcon, TranslateIcon } from "@sanity/icons";
|
|
18
|
+
import { Link, route } from "sanity/router";
|
|
19
|
+
const useClient = () => useClient$1({ apiVersion: "2025-09-15" });
|
|
9
20
|
function useSecrets(id) {
|
|
10
|
-
const [loading, setLoading] =
|
|
11
|
-
return
|
|
21
|
+
const [loading, setLoading] = useState(!0), [secrets, setSecrets] = useState(null), client = useClient();
|
|
22
|
+
return useEffect(() => {
|
|
12
23
|
function fetchData() {
|
|
13
24
|
client.fetch("* [_id == $id][0]", { id }).then((doc) => {
|
|
14
25
|
const result = {};
|
|
@@ -20,7 +31,7 @@ function useSecrets(id) {
|
|
|
20
31
|
fetchData();
|
|
21
32
|
}, [id, client]), { loading, secrets };
|
|
22
33
|
}
|
|
23
|
-
const SECRETS_NAMESPACE = "generaltranslation.secrets", gt = new
|
|
34
|
+
const SECRETS_NAMESPACE = "generaltranslation.secrets", gt = new GT();
|
|
24
35
|
function overrideConfig(secrets) {
|
|
25
36
|
gt.setConfig({
|
|
26
37
|
...secrets?.project && { projectId: secrets?.project },
|
|
@@ -50,7 +61,7 @@ class GTConfig {
|
|
|
50
61
|
return this.instance || (this.instance = new GTConfig(
|
|
51
62
|
SECRETS_NAMESPACE,
|
|
52
63
|
"language",
|
|
53
|
-
gt.sourceLocale ||
|
|
64
|
+
gt.sourceLocale || libraryDefaultLocale,
|
|
54
65
|
[],
|
|
55
66
|
[],
|
|
56
67
|
() => "",
|
|
@@ -110,18 +121,18 @@ class GTConfig {
|
|
|
110
121
|
return this.additionalBlockDeserializers;
|
|
111
122
|
}
|
|
112
123
|
}
|
|
113
|
-
const pluginConfig = GTConfig.getInstance(), theme =
|
|
124
|
+
const pluginConfig = GTConfig.getInstance(), theme = buildTheme(), BaseTranslationWrapper = ({
|
|
114
125
|
children,
|
|
115
126
|
secretsNamespace = pluginConfig.getSecretsNamespace(),
|
|
116
127
|
padding = 4,
|
|
117
128
|
showContainer = !0
|
|
118
129
|
}) => {
|
|
119
|
-
const { loading: loadingSecrets, secrets } = useSecrets(secretsNamespace), content = /* @__PURE__ */
|
|
120
|
-
loadingSecrets && /* @__PURE__ */
|
|
121
|
-
!loadingSecrets && !secrets && /* @__PURE__ */
|
|
130
|
+
const { loading: loadingSecrets, secrets } = useSecrets(secretsNamespace), content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
131
|
+
loadingSecrets && /* @__PURE__ */ jsx(Flex, { padding: 5, align: "center", justify: "center", children: /* @__PURE__ */ jsx(Spinner, {}) }),
|
|
132
|
+
!loadingSecrets && !secrets && /* @__PURE__ */ jsx(Box, { padding, children: /* @__PURE__ */ jsx(Card, { tone: "caution", padding: [2, 3, 4, 4], shadow: 1, radius: 2, children: /* @__PURE__ */ jsx(Text, { children: "Can't find secrets for your translation service. Did you load them into this dataset?" }) }) }),
|
|
122
133
|
!loadingSecrets && secrets && children
|
|
123
134
|
] });
|
|
124
|
-
return /* @__PURE__ */
|
|
135
|
+
return /* @__PURE__ */ jsx(ThemeProvider, { theme, children: /* @__PURE__ */ jsx(ToastProvider, { paddingY: 7, children: showContainer ? /* @__PURE__ */ jsx(Box, { padding, children: content }) : content }) });
|
|
125
136
|
}, reconcileArray = (origArray, translatedArray) => {
|
|
126
137
|
if (translatedArray && translatedArray.some((el) => typeof el == "string"))
|
|
127
138
|
return translatedArray;
|
|
@@ -152,12 +163,12 @@ const pluginConfig = GTConfig.getInstance(), theme = theme$1.buildTheme(), BaseT
|
|
|
152
163
|
const merged = {};
|
|
153
164
|
return ["_rev", "_id", "_type"].forEach((metaKey) => {
|
|
154
165
|
translatedFields[metaKey] && (merged[metaKey] = translatedFields[metaKey]);
|
|
155
|
-
}),
|
|
156
|
-
const origVal =
|
|
157
|
-
|
|
166
|
+
}), extractWithPath(`..${baseLang}`, translatedFields).forEach((match2) => {
|
|
167
|
+
const origVal = extractWithPath(
|
|
168
|
+
arrayToJSONMatchPath(match2.path),
|
|
158
169
|
baseDoc
|
|
159
|
-
)[0].value, translatedVal =
|
|
160
|
-
|
|
170
|
+
)[0].value, translatedVal = extractWithPath(
|
|
171
|
+
arrayToJSONMatchPath(match2.path),
|
|
161
172
|
translatedFields
|
|
162
173
|
)[0].value;
|
|
163
174
|
let valToPatch;
|
|
@@ -171,14 +182,14 @@ const pluginConfig = GTConfig.getInstance(), theme = theme$1.buildTheme(), BaseT
|
|
|
171
182
|
localeId.replace("-", "_")
|
|
172
183
|
// replace it with our locale
|
|
173
184
|
];
|
|
174
|
-
merged[
|
|
185
|
+
merged[arrayToJSONMatchPath(destinationPath)] = valToPatch;
|
|
175
186
|
}), merged;
|
|
176
187
|
}, documentLevelMerge = (translatedFields, baseDoc) => reconcileObject(baseDoc, translatedFields), BaseDocumentMerger = {
|
|
177
188
|
fieldLevelMerge,
|
|
178
189
|
documentLevelMerge,
|
|
179
190
|
reconcileArray,
|
|
180
191
|
reconcileObject
|
|
181
|
-
}, defaultSchema =
|
|
192
|
+
}, defaultSchema = Schema.compile({
|
|
182
193
|
name: "default",
|
|
183
194
|
types: [
|
|
184
195
|
{
|
|
@@ -194,7 +205,7 @@ const pluginConfig = GTConfig.getInstance(), theme = theme$1.buildTheme(), BaseT
|
|
|
194
205
|
}
|
|
195
206
|
]
|
|
196
207
|
}), blockContentType = defaultSchema.get("default").fields.find((field) => field.name === "block").type, preprocess = (html) => {
|
|
197
|
-
const intermediateBlocks =
|
|
208
|
+
const intermediateBlocks = htmlToBlocks(
|
|
198
209
|
`<p>${html}</p>`,
|
|
199
210
|
blockContentType
|
|
200
211
|
);
|
|
@@ -286,7 +297,7 @@ const defaultStopTypes = [
|
|
|
286
297
|
deserialize(el, next2) {
|
|
287
298
|
if (!el.hasChildNodes() || !el.getAttribute("data-gt-internal"))
|
|
288
299
|
return;
|
|
289
|
-
const { html, data } = detachGTData(el.outerHTML), block =
|
|
300
|
+
const { html, data } = detachGTData(el.outerHTML), block = htmlToBlocks(html, blockContentType)[0], children = next2(el.childNodes);
|
|
290
301
|
let markDefs = [];
|
|
291
302
|
return "markDefs" in block && (markDefs = block.markDefs ?? []), data?.markDef && markDefs.push(data.markDef), children && children.forEach((child) => {
|
|
292
303
|
child.marks = data?.markDef?._key ? [...child.marks || [], data.markDef._key] : [...child.marks || []];
|
|
@@ -304,7 +315,7 @@ const defaultStopTypes = [
|
|
|
304
315
|
return;
|
|
305
316
|
const style = el.getAttribute("data-style") ?? "";
|
|
306
317
|
return {
|
|
307
|
-
...
|
|
318
|
+
...htmlToBlocks(el.outerHTML, blockContentType)[0],
|
|
308
319
|
style,
|
|
309
320
|
children: next2(el.childNodes)
|
|
310
321
|
};
|
|
@@ -325,10 +336,10 @@ const defaultStopTypes = [
|
|
|
325
336
|
if (!listItem)
|
|
326
337
|
return;
|
|
327
338
|
const level = el.getAttribute("data-level") && parseInt(el.getAttribute("data-level") || "0", 10), _key = el.id;
|
|
328
|
-
let block =
|
|
339
|
+
let block = htmlToBlocks(parent.outerHTML, blockContentType)[0];
|
|
329
340
|
const customStyle = el.children?.[0]?.getAttribute("data-style");
|
|
330
341
|
if (new RegExp(/<("[^"]*"|'[^']*'|[^'">])*>/).test(el.innerHTML)) {
|
|
331
|
-
const newBlock =
|
|
342
|
+
const newBlock = htmlToBlocks(el.innerHTML, blockContentType)[0];
|
|
332
343
|
if (newBlock && (block = {
|
|
333
344
|
...block,
|
|
334
345
|
...newBlock,
|
|
@@ -391,7 +402,7 @@ const defaultStopTypes = [
|
|
|
391
402
|
const filteredObj = { _type: obj._type }, fieldFilterFunc = (field) => field.localize === !1 ? !1 : field.type === "string" || field.type === "text" || Array.isArray(obj[field.name]) ? !0 : !stopTypes.includes(field.type);
|
|
392
403
|
return [
|
|
393
404
|
...META_FIELDS$1,
|
|
394
|
-
...objFields
|
|
405
|
+
...objFields.filter(fieldFilterFunc).map((field) => field.name)
|
|
395
406
|
].forEach((field) => {
|
|
396
407
|
obj[field] && (filteredObj[field] = obj[field]);
|
|
397
408
|
}), filteredObj;
|
|
@@ -400,12 +411,12 @@ const defaultStopTypes = [
|
|
|
400
411
|
if (stopTypes.includes(obj._type))
|
|
401
412
|
return "";
|
|
402
413
|
if (serializers.types && Object.keys(serializers.types).includes(obj._type))
|
|
403
|
-
return
|
|
414
|
+
return toHTML([obj], { components: serializers });
|
|
404
415
|
if (obj._type === "span" || obj._type === "block")
|
|
405
|
-
return
|
|
416
|
+
return toHTML(obj, { components: serializers });
|
|
406
417
|
let fieldNames = Object.keys(obj).filter((key) => key !== "_type");
|
|
407
|
-
const
|
|
408
|
-
|
|
418
|
+
const schema = getSchema(obj._type);
|
|
419
|
+
schema && schema.fields && (fieldNames = schema.fields.map((field) => field.name).filter((schemaKey) => Object.keys(obj).includes(schemaKey))), typeof obj == "object" && !obj._type && (obj._type = "");
|
|
409
420
|
const newSerializationMethods = {}, tempType = `${obj._type}__temp_type__${Math.random().toString(36).substring(7)}`, objToSerialize = { _type: tempType };
|
|
410
421
|
META_FIELDS.filter((f2) => f2 !== "_type").forEach((field) => {
|
|
411
422
|
objToSerialize[field] = obj[field];
|
|
@@ -446,7 +457,7 @@ const defaultStopTypes = [
|
|
|
446
457
|
};
|
|
447
458
|
let serializedBlock = "";
|
|
448
459
|
try {
|
|
449
|
-
serializedBlock =
|
|
460
|
+
serializedBlock = toHTML(objToSerialize, {
|
|
450
461
|
components: {
|
|
451
462
|
...serializers,
|
|
452
463
|
types: {
|
|
@@ -465,16 +476,16 @@ const defaultStopTypes = [
|
|
|
465
476
|
const output = fieldContent.filter(
|
|
466
477
|
(block) => !stopTypes.includes(block._type)
|
|
467
478
|
).map((block) => {
|
|
468
|
-
const
|
|
469
|
-
return
|
|
479
|
+
const schema = getSchema(block._type);
|
|
480
|
+
return schema && schema.fields ? fieldFilter(block, schema.fields, stopTypes) : block;
|
|
470
481
|
}).map((obj) => typeof obj == "string" ? `<span>${obj}</span>` : serializeObject(obj, stopTypes, serializers));
|
|
471
482
|
return `<div class="${fieldName}" data-type="array">${output.join("")}</div>`;
|
|
472
483
|
};
|
|
473
484
|
return {
|
|
474
485
|
serializeDocument: (doc, translationLevel = "document", baseLang = "en", stopTypes = defaultStopTypes, serializers = customSerializers) => {
|
|
475
|
-
const
|
|
486
|
+
const schema = getSchema(doc._type);
|
|
476
487
|
let filteredObj = {};
|
|
477
|
-
translationLevel === "field" ? filteredObj = languageObjectFieldFilter(doc, baseLang) : filteredObj = fieldFilter(doc,
|
|
488
|
+
translationLevel === "field" ? filteredObj = languageObjectFieldFilter(doc, baseLang) : filteredObj = fieldFilter(doc, schema?.fields ?? [], stopTypes);
|
|
478
489
|
const serializedFields = {};
|
|
479
490
|
for (const key in filteredObj) {
|
|
480
491
|
if (filteredObj.hasOwnProperty(key) === !1) continue;
|
|
@@ -538,7 +549,7 @@ const deserializeArray = (arrayHTML, deserializers = customDeserializers, blockD
|
|
|
538
549
|
child,
|
|
539
550
|
deserializers,
|
|
540
551
|
blockDeserializers
|
|
541
|
-
), deserializedObject._key = child.id) : (deserializedObject =
|
|
552
|
+
), deserializedObject._key = child.id) : (deserializedObject = htmlToBlocks(child.outerHTML, blockContentType, {
|
|
542
553
|
rules: blockDeserializers
|
|
543
554
|
}), deserializedObject = mergeBlocks(deserializedObject), deserializedObject._key = child.id);
|
|
544
555
|
} catch (e) {
|
|
@@ -606,7 +617,7 @@ function forEachMatchingField(documentId, document2, fields, callback) {
|
|
|
606
617
|
for (const field of entry.fields) {
|
|
607
618
|
const { property, type } = field;
|
|
608
619
|
try {
|
|
609
|
-
const results =
|
|
620
|
+
const results = JSONPath({
|
|
610
621
|
json: document2,
|
|
611
622
|
path: property,
|
|
612
623
|
resultType: "all",
|
|
@@ -639,9 +650,9 @@ function applyDocuments(documentId, sourceDocument, targetDocument, ignore, skip
|
|
|
639
650
|
for (const [key, value] of Object.entries(clonedTarget))
|
|
640
651
|
mergedDocument[key] = value;
|
|
641
652
|
return forEachMatchingField(documentId, sourceDocument, ignore, (result) => {
|
|
642
|
-
|
|
653
|
+
JSONPointer.set(mergedDocument, result.pointer, result.value);
|
|
643
654
|
}), forEachMatchingField(documentId, sourceDocument, dedupe, (result) => {
|
|
644
|
-
|
|
655
|
+
JSONPointer.set(
|
|
645
656
|
mergedDocument,
|
|
646
657
|
result.pointer,
|
|
647
658
|
dedupeFieldValue(result.value, localeId)
|
|
@@ -686,7 +697,7 @@ function createStableTranslationKey(branchId, documentId, localeId) {
|
|
|
686
697
|
return branchId ? `${branchId}:${publishedId}:${localeId}` : `${publishedId}:${localeId}`;
|
|
687
698
|
}
|
|
688
699
|
function deserializeDocument(document2) {
|
|
689
|
-
const deserializers =
|
|
700
|
+
const deserializers = merge(
|
|
690
701
|
{ types: {} },
|
|
691
702
|
pluginConfig.getAdditionalDeserializers()
|
|
692
703
|
), blockDeserializers = [
|
|
@@ -699,11 +710,11 @@ function deserializeDocument(document2) {
|
|
|
699
710
|
blockDeserializers
|
|
700
711
|
);
|
|
701
712
|
}
|
|
702
|
-
function serializeDocument(document2,
|
|
713
|
+
function serializeDocument(document2, schema, baseLanguage) {
|
|
703
714
|
const stopTypes = [
|
|
704
715
|
...defaultStopTypes,
|
|
705
716
|
...pluginConfig.getAdditionalStopTypes()
|
|
706
|
-
], serializers =
|
|
717
|
+
], serializers = merge(
|
|
707
718
|
customSerializers,
|
|
708
719
|
pluginConfig.getAdditionalSerializers()
|
|
709
720
|
), docToSerialize = stripIgnoredFields(
|
|
@@ -711,7 +722,7 @@ function serializeDocument(document2, schema2, baseLanguage) {
|
|
|
711
722
|
pluginConfig.getIgnoreFields(),
|
|
712
723
|
pluginConfig.getDedupeFields()
|
|
713
724
|
);
|
|
714
|
-
return BaseDocumentSerializer(
|
|
725
|
+
return BaseDocumentSerializer(schema).serializeDocument(
|
|
715
726
|
docToSerialize,
|
|
716
727
|
"document",
|
|
717
728
|
baseLanguage,
|
|
@@ -737,12 +748,12 @@ async function uploadFiles(documents, secrets) {
|
|
|
737
748
|
fileName: `sanity/${info.documentId}`,
|
|
738
749
|
fileId: info.documentId,
|
|
739
750
|
fileFormat: "HTML",
|
|
740
|
-
locale: gt.sourceLocale ||
|
|
751
|
+
locale: gt.sourceLocale || libraryDefaultLocale,
|
|
741
752
|
versionId: info.versionId || void 0
|
|
742
753
|
}
|
|
743
754
|
})),
|
|
744
755
|
{
|
|
745
|
-
sourceLocale: gt.sourceLocale ||
|
|
756
|
+
sourceLocale: gt.sourceLocale || libraryDefaultLocale
|
|
746
757
|
}
|
|
747
758
|
);
|
|
748
759
|
}
|
|
@@ -780,7 +791,7 @@ async function initProject(uploadResult, options, secrets) {
|
|
|
780
791
|
}
|
|
781
792
|
async function createJobs(uploadResult, localeIds, secrets) {
|
|
782
793
|
return overrideConfig(secrets), await gt.enqueueFiles(uploadResult.uploadedFiles, {
|
|
783
|
-
sourceLocale: gt.sourceLocale ||
|
|
794
|
+
sourceLocale: gt.sourceLocale || libraryDefaultLocale,
|
|
784
795
|
targetLocales: localeIds
|
|
785
796
|
});
|
|
786
797
|
}
|
|
@@ -959,7 +970,7 @@ async function patchI18nDoc(sourceDocumentId, i18nDocId, sourceDocument, mergedD
|
|
|
959
970
|
existingDocument,
|
|
960
971
|
dedupeFields,
|
|
961
972
|
(result) => {
|
|
962
|
-
|
|
973
|
+
JSONPointer.set(appliedDocument, result.pointer, result.value);
|
|
963
974
|
}
|
|
964
975
|
), await client.patch(i18nDocId, { set: appliedDocument }).commit();
|
|
965
976
|
}
|
|
@@ -1252,12 +1263,12 @@ async function publishTranslations(documentIds, client) {
|
|
|
1252
1263
|
}
|
|
1253
1264
|
), publishedDocumentIds;
|
|
1254
1265
|
}
|
|
1255
|
-
const getLocales = async (
|
|
1266
|
+
const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) => ({
|
|
1256
1267
|
localeId: locale,
|
|
1257
1268
|
description: gt.getLocaleProperties(locale).name,
|
|
1258
1269
|
enabled: !0
|
|
1259
|
-
})), TranslationsContext =
|
|
1260
|
-
const context =
|
|
1270
|
+
})), TranslationsContext = createContext(null), useTranslations = () => {
|
|
1271
|
+
const context = useContext(TranslationsContext);
|
|
1261
1272
|
if (!context)
|
|
1262
1273
|
throw new Error("useTranslations must be used within TranslationsProvider");
|
|
1263
1274
|
return context;
|
|
@@ -1265,25 +1276,25 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1265
1276
|
children,
|
|
1266
1277
|
singleDocument
|
|
1267
1278
|
}) => {
|
|
1268
|
-
const [isBusy, setIsBusy] =
|
|
1279
|
+
const [isBusy, setIsBusy] = useState(!1), [documents, setDocuments] = useState([]), [locales, setLocales] = useState([]), [autoRefresh, setAutoRefresh] = useState(!1), [autoImport, setAutoImport] = useState(!1), [autoPatchReferences, setAutoPatchReferences] = useState(!1), [autoPublish, setAutoPublish] = useState(!1), [loadingDocuments, setLoadingDocuments] = useState(!1), [importProgress, setImportProgress] = useState({
|
|
1269
1280
|
current: 0,
|
|
1270
1281
|
total: 0,
|
|
1271
1282
|
isImporting: !1
|
|
1272
|
-
}), [importedTranslations, setImportedTranslations] =
|
|
1283
|
+
}), [importedTranslations, setImportedTranslations] = useState(
|
|
1273
1284
|
/* @__PURE__ */ new Set()
|
|
1274
|
-
), [existingTranslations, setExistingTranslations] =
|
|
1285
|
+
), [existingTranslations, setExistingTranslations] = useState(
|
|
1275
1286
|
/* @__PURE__ */ new Set()
|
|
1276
|
-
), [downloadStatus, setDownloadStatus] =
|
|
1287
|
+
), [downloadStatus, setDownloadStatus] = useState({
|
|
1277
1288
|
downloaded: /* @__PURE__ */ new Set(),
|
|
1278
1289
|
failed: /* @__PURE__ */ new Set(),
|
|
1279
1290
|
skipped: /* @__PURE__ */ new Set()
|
|
1280
|
-
}), downloadStatusRef =
|
|
1291
|
+
}), downloadStatusRef = useRef(downloadStatus), [translationStatuses, setTranslationStatuses] = useState(/* @__PURE__ */ new Map()), [isRefreshing, setIsRefreshing] = useState(!1), client = useClient(), schema = useSchema(), translationContext = { client, schema }, toast = useToast(), { loading: loadingSecrets, secrets } = useSecrets(
|
|
1281
1292
|
pluginConfig.getSecretsNamespace()
|
|
1282
|
-
), [branchId, setBranchId] =
|
|
1283
|
-
|
|
1293
|
+
), [branchId, setBranchId] = useState(void 0);
|
|
1294
|
+
useEffect(() => {
|
|
1284
1295
|
downloadStatusRef.current = downloadStatus;
|
|
1285
1296
|
}, [downloadStatus]);
|
|
1286
|
-
const fetchDocuments =
|
|
1297
|
+
const fetchDocuments = useCallback(async () => {
|
|
1287
1298
|
setLoadingDocuments(!0);
|
|
1288
1299
|
try {
|
|
1289
1300
|
if (singleDocument) {
|
|
@@ -1304,7 +1315,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1304
1315
|
} finally {
|
|
1305
1316
|
setLoadingDocuments(!1);
|
|
1306
1317
|
}
|
|
1307
|
-
}, [client, singleDocument]), fetchLocales =
|
|
1318
|
+
}, [client, singleDocument]), fetchLocales = useCallback(async () => {
|
|
1308
1319
|
if (secrets)
|
|
1309
1320
|
try {
|
|
1310
1321
|
const availableLocales = await getLocales(secrets);
|
|
@@ -1316,7 +1327,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1316
1327
|
closable: !0
|
|
1317
1328
|
});
|
|
1318
1329
|
}
|
|
1319
|
-
}, [secrets]), fetchExistingTranslations =
|
|
1330
|
+
}, [secrets]), fetchExistingTranslations = useCallback(async () => {
|
|
1320
1331
|
if (!(!documents.length || !locales.length))
|
|
1321
1332
|
try {
|
|
1322
1333
|
const sourceLocale = pluginConfig.getSourceLocale(), availableLocaleIds = locales.filter((locale) => locale.enabled !== !1).map((locale) => locale.localeId), documentIds = documents.map(getDocumentPublishedId), existingMetadata = await client.fetch(`*[
|
|
@@ -1348,7 +1359,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1348
1359
|
closable: !0
|
|
1349
1360
|
});
|
|
1350
1361
|
}
|
|
1351
|
-
}, [documents, locales, client]), handleTranslateAll =
|
|
1362
|
+
}, [documents, locales, client]), handleTranslateAll = useCallback(async () => {
|
|
1352
1363
|
if (!(!secrets || documents.length === 0)) {
|
|
1353
1364
|
setIsBusy(!0);
|
|
1354
1365
|
try {
|
|
@@ -1357,7 +1368,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1357
1368
|
try {
|
|
1358
1369
|
const serialized = serializeDocument(
|
|
1359
1370
|
cleanDoc,
|
|
1360
|
-
|
|
1371
|
+
schema,
|
|
1361
1372
|
baseLanguage
|
|
1362
1373
|
);
|
|
1363
1374
|
return {
|
|
@@ -1387,7 +1398,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1387
1398
|
setIsBusy(!1);
|
|
1388
1399
|
}
|
|
1389
1400
|
}
|
|
1390
|
-
}, [secrets, documents, locales,
|
|
1401
|
+
}, [secrets, documents, locales, schema]), handleImportAll = useCallback(async () => {
|
|
1391
1402
|
if (!(!secrets || documents.length === 0 || !branchId)) {
|
|
1392
1403
|
setIsBusy(!0);
|
|
1393
1404
|
try {
|
|
@@ -1450,7 +1461,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1450
1461
|
downloadStatus,
|
|
1451
1462
|
translationContext,
|
|
1452
1463
|
branchId
|
|
1453
|
-
]), getExistingTranslations =
|
|
1464
|
+
]), getExistingTranslations = useCallback(
|
|
1454
1465
|
async (documentIds, localeIds, branchId2) => {
|
|
1455
1466
|
const sourceLocale = pluginConfig.getSourceLocale(), existingMetadata = await client.fetch(`*[
|
|
1456
1467
|
_type == 'translation.metadata' &&
|
|
@@ -1477,7 +1488,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1477
1488
|
}), existing;
|
|
1478
1489
|
},
|
|
1479
1490
|
[client]
|
|
1480
|
-
), handleImportMissing =
|
|
1491
|
+
), handleImportMissing = useCallback(async () => {
|
|
1481
1492
|
if (!(!secrets || documents.length === 0 || !branchId)) {
|
|
1482
1493
|
setIsBusy(!0);
|
|
1483
1494
|
try {
|
|
@@ -1554,7 +1565,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1554
1565
|
translationContext,
|
|
1555
1566
|
getExistingTranslations,
|
|
1556
1567
|
branchId
|
|
1557
|
-
]), handleGetBranchId =
|
|
1568
|
+
]), handleGetBranchId = useCallback(
|
|
1558
1569
|
async (secrets2) => {
|
|
1559
1570
|
overrideConfig(secrets2);
|
|
1560
1571
|
const defaultBranch = await gt.createBranch({
|
|
@@ -1564,7 +1575,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1564
1575
|
setBranchId(defaultBranch.branch.id);
|
|
1565
1576
|
},
|
|
1566
1577
|
[secrets]
|
|
1567
|
-
), handleRefreshAll =
|
|
1578
|
+
), handleRefreshAll = useCallback(async () => {
|
|
1568
1579
|
if (!(!secrets || documents.length === 0 || !branchId)) {
|
|
1569
1580
|
setIsRefreshing(!0);
|
|
1570
1581
|
try {
|
|
@@ -1584,7 +1595,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1584
1595
|
downloadStatusRef.current,
|
|
1585
1596
|
secrets
|
|
1586
1597
|
);
|
|
1587
|
-
setTranslationStatuses((
|
|
1598
|
+
setTranslationStatuses(() => {
|
|
1588
1599
|
const newStatuses = /* @__PURE__ */ new Map();
|
|
1589
1600
|
for (const doc of documents)
|
|
1590
1601
|
for (const localeId of availableLocaleIds) {
|
|
@@ -1631,7 +1642,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1631
1642
|
setIsRefreshing(!1);
|
|
1632
1643
|
}
|
|
1633
1644
|
}
|
|
1634
|
-
}, [secrets, documents, locales, branchId]), handleImportDocument =
|
|
1645
|
+
}, [secrets, documents, locales, branchId]), handleImportDocument = useCallback(
|
|
1635
1646
|
async (documentId, versionId, localeId) => {
|
|
1636
1647
|
if (!secrets) return;
|
|
1637
1648
|
const key = createTranslationStatusKey(
|
|
@@ -1718,7 +1729,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1718
1729
|
}
|
|
1719
1730
|
},
|
|
1720
1731
|
[secrets, documents, translationContext, translationStatuses, branchId]
|
|
1721
|
-
), handlePatchDocumentReferences =
|
|
1732
|
+
), handlePatchDocumentReferences = useCallback(async () => {
|
|
1722
1733
|
if (!secrets || documents.length === 0) return 0;
|
|
1723
1734
|
setIsBusy(!0);
|
|
1724
1735
|
try {
|
|
@@ -1792,7 +1803,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1792
1803
|
} finally {
|
|
1793
1804
|
setIsBusy(!1), setImportProgress({ current: 0, total: 0, isImporting: !1 });
|
|
1794
1805
|
}
|
|
1795
|
-
}, [secrets, documents, locales, client, branchId]), handlePublishAllTranslations =
|
|
1806
|
+
}, [secrets, documents, locales, client, branchId]), handlePublishAllTranslations = useCallback(async () => {
|
|
1796
1807
|
if (!secrets || documents.length === 0) return 0;
|
|
1797
1808
|
setIsBusy(!0);
|
|
1798
1809
|
try {
|
|
@@ -1848,13 +1859,13 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1848
1859
|
setIsBusy(!1);
|
|
1849
1860
|
}
|
|
1850
1861
|
}, [secrets, documents, client, branchId]);
|
|
1851
|
-
|
|
1862
|
+
useEffect(() => {
|
|
1852
1863
|
fetchDocuments();
|
|
1853
|
-
}, [fetchDocuments]),
|
|
1864
|
+
}, [fetchDocuments]), useEffect(() => {
|
|
1854
1865
|
secrets && fetchLocales();
|
|
1855
|
-
}, [fetchLocales, secrets]),
|
|
1866
|
+
}, [fetchLocales, secrets]), useEffect(() => {
|
|
1856
1867
|
documents.length > 0 && locales.length > 0 && fetchExistingTranslations();
|
|
1857
|
-
}, [fetchExistingTranslations]),
|
|
1868
|
+
}, [fetchExistingTranslations]), useEffect(() => {
|
|
1858
1869
|
documents.length > 0 && locales.length > 0 && secrets && !loadingDocuments && branchId && handleRefreshAll();
|
|
1859
1870
|
}, [
|
|
1860
1871
|
documents,
|
|
@@ -1863,15 +1874,15 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1863
1874
|
loadingDocuments,
|
|
1864
1875
|
branchId,
|
|
1865
1876
|
handleRefreshAll
|
|
1866
|
-
]),
|
|
1877
|
+
]), useEffect(() => {
|
|
1867
1878
|
if (!autoRefresh || documents.length === 0 || !secrets) return;
|
|
1868
1879
|
const interval = setInterval(async () => {
|
|
1869
1880
|
await handleRefreshAll();
|
|
1870
1881
|
}, 1e4);
|
|
1871
1882
|
return () => clearInterval(interval);
|
|
1872
|
-
}, [autoRefresh, documents.length, secrets, handleRefreshAll]),
|
|
1883
|
+
}, [autoRefresh, documents.length, secrets, handleRefreshAll]), useEffect(() => {
|
|
1873
1884
|
setImportedTranslations(new Set(downloadStatus.downloaded));
|
|
1874
|
-
}, [downloadStatus.downloaded]),
|
|
1885
|
+
}, [downloadStatus.downloaded]), useEffect(() => {
|
|
1875
1886
|
secrets && handleGetBranchId(secrets);
|
|
1876
1887
|
}, [secrets, handleGetBranchId]);
|
|
1877
1888
|
const contextValue = {
|
|
@@ -1907,12 +1918,12 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1907
1918
|
handlePatchDocumentReferences,
|
|
1908
1919
|
handlePublishAllTranslations
|
|
1909
1920
|
};
|
|
1910
|
-
return /* @__PURE__ */
|
|
1921
|
+
return /* @__PURE__ */ jsx(TranslationsContext.Provider, { value: contextValue, children });
|
|
1911
1922
|
};
|
|
1912
1923
|
function ProgressBar({ progress }) {
|
|
1913
|
-
return typeof progress > "u" ? (console.warn("No progress prop passed to ProgressBar"), null) : /* @__PURE__ */
|
|
1914
|
-
/* @__PURE__ */
|
|
1915
|
-
|
|
1924
|
+
return typeof progress > "u" ? (console.warn("No progress prop passed to ProgressBar"), null) : /* @__PURE__ */ jsxs(Card, { border: !0, radius: 2, style: { width: "100%", position: "relative" }, children: [
|
|
1925
|
+
/* @__PURE__ */ jsx(
|
|
1926
|
+
Flex,
|
|
1916
1927
|
{
|
|
1917
1928
|
style: {
|
|
1918
1929
|
position: "absolute",
|
|
@@ -1924,14 +1935,14 @@ function ProgressBar({ progress }) {
|
|
|
1924
1935
|
},
|
|
1925
1936
|
align: "center",
|
|
1926
1937
|
justify: "center",
|
|
1927
|
-
children: /* @__PURE__ */
|
|
1938
|
+
children: /* @__PURE__ */ jsxs(Label, { size: 1, children: [
|
|
1928
1939
|
progress,
|
|
1929
1940
|
"%"
|
|
1930
1941
|
] })
|
|
1931
1942
|
}
|
|
1932
1943
|
),
|
|
1933
|
-
/* @__PURE__ */
|
|
1934
|
-
|
|
1944
|
+
/* @__PURE__ */ jsx(
|
|
1945
|
+
Card,
|
|
1935
1946
|
{
|
|
1936
1947
|
style: {
|
|
1937
1948
|
width: "100%",
|
|
@@ -1952,7 +1963,7 @@ const LanguageStatus = ({
|
|
|
1952
1963
|
importFile,
|
|
1953
1964
|
isImported = !1
|
|
1954
1965
|
}) => {
|
|
1955
|
-
const [isBusy, setIsBusy] =
|
|
1966
|
+
const [isBusy, setIsBusy] = useState(!1), displayedProgress = isImported && progress < 100 ? 100 : progress, handleImport = useCallback(async () => {
|
|
1956
1967
|
setIsBusy(!0);
|
|
1957
1968
|
try {
|
|
1958
1969
|
await importFile();
|
|
@@ -1960,20 +1971,20 @@ const LanguageStatus = ({
|
|
|
1960
1971
|
setIsBusy(!1);
|
|
1961
1972
|
}
|
|
1962
1973
|
}, [importFile, setIsBusy]);
|
|
1963
|
-
return /* @__PURE__ */
|
|
1964
|
-
/* @__PURE__ */
|
|
1965
|
-
typeof displayedProgress == "number" ? /* @__PURE__ */
|
|
1966
|
-
/* @__PURE__ */
|
|
1967
|
-
/* @__PURE__ */
|
|
1968
|
-
/* @__PURE__ */
|
|
1969
|
-
] }) : /* @__PURE__ */
|
|
1970
|
-
|
|
1974
|
+
return /* @__PURE__ */ jsx(Card, { shadow: 1, children: /* @__PURE__ */ jsxs(Grid, { columns: 5, gap: 3, padding: 3, children: [
|
|
1975
|
+
/* @__PURE__ */ jsx(Flex, { columnStart: 1, columnEnd: 3, align: "center", children: /* @__PURE__ */ jsx(Text, { weight: "bold", size: 1, children: title }) }),
|
|
1976
|
+
typeof displayedProgress == "number" ? /* @__PURE__ */ jsx(Flex, { columnStart: 3, columnEnd: 5, align: "center", children: /* @__PURE__ */ jsx(ProgressBar, { progress: displayedProgress }) }) : null,
|
|
1977
|
+
/* @__PURE__ */ jsx(Box, { columnStart: 5, columnEnd: 6, children: isImported ? /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "center", style: { color: "green" }, children: [
|
|
1978
|
+
/* @__PURE__ */ jsx(CheckmarkCircleIcon, {}),
|
|
1979
|
+
/* @__PURE__ */ jsx(Text, { size: 1, style: { marginLeft: "4px" }, children: "Imported" })
|
|
1980
|
+
] }) : /* @__PURE__ */ jsx(
|
|
1981
|
+
Button,
|
|
1971
1982
|
{
|
|
1972
1983
|
style: { width: "100%" },
|
|
1973
1984
|
mode: "ghost",
|
|
1974
1985
|
onClick: handleImport,
|
|
1975
1986
|
text: isBusy ? "Importing..." : "Import",
|
|
1976
|
-
icon: isBusy ? null :
|
|
1987
|
+
icon: isBusy ? null : DownloadIcon,
|
|
1977
1988
|
disabled: isBusy || !progress || progress < 100
|
|
1978
1989
|
}
|
|
1979
1990
|
) })
|
|
@@ -2577,7 +2588,7 @@ var unitlessKeys = {
|
|
|
2577
2588
|
}, f = typeof process < "u" && process.env !== void 0 && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR) || "data-styled", m = "active", y = "data-styled-version", v = "6.1.19", g = `/*!sc*/
|
|
2578
2589
|
`, S = typeof window < "u" && typeof document < "u", w = !!(typeof SC_DISABLE_SPEEDY == "boolean" ? SC_DISABLE_SPEEDY : typeof process < "u" && process.env !== void 0 && process.env.REACT_APP_SC_DISABLE_SPEEDY !== void 0 && process.env.REACT_APP_SC_DISABLE_SPEEDY !== "" ? process.env.REACT_APP_SC_DISABLE_SPEEDY !== "false" && process.env.REACT_APP_SC_DISABLE_SPEEDY : typeof process < "u" && process.env !== void 0 && process.env.SC_DISABLE_SPEEDY !== void 0 && process.env.SC_DISABLE_SPEEDY !== "" ? process.env.SC_DISABLE_SPEEDY !== "false" && process.env.SC_DISABLE_SPEEDY : process.env.NODE_ENV !== "production"), E = /invalid hook call/i, N = /* @__PURE__ */ new Set(), P = function(t, n) {
|
|
2579
2590
|
if (process.env.NODE_ENV !== "production") {
|
|
2580
|
-
var
|
|
2591
|
+
var o2 = n ? ' with the id of "'.concat(n, '"') : "", s = "The component ".concat(t).concat(o2, ` has been created dynamically.
|
|
2581
2592
|
`) + `You may see this warning because you've called styled inside another component.
|
|
2582
2593
|
To resolve this only create new StyledComponents outside of any render method and function component.
|
|
2583
2594
|
See https://styled-components.com/docs/basics#define-styled-components-outside-of-the-render-method for more info.
|
|
@@ -2585,9 +2596,9 @@ See https://styled-components.com/docs/basics#define-styled-components-outside-o
|
|
|
2585
2596
|
try {
|
|
2586
2597
|
var a = !0;
|
|
2587
2598
|
console.error = function(t2) {
|
|
2588
|
-
for (var n2 = [],
|
|
2599
|
+
for (var n2 = [], o3 = 1; o3 < arguments.length; o3++) n2[o3 - 1] = arguments[o3];
|
|
2589
2600
|
E.test(t2) ? (a = !1, N.delete(s)) : i.apply(void 0, __spreadArray([t2], n2, !1));
|
|
2590
|
-
},
|
|
2601
|
+
}, useRef(), a && !N.has(s) && (console.warn(s), N.add(s));
|
|
2591
2602
|
} catch (e) {
|
|
2592
2603
|
E.test(e.message) && N.delete(s);
|
|
2593
2604
|
} finally {
|
|
@@ -2925,10 +2936,10 @@ function Fe(e) {
|
|
|
2925
2936
|
return t2.name || he(15), z(e2, t2.name);
|
|
2926
2937
|
}, F).toString() : "", p;
|
|
2927
2938
|
}
|
|
2928
|
-
var ze = new ke(), Me = Fe(), $e =
|
|
2929
|
-
|
|
2939
|
+
var ze = new ke(), Me = Fe(), $e = o.createContext({ shouldForwardProp: void 0, styleSheet: ze, stylis: Me });
|
|
2940
|
+
o.createContext(void 0);
|
|
2930
2941
|
function Le() {
|
|
2931
|
-
return
|
|
2942
|
+
return useContext($e);
|
|
2932
2943
|
}
|
|
2933
2944
|
var qe = (function() {
|
|
2934
2945
|
function e(e2, t) {
|
|
@@ -3016,7 +3027,7 @@ var Ke = M(v), Qe = (function() {
|
|
|
3016
3027
|
}
|
|
3017
3028
|
return o2;
|
|
3018
3029
|
}, e;
|
|
3019
|
-
})(), et =
|
|
3030
|
+
})(), et = o.createContext(void 0), rt = {}, st = /* @__PURE__ */ new Set();
|
|
3020
3031
|
function it(e, r, s) {
|
|
3021
3032
|
var i = se(e), a = e, c = !G(e), p = r.attrs, d = p === void 0 ? _ : p, h = r.componentId, f2 = h === void 0 ? (function(e2, t) {
|
|
3022
3033
|
var n = typeof e2 != "string" ? "sc" : R(e2);
|
|
@@ -3038,8 +3049,8 @@ function it(e, r, s) {
|
|
|
3038
3049
|
var N2 = new Qe(s, g2, i ? a.componentStyle : void 0);
|
|
3039
3050
|
function O2(e2, r2) {
|
|
3040
3051
|
return (function(e3, r3, s2) {
|
|
3041
|
-
var i2 = e3.attrs, a2 = e3.componentStyle, c2 = e3.defaultProps, p2 = e3.foldedComponentIds, d2 = e3.styledComponentId, h2 = e3.target, f3 =
|
|
3042
|
-
process.env.NODE_ENV !== "production" &&
|
|
3052
|
+
var i2 = e3.attrs, a2 = e3.componentStyle, c2 = e3.defaultProps, p2 = e3.foldedComponentIds, d2 = e3.styledComponentId, h2 = e3.target, f3 = o.useContext(et), m3 = Le(), y3 = e3.shouldForwardProp || m3.shouldForwardProp;
|
|
3053
|
+
process.env.NODE_ENV !== "production" && useDebugValue(d2);
|
|
3043
3054
|
var v2 = I(r3, f3, c2) || C, g3 = (function(e4, n, o2) {
|
|
3044
3055
|
for (var r4, s3 = __assign(__assign({}, n), { className: void 0, theme: o2 }), i3 = 0; i3 < e4.length; i3 += 1) {
|
|
3045
3056
|
var a3 = re(r4 = e4[i3]) ? r4(s3) : r4;
|
|
@@ -3049,16 +3060,16 @@ function it(e, r, s) {
|
|
|
3049
3060
|
})(i2, r3, v2), S3 = g3.as || h2, w3 = {};
|
|
3050
3061
|
for (var b2 in g3) g3[b2] === void 0 || b2[0] === "$" || b2 === "as" || b2 === "theme" && g3.theme === v2 || (b2 === "forwardedAs" ? w3.as = g3.forwardedAs : y3 && !y3(b2, S3) || (w3[b2] = g3[b2], y3 || process.env.NODE_ENV !== "development" || isPropValid(b2) || st.has(b2) || !A.has(S3) || (st.add(b2), console.warn('styled-components: it looks like an unknown prop "'.concat(b2, '" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));
|
|
3051
3062
|
var E3 = (function(e4, t) {
|
|
3052
|
-
var n = Le(),
|
|
3053
|
-
return process.env.NODE_ENV !== "production" &&
|
|
3063
|
+
var n = Le(), o2 = e4.generateAndInjectStyles(t, n.styleSheet, n.stylis);
|
|
3064
|
+
return process.env.NODE_ENV !== "production" && useDebugValue(o2), o2;
|
|
3054
3065
|
})(a2, g3);
|
|
3055
3066
|
process.env.NODE_ENV !== "production" && e3.warnTooManyClasses && e3.warnTooManyClasses(E3);
|
|
3056
3067
|
var N3 = ie(p2, d2);
|
|
3057
|
-
return E3 && (N3 += " " + E3), g3.className && (N3 += " " + g3.className), w3[G(S3) && !A.has(S3) ? "class" : "className"] = N3, s2 && (w3.ref = s2),
|
|
3068
|
+
return E3 && (N3 += " " + E3), g3.className && (N3 += " " + g3.className), w3[G(S3) && !A.has(S3) ? "class" : "className"] = N3, s2 && (w3.ref = s2), createElement(S3, w3);
|
|
3058
3069
|
})(D2, e2, r2);
|
|
3059
3070
|
}
|
|
3060
3071
|
O2.displayName = y2;
|
|
3061
|
-
var D2 =
|
|
3072
|
+
var D2 = o.forwardRef(O2);
|
|
3062
3073
|
return D2.attrs = S2, D2.componentStyle = N2, D2.displayName = y2, D2.shouldForwardProp = w2, D2.foldedComponentIds = i ? ie(a.foldedComponentIds, a.styledComponentId) : "", D2.styledComponentId = g2, D2.target = i ? a.target : e, Object.defineProperty(D2, "defaultProps", { get: function() {
|
|
3063
3074
|
return this._foldedDefaultProps;
|
|
3064
3075
|
}, set: function(e2) {
|
|
@@ -3126,34 +3137,34 @@ var wt = "__sc-".concat(f, "__");
|
|
|
3126
3137
|
process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && typeof window < "u" && (window[wt] || (window[wt] = 0), window[wt] === 1 && console.warn(`It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.
|
|
3127
3138
|
|
|
3128
3139
|
See https://s-c.sh/2BAXzed for more info.`), window[wt] += 1);
|
|
3129
|
-
const WrapText = dt(
|
|
3140
|
+
const WrapText = dt(Box)`
|
|
3130
3141
|
white-space: normal;
|
|
3131
3142
|
`, LocaleCheckbox = ({
|
|
3132
3143
|
locale,
|
|
3133
3144
|
toggle,
|
|
3134
3145
|
checked
|
|
3135
3146
|
}) => {
|
|
3136
|
-
const onClick =
|
|
3147
|
+
const onClick = useCallback(
|
|
3137
3148
|
() => toggle(locale.localeId, !checked),
|
|
3138
3149
|
[locale.localeId, toggle, checked]
|
|
3139
3150
|
);
|
|
3140
|
-
return /* @__PURE__ */
|
|
3141
|
-
|
|
3151
|
+
return /* @__PURE__ */ jsx(
|
|
3152
|
+
Button,
|
|
3142
3153
|
{
|
|
3143
3154
|
mode: "ghost",
|
|
3144
3155
|
onClick,
|
|
3145
3156
|
style: { cursor: "pointer" },
|
|
3146
3157
|
radius: 2,
|
|
3147
|
-
children: /* @__PURE__ */
|
|
3148
|
-
/* @__PURE__ */
|
|
3149
|
-
|
|
3158
|
+
children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 3, children: [
|
|
3159
|
+
/* @__PURE__ */ jsx(
|
|
3160
|
+
Switch,
|
|
3150
3161
|
{
|
|
3151
3162
|
style: { pointerEvents: "none" },
|
|
3152
3163
|
onChange: onClick,
|
|
3153
3164
|
checked
|
|
3154
3165
|
}
|
|
3155
3166
|
),
|
|
3156
|
-
/* @__PURE__ */
|
|
3167
|
+
/* @__PURE__ */ jsx(WrapText, { children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "semibold", children: locale.description }) })
|
|
3157
3168
|
] })
|
|
3158
3169
|
}
|
|
3159
3170
|
);
|
|
@@ -3180,16 +3191,16 @@ const WrapText = dt(ui.Box)`
|
|
|
3180
3191
|
setAutoPatchReferences,
|
|
3181
3192
|
autoPublish,
|
|
3182
3193
|
setAutoPublish
|
|
3183
|
-
} = useTranslations(), [isImporting, setIsImporting] =
|
|
3194
|
+
} = useTranslations(), [isImporting, setIsImporting] = useState(!1), [isPublishing, setIsPublishing] = useState(!1), toast = useToast(), document2 = documents[0], currentDocumentLanguage = useMemo(() => {
|
|
3184
3195
|
if (!document2) return null;
|
|
3185
3196
|
const languageField = pluginConfig.getLanguageField();
|
|
3186
3197
|
return document2[languageField] || pluginConfig.getSourceLocale();
|
|
3187
|
-
}, [document2]), shouldShowTranslationComponents =
|
|
3198
|
+
}, [document2]), shouldShowTranslationComponents = useMemo(() => currentDocumentLanguage ? currentDocumentLanguage === pluginConfig.getSourceLocale() : !1, [currentDocumentLanguage]), availableLocales = useMemo(() => {
|
|
3188
3199
|
const sourceLocale = pluginConfig.getSourceLocale();
|
|
3189
3200
|
return locales.filter(
|
|
3190
3201
|
(locale) => locale.enabled !== !1 && locale.localeId !== sourceLocale
|
|
3191
3202
|
);
|
|
3192
|
-
}, [locales]), documentId =
|
|
3203
|
+
}, [locales]), documentId = useMemo(() => document2 ? getDocumentPublishedId(document2) : null, [document2]), handleImportTranslations = useCallback(
|
|
3193
3204
|
async (options = {}) => {
|
|
3194
3205
|
const { autoOnly = !1 } = options;
|
|
3195
3206
|
if (isImporting || !documentId || autoOnly && !autoImport) return;
|
|
@@ -3230,12 +3241,12 @@ const WrapText = dt(ui.Box)`
|
|
|
3230
3241
|
toast
|
|
3231
3242
|
]
|
|
3232
3243
|
);
|
|
3233
|
-
|
|
3244
|
+
useEffect(() => {
|
|
3234
3245
|
handleImportTranslations({ autoOnly: !0 });
|
|
3235
|
-
}, [handleImportTranslations]),
|
|
3246
|
+
}, [handleImportTranslations]), useEffect(() => {
|
|
3236
3247
|
setAutoRefresh(!0), setAutoPatchReferences(!0), setAutoPublish(!0);
|
|
3237
3248
|
}, [setAutoRefresh, setAutoPatchReferences, setAutoPublish]);
|
|
3238
|
-
const toggleLocale =
|
|
3249
|
+
const toggleLocale = useCallback(
|
|
3239
3250
|
(localeId, shouldEnable) => {
|
|
3240
3251
|
const updatedLocales = locales.map(
|
|
3241
3252
|
(locale) => locale.localeId === localeId ? { ...locale, enabled: shouldEnable } : locale
|
|
@@ -3243,7 +3254,7 @@ const WrapText = dt(ui.Box)`
|
|
|
3243
3254
|
setLocales(updatedLocales);
|
|
3244
3255
|
},
|
|
3245
3256
|
[locales, setLocales]
|
|
3246
|
-
), toggleAllLocales =
|
|
3257
|
+
), toggleAllLocales = useCallback(() => {
|
|
3247
3258
|
const sourceLocale = pluginConfig.getSourceLocale(), allEnabled = locales.filter(
|
|
3248
3259
|
(locale) => locale.localeId !== sourceLocale
|
|
3249
3260
|
).every(
|
|
@@ -3253,14 +3264,14 @@ const WrapText = dt(ui.Box)`
|
|
|
3253
3264
|
);
|
|
3254
3265
|
setLocales(updatedLocales);
|
|
3255
3266
|
}, [locales, setLocales]);
|
|
3256
|
-
return shouldShowTranslationComponents ? /* @__PURE__ */
|
|
3257
|
-
/* @__PURE__ */
|
|
3258
|
-
/* @__PURE__ */
|
|
3259
|
-
/* @__PURE__ */
|
|
3260
|
-
/* @__PURE__ */
|
|
3261
|
-
/* @__PURE__ */
|
|
3262
|
-
/* @__PURE__ */
|
|
3263
|
-
|
|
3267
|
+
return shouldShowTranslationComponents ? /* @__PURE__ */ jsxs(Stack, { space: 6, padding: 4, children: [
|
|
3268
|
+
/* @__PURE__ */ jsxs(Stack, { space: 4, children: [
|
|
3269
|
+
/* @__PURE__ */ jsx(Text, { as: "h2", weight: "semibold", size: 2, children: "Generate Translations" }),
|
|
3270
|
+
/* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
3271
|
+
/* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", children: [
|
|
3272
|
+
/* @__PURE__ */ jsx(Text, { weight: "semibold", size: 1, children: availableLocales.length === 1 ? "Select locale" : "Select locales" }),
|
|
3273
|
+
/* @__PURE__ */ jsx(
|
|
3274
|
+
Button,
|
|
3264
3275
|
{
|
|
3265
3276
|
fontSize: 1,
|
|
3266
3277
|
padding: 2,
|
|
@@ -3269,9 +3280,9 @@ const WrapText = dt(ui.Box)`
|
|
|
3269
3280
|
}
|
|
3270
3281
|
)
|
|
3271
3282
|
] }),
|
|
3272
|
-
/* @__PURE__ */
|
|
3283
|
+
/* @__PURE__ */ jsx(Grid, { columns: [1, 1, 2, 3], gap: 1, children: locales.filter(
|
|
3273
3284
|
(locale) => locale.localeId !== pluginConfig.getSourceLocale()
|
|
3274
|
-
).map((locale) => /* @__PURE__ */
|
|
3285
|
+
).map((locale) => /* @__PURE__ */ jsx(
|
|
3275
3286
|
LocaleCheckbox,
|
|
3276
3287
|
{
|
|
3277
3288
|
locale,
|
|
@@ -3281,8 +3292,8 @@ const WrapText = dt(ui.Box)`
|
|
|
3281
3292
|
locale.localeId
|
|
3282
3293
|
)) })
|
|
3283
3294
|
] }),
|
|
3284
|
-
/* @__PURE__ */
|
|
3285
|
-
|
|
3295
|
+
/* @__PURE__ */ jsx(
|
|
3296
|
+
Button,
|
|
3286
3297
|
{
|
|
3287
3298
|
onClick: () => {
|
|
3288
3299
|
setAutoImport(!0), handleTranslateAll();
|
|
@@ -3293,22 +3304,22 @@ const WrapText = dt(ui.Box)`
|
|
|
3293
3304
|
}
|
|
3294
3305
|
)
|
|
3295
3306
|
] }),
|
|
3296
|
-
documentId && availableLocales.length > 0 && /* @__PURE__ */
|
|
3297
|
-
/* @__PURE__ */
|
|
3298
|
-
/* @__PURE__ */
|
|
3299
|
-
/* @__PURE__ */
|
|
3300
|
-
/* @__PURE__ */
|
|
3301
|
-
/* @__PURE__ */
|
|
3302
|
-
/* @__PURE__ */
|
|
3303
|
-
|
|
3307
|
+
documentId && availableLocales.length > 0 && /* @__PURE__ */ jsxs(Stack, { space: 4, children: [
|
|
3308
|
+
/* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", children: [
|
|
3309
|
+
/* @__PURE__ */ jsx(Text, { as: "h2", weight: "semibold", size: 2, children: "Translation Status" }),
|
|
3310
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 3, align: "center", children: [
|
|
3311
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [
|
|
3312
|
+
/* @__PURE__ */ jsx(Text, { size: 1, children: "Auto-refresh" }),
|
|
3313
|
+
/* @__PURE__ */ jsx(
|
|
3314
|
+
Switch,
|
|
3304
3315
|
{
|
|
3305
3316
|
checked: autoRefresh,
|
|
3306
3317
|
onChange: () => setAutoRefresh(!autoRefresh)
|
|
3307
3318
|
}
|
|
3308
3319
|
)
|
|
3309
3320
|
] }),
|
|
3310
|
-
/* @__PURE__ */
|
|
3311
|
-
|
|
3321
|
+
/* @__PURE__ */ jsx(
|
|
3322
|
+
Button,
|
|
3312
3323
|
{
|
|
3313
3324
|
fontSize: 1,
|
|
3314
3325
|
padding: 2,
|
|
@@ -3319,14 +3330,14 @@ const WrapText = dt(ui.Box)`
|
|
|
3319
3330
|
)
|
|
3320
3331
|
] })
|
|
3321
3332
|
] }),
|
|
3322
|
-
/* @__PURE__ */
|
|
3333
|
+
/* @__PURE__ */ jsx(Box, { children: availableLocales.map((locale) => {
|
|
3323
3334
|
const key = createTranslationStatusKey(
|
|
3324
3335
|
branchId,
|
|
3325
3336
|
documentId,
|
|
3326
3337
|
document2._rev,
|
|
3327
3338
|
locale.localeId
|
|
3328
3339
|
), status = translationStatuses.get(key), progress = status?.progress || 0, isImported = importedTranslations.has(key);
|
|
3329
|
-
return /* @__PURE__ */
|
|
3340
|
+
return /* @__PURE__ */ jsx(
|
|
3330
3341
|
LanguageStatus,
|
|
3331
3342
|
{
|
|
3332
3343
|
title: locale.description,
|
|
@@ -3343,17 +3354,17 @@ const WrapText = dt(ui.Box)`
|
|
|
3343
3354
|
key
|
|
3344
3355
|
);
|
|
3345
3356
|
}) }),
|
|
3346
|
-
/* @__PURE__ */
|
|
3347
|
-
/* @__PURE__ */
|
|
3348
|
-
/* @__PURE__ */
|
|
3349
|
-
/* @__PURE__ */
|
|
3350
|
-
|
|
3357
|
+
/* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
3358
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 3, align: "center", justify: "space-between", children: [
|
|
3359
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [
|
|
3360
|
+
/* @__PURE__ */ jsx(
|
|
3361
|
+
Button,
|
|
3351
3362
|
{
|
|
3352
3363
|
mode: "ghost",
|
|
3353
3364
|
tone: "primary",
|
|
3354
3365
|
onClick: () => handleImportTranslations(),
|
|
3355
3366
|
text: isImporting ? "Importing..." : "Import All",
|
|
3356
|
-
icon:
|
|
3367
|
+
icon: DownloadIcon,
|
|
3357
3368
|
disabled: isImporting || availableLocales.every((locale) => {
|
|
3358
3369
|
const key = createTranslationStatusKey(
|
|
3359
3370
|
branchId,
|
|
@@ -3366,19 +3377,19 @@ const WrapText = dt(ui.Box)`
|
|
|
3366
3377
|
style: { minWidth: "180px" }
|
|
3367
3378
|
}
|
|
3368
3379
|
),
|
|
3369
|
-
/* @__PURE__ */
|
|
3370
|
-
/* @__PURE__ */
|
|
3371
|
-
|
|
3380
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [
|
|
3381
|
+
/* @__PURE__ */ jsx(
|
|
3382
|
+
Switch,
|
|
3372
3383
|
{
|
|
3373
3384
|
checked: autoImport,
|
|
3374
3385
|
onChange: () => setAutoImport(!autoImport),
|
|
3375
3386
|
disabled: isImporting
|
|
3376
3387
|
}
|
|
3377
3388
|
),
|
|
3378
|
-
/* @__PURE__ */
|
|
3389
|
+
/* @__PURE__ */ jsx(Text, { size: 1, children: "Auto-import when complete" })
|
|
3379
3390
|
] })
|
|
3380
3391
|
] }),
|
|
3381
|
-
/* @__PURE__ */
|
|
3392
|
+
/* @__PURE__ */ jsxs(Text, { size: 1, muted: !0, children: [
|
|
3382
3393
|
"Imported",
|
|
3383
3394
|
" ",
|
|
3384
3395
|
availableLocales.filter((locale) => {
|
|
@@ -3402,14 +3413,14 @@ const WrapText = dt(ui.Box)`
|
|
|
3402
3413
|
}).length
|
|
3403
3414
|
] })
|
|
3404
3415
|
] }),
|
|
3405
|
-
/* @__PURE__ */
|
|
3406
|
-
/* @__PURE__ */
|
|
3407
|
-
|
|
3416
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", justify: "flex-start", children: [
|
|
3417
|
+
/* @__PURE__ */ jsx(
|
|
3418
|
+
Tooltip,
|
|
3408
3419
|
{
|
|
3409
3420
|
placement: "top",
|
|
3410
3421
|
content: `Replaces references to ${pluginConfig.getSourceLocale()} documents in this document with the corresponding translated document reference`,
|
|
3411
|
-
children: /* @__PURE__ */
|
|
3412
|
-
|
|
3422
|
+
children: /* @__PURE__ */ jsx(
|
|
3423
|
+
Button,
|
|
3413
3424
|
{
|
|
3414
3425
|
mode: "ghost",
|
|
3415
3426
|
tone: "caution",
|
|
@@ -3417,33 +3428,33 @@ const WrapText = dt(ui.Box)`
|
|
|
3417
3428
|
await handlePatchDocumentReferences();
|
|
3418
3429
|
},
|
|
3419
3430
|
text: isBusy ? "Patching..." : "Patch References",
|
|
3420
|
-
icon: isBusy ? null :
|
|
3431
|
+
icon: isBusy ? null : LinkIcon,
|
|
3421
3432
|
disabled: isBusy || isImporting,
|
|
3422
3433
|
style: { minWidth: "180px" }
|
|
3423
3434
|
}
|
|
3424
3435
|
)
|
|
3425
3436
|
}
|
|
3426
3437
|
),
|
|
3427
|
-
/* @__PURE__ */
|
|
3428
|
-
/* @__PURE__ */
|
|
3429
|
-
|
|
3438
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [
|
|
3439
|
+
/* @__PURE__ */ jsx(
|
|
3440
|
+
Switch,
|
|
3430
3441
|
{
|
|
3431
3442
|
checked: autoPatchReferences,
|
|
3432
3443
|
onChange: () => setAutoPatchReferences(!autoPatchReferences),
|
|
3433
3444
|
disabled: isImporting || isBusy
|
|
3434
3445
|
}
|
|
3435
3446
|
),
|
|
3436
|
-
/* @__PURE__ */
|
|
3447
|
+
/* @__PURE__ */ jsx(Text, { size: 1, children: "Auto-patch after import" })
|
|
3437
3448
|
] })
|
|
3438
3449
|
] }),
|
|
3439
|
-
/* @__PURE__ */
|
|
3440
|
-
/* @__PURE__ */
|
|
3441
|
-
|
|
3450
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", justify: "flex-start", children: [
|
|
3451
|
+
/* @__PURE__ */ jsx(
|
|
3452
|
+
Tooltip,
|
|
3442
3453
|
{
|
|
3443
3454
|
placement: "top",
|
|
3444
3455
|
content: "Publishes all translations (if the source document is published)",
|
|
3445
|
-
children: /* @__PURE__ */
|
|
3446
|
-
|
|
3456
|
+
children: /* @__PURE__ */ jsx(
|
|
3457
|
+
Button,
|
|
3447
3458
|
{
|
|
3448
3459
|
mode: "ghost",
|
|
3449
3460
|
tone: "positive",
|
|
@@ -3456,48 +3467,48 @@ const WrapText = dt(ui.Box)`
|
|
|
3456
3467
|
}
|
|
3457
3468
|
},
|
|
3458
3469
|
text: isPublishing ? "Publishing..." : "Publish Translations",
|
|
3459
|
-
icon: isPublishing ? null :
|
|
3470
|
+
icon: isPublishing ? null : PublishIcon,
|
|
3460
3471
|
disabled: isBusy || isPublishing || isImporting,
|
|
3461
3472
|
style: { minWidth: "180px" }
|
|
3462
3473
|
}
|
|
3463
3474
|
)
|
|
3464
3475
|
}
|
|
3465
3476
|
),
|
|
3466
|
-
/* @__PURE__ */
|
|
3467
|
-
/* @__PURE__ */
|
|
3468
|
-
|
|
3477
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [
|
|
3478
|
+
/* @__PURE__ */ jsx(
|
|
3479
|
+
Switch,
|
|
3469
3480
|
{
|
|
3470
3481
|
checked: autoPublish,
|
|
3471
3482
|
onChange: () => setAutoPublish(!autoPublish),
|
|
3472
3483
|
disabled: isPublishing || isImporting || isBusy
|
|
3473
3484
|
}
|
|
3474
3485
|
),
|
|
3475
|
-
/* @__PURE__ */
|
|
3486
|
+
/* @__PURE__ */ jsx(Text, { size: 1, children: "Auto-publish after import" })
|
|
3476
3487
|
] })
|
|
3477
3488
|
] })
|
|
3478
3489
|
] })
|
|
3479
3490
|
] })
|
|
3480
|
-
] }) : /* @__PURE__ */
|
|
3491
|
+
] }) : /* @__PURE__ */ jsx(Card, { padding: 4, tone: "neutral", border: !0, children: /* @__PURE__ */ jsxs(Text, { size: 1, muted: !0, children: [
|
|
3481
3492
|
"Translation tools are only available for",
|
|
3482
3493
|
" ",
|
|
3483
|
-
/* @__PURE__ */
|
|
3494
|
+
/* @__PURE__ */ jsx("code", { children: pluginConfig.getSourceLocale() }),
|
|
3484
3495
|
" documents."
|
|
3485
3496
|
] }) });
|
|
3486
3497
|
}, TranslationTab = (props) => {
|
|
3487
3498
|
const { displayed } = props.document;
|
|
3488
|
-
return /* @__PURE__ */
|
|
3499
|
+
return /* @__PURE__ */ jsx(BaseTranslationWrapper, { showContainer: !1, children: /* @__PURE__ */ jsx(TranslationsProvider, { singleDocument: displayed, children: /* @__PURE__ */ jsx(TranslationView, {}) }) });
|
|
3489
3500
|
}, translateAction = (props) => {
|
|
3490
|
-
const [dialogOpen, setDialogOpen] =
|
|
3501
|
+
const [dialogOpen, setDialogOpen] = useState(!1), document2 = props.draft || props.published;
|
|
3491
3502
|
return {
|
|
3492
3503
|
label: "Translate",
|
|
3493
|
-
icon:
|
|
3504
|
+
icon: TranslateIcon,
|
|
3494
3505
|
tone: "primary",
|
|
3495
3506
|
onHandle: () => setDialogOpen(!0),
|
|
3496
3507
|
dialog: dialogOpen ? {
|
|
3497
3508
|
type: "dialog",
|
|
3498
3509
|
header: "Translations",
|
|
3499
3510
|
onClose: () => setDialogOpen(!1),
|
|
3500
|
-
content: /* @__PURE__ */
|
|
3511
|
+
content: /* @__PURE__ */ jsx(BaseTranslationWrapper, { showContainer: !1, children: /* @__PURE__ */ jsx(TranslationsProvider, { singleDocument: document2, children: /* @__PURE__ */ jsx(TranslationView, {}) }) })
|
|
3501
3512
|
} : null
|
|
3502
3513
|
};
|
|
3503
3514
|
}, TranslationsTable = () => {
|
|
@@ -3511,19 +3522,19 @@ const WrapText = dt(ui.Box)`
|
|
|
3511
3522
|
handleImportDocument,
|
|
3512
3523
|
branchId
|
|
3513
3524
|
} = useTranslations();
|
|
3514
|
-
return loadingDocuments ? /* @__PURE__ */
|
|
3515
|
-
/* @__PURE__ */
|
|
3516
|
-
/* @__PURE__ */
|
|
3517
|
-
/* @__PURE__ */
|
|
3525
|
+
return loadingDocuments ? /* @__PURE__ */ jsx(Flex, { align: "center", justify: "center", padding: 4, children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsx(Box, { style: { maxHeight: "60vh", overflowY: "auto" }, children: /* @__PURE__ */ jsx(Stack, { space: 2, children: documents.map((document2) => /* @__PURE__ */ jsx(Card, { shadow: 1, padding: 3, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
3526
|
+
/* @__PURE__ */ jsx(Flex, { justify: "space-between", align: "flex-start", children: /* @__PURE__ */ jsxs(Box, { flex: 1, children: [
|
|
3527
|
+
/* @__PURE__ */ jsx(Text, { weight: "semibold", size: 1, children: getDocumentPublishedId(document2) }),
|
|
3528
|
+
/* @__PURE__ */ jsx(Text, { size: 0, muted: !0, style: { marginTop: "2px" }, children: document2._type })
|
|
3518
3529
|
] }) }),
|
|
3519
|
-
/* @__PURE__ */
|
|
3530
|
+
/* @__PURE__ */ jsx(Stack, { space: 2, children: locales.length > 0 ? locales.filter((locale) => locale.enabled !== !1).map((locale) => {
|
|
3520
3531
|
const documentId = getDocumentPublishedId(document2), key = createTranslationStatusKey(
|
|
3521
3532
|
branchId,
|
|
3522
3533
|
documentId,
|
|
3523
3534
|
document2._rev,
|
|
3524
3535
|
locale.localeId
|
|
3525
3536
|
), status = translationStatuses.get(key), isDownloaded = downloadStatus.downloaded.has(key), isImported = importedTranslations.has(key);
|
|
3526
|
-
return /* @__PURE__ */
|
|
3537
|
+
return /* @__PURE__ */ jsx(
|
|
3527
3538
|
LanguageStatus,
|
|
3528
3539
|
{
|
|
3529
3540
|
title: locale.description || locale.localeId,
|
|
@@ -3539,40 +3550,40 @@ const WrapText = dt(ui.Box)`
|
|
|
3539
3550
|
},
|
|
3540
3551
|
`${document2._id}-${document2._rev}-${locale.localeId}`
|
|
3541
3552
|
);
|
|
3542
|
-
}) : /* @__PURE__ */
|
|
3553
|
+
}) : /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "No locales configured" }) })
|
|
3543
3554
|
] }) }, document2._id)) }) });
|
|
3544
3555
|
}, TranslateAllDialog = ({
|
|
3545
3556
|
isOpen,
|
|
3546
3557
|
onClose
|
|
3547
3558
|
}) => {
|
|
3548
|
-
const { documents, handleTranslateAll } = useTranslations()
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
return isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3552
|
-
ui.Dialog,
|
|
3559
|
+
const { documents, handleTranslateAll } = useTranslations();
|
|
3560
|
+
return isOpen ? /* @__PURE__ */ jsx(
|
|
3561
|
+
Dialog,
|
|
3553
3562
|
{
|
|
3554
3563
|
header: "Confirm Translation",
|
|
3555
3564
|
id: "translate-all-dialog",
|
|
3556
3565
|
onClose,
|
|
3557
|
-
footer: /* @__PURE__ */
|
|
3558
|
-
/* @__PURE__ */
|
|
3559
|
-
/* @__PURE__ */
|
|
3560
|
-
|
|
3566
|
+
footer: /* @__PURE__ */ jsx(Box, { padding: 3, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
3567
|
+
/* @__PURE__ */ jsx(Button, { text: "Cancel", mode: "ghost", onClick: onClose }),
|
|
3568
|
+
/* @__PURE__ */ jsx(
|
|
3569
|
+
Button,
|
|
3561
3570
|
{
|
|
3562
3571
|
text: "Translate All",
|
|
3563
3572
|
tone: "critical",
|
|
3564
|
-
onClick:
|
|
3573
|
+
onClick: async () => {
|
|
3574
|
+
onClose(), await handleTranslateAll();
|
|
3575
|
+
}
|
|
3565
3576
|
}
|
|
3566
3577
|
)
|
|
3567
3578
|
] }) }),
|
|
3568
|
-
children: /* @__PURE__ */
|
|
3569
|
-
/* @__PURE__ */
|
|
3579
|
+
children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
3580
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
3570
3581
|
"Are you sure you want to create translations for all",
|
|
3571
3582
|
" ",
|
|
3572
3583
|
documents.length,
|
|
3573
3584
|
" documents?"
|
|
3574
3585
|
] }),
|
|
3575
|
-
/* @__PURE__ */
|
|
3586
|
+
/* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "This will submit all documents to General Translation for processing." })
|
|
3576
3587
|
] }) })
|
|
3577
3588
|
}
|
|
3578
3589
|
) : null;
|
|
@@ -3580,27 +3591,27 @@ const WrapText = dt(ui.Box)`
|
|
|
3580
3591
|
isOpen,
|
|
3581
3592
|
onClose
|
|
3582
3593
|
}) => {
|
|
3583
|
-
const { documents, handleImportAll } = useTranslations()
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
return isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3587
|
-
ui.Dialog,
|
|
3594
|
+
const { documents, handleImportAll } = useTranslations();
|
|
3595
|
+
return isOpen ? /* @__PURE__ */ jsx(
|
|
3596
|
+
Dialog,
|
|
3588
3597
|
{
|
|
3589
3598
|
header: "Confirm Import",
|
|
3590
3599
|
id: "import-all-dialog",
|
|
3591
3600
|
onClose,
|
|
3592
|
-
footer: /* @__PURE__ */
|
|
3593
|
-
/* @__PURE__ */
|
|
3594
|
-
/* @__PURE__ */
|
|
3601
|
+
footer: /* @__PURE__ */ jsx(Box, { padding: 3, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
3602
|
+
/* @__PURE__ */ jsx(Button, { text: "Cancel", mode: "ghost", onClick: onClose }),
|
|
3603
|
+
/* @__PURE__ */ jsx(Button, { text: "Import All", tone: "critical", onClick: async () => {
|
|
3604
|
+
onClose(), await handleImportAll();
|
|
3605
|
+
} })
|
|
3595
3606
|
] }) }),
|
|
3596
|
-
children: /* @__PURE__ */
|
|
3597
|
-
/* @__PURE__ */
|
|
3607
|
+
children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
3608
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
3598
3609
|
"Are you sure you want to import translations for all",
|
|
3599
3610
|
" ",
|
|
3600
3611
|
documents.length,
|
|
3601
3612
|
" documents?"
|
|
3602
3613
|
] }),
|
|
3603
|
-
/* @__PURE__ */
|
|
3614
|
+
/* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "This will download and apply translated content to your documents. Note that this will overwrite any existing translations!" })
|
|
3604
3615
|
] }) })
|
|
3605
3616
|
}
|
|
3606
3617
|
) : null;
|
|
@@ -3608,29 +3619,29 @@ const WrapText = dt(ui.Box)`
|
|
|
3608
3619
|
isOpen,
|
|
3609
3620
|
onClose
|
|
3610
3621
|
}) => {
|
|
3611
|
-
const { handleImportMissing } = useTranslations()
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
return isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3615
|
-
ui.Dialog,
|
|
3622
|
+
const { handleImportMissing } = useTranslations();
|
|
3623
|
+
return isOpen ? /* @__PURE__ */ jsx(
|
|
3624
|
+
Dialog,
|
|
3616
3625
|
{
|
|
3617
3626
|
header: "Confirm Import Missing",
|
|
3618
3627
|
id: "import-missing-dialog",
|
|
3619
3628
|
onClose,
|
|
3620
|
-
footer: /* @__PURE__ */
|
|
3621
|
-
/* @__PURE__ */
|
|
3622
|
-
/* @__PURE__ */
|
|
3623
|
-
|
|
3629
|
+
footer: /* @__PURE__ */ jsx(Box, { padding: 3, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
3630
|
+
/* @__PURE__ */ jsx(Button, { text: "Cancel", mode: "ghost", onClick: onClose }),
|
|
3631
|
+
/* @__PURE__ */ jsx(
|
|
3632
|
+
Button,
|
|
3624
3633
|
{
|
|
3625
3634
|
text: "Import Missing",
|
|
3626
3635
|
tone: "primary",
|
|
3627
|
-
onClick:
|
|
3636
|
+
onClick: async () => {
|
|
3637
|
+
onClose(), await handleImportMissing();
|
|
3638
|
+
}
|
|
3628
3639
|
}
|
|
3629
3640
|
)
|
|
3630
3641
|
] }) }),
|
|
3631
|
-
children: /* @__PURE__ */
|
|
3632
|
-
/* @__PURE__ */
|
|
3633
|
-
/* @__PURE__ */
|
|
3642
|
+
children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
3643
|
+
/* @__PURE__ */ jsx(Text, { children: "Import only the missing translations (translations that are ready but haven't been imported to Sanity yet)?" }),
|
|
3644
|
+
/* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "This will check existing translation metadata and only import translations that don't already exist in your dataset." })
|
|
3634
3645
|
] }) })
|
|
3635
3646
|
}
|
|
3636
3647
|
) : null;
|
|
@@ -3639,9 +3650,9 @@ const WrapText = dt(ui.Box)`
|
|
|
3639
3650
|
current,
|
|
3640
3651
|
total,
|
|
3641
3652
|
operationName
|
|
3642
|
-
}) => isActive ? /* @__PURE__ */
|
|
3643
|
-
/* @__PURE__ */
|
|
3644
|
-
/* @__PURE__ */
|
|
3653
|
+
}) => isActive ? /* @__PURE__ */ jsxs(Flex, { justify: "center", align: "center", gap: 3, children: [
|
|
3654
|
+
/* @__PURE__ */ jsx(Spinner, { size: 1 }),
|
|
3655
|
+
/* @__PURE__ */ jsxs(Text, { size: 1, children: [
|
|
3645
3656
|
operationName,
|
|
3646
3657
|
" ",
|
|
3647
3658
|
current,
|
|
@@ -3650,7 +3661,7 @@ const WrapText = dt(ui.Box)`
|
|
|
3650
3661
|
"..."
|
|
3651
3662
|
] })
|
|
3652
3663
|
] }) : null, TranslationsToolContent = () => {
|
|
3653
|
-
const [isTranslateAllDialogOpen, setIsTranslateAllDialogOpen] =
|
|
3664
|
+
const [isTranslateAllDialogOpen, setIsTranslateAllDialogOpen] = useState(!1), [isImportAllDialogOpen, setIsImportAllDialogOpen] = useState(!1), [isImportMissingDialogOpen, setIsImportMissingDialogOpen] = useState(!1), {
|
|
3654
3665
|
isBusy,
|
|
3655
3666
|
documents,
|
|
3656
3667
|
locales,
|
|
@@ -3663,7 +3674,7 @@ const WrapText = dt(ui.Box)`
|
|
|
3663
3674
|
handleRefreshAll,
|
|
3664
3675
|
handlePatchDocumentReferences,
|
|
3665
3676
|
handlePublishAllTranslations
|
|
3666
|
-
} = useTranslations(), [currentOperation, setCurrentOperation] =
|
|
3677
|
+
} = useTranslations(), [currentOperation, setCurrentOperation] = useState(null), getOperationText = (operationName, isProcessing) => {
|
|
3667
3678
|
if (!isProcessing || !operationName) return operationName;
|
|
3668
3679
|
switch (operationName) {
|
|
3669
3680
|
case "Translate All":
|
|
@@ -3693,28 +3704,28 @@ const WrapText = dt(ui.Box)`
|
|
|
3693
3704
|
return "Processing";
|
|
3694
3705
|
}
|
|
3695
3706
|
};
|
|
3696
|
-
return
|
|
3707
|
+
return o.useEffect(() => {
|
|
3697
3708
|
!isBusy && !importProgress.isImporting && setCurrentOperation(null);
|
|
3698
|
-
}, [isBusy, importProgress.isImporting]), /* @__PURE__ */
|
|
3699
|
-
/* @__PURE__ */
|
|
3700
|
-
/* @__PURE__ */
|
|
3701
|
-
/* @__PURE__ */
|
|
3702
|
-
/* @__PURE__ */
|
|
3703
|
-
/* @__PURE__ */
|
|
3709
|
+
}, [isBusy, importProgress.isImporting]), /* @__PURE__ */ jsxs(Container, { width: 2, children: [
|
|
3710
|
+
/* @__PURE__ */ jsx(Box, { padding: 4, marginTop: 5, children: /* @__PURE__ */ jsxs(Stack, { space: 4, children: [
|
|
3711
|
+
/* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", children: [
|
|
3712
|
+
/* @__PURE__ */ jsxs(Stack, { space: 2, children: [
|
|
3713
|
+
/* @__PURE__ */ jsx(Heading, { as: "h2", size: 3, children: "Translations" }),
|
|
3714
|
+
/* @__PURE__ */ jsx(Text, { size: 2, children: "Manage your document translations from this centralized location." })
|
|
3704
3715
|
] }),
|
|
3705
|
-
/* @__PURE__ */
|
|
3706
|
-
/* @__PURE__ */
|
|
3707
|
-
/* @__PURE__ */
|
|
3708
|
-
/* @__PURE__ */
|
|
3709
|
-
|
|
3716
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 3, align: "center", children: [
|
|
3717
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [
|
|
3718
|
+
/* @__PURE__ */ jsx(Text, { size: 1, children: "Auto-refresh" }),
|
|
3719
|
+
/* @__PURE__ */ jsx(
|
|
3720
|
+
Switch,
|
|
3710
3721
|
{
|
|
3711
3722
|
checked: autoRefresh,
|
|
3712
3723
|
onChange: () => setAutoRefresh(!autoRefresh)
|
|
3713
3724
|
}
|
|
3714
3725
|
)
|
|
3715
3726
|
] }),
|
|
3716
|
-
/* @__PURE__ */
|
|
3717
|
-
|
|
3727
|
+
/* @__PURE__ */ jsx(
|
|
3728
|
+
Button,
|
|
3718
3729
|
{
|
|
3719
3730
|
fontSize: 1,
|
|
3720
3731
|
padding: 2,
|
|
@@ -3725,10 +3736,10 @@ const WrapText = dt(ui.Box)`
|
|
|
3725
3736
|
)
|
|
3726
3737
|
] })
|
|
3727
3738
|
] }),
|
|
3728
|
-
/* @__PURE__ */
|
|
3729
|
-
/* @__PURE__ */
|
|
3730
|
-
/* @__PURE__ */
|
|
3731
|
-
|
|
3739
|
+
/* @__PURE__ */ jsxs(Stack, { space: 4, children: [
|
|
3740
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: loadingDocuments ? "Loading documents..." : `Found ${documents.length} documents available for translation` }) }),
|
|
3741
|
+
/* @__PURE__ */ jsx(Flex, { justify: "center", children: /* @__PURE__ */ jsx(
|
|
3742
|
+
Button,
|
|
3732
3743
|
{
|
|
3733
3744
|
style: { width: "200px" },
|
|
3734
3745
|
tone: "critical",
|
|
@@ -3742,17 +3753,17 @@ const WrapText = dt(ui.Box)`
|
|
|
3742
3753
|
disabled: isBusy || loadingDocuments || documents.length === 0
|
|
3743
3754
|
}
|
|
3744
3755
|
) }),
|
|
3745
|
-
/* @__PURE__ */
|
|
3746
|
-
/* @__PURE__ */
|
|
3747
|
-
/* @__PURE__ */
|
|
3748
|
-
/* @__PURE__ */
|
|
3749
|
-
/* @__PURE__ */
|
|
3750
|
-
|
|
3756
|
+
/* @__PURE__ */ jsx(TranslationsTable, {}),
|
|
3757
|
+
/* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
3758
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 3, align: "center", justify: "space-between", children: [
|
|
3759
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [
|
|
3760
|
+
/* @__PURE__ */ jsx(
|
|
3761
|
+
Tooltip,
|
|
3751
3762
|
{
|
|
3752
3763
|
placement: "top",
|
|
3753
3764
|
content: "Imports and overrides all translations",
|
|
3754
|
-
children: /* @__PURE__ */
|
|
3755
|
-
|
|
3765
|
+
children: /* @__PURE__ */ jsx(
|
|
3766
|
+
Button,
|
|
3756
3767
|
{
|
|
3757
3768
|
mode: "ghost",
|
|
3758
3769
|
onClick: () => {
|
|
@@ -3762,19 +3773,19 @@ const WrapText = dt(ui.Box)`
|
|
|
3762
3773
|
"Import All",
|
|
3763
3774
|
isBusy && currentOperation === "Import All"
|
|
3764
3775
|
),
|
|
3765
|
-
icon: isBusy && currentOperation === "Import All" ? null :
|
|
3776
|
+
icon: isBusy && currentOperation === "Import All" ? null : DownloadIcon,
|
|
3766
3777
|
disabled: isBusy || loadingDocuments || documents.length === 0
|
|
3767
3778
|
}
|
|
3768
3779
|
)
|
|
3769
3780
|
}
|
|
3770
3781
|
),
|
|
3771
|
-
/* @__PURE__ */
|
|
3772
|
-
|
|
3782
|
+
/* @__PURE__ */ jsx(
|
|
3783
|
+
Tooltip,
|
|
3773
3784
|
{
|
|
3774
3785
|
placement: "top",
|
|
3775
3786
|
content: "Imports all translations that are not yet imported (according to the source document's translation.metadata document)",
|
|
3776
|
-
children: /* @__PURE__ */
|
|
3777
|
-
|
|
3787
|
+
children: /* @__PURE__ */ jsx(
|
|
3788
|
+
Button,
|
|
3778
3789
|
{
|
|
3779
3790
|
mode: "ghost",
|
|
3780
3791
|
tone: "primary",
|
|
@@ -3785,19 +3796,19 @@ const WrapText = dt(ui.Box)`
|
|
|
3785
3796
|
"Import Missing",
|
|
3786
3797
|
isBusy && currentOperation === "Import Missing"
|
|
3787
3798
|
),
|
|
3788
|
-
icon: isBusy && currentOperation === "Import Missing" ? null :
|
|
3799
|
+
icon: isBusy && currentOperation === "Import Missing" ? null : DownloadIcon,
|
|
3789
3800
|
disabled: isBusy || loadingDocuments || documents.length === 0
|
|
3790
3801
|
}
|
|
3791
3802
|
)
|
|
3792
3803
|
}
|
|
3793
3804
|
),
|
|
3794
|
-
/* @__PURE__ */
|
|
3795
|
-
|
|
3805
|
+
/* @__PURE__ */ jsx(
|
|
3806
|
+
Tooltip,
|
|
3796
3807
|
{
|
|
3797
3808
|
placement: "top",
|
|
3798
3809
|
content: "Replaces references in documents with the corresponding translated document reference",
|
|
3799
|
-
children: /* @__PURE__ */
|
|
3800
|
-
|
|
3810
|
+
children: /* @__PURE__ */ jsx(
|
|
3811
|
+
Button,
|
|
3801
3812
|
{
|
|
3802
3813
|
mode: "ghost",
|
|
3803
3814
|
tone: "caution",
|
|
@@ -3808,19 +3819,19 @@ const WrapText = dt(ui.Box)`
|
|
|
3808
3819
|
"Patch Document References",
|
|
3809
3820
|
isBusy && currentOperation === "Patch Document References"
|
|
3810
3821
|
),
|
|
3811
|
-
icon: isBusy && currentOperation === "Patch Document References" ? null :
|
|
3822
|
+
icon: isBusy && currentOperation === "Patch Document References" ? null : LinkIcon,
|
|
3812
3823
|
disabled: isBusy || loadingDocuments || documents.length === 0
|
|
3813
3824
|
}
|
|
3814
3825
|
)
|
|
3815
3826
|
}
|
|
3816
3827
|
),
|
|
3817
|
-
/* @__PURE__ */
|
|
3818
|
-
|
|
3828
|
+
/* @__PURE__ */ jsx(
|
|
3829
|
+
Tooltip,
|
|
3819
3830
|
{
|
|
3820
3831
|
placement: "top",
|
|
3821
3832
|
content: "Publishes all translations whose source document is published",
|
|
3822
|
-
children: /* @__PURE__ */
|
|
3823
|
-
|
|
3833
|
+
children: /* @__PURE__ */ jsx(
|
|
3834
|
+
Button,
|
|
3824
3835
|
{
|
|
3825
3836
|
mode: "ghost",
|
|
3826
3837
|
tone: "positive",
|
|
@@ -3831,17 +3842,17 @@ const WrapText = dt(ui.Box)`
|
|
|
3831
3842
|
"Publish Translations",
|
|
3832
3843
|
isBusy && currentOperation === "Publish Translations"
|
|
3833
3844
|
),
|
|
3834
|
-
icon: isBusy && currentOperation === "Publish Translations" ? null :
|
|
3845
|
+
icon: isBusy && currentOperation === "Publish Translations" ? null : PublishIcon,
|
|
3835
3846
|
disabled: isBusy || loadingDocuments || documents.length === 0
|
|
3836
3847
|
}
|
|
3837
3848
|
)
|
|
3838
3849
|
}
|
|
3839
3850
|
),
|
|
3840
|
-
importedTranslations.size === documents.length * locales.filter((l) => l.enabled !== !1).length && documents.length > 0 && locales.length > 0 && /* @__PURE__ */
|
|
3841
|
-
/* @__PURE__ */
|
|
3842
|
-
/* @__PURE__ */
|
|
3851
|
+
importedTranslations.size === documents.length * locales.filter((l) => l.enabled !== !1).length && documents.length > 0 && locales.length > 0 && /* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", style: { color: "green" }, children: [
|
|
3852
|
+
/* @__PURE__ */ jsx(CheckmarkCircleIcon, {}),
|
|
3853
|
+
/* @__PURE__ */ jsx(Text, { size: 1, children: "All translations imported" })
|
|
3843
3854
|
] }),
|
|
3844
|
-
importedTranslations.size > 0 && importedTranslations.size < documents.length * locales.filter((l) => l.enabled !== !1).length && /* @__PURE__ */
|
|
3855
|
+
importedTranslations.size > 0 && importedTranslations.size < documents.length * locales.filter((l) => l.enabled !== !1).length && /* @__PURE__ */ jsxs(Text, { size: 1, style: { color: "#666" }, children: [
|
|
3845
3856
|
importedTranslations.size,
|
|
3846
3857
|
"/",
|
|
3847
3858
|
documents.length * locales.filter((l) => l.enabled !== !1).length,
|
|
@@ -3849,9 +3860,9 @@ const WrapText = dt(ui.Box)`
|
|
|
3849
3860
|
"imported"
|
|
3850
3861
|
] })
|
|
3851
3862
|
] }),
|
|
3852
|
-
/* @__PURE__ */
|
|
3863
|
+
/* @__PURE__ */ jsx(Box, {})
|
|
3853
3864
|
] }),
|
|
3854
|
-
/* @__PURE__ */
|
|
3865
|
+
/* @__PURE__ */ jsx(
|
|
3855
3866
|
BatchProgress,
|
|
3856
3867
|
{
|
|
3857
3868
|
isActive: importProgress.isImporting,
|
|
@@ -3862,28 +3873,28 @@ const WrapText = dt(ui.Box)`
|
|
|
3862
3873
|
)
|
|
3863
3874
|
] })
|
|
3864
3875
|
] }),
|
|
3865
|
-
/* @__PURE__ */
|
|
3876
|
+
/* @__PURE__ */ jsxs(Text, { size: 2, children: [
|
|
3866
3877
|
"For more information, see the",
|
|
3867
3878
|
" ",
|
|
3868
|
-
/* @__PURE__ */
|
|
3879
|
+
/* @__PURE__ */ jsx(Link, { href: "https://dash.generaltranslation.com", children: "General Translation Dashboard" }),
|
|
3869
3880
|
"."
|
|
3870
3881
|
] })
|
|
3871
3882
|
] }) }),
|
|
3872
|
-
/* @__PURE__ */
|
|
3883
|
+
/* @__PURE__ */ jsx(
|
|
3873
3884
|
TranslateAllDialog,
|
|
3874
3885
|
{
|
|
3875
3886
|
isOpen: isTranslateAllDialogOpen,
|
|
3876
3887
|
onClose: () => setIsTranslateAllDialogOpen(!1)
|
|
3877
3888
|
}
|
|
3878
3889
|
),
|
|
3879
|
-
/* @__PURE__ */
|
|
3890
|
+
/* @__PURE__ */ jsx(
|
|
3880
3891
|
ImportAllDialog,
|
|
3881
3892
|
{
|
|
3882
3893
|
isOpen: isImportAllDialogOpen,
|
|
3883
3894
|
onClose: () => setIsImportAllDialogOpen(!1)
|
|
3884
3895
|
}
|
|
3885
3896
|
),
|
|
3886
|
-
/* @__PURE__ */
|
|
3897
|
+
/* @__PURE__ */ jsx(
|
|
3887
3898
|
ImportMissingDialog,
|
|
3888
3899
|
{
|
|
3889
3900
|
isOpen: isImportMissingDialogOpen,
|
|
@@ -3891,7 +3902,7 @@ const WrapText = dt(ui.Box)`
|
|
|
3891
3902
|
}
|
|
3892
3903
|
)
|
|
3893
3904
|
] });
|
|
3894
|
-
}, TranslationsTool = () => /* @__PURE__ */
|
|
3905
|
+
}, TranslationsTool = () => /* @__PURE__ */ jsx(BaseTranslationWrapper, { showContainer: !1, children: /* @__PURE__ */ jsx(TranslationsProvider, { children: /* @__PURE__ */ jsx(TranslationsToolContent, {}) }) }), gtPlugin = definePlugin(
|
|
3895
3906
|
({
|
|
3896
3907
|
languageField = "language",
|
|
3897
3908
|
sourceLocale,
|
|
@@ -3913,7 +3924,7 @@ const WrapText = dt(ui.Box)`
|
|
|
3913
3924
|
additionalBlockDeserializers = [],
|
|
3914
3925
|
showDocumentInternationalization = !0
|
|
3915
3926
|
}) => {
|
|
3916
|
-
const resolvedSourceLocale = sourceLocale ?? defaultLocale ??
|
|
3927
|
+
const resolvedSourceLocale = sourceLocale ?? defaultLocale ?? libraryDefaultLocale;
|
|
3917
3928
|
let normalizedTranslateDocuments;
|
|
3918
3929
|
translateDocuments && (normalizedTranslateDocuments = translateDocuments.map((entry) => typeof entry == "string" ? { type: entry } : entry).filter((filter2) => filter2.documentId || filter2.type)), pluginConfig.init(
|
|
3919
3930
|
secretsNamespace,
|
|
@@ -3942,11 +3953,11 @@ const WrapText = dt(ui.Box)`
|
|
|
3942
3953
|
const schemaTypes = normalizedTranslateDocuments?.map((filter2) => filter2.type).filter((type) => !!type) ?? [];
|
|
3943
3954
|
if (schemaTypes.length > 0) {
|
|
3944
3955
|
const supportedLanguages = [resolvedSourceLocale, ...locales].map((locale) => {
|
|
3945
|
-
const props =
|
|
3956
|
+
const props = getLocaleProperties(locale, resolvedSourceLocale);
|
|
3946
3957
|
return { id: locale, title: props.name };
|
|
3947
3958
|
});
|
|
3948
3959
|
plugins.push(
|
|
3949
|
-
documentInternationalization
|
|
3960
|
+
documentInternationalization({
|
|
3950
3961
|
supportedLanguages,
|
|
3951
3962
|
schemaTypes,
|
|
3952
3963
|
languageField
|
|
@@ -3962,7 +3973,7 @@ const WrapText = dt(ui.Box)`
|
|
|
3962
3973
|
name: "translations",
|
|
3963
3974
|
title: "Translations",
|
|
3964
3975
|
component: TranslationsTool,
|
|
3965
|
-
router:
|
|
3976
|
+
router: route.create("/*")
|
|
3966
3977
|
}
|
|
3967
3978
|
],
|
|
3968
3979
|
document: {
|
|
@@ -3971,45 +3982,22 @@ const WrapText = dt(ui.Box)`
|
|
|
3971
3982
|
};
|
|
3972
3983
|
}
|
|
3973
3984
|
);
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
}
|
|
3992
|
-
Object.defineProperty(exports, "useDocumentInternationalizationContext", {
|
|
3993
|
-
enumerable: !0,
|
|
3994
|
-
get: function() {
|
|
3995
|
-
return documentInternationalization.useDocumentInternationalizationContext;
|
|
3996
|
-
}
|
|
3997
|
-
});
|
|
3998
|
-
Object.defineProperty(exports, "useDuplicateWithTranslationsAction", {
|
|
3999
|
-
enumerable: !0,
|
|
4000
|
-
get: function() {
|
|
4001
|
-
return documentInternationalization.useDuplicateWithTranslationsAction;
|
|
4002
|
-
}
|
|
4003
|
-
});
|
|
4004
|
-
exports.BaseDocumentDeserializer = BaseDocumentDeserializer;
|
|
4005
|
-
exports.BaseDocumentMerger = BaseDocumentMerger;
|
|
4006
|
-
exports.BaseDocumentSerializer = BaseDocumentSerializer;
|
|
4007
|
-
exports.TranslationsTab = TranslationTab;
|
|
4008
|
-
exports.attachGTData = attachGTData;
|
|
4009
|
-
exports.customSerializers = customSerializers;
|
|
4010
|
-
exports.defaultStopTypes = defaultStopTypes;
|
|
4011
|
-
exports.detachGTData = detachGTData;
|
|
4012
|
-
exports.findLatestDraft = findLatestDraft;
|
|
4013
|
-
exports.gtPlugin = gtPlugin;
|
|
4014
|
-
exports.translateAction = translateAction;
|
|
3985
|
+
export {
|
|
3986
|
+
BaseDocumentDeserializer,
|
|
3987
|
+
BaseDocumentMerger,
|
|
3988
|
+
BaseDocumentSerializer,
|
|
3989
|
+
DocumentInternationalizationMenu,
|
|
3990
|
+
TranslationTab as TranslationsTab,
|
|
3991
|
+
attachGTData,
|
|
3992
|
+
customSerializers,
|
|
3993
|
+
defaultStopTypes,
|
|
3994
|
+
detachGTData,
|
|
3995
|
+
documentInternationalization2 as documentInternationalization,
|
|
3996
|
+
findLatestDraft,
|
|
3997
|
+
gtPlugin,
|
|
3998
|
+
translateAction,
|
|
3999
|
+
useDeleteTranslationAction,
|
|
4000
|
+
useDocumentInternationalizationContext,
|
|
4001
|
+
useDuplicateWithTranslationsAction
|
|
4002
|
+
};
|
|
4015
4003
|
//# sourceMappingURL=index.js.map
|