-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
pipeline-details.tsx
168 lines (161 loc) · 6.92 KB
/
pipeline-details.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import {NotificationType, Page} from 'argo-ui';
import * as React from 'react';
import {useContext, useEffect, useState} from 'react';
import {RouteComponentProps} from 'react-router';
import {Pipeline} from '../../../../models/pipeline';
import {Step} from '../../../../models/step';
import {uiUrl} from '../../../shared/base';
import {ErrorNotice} from '../../../shared/components/error-notice';
import {GraphPanel} from '../../../shared/components/graph/graph-panel';
import {Loading} from '../../../shared/components/loading';
import {Context} from '../../../shared/context';
import {historyUrl} from '../../../shared/history';
import {ListWatch} from '../../../shared/list-watch';
import {services} from '../../../shared/services';
import {StepSidePanel} from '../step-side-panel';
import {graph} from './pipeline-graph';
require('./pipeline.scss');
export const PipelineDetails = ({history, match, location}: RouteComponentProps<any>) => {
const {notifications, navigation, popup} = useContext(Context);
const queryParams = new URLSearchParams(location.search);
// state for URL and query parameters
const namespace = match.params.namespace;
const name = match.params.name;
const [tab, setTab] = useState(queryParams.get('tab'));
const [selectedStep, selectStep] = useState(queryParams.get('selectedStep'));
useEffect(
() =>
history.push(
historyUrl('pipelines/{namespace}/{name}', {
namespace,
name,
selectedStep,
tab
})
),
[namespace, name, selectedStep, tab]
);
const [error, setError] = useState<Error>();
const [pipeline, setPipeline] = useState<Pipeline>();
const [steps, setSteps] = useState<Step[]>([]);
useEffect(() => {
services.pipeline
.getPipeline(namespace, name)
.then(setPipeline)
.then(() => setError(null))
.catch(setError);
const w = new ListWatch<Step>(
() => Promise.resolve({metadata: {}, items: []}),
() => services.pipeline.watchSteps(namespace, ['dataflow.argoproj.io/pipeline-name=' + name]),
() => setError(null),
() => setError(null),
items => setSteps([...items]),
setError
);
w.start();
return () => w.stop();
}, [name, namespace]);
const step = steps.find(s => s.spec.name === selectedStep);
return (
<Page
title='Pipeline Details'
toolbar={{
breadcrumbs: [
{title: 'Pipelines', path: uiUrl('pipelines')},
{title: namespace, path: uiUrl('pipelines/' + namespace)},
{title: name, path: uiUrl('pipelines/' + namespace + '/' + name)}
],
actionMenu: {
items: [
{
title: 'Restart',
iconClassName: 'fa fa-redo',
action: () => {
services.pipeline
.restartPipeline(namespace, name)
.then(() => setError(null))
.then(() =>
notifications.show({type: NotificationType.Success, content: 'Your pipeline pods should terminate within ~30s, before being re-created'})
)
.catch(setError);
}
},
{
title: 'Delete',
iconClassName: 'fa fa-trash',
action: () => {
popup.confirm('confirm', 'Are you sure you want to delete this pipeline?').then(yes => {
if (yes) {
services.pipeline
.deletePipeline(namespace, name)
.then(() => navigation.goto(uiUrl('pipelines/' + namespace)))
.then(() => setError(null))
.catch(setError);
}
});
}
}
]
}
}}>
<>
<ErrorNotice error={error} />
{!pipeline ? (
<Loading />
) : (
<>
<GraphPanel
storageScope='pipeline'
classNames='pipeline'
graph={graph(pipeline, steps)}
nodeGenresTitle='Type'
nodeGenres={{
cat: true,
container: true,
cron: true,
expand: true,
filter: true,
flatten: true,
git: true,
group: true,
handler: true,
http: true,
log: true,
map: true,
kafka: true,
stan: true
}}
defaultIconShape='circle'
nodeClassNamesTitle='Status'
nodeClassNames={{
'': true,
'Pending': true,
'Running': true,
'Failed': true,
'Succeeded': true
}}
horizontal={true}
selectedNode={selectedStep}
onNodeSelect={node => {
if (node.startsWith('step/')) {
selectStep(node.replace('step/', ''));
}
}}
/>
{step && (
<StepSidePanel
isShown={!!selectedStep}
namespace={namespace}
pipelineName={name}
step={step}
tab={tab}
setTab={setTab}
onClose={() => selectStep(null)}
/>
)}
</>
)}
</>
</Page>
);
};