refactor(pipelines): clarify log view switching

This commit is contained in:
RockChinQ
2026-08-27 15:49:55 +08:00
parent 7671aefed7
commit f3c1887e92
12 changed files with 124 additions and 94 deletions
@@ -7,10 +7,12 @@ import {
TooltipContent,
TooltipTrigger,
} from '@/components/ui/tooltip';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { cn } from '@/lib/utils';
interface ProcessorMonitoringView {
label: string;
workbenchLabel: string;
content: ReactNode;
}
@@ -67,11 +69,37 @@ export default function ProcessorDetailWorkbench({
const hasDebug = Boolean(debugTitle && debugContent);
return (
<div className="flex h-full min-h-0 min-w-0 flex-col">
<Tabs
value={activeView}
onValueChange={(value) =>
setActiveView(value as 'workbench' | 'monitoring')
}
className="flex h-full min-h-0 min-w-0 flex-col gap-0"
>
<div className="flex shrink-0 flex-wrap items-center justify-between gap-3 pb-4">
<div className="flex min-w-0 items-center gap-2">
<h1 className="truncate text-xl font-semibold">{title}</h1>
{titleAction}
{monitoring && (
<TabsList
aria-label={`${monitoring.workbenchLabel} / ${monitoring.label}`}
className="ml-1"
>
<TabsTrigger value="workbench" className="gap-1.5 px-3">
<Settings className="size-4" />
{monitoring.workbenchLabel}
{isDirty && (
<span className="size-1.5 rounded-full bg-amber-500">
<span className="sr-only">{unsavedLabel}</span>
</span>
)}
</TabsTrigger>
<TabsTrigger value="monitoring" className="gap-1.5 px-3">
<BarChart3 className="size-4" />
{monitoring.label}
</TabsTrigger>
</TabsList>
)}
{status && (
<Tooltip>
<TooltipTrigger asChild>
@@ -117,20 +145,6 @@ export default function ProcessorDetailWorkbench({
)}
</div>
<div className="flex items-center gap-2">
{monitoring && (
<Button
type="button"
variant={activeView === 'monitoring' ? 'secondary' : 'outline'}
onClick={() =>
setActiveView((current) =>
current === 'monitoring' ? 'workbench' : 'monitoring',
)
}
>
<BarChart3 className="size-4" />
{monitoring.label}
</Button>
)}
{canSave && activeView === 'workbench' && (
<Button
type="submit"
@@ -144,74 +158,82 @@ export default function ProcessorDetailWorkbench({
</div>
</div>
{activeView === 'monitoring' && monitoring ? (
<section
aria-label={monitoring.label}
className="min-h-0 flex-1 overflow-y-auto rounded-xl border bg-card p-4"
{monitoring && (
<TabsContent
value="monitoring"
className="mt-0 min-h-0 flex-1 overflow-hidden"
>
{monitoring.content}
</section>
) : (
<div className="min-h-0 flex-1 overflow-y-auto lg:overflow-hidden">
<div
className={cn(
'grid min-h-0 gap-3 lg:h-full',
hasDebug
? 'lg:grid-cols-[minmax(20rem,0.72fr)_minmax(0,1.28fr)]'
: 'grid-cols-1',
)}
<section
aria-label={monitoring.label}
className="h-full min-h-0 overflow-y-auto rounded-xl border bg-card p-4"
>
{hasDebug && (
<section
aria-label={debugTitle}
className="flex min-h-[32rem] min-w-0 flex-col overflow-hidden rounded-xl border bg-card lg:min-h-0"
>
<div className="flex h-12 shrink-0 items-center justify-between gap-3 border-b px-4">
<div className="flex min-w-0 items-center gap-2 font-medium">
<Bug className="size-4 shrink-0" />
<span className="truncate">{debugTitle}</span>
</div>
{debugConnected !== undefined && (
<span className="flex items-center gap-1.5 text-xs text-muted-foreground">
<span
className={cn(
'size-2 rounded-full',
debugConnected ? 'bg-emerald-500' : 'bg-destructive',
)}
/>
{debugConnected
? debugConnectedLabel
: debugDisconnectedLabel}
</span>
)}
</div>
<div className="min-h-0 min-w-0 flex-1 overflow-hidden">
{debugContent}
</div>
</section>
)}
{monitoring.content}
</section>
</TabsContent>
)}
<TabsContent
value="workbench"
className="mt-0 min-h-0 flex-1 overflow-y-auto lg:overflow-hidden"
>
<div
className={cn(
'grid min-h-0 gap-3 lg:h-full',
hasDebug
? 'lg:grid-cols-[minmax(20rem,0.72fr)_minmax(0,1.28fr)]'
: 'grid-cols-1',
)}
>
{hasDebug && (
<section
aria-label={configTitle}
className="flex min-h-[36rem] min-w-0 flex-col overflow-hidden rounded-xl border bg-card lg:min-h-0"
aria-label={debugTitle}
className="flex min-h-[32rem] min-w-0 flex-col overflow-hidden rounded-xl border bg-card lg:min-h-0"
>
<div className="flex h-12 shrink-0 items-center gap-2 border-b px-4 font-medium">
<Settings className="size-4" />
<span className="truncate">{configTitle}</span>
{isDirty && (
<span className="ml-auto flex items-center gap-1.5 text-xs text-amber-600 dark:text-amber-400">
<span className="size-1.5 rounded-full bg-amber-500" />
{unsavedLabel}
<div className="flex h-12 shrink-0 items-center justify-between gap-3 border-b px-4">
<div className="flex min-w-0 items-center gap-2 font-medium">
<Bug className="size-4 shrink-0" />
<span className="truncate">{debugTitle}</span>
</div>
{debugConnected !== undefined && (
<span className="flex items-center gap-1.5 text-xs text-muted-foreground">
<span
className={cn(
'size-2 rounded-full',
debugConnected ? 'bg-emerald-500' : 'bg-destructive',
)}
/>
{debugConnected
? debugConnectedLabel
: debugDisconnectedLabel}
</span>
)}
</div>
<div className="min-h-0 min-w-0 flex-1 overflow-hidden p-4">
{configContent}
<div className="min-h-0 min-w-0 flex-1 overflow-hidden">
{debugContent}
</div>
</section>
</div>
)}
<section
aria-label={configTitle}
className="flex min-h-[36rem] min-w-0 flex-col overflow-hidden rounded-xl border bg-card lg:min-h-0"
>
<div className="flex h-12 shrink-0 items-center gap-2 border-b px-4 font-medium">
<Settings className="size-4" />
<span className="truncate">{configTitle}</span>
{isDirty && (
<span className="ml-auto flex items-center gap-1.5 text-xs text-amber-600 dark:text-amber-400">
<span className="size-1.5 rounded-full bg-amber-500" />
{unsavedLabel}
</span>
)}
</div>
<div className="min-h-0 min-w-0 flex-1 overflow-hidden p-4">
{configContent}
</div>
</section>
</div>
)}
</div>
</TabsContent>
</Tabs>
);
}
@@ -200,6 +200,7 @@ export default function PipelineDetailContent({
canViewMonitoring
? {
label: t('pipelines.monitoring.title'),
workbenchLabel: t('pipelines.monitoring.workbench'),
content: (
<PipelineMonitoringTab
pipelineId={id}