@parhelia/localization 0.4.13037 → 0.4.13058
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/LocalizeItemDialog.d.ts.map +1 -1
- package/dist/LocalizeItemDialog.js +1 -0
- package/dist/LocalizeItemUtils.d.ts.map +1 -1
- package/dist/LocalizeItemUtils.js +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/steps/ItemSelectionTree.d.ts +2 -2
- package/dist/steps/ItemSelectionTree.d.ts.map +1 -1
- package/dist/steps/ItemSelectionTree.js +43 -45
- package/dist/steps/ProviderStep.d.ts.map +1 -1
- package/dist/steps/ProviderStep.js +2 -1
- package/dist/steps/ServiceLanguageSelectionStep.d.ts +1 -1
- package/dist/steps/ServiceLanguageSelectionStep.d.ts.map +1 -1
- package/dist/steps/ServiceLanguageSelectionStep.js +130 -173
- package/dist/steps/types.d.ts +1 -1
- package/dist/translation-center/TranslationBatches.d.ts +1 -0
- package/dist/translation-center/TranslationBatches.d.ts.map +1 -1
- package/dist/translation-center/TranslationBatches.js +14 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalizeItemDialog.d.ts","sourceRoot":"","sources":["../src/LocalizeItemDialog.tsx"],"names":[],"mappings":"AA8BA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EAExB,MAAM,eAAe,CAAC;AAoEvB,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,uBAAuB,GAAG,WAAW,CAAC,uBAAuB,CAAC,+
|
|
1
|
+
{"version":3,"file":"LocalizeItemDialog.d.ts","sourceRoot":"","sources":["../src/LocalizeItemDialog.tsx"],"names":[],"mappings":"AA8BA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EAExB,MAAM,eAAe,CAAC;AAoEvB,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,uBAAuB,GAAG,WAAW,CAAC,uBAAuB,CAAC,+BAqiBtE"}
|
|
@@ -240,6 +240,7 @@ export function LocalizeItemDialog(props) {
|
|
|
240
240
|
: null;
|
|
241
241
|
const dataKey = JSON.stringify({
|
|
242
242
|
translationProvider: newData.translationProvider,
|
|
243
|
+
sourceLanguage: newData.sourceLanguage ?? "",
|
|
243
244
|
targetLanguages: [...newData.targetLanguages].sort(),
|
|
244
245
|
includeSubitems: newData.includeSubitems,
|
|
245
246
|
discoveredItemIds: (newData.discoveredItems || [])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalizeItemUtils.d.ts","sourceRoot":"","sources":["../src/LocalizeItemUtils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AA8EjD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAIF,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,qBAAqB,EACjC,WAAW,EAAE,eAAe,GAC3B,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"LocalizeItemUtils.d.ts","sourceRoot":"","sources":["../src/LocalizeItemUtils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AA8EjD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAIF,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,qBAAqB,EACjC,WAAW,EAAE,eAAe,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CAmI5B;AAGD,eAAO,MAAM,mBAAmB,kBACf,MAAM,EAAE,qBACJ,iBAAiB,EAAE,aAC3B,MAAM,QACX,QAAQ,uBACO,MAAM,+BAqC5B,CAAC"}
|
|
@@ -105,6 +105,8 @@ export async function performDefaultTranslation(wizardData, editContext) {
|
|
|
105
105
|
if (trimmedName) {
|
|
106
106
|
metadataObj.name = trimmedName;
|
|
107
107
|
}
|
|
108
|
+
// One source per batch; the batch list shows it without loading the jobs.
|
|
109
|
+
metadataObj.sourceLanguage = languageMappings[0].sourceLanguage;
|
|
108
110
|
// Merge service-specific custom data (e.g., custom prompts for AI providers)
|
|
109
111
|
if (wizardData.serviceCustomData && wizardData.serviceCustomData.size > 0) {
|
|
110
112
|
const serviceData = wizardData.serviceCustomData.get(wizardData.translationProvider);
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAoBpF,OAAO,EACL,mBAAmB,EAGpB,MAAM,gBAAgB,CAAC;AAWxB,QAAA,MAAM,wCAAwC;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAoBpF,OAAO,EACL,mBAAmB,EAGpB,MAAM,gBAAgB,CAAC;AAWxB,QAAA,MAAM,wCAAwC;;;;;;;;;;;;;;CAwB7C,CAAC;AAEF,QAAA,MAAM,4CAA4C;;;;;;;;CAkBjD,CAAC;AAoDF,OAAO,EACL,wCAAwC,EACxC,4CAA4C,GAC7C,CAAC;AACF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,YAAY,EACV,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,YAAY,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEhF,MAAM,MAAM,yBAAyB,GAAG;IACtC;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,mBAAmB,EAClC,OAAO,CAAC,EAAE,yBAAyB,uBAuIpC"}
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,7 @@ const DEFAULT_TRANSLATION_WIZARD_CONFIGURATION = {
|
|
|
25
25
|
id: "language-selection",
|
|
26
26
|
name: "Languages",
|
|
27
27
|
nextButtonLabel: "Select Languages",
|
|
28
|
-
description: "Select target languages for your content.",
|
|
28
|
+
description: "Select the source language and the target languages for your content.",
|
|
29
29
|
component: ServiceLanguageSelectionStep,
|
|
30
30
|
},
|
|
31
31
|
{
|
|
@@ -43,7 +43,7 @@ const SINGLE_ITEM_TRANSLATION_WIZARD_CONFIGURATION = {
|
|
|
43
43
|
id: "language-selection",
|
|
44
44
|
name: "Languages",
|
|
45
45
|
nextButtonLabel: "Select Languages",
|
|
46
|
-
description: "Select target languages for your content.",
|
|
46
|
+
description: "Select the source language and the target languages for your content.",
|
|
47
47
|
component: ServiceLanguageSelectionStep,
|
|
48
48
|
},
|
|
49
49
|
{
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type EditContextType } from "@parhelia/core";
|
|
2
|
-
import type { TranslationWizardData } from "./types";
|
|
2
|
+
import type { TranslationStepProps, TranslationWizardData } from "./types";
|
|
3
3
|
type ItemSelectionTreeProps = {
|
|
4
4
|
data: TranslationWizardData;
|
|
5
|
-
setData:
|
|
5
|
+
setData: TranslationStepProps["setData"];
|
|
6
6
|
editContext: EditContextType;
|
|
7
7
|
isActive?: boolean;
|
|
8
8
|
onSelectionValidChange?: (valid: boolean) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemSelectionTree.d.ts","sourceRoot":"","sources":["../../src/steps/ItemSelectionTree.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"ItemSelectionTree.d.ts","sourceRoot":"","sources":["../../src/steps/ItemSelectionTree.tsx"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,eAAe,EAOrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAO3E,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IACzC,WAAW,EAAE,eAAe,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B,CAAC;AAoFF,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,OAAO,EACP,WAAW,EACX,QAAe,EACf,sBAAsB,EACtB,MAAY,GACb,EAAE,sBAAsB,+BAqexB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import { ContentStoreSelect,
|
|
3
|
+
import { ContentStoreSelect, ItemCollectionEditor, getLanguages, useContentModel, } from "@parhelia/core";
|
|
4
4
|
import { streamSubitemCount } from "../api/discovery";
|
|
5
5
|
import { translationDescriptorKey as itemKey, translationItem, } from "../services/translationService";
|
|
6
6
|
const NO_WRITE_ACCESS_TITLE = "You don't have write access to this item, so it can't be translated.";
|
|
@@ -71,9 +71,10 @@ export function ItemSelectionTree({ data, setData, editContext, isActive = true,
|
|
|
71
71
|
const [store, setStore] = useState(editContext.currentItemDescriptor?.database ??
|
|
72
72
|
data.items[0]?.descriptor.database ??
|
|
73
73
|
"");
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
const preferredLanguage = data.sourceLanguage ||
|
|
75
|
+
editContext?.currentItemDescriptor?.language ||
|
|
76
|
+
data.items[0]?.descriptor.language ||
|
|
77
|
+
"";
|
|
77
78
|
// Seed selection: prefer previously saved tree items, then discoveredItems,
|
|
78
79
|
// then the wizard's initial `items`. Default includeSubitems = legacy flag.
|
|
79
80
|
const initialItems = useMemo(() => {
|
|
@@ -101,10 +102,8 @@ export function ItemSelectionTree({ data, setData, editContext, isActive = true,
|
|
|
101
102
|
const [subitemCounts, setSubitemCounts] = useState(() => data.subitemCounts ?? {});
|
|
102
103
|
// Mirror local subitemCounts into wizardData so later steps (e.g. the
|
|
103
104
|
// Start Translation button) can show a live total.
|
|
104
|
-
const dataRef = useRef(data);
|
|
105
|
-
dataRef.current = data;
|
|
106
105
|
useEffect(() => {
|
|
107
|
-
setData({ ...
|
|
106
|
+
setData((current) => ({ ...current, subitemCounts }));
|
|
108
107
|
}, [subitemCounts, setData]);
|
|
109
108
|
// Keep a cache of the richest FullItem we've ever seen for each id so we
|
|
110
109
|
// can rebuild discoveredItems without re-fetching.
|
|
@@ -135,18 +134,19 @@ export function ItemSelectionTree({ data, setData, editContext, isActive = true,
|
|
|
135
134
|
return undefined;
|
|
136
135
|
return "/" + segments.join("/");
|
|
137
136
|
}, [items]);
|
|
138
|
-
const commitToWizard = useCallback((nextItems
|
|
137
|
+
const commitToWizard = useCallback((nextItems) => {
|
|
139
138
|
const cache = itemCacheRef.current;
|
|
140
139
|
const discovered = nextItems.map((entry) => cache.get(itemKey(entry.descriptor)) ??
|
|
141
140
|
fullItemFromDescriptor(entry.descriptor));
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
// A functional update: the Languages step writes the source language
|
|
142
|
+
// into the same wizard data.
|
|
143
|
+
setData((current) => ({
|
|
144
|
+
...current,
|
|
144
145
|
selectionTreeItems: nextItems,
|
|
145
146
|
discoveredItems: discovered,
|
|
146
147
|
includeSubitems: nextItems.some((i) => i.includeSubitems),
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}, [data, setData, language]);
|
|
148
|
+
}));
|
|
149
|
+
}, [setData]);
|
|
150
150
|
// Only stores the user may write can receive a translation. With a single
|
|
151
151
|
// one there is nothing to choose: it is preselected and the picker hidden.
|
|
152
152
|
const writableStores = useMemo(() => (model?.stores ?? []).filter((candidate) => candidate.canWrite), [model?.stores]);
|
|
@@ -155,8 +155,8 @@ export function ItemSelectionTree({ data, setData, editContext, isActive = true,
|
|
|
155
155
|
if (onlyStore && !store)
|
|
156
156
|
setStore(onlyStore.id);
|
|
157
157
|
}, [onlyStore, store]);
|
|
158
|
-
// The locales the chosen store declares
|
|
159
|
-
//
|
|
158
|
+
// The locales the chosen store declares. Null while loading (or with no
|
|
159
|
+
// store), so the preferred language is kept.
|
|
160
160
|
const [storeLanguages, setStoreLanguages] = useState(null);
|
|
161
161
|
useEffect(() => {
|
|
162
162
|
setStoreLanguages(null);
|
|
@@ -177,28 +177,29 @@ export function ItemSelectionTree({ data, setData, editContext, isActive = true,
|
|
|
177
177
|
cancelled = true;
|
|
178
178
|
};
|
|
179
179
|
}, [store]);
|
|
180
|
+
// The tree browses in the source language chosen in the Languages step,
|
|
181
|
+
// else the editor's language; a store that declares neither is browsed in
|
|
182
|
+
// its first language. An empty list is a failed read, not a store without
|
|
183
|
+
// languages.
|
|
184
|
+
const language = !storeLanguages?.length ||
|
|
185
|
+
storeLanguages.some((entry) => entry.languageCode === preferredLanguage)
|
|
186
|
+
? preferredLanguage
|
|
187
|
+
: storeLanguages[0].languageCode;
|
|
180
188
|
// The selected items carry the source language as their coordinate, so a
|
|
181
189
|
// new source relabels them (subitem discovery reads it from there too).
|
|
182
|
-
|
|
183
|
-
|
|
190
|
+
useEffect(() => {
|
|
191
|
+
if (!language)
|
|
192
|
+
return;
|
|
193
|
+
if (items.every((entry) => entry.descriptor.language === language))
|
|
194
|
+
return;
|
|
184
195
|
setSelectedInTree([]);
|
|
185
196
|
const next = items.map((entry) => ({
|
|
186
197
|
...entry,
|
|
187
|
-
descriptor: { ...entry.descriptor, language
|
|
198
|
+
descriptor: { ...entry.descriptor, language },
|
|
188
199
|
}));
|
|
189
200
|
setItems(next);
|
|
190
|
-
commitToWizard(next
|
|
191
|
-
}, [items, commitToWizard]);
|
|
192
|
-
// A store that does not declare the current source language (another
|
|
193
|
-
// store picked, or a seed in a language the store lacks) clears it.
|
|
194
|
-
useEffect(() => {
|
|
195
|
-
// An empty list is a failed read, not a store without languages.
|
|
196
|
-
if (!storeLanguages?.length || !language)
|
|
197
|
-
return;
|
|
198
|
-
if (storeLanguages.some((entry) => entry.languageCode === language))
|
|
199
|
-
return;
|
|
200
|
-
handleLanguageChange("");
|
|
201
|
-
}, [storeLanguages, language, handleLanguageChange]);
|
|
201
|
+
commitToWizard(next);
|
|
202
|
+
}, [language, items, commitToWizard]);
|
|
202
203
|
// Commit current state on first mount so wizard data reflects the seed.
|
|
203
204
|
const didInitialCommitRef = useRef(false);
|
|
204
205
|
useEffect(() => {
|
|
@@ -423,19 +424,16 @@ export function ItemSelectionTree({ data, setData, editContext, isActive = true,
|
|
|
423
424
|
}, [items, commitToWizard]);
|
|
424
425
|
// A bounded column: the pickers keep their height and the editor takes the
|
|
425
426
|
// rest, so the tree and the list scroll inside it, never the whole step.
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
.map((root) => root.id), hideRootNodes: false, isItemSelectable: isWritable, unselectableItemTitle: NO_WRITE_ACCESS_TITLE, selectedItemsLabel: "Items to Translate", emptyMessage: "No items selected", emptyHint: "Browse or search to add items", height: height, subitemCounts: subitemCounts, subitemCountKey: itemKey, expandIdPath: expandIdPath, localStorageKey: "translation-wizard.itemCollectionSplitter", treeSearchContainerClassName: "border-b-0 p-0 pb-3", frameless: true }) })) : (_jsx("p", { className: "text-neutral-grey-50 px-6 text-sm", children: onlyStore
|
|
439
|
-
? "Select a source language to choose translation items."
|
|
440
|
-
: "Select a content store and source language to choose translation items." }))] }));
|
|
427
|
+
const storePicker = onlyStore ? undefined : (_jsxs("div", { className: "flex w-64 max-w-full flex-col gap-2", children: [_jsx("span", { className: "text-neutral-grey-50 text-xs font-medium tracking-wider", children: "Content store" }), _jsx(ContentStoreSelect, { "data-testid": "translation-content-store", value: store, placeholder: "Select a store", onValueChange: (value) => {
|
|
428
|
+
setStore(value);
|
|
429
|
+
setSelectedInTree([]);
|
|
430
|
+
}, stores: writableStores })] }));
|
|
431
|
+
return (_jsx("div", { className: "flex h-full min-h-0 flex-col", children: store && language ? (_jsx("div", { className: "min-h-0 flex-1", children: _jsx(ItemCollectionEditor, { items: items, selectedInTree: selectedInTree, onSelectedInTreeChange: setSelectedInTree, selectedFromList: selectedFromList, onSelectedFromListChange: setSelectedFromList, onAddToList: handleAddToList, onRemoveFromList: handleRemoveFromList, onAddItem: handleAddItem, onRemoveItem: handleRemoveItem, onToggleSubitems: handleToggleSubitems, language: language, database: store, rootItemIds: model?.roots
|
|
432
|
+
.filter((root) => root.storeId === store &&
|
|
433
|
+
(root.kind === "content" || root.kind === "media"))
|
|
434
|
+
.map((root) => root.id), hideRootNodes: false, isItemSelectable: isWritable, unselectableItemTitle: NO_WRITE_ACCESS_TITLE, selectedItemsLabel: "Selected", emptyMessage: "No items selected", emptyHint: "Browse or search to add items", height: height, subitemCounts: subitemCounts, subitemCountKey: itemKey, expandIdPath: expandIdPath, localStorageKey: "translation-wizard.itemCollectionSplitter", treeSearchContainerClassName: "border-b-0 p-0 pb-3", treeHeader: storePicker, frameless: true }) })) : (_jsxs("div", { className: "flex flex-col gap-4 p-6", children: [storePicker, _jsx("p", { className: "text-neutral-grey-50 text-sm", children: !store
|
|
435
|
+
? "Select a content store to choose translation items."
|
|
436
|
+
: storeLanguages === null
|
|
437
|
+
? "Loading languages..."
|
|
438
|
+
: "This store declares no languages." })] })) }));
|
|
441
439
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProviderStep.d.ts","sourceRoot":"","sources":["../../src/steps/ProviderStep.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AAUf,OAAO,EAAE,oBAAoB,EAAyB,MAAM,SAAS,CAAC;AAStE,wBAAgB,YAAY,CAAC,EAC3B,QAAe,EACf,IAAI,EACJ,OAAO,EACP,eAAe,EACf,WAAW,GACZ,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"ProviderStep.d.ts","sourceRoot":"","sources":["../../src/steps/ProviderStep.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AAUf,OAAO,EAAE,oBAAoB,EAAyB,MAAM,SAAS,CAAC;AAStE,wBAAgB,YAAY,CAAC,EAC3B,QAAe,EACf,IAAI,EACJ,OAAO,EACP,eAAe,EACf,WAAW,GACZ,EAAE,oBAAoB,qBAkZtB"}
|
|
@@ -58,7 +58,7 @@ export function ProviderStep({ isActive = true, data, setData, onStepCompleted,
|
|
|
58
58
|
descriptors.some((d) => !d.database || !d.language))
|
|
59
59
|
return;
|
|
60
60
|
const items = descriptors.map(translationItem);
|
|
61
|
-
const language = descriptors[0].language;
|
|
61
|
+
const language = data.sourceLanguage || descriptors[0].language;
|
|
62
62
|
const key = JSON.stringify({ items, language, langs });
|
|
63
63
|
if (lastSuggestionKeyRef.current === key)
|
|
64
64
|
return;
|
|
@@ -87,6 +87,7 @@ export function ProviderStep({ isActive = true, data, setData, onStepCompleted,
|
|
|
87
87
|
sessionId,
|
|
88
88
|
data.selectionTreeItems,
|
|
89
89
|
data.items,
|
|
90
|
+
data.sourceLanguage,
|
|
90
91
|
data.targetLanguages,
|
|
91
92
|
]);
|
|
92
93
|
const customPromptRef = useRef(customPrompt);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TranslationStepProps } from "./types";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Source and target languages. Item selection lives in its own step
|
|
4
4
|
* (see ItemSelectionStep). The legacy name is kept so existing imports
|
|
5
5
|
* keep working.
|
|
6
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceLanguageSelectionStep.d.ts","sourceRoot":"","sources":["../../src/steps/ServiceLanguageSelectionStep.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ServiceLanguageSelectionStep.d.ts","sourceRoot":"","sources":["../../src/steps/ServiceLanguageSelectionStep.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAoB/C;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,QAAe,EACf,IAAI,EACJ,OAAO,EACP,eAAe,EACf,WAAW,GACZ,EAAE,oBAAoB,+BA0VtB"}
|
|
@@ -1,214 +1,171 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import {
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { LanguageIcon, SearchInput, Select, Tooltip, TooltipContent, TooltipTrigger, cn, getLanguages, } from "@parhelia/core";
|
|
4
4
|
import { WizardStepShell } from "./WizardStepShell";
|
|
5
|
+
const columnLabel = "text-xs font-medium tracking-wider text-neutral-grey-50";
|
|
6
|
+
function matchesFilter(language, filter) {
|
|
7
|
+
const text = filter.trim().toLowerCase();
|
|
8
|
+
return (!text ||
|
|
9
|
+
language.name.toLowerCase().includes(text) ||
|
|
10
|
+
language.code.toLowerCase().includes(text));
|
|
11
|
+
}
|
|
5
12
|
/**
|
|
6
|
-
*
|
|
13
|
+
* Source and target languages. Item selection lives in its own step
|
|
7
14
|
* (see ItemSelectionStep). The legacy name is kept so existing imports
|
|
8
15
|
* keep working.
|
|
9
16
|
*/
|
|
10
17
|
export function ServiceLanguageSelectionStep({ isActive = true, data, setData, onStepCompleted, editContext, }) {
|
|
11
|
-
const [
|
|
12
|
-
const dataRef = useRef(data);
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
dataRef.current = data;
|
|
15
|
-
}, [data]);
|
|
16
|
-
const onStepCompletedRef = useRef(onStepCompleted);
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
onStepCompletedRef.current = onStepCompleted;
|
|
19
|
-
}, [onStepCompleted]);
|
|
20
|
-
const lastCompletionStateRef = useRef(null);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (!isActive)
|
|
23
|
-
return;
|
|
24
|
-
const isCompleted = data.targetLanguages.length > 0;
|
|
25
|
-
if (lastCompletionStateRef.current !== isCompleted) {
|
|
26
|
-
lastCompletionStateRef.current = isCompleted;
|
|
27
|
-
onStepCompletedRef.current(isCompleted);
|
|
28
|
-
}
|
|
29
|
-
}, [isActive, data.targetLanguages.length]);
|
|
18
|
+
const [filter, setFilter] = useState("");
|
|
30
19
|
const editContextLanguages = useMemo(() => editContext?.itemLanguages || [], [editContext?.itemLanguages]);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
// The store chosen in the Items step; outside the editor (Translation
|
|
21
|
+
// Management) there is no current item to fall back on.
|
|
22
|
+
const store = data.selectionTreeItems?.[0]?.descriptor.database ||
|
|
23
|
+
data.items[0]?.descriptor.database ||
|
|
24
|
+
editContext?.currentItemDescriptor?.database;
|
|
25
|
+
const [storeLanguages, setStoreLanguages] = useState([]);
|
|
34
26
|
useEffect(() => {
|
|
35
|
-
|
|
36
|
-
return;
|
|
37
|
-
// The store chosen in the Items step; outside the editor (Translation
|
|
38
|
-
// Management) there is no current item to fall back on.
|
|
39
|
-
const store = wizardStore || editContext?.currentItemDescriptor?.database;
|
|
27
|
+
setStoreLanguages([]);
|
|
40
28
|
if (!store)
|
|
41
29
|
return;
|
|
42
30
|
let cancelled = false;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
console.error("Failed to load languages:", error);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
loadSiteLanguages();
|
|
31
|
+
getLanguages(store)
|
|
32
|
+
.then((res) => {
|
|
33
|
+
const languages = res?.data ?? res ?? [];
|
|
34
|
+
if (!cancelled && Array.isArray(languages))
|
|
35
|
+
setStoreLanguages(languages);
|
|
36
|
+
})
|
|
37
|
+
.catch((error) => console.error("Failed to load languages:", error));
|
|
56
38
|
return () => {
|
|
57
39
|
cancelled = true;
|
|
58
40
|
};
|
|
59
|
-
}, [
|
|
60
|
-
|
|
61
|
-
data.languageData.size,
|
|
62
|
-
wizardStore,
|
|
63
|
-
editContext?.currentItemDescriptor?.database,
|
|
64
|
-
]);
|
|
65
|
-
const siteLanguageCodes = useMemo(() => {
|
|
66
|
-
if (editContextLanguages.length > 0) {
|
|
67
|
-
return editContextLanguages.map((lang) => lang.languageCode);
|
|
68
|
-
}
|
|
69
|
-
if (data.languageData.size > 0) {
|
|
70
|
-
return Array.from(data.languageData.keys());
|
|
71
|
-
}
|
|
72
|
-
if (siteLanguages.length > 0) {
|
|
73
|
-
return siteLanguages.map((lang) => lang.languageCode);
|
|
74
|
-
}
|
|
75
|
-
return Array.from(data.languageData.keys());
|
|
76
|
-
}, [editContextLanguages, data.languageData, siteLanguages]);
|
|
77
|
-
const itemSourceLanguage = useMemo(() => {
|
|
78
|
-
return (data.sourceLanguage ||
|
|
79
|
-
data.selectionTreeItems?.[0]?.descriptor.language ||
|
|
80
|
-
data.items[0]?.descriptor.language ||
|
|
81
|
-
editContext?.item?.descriptor.language ||
|
|
82
|
-
editContext?.currentItemDescriptor?.language ||
|
|
83
|
-
"");
|
|
84
|
-
}, [
|
|
85
|
-
data.sourceLanguage,
|
|
86
|
-
data.selectionTreeItems,
|
|
87
|
-
data.items,
|
|
88
|
-
editContext?.item,
|
|
89
|
-
editContext?.currentItemDescriptor,
|
|
90
|
-
]);
|
|
91
|
-
const allLanguages = useMemo(() => {
|
|
41
|
+
}, [store]);
|
|
42
|
+
const languages = useMemo(() => {
|
|
92
43
|
const editContextLanguageMap = new Map(editContextLanguages.map((lang) => [lang.languageCode, lang]));
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
.map((
|
|
44
|
+
const storeLanguageMap = new Map(storeLanguages.map((lang) => [lang.languageCode, lang]));
|
|
45
|
+
const codes = storeLanguages.length > 0
|
|
46
|
+
? storeLanguages.map((lang) => lang.languageCode)
|
|
47
|
+
: editContextLanguages.length > 0
|
|
48
|
+
? editContextLanguages.map((lang) => lang.languageCode)
|
|
49
|
+
: Array.from(data.languageData.keys());
|
|
50
|
+
const list = codes.map((code) => {
|
|
96
51
|
const editContextLang = editContextLanguageMap.get(code);
|
|
97
|
-
const
|
|
52
|
+
const storeLanguage = storeLanguageMap.get(code);
|
|
98
53
|
const languageDataLang = data.languageData.get(code);
|
|
99
|
-
// The source chosen in the dialog wins over the status endpoint's
|
|
100
|
-
// per-target suggestion (same order as performDefaultTranslation).
|
|
101
|
-
const sourceLanguage = itemSourceLanguage ||
|
|
102
|
-
languageDataLang?.translationStatus?.sourceLanguage ||
|
|
103
|
-
"";
|
|
104
|
-
const sourceLanguageName = editContextLanguageMap.get(sourceLanguage)?.name ||
|
|
105
|
-
data.languageData.get(sourceLanguage)?.name ||
|
|
106
|
-
siteLanguageMap.get(sourceLanguage)?.name ||
|
|
107
|
-
sourceLanguage;
|
|
108
54
|
// Language write ACL (language:write). Every source reports it for
|
|
109
55
|
// the same language item, so the first defined value wins; unknown
|
|
110
56
|
// is treated as allowed and left to the backend check.
|
|
111
57
|
const canWrite = editContextLang?.canWrite ??
|
|
112
58
|
languageDataLang?.canWrite ??
|
|
113
|
-
|
|
59
|
+
storeLanguage?.canWrite;
|
|
114
60
|
return {
|
|
115
61
|
code,
|
|
116
62
|
name: editContextLang?.name ||
|
|
117
63
|
languageDataLang?.name ||
|
|
118
|
-
|
|
64
|
+
storeLanguage?.name ||
|
|
119
65
|
code,
|
|
120
|
-
icon: editContextLang?.icon || siteLanguage?.icon,
|
|
121
|
-
sourceLanguage,
|
|
122
|
-
sourceLanguageName,
|
|
123
66
|
canWrite: canWrite !== false,
|
|
124
67
|
};
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
68
|
+
});
|
|
69
|
+
list.sort((a, b) => a.name.localeCompare(b.name));
|
|
70
|
+
return list;
|
|
71
|
+
}, [editContextLanguages, storeLanguages, data.languageData]);
|
|
72
|
+
const itemLanguage = data.selectionTreeItems?.[0]?.descriptor.language ||
|
|
73
|
+
data.items[0]?.descriptor.language ||
|
|
74
|
+
editContext?.item?.descriptor.language ||
|
|
75
|
+
editContext?.currentItemDescriptor?.language ||
|
|
76
|
+
"";
|
|
77
|
+
const sourceLanguage = data.sourceLanguage || "";
|
|
78
|
+
// The source is always explicit in the wizard data: seeded from the items'
|
|
79
|
+
// language, and dropped when the store does not declare it.
|
|
137
80
|
useEffect(() => {
|
|
138
|
-
if (
|
|
81
|
+
if (languages.length === 0)
|
|
139
82
|
return;
|
|
140
|
-
const
|
|
141
|
-
if (
|
|
83
|
+
const declared = (code) => languages.some((lang) => lang.code === code);
|
|
84
|
+
if (sourceLanguage && declared(sourceLanguage))
|
|
142
85
|
return;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}, [allLanguages, data.targetLanguages]);
|
|
153
|
-
const lastSetTargetLanguagesRef = useRef("");
|
|
86
|
+
const next = itemLanguage && declared(itemLanguage) ? itemLanguage : "";
|
|
87
|
+
if (next === sourceLanguage)
|
|
88
|
+
return;
|
|
89
|
+
setData((current) => ({ ...current, sourceLanguage: next || undefined }));
|
|
90
|
+
}, [languages, sourceLanguage, itemLanguage, setData]);
|
|
91
|
+
const targetLanguages = useMemo(() => languages.filter((lang) => lang.code !== sourceLanguage), [languages, sourceLanguage]);
|
|
92
|
+
const writableTargets = useMemo(() => targetLanguages.filter((lang) => lang.canWrite), [targetLanguages]);
|
|
93
|
+
// Predefined targets the user cannot write, and the source itself, are
|
|
94
|
+
// dropped silently.
|
|
154
95
|
useEffect(() => {
|
|
155
|
-
|
|
156
|
-
.filter(([, isSelected]) => isSelected)
|
|
157
|
-
.map(([code]) => code);
|
|
158
|
-
const selectedLanguagesKey = JSON.stringify([...selectedLanguages].sort());
|
|
159
|
-
const currentTargetLanguagesKey = JSON.stringify([...data.targetLanguages].sort());
|
|
160
|
-
if (selectedLanguagesKey === currentTargetLanguagesKey)
|
|
96
|
+
if (languages.length === 0)
|
|
161
97
|
return;
|
|
162
|
-
|
|
98
|
+
const allowed = new Set(writableTargets.map((lang) => lang.code));
|
|
99
|
+
if (data.targetLanguages.every((code) => allowed.has(code)))
|
|
163
100
|
return;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const
|
|
174
|
-
const
|
|
175
|
-
|
|
101
|
+
setData((current) => ({
|
|
102
|
+
...current,
|
|
103
|
+
targetLanguages: current.targetLanguages.filter((code) => allowed.has(code)),
|
|
104
|
+
}));
|
|
105
|
+
}, [languages.length, writableTargets, data.targetLanguages, setData]);
|
|
106
|
+
const onStepCompletedRef = useRef(onStepCompleted);
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
onStepCompletedRef.current = onStepCompleted;
|
|
109
|
+
}, [onStepCompleted]);
|
|
110
|
+
const lastCompletionStateRef = useRef(null);
|
|
111
|
+
const isCompleted = !!sourceLanguage && data.targetLanguages.length > 0;
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
if (!isActive)
|
|
176
114
|
return;
|
|
177
|
-
|
|
115
|
+
if (lastCompletionStateRef.current !== isCompleted) {
|
|
116
|
+
lastCompletionStateRef.current = isCompleted;
|
|
117
|
+
onStepCompletedRef.current(isCompleted);
|
|
118
|
+
}
|
|
119
|
+
}, [isActive, isCompleted]);
|
|
120
|
+
const handleSourceChange = useCallback((code) => {
|
|
121
|
+
setData((current) => ({
|
|
122
|
+
...current,
|
|
123
|
+
sourceLanguage: code,
|
|
124
|
+
targetLanguages: current.targetLanguages.filter((target) => target !== code),
|
|
125
|
+
}));
|
|
126
|
+
}, [setData]);
|
|
127
|
+
const selected = useMemo(() => new Set(data.targetLanguages), [data.targetLanguages]);
|
|
128
|
+
const shownTargets = useMemo(() => targetLanguages.filter((lang) => matchesFilter(lang, filter)), [targetLanguages, filter]);
|
|
129
|
+
const shownWritable = shownTargets.filter((lang) => lang.canWrite);
|
|
130
|
+
const allShownSelected = shownWritable.length > 0 &&
|
|
131
|
+
shownWritable.every((lang) => selected.has(lang.code));
|
|
132
|
+
const someShownSelected = shownWritable.some((lang) => selected.has(lang.code));
|
|
133
|
+
const toggleLanguage = (code) => {
|
|
134
|
+
setData((current) => ({
|
|
135
|
+
...current,
|
|
136
|
+
targetLanguages: current.targetLanguages.includes(code)
|
|
137
|
+
? current.targetLanguages.filter((target) => target !== code)
|
|
138
|
+
: [...current.targetLanguages, code],
|
|
139
|
+
}));
|
|
178
140
|
};
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
141
|
+
const toggleAllShown = () => {
|
|
142
|
+
const shownCodes = shownWritable.map((lang) => lang.code);
|
|
143
|
+
setData((current) => {
|
|
144
|
+
const rest = current.targetLanguages.filter((code) => !shownCodes.includes(code));
|
|
145
|
+
return {
|
|
146
|
+
...current,
|
|
147
|
+
targetLanguages: allShownSelected ? rest : [...rest, ...shownCodes],
|
|
148
|
+
};
|
|
184
149
|
});
|
|
185
|
-
setLanguageSelection(newSelection);
|
|
186
150
|
};
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
? "You don't have write access to this language."
|
|
206
|
-
|
|
207
|
-
? "cursor-not-allowed border-border-default opacity-50"
|
|
208
|
-
: checked
|
|
209
|
-
? "cursor-pointer border-neutral-grey-100"
|
|
210
|
-
: "cursor-pointer border-border-default hover:border-border-default hover:bg-neutral-grey-5"}`, children: [_jsx("input", { type: "checkbox", checked: checked, disabled: readOnly, onChange: () => handleLanguageToggle(lang.code), className: "h-3.5 w-3.5 shrink-0 rounded border-border-default text-[var(--color-highlight-100)] accent-[var(--color-highlight-100)] focus:ring-[var(--color-highlight-100)] disabled:cursor-not-allowed", "data-testid": `language-checkbox-${lang.code}` }), _jsx(LanguageIcon, { language: { languageCode: lang.code, name: lang.name }, flagClassName: "h-[15px] w-5 shrink-0", globeClassName: "h-4 w-5 shrink-0" }), _jsx("span", { className: `min-w-0 flex-1 truncate text-[13px] ${checked
|
|
211
|
-
? "font-medium text-neutral-grey-100"
|
|
212
|
-
: "text-neutral-grey-100"}`, children: lang.name }), _jsxs("span", { className: "ml-auto flex max-w-[9rem] shrink-0 flex-col items-end leading-tight", children: [_jsx("span", { className: "font-mono text-[10px] tracking-wider text-neutral-grey-50", children: lang.code }), readOnly ? (_jsx("span", { className: "max-w-full truncate text-[10px] text-neutral-grey-50", children: "no write access" })) : (_jsxs("span", { className: "max-w-full truncate text-[10px] text-neutral-grey-50", title: `Source language: ${lang.sourceLanguageName}`, children: ["from ", lang.sourceLanguageName] }))] })] }, lang.code));
|
|
213
|
-
}) })) })] }) }));
|
|
151
|
+
const isFiltering = filter.trim().length > 0;
|
|
152
|
+
return (_jsx(WizardStepShell, { fillHeight: true, noPadding: true, testId: "language-selection-step", children: _jsxs("div", { className: "flex min-h-0 w-full flex-1 flex-col overflow-hidden sm:flex-row", children: [_jsxs("div", { className: "flex min-w-0 shrink-0 flex-col gap-2 border-b border-border-default p-6 sm:flex-1 sm:border-r sm:border-b-0", children: [_jsx("span", { className: columnLabel, children: "Select source language" }), _jsx(Select, { "data-testid": "translation-source-language", "aria-label": "Source language", value: sourceLanguage, placeholder: "Select a language", loading: languages.length === 0, onValueChange: handleSourceChange, searchable: true, searchMatch: "substring", searchPlaceholder: "Search language or code...", emptyMessage: "No languages match", maxWidth: "100%", className: "min-h-10 text-sm", renderHeader: (count) => (_jsxs("div", { className: "flex items-center justify-between px-3 pt-2 text-[11px] text-neutral-grey-50", children: [_jsx("span", { children: "All languages" }), _jsxs("span", { "data-testid": "translation-source-language-count", children: [count, " ", count === 1 ? "language" : "languages"] })] })), options: languages.map((lang) => ({
|
|
153
|
+
value: lang.code,
|
|
154
|
+
label: lang.name,
|
|
155
|
+
trailing: lang.name !== lang.code ? lang.code : undefined,
|
|
156
|
+
icon: (_jsx(LanguageIcon, { language: { languageCode: lang.code, name: lang.name }, flagClassName: "h-[15px] w-5 shrink-0", globeClassName: "h-4 w-5 shrink-0" })),
|
|
157
|
+
})) }), _jsx("span", { className: "text-xs text-neutral-grey-50", children: "Content is translated from this language." })] }), _jsxs("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden", children: [_jsxs("div", { className: "flex shrink-0 flex-col gap-2 border-b border-border-default p-6 pb-4", children: [_jsxs("div", { className: "flex items-baseline justify-between gap-2", children: [_jsx("span", { className: columnLabel, children: "Select target languages" }), _jsxs("span", { className: "text-xs text-neutral-grey-50", "data-testid": "target-language-count", children: [data.targetLanguages.length, " of ", targetLanguages.length, " ", "selected"] })] }), _jsxs("div", { className: "flex items-center gap-4", children: [_jsx(SearchInput, { className: "min-w-0 flex-1", size: "lg", value: filter, onChange: setFilter, placeholder: "Filter target languages...", "aria-label": "Filter target languages", testId: "target-language-filter" }), writableTargets.length > 1 && (_jsxs("label", { className: "flex shrink-0 cursor-pointer items-center gap-1.5 text-xs text-neutral-grey-100", children: [_jsx("input", { type: "checkbox", checked: allShownSelected, disabled: shownWritable.length === 0, ref: (input) => {
|
|
158
|
+
if (input)
|
|
159
|
+
input.indeterminate =
|
|
160
|
+
someShownSelected && !allShownSelected;
|
|
161
|
+
}, onChange: toggleAllShown, className: "h-3.5 w-3.5 rounded border-border-default accent-[var(--color-highlight-100)]", "data-testid": "select-all-languages-checkbox" }), isFiltering ? "Select all shown" : "Select all"] }))] })] }), _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto p-6 pt-4", children: languages.length === 0 ? (_jsx("div", { className: "flex flex-col gap-2", children: [...Array(6)].map((_, i) => (_jsxs("div", { className: "flex animate-pulse items-center gap-2.5 rounded-[8px] border border-border-default px-3 py-3", children: [_jsx("div", { className: "h-3.5 w-3.5 rounded bg-neutral-grey-10" }), _jsx("div", { className: "h-4 w-5 bg-neutral-grey-10" }), _jsx("div", { className: "h-3.5 w-32 rounded bg-neutral-grey-10" }), _jsx("div", { className: "ml-auto h-3 w-10 rounded bg-neutral-grey-5" })] }, i))) })) : shownTargets.length === 0 ? (_jsx("p", { className: "text-sm text-neutral-grey-50", "data-testid": "target-language-empty", children: "No languages match" })) : (_jsx("div", { className: "flex flex-col gap-2", children: shownTargets.map((lang) => {
|
|
162
|
+
const checked = selected.has(lang.code);
|
|
163
|
+
const readOnly = !lang.canWrite;
|
|
164
|
+
const row = (_jsxs("label", { "data-testid": `language-option-${lang.code}`, "data-readonly": readOnly || undefined, className: cn("flex items-center gap-2.5 rounded-[8px] border px-3 py-3 transition-colors", readOnly
|
|
165
|
+
? "cursor-not-allowed border-border-default opacity-50"
|
|
166
|
+
: checked
|
|
167
|
+
? "border-primary/30 bg-primary/5 cursor-pointer"
|
|
168
|
+
: "cursor-pointer border-border-default hover:bg-neutral-grey-5"), children: [_jsx("input", { type: "checkbox", checked: checked, disabled: readOnly, onChange: () => toggleLanguage(lang.code), className: "h-3.5 w-3.5 shrink-0 rounded border-border-default accent-[var(--color-highlight-100)] disabled:cursor-not-allowed", "data-testid": `language-checkbox-${lang.code}` }), _jsx(LanguageIcon, { language: { languageCode: lang.code, name: lang.name }, flagClassName: "h-[15px] w-5 shrink-0", globeClassName: "h-4 w-5 shrink-0" }), _jsx("span", { className: "min-w-0 flex-1 truncate text-sm text-neutral-grey-100", children: lang.name }), _jsx("span", { className: "shrink-0 font-mono text-[11px] text-neutral-grey-50", children: readOnly ? "no write access" : lang.code })] }, lang.code));
|
|
169
|
+
return readOnly ? (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: row }), _jsx(TooltipContent, { children: "You don't have write access to this language." })] }, lang.code)) : (row);
|
|
170
|
+
}) })) })] })] }) }));
|
|
214
171
|
}
|
package/dist/steps/types.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export type TranslationWizardData = {
|
|
|
51
51
|
/** User's tree selection with per-item subitem flags. Authoritative for the UI. */
|
|
52
52
|
selectionTreeItems?: ItemWithSubtree[];
|
|
53
53
|
/**
|
|
54
|
-
* The language every target is translated from, as chosen in the
|
|
54
|
+
* The language every target is translated from, as chosen in the Languages
|
|
55
55
|
* step. It wins over the status endpoint's per-target suggestion.
|
|
56
56
|
*/
|
|
57
57
|
sourceLanguage?: string;
|
|
@@ -11,6 +11,7 @@ export declare function canDeleteTranslationBatch(info: Pick<TranslationBatchInf
|
|
|
11
11
|
subjectId?: string;
|
|
12
12
|
isAdministrator?: boolean;
|
|
13
13
|
} | undefined): boolean;
|
|
14
|
+
export declare function batchSourceLanguage(metadata: string | null | undefined, jobs: TranslationJobRecord[] | undefined): string | undefined;
|
|
14
15
|
export declare function TranslationBatches(): React.JSX.Element;
|
|
15
16
|
export declare const TRANSLATION_BATCH_FILTERS_SIDEBAR_ID = "translation-batch-filters";
|
|
16
17
|
export declare function TranslationBatchFiltersSidebar(): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranslationBatches.d.ts","sourceRoot":"","sources":["../../src/translation-center/TranslationBatches.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EA4BL,KAAK,QAAQ,EAGd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAGL,oBAAoB,EACpB,oBAAoB,EAYrB,MAAM,gCAAgC,CAAC;AAsFxC,KAAK,YAAY,GAAG,KAAK,GAAG,aAAa,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;AAgI/E;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EACF,IAAI,CAAC,oBAAoB,EAAE,QAAQ,GAAG,sBAAsB,CAAC,GAAG,SAAS,EAC3E,IAAI,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,GAClE,OAAO,CAMT;
|
|
1
|
+
{"version":3,"file":"TranslationBatches.d.ts","sourceRoot":"","sources":["../../src/translation-center/TranslationBatches.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EA4BL,KAAK,QAAQ,EAGd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAGL,oBAAoB,EACpB,oBAAoB,EAYrB,MAAM,gCAAgC,CAAC;AAsFxC,KAAK,YAAY,GAAG,KAAK,GAAG,aAAa,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;AAgI/E;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EACF,IAAI,CAAC,oBAAoB,EAAE,QAAQ,GAAG,sBAAsB,CAAC,GAAG,SAAS,EAC3E,IAAI,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,GAClE,OAAO,CAMT;AAQD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACnC,IAAI,EAAE,oBAAoB,EAAE,GAAG,SAAS,GACvC,MAAM,GAAG,SAAS,CAUpB;AA2ID,wBAAgB,kBAAkB,sBAs3CjC;AAED,eAAO,MAAM,oCAAoC,8BAA8B,CAAC;AAEhF,wBAAgB,8BAA8B,sBAgb7C;AAED,UAAU,kBAAkB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,oBAAoB,EAAE,GAAG,SAAS,CAAC;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,UAAU,EAAE,CACV,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,KAClB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,UAAU,EAAE,CAAC,GAAG,EAAE,oBAAoB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,WAAW,EAAE,CACX,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,IAAI,EAAE,oBAAoB,EAAE,EAC5B,QAAQ,EAAE,MAAM,KACb,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAytBD,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,aAAa,EACb,IAAI,EACJ,SAAS,EACT,aAAa,EACb,SAAS,EACT,eAAe,EACf,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,QAAgB,EAChB,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,GACZ,EAAE,kBAAkB,qBA0YpB"}
|
|
@@ -126,6 +126,18 @@ export function canDeleteTranslationBatch(info, user) {
|
|
|
126
126
|
function isRetriableJob(job) {
|
|
127
127
|
return job?.status === "Error" && !!job.store;
|
|
128
128
|
}
|
|
129
|
+
export function batchSourceLanguage(metadata, jobs) {
|
|
130
|
+
let fromMetadata;
|
|
131
|
+
try {
|
|
132
|
+
fromMetadata = metadata ? JSON.parse(metadata).sourceLanguage : undefined;
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
fromMetadata = undefined;
|
|
136
|
+
}
|
|
137
|
+
return typeof fromMetadata === "string" && fromMetadata.trim()
|
|
138
|
+
? fromMetadata.trim()
|
|
139
|
+
: jobs?.find((job) => job.sourceLanguage)?.sourceLanguage;
|
|
140
|
+
}
|
|
129
141
|
function buildRetryJobRequest(job) {
|
|
130
142
|
if (!job.store || !job.itemId || !job.sourceLanguage || !job.targetLanguage)
|
|
131
143
|
return null;
|
|
@@ -1022,6 +1034,7 @@ export function TranslationBatches() {
|
|
|
1022
1034
|
const languages = languagesCsv
|
|
1023
1035
|
? languagesCsv.split(",")
|
|
1024
1036
|
: [];
|
|
1037
|
+
const sourceLanguage = batchSourceLanguage(info?.metadata, batchJobs[b.id]);
|
|
1025
1038
|
const errorJobs = info?.errorJobs ?? 0;
|
|
1026
1039
|
const anyError = errorJobs > 0;
|
|
1027
1040
|
const anyInProgress = isActiveBatchStatus(info?.status);
|
|
@@ -1037,7 +1050,7 @@ export function TranslationBatches() {
|
|
|
1037
1050
|
metaParts.push(_jsxs("span", { children: [itemsCount, " item", itemsCount !== 1 ? "s" : ""] }, "items"));
|
|
1038
1051
|
}
|
|
1039
1052
|
if (languages.length > 0) {
|
|
1040
|
-
metaParts.push(_jsxs("span", { title: languages.join(", "), children: [languages.length, " language", languages.length !== 1 ? "s" : ""] }, "langs"));
|
|
1053
|
+
metaParts.push(_jsxs("span", { title: languages.join(", "), children: [sourceLanguage && (_jsxs("span", { className: "font-mono tracking-tight", "data-testid": "batch-source-language", children: [sourceLanguage, " → "] })), languages.length, " language", languages.length !== 1 ? "s" : ""] }, "langs"));
|
|
1041
1054
|
}
|
|
1042
1055
|
if (info?.provider) {
|
|
1043
1056
|
metaParts.push(_jsx("span", { children: info.provider }, "prov"));
|