From 6c9f4503940c609358803e464144b4d3bcdae935 Mon Sep 17 00:00:00 2001 From: g Date: Fri, 9 Feb 2024 12:23:25 -0500 Subject: [PATCH] feat: unify state --- .../pages/main/workflow-runs/$run/index.tsx | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/frontend/app/src/pages/main/workflow-runs/$run/index.tsx b/frontend/app/src/pages/main/workflow-runs/$run/index.tsx index 9d22fcf2b..e8bc7665d 100644 --- a/frontend/app/src/pages/main/workflow-runs/$run/index.tsx +++ b/frontend/app/src/pages/main/workflow-runs/$run/index.tsx @@ -23,8 +23,6 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { StepRunPlayground } from './components/step-run-playground'; export default function ExpandedWorkflowRun() { - const [expandedStepRuns, setExpandedStepRuns] = useState([]); - const [selectedStepRun, setSelectedStepRun] = useState(); const { tenant } = useOutletContext(); @@ -104,7 +102,6 @@ export default function ExpandedWorkflowRun() { workflowRun={run} selectedStepRun={selectedStepRun} setSelectedStepRun={(step) => { - console.log(step); setSelectedStepRun( step.stepId === selectedStepRun?.stepId ? undefined : step, ); @@ -148,26 +145,17 @@ export default function ExpandedWorkflowRun() { kind: 'step', isExpandable: true, onClick: () => { - if ( - expandedStepRuns.includes(stepRun.metadata.id) - ) { - setExpandedStepRuns( - expandedStepRuns.filter( - (id) => id != stepRun.metadata.id, - ), - ); - } else { - setExpandedStepRuns([ - ...expandedStepRuns, - stepRun.metadata.id, - ]); - } + setSelectedStepRun( + stepRun.stepId === selectedStepRun?.stepId + ? undefined + : stepRun, + ); }, ...stepRun, }, ]; - if (expandedStepRuns.includes(stepRun.metadata.id)) { + if (selectedStepRun?.stepId == stepRun.stepId) { res.push({ kind: 'step', isExpandable: false,