1- import {
2- ActionBlock ,
3- type ActionOrReactNode ,
4- } from "@/components/shared/ContextPanel/Blocks/ActionBlock" ;
1+ import { ActionBlock } from "@/components/shared/ContextPanel/Blocks/ActionBlock" ;
52import { ContentBlock } from "@/components/shared/ContextPanel/Blocks/ContentBlock" ;
63import { ListBlock } from "@/components/shared/ContextPanel/Blocks/ListBlock" ;
74import { TextBlock } from "@/components/shared/ContextPanel/Blocks/TextBlock" ;
@@ -10,35 +7,26 @@ import PipelineIO from "@/components/shared/Execution/PipelineIO";
107import { InfoBox } from "@/components/shared/InfoBox" ;
118import { LoadingScreen } from "@/components/shared/LoadingScreen" ;
129import { StatusBar } from "@/components/shared/Status" ;
13- import { useState } from "react" ;
1410
15- import { Icon } from "@/components/ui/icon" ;
1611import { BlockStack , InlineStack } from "@/components/ui/layout" ;
1712import { Text } from "@/components/ui/typography" ;
18- import { useCheckComponentSpecFromPath } from "@/hooks/useCheckComponentSpecFromPath" ;
19- import { useUserDetails } from "@/hooks/useUserDetails" ;
2013import { useBackend } from "@/providers/BackendProvider" ;
2114import { useComponentSpec } from "@/providers/ComponentSpecProvider" ;
2215import { useExecutionData } from "@/providers/ExecutionDataProvider" ;
2316import {
24- countInProgressFromStats ,
2517 flattenExecutionStatusStats ,
2618 getExecutionStatusLabel ,
2719 getOverallExecutionStatusFromStats ,
28- isExecutionComplete ,
2920} from "@/utils/executionStatus" ;
3021
3122import { componentSpecToText } from "@/utils/yaml" ;
3223
33- import TooltipButton from "../shared/Buttons/TooltipButton" ;
3424import { CodeViewer } from "../shared/CodeViewer" ;
35- import { CancelPipelineRunButton } from "./components/CancelPipelineRunButton" ;
36- import { ClonePipelineButton } from "./components/ClonePipelineButton" ;
37- import { InspectPipelineButton } from "./components/InspectPipelineButton" ;
38- import { RerunPipelineButton } from "./components/RerunPipelineButton" ;
25+ import { useRunActions } from "./useRunActions" ;
3926
4027export const RunDetails = ( ) => {
4128 const { configured } = useBackend ( ) ;
29+
4230 const { componentSpec } = useComponentSpec ( ) ;
4331 const {
4432 rootDetails : details ,
@@ -48,21 +36,17 @@ export const RunDetails = () => {
4836 isLoading,
4937 error,
5038 } = useExecutionData ( ) ;
51- const { data : currentUserDetails } = useUserDetails ( ) ;
52-
53- const [ isYamlFullscreen , setIsYamlFullscreen ] = useState ( false ) ;
54-
55- const editorRoute = componentSpec . name
56- ? `/editor/${ encodeURIComponent ( componentSpec . name ) } `
57- : "" ;
5839
59- const canAccessEditorSpec = useCheckComponentSpecFromPath (
60- editorRoute ,
61- ! componentSpec . name ,
62- ) ;
40+ const executionStatusStats =
41+ metadata ?. execution_status_stats ??
42+ flattenExecutionStatusStats ( state ?. child_execution_status_stats ) ;
6343
64- const isRunCreator =
65- currentUserDetails ?. id && metadata ?. created_by === currentUserDetails . id ;
44+ const { actions, isYamlFullscreen, handleCloseYaml } = useRunActions ( {
45+ componentSpec,
46+ runId,
47+ createdBy : metadata ?. created_by ,
48+ statusCounts : executionStatusStats ,
49+ } ) ;
6650
6751 if ( error || ! details || ! state || ! componentSpec ) {
6852 return (
@@ -88,55 +72,12 @@ export const RunDetails = () => {
8872 ) ;
8973 }
9074
91- const executionStatusStats =
92- metadata ?. execution_status_stats ??
93- flattenExecutionStatusStats ( state . child_execution_status_stats ) ;
94-
9575 const overallStatus =
9676 getOverallExecutionStatusFromStats ( executionStatusStats ) ;
9777 const statusLabel = getExecutionStatusLabel ( overallStatus ) ;
9878
99- const isInProgress = countInProgressFromStats ( executionStatusStats ) > 0 ;
100- const isComplete = isExecutionComplete ( executionStatusStats ) ;
101-
10279 const annotations = componentSpec . metadata ?. annotations || { } ;
10380
104- const actions : ActionOrReactNode [ ] = [ ] ;
105-
106- actions . push (
107- < TooltipButton
108- variant = "outline"
109- tooltip = "View YAML"
110- onClick = { ( ) => setIsYamlFullscreen ( true ) }
111- >
112- < Icon name = "FileCodeCorner" />
113- </ TooltipButton > ,
114- ) ;
115-
116- if ( canAccessEditorSpec && componentSpec . name ) {
117- actions . push (
118- < InspectPipelineButton key = "inspect" pipelineName = { componentSpec . name } /> ,
119- ) ;
120- }
121-
122- actions . push (
123- < ClonePipelineButton
124- key = "clone"
125- componentSpec = { componentSpec }
126- runId = { runId }
127- /> ,
128- ) ;
129-
130- if ( isInProgress && isRunCreator ) {
131- actions . push ( < CancelPipelineRunButton key = "cancel" runId = { runId } /> ) ;
132- }
133-
134- if ( isComplete ) {
135- actions . push (
136- < RerunPipelineButton key = "rerun" componentSpec = { componentSpec } /> ,
137- ) ;
138- }
139-
14081 return (
14182 < >
14283 < BlockStack gap = "6" className = "p-2 h-full" >
@@ -196,7 +137,7 @@ export const RunDetails = () => {
196137 language = "yaml"
197138 filename = { componentSpec . name ?? "pipeline.yaml" }
198139 isFullscreen = { isYamlFullscreen }
199- onClose = { ( ) => setIsYamlFullscreen ( false ) }
140+ onClose = { handleCloseYaml }
200141 />
201142 ) }
202143 </ >
0 commit comments