foreman-tasks 2.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/js_tests.yml +31 -0
- data/.github/workflows/ruby_tests.yml +74 -0
- data/.rubocop.yml +12 -4
- data/.rubocop_todo.yml +32 -25
- data/Gemfile +5 -0
- data/app/controllers/foreman_tasks/api/tasks_controller.rb +36 -60
- data/app/controllers/foreman_tasks/concerns/parameters/triggering.rb +1 -1
- data/app/controllers/foreman_tasks/recurring_logics_controller.rb +7 -0
- data/app/controllers/foreman_tasks/tasks_controller.rb +6 -3
- data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +3 -3
- data/app/lib/actions/proxy_action.rb +1 -1
- data/app/models/foreman_tasks/recurring_logic.rb +1 -1
- data/app/models/foreman_tasks/task.rb +11 -0
- data/app/models/foreman_tasks/task/dynflow_task.rb +29 -33
- data/app/models/foreman_tasks/task/status_explicator.rb +1 -1
- data/app/models/foreman_tasks/triggering.rb +1 -1
- data/app/models/setting/foreman_tasks.rb +9 -9
- data/app/services/foreman_tasks/dashboard_table_filter.rb +5 -1
- data/app/views/foreman_tasks/api/tasks/index.json.rabl +2 -0
- data/app/views/foreman_tasks/api/tasks/show.json.rabl +2 -0
- data/app/views/foreman_tasks/layouts/react.html.erb +1 -2
- data/app/views/foreman_tasks/recurring_logics/index.html.erb +3 -1
- data/app/views/foreman_tasks/tasks/show.html.erb +1 -6
- data/config/routes.rb +2 -1
- data/db/migrate/20200517215015_rename_bookmarks_controller.rb +2 -2
- data/db/migrate/20200611090846_add_task_lock_index_on_resource_type_and_task_id.rb +9 -0
- data/db/seeds.d/30-notification_blueprints.rb +7 -7
- data/db/seeds.d/61-foreman_tasks_bookmarks.rb +1 -1
- data/foreman-tasks.gemspec +1 -0
- data/lib/foreman_tasks/cleaner.rb +4 -6
- data/lib/foreman_tasks/dynflow/configuration.rb +1 -1
- data/lib/foreman_tasks/dynflow/persistence.rb +4 -6
- data/lib/foreman_tasks/engine.rb +2 -7
- data/lib/foreman_tasks/tasks/cleanup.rake +2 -2
- data/lib/foreman_tasks/tasks/dynflow.rake +6 -0
- data/lib/foreman_tasks/tasks/export_tasks.rake +1 -1
- data/lib/foreman_tasks/version.rb +1 -1
- data/locale/en/LC_MESSAGES/foreman_tasks.mo +0 -0
- data/locale/en/foreman_tasks.po +50 -20
- data/locale/foreman_tasks.pot +173 -126
- data/locale/fr/LC_MESSAGES/foreman_tasks.mo +0 -0
- data/locale/fr/foreman_tasks.po +817 -0
- data/locale/ja/LC_MESSAGES/foreman_tasks.mo +0 -0
- data/locale/ja/foreman_tasks.po +817 -0
- data/locale/zh_CN/LC_MESSAGES/foreman_tasks.mo +0 -0
- data/locale/zh_CN/foreman_tasks.po +816 -0
- data/package.json +1 -1
- data/script/npm_link_foreman_js.sh +26 -0
- data/test/controllers/api/recurring_logics_controller_test.rb +1 -1
- data/test/controllers/api/tasks_controller_test.rb +17 -7
- data/test/controllers/tasks_controller_test.rb +6 -6
- data/test/core/unit/runner_test.rb +20 -20
- data/test/core/unit/task_launcher_test.rb +8 -8
- data/test/helpers/foreman_tasks/foreman_tasks_helper_test.rb +7 -7
- data/test/helpers/foreman_tasks/tasks_helper_test.rb +3 -3
- data/test/lib/actions/middleware/keep_current_request_id_test.rb +3 -3
- data/test/support/history_tasks_builder.rb +1 -1
- data/test/tasks/generate_task_actions_test.rb +1 -1
- data/test/unit/actions/action_with_sub_plans_test.rb +2 -2
- data/test/unit/actions/bulk_action_test.rb +6 -6
- data/test/unit/actions/proxy_action_test.rb +20 -20
- data/test/unit/actions/recurring_action_test.rb +30 -32
- data/test/unit/cleaner_test.rb +24 -24
- data/test/unit/dashboard_table_filter_test.rb +5 -5
- data/test/unit/otp_manager_test.rb +2 -2
- data/test/unit/proxy_selector_test.rb +9 -9
- data/test/unit/recurring_logic_test.rb +32 -32
- data/test/unit/remote_task_test.rb +2 -2
- data/test/unit/task_groups_test.rb +4 -4
- data/test/unit/task_test.rb +18 -18
- data/test/unit/triggering_test.rb +8 -8
- data/test/unit/troubleshooting_help_generator_test.rb +6 -6
- data/test/unit/ui_notifications_test.rb +11 -11
- data/webpack/ForemanTasks/Components/TaskActions/TaskAction.test.js +2 -2
- data/webpack/ForemanTasks/Components/TaskActions/index.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/RunningSteps.js +17 -3
- data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +8 -153
- data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskButtons.js +168 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskInfo.js +6 -7
- data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskSkeleton.js +48 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/RunningSteps.test.js +8 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +13 -70
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskButtons.test.js +95 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/RunningSteps.test.js.snap +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +78 -208
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskButtons.test.js.snap +212 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskInfo.test.js.snap +8 -4
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.js +100 -53
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.scss +13 -14
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +57 -95
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsConstants.js +3 -12
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +57 -28
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.fixtures.js +8 -0
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +8 -1
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js +6 -6
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +84 -12
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsActions.test.js.snap +25 -21
- data/webpack/ForemanTasks/Components/TaskDetails/index.js +8 -3
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.scss +4 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/OtherInfo.js +53 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/OtherInfo.test.js +14 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.js +27 -19
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.scss +14 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.test.js +1 -34
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/{StoppedTasksCardHelper.js → StoppedTasksCardTable.js} +28 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardTable.test.js +54 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/OtherInfo.test.js.snap +48 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/StoppedTasksCard.test.js.snap +60 -1367
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/StoppedTasksCardTable.test.js.snap +960 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/__snapshots__/TasksCardsGrid.test.js.snap +14 -11
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardActions.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardConstants.js +2 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js +17 -11
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardActions.test.js +2 -2
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardSelectors.test.js +26 -14
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboard.test.js.snap +14 -11
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboardSelectors.test.js.snap +38 -22
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalSelectors.test.js +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalSelectors.test.js.snap +2 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksBulkActions.js +25 -8
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +3 -3
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +6 -3
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.scss +0 -10
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksBulkActions.test.js +15 -2
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTablePage.test.js +2 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksBulkActions.test.js.snap +48 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +39 -7
- data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/actionCellFormatter.test.js.snap +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/selectionCellFormatter.test.js.snap +2 -0
- data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/actionCellFormatter.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/selectionCellFormatter.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/formatters/actionCellFormatter.js +10 -7
- data/webpack/ForemanTasks/Components/TasksTable/formatters/selectionCellFormatter.js +7 -0
- data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js +39 -31
- data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js +17 -8
- data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap +8 -0
- data/webpack/ForemanTasks/Components/common/urlHelpers.js +7 -0
- data/webpack/ForemanTasks/ForemanTasksReducers.js +0 -2
- data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
- data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +10 -0
- data/webpack/__mocks__/foremanReact/redux/API/index.js +10 -0
- data/webpack/__mocks__/foremanReact/redux/middlewares/IntervalMiddleware.js +5 -0
- metadata +35 -17
- data/.travis.yml +0 -5
- data/app/assets/stylesheets/foreman_tasks/tasks.scss +0 -9
- data/script/travis_run_js_tests.sh +0 -7
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js +0 -38
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsReducer.test.js +0 -33
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsReducer.test.js.snap +0 -26
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/integration.test.js.snap +0 -122
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/integration.test.js +0 -67
- data/webpack/__mocks__/foremanReact/API.js +0 -7
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Col, Button } from 'patternfly-react';
|
|
4
|
+
import { useForemanModal } from 'foremanReact/components/ForemanModal/ForemanModalHooks';
|
|
5
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
|
6
|
+
import {
|
|
7
|
+
UNLOCK_MODAL,
|
|
8
|
+
FORCE_UNLOCK_MODAL,
|
|
9
|
+
} from '../../TaskActions/TaskActionsConstants';
|
|
10
|
+
|
|
11
|
+
export const TaskButtons = ({
|
|
12
|
+
canEdit,
|
|
13
|
+
dynflowEnableConsole,
|
|
14
|
+
taskReloadStart,
|
|
15
|
+
taskProgressToggle,
|
|
16
|
+
taskReload,
|
|
17
|
+
externalId,
|
|
18
|
+
id,
|
|
19
|
+
action,
|
|
20
|
+
state,
|
|
21
|
+
resumable,
|
|
22
|
+
cancellable,
|
|
23
|
+
hasSubTasks,
|
|
24
|
+
parentTask,
|
|
25
|
+
cancelTaskRequest,
|
|
26
|
+
resumeTaskRequest,
|
|
27
|
+
}) => {
|
|
28
|
+
const unlockModalActions = useForemanModal({
|
|
29
|
+
id: UNLOCK_MODAL,
|
|
30
|
+
});
|
|
31
|
+
const forceUnlockModalActions = useForemanModal({
|
|
32
|
+
id: FORCE_UNLOCK_MODAL,
|
|
33
|
+
});
|
|
34
|
+
const editActionsTitle = canEdit
|
|
35
|
+
? undefined
|
|
36
|
+
: __('You do not have permission');
|
|
37
|
+
const dynflowTitle = dynflowEnableConsole
|
|
38
|
+
? undefined
|
|
39
|
+
: `dynflow_enable_console ${__('Setting is off')}`;
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Col xs={12}>
|
|
43
|
+
<Button
|
|
44
|
+
className="reload-button"
|
|
45
|
+
bsSize="small"
|
|
46
|
+
onClick={taskProgressToggle}
|
|
47
|
+
>
|
|
48
|
+
<span
|
|
49
|
+
className={`glyphicon glyphicon-refresh ${taskReload ? 'spin' : ''}`}
|
|
50
|
+
/>
|
|
51
|
+
{__(`${taskReload ? 'Stop' : 'Start'} auto-reloading`)}
|
|
52
|
+
</Button>
|
|
53
|
+
<Button
|
|
54
|
+
className="dynflow-button"
|
|
55
|
+
bsSize="small"
|
|
56
|
+
href={`/foreman_tasks/dynflow/${externalId}`}
|
|
57
|
+
disabled={!dynflowEnableConsole}
|
|
58
|
+
rel="noopener noreferrer"
|
|
59
|
+
target="_blank"
|
|
60
|
+
>
|
|
61
|
+
<span title={dynflowTitle} data-original-title={dynflowTitle}>
|
|
62
|
+
{__('Dynflow console')}
|
|
63
|
+
</span>
|
|
64
|
+
</Button>
|
|
65
|
+
<Button
|
|
66
|
+
className="resume-button"
|
|
67
|
+
bsSize="small"
|
|
68
|
+
title={editActionsTitle}
|
|
69
|
+
data-original-title={editActionsTitle}
|
|
70
|
+
disabled={!canEdit || !resumable}
|
|
71
|
+
onClick={() => {
|
|
72
|
+
if (!taskReload) {
|
|
73
|
+
taskReloadStart(id);
|
|
74
|
+
}
|
|
75
|
+
resumeTaskRequest(id, action);
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
{__('Resume')}
|
|
79
|
+
</Button>
|
|
80
|
+
<Button
|
|
81
|
+
className="cancel-button"
|
|
82
|
+
bsSize="small"
|
|
83
|
+
title={editActionsTitle}
|
|
84
|
+
data-original-title={editActionsTitle}
|
|
85
|
+
disabled={!canEdit || !cancellable}
|
|
86
|
+
onClick={() => {
|
|
87
|
+
if (!taskReload) {
|
|
88
|
+
taskReloadStart(id);
|
|
89
|
+
}
|
|
90
|
+
cancelTaskRequest(id, action);
|
|
91
|
+
}}
|
|
92
|
+
>
|
|
93
|
+
{__('Cancel')}
|
|
94
|
+
</Button>
|
|
95
|
+
{parentTask && (
|
|
96
|
+
<Button
|
|
97
|
+
className="parent-button"
|
|
98
|
+
bsSize="small"
|
|
99
|
+
href={`/foreman_tasks/tasks/${parentTask}`}
|
|
100
|
+
>
|
|
101
|
+
{__('Parent task')}
|
|
102
|
+
</Button>
|
|
103
|
+
)}
|
|
104
|
+
{hasSubTasks && (
|
|
105
|
+
<Button
|
|
106
|
+
className="subtask-button"
|
|
107
|
+
bsSize="small"
|
|
108
|
+
href={`/foreman_tasks/tasks/${id}/sub_tasks`}
|
|
109
|
+
>
|
|
110
|
+
{__('Sub tasks')}
|
|
111
|
+
</Button>
|
|
112
|
+
)}
|
|
113
|
+
<Button
|
|
114
|
+
className="unlock-button"
|
|
115
|
+
bsSize="small"
|
|
116
|
+
disabled={!canEdit || state !== 'paused'}
|
|
117
|
+
onClick={unlockModalActions.setModalOpen}
|
|
118
|
+
title={editActionsTitle}
|
|
119
|
+
data-original-title={editActionsTitle}
|
|
120
|
+
>
|
|
121
|
+
{__('Unlock')}
|
|
122
|
+
</Button>
|
|
123
|
+
<Button
|
|
124
|
+
className="force-unlock-button"
|
|
125
|
+
bsSize="small"
|
|
126
|
+
disabled={!canEdit || state === 'stopped'}
|
|
127
|
+
onClick={forceUnlockModalActions.setModalOpen}
|
|
128
|
+
title={editActionsTitle}
|
|
129
|
+
data-original-title={editActionsTitle}
|
|
130
|
+
>
|
|
131
|
+
{__('Force Unlock')}
|
|
132
|
+
</Button>
|
|
133
|
+
</Col>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
TaskButtons.propTypes = {
|
|
138
|
+
canEdit: PropTypes.bool,
|
|
139
|
+
dynflowEnableConsole: PropTypes.bool,
|
|
140
|
+
taskReloadStart: PropTypes.func.isRequired,
|
|
141
|
+
taskProgressToggle: PropTypes.func.isRequired,
|
|
142
|
+
taskReload: PropTypes.bool,
|
|
143
|
+
externalId: PropTypes.string,
|
|
144
|
+
id: PropTypes.string.isRequired,
|
|
145
|
+
action: PropTypes.string,
|
|
146
|
+
state: PropTypes.string,
|
|
147
|
+
resumable: PropTypes.bool,
|
|
148
|
+
cancellable: PropTypes.bool,
|
|
149
|
+
hasSubTasks: PropTypes.bool,
|
|
150
|
+
parentTask: PropTypes.string,
|
|
151
|
+
cancelTaskRequest: PropTypes.func,
|
|
152
|
+
resumeTaskRequest: PropTypes.func,
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
TaskButtons.defaultProps = {
|
|
156
|
+
canEdit: false,
|
|
157
|
+
dynflowEnableConsole: false,
|
|
158
|
+
taskReload: false,
|
|
159
|
+
externalId: '',
|
|
160
|
+
action: '',
|
|
161
|
+
state: '',
|
|
162
|
+
resumable: false,
|
|
163
|
+
cancellable: false,
|
|
164
|
+
hasSubTasks: false,
|
|
165
|
+
parentTask: '',
|
|
166
|
+
cancelTaskRequest: () => null,
|
|
167
|
+
resumeTaskRequest: () => null,
|
|
168
|
+
};
|
|
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { Grid, Row, Col, ProgressBar } from 'patternfly-react';
|
|
4
4
|
import { translate as __ } from 'foremanReact/common/I18n';
|
|
5
5
|
import RelativeDateTime from 'foremanReact/components/common/dates/RelativeDateTime';
|
|
6
|
-
import ReactHtmlParser from 'react-html-parser';
|
|
7
6
|
|
|
8
7
|
class TaskInfo extends Component {
|
|
9
8
|
isDelayed = () => {
|
|
@@ -59,7 +58,7 @@ class TaskInfo extends Component {
|
|
|
59
58
|
state,
|
|
60
59
|
help,
|
|
61
60
|
output,
|
|
62
|
-
|
|
61
|
+
errors,
|
|
63
62
|
progress,
|
|
64
63
|
username,
|
|
65
64
|
usernamePath,
|
|
@@ -171,7 +170,7 @@ class TaskInfo extends Component {
|
|
|
171
170
|
<b>{__('Troubleshooting')}</b>
|
|
172
171
|
</span>
|
|
173
172
|
</p>
|
|
174
|
-
<p
|
|
173
|
+
<p dangerouslySetInnerHTML={{ __html: help }} />
|
|
175
174
|
</Col>
|
|
176
175
|
</Row>
|
|
177
176
|
)}
|
|
@@ -187,7 +186,7 @@ class TaskInfo extends Component {
|
|
|
187
186
|
</Col>
|
|
188
187
|
</Row>
|
|
189
188
|
)}
|
|
190
|
-
{
|
|
189
|
+
{errors && errors.length > 0 && (
|
|
191
190
|
<Row>
|
|
192
191
|
<Col xs={12}>
|
|
193
192
|
<div>
|
|
@@ -195,7 +194,7 @@ class TaskInfo extends Component {
|
|
|
195
194
|
<b>{__('Errors:')}</b>
|
|
196
195
|
</span>
|
|
197
196
|
</div>
|
|
198
|
-
<pre>{
|
|
197
|
+
<pre>{errors}</pre>
|
|
199
198
|
</Col>
|
|
200
199
|
</Row>
|
|
201
200
|
)}
|
|
@@ -213,7 +212,7 @@ TaskInfo.propTypes = {
|
|
|
213
212
|
startedAt: PropTypes.string,
|
|
214
213
|
state: PropTypes.string,
|
|
215
214
|
help: PropTypes.string,
|
|
216
|
-
|
|
215
|
+
errors: PropTypes.array,
|
|
217
216
|
progress: PropTypes.number,
|
|
218
217
|
username: PropTypes.string,
|
|
219
218
|
usernamePath: PropTypes.string,
|
|
@@ -232,7 +231,7 @@ TaskInfo.defaultProps = {
|
|
|
232
231
|
startedAt: '',
|
|
233
232
|
state: '',
|
|
234
233
|
help: '',
|
|
235
|
-
|
|
234
|
+
errors: [],
|
|
236
235
|
progress: 0,
|
|
237
236
|
username: '',
|
|
238
237
|
usernamePath: '',
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Skeleton from 'react-loading-skeleton';
|
|
3
|
+
import { Grid, Row, Col } from 'patternfly-react';
|
|
4
|
+
|
|
5
|
+
export const TaskSkeleton = () => {
|
|
6
|
+
const details = [1, 2, 3, 4, 5, 6];
|
|
7
|
+
return (
|
|
8
|
+
<Grid>
|
|
9
|
+
<br />
|
|
10
|
+
<Row>
|
|
11
|
+
<Col>
|
|
12
|
+
<Skeleton />
|
|
13
|
+
</Col>
|
|
14
|
+
</Row>
|
|
15
|
+
{details.map((items, key) => (
|
|
16
|
+
<Row key={key}>
|
|
17
|
+
<Col md={2} sm={6}>
|
|
18
|
+
<Skeleton />
|
|
19
|
+
</Col>
|
|
20
|
+
<Col md={5} sm={6}>
|
|
21
|
+
<Skeleton />
|
|
22
|
+
</Col>
|
|
23
|
+
<Col md={2} sm={6}>
|
|
24
|
+
<Skeleton />
|
|
25
|
+
</Col>
|
|
26
|
+
<Col md={3} sm={6}>
|
|
27
|
+
<Skeleton />
|
|
28
|
+
</Col>
|
|
29
|
+
</Row>
|
|
30
|
+
))}
|
|
31
|
+
<br />
|
|
32
|
+
<Row>
|
|
33
|
+
<Col xs={6}>
|
|
34
|
+
<div className="progress-description">
|
|
35
|
+
<Skeleton />
|
|
36
|
+
</div>
|
|
37
|
+
</Col>
|
|
38
|
+
<Col xs={3} xsOffset={3} className="progress-label-top-right">
|
|
39
|
+
<Skeleton />
|
|
40
|
+
</Col>
|
|
41
|
+
<Col xs={12}>
|
|
42
|
+
<Skeleton />
|
|
43
|
+
</Col>
|
|
44
|
+
</Row>
|
|
45
|
+
<br />
|
|
46
|
+
</Grid>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -2,9 +2,16 @@ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
|
|
2
2
|
|
|
3
3
|
import RunningSteps from '../RunningSteps';
|
|
4
4
|
|
|
5
|
+
const minProps = {
|
|
6
|
+
id: 'task-id1',
|
|
7
|
+
taskReload: true,
|
|
8
|
+
cancelStep: jest.fn(),
|
|
9
|
+
taskReloadStart: jest.fn(),
|
|
10
|
+
};
|
|
5
11
|
const fixtures = {
|
|
6
|
-
'render
|
|
12
|
+
'render with min Props': minProps,
|
|
7
13
|
'render with Props': {
|
|
14
|
+
...minProps,
|
|
8
15
|
executionPlan: {
|
|
9
16
|
state: 'paused',
|
|
10
17
|
cancellable: false,
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
testComponentSnapshotsWithFixtures,
|
|
4
|
-
mount,
|
|
5
|
-
shallow,
|
|
6
|
-
} from '@theforeman/test';
|
|
7
|
-
import { useForemanModal } from 'foremanReact/components/ForemanModal/ForemanModalHooks';
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
|
2
|
+
import { STATUS } from 'foremanReact/constants';
|
|
8
3
|
import Task from '../Task';
|
|
9
|
-
import {
|
|
10
|
-
UNLOCK_MODAL,
|
|
11
|
-
FORCE_UNLOCK_MODAL,
|
|
12
|
-
} from '../../../TaskActions/TaskActionsConstants';
|
|
13
4
|
|
|
14
5
|
const fixtures = {
|
|
15
|
-
'render
|
|
6
|
+
'render with minimal Props': {
|
|
7
|
+
id: 'test',
|
|
8
|
+
taskReloadStart: jest.fn(),
|
|
9
|
+
taskProgressToggle: jest.fn(),
|
|
10
|
+
},
|
|
16
11
|
'render with some Props': {
|
|
17
12
|
id: 'test',
|
|
18
13
|
state: 'paused',
|
|
@@ -20,64 +15,12 @@ const fixtures = {
|
|
|
20
15
|
dynflowEnableConsole: true,
|
|
21
16
|
parentTask: 'parent-id',
|
|
22
17
|
taskReload: true,
|
|
18
|
+
canEdit: true,
|
|
19
|
+
status: STATUS.RESOLVED,
|
|
20
|
+
taskProgressToggle: jest.fn(),
|
|
21
|
+
taskReloadStart: jest.fn(),
|
|
23
22
|
},
|
|
24
23
|
};
|
|
25
24
|
|
|
26
|
-
describe('Task', () =>
|
|
27
|
-
|
|
28
|
-
testComponentSnapshotsWithFixtures(Task, fixtures));
|
|
29
|
-
describe('click test', () => {
|
|
30
|
-
const setModalOpen = jest.fn();
|
|
31
|
-
useForemanModal.mockImplementation(id => ({
|
|
32
|
-
setModalOpen: () => setModalOpen(id),
|
|
33
|
-
}));
|
|
34
|
-
const cancelTaskRequest = jest.fn();
|
|
35
|
-
const resumeTaskRequest = jest.fn();
|
|
36
|
-
const taskReloadStart = jest.fn();
|
|
37
|
-
const id = 'some-id';
|
|
38
|
-
const action = 'some-action';
|
|
39
|
-
const props = {
|
|
40
|
-
taskReload: false,
|
|
41
|
-
taskReloadStart,
|
|
42
|
-
id,
|
|
43
|
-
action,
|
|
44
|
-
cancelTaskRequest,
|
|
45
|
-
resumeTaskRequest,
|
|
46
|
-
};
|
|
47
|
-
afterEach(() => {
|
|
48
|
-
jest.clearAllMocks();
|
|
49
|
-
});
|
|
50
|
-
it('reload', () => {
|
|
51
|
-
const component = mount(<Task {...props} />);
|
|
52
|
-
const reloadButton = component.find('.reload-button').at(0);
|
|
53
|
-
reloadButton.simulate('click');
|
|
54
|
-
expect(taskReloadStart).toBeCalled();
|
|
55
|
-
});
|
|
56
|
-
it('resume', () => {
|
|
57
|
-
const component = shallow(<Task {...props} />);
|
|
58
|
-
const resumeButton = component.find('.resume-button').at(0);
|
|
59
|
-
resumeButton.props().onClick();
|
|
60
|
-
expect(taskReloadStart).toBeCalled();
|
|
61
|
-
expect(resumeTaskRequest).toBeCalledWith(id, action);
|
|
62
|
-
});
|
|
63
|
-
it('cancel', () => {
|
|
64
|
-
const component = shallow(<Task {...props} />);
|
|
65
|
-
const cancelButton = component.find('.cancel-button').at(0);
|
|
66
|
-
cancelButton.props().onClick();
|
|
67
|
-
expect(taskReloadStart).toBeCalled();
|
|
68
|
-
expect(cancelTaskRequest).toBeCalledWith(id, action);
|
|
69
|
-
});
|
|
70
|
-
it('unlock', () => {
|
|
71
|
-
const component = shallow(<Task {...props} />);
|
|
72
|
-
const unlockButton = component.find('.unlock-button').at(0);
|
|
73
|
-
unlockButton.props().onClick();
|
|
74
|
-
expect(setModalOpen).toBeCalledWith({ id: UNLOCK_MODAL });
|
|
75
|
-
});
|
|
76
|
-
it('focrce unlock', () => {
|
|
77
|
-
const component = shallow(<Task {...props} />);
|
|
78
|
-
const forceUnlockButton = component.find('.force-unlock-button').at(0);
|
|
79
|
-
forceUnlockButton.props().onClick();
|
|
80
|
-
expect(setModalOpen).toBeCalledWith({ id: FORCE_UNLOCK_MODAL });
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
});
|
|
25
|
+
describe('Task rendering', () =>
|
|
26
|
+
testComponentSnapshotsWithFixtures(Task, fixtures));
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
testComponentSnapshotsWithFixtures,
|
|
4
|
+
mount,
|
|
5
|
+
shallow,
|
|
6
|
+
} from '@theforeman/test';
|
|
7
|
+
import { useForemanModal } from 'foremanReact/components/ForemanModal/ForemanModalHooks';
|
|
8
|
+
import { STATUS } from 'foremanReact/constants';
|
|
9
|
+
import { TaskButtons } from '../TaskButtons';
|
|
10
|
+
import {
|
|
11
|
+
UNLOCK_MODAL,
|
|
12
|
+
FORCE_UNLOCK_MODAL,
|
|
13
|
+
} from '../../../TaskActions/TaskActionsConstants';
|
|
14
|
+
|
|
15
|
+
const fixtures = {
|
|
16
|
+
'render with minimal Props': {
|
|
17
|
+
id: 'test',
|
|
18
|
+
taskReloadStart: jest.fn(),
|
|
19
|
+
taskProgressToggle: jest.fn(),
|
|
20
|
+
},
|
|
21
|
+
'render with some Props': {
|
|
22
|
+
id: 'test',
|
|
23
|
+
state: 'paused',
|
|
24
|
+
hasSubTasks: true,
|
|
25
|
+
dynflowEnableConsole: true,
|
|
26
|
+
parentTask: 'parent-id',
|
|
27
|
+
taskReload: true,
|
|
28
|
+
canEdit: true,
|
|
29
|
+
status: STATUS.RESOLVED,
|
|
30
|
+
taskReloadStart: jest.fn(),
|
|
31
|
+
taskProgressToggle: jest.fn(),
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
describe('Task', () => {
|
|
36
|
+
describe('rendering', () =>
|
|
37
|
+
testComponentSnapshotsWithFixtures(TaskButtons, fixtures));
|
|
38
|
+
describe('click test', () => {
|
|
39
|
+
const setModalOpen = jest.fn();
|
|
40
|
+
useForemanModal.mockImplementation(id => ({
|
|
41
|
+
setModalOpen: () => setModalOpen(id),
|
|
42
|
+
}));
|
|
43
|
+
const cancelTaskRequest = jest.fn();
|
|
44
|
+
const resumeTaskRequest = jest.fn();
|
|
45
|
+
const taskProgressToggle = jest.fn();
|
|
46
|
+
const taskReloadStart = jest.fn();
|
|
47
|
+
const id = 'some-id';
|
|
48
|
+
const action = 'some-action';
|
|
49
|
+
const props = {
|
|
50
|
+
taskReload: false,
|
|
51
|
+
id,
|
|
52
|
+
action,
|
|
53
|
+
cancelTaskRequest,
|
|
54
|
+
resumeTaskRequest,
|
|
55
|
+
taskProgressToggle,
|
|
56
|
+
taskReloadStart,
|
|
57
|
+
status: STATUS.RESOLVED,
|
|
58
|
+
};
|
|
59
|
+
afterEach(() => {
|
|
60
|
+
jest.clearAllMocks();
|
|
61
|
+
});
|
|
62
|
+
it('reload', () => {
|
|
63
|
+
const component = mount(<TaskButtons {...props} />);
|
|
64
|
+
const reloadButton = component.find('.reload-button').at(0);
|
|
65
|
+
reloadButton.simulate('click');
|
|
66
|
+
expect(taskProgressToggle).toBeCalled();
|
|
67
|
+
});
|
|
68
|
+
it('resume', () => {
|
|
69
|
+
const component = shallow(<TaskButtons {...props} />);
|
|
70
|
+
const resumeButton = component.find('.resume-button').at(0);
|
|
71
|
+
resumeButton.props().onClick();
|
|
72
|
+
expect(taskReloadStart).toBeCalled();
|
|
73
|
+
expect(resumeTaskRequest).toBeCalledWith(id, action);
|
|
74
|
+
});
|
|
75
|
+
it('cancel', () => {
|
|
76
|
+
const component = shallow(<TaskButtons {...props} />);
|
|
77
|
+
const cancelButton = component.find('.cancel-button').at(0);
|
|
78
|
+
cancelButton.props().onClick();
|
|
79
|
+
expect(taskReloadStart).toBeCalled();
|
|
80
|
+
expect(cancelTaskRequest).toBeCalledWith(id, action);
|
|
81
|
+
});
|
|
82
|
+
it('unlock', () => {
|
|
83
|
+
const component = shallow(<TaskButtons {...props} />);
|
|
84
|
+
const unlockButton = component.find('.unlock-button').at(0);
|
|
85
|
+
unlockButton.props().onClick();
|
|
86
|
+
expect(setModalOpen).toBeCalledWith({ id: UNLOCK_MODAL });
|
|
87
|
+
});
|
|
88
|
+
it('focrce unlock', () => {
|
|
89
|
+
const component = shallow(<TaskButtons {...props} />);
|
|
90
|
+
const forceUnlockButton = component.find('.force-unlock-button').at(0);
|
|
91
|
+
forceUnlockButton.props().onClick();
|
|
92
|
+
expect(setModalOpen).toBeCalledWith({ id: FORCE_UNLOCK_MODAL });
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|