@parhelia/localization 0.4.13058 → 0.4.13170
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/LICENSE +1 -1
- package/dist/LocalizeItemCommand.d.ts.map +1 -1
- package/dist/LocalizeItemCommand.js +0 -1
- package/dist/LocalizeItemDialog.d.ts.map +1 -1
- package/dist/LocalizeItemDialog.js +3 -9
- package/dist/LocalizeItemUtils.d.ts +0 -1
- package/dist/LocalizeItemUtils.d.ts.map +1 -1
- package/dist/LocalizeItemUtils.js +24 -45
- package/dist/api/discovery.d.ts +3 -17
- package/dist/api/discovery.d.ts.map +1 -1
- package/dist/api/discovery.js +14 -35
- package/dist/hooks/useTranslationWizard.d.ts.map +1 -1
- package/dist/hooks/useTranslationWizard.js +2 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -6
- package/dist/services/translationService.d.ts +27 -43
- package/dist/services/translationService.d.ts.map +1 -1
- package/dist/services/translationService.js +32 -36
- package/dist/settings/TranslationServicesPanel.d.ts +4 -14
- package/dist/settings/TranslationServicesPanel.d.ts.map +1 -1
- package/dist/settings/TranslationServicesPanel.js +263 -186
- package/dist/setup/LocalizationSetupStep.d.ts.map +1 -1
- package/dist/setup/LocalizationSetupStep.js +33 -14
- package/dist/sidebar/TranslationSidebar.d.ts.map +1 -1
- package/dist/sidebar/TranslationSidebar.js +14 -35
- package/dist/steps/ItemSelectionTree.d.ts +2 -2
- package/dist/steps/ItemSelectionTree.d.ts.map +1 -1
- package/dist/steps/ItemSelectionTree.js +47 -132
- package/dist/steps/ProviderStep.d.ts.map +1 -1
- package/dist/steps/ProviderStep.js +42 -55
- package/dist/steps/ServiceLanguageSelectionStep.d.ts +1 -1
- package/dist/steps/ServiceLanguageSelectionStep.d.ts.map +1 -1
- package/dist/steps/ServiceLanguageSelectionStep.js +176 -127
- package/dist/steps/types.d.ts +3 -3
- package/dist/steps/types.d.ts.map +1 -1
- package/dist/translation-center/TranslationBatches.d.ts +0 -37
- package/dist/translation-center/TranslationBatches.d.ts.map +1 -1
- package/dist/translation-center/TranslationBatches.js +78 -214
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/services/translationSettingsService.d.ts +0 -79
- package/dist/services/translationSettingsService.d.ts.map +0 -1
- package/dist/services/translationSettingsService.js +0 -68
- package/dist/settings/ExcludedContentTypeDialog.d.ts +0 -12
- package/dist/settings/ExcludedContentTypeDialog.d.ts.map +0 -1
- package/dist/settings/ExcludedContentTypeDialog.js +0 -29
- package/dist/settings/TranslationProviderDialog.d.ts +0 -18
- package/dist/settings/TranslationProviderDialog.d.ts.map +0 -1
- package/dist/settings/TranslationProviderDialog.js +0 -105
|
@@ -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,
|
|
5
|
-
import { listBatches, getTranslationProviders, getTranslationJobLastPayload, listBatchTranslationJobs, retryBatchTranslation, abortJob, abortBatch,
|
|
4
|
+
import { Button, Badge, Select, Input, UserPicker, Popover, PopoverContent, PopoverTrigger, Tooltip, TooltipContent, TooltipTrigger, ContentTree, ContentInspectorPopover, PageHeader, fetchItemStubs, searchUsers as searchBackendUsers, useEditContext, getLanguages, SimpleIconButton, WorkspaceHomeView, capitalizeFirstLetter, formatDateTime, } from "@parhelia/core";
|
|
5
|
+
import { listBatches, getTranslationProviders, getTranslationJobLastPayload, listBatchTranslationJobs, retryBatchTranslation, abortJob, abortBatch, subscribeToBatch, unsubscribeFromBatch, } 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, Bug, } from "lucide-react";
|
|
8
|
+
import { X, ChevronDown, Languages, Loader2, Globe, FolderTree, ExternalLink, Check, AlertCircle, CircleStop, Hourglass, Copy, Sparkles, RotateCcw, Plus, 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
|
|
@@ -13,6 +13,7 @@ const XIcon = (props) => React.createElement(X, props);
|
|
|
13
13
|
const ChevronDownIcon = (props) => React.createElement(ChevronDown, props);
|
|
14
14
|
const LanguagesIcon = (props) => React.createElement(Languages, props);
|
|
15
15
|
const LoaderIcon = (props) => React.createElement(Loader2, props);
|
|
16
|
+
const GlobeIcon = (props) => React.createElement(Globe, props);
|
|
16
17
|
const FolderTreeIcon = (props) => React.createElement(FolderTree, props);
|
|
17
18
|
const ExternalLinkIcon = (props) => React.createElement(ExternalLink, props);
|
|
18
19
|
const CheckIcon = (props) => React.createElement(Check, props);
|
|
@@ -22,12 +23,21 @@ const QueuedIcon = (props) => React.createElement(Hourglass, props);
|
|
|
22
23
|
const CopyIcon = (props) => React.createElement(Copy, props);
|
|
23
24
|
const SparklesIcon = (props) => React.createElement(Sparkles, props);
|
|
24
25
|
const RetryIcon = (props) => React.createElement(RotateCcw, props);
|
|
26
|
+
const PlusIcon = (props) => React.createElement(Plus, props);
|
|
25
27
|
const BugIcon = (props) => React.createElement(Bug, props);
|
|
26
28
|
function renderTargetLanguageIcon(language) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
if (language.icon) {
|
|
30
|
+
return React.createElement("img", {
|
|
31
|
+
src: language.icon,
|
|
32
|
+
className: "h-4 w-5 object-cover",
|
|
33
|
+
alt: "",
|
|
34
|
+
"aria-hidden": true,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return React.createElement(GlobeIcon, {
|
|
38
|
+
className: "h-3.5 w-3.5 text-neutral-grey-50",
|
|
39
|
+
strokeWidth: 1,
|
|
40
|
+
"aria-hidden": true,
|
|
31
41
|
});
|
|
32
42
|
}
|
|
33
43
|
const DEFAULT_FILTERS = {
|
|
@@ -109,40 +119,13 @@ function isTerminalBatchStatus(status) {
|
|
|
109
119
|
function isActiveBatchStatus(status) {
|
|
110
120
|
return status === "Pending" || status === "In Progress";
|
|
111
121
|
}
|
|
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
|
-
}
|
|
126
122
|
function isRetriableJob(job) {
|
|
127
|
-
return job?.status === "Error"
|
|
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;
|
|
123
|
+
return job?.status === "Error";
|
|
140
124
|
}
|
|
141
125
|
function buildRetryJobRequest(job) {
|
|
142
|
-
if (!job.
|
|
126
|
+
if (!job.itemId || !job.sourceLanguage || !job.targetLanguage)
|
|
143
127
|
return null;
|
|
144
128
|
return {
|
|
145
|
-
store: job.store,
|
|
146
129
|
sourceTranslationId: job.id,
|
|
147
130
|
itemId: job.itemId,
|
|
148
131
|
sourceLanguage: job.sourceLanguage,
|
|
@@ -257,7 +240,7 @@ export function TranslationBatches() {
|
|
|
257
240
|
const editContext = useEditContext();
|
|
258
241
|
const [emptyStateSlogan] = useState(() => EMPTY_STATE_SLOGANS[Math.floor(Math.random() * EMPTY_STATE_SLOGANS.length)]);
|
|
259
242
|
const [batches, setBatches] = useState([]);
|
|
260
|
-
const [
|
|
243
|
+
const [sitecoreLanguages, setSitecoreLanguages] = useState([]);
|
|
261
244
|
const [isLoading, setIsLoading] = useState(false);
|
|
262
245
|
// False until the first list response lands. Later reloads (the user filter
|
|
263
246
|
// defaulting in, socket refreshes, the reconciliation poll) update in place
|
|
@@ -273,7 +256,6 @@ export function TranslationBatches() {
|
|
|
273
256
|
const [loadingJobs, setLoadingJobs] = useState(new Set());
|
|
274
257
|
const [abortingBatchIds, setAbortingBatchIds] = useState(new Set());
|
|
275
258
|
const [abortingJobIds, setAbortingJobIds] = useState(new Set());
|
|
276
|
-
const [deletingBatchIds, setDeletingBatchIds] = useState(new Set());
|
|
277
259
|
const [retryingKeys, setRetryingKeys] = useState(new Set());
|
|
278
260
|
// Cache of userName → displayName so we can render full names on batch rows
|
|
279
261
|
// without re-querying the user service every render.
|
|
@@ -352,18 +334,12 @@ export function TranslationBatches() {
|
|
|
352
334
|
provider: filters.provider === "all" ? undefined : filters.provider,
|
|
353
335
|
targetLanguage: filters.targetLanguage === "all" ? undefined : filters.targetLanguage,
|
|
354
336
|
itemIdOrPath: trimmedItem ? trimmedItem : undefined,
|
|
355
|
-
store: filters.store,
|
|
356
|
-
language: filters.language,
|
|
357
337
|
itemIncludeSubitems: trimmedItem && filters.itemIncludeSubitems ? true : undefined,
|
|
358
338
|
};
|
|
359
339
|
}, [filters, userFilterLocked, currentUserName]);
|
|
360
|
-
const loadRecentBatches = useCallback(async (offset, append, filtersToUse
|
|
340
|
+
const loadRecentBatches = useCallback(async (offset, append, filtersToUse) => {
|
|
361
341
|
const myRequestId = ++requestIdRef.current;
|
|
362
|
-
if (
|
|
363
|
-
// Background reconciliation must not replace the list with a loading
|
|
364
|
-
// state; websocket events remain the fast path.
|
|
365
|
-
}
|
|
366
|
-
else if (offset === 0) {
|
|
342
|
+
if (offset === 0) {
|
|
367
343
|
setIsLoading(true);
|
|
368
344
|
}
|
|
369
345
|
else {
|
|
@@ -404,7 +380,7 @@ export function TranslationBatches() {
|
|
|
404
380
|
console.error("Failed to load batches:", error);
|
|
405
381
|
}
|
|
406
382
|
finally {
|
|
407
|
-
if (
|
|
383
|
+
if (myRequestId === requestIdRef.current) {
|
|
408
384
|
setIsLoading(false);
|
|
409
385
|
setIsLoadingMore(false);
|
|
410
386
|
setHasLoadedOnce(true);
|
|
@@ -417,43 +393,24 @@ export function TranslationBatches() {
|
|
|
417
393
|
loadRecentBatches(currentOffset, true, effectiveFilters);
|
|
418
394
|
}
|
|
419
395
|
};
|
|
420
|
-
// Load
|
|
396
|
+
// Load Sitecore languages for language chips in expanded batches.
|
|
421
397
|
useEffect(() => {
|
|
422
398
|
const loadLanguages = async () => {
|
|
423
399
|
try {
|
|
424
|
-
const res = await getLanguages(
|
|
400
|
+
const res = await getLanguages();
|
|
425
401
|
const langs = (res?.data ?? res ?? []);
|
|
426
|
-
|
|
402
|
+
setSitecoreLanguages(Array.isArray(langs) ? langs : []);
|
|
427
403
|
}
|
|
428
404
|
catch (error) {
|
|
429
|
-
console.error("Failed to load
|
|
405
|
+
console.error("Failed to load Sitecore languages:", error);
|
|
430
406
|
}
|
|
431
407
|
};
|
|
432
408
|
loadLanguages();
|
|
433
|
-
}, [
|
|
409
|
+
}, []);
|
|
434
410
|
// Reload when filters change (resets pagination)
|
|
435
411
|
useEffect(() => {
|
|
436
412
|
loadRecentBatches(0, false, effectiveFilters);
|
|
437
413
|
}, [loadRecentBatches, effectiveFilters]);
|
|
438
|
-
// Socket delivery is best-effort across reconnects and host restarts. Keep
|
|
439
|
-
// the visible list eventually consistent with a quiet REST reconciliation.
|
|
440
|
-
useEffect(() => {
|
|
441
|
-
let inFlight = false;
|
|
442
|
-
const reconcile = () => {
|
|
443
|
-
if (document.visibilityState === "hidden" || inFlight)
|
|
444
|
-
return;
|
|
445
|
-
inFlight = true;
|
|
446
|
-
void loadRecentBatches(0, false, effectiveFilters, true).finally(() => {
|
|
447
|
-
inFlight = false;
|
|
448
|
-
});
|
|
449
|
-
};
|
|
450
|
-
const interval = window.setInterval(reconcile, 3000);
|
|
451
|
-
document.addEventListener("visibilitychange", reconcile);
|
|
452
|
-
return () => {
|
|
453
|
-
window.clearInterval(interval);
|
|
454
|
-
document.removeEventListener("visibilitychange", reconcile);
|
|
455
|
-
};
|
|
456
|
-
}, [effectiveFilters, loadRecentBatches]);
|
|
457
414
|
// Seed the cache with the current user's full name so rows authored by us
|
|
458
415
|
// resolve immediately, without waiting on a searchUsers round-trip.
|
|
459
416
|
useEffect(() => {
|
|
@@ -504,24 +461,6 @@ export function TranslationBatches() {
|
|
|
504
461
|
cancelled = true;
|
|
505
462
|
};
|
|
506
463
|
}, [batches, userDisplayNames]);
|
|
507
|
-
// A deleted batch leaves the list, its held jobs and the expansion at once;
|
|
508
|
-
// the next list read would drop it as well.
|
|
509
|
-
const removeBatch = useCallback((batchId) => {
|
|
510
|
-
const id = normalizeGuid(batchId);
|
|
511
|
-
setBatches((prev) => {
|
|
512
|
-
const next = prev.filter((b) => normalizeGuid(b.id) !== id);
|
|
513
|
-
return next.length === prev.length ? prev : next;
|
|
514
|
-
});
|
|
515
|
-
setBatchJobs((prev) => {
|
|
516
|
-
const key = Object.keys(prev).find((k) => normalizeGuid(k) === id);
|
|
517
|
-
if (key === undefined)
|
|
518
|
-
return prev;
|
|
519
|
-
const next = { ...prev };
|
|
520
|
-
delete next[key];
|
|
521
|
-
return next;
|
|
522
|
-
});
|
|
523
|
-
setExpandedBatchId((prev) => prev && normalizeGuid(prev) === id ? null : prev);
|
|
524
|
-
}, []);
|
|
525
464
|
// Keep refs to the latest reload + expansion state so the socket listener
|
|
526
465
|
// can be registered once and survive editContext identity changes.
|
|
527
466
|
// Without this, a context recreation (triggered e.g. by EditorShell's
|
|
@@ -550,7 +489,6 @@ export function TranslationBatches() {
|
|
|
550
489
|
// Live progress: patch the matching job's message in-place so an open
|
|
551
490
|
// popover reflects the latest progress text without a REST reload.
|
|
552
491
|
if (message.type === "translation-progress" && batchIdFromPayload) {
|
|
553
|
-
const storeFromPayload = message?.payload?.store ?? message?.payload?.Store;
|
|
554
492
|
const itemIdFromPayload = normalizeGuid(message?.payload?.itemId ?? message?.payload?.ItemId);
|
|
555
493
|
const languageFromPayload = (message?.payload?.language ??
|
|
556
494
|
message?.payload?.Language ??
|
|
@@ -565,9 +503,7 @@ export function TranslationBatches() {
|
|
|
565
503
|
return prev;
|
|
566
504
|
let changed = false;
|
|
567
505
|
const nextJobs = jobs.map((job) => {
|
|
568
|
-
if (
|
|
569
|
-
job.store === storeFromPayload &&
|
|
570
|
-
normalizeGuid(job.itemId) === itemIdFromPayload &&
|
|
506
|
+
if (normalizeGuid(job.itemId) === itemIdFromPayload &&
|
|
571
507
|
job.targetLanguage === languageFromPayload &&
|
|
572
508
|
// A late progress text must not replace a terminal
|
|
573
509
|
// outcome (an error text, or the final record).
|
|
@@ -600,10 +536,6 @@ export function TranslationBatches() {
|
|
|
600
536
|
applyBatchRow(message.payload);
|
|
601
537
|
return;
|
|
602
538
|
}
|
|
603
|
-
if (message.type === "batch-deleted" && batchIdFromPayload) {
|
|
604
|
-
removeBatch(batchIdFromPayload);
|
|
605
|
-
return;
|
|
606
|
-
}
|
|
607
539
|
if ((message.type === "translation-started" ||
|
|
608
540
|
message.type === "translation-finished" ||
|
|
609
541
|
message.type === "translation-error" ||
|
|
@@ -646,7 +578,7 @@ export function TranslationBatches() {
|
|
|
646
578
|
// debounce expiry, and cancelling on re-subscription would drop the
|
|
647
579
|
// refresh that brings the UI to its final state.
|
|
648
580
|
};
|
|
649
|
-
}, [editContext
|
|
581
|
+
}, [editContext]);
|
|
650
582
|
// Websocket events are the fast path, but a short disconnect or a batch that
|
|
651
583
|
// completes before the editor transport finishes reconnecting must not leave
|
|
652
584
|
// this management view permanently stale. Reconcile while the panel is
|
|
@@ -856,35 +788,6 @@ export function TranslationBatches() {
|
|
|
856
788
|
loadBatchJobs,
|
|
857
789
|
loadRecentBatches,
|
|
858
790
|
]);
|
|
859
|
-
const handleDeleteBatch = useCallback((batchId, batchName) => {
|
|
860
|
-
editContext?.confirm({
|
|
861
|
-
header: "Delete Translation Batch",
|
|
862
|
-
message: `Delete "${batchName}" and its translation jobs? The batch disappears from Translation Management for everyone. Content that was already translated stays as it is.`,
|
|
863
|
-
acceptLabel: "Delete",
|
|
864
|
-
showCancel: true,
|
|
865
|
-
accept: async () => {
|
|
866
|
-
setDeletingBatchIds((prev) => new Set(prev).add(batchId));
|
|
867
|
-
try {
|
|
868
|
-
const result = await deleteBatch(batchId);
|
|
869
|
-
if (result.type !== "success") {
|
|
870
|
-
toast.error(result.details ||
|
|
871
|
-
result.summary ||
|
|
872
|
-
"Failed to delete translation batch.");
|
|
873
|
-
return;
|
|
874
|
-
}
|
|
875
|
-
removeBatch(batchId);
|
|
876
|
-
toast.success("Translation batch deleted.");
|
|
877
|
-
}
|
|
878
|
-
finally {
|
|
879
|
-
setDeletingBatchIds((prev) => {
|
|
880
|
-
const next = new Set(prev);
|
|
881
|
-
next.delete(batchId);
|
|
882
|
-
return next;
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
},
|
|
886
|
-
});
|
|
887
|
-
}, [editContext, removeBatch]);
|
|
888
791
|
const handleAbortJob = useCallback((job) => {
|
|
889
792
|
if (!job.id || !job.batchId) {
|
|
890
793
|
toast.error("This translation job cannot be aborted.");
|
|
@@ -1000,16 +903,10 @@ export function TranslationBatches() {
|
|
|
1000
903
|
const jobs = batchJobs[batchId] ?? (await loadBatchJobs(batchId));
|
|
1001
904
|
await handleRetryJobs(batchId, batch.provider, jobs, `batch:${batchId}`);
|
|
1002
905
|
}, [batchJobs, handleRetryJobs, loadBatchJobs]);
|
|
1003
|
-
const openItemInEditor = useCallback(async (itemId, language
|
|
1004
|
-
|
|
1005
|
-
return;
|
|
906
|
+
const openItemInEditor = useCallback(async (itemId, language) => {
|
|
907
|
+
const normalized = (itemId ?? "").toString().toLowerCase();
|
|
1006
908
|
editContext?.setShowAgentsWorkspaceEditor(true);
|
|
1007
|
-
await editContext?.loadItem({
|
|
1008
|
-
id: itemId,
|
|
1009
|
-
language,
|
|
1010
|
-
version: 0,
|
|
1011
|
-
database: store,
|
|
1012
|
-
});
|
|
909
|
+
await editContext?.loadItem(language ? { id: normalized, language, version: 0 } : normalized);
|
|
1013
910
|
}, [editContext]);
|
|
1014
911
|
// The blank-slate home view (no header, grey full-height greeting) also
|
|
1015
912
|
// covers the initial load, so the greeting mounts exactly once.
|
|
@@ -1034,7 +931,6 @@ export function TranslationBatches() {
|
|
|
1034
931
|
const languages = languagesCsv
|
|
1035
932
|
? languagesCsv.split(",")
|
|
1036
933
|
: [];
|
|
1037
|
-
const sourceLanguage = batchSourceLanguage(info?.metadata, batchJobs[b.id]);
|
|
1038
934
|
const errorJobs = info?.errorJobs ?? 0;
|
|
1039
935
|
const anyError = errorJobs > 0;
|
|
1040
936
|
const anyInProgress = isActiveBatchStatus(info?.status);
|
|
@@ -1050,7 +946,7 @@ export function TranslationBatches() {
|
|
|
1050
946
|
metaParts.push(_jsxs("span", { children: [itemsCount, " item", itemsCount !== 1 ? "s" : ""] }, "items"));
|
|
1051
947
|
}
|
|
1052
948
|
if (languages.length > 0) {
|
|
1053
|
-
metaParts.push(_jsxs("span", { title: languages.join(", "), children: [
|
|
949
|
+
metaParts.push(_jsxs("span", { title: languages.join(", "), children: [languages.length, " language", languages.length !== 1 ? "s" : ""] }, "langs"));
|
|
1054
950
|
}
|
|
1055
951
|
if (info?.provider) {
|
|
1056
952
|
metaParts.push(_jsx("span", { children: info.provider }, "prov"));
|
|
@@ -1101,9 +997,7 @@ export function TranslationBatches() {
|
|
|
1101
997
|
const canAbort = isActiveBatchStatus(info?.status);
|
|
1102
998
|
const isRetryingBatch = retryingKeys.has(`batch:${b.id}`);
|
|
1103
999
|
const isAborting = abortingBatchIds.has(b.id);
|
|
1104
|
-
const
|
|
1105
|
-
const isDeleting = deletingBatchIds.has(b.id);
|
|
1106
|
-
const hasBatchActions = canRetry || canAbort || canDelete;
|
|
1000
|
+
const hasBatchActions = canRetry || canAbort;
|
|
1107
1001
|
// Stable test-id status used by Playwright assertions.
|
|
1108
1002
|
// Matches the visual status dot/spinner logic above.
|
|
1109
1003
|
const testStatus = anyError
|
|
@@ -1126,10 +1020,7 @@ export function TranslationBatches() {
|
|
|
1126
1020
|
if (!canAbort)
|
|
1127
1021
|
return;
|
|
1128
1022
|
handleAbortBatch(b.id);
|
|
1129
|
-
}, 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 }))
|
|
1130
|
-
event.stopPropagation();
|
|
1131
|
-
handleDeleteBatch(b.id, batchDisplayName);
|
|
1132
|
-
}, onKeyDown: (event) => event.stopPropagation(), disabled: isDeleting || isRetryingBatch }))] }));
|
|
1023
|
+
}, 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 }))] }));
|
|
1133
1024
|
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) => {
|
|
1134
1025
|
if (e.key === "Enter" || e.key === " ") {
|
|
1135
1026
|
e.preventDefault();
|
|
@@ -1141,26 +1032,15 @@ export function TranslationBatches() {
|
|
|
1141
1032
|
? "whitespace-normal break-words leading-5"
|
|
1142
1033
|
: "truncate"}`, style: isCompactBatches
|
|
1143
1034
|
? { overflowWrap: "anywhere" }
|
|
1144
|
-
: undefined, title: formattedBatchDate, children: batchDisplayName }), _jsx("div", { className: "mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px] text-neutral-grey-50", children: desktopMetaParts.map((part, i) => (_jsxs(React.Fragment, { children: [i > 0 && (_jsx("span", { className: "text-neutral-grey-15", children: "\u00B7" })), part] }, i))) }), mobileFooterMetaParts.length > 0 && (_jsx("div", { className: "mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px] text-neutral-grey-50", children: mobileFooterMetaParts.map((part, i) => (_jsxs(React.Fragment, { children: [i > 0 && (_jsx("span", { className: "text-neutral-grey-15", children: "\u00B7" })), part] }, `footer-${i}`))) }))] }), isCompactBatches && (_jsxs("div", { className: "mt-2 flex min-w-0 items-center gap-2", children: [totalJobs > 0 && (_jsx("div", { className: "min-w-0 flex-1", children: _jsx(BatchProgressIndicator, { counts: statusCounts, status: info?.status, testId: `batch-progress-${b.id}`, variant: "bar" }) })), hasBatchActions && (_jsx("div", { className: "flex shrink-0 items-center gap-1.5", children: batchActions }))] })), !isCompactBatches && hasBatchActions && (_jsx("div", { className: "flex shrink-0 items-center gap-2 self-center", children: batchActions }))] })] }) }), isExpanded && (_jsxs("div", { className: "border-t border-border-default/50", children: [_jsx(CustomPromptPanel, { prompts: parseCustomPrompts(info?.metadata) }), _jsx(BatchItemList, { batchId: b.id, batchProvider: info?.provider, jobs: jobs, isLoading: isLoadingThis, expandedItems: expandedItems, languages:
|
|
1035
|
+
: undefined, title: formattedBatchDate, children: batchDisplayName }), _jsx("div", { className: "mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px] text-neutral-grey-50", children: desktopMetaParts.map((part, i) => (_jsxs(React.Fragment, { children: [i > 0 && (_jsx("span", { className: "text-neutral-grey-15", children: "\u00B7" })), part] }, i))) }), mobileFooterMetaParts.length > 0 && (_jsx("div", { className: "mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px] text-neutral-grey-50", children: mobileFooterMetaParts.map((part, i) => (_jsxs(React.Fragment, { children: [i > 0 && (_jsx("span", { className: "text-neutral-grey-15", children: "\u00B7" })), part] }, `footer-${i}`))) }))] }), isCompactBatches && (_jsxs("div", { className: "mt-2 flex min-w-0 items-center gap-2", children: [totalJobs > 0 && (_jsx("div", { className: "min-w-0 flex-1", children: _jsx(BatchProgressIndicator, { counts: statusCounts, status: info?.status, testId: `batch-progress-${b.id}`, variant: "bar" }) })), hasBatchActions && (_jsx("div", { className: "flex shrink-0 items-center gap-1.5", children: batchActions }))] })), !isCompactBatches && hasBatchActions && (_jsx("div", { className: "flex shrink-0 items-center gap-2 self-center", children: batchActions }))] })] }) }), isExpanded && (_jsxs("div", { className: "border-t border-border-default/50", children: [_jsx(CustomPromptPanel, { prompts: parseCustomPrompts(info?.metadata) }), _jsx(BatchItemList, { batchId: b.id, batchProvider: info?.provider, jobs: jobs, isLoading: isLoadingThis, expandedItems: expandedItems, languages: sitecoreLanguages, currentLanguage: editContext?.item?.language, itemFilter: filters.itemIdOrPath.trim(), itemIncludeSubitems: filters.itemIncludeSubitems, statusFilter: filters.status, batchIsTerminal: isTerminalBatchStatus(info?.status), batchStartedAtUtc: info?.startedAtUtc ?? info?.createdAtUtc, abortingJobIds: abortingJobIds, retryingKeys: retryingKeys, isMobile: isMobile, onToggleItem: toggleItem, onOpenItem: openItemInEditor, onAbortJob: handleAbortJob, onRetryJobs: handleRetryJobs })] }))] }, b.id));
|
|
1145
1036
|
}) })] }, dateGroup.label))), hasMore && (_jsx("div", { className: "flex justify-center pt-6", children: _jsx(Button, { variant: "outline", size: "sm", onClick: loadMore, disabled: isLoadingMore, children: isLoadingMore ? (_jsxs(_Fragment, { children: [_jsx(LoaderIcon, { className: "h-4 w-4 animate-spin text-highlight-100" }), "Loading more..."] })) : (_jsxs(_Fragment, { children: [_jsx(ChevronDownIcon, { className: "h-4 w-4" }), "Load More Batches"] })) }) }))] })) }) })] }));
|
|
1146
1037
|
}
|
|
1147
1038
|
export const TRANSLATION_BATCH_FILTERS_SIDEBAR_ID = "translation-batch-filters";
|
|
1148
1039
|
export function TranslationBatchFiltersSidebar() {
|
|
1149
1040
|
const editContext = useEditContext();
|
|
1150
|
-
const model = useContentModel();
|
|
1151
1041
|
const { filters, itemIdOrPathInput } = useTranslationBatchFilterSnapshot();
|
|
1152
|
-
const filterStore = filters.store ?? editContext?.currentItemDescriptor?.database ?? "";
|
|
1153
|
-
// The item filter reads its item in the open item's language, or in the store's own default locale when no item of
|
|
1154
|
-
// that store is open; a pick from the content tree carries the picked item's language instead.
|
|
1155
|
-
const itemFilterLanguage = (storeId) => {
|
|
1156
|
-
const openItem = editContext?.currentItemDescriptor;
|
|
1157
|
-
if (openItem?.database === storeId && openItem.language)
|
|
1158
|
-
return openItem.language;
|
|
1159
|
-
return (model?.stores.find((store) => store.id === storeId)?.defaultLocale ?? "");
|
|
1160
|
-
};
|
|
1161
|
-
const filterLanguage = itemFilterLanguage(filterStore);
|
|
1162
1042
|
const [providers, setProviders] = useState([]);
|
|
1163
|
-
const [
|
|
1043
|
+
const [sitecoreLanguages, setSitecoreLanguages] = useState([]);
|
|
1164
1044
|
const [itemPickerOpen, setItemPickerOpen] = useState(false);
|
|
1165
1045
|
const currentUserName = editContext?.user?.name || "all";
|
|
1166
1046
|
// Limited-preview sessions and accounts confined to their own batches (see
|
|
@@ -1185,8 +1065,6 @@ export function TranslationBatchFiltersSidebar() {
|
|
|
1185
1065
|
const debouncedSetItemFilter = useDebouncedCallback((value) => setTranslationBatchFilters((prev) => ({
|
|
1186
1066
|
...prev,
|
|
1187
1067
|
itemIdOrPath: value,
|
|
1188
|
-
store: filterStore,
|
|
1189
|
-
language: filterLanguage,
|
|
1190
1068
|
})), 400);
|
|
1191
1069
|
useEffect(() => {
|
|
1192
1070
|
const loadProviders = async () => {
|
|
@@ -1206,23 +1084,23 @@ export function TranslationBatchFiltersSidebar() {
|
|
|
1206
1084
|
useEffect(() => {
|
|
1207
1085
|
const loadLanguages = async () => {
|
|
1208
1086
|
try {
|
|
1209
|
-
const res = await getLanguages(
|
|
1087
|
+
const res = await getLanguages();
|
|
1210
1088
|
const langs = (res?.data ?? res ?? []);
|
|
1211
|
-
|
|
1089
|
+
setSitecoreLanguages(Array.isArray(langs) ? langs : []);
|
|
1212
1090
|
}
|
|
1213
1091
|
catch (error) {
|
|
1214
|
-
console.error("Failed to load
|
|
1092
|
+
console.error("Failed to load Sitecore languages:", error);
|
|
1215
1093
|
}
|
|
1216
1094
|
};
|
|
1217
1095
|
loadLanguages();
|
|
1218
|
-
}, [
|
|
1219
|
-
const languageOptions = useMemo(() =>
|
|
1096
|
+
}, []);
|
|
1097
|
+
const languageOptions = useMemo(() => sitecoreLanguages
|
|
1220
1098
|
.map((language) => {
|
|
1221
1099
|
const code = language.languageCode || language.name;
|
|
1222
1100
|
return code ? { ...language, languageCode: code } : null;
|
|
1223
1101
|
})
|
|
1224
1102
|
.filter((language) => language !== null)
|
|
1225
|
-
.sort((a, b) => a.languageCode.localeCompare(b.languageCode)), [
|
|
1103
|
+
.sort((a, b) => a.languageCode.localeCompare(b.languageCode)), [sitecoreLanguages]);
|
|
1226
1104
|
const currentItem = editContext?.item;
|
|
1227
1105
|
const multiItemEnabled = editContext?.configuration?.localization?.multiItem !== false;
|
|
1228
1106
|
const canStartTranslation = !!editContext && (multiItemEnabled || !!currentItem);
|
|
@@ -1251,7 +1129,9 @@ export function TranslationBatchFiltersSidebar() {
|
|
|
1251
1129
|
}, [currentUserName, debouncedSetItemFilter]);
|
|
1252
1130
|
const filterLabelClass = "text-[12px] font-medium text-neutral-grey-50";
|
|
1253
1131
|
const filterFieldClass = "flex flex-col gap-1";
|
|
1254
|
-
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:
|
|
1132
|
+
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: _jsxs(Button, { type: "button", variant: "outline", size: "lg", title: canStartTranslation
|
|
1133
|
+
? "Start new translation"
|
|
1134
|
+
: "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) => ({
|
|
1255
1135
|
...prev,
|
|
1256
1136
|
dateRange: value,
|
|
1257
1137
|
})), 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) => ({
|
|
@@ -1295,17 +1175,11 @@ export function TranslationBatchFiltersSidebar() {
|
|
|
1295
1175
|
})), 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) => ({
|
|
1296
1176
|
...prev,
|
|
1297
1177
|
itemIncludeSubitems: e.target.checked,
|
|
1298
|
-
})), className: "h-3 w-3 cursor-pointer accent-highlight-100" }), "Include subitems"] })] }),
|
|
1299
|
-
...prev,
|
|
1300
|
-
store: storeId,
|
|
1301
|
-
language: itemFilterLanguage(storeId),
|
|
1302
|
-
})), stores: model?.stores ?? [] }), _jsxs("div", { className: "relative", children: [_jsx(Input, { value: itemIdOrPathInput, disabled: !filterStore || !filterLanguage, onChange: (e) => {
|
|
1178
|
+
})), className: "h-3 w-3 cursor-pointer accent-highlight-100" }), "Include subitems"] })] }), _jsxs("div", { className: "relative", children: [_jsx(Input, { value: itemIdOrPathInput, onChange: (e) => {
|
|
1303
1179
|
const next = e.target.value;
|
|
1304
1180
|
setTranslationBatchItemInput(next);
|
|
1305
1181
|
debouncedSetItemFilter(next);
|
|
1306
|
-
}, placeholder:
|
|
1307
|
-
? "Open an item of this store"
|
|
1308
|
-
: "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: () => {
|
|
1182
|
+
}, placeholder: "GUID or /sitecore/content/...", 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: () => {
|
|
1309
1183
|
setTranslationBatchItemInput("");
|
|
1310
1184
|
debouncedSetItemFilter.cancel();
|
|
1311
1185
|
setTranslationBatchFilters((prev) => ({
|
|
@@ -1313,21 +1187,18 @@ export function TranslationBatchFiltersSidebar() {
|
|
|
1313
1187
|
itemIdOrPath: "",
|
|
1314
1188
|
itemIncludeSubitems: false,
|
|
1315
1189
|
}));
|
|
1316
|
-
}, className: "cursor-pointer text-neutral-grey-50 hover:text-neutral-grey-100", "aria-label": "Clear", children: _jsx(XIcon, { className: "h-3.5 w-3.5" }) })), _jsxs(Popover, { open: itemPickerOpen, onOpenChange: setItemPickerOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("button", { type: "button", className: "cursor-pointer text-neutral-grey-50 hover:text-neutral-grey-100", "aria-label": "Browse content tree",
|
|
1190
|
+
}, className: "cursor-pointer text-neutral-grey-50 hover:text-neutral-grey-100", "aria-label": "Clear", children: _jsx(XIcon, { className: "h-3.5 w-3.5" }) })), _jsxs(Popover, { open: itemPickerOpen, onOpenChange: setItemPickerOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("button", { type: "button", className: "cursor-pointer text-neutral-grey-50 hover:text-neutral-grey-100", "aria-label": "Browse content tree", title: "Browse content tree", children: _jsx(FolderTreeIcon, { className: "h-3.5 w-3.5" }) }) }), _jsxs(PopoverContent, { align: "end", sideOffset: 6, className: "w-[28rem] max-w-[calc(100vw-2rem)] p-0", children: [_jsx("div", { className: "flex items-center justify-between gap-2 border-b border-border-default px-3 py-2 text-[11px] text-neutral-grey-50", children: _jsx("span", { children: "Pick item to filter by" }) }), _jsx("div", { className: "max-h-80 overflow-auto p-2", children: _jsx(ContentTree, { language: "en", selectionMode: "single", rootItemIds: ["0de95ae4-41ab-4d01-9eb0-67441b7c2450"], initialExpandedKeys: [
|
|
1191
|
+
"0de95ae4-41ab-4d01-9eb0-67441b7c2450",
|
|
1192
|
+
], onSelectionChange: (items) => {
|
|
1317
1193
|
const picked = items?.[0];
|
|
1318
1194
|
if (!picked)
|
|
1319
1195
|
return;
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
// can name two pages) — while the box shows its path where it has one.
|
|
1323
|
-
const applyValue = (shown) => {
|
|
1324
|
-
setTranslationBatchItemInput(shown);
|
|
1196
|
+
const applyValue = (value) => {
|
|
1197
|
+
setTranslationBatchItemInput(value);
|
|
1325
1198
|
debouncedSetItemFilter.cancel();
|
|
1326
1199
|
setTranslationBatchFilters((prev) => ({
|
|
1327
1200
|
...prev,
|
|
1328
|
-
itemIdOrPath:
|
|
1329
|
-
store: picked.database,
|
|
1330
|
-
language: picked.language,
|
|
1201
|
+
itemIdOrPath: value,
|
|
1331
1202
|
}));
|
|
1332
1203
|
setItemPickerOpen(false);
|
|
1333
1204
|
};
|
|
@@ -1338,8 +1209,7 @@ export function TranslationBatchFiltersSidebar() {
|
|
|
1338
1209
|
fetchItemStubs([
|
|
1339
1210
|
{
|
|
1340
1211
|
id: picked.id,
|
|
1341
|
-
language:
|
|
1342
|
-
database: picked.database,
|
|
1212
|
+
language: "en",
|
|
1343
1213
|
version: 1,
|
|
1344
1214
|
},
|
|
1345
1215
|
])
|
|
@@ -1348,7 +1218,7 @@ export function TranslationBatchFiltersSidebar() {
|
|
|
1348
1218
|
applyValue(stubPath || picked.id);
|
|
1349
1219
|
})
|
|
1350
1220
|
.catch(() => applyValue(picked.id));
|
|
1351
|
-
} })
|
|
1221
|
+
} }) })] })] })] })] })] }), _jsx("div", { className: "flex justify-start pt-1", children: _jsxs(Button, { type: "button", variant: "ghost", size: "sm", onClick: resetFilters, disabled: !hasActiveFilters, children: [_jsx(XIcon, { className: "h-3.5 w-3.5" }), "Reset Filters"] }) })] }) })] }));
|
|
1352
1222
|
}
|
|
1353
1223
|
function isLikelyGuid(value) {
|
|
1354
1224
|
return /^[{(]?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}[)}]?$/i.test(value.trim());
|
|
@@ -1654,8 +1524,8 @@ function InlineLanguageJobChips({ batchId, batchProvider, jobs, languageMap, isE
|
|
|
1654
1524
|
? undefined
|
|
1655
1525
|
: { maxHeight: firstRowHeight ?? COLLAPSED_CHIP_ROW_HEIGHT_PX }, children: jobs.map((job, idx) => {
|
|
1656
1526
|
const lang = languageMap.get((job.targetLanguage || "").toLowerCase());
|
|
1657
|
-
const retryKey = `job:${job.id ?? `${
|
|
1658
|
-
return (_jsx("span", { className: "shrink-0", onClick: (event) => event.stopPropagation(), children: _jsx(LanguageJobChip, { job: job, language: lang, provider: batchProvider, batchStartedAtUtc: batchStartedAtUtc, onOpen: () => onOpenItem(job.itemId, job.targetLanguage
|
|
1527
|
+
const retryKey = `job:${job.id ?? `${job.itemId}:${job.sourceLanguage}:${job.targetLanguage}`}`;
|
|
1528
|
+
return (_jsx("span", { className: "shrink-0", onClick: (event) => event.stopPropagation(), children: _jsx(LanguageJobChip, { job: job, language: lang, provider: batchProvider, batchStartedAtUtc: batchStartedAtUtc, onOpen: () => onOpenItem(job.itemId, job.targetLanguage), isAborting: !!job.id && abortingJobIds.has(job.id), onAbort: () => onAbortJob(job), isRetrying: retryingKeys.has(retryKey), onRetry: () => onRetryJobs(batchId, batchProvider, [job], retryKey) }) }, `${job.id ?? idx}-${job.targetLanguage}`));
|
|
1659
1529
|
}) }), !isExpanded && hiddenCount > 0 && (_jsxs("button", { type: "button", className: "mt-px shrink-0 rounded border border-border-default bg-neutral-grey-5 badge-pad-sm text-[12px] leading-none tabular-nums text-neutral-grey-50 transition-colors hover:bg-neutral-grey-15 hover:text-neutral-grey-100", "aria-label": `Show ${hiddenCount} more language${hiddenCount !== 1 ? "s" : ""}`, title: `${hiddenCount} more language${hiddenCount !== 1 ? "s" : ""}`, onClick: (event) => {
|
|
1660
1530
|
event.stopPropagation();
|
|
1661
1531
|
onToggle();
|
|
@@ -1699,7 +1569,7 @@ function CustomPromptPanel({ prompts }) {
|
|
|
1699
1569
|
}, icon: justCopied ? (_jsx(CheckIcon, { className: "h-3.5 w-3.5", strokeWidth: 1 })) : (_jsx(CopyIcon, { className: "h-3.5 w-3.5", strokeWidth: 1 })), label: justCopied ? "Copied" : "Copy prompt" })), _jsx(ChevronDownIcon, { className: `h-3.5 w-3.5 text-neutral-grey-100 transition-transform ${isOpen ? "rotate-180" : ""}` })] })] }), isOpen && (_jsx("div", { style: { paddingLeft: "2.5rem" }, className: "pr-3 md:pr-4 pb-3", children: _jsx("pre", { className: "max-h-64 overflow-y-auto whitespace-pre-wrap break-words rounded border border-border-default/50 bg-white p-2 font-mono text-[12px] text-neutral-grey-100", children: p.prompt }) }))] }, p.provider));
|
|
1700
1570
|
}) }));
|
|
1701
1571
|
}
|
|
1702
|
-
|
|
1572
|
+
function BatchItemList({ batchId, batchProvider, jobs, isLoading, expandedItems, languages, currentLanguage, itemFilter, itemIncludeSubitems, statusFilter, batchIsTerminal, batchStartedAtUtc, abortingJobIds, retryingKeys, isMobile = false, onToggleItem, onOpenItem, onAbortJob, onRetryJobs, }) {
|
|
1703
1573
|
const languageMap = React.useMemo(() => {
|
|
1704
1574
|
const map = new Map();
|
|
1705
1575
|
for (const l of languages) {
|
|
@@ -1730,7 +1600,6 @@ export function BatchItemList({ batchId, batchProvider, jobs, isLoading, expande
|
|
|
1730
1600
|
const filter = itemFilter.trim();
|
|
1731
1601
|
if (!filter)
|
|
1732
1602
|
return effectiveJobs;
|
|
1733
|
-
const scopedJobs = effectiveJobs.filter((job) => !!itemFilterStore && job.store === itemFilterStore);
|
|
1734
1603
|
// When subitems is enabled and the filter is a GUID, derive the root path
|
|
1735
1604
|
// from any job in this batch that matches the GUID — then fall through to
|
|
1736
1605
|
// prefix-matching on path. If no such job is in the batch we keep only
|
|
@@ -1740,29 +1609,29 @@ export function BatchItemList({ batchId, batchProvider, jobs, isLoading, expande
|
|
|
1740
1609
|
if (isLikelyGuid(filter)) {
|
|
1741
1610
|
const normalized = normalizeGuid(filter);
|
|
1742
1611
|
if (itemIncludeSubitems) {
|
|
1743
|
-
const rootJob =
|
|
1612
|
+
const rootJob = effectiveJobs.find((j) => normalizeGuid((j.itemId || "").toString()) === normalized);
|
|
1744
1613
|
pathPrefix = rootJob?.itemPath ? rootJob.itemPath.toLowerCase() : null;
|
|
1745
1614
|
}
|
|
1746
1615
|
if (!pathPrefix) {
|
|
1747
|
-
return
|
|
1616
|
+
return effectiveJobs.filter((j) => normalizeGuid((j.itemId || "").toString()) === normalized);
|
|
1748
1617
|
}
|
|
1749
1618
|
}
|
|
1750
1619
|
else if (filter.startsWith("/")) {
|
|
1751
1620
|
pathPrefix = filter.toLowerCase();
|
|
1752
1621
|
}
|
|
1753
1622
|
else {
|
|
1754
|
-
return
|
|
1623
|
+
return effectiveJobs;
|
|
1755
1624
|
}
|
|
1756
1625
|
if (itemIncludeSubitems) {
|
|
1757
1626
|
const prefix = pathPrefix;
|
|
1758
1627
|
const prefixSlash = prefix.endsWith("/") ? prefix : prefix + "/";
|
|
1759
|
-
return
|
|
1628
|
+
return effectiveJobs.filter((j) => {
|
|
1760
1629
|
const p = (j.itemPath || "").toLowerCase();
|
|
1761
1630
|
return p === prefix || p.startsWith(prefixSlash);
|
|
1762
1631
|
});
|
|
1763
1632
|
}
|
|
1764
|
-
return
|
|
1765
|
-
}, [effectiveJobs, itemFilter,
|
|
1633
|
+
return effectiveJobs.filter((j) => (j.itemPath || "").toLowerCase() === pathPrefix);
|
|
1634
|
+
}, [effectiveJobs, itemFilter, itemIncludeSubitems]);
|
|
1766
1635
|
// Keep all jobs of items that have at least one job matching the selected status —
|
|
1767
1636
|
// this way the per-item language overview stays intact even when filtering.
|
|
1768
1637
|
const statusFilteredJobs = React.useMemo(() => {
|
|
@@ -1774,12 +1643,12 @@ export function BatchItemList({ batchId, batchProvider, jobs, isLoading, expande
|
|
|
1774
1643
|
const matchingItemIds = new Set();
|
|
1775
1644
|
for (const j of filteredJobs) {
|
|
1776
1645
|
if (j.status === targetDbStatus) {
|
|
1777
|
-
matchingItemIds.add(
|
|
1646
|
+
matchingItemIds.add((j.itemId || "").toString().toLowerCase());
|
|
1778
1647
|
}
|
|
1779
1648
|
}
|
|
1780
1649
|
if (matchingItemIds.size === 0)
|
|
1781
1650
|
return [];
|
|
1782
|
-
return filteredJobs.filter((j) => matchingItemIds.has(
|
|
1651
|
+
return filteredJobs.filter((j) => matchingItemIds.has((j.itemId || "").toString().toLowerCase()));
|
|
1783
1652
|
}, [filteredJobs, statusFilter]);
|
|
1784
1653
|
const [stackLanguageChips, setStackLanguageChips] = React.useState(isMobile);
|
|
1785
1654
|
const itemTableContainerRef = React.useRef(null);
|
|
@@ -1843,7 +1712,7 @@ export function BatchItemList({ batchId, batchProvider, jobs, isLoading, expande
|
|
|
1843
1712
|
}
|
|
1844
1713
|
const byItem = new Map();
|
|
1845
1714
|
for (const job of statusFilteredJobs) {
|
|
1846
|
-
const key =
|
|
1715
|
+
const key = (job.itemId ?? "").toString().toLowerCase();
|
|
1847
1716
|
if (!byItem.has(key))
|
|
1848
1717
|
byItem.set(key, []);
|
|
1849
1718
|
byItem.get(key).push(job);
|
|
@@ -1858,8 +1727,8 @@ export function BatchItemList({ batchId, batchProvider, jobs, isLoading, expande
|
|
|
1858
1727
|
const itemPath = firstJob?.itemPath ?? null;
|
|
1859
1728
|
const serverName = firstJob?.itemName ?? null;
|
|
1860
1729
|
const metadataName = parseItemName(firstJob?.metadata, "");
|
|
1861
|
-
const displayName = serverName || metadataName ||
|
|
1862
|
-
const titleAttr = `${
|
|
1730
|
+
const displayName = serverName || metadataName || itemId;
|
|
1731
|
+
const titleAttr = `${itemPath ?? ""}\n${itemId}`.trim();
|
|
1863
1732
|
const itemErrorJobs = itemJobs.filter(isRetriableJob);
|
|
1864
1733
|
const itemRetryKey = `item:${batchId}:${itemId}`;
|
|
1865
1734
|
const isRetryingItem = retryingKeys.has(itemRetryKey);
|
|
@@ -1878,16 +1747,13 @@ export function BatchItemList({ batchId, batchProvider, jobs, isLoading, expande
|
|
|
1878
1747
|
}, icon: _jsx(RetryIcon, { className: `h-3.5 w-3.5 ${isRetryingItem ? "animate-spin" : ""}`, strokeWidth: 1 }), label: "Retry failed translations for this item", disabled: itemErrorJobs.length === 0 || isRetryingItem }) })) : null;
|
|
1879
1748
|
const itemContent = (_jsxs("div", { className: `flex min-w-0 items-start ${stackLanguageChips ? "gap-2" : "gap-2.5"}`, children: [_jsx("span", { className: "mt-1 shrink-0", children: itemAnyInProgress ? (_jsx(LoaderIcon, { className: "h-3 w-3 animate-spin text-neutral-grey-50" })) : itemIsQueued ? (_jsx(QueuedIcon, { className: "h-3 w-3 text-neutral-grey-50", strokeWidth: 1, "aria-label": "Queued" })) : (_jsx("span", { className: `block h-1.5 w-1.5 rounded-full ${status.cls}`, "aria-hidden": "true" })) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("span", { className: `block min-w-0 text-[13px] text-neutral-grey-100 ${stackLanguageChips ? "break-words" : "truncate"}`, style: stackLanguageChips
|
|
1880
1749
|
? { overflowWrap: "anywhere" }
|
|
1881
|
-
: undefined, title: titleAttr, children: displayName }), itemPath && (_jsx("div", { className: "whitespace-normal break-words font-mono text-[11px] text-neutral-grey-50", style: { overflowWrap: "anywhere" }, title: titleAttr, children: itemPath })), _jsx("div", { className: "
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
if (firstJob?.store)
|
|
1885
|
-
void onOpenItem(firstJob.itemId, rowOpenLanguage, firstJob.store);
|
|
1750
|
+
: undefined, title: titleAttr, children: displayName }), itemPath && (_jsx("div", { className: "whitespace-normal break-words font-mono text-[11px] text-neutral-grey-50", style: { overflowWrap: "anywhere" }, title: titleAttr, children: itemPath })), stackLanguageChips && (_jsx("div", { className: "mt-2", children: languageChips })), stackLanguageChips && retryAction && (_jsx("div", { className: "mt-2 flex justify-start", children: retryAction }))] })] }));
|
|
1751
|
+
return (_jsxs("tr", { role: "button", tabIndex: 0, className: `group cursor-pointer transition-colors hover:bg-neutral-grey-5 ${itemIndex > 0 ? "border-t border-border-default/50" : ""}`, onClick: () => {
|
|
1752
|
+
void onOpenItem(itemId, rowOpenLanguage);
|
|
1886
1753
|
}, onKeyDown: (e) => {
|
|
1887
1754
|
if (e.key === "Enter" || e.key === " ") {
|
|
1888
1755
|
e.preventDefault();
|
|
1889
|
-
|
|
1890
|
-
void onOpenItem(firstJob.itemId, rowOpenLanguage, firstJob.store);
|
|
1756
|
+
void onOpenItem(itemId, rowOpenLanguage);
|
|
1891
1757
|
}
|
|
1892
1758
|
}, children: [!stackLanguageChips && (_jsx("td", { "aria-hidden": "true", className: "px-3 py-2 md:px-4" })), _jsx("td", { className: `py-2 align-top ${stackLanguageChips ? "pr-2 pl-2.5" : "pr-4"}`, children: itemContent }), !stackLanguageChips && (_jsx("td", { className: "py-2 pr-2 align-top", children: languageChips })), !stackLanguageChips && (_jsx("td", { className: "w-12 py-2 pr-3 align-top whitespace-nowrap md:pr-4", children: retryAction }))] }, itemId));
|
|
1893
1759
|
}) })] }) }));
|
|
@@ -1988,7 +1854,7 @@ function LanguageJobChip({ job, language, provider, batchStartedAtUtc, onOpen, i
|
|
|
1988
1854
|
const emptyFieldText = statistics && statistics.emptyFieldCount > 0
|
|
1989
1855
|
? `${formatCount(statistics.emptyFieldCount)} empty`
|
|
1990
1856
|
: null;
|
|
1991
|
-
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { type: "button", className: `group inline-flex items-center gap-1.5 rounded border badge-pad-sm text-[12px] transition-colors cursor-pointer ${chipCls}`, children: [_jsx(
|
|
1857
|
+
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { type: "button", className: `group inline-flex items-center gap-1.5 rounded border badge-pad-sm text-[12px] transition-colors cursor-pointer ${chipCls}`, children: [language?.icon ? (_jsx("img", { src: language.icon, alt: langName, className: "h-3.5 shrink-0" })) : null, _jsx("span", { className: "font-mono tracking-tight", children: job.targetLanguage }), jobInProgress && (_jsx(LoaderIcon, { className: "h-3 w-3 shrink-0 animate-spin" })), jobPending && (_jsx(QueuedIcon, { className: "h-3 w-3 shrink-0", strokeWidth: 1, "aria-label": "Queued" })), jobError && _jsx(AlertCircleIcon, { className: "h-3 w-3 shrink-0" }), !jobInProgress && !jobError && !jobPending && !jobAborted && (_jsx(CheckIcon, { className: "h-3 w-3 shrink-0 text-feedback-green" }))] }) }), _jsxs(PopoverContent, { align: "start", sideOffset: 6, className: "w-[26rem] max-w-[calc(100vw-2rem)] p-0", children: [_jsxs("div", { className: "flex items-center gap-2 border-b border-border-default px-3 py-2", children: [language?.icon ? (_jsx("img", { src: language.icon, alt: langName, className: "h-4 shrink-0" })) : null, _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("div", { className: "text-[13px] font-medium text-neutral-grey-100 truncate", children: langName }), _jsxs("div", { className: "text-[11px] text-neutral-grey-50 font-mono truncate", children: [job.targetLanguage, job.sourceLanguage ? ` ← ${job.sourceLanguage}` : ""] })] }), _jsxs(Badge, { size: "sm", className: statusBadgeCls, children: [jobInProgress && (_jsx(LoaderIcon, { className: "h-2.5 w-2.5 animate-spin" })), capitalizeFirstLetter(jobStatus || "Unknown")] })] }), _jsxs("dl", { className: "divide-y divide-border-default/60", children: [claimedAtValid && (_jsxs("div", { className: "flex items-baseline gap-3 px-3 py-2", children: [_jsx("dt", { className: "w-20 shrink-0 text-[10px] tracking-wide text-neutral-grey-50", children: "Claimed" }), _jsx("dd", { className: "text-[12px] text-neutral-grey-100", children: formatDateTime(claimedAt) })] })), timestampValid && (jobInProgress || jobPending) && (_jsxs("div", { className: "flex items-baseline gap-3 px-3 py-2", children: [_jsx("dt", { className: "w-20 shrink-0 text-[10px] tracking-wide text-neutral-grey-50", children: "Updated" }), _jsx("dd", { className: "text-[12px] text-neutral-grey-100", children: formatDateTime(timestamp) })] })), durationMs != null && (_jsxs("div", { className: "flex items-baseline gap-3 px-3 py-2", children: [_jsx("dt", { className: "w-20 shrink-0 text-[10px] tracking-wide text-neutral-grey-50", children: heartbeatStale
|
|
1992
1858
|
? "Stalled"
|
|
1993
1859
|
: jobInProgress || jobPending
|
|
1994
1860
|
? "Running"
|
|
@@ -2017,13 +1883,11 @@ function LanguageJobChip({ job, language, provider, batchStartedAtUtc, onOpen, i
|
|
|
2017
1883
|
e.stopPropagation();
|
|
2018
1884
|
void onAbort?.();
|
|
2019
1885
|
setOpen(false);
|
|
2020
|
-
}, className: "gap-1.5 text-neutral-grey-50 hover:text-neutral-grey-100", children: [isAborting ? (_jsx(LoaderIcon, { className: "h-3.5 w-3.5 animate-spin" })) : (_jsx(AbortIcon, { className: "h-3.5 w-3.5" })), "Abort"] })), jobError &&
|
|
1886
|
+
}, className: "gap-1.5 text-neutral-grey-50 hover:text-neutral-grey-100", children: [isAborting ? (_jsx(LoaderIcon, { className: "h-3.5 w-3.5 animate-spin" })) : (_jsx(AbortIcon, { className: "h-3.5 w-3.5" })), "Abort"] })), jobError && onRetry && (_jsxs(Button, { size: "sm", variant: "outline", disabled: isRetrying, onClick: (e) => {
|
|
2021
1887
|
e.stopPropagation();
|
|
2022
1888
|
void onRetry();
|
|
2023
1889
|
setOpen(false);
|
|
2024
|
-
}, className: "gap-1.5", children: [_jsx(RetryIcon, { className: `h-3.5 w-3.5 ${isRetrying ? "animate-spin" : ""}` }), "Retry"] })), _jsxs(Button, { size: "sm", variant: "default",
|
|
2025
|
-
? "Legacy row has no content store; navigation is unavailable."
|
|
2026
|
-
: undefined, onClick: (e) => {
|
|
1890
|
+
}, className: "gap-1.5", children: [_jsx(RetryIcon, { className: `h-3.5 w-3.5 ${isRetrying ? "animate-spin" : ""}` }), "Retry"] })), _jsxs(Button, { size: "sm", variant: "default", onClick: (e) => {
|
|
2027
1891
|
e.stopPropagation();
|
|
2028
1892
|
void onOpen();
|
|
2029
1893
|
setOpen(false);
|