forked from theforeman/foreman-tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskDetails.js
More file actions
149 lines (142 loc) · 4.09 KB
/
TaskDetails.js
File metadata and controls
149 lines (142 loc) · 4.09 KB
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
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { Tab, Tabs } from 'patternfly-react';
import { translate as __, sprintf } from 'foremanReact/common/I18n';
import { STATUS } from 'foremanReact/constants';
import MessageBox from 'foremanReact/components/common/MessageBox';
import Task from './Components/Task';
import RunningSteps from './Components/RunningSteps';
import Errors from './Components/Errors';
import Locks from './Components/Locks';
import Raw from './Components/Raw';
import Dependencies from './Components/Dependencies';
import { getTaskID } from './TasksDetailsHelper';
import { TaskSkeleton } from './Components/TaskSkeleton';
import './TaskDetails.scss';
const TaskDetails = ({
executionPlan,
failedSteps,
runningSteps,
locks,
links,
dependsOn,
blocks,
cancelStep,
taskReloadStart,
taskReloadStop,
APIerror,
...props
}) => {
const id = getTaskID();
const { taskReload, status, isLoading } = props;
useEffect(() => {
taskReloadStart(id);
return () => {
taskReloadStop();
};
}, [id, taskReloadStart, taskReloadStop]);
const taskProgressToggle = () => {
if (taskReload) {
taskReloadStop();
} else {
taskReloadStart(id);
}
};
if (status === STATUS.ERROR) {
return (
<MessageBox
key="task-details-error"
icontype="error-circle-o"
msg={sprintf(__('Could not receive data: %s'), APIerror?.message)}
/>
);
}
const resumable = executionPlan ? executionPlan.state === 'paused' : false;
const cancellable = executionPlan ? executionPlan.cancellable : false;
return (
<div className="task-details-react well">
<Tabs defaultActiveKey={1} animation={false} id="task-details-tabs">
<Tab eventKey={1} title={__('Task')}>
{isLoading ? (
<TaskSkeleton />
) : (
<Task
{...{
...props,
cancellable,
resumable,
id,
status,
taskProgressToggle,
taskReloadStart,
}}
/>
)}
</Tab>
<Tab eventKey={2} disabled={isLoading} title={__('Running Steps')}>
<RunningSteps
runningSteps={runningSteps}
id={id}
cancelStep={cancelStep}
taskReload={taskReload}
taskReloadStart={taskReloadStart}
/>
</Tab>
<Tab eventKey={3} disabled={isLoading} title={__('Errors')}>
<Errors executionPlan={executionPlan} failedSteps={failedSteps} />
</Tab>
<Tab eventKey={4} disabled={isLoading} title={__('Locks')}>
<Locks locks={locks.concat(links)} />
</Tab>
<Tab eventKey={5} disabled={isLoading} title={__('Dependencies')}>
<Dependencies dependsOn={dependsOn} blocks={blocks} />
</Tab>
<Tab eventKey={6} disabled={isLoading} title={__('Raw')}>
<Raw
id={id}
label={props.label}
startedAt={props.startedAt}
endedAt={props.endedAt}
input={props.input}
output={props.output}
externalId={props.externalId}
/>
</Tab>
</Tabs>
</div>
);
};
TaskDetails.propTypes = {
label: PropTypes.string,
runningSteps: PropTypes.array,
cancelStep: PropTypes.func.isRequired,
taskReload: PropTypes.bool.isRequired,
status: PropTypes.oneOf(Object.keys(STATUS)),
APIerror: PropTypes.object,
taskReloadStop: PropTypes.func.isRequired,
taskReloadStart: PropTypes.func.isRequired,
links: PropTypes.array,
dependsOn: PropTypes.array,
blocks: PropTypes.array,
...Task.propTypes,
...Errors.propTypes,
...Locks.propTypes,
...Dependencies.propTypes,
...Raw.propTypes,
};
TaskDetails.defaultProps = {
label: '',
runningSteps: [],
APIerror: null,
status: STATUS.PENDING,
links: [],
dependsOn: [],
blocks: [],
...Task.defaultProps,
...RunningSteps.defaultProps,
...Errors.defaultProps,
...Locks.defaultProps,
...Dependencies.defaultProps,
...Raw.defaultProps,
};
export default TaskDetails;