Skip to content

Commit 993fe0b

Browse files
authored
Merge pull request #358 from kube-HPC/HKUBE-1909-stop-of-all-jobs
invoke stop of all jobs of a certain pipeline
2 parents 52dc92f + 4946fa3 commit 993fe0b

File tree

7 files changed

+53
-5
lines changed

7 files changed

+53
-5
lines changed

src/Routes/Tables/Pipelines/PipelineActions.react.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import {
55
EditOutlined,
66
InfoCircleOutlined,
77
PlayCircleOutlined,
8+
StopOutlined,
89
} from '@ant-design/icons';
910
import { Button, Empty, Popover, Tooltip } from 'antd';
1011

1112
import { USER_GUIDE } from 'const';
1213
import { useActions } from 'hooks';
1314
import isEqual from 'lodash/isEqual';
14-
import { deleteConfirmAction } from 'utils';
15+
import { deleteConfirmAction, stopConfirmAction } from 'utils';
1516
import PipelineCreateBoard from './TensorflowBoards/PipelineCreateBoard.react';
1617
import usePath from './usePath';
1718

@@ -23,7 +24,7 @@ const title = 'Create Tensor Board for selected Node';
2324

2425
const PipelineActions = ({ pipeline, className }) => {
2526
const { goTo } = usePath();
26-
const { deleteStored: remove } = useActions();
27+
const { deleteStored: remove, stopAllPipeline } = useActions();
2728

2829
const container = useRef();
2930

@@ -38,6 +39,11 @@ const PipelineActions = ({ pipeline, className }) => {
3839
remove,
3940
]);
4041

42+
const onStop = useCallback(
43+
() => stopConfirmAction(stopAllPipeline, pipeline),
44+
[pipeline, stopAllPipeline]
45+
);
46+
4147
const setPopupContainer = useCallback(() => container.current, [container]);
4248

4349
const onUpdate = useCallback(() => {
@@ -90,6 +96,9 @@ const PipelineActions = ({ pipeline, className }) => {
9096
<Tooltip title="delete pipeline">
9197
<Button icon={<DeleteOutlined />} onClick={onDelete} />
9298
</Tooltip>
99+
<Tooltip title="stop all jobs of pipeline">
100+
<Button icon={<StopOutlined />} onClick={onStop} />
101+
</Tooltip>
93102
<Tooltip title="show overview">
94103
<Button icon={<InfoCircleOutlined />} onClick={onEdit} />
95104
</Tooltip>

src/actions/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
pausePipeline,
3131
resumePipeline,
3232
stopPipeline,
33+
stopAllPipeline,
3334
updateStored,
3435
} from './pipeline.action';
3536
import { setSettings } from './settings.action';
@@ -78,6 +79,7 @@ const actions = {
7879
socketInit,
7980
startBoard,
8081
stopPipeline,
82+
stopAllPipeline,
8183
toggleViewType,
8284
setExperimentLoading,
8385
triggerUserGuide,

src/actions/pipeline.action.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ export const addPipeline = pipeline => ({
99
},
1010
});
1111

12+
export const stopAllPipeline = (pipelineName, { onSuccess }) => ({
13+
type: actions.REST_REQ_POST,
14+
payload: {
15+
url: `exec/stop`,
16+
body: {
17+
pipelineName,
18+
reason: `Request from simulator, Algorithms-tab Delete action`,
19+
},
20+
actionType: actions.PIPELINE_STOP,
21+
},
22+
meta: { pipelineName, onSuccess },
23+
});
24+
1225
export const stopPipeline = jobId => ({
1326
type: actions.REST_REQ_POST,
1427
payload: {

src/config/schema/success-messages.schema.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Text from 'antd/lib/typography/Text';
22
import React from 'react';
33

44
const successMsg = payload => ({
5+
ALL_PIPELINE_JOBS_STOP: `${payload.name}'s Jobs have been stopped`,
56
ALGORITHM_APPLY: 'Algorithm Applied, check Algorithms table',
67
ALGORITHM_RUN: (
78
<>

src/styles/themes/CommonColor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const COMMON_COLOR = () => {
111111
[PIPELINE.COMPLETED]: COLOR.greenLight,
112112
[PIPELINE.CRASHED]: COLOR.redPale,
113113
[PIPELINE.FAILED]: COLOR.red,
114-
[PIPELINE.PENDING]: COLOR.white,
114+
[PIPELINE.PENDING]: COLOR.grey,
115115
[PIPELINE.RESUMED]: COLOR.blueLight,
116116
[PIPELINE.RUNNING]: COLOR.blue,
117117
[PIPELINE.STALLED]: COLOR.darkGrey,

src/utils/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export {
77
setLsItem,
88
} from './localStorage';
99
export { default as mapObjValues } from './mapObjValues';
10-
export { deleteConfirmAction } from './modal';
10+
export { deleteConfirmAction, stopConfirmAction } from './modal';
1111
export { default as notification, copyToClipboard } from './notification';
1212
export { default as selector } from './selector';
1313
export {

src/utils/modal.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Modal } from 'antd';
1+
import { Modal, message } from 'antd';
2+
import successMsg from 'config/schema/success-messages.schema';
23
import Text from 'antd/lib/typography/Text';
34
import React from 'react';
45

@@ -19,3 +20,25 @@ export const deleteConfirmAction = (action, { name }) => {
1920
},
2021
});
2122
};
23+
24+
export const stopConfirmAction = (action, { name }) => {
25+
Modal.confirm({
26+
title: 'WARNING stop all jobs',
27+
content: (
28+
<>
29+
Are you sure you want to stop all jobs of pipeline{' '}
30+
<Text strong>{name}</Text>?
31+
</>
32+
),
33+
okText: 'Confirm',
34+
okType: 'danger',
35+
cancelText: 'Cancel',
36+
onOk() {
37+
action(name, {
38+
onSuccess: () => {
39+
message.success(successMsg({ name }).ALL_PIPELINE_JOBS_STOP);
40+
},
41+
});
42+
},
43+
});
44+
};

0 commit comments

Comments
 (0)