@parhelia/localization 0.4.12903 → 0.4.13030
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/LocalizeItemCommand.d.ts.map +1 -1
- package/dist/LocalizeItemCommand.js +1 -0
- package/dist/LocalizeItemDialog.js +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/services/translationService.d.ts +12 -0
- package/dist/services/translationService.d.ts.map +1 -1
- package/dist/services/translationService.js +7 -0
- package/dist/settings/ExcludedContentTypeDialog.d.ts.map +1 -1
- package/dist/settings/ExcludedContentTypeDialog.js +6 -4
- package/dist/settings/TranslationProviderDialog.d.ts.map +1 -1
- package/dist/settings/TranslationProviderDialog.js +31 -11
- package/dist/settings/TranslationServicesPanel.d.ts.map +1 -1
- package/dist/settings/TranslationServicesPanel.js +54 -42
- package/dist/steps/ItemSelectionTree.d.ts.map +1 -1
- package/dist/steps/ItemSelectionTree.js +11 -7
- package/dist/translation-center/TranslationBatches.d.ts +10 -1
- package/dist/translation-center/TranslationBatches.d.ts.map +1 -1
- package/dist/translation-center/TranslationBatches.js +94 -20
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalizeItemCommand.d.ts","sourceRoot":"","sources":["../src/LocalizeItemCommand.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EACP,cAAc,EACd,WAAW,EACX,eAAe,EACf,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAEL,uBAAuB,EACxB,MAAM,eAAe,CAAC;AAQvB,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG;IAClD,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GACpC,cAAc,CAAC,uBAAuB,CAAC,CAAC;AAC1C,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAEnE,wBAAsB,sBAAsB,CAAC,EAC3C,WAAW,EACX,UAAmC,EACnC,KAAK,GACN,EAAE;IACD,WAAW,EAAE,eAAe,CAAC;IAC7B,UAAU,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IAC3C,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,2CAiCA;AAED,eAAO,MAAM,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"LocalizeItemCommand.d.ts","sourceRoot":"","sources":["../src/LocalizeItemCommand.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EACP,cAAc,EACd,WAAW,EACX,eAAe,EACf,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAEL,uBAAuB,EACxB,MAAM,eAAe,CAAC;AAQvB,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG;IAClD,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GACpC,cAAc,CAAC,uBAAuB,CAAC,CAAC;AAC1C,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAEnE,wBAAsB,sBAAsB,CAAC,EAC3C,WAAW,EACX,UAAmC,EACnC,KAAK,GACN,EAAE;IACD,WAAW,EAAE,eAAe,CAAC;IAC7B,UAAU,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IAC3C,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,2CAiCA;AAED,eAAO,MAAM,mBAAmB,EAAE,mBAmCjC,CAAC"}
|
|
@@ -33,6 +33,7 @@ export async function openLocalizeItemDialog({ editContext, openDialog = editCon
|
|
|
33
33
|
}
|
|
34
34
|
export const localizeItemCommand = {
|
|
35
35
|
id: "localizeItem",
|
|
36
|
+
right: "parhelia.translate",
|
|
36
37
|
label: "Translate",
|
|
37
38
|
icon: _jsx(GlobeIcon, { strokeWidth: 1 }),
|
|
38
39
|
disabled: (context) => {
|
|
@@ -87,7 +87,7 @@ export function LocalizeItemDialog(props) {
|
|
|
87
87
|
useEffect(() => {
|
|
88
88
|
beforeNextCallbackRef.current = beforeNextCallback;
|
|
89
89
|
}, [beforeNextCallback]);
|
|
90
|
-
// Switch step helper that clears callbacks
|
|
90
|
+
// Switch step helper that clears callbacks
|
|
91
91
|
const switchStep = useCallback((index) => {
|
|
92
92
|
beforeNextCallbackRef.current = null; // Clear callback when switching steps
|
|
93
93
|
setBeforeNextCallback(null);
|
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;;;;;;;;;;;;;;CAuB7C,CAAC;AAEF,QAAA,MAAM,4CAA4C;;;;;;;;CAiBjD,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,CA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iB,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
|
@@ -222,14 +222,16 @@ export function configureLocalization(configuration, options) {
|
|
|
222
222
|
}
|
|
223
223
|
else {
|
|
224
224
|
const groups = configuration.settings.groups;
|
|
225
|
-
|
|
225
|
+
// Localization sits above System (or above About when there is no System group).
|
|
226
|
+
const systemIndex = groups.findIndex((g) => g.title === "System");
|
|
227
|
+
const insertIndex = systemIndex >= 0 ? systemIndex : groups.findIndex((g) => g.title === "About");
|
|
226
228
|
const localizationGroup = {
|
|
227
229
|
title: "Localization",
|
|
228
230
|
icon: _jsx(LanguagesIcon, { strokeWidth: 1 }),
|
|
229
231
|
panels: [translationServicesPanel],
|
|
230
232
|
};
|
|
231
|
-
if (
|
|
232
|
-
groups.splice(
|
|
233
|
+
if (insertIndex >= 0) {
|
|
234
|
+
groups.splice(insertIndex, 0, localizationGroup);
|
|
233
235
|
}
|
|
234
236
|
else {
|
|
235
237
|
groups.push(localizationGroup);
|
|
@@ -82,6 +82,8 @@ export type TranslationBatchInfo = {
|
|
|
82
82
|
startedAtUtc?: string;
|
|
83
83
|
completedAtUtc?: string;
|
|
84
84
|
initiatedByUser?: string;
|
|
85
|
+
/** The initiator's account id; the name where names are ids (the classic CM). */
|
|
86
|
+
initiatedBySubjectId?: string;
|
|
85
87
|
initiatorSessionId?: string;
|
|
86
88
|
provider?: string;
|
|
87
89
|
status?: string;
|
|
@@ -122,6 +124,16 @@ export type AbortTranslationResponse = {
|
|
|
122
124
|
};
|
|
123
125
|
export declare function abortJob(id: string): Promise<import("@parhelia/core").ExecutionResult<AbortTranslationResponse>>;
|
|
124
126
|
export declare function abortBatch(id: string): Promise<import("@parhelia/core").ExecutionResult<AbortTranslationResponse>>;
|
|
127
|
+
export type DeleteTranslationBatchResponse = {
|
|
128
|
+
success: boolean;
|
|
129
|
+
batchId: string;
|
|
130
|
+
deletedJobs: number;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Deletes a batch that has stopped, with its jobs. A running batch is refused
|
|
134
|
+
* (409): abort it first. Translations already written to content stay.
|
|
135
|
+
*/
|
|
136
|
+
export declare function deleteBatch(id: string): Promise<import("@parhelia/core").ExecutionResult<DeleteTranslationBatchResponse>>;
|
|
125
137
|
export declare function subscribeToBatch(batchId: string, sessionId: string): Promise<import("@parhelia/core").ExecutionResult<{
|
|
126
138
|
success: boolean;
|
|
127
139
|
message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translationService.d.ts","sourceRoot":"","sources":["../../src/services/translationService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAGzD,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE,wBAAgB,wBAAwB,CAAC,UAAU,EAAE;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,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ACzB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,+BAA+B,EAAE,CAAC;IAC3C,OAAO,EAAE,+BAA+B,EAAE,CAAC;CAC5C,CAAC;AAEF,wBAAsB,qBAAqB,CAAC,EAC1C,SAAS,EACT,aAAa,EACb,QAAQ,EACR,IAAI,GACL,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,+BAA+B,EAAE,CAAC;CACzC,oFAKA"}
|
|
1
|
+
{"version":3,"file":"translationService.d.ts","sourceRoot":"","sources":["../../src/services/translationService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAGzD,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE,wBAAgB,wBAAwB,C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ACvB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,+BAA+B,EAAE,CAAC;IAC3C,OAAO,EAAE,+BAA+B,EAAE,CAAC;CAC5C,CAAC;AAEF,wBAAsB,qBAAqB,CAAC,EAC1C,SAAS,EACT,aAAa,EACb,QAAQ,EACR,IAAI,GACL,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,+BAA+B,EAAE,CAAC;CACzC,oFAKA"}
|
|
@@ -84,6 +84,13 @@ export async function abortJob(id) {
|
|
|
84
84
|
export async function abortBatch(id) {
|
|
85
85
|
return await post("/parhelia/translation/abortBatch", { id });
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Deletes a batch that has stopped, with its jobs. A running batch is refused
|
|
89
|
+
* (409): abort it first. Translations already written to content stay.
|
|
90
|
+
*/
|
|
91
|
+
export async function deleteBatch(id) {
|
|
92
|
+
return await post("/parhelia/translation/deleteBatch", { id });
|
|
93
|
+
}
|
|
87
94
|
export async function subscribeToBatch(batchId, sessionId) {
|
|
88
95
|
return await post("/parhelia/translation/subscribeToBatch", { batchId, sessionId });
|
|
89
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExcludedContentTypeDialog.d.ts","sourceRoot":"","sources":["../../src/settings/ExcludedContentTypeDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExcludedContentTypeDialog.d.ts","sourceRoot":"","sources":["../../src/settings/ExcludedContentTypeDialog.tsx"],"names":[],"mappings":"AAeA;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,IAAI,EACJ,MAAM,EACN,KAAK,EACL,YAAY,EACZ,MAAM,GACP,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD,+BAuGA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { FolderTree, Loader2 } from "lucide-react";
|
|
4
|
-
import { Button, ContentStoreSelect, ContentTree, Dialog, DialogContent, DialogFooter, FormField, StyledDialogTitle, useContentModel, } from "@parhelia/core";
|
|
4
|
+
import { Button, ContentStoreSelect, ContentTree, Dialog, DialogContent, DialogFooter, FormField, StyledDialogTitle, settingsText, useContentModel, } from "@parhelia/core";
|
|
5
5
|
/**
|
|
6
6
|
* Adds a content type to the types translation skips: the person picks the content store, then an item of that type in
|
|
7
7
|
* the store's content tree (every CMS has items; not every CMS lists its types).
|
|
@@ -18,10 +18,12 @@ export function ExcludedContentTypeDialog({ open, saving, error, onOpenChange, o
|
|
|
18
18
|
setStore((current) => current || (stores.length === 1 ? stores[0].id : ""));
|
|
19
19
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
20
20
|
}, [open]);
|
|
21
|
-
const roots = model?.roots
|
|
21
|
+
const roots = model?.roots
|
|
22
|
+
.filter((root) => root.storeId === store && root.kind === "content")
|
|
23
|
+
.map((root) => root.id) ?? [];
|
|
22
24
|
const language = stores.find((candidate) => candidate.id === store)?.defaultLocale ?? "en";
|
|
23
|
-
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "max-w-xl gap-0 p-0", "data-testid": "translation-excluded-type-dialog", children: [_jsx(StyledDialogTitle, { icon: _jsx(FolderTree, { strokeWidth: 1 }), title: "Exclude a content type", subtitle: "Pick an item: its content type, and every type based on it, is not translated." }), _jsxs("div", { className: "
|
|
25
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "max-w-xl gap-0 p-0", "data-testid": "translation-excluded-type-dialog", children: [_jsx(StyledDialogTitle, { icon: _jsx(FolderTree, { strokeWidth: 1 }), title: "Exclude a content type", subtitle: "Pick an item: its content type, and every type based on it, is not translated." }), _jsxs("div", { className: "flex flex-col gap-4 px-8 py-6", children: [_jsx(FormField, { label: "Content store", children: _jsx(ContentStoreSelect, { value: store, onValueChange: (value) => {
|
|
24
26
|
setStore(value);
|
|
25
27
|
setItemId("");
|
|
26
|
-
}, stores: stores, placeholder: "Select a content store", maxWidth: "100%", "data-testid": "translation-excluded-type-store" }) }), store && roots.length === 0 && (_jsx("p", { className:
|
|
28
|
+
}, stores: stores, placeholder: "Select a content store", maxWidth: "100%", "data-testid": "translation-excluded-type-store" }) }), store && roots.length === 0 && (_jsx("p", { className: settingsText.help, children: "This store shows no content tree to pick from." })), store && roots.length > 0 && (_jsx("div", { className: "border-border-default h-72 overflow-auto rounded-md border", "data-testid": "translation-excluded-type-tree", children: _jsx(ContentTree, { database: store, language: language, rootItemIds: roots, hideRootNodes: false, selectionMode: "single", selectedItemIds: itemId ? [itemId] : [], onSelectionChange: (items) => setItemId(items[0]?.id ?? "") }, JSON.stringify([store, language])) })), error && (_jsx("p", { className: settingsText.error, role: "alert", "data-testid": "translation-excluded-type-error", children: error }))] }), _jsxs(DialogFooter, { className: "border-border-default gap-2 border-t pt-5 sm:gap-3", children: [_jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), disabled: saving, children: "Cancel" }), _jsxs(Button, { onClick: () => onPick(store, itemId), disabled: saving || !store || !itemId, "data-testid": "translation-excluded-type-add", children: [saving && (_jsx(Loader2, { className: "h-4 w-4 animate-spin", strokeWidth: 1 })), "Add its content type"] })] })] }) }));
|
|
27
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranslationProviderDialog.d.ts","sourceRoot":"","sources":["../../src/settings/TranslationProviderDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TranslationProviderDialog.d.ts","sourceRoot":"","sources":["../../src/settings/TranslationProviderDialog.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,mBAAmB,EAEpB,MAAM,wCAAwC,CAAC;AAKhD,qHAAqH;AACrH,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAepC;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,mBAAmB,EAC7B,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,GAClC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAc/B;AAkKD,8GAA8G;AAC9G,wBAAgB,yBAAyB,CAAC,EACxC,QAAQ,EACR,MAAM,EACN,KAAK,EACL,YAAY,EACZ,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC;CACzD,+BA6GA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useState } from "react";
|
|
3
3
|
import { Languages, Loader2 } from "lucide-react";
|
|
4
|
-
import { Button, Checkbox, Dialog, DialogContent, DialogFooter, FormField, Input, Select, StyledDialogTitle, Textarea, } from "@parhelia/core";
|
|
4
|
+
import { Button, Checkbox, Dialog, DialogContent, DialogFooter, FormField, Input, Select, StyledDialogTitle, Textarea, cn, settingsText, } from "@parhelia/core";
|
|
5
5
|
/** The select value of "no model chosen" (the provider then uses the default agent profile's model). */
|
|
6
6
|
const NO_MODEL = "translation-provider-default-model";
|
|
7
7
|
const splitList = (value) => (value ?? "")
|
|
@@ -46,24 +46,37 @@ function FieldInput({ field, value, secretState, onChange, onRemoveSecret, }) {
|
|
|
46
46
|
case "checkbox":
|
|
47
47
|
return (_jsx(Checkbox, { checked: value === "1", onCheckedChange: (checked) => onChange(checked === true ? "1" : ""), "data-testid": testId }));
|
|
48
48
|
case "choice":
|
|
49
|
-
return (_jsx(Select, { value: value, onValueChange: onChange, options: field.options.map((option) => ({
|
|
49
|
+
return (_jsx(Select, { value: value, onValueChange: onChange, options: field.options.map((option) => ({
|
|
50
|
+
value: option.value,
|
|
51
|
+
label: option.label,
|
|
52
|
+
})), placeholder: field.defaultValue ?? "Not set", maxWidth: "100%", "data-testid": testId }));
|
|
50
53
|
case "modelReference":
|
|
51
54
|
return (_jsx(Select, { value: value || NO_MODEL, onValueChange: (next) => onChange(next === NO_MODEL ? "" : next), options: [
|
|
52
|
-
{
|
|
53
|
-
|
|
55
|
+
{
|
|
56
|
+
value: NO_MODEL,
|
|
57
|
+
label: "Default (the model of the default agent profile)",
|
|
58
|
+
},
|
|
59
|
+
...field.options.map((option) => ({
|
|
60
|
+
value: option.value,
|
|
61
|
+
label: option.label,
|
|
62
|
+
})),
|
|
54
63
|
], searchable: true, maxWidth: "100%", "data-testid": testId }));
|
|
55
64
|
case "languages": {
|
|
56
65
|
const selected = new Set(splitList(value).map((code) => code.toLowerCase()));
|
|
57
66
|
const toggle = (code, on) => {
|
|
58
|
-
const codes = field.options
|
|
67
|
+
const codes = field.options
|
|
68
|
+
.map((option) => option.value)
|
|
69
|
+
.filter((option) => option === code ? on : selected.has(option.toLowerCase()));
|
|
59
70
|
onChange(codes.join("|"));
|
|
60
71
|
};
|
|
61
72
|
if (field.options.length === 0)
|
|
62
|
-
return _jsx("p", { className:
|
|
63
|
-
return (_jsx("div", { className: "grid gap-1.5 sm:grid-cols-2", "data-testid": testId, children: field.options.map((option) => (_jsxs("span", { className: "flex items-center gap-2
|
|
73
|
+
return (_jsx("p", { className: settingsText.meta, children: "The mounted content has no languages." }));
|
|
74
|
+
return (_jsx("div", { className: "grid gap-1.5 sm:grid-cols-2", "data-testid": testId, children: field.options.map((option) => (_jsxs("span", { className: cn("flex items-center gap-2", settingsText.body), children: [_jsx(Checkbox, { checked: selected.has(option.value.toLowerCase()), onCheckedChange: (checked) => toggle(option.value, checked === true), "aria-label": option.label, "data-testid": `${testId}-${option.value}` }), _jsx("span", { children: option.label }), option.label !== option.value && (_jsx("span", { className: cn("text-neutral-grey-50", settingsText.mono), children: option.value }))] }, option.value))) }));
|
|
64
75
|
}
|
|
65
76
|
case "secret":
|
|
66
|
-
return (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Input, { type: "password", autoComplete: "new-password", value: value, onChange: (event) => onChange(event.target.value), placeholder: secretState === "set"
|
|
77
|
+
return (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Input, { type: "password", autoComplete: "new-password", value: value, onChange: (event) => onChange(event.target.value), placeholder: secretState === "set"
|
|
78
|
+
? "Set. Type a new value to replace it."
|
|
79
|
+
: "Not set", "data-testid": testId }), secretState === "set" && value.length === 0 && (_jsx(Button, { variant: "outline", size: "sm", onClick: onRemoveSecret, "data-testid": `${testId}-remove`, children: "Remove" }))] }));
|
|
67
80
|
default:
|
|
68
81
|
return (_jsx(Input, { value: value, onChange: (event) => onChange(event.target.value), placeholder: field.defaultValue ?? undefined, "data-testid": testId }));
|
|
69
82
|
}
|
|
@@ -71,15 +84,22 @@ function FieldInput({ field, value, secretState, onChange, onRemoveSecret, }) {
|
|
|
71
84
|
/** Edits one translation provider's settings with the fields its service declares (on every host and CMS). */
|
|
72
85
|
export function TranslationProviderDialog({ provider, saving, error, onOpenChange, onSave, }) {
|
|
73
86
|
// The panel keys this dialog by provider, so a fresh form starts from the provider it opens for.
|
|
74
|
-
const [draft, setDraft] = useState(() =>
|
|
87
|
+
const [draft, setDraft] = useState(() => provider ? initialDraft(provider) : {});
|
|
75
88
|
const [removedSecrets, setRemovedSecrets] = useState(() => new Set());
|
|
76
89
|
const changes = useMemo(() => (provider ? providerChanges(provider, draft, removedSecrets) : {}), [provider, draft, removedSecrets]);
|
|
77
90
|
const dirty = Object.keys(changes).length > 0;
|
|
78
|
-
return (_jsx(Dialog, { open: provider !== null, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "max-w-2xl gap-0 p-0", "data-testid": "translation-provider-dialog", children: [_jsx(StyledDialogTitle, { icon: _jsx(Languages, { strokeWidth: 1 }), title: provider ? `Settings: ${provider.displayName}` : "Settings", subtitle: provider
|
|
91
|
+
return (_jsx(Dialog, { open: provider !== null, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "max-w-2xl gap-0 p-0", "data-testid": "translation-provider-dialog", children: [_jsx(StyledDialogTitle, { icon: _jsx(Languages, { strokeWidth: 1 }), title: provider ? `Settings: ${provider.displayName}` : "Settings", subtitle: provider
|
|
92
|
+
? `Translation service "${provider.serviceName}".`
|
|
93
|
+
: undefined }), _jsxs("div", { className: "flex max-h-[60vh] flex-col gap-4 overflow-auto px-8 py-6", children: [provider?.fields.map((field) => {
|
|
94
|
+
const label = field.required ? `${field.label} *` : field.label;
|
|
95
|
+
const input = (_jsx(FieldInput, { field: field, value: draft[field.name] ?? "", secretState: field.type !== "secret"
|
|
79
96
|
? "unset"
|
|
80
97
|
: removedSecrets.has(field.name)
|
|
81
98
|
? "removed"
|
|
82
99
|
: field.isSet
|
|
83
100
|
? "set"
|
|
84
|
-
: "unset", onChange: (value) => setDraft((current) => ({ ...current, [field.name]: value })), onRemoveSecret: () => setRemovedSecrets((current) => new Set(current).add(field.name)) })
|
|
101
|
+
: "unset", onChange: (value) => setDraft((current) => ({ ...current, [field.name]: value })), onRemoveSecret: () => setRemovedSecrets((current) => new Set(current).add(field.name)) }));
|
|
102
|
+
// A group of checkboxes is several controls: a <label> around it would send every click to the first one.
|
|
103
|
+
return field.type === "languages" ? (_jsxs("fieldset", { className: "flex flex-col gap-1.5", children: [_jsx("legend", { className: cn("mb-1.5", settingsText.label), children: label }), input, field.help && (_jsx("p", { className: settingsText.help, children: field.help }))] }, field.name)) : (_jsx(FormField, { label: label, hint: field.help ?? undefined, children: input }, field.name));
|
|
104
|
+
}), error && (_jsx("p", { className: settingsText.error, role: "alert", "data-testid": "translation-provider-error", children: error }))] }), _jsxs(DialogFooter, { className: "border-border-default gap-2 border-t pt-5 sm:gap-3", children: [_jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), disabled: saving, children: "Cancel" }), _jsxs(Button, { onClick: () => onSave(changes), disabled: saving || !dirty, "data-testid": "translation-provider-save", children: [saving && (_jsx(Loader2, { className: "h-4 w-4 animate-spin", strokeWidth: 1 })), "Save"] })] })] }) }));
|
|
85
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranslationServicesPanel.d.ts","sourceRoot":"","sources":["../../src/settings/TranslationServicesPanel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TranslationServicesPanel.d.ts","sourceRoot":"","sources":["../../src/settings/TranslationServicesPanel.tsx"],"names":[],"mappings":"AAmCA,OAAO,EAEL,KAAK,sBAAsB,EAI3B,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC/B,MAAM,wCAAwC,CAAC;AAOhD,4DAA4D;AAC5D,KAAK,aAAa,GAAG;IACnB,4BAA4B,EAAE,MAAM,CAAC;IACrC,yBAAyB,EAAE,MAAM,CAAC;IAClC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,oBAAoB,EAAE,sBAAsB,EAAE,CAAC;CAChD,CAAC;AAqBF,+DAA+D;AAC/D,wBAAgB,eAAe,CAC7B,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,yBAAyB,GAC/B,sBAAsB,CAqBxB;AAuED;;;GAGG;AACH,wBAAgB,wBAAwB,gCAuevC;eAEc,wBAAwB"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
3
|
-
import { Pencil, Plus, X } from "lucide-react";
|
|
4
|
-
import {
|
|
2
|
+
import { useCallback, useEffect, useMemo, useState, } from "react";
|
|
3
|
+
import { AlertCircle, Languages, Pencil, Plus, Save, SlidersHorizontal, X, } from "lucide-react";
|
|
4
|
+
import { Alert, AlertDescription, Badge, Button, DeleteButton, Input, LoadingState, SettingsCard, SettingsEmptyState, SettingsList, SettingsListItem, SettingsPanelLayout, SettingsRow, SimpleIconButton, Switch, settingsText, useEditContext, } from "@parhelia/core";
|
|
5
5
|
import { translationSettingsService, } from "../services/translationSettingsService";
|
|
6
6
|
import { TranslationProviderDialog } from "./TranslationProviderDialog";
|
|
7
7
|
import { ExcludedContentTypeDialog } from "./ExcludedContentTypeDialog";
|
|
8
|
-
const errorText = (error, fallback) =>
|
|
8
|
+
const errorText = (error, fallback) => error instanceof Error ? error.message : fallback;
|
|
9
9
|
const draftOf = (values) => ({
|
|
10
10
|
maxConcurrentTranslationJobs: String(values.maxConcurrentTranslationJobs),
|
|
11
11
|
maxConcurrentJobsPerBatch: String(values.maxConcurrentJobsPerBatch),
|
|
@@ -14,17 +14,19 @@ const draftOf = (values) => ({
|
|
|
14
14
|
excludedContentTypes: values.excludedContentTypes,
|
|
15
15
|
});
|
|
16
16
|
/** An excluded type by its name; a key no mounted store knows any more by the key, so it can still be removed. */
|
|
17
|
-
const typeLabel = (type) =>
|
|
17
|
+
const typeLabel = (type) => type.known ? type.name : `Unknown type ${type.key}`;
|
|
18
18
|
const keysOf = (types) => types.map((type) => type.key);
|
|
19
19
|
const sameKeys = (a, b) => keysOf(a).join("\n") === keysOf(b).join("\n");
|
|
20
20
|
/** What a save sends: only the settings the person changed. */
|
|
21
21
|
export function settingsChanges(draft, saved) {
|
|
22
22
|
const set = {};
|
|
23
23
|
const jobs = Number(draft.maxConcurrentTranslationJobs);
|
|
24
|
-
if (draft.maxConcurrentTranslationJobs.trim() !== "" &&
|
|
24
|
+
if (draft.maxConcurrentTranslationJobs.trim() !== "" &&
|
|
25
|
+
jobs !== saved.maxConcurrentTranslationJobs)
|
|
25
26
|
set.maxConcurrentTranslationJobs = jobs;
|
|
26
27
|
const perBatch = Number(draft.maxConcurrentJobsPerBatch);
|
|
27
|
-
if (draft.maxConcurrentJobsPerBatch.trim() !== "" &&
|
|
28
|
+
if (draft.maxConcurrentJobsPerBatch.trim() !== "" &&
|
|
29
|
+
perBatch !== saved.maxConcurrentJobsPerBatch)
|
|
28
30
|
set.maxConcurrentJobsPerBatch = perBatch;
|
|
29
31
|
if (draft.skipSharedFields !== saved.skipSharedFields)
|
|
30
32
|
set.skipSharedFields = draft.skipSharedFields;
|
|
@@ -34,20 +36,14 @@ export function settingsChanges(draft, saved) {
|
|
|
34
36
|
set.excludedContentTypes = keysOf(draft.excludedContentTypes);
|
|
35
37
|
return set;
|
|
36
38
|
}
|
|
37
|
-
function SectionHeading({ title, hint }) {
|
|
38
|
-
return (_jsxs("div", { children: [_jsx("h2", { className: "text-base font-medium", children: title }), hint && _jsx("p", { className: "text-neutral-grey-50 max-w-2xl text-xs", children: hint })] }));
|
|
39
|
-
}
|
|
40
39
|
/**
|
|
41
|
-
*
|
|
42
|
-
* comparing values here
|
|
40
|
+
* One translation setting as a settings row. Whether the customer set it comes from the server (`customized`), never
|
|
41
|
+
* from comparing values here: a customized setting shows "Customized" and a reset, which removes the customer's value so
|
|
42
|
+
* the setting follows the shipped default again (the way System Settings shows its root settings).
|
|
43
43
|
*/
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return (_jsxs("span", { className: "flex items-center gap-2 text-xs", "data-testid": `translation-setting-state-${name}`, children: [_jsx("span", { className: "text-feedback-blue", children: "Customized" }), _jsx("button", { type: "button", className: "text-neutral-grey-50 hover:text-neutral-grey-100 underline disabled:opacity-50", onClick: () => onReset(name), disabled: busy, "data-testid": `translation-setting-reset-${name}`, children: "Reset to default" })] }));
|
|
48
|
-
}
|
|
49
|
-
function SettingRow({ label, hint, state, children }) {
|
|
50
|
-
return (_jsxs("div", { className: "grid items-start gap-2 md:grid-cols-[1fr_12rem]", children: [_jsx(FormField, { label: label, hint: hint, children: children }), _jsx("div", { className: "md:pt-7", children: state })] }));
|
|
44
|
+
function TranslationSettingRow({ name, page, busy, onReset, label, htmlFor, hint, toggle, control, children, }) {
|
|
45
|
+
const customized = page.customized.includes(name);
|
|
46
|
+
return (_jsx(SettingsRow, { "data-testid": `translation-setting-state-${name}`, "data-customized": customized ? "true" : "false", htmlFor: htmlFor, label: _jsxs("span", { className: "flex items-center gap-2", children: [label, customized && _jsx("span", { className: settingsText.meta, children: "Customized" })] }), description: hint || customized ? (_jsxs(_Fragment, { children: [hint, customized && (_jsx("div", { children: _jsx(Button, { variant: "link", size: "xxs", className: "h-auto px-0 text-xs", onClick: () => onReset(name), disabled: busy, "data-testid": `translation-setting-reset-${name}`, children: "Reset to default" }) }))] })) : undefined, toggle: toggle, control: control, children: children }));
|
|
51
47
|
}
|
|
52
48
|
/**
|
|
53
49
|
* Settings → Localization → Translation Services, on every host and every CMS: which translation services are set up
|
|
@@ -76,7 +72,8 @@ export function TranslationServicesPanel() {
|
|
|
76
72
|
translationSettingsService
|
|
77
73
|
.get()
|
|
78
74
|
.then((next) => !cancelled && apply(next))
|
|
79
|
-
.catch((error) => !cancelled &&
|
|
75
|
+
.catch((error) => !cancelled &&
|
|
76
|
+
setLoadError(errorText(error, "Failed to load the translation settings")));
|
|
80
77
|
return () => {
|
|
81
78
|
cancelled = true;
|
|
82
79
|
};
|
|
@@ -84,9 +81,9 @@ export function TranslationServicesPanel() {
|
|
|
84
81
|
const changes = useMemo(() => (page && draft ? settingsChanges(draft, page.settings) : {}), [page, draft]);
|
|
85
82
|
const dirty = Object.keys(changes).length > 0;
|
|
86
83
|
if (loadError)
|
|
87
|
-
return (_jsx(SettingsPanelLayout, { testId: "translation-services-panel", children:
|
|
84
|
+
return (_jsx(SettingsPanelLayout, { testId: "translation-services-panel", children: _jsxs(Alert, { variant: "destructive", children: [_jsx(AlertCircle, { className: "h-4 w-4", strokeWidth: 1 }), _jsx(AlertDescription, { children: loadError })] }) }));
|
|
88
85
|
if (!page || !draft)
|
|
89
|
-
return _jsx(LoadingState, { message: "Loading translation settings" });
|
|
86
|
+
return (_jsx(SettingsPanelLayout, { testId: "translation-services-panel", children: _jsx(SettingsCard, { icon: _jsx(Languages, { strokeWidth: 1 }), title: "Translation providers", description: "The translation services of this installation. People can pick a service for translation once it is set up.", children: _jsx(LoadingState, { variant: "inline", message: "Loading translation settings" }) }) }));
|
|
90
87
|
const createProvider = async (provider) => {
|
|
91
88
|
setBusyProvider(provider.serviceName);
|
|
92
89
|
setProviderError(null);
|
|
@@ -165,8 +162,12 @@ export function TranslationServicesPanel() {
|
|
|
165
162
|
setTypeError(null);
|
|
166
163
|
try {
|
|
167
164
|
const type = await translationSettingsService.contentTypeOf(store, itemId);
|
|
168
|
-
setDraft((current) => current &&
|
|
169
|
-
|
|
165
|
+
setDraft((current) => current &&
|
|
166
|
+
!current.excludedContentTypes.some((existing) => existing.key === type.key)
|
|
167
|
+
? {
|
|
168
|
+
...current,
|
|
169
|
+
excludedContentTypes: [...current.excludedContentTypes, type],
|
|
170
|
+
}
|
|
170
171
|
: current);
|
|
171
172
|
setTypeDialog(false);
|
|
172
173
|
}
|
|
@@ -180,23 +181,34 @@ export function TranslationServicesPanel() {
|
|
|
180
181
|
const services = page.providers;
|
|
181
182
|
const configuredCount = services.filter((service) => service.configured).length;
|
|
182
183
|
const languageName = (code) => page.languages.find((language) => language.code === code)?.name ?? code;
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
184
|
+
const settingRow = {
|
|
185
|
+
page,
|
|
186
|
+
busy: savingSettings,
|
|
187
|
+
onReset: (reset) => void saveSettings({}, [reset]),
|
|
188
|
+
};
|
|
189
|
+
const removeType = (key) => setDraft({
|
|
190
|
+
...draft,
|
|
191
|
+
excludedContentTypes: draft.excludedContentTypes.filter((existing) => existing.key !== key),
|
|
192
|
+
});
|
|
193
|
+
return (_jsxs(SettingsPanelLayout, { testId: "translation-services-panel", children: [_jsx(SettingsCard, { icon: _jsx(Languages, { strokeWidth: 1 }), title: `Translation providers (${configuredCount} of ${services.length} set up)`, description: "The translation services of this installation. People can pick a service for translation once it is set up.", children: _jsxs("div", { className: "flex flex-col gap-4", "data-testid": "translation-services-providers", children: [providerError && (_jsxs(Alert, { variant: "destructive", "data-testid": "translation-services-error", children: [_jsx(AlertCircle, { className: "h-4 w-4", strokeWidth: 1 }), _jsx(AlertDescription, { children: providerError })] })), services.length === 0 ? (_jsx(SettingsEmptyState, { icon: Languages, title: "This installation has no translation services." })) : (_jsx(SettingsList, { children: services.map((service) => {
|
|
194
|
+
const languages = service.fields.find((field) => field.type === "languages")?.value;
|
|
195
|
+
return (_jsx(SettingsListItem, { "data-testid": "translation-provider", "data-service-name": service.serviceName, icon: _jsx(Languages, { strokeWidth: 1 }), title: service.displayName, badges: service.displayName !== service.serviceName && (_jsx("span", { className: settingsText.meta, children: service.serviceName })), meta: _jsx("div", { className: "truncate", "data-testid": "translation-provider-summary", children: !service.configured
|
|
196
|
+
? "Not set up"
|
|
197
|
+
: languages
|
|
198
|
+
? `Languages: ${languages.split("|").map(languageName).join(", ")}`
|
|
199
|
+
: "Set up" }), actions: service.configured ? (_jsxs(_Fragment, { children: [_jsx(SimpleIconButton, { label: `Edit the settings of ${service.displayName}`, icon: _jsx(Pencil, { className: "size-4", strokeWidth: 1 }), className: "size-7 p-0", onClick: () => {
|
|
200
|
+
setDialogError(null);
|
|
201
|
+
setEditing(service);
|
|
202
|
+
}, disabled: busyProvider !== null, "data-testid": "translation-provider-edit" }), _jsx(DeleteButton, { label: `Delete the settings of ${service.displayName}`, onClick: () => deleteProvider(service), disabled: busyProvider !== null, "data-testid": "translation-provider-delete" })] })) : (_jsxs(Button, { size: "sm", variant: "outline", onClick: () => void createProvider(service), disabled: busyProvider !== null, "data-testid": "translation-provider-create", children: [_jsx(Plus, { className: "h-4 w-4", strokeWidth: 1 }), "Set up"] })) }, service.serviceName));
|
|
203
|
+
}) }))] }) }), _jsx(SettingsCard, { icon: _jsx(SlidersHorizontal, { strokeWidth: 1 }), title: "Translation settings", description: "How translation runs, for every translation service.", children: _jsxs("div", { "data-testid": "translation-settings-section", children: [_jsxs("div", { children: [_jsx(TranslationSettingRow, { ...settingRow, name: "maxConcurrentTranslationJobs", label: "Jobs at once", htmlFor: "translation-setting-maxConcurrentTranslationJobs", hint: `How many translation jobs run at the same time. Default: ${page.defaults.maxConcurrentTranslationJobs}.`, control: _jsx(Input, { id: "translation-setting-maxConcurrentTranslationJobs", type: "number", min: 1, className: "w-28", value: draft.maxConcurrentTranslationJobs, onChange: (event) => setDraft({
|
|
204
|
+
...draft,
|
|
205
|
+
maxConcurrentTranslationJobs: event.target.value,
|
|
206
|
+
}), "data-testid": "translation-setting-maxConcurrentTranslationJobs" }) }), _jsx(TranslationSettingRow, { ...settingRow, name: "maxConcurrentJobsPerBatch", label: "Jobs at once per batch", htmlFor: "translation-setting-maxConcurrentJobsPerBatch", hint: `How many jobs of one batch run at the same time; 0 sets no limit. Default: ${page.defaults.maxConcurrentJobsPerBatch}.`, control: _jsx(Input, { id: "translation-setting-maxConcurrentJobsPerBatch", type: "number", min: 0, className: "w-28", value: draft.maxConcurrentJobsPerBatch, onChange: (event) => setDraft({
|
|
207
|
+
...draft,
|
|
208
|
+
maxConcurrentJobsPerBatch: event.target.value,
|
|
209
|
+
}), "data-testid": "translation-setting-maxConcurrentJobsPerBatch" }) }), _jsx(TranslationSettingRow, { ...settingRow, name: "skipSharedFields", label: "Skip fields that are the same in all languages", htmlFor: "translation-setting-skipSharedFields", toggle: _jsx(Switch, { id: "translation-setting-skipSharedFields", checked: draft.skipSharedFields, onCheckedChange: (checked) => setDraft({ ...draft, skipSharedFields: checked }), "data-testid": "translation-setting-skipSharedFields" }) }), _jsx(TranslationSettingRow, { ...settingRow, name: "displayCosts", label: "Show translation costs", htmlFor: "translation-setting-displayCosts", toggle: _jsx(Switch, { id: "translation-setting-displayCosts", checked: draft.displayCosts, onCheckedChange: (checked) => setDraft({ ...draft, displayCosts: checked }), "data-testid": "translation-setting-displayCosts" }) }), _jsxs(TranslationSettingRow, { ...settingRow, name: "excludedContentTypes", label: "Content types that are not translated", hint: "Items of these types, and of types based on them, are left out of translation.", control: _jsxs(Button, { size: "sm", variant: "outline", onClick: () => {
|
|
210
|
+
setTypeError(null);
|
|
211
|
+
setTypeDialog(true);
|
|
212
|
+
}, "data-testid": "translation-excluded-type-open", children: [_jsx(Plus, { className: "h-4 w-4", strokeWidth: 1 }), "Add content type"] }), children: [draft.excludedContentTypes.length === 0 && (_jsx("p", { className: settingsText.meta, children: "None: every content type is translated." })), _jsx("ul", { className: "flex flex-wrap gap-1.5 empty:hidden", "data-testid": "translation-setting-excludedContentTypes", children: draft.excludedContentTypes.map((type) => (_jsx("li", { className: "contents", children: _jsxs(Badge, { variant: type.known ? "secondary" : "warning", className: "pr-1", "data-testid": "translation-excluded-type", "data-type-key": type.key, "data-known": type.known, children: [typeLabel(type), _jsx("button", { type: "button", "aria-label": `Translate ${typeLabel(type)} again`, className: "flex cursor-pointer items-center rounded-sm opacity-70 hover:opacity-100", onClick: () => removeType(type.key), children: _jsx(X, { className: "size-3", strokeWidth: 1 }) })] }) }, type.key))) })] })] }), settingsError && (_jsx("p", { className: `mt-4 ${settingsText.error}`, role: "alert", "data-testid": "translation-settings-error", children: settingsError })), _jsxs("div", { className: "border-border-default mt-4 flex justify-end gap-2 border-t pt-4", children: [dirty && (_jsx(Button, { size: "sm", variant: "outline", onClick: () => setDraft(draftOf(page.settings)), disabled: savingSettings, children: "Discard changes" })), _jsxs(Button, { size: "sm", onClick: () => void saveSettings(changes), disabled: !dirty || savingSettings, "data-testid": "translation-settings-save", children: [_jsx(Save, { className: "h-4 w-4", strokeWidth: 1 }), "Save"] })] })] }) }), _jsx(TranslationProviderDialog, { provider: editing, saving: busyProvider !== null, error: dialogError, onOpenChange: (open) => !open && setEditing(null), onSave: (values) => void saveProvider(values) }, editing?.serviceName ?? "closed"), _jsx(ExcludedContentTypeDialog, { open: typeDialog, saving: readingType, error: typeError, onOpenChange: setTypeDialog, onPick: (store, itemId) => void addContentType(store, itemId) })] }));
|
|
201
213
|
}
|
|
202
214
|
export default TranslationServicesPanel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemSelectionTree.d.ts","sourceRoot":"","sources":["../../src/steps/ItemSelectionTree.tsx"],"names":[],"mappings":"AACA,OAAO,EAOL,KAAK,eAAe,EAOrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAOrD,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAC/C,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,+
|
|
1
|
+
{"version":3,"file":"ItemSelectionTree.d.ts","sourceRoot":"","sources":["../../src/steps/ItemSelectionTree.tsx"],"names":[],"mappings":"AACA,OAAO,EAOL,KAAK,eAAe,EAOrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAOrD,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAC/C,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,+BAkfxB"}
|
|
@@ -345,7 +345,9 @@ export function ItemSelectionTree({ data, setData, editContext, isActive = true,
|
|
|
345
345
|
return;
|
|
346
346
|
const existing = new Set(items.map((i) => itemKey(i.descriptor)));
|
|
347
347
|
const next = [...items];
|
|
348
|
-
for (const
|
|
348
|
+
for (const candidate of source) {
|
|
349
|
+
// A tree node belongs to the store the tree browses.
|
|
350
|
+
const node = { ...candidate, database: candidate.database ?? store };
|
|
349
351
|
if (!node.id || !node.database || existing.has(itemKey(node)))
|
|
350
352
|
continue;
|
|
351
353
|
if (!isWritable(node))
|
|
@@ -371,7 +373,7 @@ export function ItemSelectionTree({ data, setData, editContext, isActive = true,
|
|
|
371
373
|
commitToWizard(next);
|
|
372
374
|
setSelectedInTree([]);
|
|
373
375
|
setSelectedFromList([]);
|
|
374
|
-
}, [items, selectedInTree, language, cacheTreeNode, commitToWizard]);
|
|
376
|
+
}, [items, selectedInTree, store, language, cacheTreeNode, commitToWizard]);
|
|
375
377
|
const handleAddItem = useCallback(async (item) => {
|
|
376
378
|
const id = item.id;
|
|
377
379
|
if (!id ||
|
|
@@ -419,7 +421,9 @@ export function ItemSelectionTree({ data, setData, editContext, isActive = true,
|
|
|
419
421
|
setItems(next);
|
|
420
422
|
commitToWizard(next);
|
|
421
423
|
}, [items, commitToWizard]);
|
|
422
|
-
|
|
424
|
+
// A bounded column: the pickers keep their height and the editor takes the
|
|
425
|
+
// rest, so the tree and the list scroll inside it, never the whole step.
|
|
426
|
+
return (_jsxs("div", { className: "flex h-full min-h-0 flex-col", children: [_jsxs("div", { className: "mb-3 flex shrink-0 flex-wrap gap-4 px-6 pt-4", children: [!onlyStore && (_jsx(FormField, { label: "Content store", className: "w-64", children: _jsx(ContentStoreSelect, { "data-testid": "translation-content-store", value: store, placeholder: "Select a store", onValueChange: (value) => {
|
|
423
427
|
setStore(value);
|
|
424
428
|
setSelectedInTree([]);
|
|
425
429
|
}, stores: writableStores }) })), _jsx(FormField, { label: "Source language", className: "w-64", children: _jsx(Select, { "data-testid": "translation-source-language", value: language, placeholder: store ? "Select a language" : "Select a store first", disabled: !store, loading: !!store && storeLanguages === null, onValueChange: handleLanguageChange, searchable: (storeLanguages?.length ?? 0) > 8, options: (storeLanguages ?? []).map((entry) => ({
|
|
@@ -428,10 +432,10 @@ export function ItemSelectionTree({ data, setData, editContext, isActive = true,
|
|
|
428
432
|
description: entry.name && entry.name !== entry.languageCode
|
|
429
433
|
? entry.languageCode
|
|
430
434
|
: undefined,
|
|
431
|
-
})) }) })] }), store && language ? (_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
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
+
})) }) })] }), 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
|
|
436
|
+
.filter((root) => root.storeId === store &&
|
|
437
|
+
(root.kind === "content" || root.kind === "media"))
|
|
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
|
|
435
439
|
? "Select a source language to choose translation items."
|
|
436
440
|
: "Select a content store and source language to choose translation items." }))] }));
|
|
437
441
|
}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { type Language } from "@parhelia/core";
|
|
3
|
-
import { TranslationJobRecord } from "../services/translationService";
|
|
3
|
+
import { TranslationBatchInfo, TranslationJobRecord } from "../services/translationService";
|
|
4
4
|
type StatusFilter = "all" | "in-progress" | "completed" | "errors" | "aborted";
|
|
5
|
+
/**
|
|
6
|
+
* Whether the signed-in person may delete this batch: it has stopped (a running
|
|
7
|
+
* batch is aborted first), and they started it or are an administrator. The
|
|
8
|
+
* server checks the same; this only hides the action where it would be refused.
|
|
9
|
+
*/
|
|
10
|
+
export declare function canDeleteTranslationBatch(info: Pick<TranslationBatchInfo, "status" | "initiatedBySubjectId"> | undefined, user: {
|
|
11
|
+
subjectId?: string;
|
|
12
|
+
isAdministrator?: boolean;
|
|
13
|
+
} | undefined): boolean;
|
|
5
14
|
export declare function TranslationBatches(): React.JSX.Element;
|
|
6
15
|
export declare const TRANSLATION_BATCH_FILTERS_SIDEBAR_ID = "translation-batch-filters";
|
|
7
16
|
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,
|
|
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,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U,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"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useRef, useState, useMemo, useSyncExternalStore, } from "react";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { Button, Badge, ContentStoreSelect, Select, Input, UserPicker, Popover, PopoverContent, PopoverTrigger, Tooltip, TooltipContent, TooltipTrigger, ContentTree, ContentInspectorPopover, PageHeader, fetchItemStubs, searchUsers as searchBackendUsers, useEditContext, useContentModel, getLanguages, SimpleIconButton, WorkspaceHomeView, capitalizeFirstLetter, formatDateTime, LanguageIcon, } from "@parhelia/core";
|
|
5
|
-
import { listBatches, getTranslationProviders, getTranslationJobLastPayload, listBatchTranslationJobs, retryBatchTranslation, abortJob, abortBatch, subscribeToBatch, unsubscribeFromBatch, translationItemKey, } from "../services/translationService";
|
|
4
|
+
import { Button, Badge, ContentStoreSelect, CreateButton, DeleteButton, Select, Input, UserPicker, Popover, PopoverContent, PopoverTrigger, Tooltip, TooltipContent, TooltipTrigger, ContentTree, ContentInspectorPopover, PageHeader, fetchItemStubs, searchUsers as searchBackendUsers, useEditContext, useContentModel, getLanguages, SimpleIconButton, WorkspaceHomeView, capitalizeFirstLetter, formatDateTime, LanguageIcon, } from "@parhelia/core";
|
|
5
|
+
import { listBatches, getTranslationProviders, getTranslationJobLastPayload, listBatchTranslationJobs, retryBatchTranslation, abortJob, abortBatch, deleteBatch, subscribeToBatch, unsubscribeFromBatch, translationItemKey, } from "../services/translationService";
|
|
6
6
|
import { TRANSLATION_BATCH_STARTED_EVENT, } from "../translationEvents";
|
|
7
7
|
import { useDebouncedCallback } from "use-debounce";
|
|
8
|
-
import { X, ChevronDown, Languages, Loader2, FolderTree, ExternalLink, Check, AlertCircle, CircleStop, Hourglass, Copy, Sparkles, RotateCcw,
|
|
8
|
+
import { X, ChevronDown, Languages, Loader2, FolderTree, ExternalLink, Check, AlertCircle, CircleStop, Hourglass, Copy, Sparkles, RotateCcw, Bug, } from "lucide-react";
|
|
9
9
|
import { toast } from "sonner";
|
|
10
10
|
import { openLocalizeItemDialog } from "../LocalizeItemCommand";
|
|
11
11
|
// Wrappers for lucide-react icons to work with React 19
|
|
@@ -22,7 +22,6 @@ const QueuedIcon = (props) => React.createElement(Hourglass, props);
|
|
|
22
22
|
const CopyIcon = (props) => React.createElement(Copy, props);
|
|
23
23
|
const SparklesIcon = (props) => React.createElement(Sparkles, props);
|
|
24
24
|
const RetryIcon = (props) => React.createElement(RotateCcw, props);
|
|
25
|
-
const PlusIcon = (props) => React.createElement(Plus, props);
|
|
26
25
|
const BugIcon = (props) => React.createElement(Bug, props);
|
|
27
26
|
function renderTargetLanguageIcon(language) {
|
|
28
27
|
return React.createElement(LanguageIcon, {
|
|
@@ -110,6 +109,20 @@ function isTerminalBatchStatus(status) {
|
|
|
110
109
|
function isActiveBatchStatus(status) {
|
|
111
110
|
return status === "Pending" || status === "In Progress";
|
|
112
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Whether the signed-in person may delete this batch: it has stopped (a running
|
|
114
|
+
* batch is aborted first), and they started it or are an administrator. The
|
|
115
|
+
* server checks the same; this only hides the action where it would be refused.
|
|
116
|
+
*/
|
|
117
|
+
export function canDeleteTranslationBatch(info, user) {
|
|
118
|
+
if (!info || !user || !isTerminalBatchStatus(info.status))
|
|
119
|
+
return false;
|
|
120
|
+
if (user.isAdministrator)
|
|
121
|
+
return true;
|
|
122
|
+
// The initiator is the account whose id the batch stores, as on the server.
|
|
123
|
+
const initiator = info.initiatedBySubjectId?.trim().toLowerCase();
|
|
124
|
+
return !!initiator && initiator === user.subjectId?.trim().toLowerCase();
|
|
125
|
+
}
|
|
113
126
|
function isRetriableJob(job) {
|
|
114
127
|
return job?.status === "Error" && !!job.store;
|
|
115
128
|
}
|
|
@@ -248,6 +261,7 @@ export function TranslationBatches() {
|
|
|
248
261
|
const [loadingJobs, setLoadingJobs] = useState(new Set());
|
|
249
262
|
const [abortingBatchIds, setAbortingBatchIds] = useState(new Set());
|
|
250
263
|
const [abortingJobIds, setAbortingJobIds] = useState(new Set());
|
|
264
|
+
const [deletingBatchIds, setDeletingBatchIds] = useState(new Set());
|
|
251
265
|
const [retryingKeys, setRetryingKeys] = useState(new Set());
|
|
252
266
|
// Cache of userName → displayName so we can render full names on batch rows
|
|
253
267
|
// without re-querying the user service every render.
|
|
@@ -478,6 +492,24 @@ export function TranslationBatches() {
|
|
|
478
492
|
cancelled = true;
|
|
479
493
|
};
|
|
480
494
|
}, [batches, userDisplayNames]);
|
|
495
|
+
// A deleted batch leaves the list, its held jobs and the expansion at once;
|
|
496
|
+
// the next list read would drop it as well.
|
|
497
|
+
const removeBatch = useCallback((batchId) => {
|
|
498
|
+
const id = normalizeGuid(batchId);
|
|
499
|
+
setBatches((prev) => {
|
|
500
|
+
const next = prev.filter((b) => normalizeGuid(b.id) !== id);
|
|
501
|
+
return next.length === prev.length ? prev : next;
|
|
502
|
+
});
|
|
503
|
+
setBatchJobs((prev) => {
|
|
504
|
+
const key = Object.keys(prev).find((k) => normalizeGuid(k) === id);
|
|
505
|
+
if (key === undefined)
|
|
506
|
+
return prev;
|
|
507
|
+
const next = { ...prev };
|
|
508
|
+
delete next[key];
|
|
509
|
+
return next;
|
|
510
|
+
});
|
|
511
|
+
setExpandedBatchId((prev) => prev && normalizeGuid(prev) === id ? null : prev);
|
|
512
|
+
}, []);
|
|
481
513
|
// Keep refs to the latest reload + expansion state so the socket listener
|
|
482
514
|
// can be registered once and survive editContext identity changes.
|
|
483
515
|
// Without this, a context recreation (triggered e.g. by EditorShell's
|
|
@@ -556,6 +588,10 @@ export function TranslationBatches() {
|
|
|
556
588
|
applyBatchRow(message.payload);
|
|
557
589
|
return;
|
|
558
590
|
}
|
|
591
|
+
if (message.type === "batch-deleted" && batchIdFromPayload) {
|
|
592
|
+
removeBatch(batchIdFromPayload);
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
559
595
|
if ((message.type === "translation-started" ||
|
|
560
596
|
message.type === "translation-finished" ||
|
|
561
597
|
message.type === "translation-error" ||
|
|
@@ -598,7 +634,7 @@ export function TranslationBatches() {
|
|
|
598
634
|
// debounce expiry, and cancelling on re-subscription would drop the
|
|
599
635
|
// refresh that brings the UI to its final state.
|
|
600
636
|
};
|
|
601
|
-
}, [editContext]);
|
|
637
|
+
}, [editContext, removeBatch]);
|
|
602
638
|
// Websocket events are the fast path, but a short disconnect or a batch that
|
|
603
639
|
// completes before the editor transport finishes reconnecting must not leave
|
|
604
640
|
// this management view permanently stale. Reconcile while the panel is
|
|
@@ -808,6 +844,35 @@ export function TranslationBatches() {
|
|
|
808
844
|
loadBatchJobs,
|
|
809
845
|
loadRecentBatches,
|
|
810
846
|
]);
|
|
847
|
+
const handleDeleteBatch = useCallback((batchId, batchName) => {
|
|
848
|
+
editContext?.confirm({
|
|
849
|
+
header: "Delete Translation Batch",
|
|
850
|
+
message: `Delete "${batchName}" and its translation jobs? The batch disappears from Translation Management for everyone. Content that was already translated stays as it is.`,
|
|
851
|
+
acceptLabel: "Delete",
|
|
852
|
+
showCancel: true,
|
|
853
|
+
accept: async () => {
|
|
854
|
+
setDeletingBatchIds((prev) => new Set(prev).add(batchId));
|
|
855
|
+
try {
|
|
856
|
+
const result = await deleteBatch(batchId);
|
|
857
|
+
if (result.type !== "success") {
|
|
858
|
+
toast.error(result.details ||
|
|
859
|
+
result.summary ||
|
|
860
|
+
"Failed to delete translation batch.");
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
removeBatch(batchId);
|
|
864
|
+
toast.success("Translation batch deleted.");
|
|
865
|
+
}
|
|
866
|
+
finally {
|
|
867
|
+
setDeletingBatchIds((prev) => {
|
|
868
|
+
const next = new Set(prev);
|
|
869
|
+
next.delete(batchId);
|
|
870
|
+
return next;
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
},
|
|
874
|
+
});
|
|
875
|
+
}, [editContext, removeBatch]);
|
|
811
876
|
const handleAbortJob = useCallback((job) => {
|
|
812
877
|
if (!job.id || !job.batchId) {
|
|
813
878
|
toast.error("This translation job cannot be aborted.");
|
|
@@ -1023,7 +1088,9 @@ export function TranslationBatches() {
|
|
|
1023
1088
|
const canAbort = isActiveBatchStatus(info?.status);
|
|
1024
1089
|
const isRetryingBatch = retryingKeys.has(`batch:${b.id}`);
|
|
1025
1090
|
const isAborting = abortingBatchIds.has(b.id);
|
|
1026
|
-
const
|
|
1091
|
+
const canDelete = canDeleteTranslationBatch(info, editContext?.user);
|
|
1092
|
+
const isDeleting = deletingBatchIds.has(b.id);
|
|
1093
|
+
const hasBatchActions = canRetry || canAbort || canDelete;
|
|
1027
1094
|
// Stable test-id status used by Playwright assertions.
|
|
1028
1095
|
// Matches the visual status dot/spinner logic above.
|
|
1029
1096
|
const testStatus = anyError
|
|
@@ -1046,7 +1113,10 @@ export function TranslationBatches() {
|
|
|
1046
1113
|
if (!canAbort)
|
|
1047
1114
|
return;
|
|
1048
1115
|
handleAbortBatch(b.id);
|
|
1049
|
-
}, icon: isAborting ? (_jsx(LoaderIcon, { className: "h-3.5 w-3.5 animate-spin", strokeWidth: 1 })) : (_jsx(AbortIcon, { className: "h-3.5 w-3.5", strokeWidth: 1 })), label: "Abort translation batch", disabled: !canAbort || isAborting }))
|
|
1116
|
+
}, icon: isAborting ? (_jsx(LoaderIcon, { className: "h-3.5 w-3.5 animate-spin", strokeWidth: 1 })) : (_jsx(AbortIcon, { className: "h-3.5 w-3.5", strokeWidth: 1 })), label: "Abort translation batch", disabled: !canAbort || isAborting })), canDelete && (_jsx(DeleteButton, { size: "xs", iconSize: "md", className: "h-6 w-6", label: "Delete translation batch", "data-testid": `batch-delete-${b.id}`, onClick: (event) => {
|
|
1117
|
+
event.stopPropagation();
|
|
1118
|
+
handleDeleteBatch(b.id, batchDisplayName);
|
|
1119
|
+
}, onKeyDown: (event) => event.stopPropagation(), disabled: isDeleting || isRetryingBatch }))] }));
|
|
1050
1120
|
return (_jsxs("div", { "data-testid": `batch-row-${b.id}`, "data-batch-status": testStatus, children: [_jsx("div", { role: "button", tabIndex: 0, className: `group w-full cursor-pointer py-3 text-left transition-colors hover:bg-neutral-grey-5 ${isCompactBatches ? "px-2.5" : "px-4"}`, onClick: () => toggleBatch(b.id), onKeyDown: (e) => {
|
|
1051
1121
|
if (e.key === "Enter" || e.key === " ") {
|
|
1052
1122
|
e.preventDefault();
|
|
@@ -1067,7 +1137,15 @@ export function TranslationBatchFiltersSidebar() {
|
|
|
1067
1137
|
const model = useContentModel();
|
|
1068
1138
|
const { filters, itemIdOrPathInput } = useTranslationBatchFilterSnapshot();
|
|
1069
1139
|
const filterStore = filters.store ?? editContext?.currentItemDescriptor?.database ?? "";
|
|
1070
|
-
|
|
1140
|
+
// The item filter reads its item in the open item's language, or in the store's own default locale when no item of
|
|
1141
|
+
// that store is open; a pick from the content tree carries the picked item's language instead.
|
|
1142
|
+
const itemFilterLanguage = (storeId) => {
|
|
1143
|
+
const openItem = editContext?.currentItemDescriptor;
|
|
1144
|
+
if (openItem?.database === storeId && openItem.language)
|
|
1145
|
+
return openItem.language;
|
|
1146
|
+
return (model?.stores.find((store) => store.id === storeId)?.defaultLocale ?? "");
|
|
1147
|
+
};
|
|
1148
|
+
const filterLanguage = itemFilterLanguage(filterStore);
|
|
1071
1149
|
const [providers, setProviders] = useState([]);
|
|
1072
1150
|
const [contentLanguages, setContentLanguages] = useState([]);
|
|
1073
1151
|
const [itemPickerOpen, setItemPickerOpen] = useState(false);
|
|
@@ -1160,9 +1238,7 @@ export function TranslationBatchFiltersSidebar() {
|
|
|
1160
1238
|
}, [currentUserName, debouncedSetItemFilter]);
|
|
1161
1239
|
const filterLabelClass = "text-[12px] font-medium text-neutral-grey-50";
|
|
1162
1240
|
const filterFieldClass = "flex flex-col gap-1";
|
|
1163
|
-
return (_jsxs("div", { className: "flex h-full min-h-0 flex-col bg-white", "data-testid": "translation-filters-sidebar", children: [_jsx("div", { className: "border-border-default flex shrink-0 flex-col gap-2 border-b px-3 py-3", children:
|
|
1164
|
-
? "Start new translation"
|
|
1165
|
-
: "Open an item to translate", "data-testid": "translation-sidebar-start-new-translation-button", disabled: !canStartTranslation, onClick: handleStartTranslation, className: "border-border-default hover:border-neutral-grey-100 hover:bg-neutral-grey-5 h-9 w-full justify-center gap-3 rounded-md bg-white px-3 text-sm font-medium shadow-none", children: [_jsx("span", { className: "truncate", children: "Start new translation" }), _jsx(PlusIcon, { className: "size-4", strokeWidth: 1 })] }) }), _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto px-3 py-4", children: _jsxs("div", { className: "grid gap-4", children: [_jsxs("div", { className: filterFieldClass, children: [_jsx("label", { className: filterLabelClass, children: "Date Range" }), _jsx(Select, { className: "w-full bg-white", options: DATE_RANGE_OPTIONS, value: filters.dateRange, onValueChange: (value) => setTranslationBatchFilters((prev) => ({
|
|
1241
|
+
return (_jsxs("div", { className: "flex h-full min-h-0 flex-col bg-white", "data-testid": "translation-filters-sidebar", children: [_jsx("div", { className: "border-border-default flex shrink-0 flex-col gap-2 border-b px-3 py-3", children: _jsx(CreateButton, { label: "Start new translation", disabledHint: "Open an item to translate", "data-testid": "translation-sidebar-start-new-translation-button", disabled: !canStartTranslation, onClick: handleStartTranslation }) }), _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto px-3 py-4", children: _jsxs("div", { className: "grid gap-4", children: [_jsxs("div", { className: filterFieldClass, children: [_jsx("label", { className: filterLabelClass, children: "Date Range" }), _jsx(Select, { className: "w-full bg-white", options: DATE_RANGE_OPTIONS, value: filters.dateRange, onValueChange: (value) => setTranslationBatchFilters((prev) => ({
|
|
1166
1242
|
...prev,
|
|
1167
1243
|
dateRange: value,
|
|
1168
1244
|
})), placeholder: "Select date range" })] }), _jsxs("div", { className: filterFieldClass, children: [_jsx("label", { className: filterLabelClass, children: "Status" }), _jsx(Select, { className: "w-full bg-white", options: STATUS_OPTIONS, value: filters.status, onValueChange: (value) => setTranslationBatchFilters((prev) => ({
|
|
@@ -1206,19 +1282,17 @@ export function TranslationBatchFiltersSidebar() {
|
|
|
1206
1282
|
})), placeholder: "Select language" })] }), _jsxs("div", { className: filterFieldClass, children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("label", { className: filterLabelClass, children: "Item ID / Path" }), _jsxs("label", { className: "flex cursor-pointer items-center gap-1 text-[10px] text-neutral-grey-50 select-none", children: [_jsx("input", { type: "checkbox", checked: filters.itemIncludeSubitems, onChange: (e) => setTranslationBatchFilters((prev) => ({
|
|
1207
1283
|
...prev,
|
|
1208
1284
|
itemIncludeSubitems: e.target.checked,
|
|
1209
|
-
})), className: "h-3 w-3 cursor-pointer accent-highlight-100" }), "Include subitems"] })] }),
|
|
1210
|
-
...prev,
|
|
1211
|
-
store: storeId,
|
|
1212
|
-
language: filterLanguage,
|
|
1213
|
-
})), stores: model?.stores ?? [] })] }), _jsx(Input, { "aria-label": "Item filter language", value: filterLanguage, onChange: (event) => setTranslationBatchFilters((prev) => ({
|
|
1285
|
+
})), className: "h-3 w-3 cursor-pointer accent-highlight-100" }), "Include subitems"] })] }), _jsx(ContentStoreSelect, { "aria-label": "Item filter store", className: "w-full bg-white", value: filterStore, placeholder: "Select a store", onValueChange: (storeId) => setTranslationBatchFilters((prev) => ({
|
|
1214
1286
|
...prev,
|
|
1215
|
-
store:
|
|
1216
|
-
language:
|
|
1217
|
-
})),
|
|
1287
|
+
store: storeId,
|
|
1288
|
+
language: itemFilterLanguage(storeId),
|
|
1289
|
+
})), stores: model?.stores ?? [] }), _jsxs("div", { className: "relative", children: [_jsx(Input, { value: itemIdOrPathInput, disabled: !filterStore || !filterLanguage, onChange: (e) => {
|
|
1218
1290
|
const next = e.target.value;
|
|
1219
1291
|
setTranslationBatchItemInput(next);
|
|
1220
1292
|
debouncedSetItemFilter(next);
|
|
1221
|
-
}, placeholder:
|
|
1293
|
+
}, placeholder: filterStore && !filterLanguage
|
|
1294
|
+
? "Open an item of this store"
|
|
1295
|
+
: "Item ID or path", className: "h-auto min-h-[34px] w-full bg-white py-2 pr-14 text-xs" }), _jsxs("div", { className: "absolute top-1/2 right-1.5 flex -translate-y-1/2 items-center gap-1", children: [itemIdOrPathInput && (_jsx("button", { type: "button", onClick: () => {
|
|
1222
1296
|
setTranslationBatchItemInput("");
|
|
1223
1297
|
debouncedSetItemFilter.cancel();
|
|
1224
1298
|
setTranslationBatchFilters((prev) => ({
|