gt-sanity 4.0.29 → 4.0.30
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.js +399 -203
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/TranslationsProvider.tsx +145 -70
- package/src/components/page/ImportAllDialog.tsx +2 -0
- package/src/components/page/ImportMissingDialog.tsx +2 -0
- package/src/components/page/SelectedLocalesNote.tsx +19 -0
- package/src/components/page/TranslateAllDialog.tsx +2 -0
- package/src/components/page/TranslationsTool.tsx +72 -34
- package/src/components/page/UploadExistingDialog.tsx +2 -0
- package/src/components/shared/LocaleCheckbox.tsx +7 -3
- package/src/components/shared/LocaleDropdown.tsx +174 -0
- package/src/components/shared/LocaleSelector.tsx +57 -0
- package/src/components/tab/TranslationView.tsx +3 -67
- package/src/sanity-api/__tests__/publishDocuments.test.ts +50 -3
- package/src/sanity-api/publishDocuments.ts +4 -1
- package/src/utils/__tests__/locales.test.ts +77 -1
- package/src/utils/__tests__/refreshTracker.test.ts +95 -0
- package/src/utils/locales.ts +53 -0
- package/src/utils/refreshTracker.ts +52 -0
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { useIntentLink, Link, route } from "sanity/router";
|
|
|
6
6
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
7
7
|
import React, { useState, useEffect, createContext, useRef, useCallback, useContext, useMemo } from "react";
|
|
8
8
|
import { TranslateIcon } from "@sanity/icons/Translate";
|
|
9
|
-
import { ThemeProvider, Box, Flex, Spinner, Card, Text, Dialog, Stack, Button, Badge, Grid, Checkbox, Switch, Container, Heading } from "@sanity/ui";
|
|
9
|
+
import { ThemeProvider, Box, Flex, Spinner, Card, Text, Dialog, Stack, Button, Badge, Grid, Checkbox, Switch, useClickOutsideEvent, useGlobalKeyDown, TextInput, Container, Heading } from "@sanity/ui";
|
|
10
10
|
import { ToastProvider, useToast } from "@sanity/ui/toast";
|
|
11
11
|
import { buildTheme } from "@sanity/ui/theme";
|
|
12
12
|
import { extractWithPath, arrayToJSONMatchPath } from "@sanity/mutator";
|
|
@@ -27,6 +27,9 @@ import { RefreshIcon } from "@sanity/icons/Refresh";
|
|
|
27
27
|
import { UploadIcon } from "@sanity/icons/Upload";
|
|
28
28
|
import { internationalizedArray } from "sanity-plugin-internationalized-array";
|
|
29
29
|
import { internationalizedArray as internationalizedArray2, internationalizedArrayLanguageFilter, isInternationalizedArrayItemType } from "sanity-plugin-internationalized-array";
|
|
30
|
+
import { Popover } from "@sanity/ui/popover";
|
|
31
|
+
import { ChevronDownIcon } from "@sanity/icons/ChevronDown";
|
|
32
|
+
import { SearchIcon } from "@sanity/icons/Search";
|
|
30
33
|
import { documentInternationalization } from "@sanity/document-internationalization";
|
|
31
34
|
import { DocumentInternationalizationMenu, documentInternationalization as documentInternationalization2, useDeleteTranslationAction, useDocumentInternationalizationContext, useDuplicateWithTranslationsAction } from "@sanity/document-internationalization";
|
|
32
35
|
const {
|
|
@@ -182,6 +185,13 @@ function formatLocalePropertiesLabel(code, properties, mapping) {
|
|
|
182
185
|
);
|
|
183
186
|
return verbatim ? name : [emoji, `${name} (${code})`].filter(Boolean).join(" ");
|
|
184
187
|
}
|
|
188
|
+
function formatLocaleLabel(localeId) {
|
|
189
|
+
return formatLocalePropertiesLabel(
|
|
190
|
+
localeId,
|
|
191
|
+
gt.getLocaleProperties(localeId),
|
|
192
|
+
gt.customMapping?.[localeId]
|
|
193
|
+
);
|
|
194
|
+
}
|
|
185
195
|
const useClient = () => useClient$1({ apiVersion: SANITY_API_VERSION });
|
|
186
196
|
function useSecrets(id) {
|
|
187
197
|
const [loading, setLoading] = useState(!0), [secrets, setSecrets] = useState(null), client = useClient();
|
|
@@ -2010,7 +2020,8 @@ const TRANSLATION_DOCS_FOR_PUBLISH_QUERY = `*[
|
|
|
2010
2020
|
count(translations[defined(value._ref) && value._ref in $publishedDocumentIds]) > 0
|
|
2011
2021
|
] {
|
|
2012
2022
|
'translationDocs': translations[
|
|
2013
|
-
defined(value._ref) && !(value._ref in $sourceDocumentIds)
|
|
2023
|
+
defined(value._ref) && !(value._ref in $sourceDocumentIds) &&
|
|
2024
|
+
($localeIds == null || language in $localeIds)
|
|
2014
2025
|
]{
|
|
2015
2026
|
_key,
|
|
2016
2027
|
'docId': value._ref
|
|
@@ -2049,7 +2060,47 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
2049
2060
|
localeId: locale,
|
|
2050
2061
|
description: gt.getLocaleProperties(locale).name,
|
|
2051
2062
|
enabled: !0
|
|
2052
|
-
}))
|
|
2063
|
+
}));
|
|
2064
|
+
function resolveTargetLocales(sourceLocale, locales) {
|
|
2065
|
+
return Array.from(new Set(locales)).filter(
|
|
2066
|
+
(locale) => locale !== sourceLocale
|
|
2067
|
+
);
|
|
2068
|
+
}
|
|
2069
|
+
function isLocaleSelected(locale) {
|
|
2070
|
+
return locale.enabled !== !1;
|
|
2071
|
+
}
|
|
2072
|
+
function getSelectedLocaleIds(locales) {
|
|
2073
|
+
return locales.filter(isLocaleSelected).map((locale) => locale.localeId);
|
|
2074
|
+
}
|
|
2075
|
+
function getLocaleIdsToPoll(locales, isPending) {
|
|
2076
|
+
return locales.filter((locale) => isLocaleSelected(locale) || isPending(locale.localeId)).map((locale) => locale.localeId);
|
|
2077
|
+
}
|
|
2078
|
+
function setLocaleSelected(locales, localeId, selected) {
|
|
2079
|
+
return locales.map(
|
|
2080
|
+
(locale) => locale.localeId === localeId ? { ...locale, enabled: selected } : locale
|
|
2081
|
+
);
|
|
2082
|
+
}
|
|
2083
|
+
function toggleAllLocales(locales, sourceLocale) {
|
|
2084
|
+
const allSelected = locales.filter((locale) => locale.localeId !== sourceLocale).every(isLocaleSelected);
|
|
2085
|
+
return locales.map(
|
|
2086
|
+
(locale) => locale.localeId === sourceLocale ? locale : { ...locale, enabled: !allSelected }
|
|
2087
|
+
);
|
|
2088
|
+
}
|
|
2089
|
+
function createRefreshTracker(getScope) {
|
|
2090
|
+
let inFlight = 0;
|
|
2091
|
+
return {
|
|
2092
|
+
isRefreshing: () => inFlight > 0,
|
|
2093
|
+
begin: () => {
|
|
2094
|
+
const scope = getScope();
|
|
2095
|
+
let finished = !1;
|
|
2096
|
+
return inFlight += 1, {
|
|
2097
|
+
isCurrent: () => getScope() === scope,
|
|
2098
|
+
finish: () => (finished || (finished = !0, inFlight -= 1), inFlight > 0)
|
|
2099
|
+
};
|
|
2100
|
+
}
|
|
2101
|
+
};
|
|
2102
|
+
}
|
|
2103
|
+
const getPreferencesStorageKey = (projectId, dataset) => `gt-sanity:preferences:${projectId ?? ""}:${dataset ?? ""}`, isPlainRecord$1 = (value) => typeof value == "object" && value !== null && !Array.isArray(value);
|
|
2053
2104
|
function readPreferences(storageKey, defaults) {
|
|
2054
2105
|
try {
|
|
2055
2106
|
const raw = window.localStorage.getItem(storageKey);
|
|
@@ -2122,7 +2173,9 @@ const useTranslations = () => {
|
|
|
2122
2173
|
skipped: /* @__PURE__ */ new Set()
|
|
2123
2174
|
}), downloadStatusRef = useRef(downloadStatus), [translationStatuses, setTranslationStatuses] = useState(/* @__PURE__ */ new Map()), [pendingTranslations, setPendingTranslations] = useState(
|
|
2124
2175
|
/* @__PURE__ */ new Set()
|
|
2125
|
-
), [importingTranslations, setImportingTranslations] = useState(/* @__PURE__ */ new Set()), [isRefreshing, setIsRefreshing] = useState(!1),
|
|
2176
|
+
), [importingTranslations, setImportingTranslations] = useState(/* @__PURE__ */ new Set()), [isRefreshing, setIsRefreshing] = useState(!1), pendingTranslationsRef = useRef(pendingTranslations), refreshScopeRef = useRef({}), [refreshTracker] = useState(
|
|
2177
|
+
() => createRefreshTracker(() => refreshScopeRef.current)
|
|
2178
|
+
), client = useClient(), { projectId, dataset } = client.config(), uploadedVersionsStorageKey = getUploadedVersionsStorageKey(
|
|
2126
2179
|
projectId,
|
|
2127
2180
|
dataset
|
|
2128
2181
|
), [uploadedVersions, setUploadedVersions] = useState(
|
|
@@ -2161,11 +2214,17 @@ const useTranslations = () => {
|
|
|
2161
2214
|
), [branchId, setBranchId] = useState(void 0);
|
|
2162
2215
|
useEffect(() => {
|
|
2163
2216
|
downloadStatusRef.current = downloadStatus;
|
|
2164
|
-
}, [downloadStatus])
|
|
2217
|
+
}, [downloadStatus]), useEffect(() => {
|
|
2218
|
+
pendingTranslationsRef.current = pendingTranslations;
|
|
2219
|
+
}, [pendingTranslations]);
|
|
2165
2220
|
const getVersionId = useCallback(
|
|
2166
2221
|
(document2) => uploadedVersions.get(getDocumentPublishedId(document2)) ?? document2._rev,
|
|
2167
2222
|
[uploadedVersions]
|
|
2168
|
-
)
|
|
2223
|
+
);
|
|
2224
|
+
useEffect(() => {
|
|
2225
|
+
refreshScopeRef.current = {};
|
|
2226
|
+
}, [locales, documents, branchId, getVersionId]);
|
|
2227
|
+
const fetchDocuments = useCallback(async () => {
|
|
2169
2228
|
setLoadingDocuments(!0);
|
|
2170
2229
|
try {
|
|
2171
2230
|
if (singleDocument) {
|
|
@@ -2381,8 +2440,9 @@ const useTranslations = () => {
|
|
|
2381
2440
|
if (!(!secrets || documents.length === 0 || !branchId)) {
|
|
2382
2441
|
setIsBusy(!0);
|
|
2383
2442
|
try {
|
|
2384
|
-
const readyFiles = await getReadyFilesForImport(translationStatuses, {
|
|
2385
|
-
onSelectedKeys: (keys) => setImportingTranslations(new Set(keys))
|
|
2443
|
+
const selectedLocaleIds = new Set(getSelectedLocaleIds(locales)), readyFiles = await getReadyFilesForImport(translationStatuses, {
|
|
2444
|
+
onSelectedKeys: (keys) => setImportingTranslations(new Set(keys)),
|
|
2445
|
+
filterReadyFiles: (_key, status) => selectedLocaleIds.has(status.fileData.locale)
|
|
2386
2446
|
});
|
|
2387
2447
|
if (readyFiles.length === 0) {
|
|
2388
2448
|
toast.push({
|
|
@@ -2438,6 +2498,7 @@ const useTranslations = () => {
|
|
|
2438
2498
|
}, [
|
|
2439
2499
|
secrets,
|
|
2440
2500
|
documents,
|
|
2501
|
+
locales,
|
|
2441
2502
|
translationStatuses,
|
|
2442
2503
|
downloadStatus,
|
|
2443
2504
|
translationContext,
|
|
@@ -2479,7 +2540,7 @@ const useTranslations = () => {
|
|
|
2479
2540
|
branchId
|
|
2480
2541
|
), readyFiles = await getReadyFilesForImport(translationStatuses, {
|
|
2481
2542
|
onSelectedKeys: (keys) => setImportingTranslations(new Set(keys)),
|
|
2482
|
-
filterReadyFiles: (_key, status) => !existingTranslations2.has(
|
|
2543
|
+
filterReadyFiles: (_key, status) => availableLocaleIds.includes(status.fileData.locale) && !existingTranslations2.has(
|
|
2483
2544
|
createStableTranslationKey(
|
|
2484
2545
|
branchId,
|
|
2485
2546
|
status.fileData.fileId,
|
|
@@ -2559,77 +2620,97 @@ const useTranslations = () => {
|
|
|
2559
2620
|
[secrets]
|
|
2560
2621
|
), handleRefreshAll = useCallback(
|
|
2561
2622
|
async ({ silent = !1 } = {}) => {
|
|
2562
|
-
if (!
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2623
|
+
if (!secrets || documents.length === 0 || !branchId) return;
|
|
2624
|
+
const refresh = refreshTracker.begin();
|
|
2625
|
+
setIsRefreshing(!0);
|
|
2626
|
+
try {
|
|
2627
|
+
const localeIdsByDocument = new Map(
|
|
2628
|
+
documents.map((doc) => {
|
|
2629
|
+
const documentId = getDocumentPublishedId(doc), versionId = getVersionId(doc);
|
|
2630
|
+
return [
|
|
2631
|
+
doc,
|
|
2632
|
+
getLocaleIdsToPoll(
|
|
2633
|
+
locales,
|
|
2634
|
+
(localeId) => pendingTranslationsRef.current.has(
|
|
2635
|
+
createTranslationStatusKey(
|
|
2636
|
+
branchId,
|
|
2637
|
+
documentId,
|
|
2638
|
+
versionId,
|
|
2639
|
+
localeId
|
|
2640
|
+
)
|
|
2641
|
+
)
|
|
2642
|
+
)
|
|
2643
|
+
];
|
|
2644
|
+
})
|
|
2645
|
+
), fileQueryData = [];
|
|
2646
|
+
for (const doc of documents)
|
|
2647
|
+
for (const localeId of localeIdsByDocument.get(doc) ?? []) {
|
|
2648
|
+
const documentId = getDocumentPublishedId(doc);
|
|
2649
|
+
fileQueryData.push({
|
|
2650
|
+
versionId: getVersionId(doc),
|
|
2651
|
+
fileId: documentId,
|
|
2652
|
+
branchId,
|
|
2653
|
+
locale: localeId
|
|
2654
|
+
});
|
|
2655
|
+
}
|
|
2656
|
+
const readyTranslations = await checkTranslationStatus(
|
|
2657
|
+
fileQueryData,
|
|
2658
|
+
downloadStatusRef.current,
|
|
2659
|
+
secrets
|
|
2660
|
+
);
|
|
2661
|
+
if (!refresh.isCurrent()) return;
|
|
2662
|
+
const newStatuses = /* @__PURE__ */ new Map();
|
|
2663
|
+
for (const doc of documents)
|
|
2664
|
+
for (const localeId of localeIdsByDocument.get(doc) ?? []) {
|
|
2665
|
+
const documentId = getDocumentPublishedId(doc), versionId = getVersionId(doc), key = createTranslationStatusKey(
|
|
2666
|
+
branchId,
|
|
2667
|
+
documentId,
|
|
2668
|
+
versionId,
|
|
2669
|
+
localeId
|
|
2670
|
+
);
|
|
2671
|
+
newStatuses.set(key, { progress: 0, isReady: !1 });
|
|
2672
|
+
}
|
|
2673
|
+
if (Array.isArray(readyTranslations))
|
|
2674
|
+
for (const translation of readyTranslations) {
|
|
2675
|
+
const key = createTranslationStatusKey(
|
|
2676
|
+
branchId,
|
|
2677
|
+
translation.fileId,
|
|
2678
|
+
translation.versionId,
|
|
2679
|
+
translation.locale
|
|
2680
|
+
);
|
|
2681
|
+
newStatuses.set(key, {
|
|
2682
|
+
progress: 100,
|
|
2683
|
+
isReady: !0,
|
|
2684
|
+
fileData: {
|
|
2685
|
+
versionId: translation.versionId,
|
|
2686
|
+
fileId: translation.fileId,
|
|
2687
|
+
branchId: translation.branchId,
|
|
2688
|
+
locale: translation.locale
|
|
2689
|
+
}
|
|
2690
|
+
});
|
|
2691
|
+
}
|
|
2692
|
+
setTranslationStatuses(newStatuses), setPendingTranslations((prev) => {
|
|
2693
|
+
if (prev.size === 0) return prev;
|
|
2694
|
+
const next = new Set(prev);
|
|
2695
|
+
for (const [key, status] of newStatuses)
|
|
2696
|
+
status.isReady && next.delete(key);
|
|
2697
|
+
return next.size === prev.size ? prev : next;
|
|
2698
|
+
}), silent || toast.push({
|
|
2699
|
+
title: `Refreshed status for ${documents.length} document(s)`,
|
|
2700
|
+
status: "success",
|
|
2701
|
+
closable: !0
|
|
2702
|
+
});
|
|
2703
|
+
} catch (error) {
|
|
2704
|
+
console.error("Error refreshing translation status:", error), toast.push({
|
|
2705
|
+
title: "Translation status could not be refreshed. Try again before importing.",
|
|
2706
|
+
status: "error",
|
|
2707
|
+
closable: !0
|
|
2708
|
+
});
|
|
2709
|
+
} finally {
|
|
2710
|
+
setIsRefreshing(refresh.finish());
|
|
2630
2711
|
}
|
|
2631
2712
|
},
|
|
2632
|
-
[secrets, documents, locales, branchId, getVersionId]
|
|
2713
|
+
[secrets, documents, locales, branchId, getVersionId, refreshTracker]
|
|
2633
2714
|
), handleImportDocument = useCallback(
|
|
2634
2715
|
async (documentId, versionId, localeId) => {
|
|
2635
2716
|
if (!secrets) return;
|
|
@@ -2782,55 +2863,59 @@ const useTranslations = () => {
|
|
|
2782
2863
|
} finally {
|
|
2783
2864
|
setIsBusy(!1), setImportProgress({ current: 0, total: 0, isImporting: !1 });
|
|
2784
2865
|
}
|
|
2785
|
-
}, [secrets, documents, locales, client, branchId]), handlePublishAllTranslations = useCallback(
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2866
|
+
}, [secrets, documents, locales, client, branchId]), handlePublishAllTranslations = useCallback(
|
|
2867
|
+
async ({ localeIds = null } = {}) => {
|
|
2868
|
+
if (!secrets || documents.length === 0) return 0;
|
|
2869
|
+
setIsBusy(!0);
|
|
2870
|
+
try {
|
|
2871
|
+
const sourceDocumentIds = documents.map(getDocumentPublishedId), publishedDocumentIds = await client.fetch(
|
|
2872
|
+
"*[_id in $sourceDocumentIds]._id",
|
|
2873
|
+
{ sourceDocumentIds }
|
|
2874
|
+
);
|
|
2875
|
+
if (publishedDocumentIds.length === 0)
|
|
2876
|
+
return toast.push({
|
|
2877
|
+
title: "No published source documents found to publish translations for",
|
|
2878
|
+
status: "warning",
|
|
2879
|
+
closable: !0
|
|
2880
|
+
}), 0;
|
|
2881
|
+
const translationMetadata = await client.fetch(TRANSLATION_DOCS_FOR_PUBLISH_QUERY, {
|
|
2882
|
+
publishedDocumentIds,
|
|
2883
|
+
sourceDocumentIds,
|
|
2884
|
+
localeIds
|
|
2885
|
+
}), translationDocIds = /* @__PURE__ */ new Set();
|
|
2886
|
+
translationMetadata.forEach((metadata) => {
|
|
2887
|
+
metadata.translationDocs?.forEach((translation) => {
|
|
2888
|
+
translation.docId && translationDocIds.add(translation.docId);
|
|
2889
|
+
});
|
|
2806
2890
|
});
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2891
|
+
const publishableIds = Array.from(translationDocIds);
|
|
2892
|
+
if (publishableIds.length === 0)
|
|
2893
|
+
return toast.push({
|
|
2894
|
+
title: "No translation documents found to publish",
|
|
2895
|
+
status: "warning",
|
|
2896
|
+
closable: !0
|
|
2897
|
+
}), 0;
|
|
2898
|
+
const translatedDocumentIds = await publishTranslations(
|
|
2899
|
+
publishableIds,
|
|
2900
|
+
client
|
|
2901
|
+
);
|
|
2810
2902
|
return toast.push({
|
|
2811
|
-
title:
|
|
2812
|
-
status: "
|
|
2903
|
+
title: `Published ${translatedDocumentIds.length} translation documents`,
|
|
2904
|
+
status: "success",
|
|
2905
|
+
closable: !0
|
|
2906
|
+
}), translatedDocumentIds.length;
|
|
2907
|
+
} catch (error) {
|
|
2908
|
+
return console.error("Error publishing translations:", error), toast.push({
|
|
2909
|
+
title: "Translations could not be published. No unpublished source documents were changed.",
|
|
2910
|
+
status: "error",
|
|
2813
2911
|
closable: !0
|
|
2814
2912
|
}), 0;
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
status: "success",
|
|
2822
|
-
closable: !0
|
|
2823
|
-
}), translatedDocumentIds.length;
|
|
2824
|
-
} catch (error) {
|
|
2825
|
-
return console.error("Error publishing translations:", error), toast.push({
|
|
2826
|
-
title: "Translations could not be published. No unpublished source documents were changed.",
|
|
2827
|
-
status: "error",
|
|
2828
|
-
closable: !0
|
|
2829
|
-
}), 0;
|
|
2830
|
-
} finally {
|
|
2831
|
-
setIsBusy(!1);
|
|
2832
|
-
}
|
|
2833
|
-
}, [secrets, documents, client, branchId]);
|
|
2913
|
+
} finally {
|
|
2914
|
+
setIsBusy(!1);
|
|
2915
|
+
}
|
|
2916
|
+
},
|
|
2917
|
+
[secrets, documents, client, branchId]
|
|
2918
|
+
);
|
|
2834
2919
|
useEffect(() => {
|
|
2835
2920
|
fetchDocuments();
|
|
2836
2921
|
}, [fetchDocuments]), useEffect(() => {
|
|
@@ -2849,10 +2934,16 @@ const useTranslations = () => {
|
|
|
2849
2934
|
]), useEffect(() => {
|
|
2850
2935
|
if (!autoRefresh || documents.length === 0 || !secrets) return;
|
|
2851
2936
|
const interval = setInterval(async () => {
|
|
2852
|
-
await handleRefreshAll({ silent: !0 });
|
|
2937
|
+
refreshTracker.isRefreshing() || await handleRefreshAll({ silent: !0 });
|
|
2853
2938
|
}, 1e4);
|
|
2854
2939
|
return () => clearInterval(interval);
|
|
2855
|
-
}, [
|
|
2940
|
+
}, [
|
|
2941
|
+
autoRefresh,
|
|
2942
|
+
documents.length,
|
|
2943
|
+
secrets,
|
|
2944
|
+
handleRefreshAll,
|
|
2945
|
+
refreshTracker
|
|
2946
|
+
]), useEffect(() => {
|
|
2856
2947
|
setImportedTranslations(new Set(downloadStatus.downloaded));
|
|
2857
2948
|
}, [downloadStatus.downloaded]), useEffect(() => {
|
|
2858
2949
|
secrets && handleGetBranchId(secrets);
|
|
@@ -2917,7 +3008,7 @@ const useTranslations = () => {
|
|
|
2917
3008
|
] }) })
|
|
2918
3009
|
}
|
|
2919
3010
|
) : null;
|
|
2920
|
-
var version = "4.0.
|
|
3011
|
+
var version = "4.0.30";
|
|
2921
3012
|
function buildDebugInfo({
|
|
2922
3013
|
secrets,
|
|
2923
3014
|
preferences,
|
|
@@ -3200,7 +3291,9 @@ function resolveLanguageStatusState({
|
|
|
3200
3291
|
const LocaleCheckbox = ({
|
|
3201
3292
|
locale,
|
|
3202
3293
|
toggle,
|
|
3203
|
-
checked
|
|
3294
|
+
checked,
|
|
3295
|
+
mode = "ghost",
|
|
3296
|
+
padding = 3
|
|
3204
3297
|
}) => {
|
|
3205
3298
|
const onClick = useCallback(
|
|
3206
3299
|
() => toggle(locale.localeId, !checked),
|
|
@@ -3209,10 +3302,10 @@ const LocaleCheckbox = ({
|
|
|
3209
3302
|
return /* @__PURE__ */ jsx(
|
|
3210
3303
|
Button,
|
|
3211
3304
|
{
|
|
3212
|
-
mode
|
|
3305
|
+
mode,
|
|
3213
3306
|
onClick,
|
|
3214
3307
|
style: { cursor: "pointer" },
|
|
3215
|
-
padding
|
|
3308
|
+
padding,
|
|
3216
3309
|
children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 3, children: [
|
|
3217
3310
|
/* @__PURE__ */ jsx(
|
|
3218
3311
|
Checkbox,
|
|
@@ -3226,6 +3319,37 @@ const LocaleCheckbox = ({
|
|
|
3226
3319
|
] })
|
|
3227
3320
|
}
|
|
3228
3321
|
);
|
|
3322
|
+
}, LocaleSelector = () => {
|
|
3323
|
+
const { locales, setLocales } = useTranslations(), sourceLocale = pluginConfig.getSourceLocale(), targetLocales = locales.filter(
|
|
3324
|
+
(locale) => locale.localeId !== sourceLocale
|
|
3325
|
+
), selectedCount = targetLocales.filter(isLocaleSelected).length, toggleLocale = useCallback(
|
|
3326
|
+
(localeId, shouldEnable) => setLocales(setLocaleSelected(locales, localeId, shouldEnable)),
|
|
3327
|
+
[locales, setLocales]
|
|
3328
|
+
);
|
|
3329
|
+
return /* @__PURE__ */ jsxs(Stack, { gap: 3, children: [
|
|
3330
|
+
/* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", children: [
|
|
3331
|
+
/* @__PURE__ */ jsx(Text, { weight: "semibold", size: 1, children: selectedCount === 1 ? "Select locale" : "Select locales" }),
|
|
3332
|
+
/* @__PURE__ */ jsx(
|
|
3333
|
+
Button,
|
|
3334
|
+
{
|
|
3335
|
+
fontSize: 1,
|
|
3336
|
+
padding: 2,
|
|
3337
|
+
mode: "ghost",
|
|
3338
|
+
text: "Toggle All",
|
|
3339
|
+
onClick: () => setLocales(toggleAllLocales(locales, sourceLocale))
|
|
3340
|
+
}
|
|
3341
|
+
)
|
|
3342
|
+
] }),
|
|
3343
|
+
/* @__PURE__ */ jsx(Grid, { gridTemplateColumns: [1, 1, 2, 3], gap: 1, children: targetLocales.map((locale) => /* @__PURE__ */ jsx(
|
|
3344
|
+
LocaleCheckbox,
|
|
3345
|
+
{
|
|
3346
|
+
locale,
|
|
3347
|
+
toggle: toggleLocale,
|
|
3348
|
+
checked: isLocaleSelected(locale)
|
|
3349
|
+
},
|
|
3350
|
+
locale.localeId
|
|
3351
|
+
)) })
|
|
3352
|
+
] });
|
|
3229
3353
|
}, TranslationView = () => {
|
|
3230
3354
|
const {
|
|
3231
3355
|
documents,
|
|
@@ -3241,7 +3365,6 @@ const LocaleCheckbox = ({
|
|
|
3241
3365
|
handleRefreshAll,
|
|
3242
3366
|
isRefreshing,
|
|
3243
3367
|
importedTranslations,
|
|
3244
|
-
setLocales,
|
|
3245
3368
|
handlePatchDocumentReferences,
|
|
3246
3369
|
handlePublishAllTranslations,
|
|
3247
3370
|
autoRefresh,
|
|
@@ -3321,56 +3444,12 @@ const LocaleCheckbox = ({
|
|
|
3321
3444
|
toast
|
|
3322
3445
|
]
|
|
3323
3446
|
);
|
|
3324
|
-
useEffect(() => {
|
|
3447
|
+
return useEffect(() => {
|
|
3325
3448
|
handleImportTranslations({ autoOnly: !0 });
|
|
3326
|
-
}, [handleImportTranslations])
|
|
3327
|
-
const toggleLocale = useCallback(
|
|
3328
|
-
(localeId, shouldEnable) => {
|
|
3329
|
-
const updatedLocales = locales.map(
|
|
3330
|
-
(locale) => locale.localeId === localeId ? { ...locale, enabled: shouldEnable } : locale
|
|
3331
|
-
);
|
|
3332
|
-
setLocales(updatedLocales);
|
|
3333
|
-
},
|
|
3334
|
-
[locales, setLocales]
|
|
3335
|
-
), toggleAllLocales = useCallback(() => {
|
|
3336
|
-
const sourceLocale = pluginConfig.getSourceLocale(), allEnabled = locales.filter(
|
|
3337
|
-
(locale) => locale.localeId !== sourceLocale
|
|
3338
|
-
).every(
|
|
3339
|
-
(locale) => locale.enabled === !0 || locale.enabled === void 0
|
|
3340
|
-
), updatedLocales = locales.map(
|
|
3341
|
-
(locale) => locale.localeId === sourceLocale ? locale : { ...locale, enabled: !allEnabled }
|
|
3342
|
-
);
|
|
3343
|
-
setLocales(updatedLocales);
|
|
3344
|
-
}, [locales, setLocales]);
|
|
3345
|
-
return shouldShowTranslationComponents ? /* @__PURE__ */ jsxs(Stack, { gap: 6, padding: 4, children: [
|
|
3449
|
+
}, [handleImportTranslations]), shouldShowTranslationComponents ? /* @__PURE__ */ jsxs(Stack, { gap: 6, padding: 4, children: [
|
|
3346
3450
|
/* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
|
|
3347
3451
|
/* @__PURE__ */ jsx(Text, { as: "h2", weight: "semibold", size: 2, children: "Translate" }),
|
|
3348
|
-
/* @__PURE__ */
|
|
3349
|
-
/* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", children: [
|
|
3350
|
-
/* @__PURE__ */ jsx(Text, { weight: "semibold", size: 1, children: availableLocales.length === 1 ? "Select locale" : "Select locales" }),
|
|
3351
|
-
/* @__PURE__ */ jsx(
|
|
3352
|
-
Button,
|
|
3353
|
-
{
|
|
3354
|
-
fontSize: 1,
|
|
3355
|
-
padding: 2,
|
|
3356
|
-
mode: "ghost",
|
|
3357
|
-
text: "Toggle All",
|
|
3358
|
-
onClick: toggleAllLocales
|
|
3359
|
-
}
|
|
3360
|
-
)
|
|
3361
|
-
] }),
|
|
3362
|
-
/* @__PURE__ */ jsx(Grid, { gridTemplateColumns: [1, 1, 2, 3], gap: 1, children: locales.filter(
|
|
3363
|
-
(locale) => locale.localeId !== pluginConfig.getSourceLocale()
|
|
3364
|
-
).map((locale) => /* @__PURE__ */ jsx(
|
|
3365
|
-
LocaleCheckbox,
|
|
3366
|
-
{
|
|
3367
|
-
locale,
|
|
3368
|
-
toggle: toggleLocale,
|
|
3369
|
-
checked: locale.enabled === !0 || locale.enabled === void 0
|
|
3370
|
-
},
|
|
3371
|
-
locale.localeId
|
|
3372
|
-
)) })
|
|
3373
|
-
] }),
|
|
3452
|
+
/* @__PURE__ */ jsx(LocaleSelector, {}),
|
|
3374
3453
|
/* @__PURE__ */ jsx(
|
|
3375
3454
|
Button,
|
|
3376
3455
|
{
|
|
@@ -3684,7 +3763,103 @@ function buildInternationalizedArrayPlugin(config, sourceLocale, locales, custom
|
|
|
3684
3763
|
}
|
|
3685
3764
|
});
|
|
3686
3765
|
}
|
|
3687
|
-
|
|
3766
|
+
function matchesSearch(localeId, search) {
|
|
3767
|
+
const { name } = getLocaleDisplay(localeId);
|
|
3768
|
+
return localeId.toLowerCase().includes(search) || name.toLowerCase().includes(search);
|
|
3769
|
+
}
|
|
3770
|
+
const LocaleDropdown = () => {
|
|
3771
|
+
const { locales, setLocales } = useTranslations(), [open, setOpen] = useState(!1), [search, setSearch] = useState(""), buttonRef = useRef(null), popoverRef = useRef(null), sourceLocale = pluginConfig.getSourceLocale(), targetLocales = locales.filter(
|
|
3772
|
+
(locale) => locale.localeId !== sourceLocale
|
|
3773
|
+
), selectedCount = targetLocales.filter(isLocaleSelected).length, normalizedSearch = search.trim().toLowerCase(), visibleLocales = normalizedSearch ? targetLocales.filter(
|
|
3774
|
+
(locale) => matchesSearch(locale.localeId, normalizedSearch)
|
|
3775
|
+
) : targetLocales, allVisibleSelected = visibleLocales.length > 0 && visibleLocales.every(isLocaleSelected), label = selectedCount === 0 ? "Select locales" : `${selectedCount} ${selectedCount === 1 ? "locale" : "locales"}`, close = useCallback(() => setOpen(!1), []);
|
|
3776
|
+
useClickOutsideEvent(open && close, () => [
|
|
3777
|
+
buttonRef.current,
|
|
3778
|
+
popoverRef.current
|
|
3779
|
+
]), useGlobalKeyDown((event) => {
|
|
3780
|
+
open && event.key === "Escape" && (close(), buttonRef.current?.focus());
|
|
3781
|
+
});
|
|
3782
|
+
const toggleLocale = useCallback(
|
|
3783
|
+
(localeId, shouldEnable) => setLocales(setLocaleSelected(locales, localeId, shouldEnable)),
|
|
3784
|
+
[locales, setLocales]
|
|
3785
|
+
), setVisibleSelected = (selected) => {
|
|
3786
|
+
const visibleIds = new Set(visibleLocales.map((locale) => locale.localeId));
|
|
3787
|
+
setLocales(
|
|
3788
|
+
locales.map(
|
|
3789
|
+
(locale) => visibleIds.has(locale.localeId) ? { ...locale, enabled: selected } : locale
|
|
3790
|
+
)
|
|
3791
|
+
);
|
|
3792
|
+
}, content = /* @__PURE__ */ jsxs(Stack, { style: { minWidth: 288 }, children: [
|
|
3793
|
+
/* @__PURE__ */ jsxs(
|
|
3794
|
+
Flex,
|
|
3795
|
+
{
|
|
3796
|
+
align: "center",
|
|
3797
|
+
gap: 2,
|
|
3798
|
+
padding: 2,
|
|
3799
|
+
style: { borderBottom: "1px solid var(--card-border-color)" },
|
|
3800
|
+
children: [
|
|
3801
|
+
/* @__PURE__ */ jsx(Box, { paddingLeft: 1, children: /* @__PURE__ */ jsx(
|
|
3802
|
+
Checkbox,
|
|
3803
|
+
{
|
|
3804
|
+
checked: allVisibleSelected,
|
|
3805
|
+
onChange: (event) => setVisibleSelected(event.currentTarget.checked),
|
|
3806
|
+
"aria-label": "Select all visible locales"
|
|
3807
|
+
}
|
|
3808
|
+
) }),
|
|
3809
|
+
/* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(
|
|
3810
|
+
TextInput,
|
|
3811
|
+
{
|
|
3812
|
+
fontSize: 1,
|
|
3813
|
+
icon: SearchIcon,
|
|
3814
|
+
placeholder: "Search...",
|
|
3815
|
+
value: search,
|
|
3816
|
+
onChange: (event) => setSearch(event.currentTarget.value),
|
|
3817
|
+
border: !1,
|
|
3818
|
+
autoFocus: !0
|
|
3819
|
+
}
|
|
3820
|
+
) })
|
|
3821
|
+
]
|
|
3822
|
+
}
|
|
3823
|
+
),
|
|
3824
|
+
/* @__PURE__ */ jsx(Box, { padding: 1, style: { maxHeight: 320, overflowY: "auto" }, children: visibleLocales.length > 0 ? /* @__PURE__ */ jsx(Stack, { gap: 1, children: visibleLocales.map((locale) => /* @__PURE__ */ jsx(
|
|
3825
|
+
LocaleCheckbox,
|
|
3826
|
+
{
|
|
3827
|
+
locale,
|
|
3828
|
+
toggle: toggleLocale,
|
|
3829
|
+
checked: isLocaleSelected(locale),
|
|
3830
|
+
mode: "bleed",
|
|
3831
|
+
padding: 2
|
|
3832
|
+
},
|
|
3833
|
+
locale.localeId
|
|
3834
|
+
)) }) : /* @__PURE__ */ jsx(Box, { padding: 3, children: /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: targetLocales.length === 0 ? "No locales" : "No matches" }) }) })
|
|
3835
|
+
] });
|
|
3836
|
+
return /* @__PURE__ */ jsx(
|
|
3837
|
+
Popover,
|
|
3838
|
+
{
|
|
3839
|
+
ref: popoverRef,
|
|
3840
|
+
content,
|
|
3841
|
+
open,
|
|
3842
|
+
placement: "bottom-end",
|
|
3843
|
+
portal: !0,
|
|
3844
|
+
constrainSize: !0,
|
|
3845
|
+
children: /* @__PURE__ */ jsx(
|
|
3846
|
+
Button,
|
|
3847
|
+
{
|
|
3848
|
+
ref: buttonRef,
|
|
3849
|
+
mode: "ghost",
|
|
3850
|
+
text: label,
|
|
3851
|
+
iconRight: ChevronDownIcon,
|
|
3852
|
+
justify: "space-between",
|
|
3853
|
+
disabled: targetLocales.length === 0,
|
|
3854
|
+
style: { width: 192 },
|
|
3855
|
+
onClick: () => {
|
|
3856
|
+
open || setSearch(""), setOpen(!open);
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
)
|
|
3860
|
+
}
|
|
3861
|
+
);
|
|
3862
|
+
}, DocumentRow = ({ document: document2 }) => {
|
|
3688
3863
|
const {
|
|
3689
3864
|
locales,
|
|
3690
3865
|
translationStatuses,
|
|
@@ -3749,6 +3924,9 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
3749
3924
|
}, TranslationsTable = () => {
|
|
3750
3925
|
const { documents, loadingDocuments } = useTranslations();
|
|
3751
3926
|
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, { gap: 2, children: documents.map((document2) => /* @__PURE__ */ jsx(DocumentRow, { document: document2 }, document2._id)) }) });
|
|
3927
|
+
}, SelectedLocalesNote = () => {
|
|
3928
|
+
const { locales } = useTranslations(), selectedLocaleIds = getSelectedLocaleIds(locales);
|
|
3929
|
+
return /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: selectedLocaleIds.length === locales.length ? `Locales: all ${locales.length}` : `Locales: ${selectedLocaleIds.map(formatLocaleLabel).join(", ")}` });
|
|
3752
3930
|
}, TranslateAllDialog = ({
|
|
3753
3931
|
isOpen,
|
|
3754
3932
|
onClose
|
|
@@ -3783,6 +3961,7 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
3783
3961
|
documents.length,
|
|
3784
3962
|
" documents?"
|
|
3785
3963
|
] }),
|
|
3964
|
+
/* @__PURE__ */ jsx(SelectedLocalesNote, {}),
|
|
3786
3965
|
/* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "This will submit all documents to General Translation for processing." })
|
|
3787
3966
|
] }),
|
|
3788
3967
|
/* @__PURE__ */ jsx(
|
|
@@ -3835,6 +4014,7 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
3835
4014
|
documents.length,
|
|
3836
4015
|
" documents?"
|
|
3837
4016
|
] }),
|
|
4017
|
+
/* @__PURE__ */ jsx(SelectedLocalesNote, {}),
|
|
3838
4018
|
/* @__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!" })
|
|
3839
4019
|
] }) })
|
|
3840
4020
|
}
|
|
@@ -3858,6 +4038,7 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
3858
4038
|
] }) }),
|
|
3859
4039
|
children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Stack, { gap: 3, children: [
|
|
3860
4040
|
/* @__PURE__ */ jsx(Text, { children: "Import only the missing translations (translations that are ready but haven't been imported to Sanity yet)?" }),
|
|
4041
|
+
/* @__PURE__ */ jsx(SelectedLocalesNote, {}),
|
|
3861
4042
|
/* @__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." })
|
|
3862
4043
|
] }) })
|
|
3863
4044
|
}
|
|
@@ -3886,6 +4067,7 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
3886
4067
|
" ",
|
|
3887
4068
|
"documents to General Translation?"
|
|
3888
4069
|
] }),
|
|
4070
|
+
/* @__PURE__ */ jsx(SelectedLocalesNote, {}),
|
|
3889
4071
|
/* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "They become the stored translation for each locale, so later translation runs reuse them. Anything General Translation already holds for those versions is replaced. No translation is started." })
|
|
3890
4072
|
] }) })
|
|
3891
4073
|
}
|
|
@@ -3914,6 +4096,7 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
3914
4096
|
loadingDocuments,
|
|
3915
4097
|
importProgress,
|
|
3916
4098
|
importedTranslations,
|
|
4099
|
+
downloadStatus,
|
|
3917
4100
|
pendingTranslations,
|
|
3918
4101
|
isRefreshing,
|
|
3919
4102
|
setAutoRefresh,
|
|
@@ -3921,7 +4104,9 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
3921
4104
|
setPreserveExistingTranslations,
|
|
3922
4105
|
handleRefreshAll,
|
|
3923
4106
|
handlePatchDocumentReferences,
|
|
3924
|
-
handlePublishAllTranslations
|
|
4107
|
+
handlePublishAllTranslations,
|
|
4108
|
+
branchId,
|
|
4109
|
+
getVersionId
|
|
3925
4110
|
} = useTranslations(), [currentOperation, setCurrentOperation] = useState(null), getProgressOperationName = () => {
|
|
3926
4111
|
switch (currentOperation) {
|
|
3927
4112
|
case "Import All":
|
|
@@ -3941,7 +4126,18 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
3941
4126
|
React.useEffect(() => {
|
|
3942
4127
|
!isBusy && !importProgress.isImporting && setCurrentOperation(null);
|
|
3943
4128
|
}, [isBusy, importProgress.isImporting]);
|
|
3944
|
-
const isWaitingOnTranslations = pendingTranslations.size > 0,
|
|
4129
|
+
const isWaitingOnTranslations = pendingTranslations.size > 0, selectedLocaleIds = getSelectedLocaleIds(locales), totalTranslations = documents.length * selectedLocaleIds.length, importedCount = documents.reduce((count, doc) => {
|
|
4130
|
+
const publishedId = getDocumentPublishedId(doc), versionId = getVersionId(doc);
|
|
4131
|
+
return count + selectedLocaleIds.filter((localeId) => {
|
|
4132
|
+
const key = createTranslationStatusKey(
|
|
4133
|
+
branchId,
|
|
4134
|
+
publishedId,
|
|
4135
|
+
versionId,
|
|
4136
|
+
localeId
|
|
4137
|
+
);
|
|
4138
|
+
return importedTranslations.has(key) || downloadStatus.downloaded.has(key);
|
|
4139
|
+
}).length;
|
|
4140
|
+
}, 0), actionsDisabled = isBusy || loadingDocuments || documents.length === 0 || selectedLocaleIds.length === 0;
|
|
3945
4141
|
return /* @__PURE__ */ jsxs(Container, { width: 2, children: [
|
|
3946
4142
|
/* @__PURE__ */ jsx(Box, { padding: 4, marginTop: 5, children: /* @__PURE__ */ jsxs(Stack, { gap: 5, children: [
|
|
3947
4143
|
/* @__PURE__ */ jsxs(Flex, { align: "flex-start", justify: "space-between", gap: 4, children: [
|
|
@@ -3949,18 +4145,21 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
3949
4145
|
/* @__PURE__ */ jsx(Heading, { as: "h2", size: 3, children: "Translations" }),
|
|
3950
4146
|
/* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "Manage your document translations from this centralized location." })
|
|
3951
4147
|
] }),
|
|
3952
|
-
/* @__PURE__ */
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
4148
|
+
/* @__PURE__ */ jsxs(Flex, { align: "center", gap: 2, children: [
|
|
4149
|
+
/* @__PURE__ */ jsx(LocaleDropdown, {}),
|
|
4150
|
+
/* @__PURE__ */ jsx(
|
|
4151
|
+
Button,
|
|
4152
|
+
{
|
|
4153
|
+
icon: TranslateIcon,
|
|
4154
|
+
text: isWaitingOnTranslations ? "Translating\u2026" : "Translate All",
|
|
4155
|
+
loading: isBusy && currentOperation === "Translate All" || isWaitingOnTranslations,
|
|
4156
|
+
onClick: () => {
|
|
4157
|
+
setCurrentOperation("Translate All"), setIsTranslateAllDialogOpen(!0);
|
|
4158
|
+
},
|
|
4159
|
+
disabled: actionsDisabled || isWaitingOnTranslations
|
|
4160
|
+
}
|
|
4161
|
+
)
|
|
4162
|
+
] })
|
|
3964
4163
|
] }),
|
|
3965
4164
|
/* @__PURE__ */ jsxs(Stack, { gap: 3, children: [
|
|
3966
4165
|
/* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", gap: 3, children: [
|
|
@@ -4012,7 +4211,7 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
4012
4211
|
Tooltip,
|
|
4013
4212
|
{
|
|
4014
4213
|
placement: "top",
|
|
4015
|
-
content: "Imports and overrides
|
|
4214
|
+
content: "Imports and overrides translations for the selected locales",
|
|
4016
4215
|
children: /* @__PURE__ */ jsx(
|
|
4017
4216
|
Button,
|
|
4018
4217
|
{
|
|
@@ -4096,14 +4295,16 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
4096
4295
|
Tooltip,
|
|
4097
4296
|
{
|
|
4098
4297
|
placement: "top",
|
|
4099
|
-
content: "Publishes
|
|
4298
|
+
content: "Publishes translations in the selected locales whose source document is published",
|
|
4100
4299
|
children: /* @__PURE__ */ jsx(
|
|
4101
4300
|
Button,
|
|
4102
4301
|
{
|
|
4103
4302
|
mode: "ghost",
|
|
4104
4303
|
fontSize: 1,
|
|
4105
4304
|
onClick: () => {
|
|
4106
|
-
setCurrentOperation("Publish Translations"), handlePublishAllTranslations(
|
|
4305
|
+
setCurrentOperation("Publish Translations"), handlePublishAllTranslations({
|
|
4306
|
+
localeIds: selectedLocaleIds
|
|
4307
|
+
});
|
|
4107
4308
|
},
|
|
4108
4309
|
text: "Publish Translations",
|
|
4109
4310
|
loading: isBusy && currentOperation === "Publish Translations",
|
|
@@ -4114,12 +4315,12 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
4114
4315
|
}
|
|
4115
4316
|
)
|
|
4116
4317
|
] }),
|
|
4117
|
-
totalTranslations > 0 &&
|
|
4318
|
+
totalTranslations > 0 && importedCount === totalTranslations && /* @__PURE__ */ jsx(Badge, { tone: "positive", fontSize: 0, radius: 2, children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 1, children: [
|
|
4118
4319
|
/* @__PURE__ */ jsx(CheckmarkCircleIcon, {}),
|
|
4119
4320
|
/* @__PURE__ */ jsx(Box, { children: "All translations imported" })
|
|
4120
4321
|
] }) }),
|
|
4121
|
-
|
|
4122
|
-
|
|
4322
|
+
importedCount > 0 && importedCount < totalTranslations && /* @__PURE__ */ jsxs(Text, { size: 1, muted: !0, children: [
|
|
4323
|
+
importedCount,
|
|
4123
4324
|
"/",
|
|
4124
4325
|
totalTranslations,
|
|
4125
4326
|
" imported"
|
|
@@ -4207,11 +4408,6 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
4207
4408
|
)
|
|
4208
4409
|
] });
|
|
4209
4410
|
}, TranslationsTool = () => /* @__PURE__ */ jsx(BaseTranslationWrapper, { showContainer: !1, children: /* @__PURE__ */ jsx(TranslationsProvider, { children: /* @__PURE__ */ jsx(TranslationsToolContent, {}) }) });
|
|
4210
|
-
function resolveTargetLocales(sourceLocale, locales) {
|
|
4211
|
-
return Array.from(new Set(locales)).filter(
|
|
4212
|
-
(locale) => locale !== sourceLocale
|
|
4213
|
-
);
|
|
4214
|
-
}
|
|
4215
4411
|
function documentLevelTypes() {
|
|
4216
4412
|
const level = pluginConfig.getTranslationLevel(), types = pluginConfig.getTranslateDocuments().map((filter) => filter.type).filter((type) => !!type);
|
|
4217
4413
|
if (level === "internationalizedArray") return [];
|