From 2dcd756f00ed965ff33db4303740683d3900b727 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 18 Mar 2026 13:49:52 +0800 Subject: [PATCH] refactor(ui): extract SyncResultList component from SyncPage --- ui/src/components/SyncResultList.tsx | 75 ++++++++++++++++++++++++++++ ui/src/pages/SyncPage.tsx | 52 +------------------ 2 files changed, 77 insertions(+), 50 deletions(-) create mode 100644 ui/src/components/SyncResultList.tsx diff --git a/ui/src/components/SyncResultList.tsx b/ui/src/components/SyncResultList.tsx new file mode 100644 index 000000000..acb89c287 --- /dev/null +++ b/ui/src/components/SyncResultList.tsx @@ -0,0 +1,75 @@ +import { Check, Minus } from 'lucide-react'; + +import type { SyncResult } from '../api/client'; + +import Badge from './Badge'; +import Card from './Card'; + +interface SyncResultListProps { + results: SyncResult[]; + detailed?: boolean; +} + +export default function SyncResultList({ results, detailed = false }: SyncResultListProps) { + if (results.length === 0) { + return ( + +

No results to show.

+
+ ); + } + + return ( +
+ {results.map((r, i) => { + const linked = r.linked?.length ?? 0; + const updated = r.updated?.length ?? 0; + const skipped = r.skipped?.length ?? 0; + const pruned = r.pruned?.length ?? 0; + const hasChanges = linked > 0 || updated > 0; + + return ( + +
+ {hasChanges ? ( + + ) : ( + + )} + {r.target} +
+ {linked > 0 && {linked} linked} + {updated > 0 && {updated} updated} + {skipped > 0 && {skipped} skipped} + {pruned > 0 && {pruned} pruned} +
+
+ + {detailed && hasChanges && ( +
+ {linked > 0 && ( +
+ Linked:{' '} + {r.linked.join(', ')} +
+ )} + {updated > 0 && ( +
+ Updated:{' '} + {r.updated.join(', ')} +
+ )} + {pruned > 0 && ( +
+ Pruned:{' '} + {r.pruned.join(', ')} +
+ )} +
+ )} +
+ ); + })} +
+ ); +} diff --git a/ui/src/pages/SyncPage.tsx b/ui/src/pages/SyncPage.tsx index 30e6fbac1..29844a020 100644 --- a/ui/src/pages/SyncPage.tsx +++ b/ui/src/pages/SyncPage.tsx @@ -7,8 +7,6 @@ import { Zap, ChevronDown, ChevronRight, - Check, - Minus, CheckCircle, AlertCircle, Folder, @@ -28,6 +26,7 @@ import { useToast } from '../components/Toast'; import { api, type SyncResult, type DiffTarget, type IgnoreSources } from '../api/client'; import { queryKeys } from '../lib/queryKeys'; import StreamProgressBar from '../components/StreamProgressBar'; +import SyncResultList from '../components/SyncResultList'; import { radius, shadows } from '../design'; function extractIgnoreSources(data: IgnoreSources): IgnoreSources { @@ -327,7 +326,7 @@ export default function SyncPage() { > {dryRun ? 'Preview Results' : 'Results'} - + )} @@ -413,53 +412,6 @@ export default function SyncPage() { ); } -/** Sync results visualization — compact per-target cards with badge counts */ -function SyncResults({ results }: { results: SyncResult[] }) { - if (results.length === 0) { - return ( - -

No results to show.

-
- ); - } - - return ( -
- {results.map((r, i) => { - const linked = r.linked?.length ?? 0; - const updated = r.updated?.length ?? 0; - const skipped = r.skipped?.length ?? 0; - const pruned = r.pruned?.length ?? 0; - const hasChanges = linked > 0 || updated > 0; - - return ( - -
- {hasChanges ? ( - - ) : ( - - )} - - {r.target} - -
- {linked > 0 && {linked} linked} - {updated > 0 && {updated} updated} - {skipped > 0 && {skipped} skipped} - {pruned > 0 && {pruned} pruned} -
-
-
- ); - })} -
- ); -} - function ActionBadge({ action }: { action: string }) { const map: Record = { link: { variant: 'success', label: 'link' },