Skip to content

Commit

Permalink
feat: unify state
Browse files Browse the repository at this point in the history
  • Loading branch information
grutt committed Feb 9, 2024
1 parent ff0e060 commit 6c9f450
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions frontend/app/src/pages/main/workflow-runs/$run/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string[]>([]);

const [selectedStepRun, setSelectedStepRun] = useState<StepRun | undefined>();

const { tenant } = useOutletContext<TenantContextType>();
Expand Down Expand Up @@ -104,7 +102,6 @@ export default function ExpandedWorkflowRun() {
workflowRun={run}
selectedStepRun={selectedStepRun}
setSelectedStepRun={(step) => {
console.log(step);
setSelectedStepRun(
step.stepId === selectedStepRun?.stepId ? undefined : step,
);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 6c9f450

Please sign in to comment.