foreman-tasks 1.1.2 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +2 -0
- data/app/controllers/foreman_tasks/api/tasks_controller.rb +33 -1
- data/app/controllers/foreman_tasks/tasks_controller.rb +9 -14
- data/app/lib/actions/proxy_action.rb +1 -1
- data/app/models/foreman_tasks/task.rb +4 -0
- data/app/models/foreman_tasks/task/dynflow_task.rb +3 -1
- data/app/models/setting/foreman_tasks.rb +1 -1
- data/app/services/ui_notifications/tasks/task_bulk_stop.rb +36 -0
- data/app/views/foreman_tasks/api/tasks/details.json.rabl +0 -1
- data/app/views/foreman_tasks/api/tasks/show.json.rabl +2 -0
- data/config/routes.rb +1 -0
- data/db/migrate/20200517215015_rename_bookmarks_controller.rb +35 -0
- data/db/migrate/20200519093217_drop_dynflow_allow_dangerous_actions_setting.foreman_tasks.rb +5 -0
- data/db/migrate/20200611090846_add_task_lock_index_on_resource_type_and_task_id.rb +3 -3
- data/db/seeds.d/30-notification_blueprints.rb +7 -0
- data/lib/foreman_tasks/engine.rb +2 -7
- data/lib/foreman_tasks/version.rb +1 -1
- data/locale/action_names.rb +1 -1
- data/locale/en/LC_MESSAGES/foreman_tasks.mo +0 -0
- data/locale/en/foreman_tasks.po +270 -54
- data/locale/foreman_tasks.pot +630 -292
- 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 -0
- data/script/npm_link_foreman_js.sh +26 -0
- data/webpack/ForemanTasks/Components/TaskActions/TaskAction.test.js +60 -0
- data/webpack/ForemanTasks/Components/{TasksTable/TasksTableActionHelpers.js → TaskActions/TaskActionHelpers.js} +21 -6
- data/webpack/ForemanTasks/Components/{TasksTable/__tests__/TasksTableActionHelpers.test.js → TaskActions/TaskActionHelpers.test.js} +2 -2
- data/webpack/ForemanTasks/Components/TaskActions/TaskActionsConstants.js +16 -0
- data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.js +60 -0
- data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.test.js +14 -0
- data/webpack/ForemanTasks/Components/TaskActions/__snapshots__/TaskAction.test.js.snap +233 -0
- data/webpack/ForemanTasks/Components/TaskActions/__snapshots__/UnlockModals.test.js.snap +25 -0
- data/webpack/ForemanTasks/Components/TaskActions/index.js +115 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/RunningSteps.js +17 -3
- data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +149 -167
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/RunningSteps.test.js +8 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +68 -3
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskInfo.test.js +0 -1
- 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 +124 -76
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.js +35 -5
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.scss +3 -14
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +40 -16
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsConstants.js +3 -4
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js +0 -6
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +4 -10
- data/webpack/ForemanTasks/Components/TaskDetails/TasksDetailsHelper.js +6 -1
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.fixtures.js +8 -0
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +7 -1
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js +18 -2
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +30 -13
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsActions.test.js.snap +91 -0
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/integration.test.js +13 -4
- data/webpack/ForemanTasks/Components/TaskDetails/index.js +6 -8
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardActions.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardActions.test.js +2 -2
- data/webpack/ForemanTasks/Components/TasksTable/Components/ActionSelectButton.js +14 -1
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModal.js +83 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalActions.js +106 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalReducer.js +38 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js +46 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModal.test.js +36 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalActions.test.js +205 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalReducer.test.js +27 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalSelectors.test.js +55 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModal.test.js.snap +41 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalReducer.test.js.snap +19 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalSelectors.test.js.snap +32 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/index.js +29 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionSelectButton.test.js +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ActionSelectButton.test.js.snap +11 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksBulkActions.js +135 -35
- data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +13 -9
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +26 -66
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableConstants.js +10 -12
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +30 -96
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableSchema.js +2 -2
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +8 -4
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksBulkActions.test.js +50 -2
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +3 -12
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableActions.test.js +22 -26
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTablePage.test.js +2 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +3 -14
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksBulkActions.test.js.snap +155 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +3 -14
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableActions.test.js.snap +17 -124
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +63 -133
- 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/TasksTable/index.js +2 -2
- data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js +55 -19
- data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js +75 -19
- data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap +88 -21
- data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.scss +9 -0
- data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.test.js +44 -0
- data/webpack/ForemanTasks/Components/common/ClickConfirmation/__snapshots__/ClickConfirmation.test.js.snap +52 -0
- data/webpack/ForemanTasks/Components/common/ClickConfirmation/index.js +59 -66
- data/webpack/ForemanTasks/Components/common/{ToastTypesConstants.js → ToastsHelpers/ToastTypesConstants.js} +0 -0
- data/webpack/ForemanTasks/Components/common/ToastsHelpers/index.js +15 -0
- data/webpack/ForemanTasks/ForemanTasksReducers.js +2 -0
- data/webpack/ForemanTasks/Routes/ForemanTasksRoutes.test.js +2 -1
- data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalHooks.js +2 -2
- data/webpack/__mocks__/foremanReact/components/ForemanModal/index.js +17 -3
- data/webpack/__mocks__/foremanReact/components/common/ActionButtons/ActionButtons.js +3 -0
- data/webpack/__mocks__/foremanReact/{API.js → redux/API.js} +1 -1
- metadata +41 -21
- data/webpack/ForemanTasks/Components/TasksTable/Components/CancelConfirm.js +0 -53
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmationModals.js +0 -56
- data/webpack/ForemanTasks/Components/TasksTable/Components/ResumeConfirm.js +0 -52
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/CancelConfirm.test.js +0 -26
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ConfirmationModals.test.js +0 -24
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ResumeConfirm.test.js +0 -26
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/CancelConfirm.test.js.snap +0 -65
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ConfirmationModals.test.js.snap +0 -30
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ResumeConfirm.test.js.snap +0 -63
- data/webpack/ForemanTasks/Components/common/ActionButtons/CancelButton.js +0 -23
- data/webpack/ForemanTasks/Components/common/ActionButtons/CancelButton.test.js +0 -26
- data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.js +0 -23
- data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.test.js +0 -27
- data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/CancelButton.test.js.snap +0 -15
- data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ResumeButton.test.js.snap +0 -15
@@ -0,0 +1,25 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`ForceUnlockModal render 1`] = `
|
4
|
+
<ClickConfirmation
|
5
|
+
body="Resources for 1 task(s) will be unlocked and will not prevent other tasks from being run. As the task(s) might be still running, it should be avoided to use this unless you are really sure the task(s) got stuck."
|
6
|
+
confirmAction="Force Unlock"
|
7
|
+
confirmType="danger"
|
8
|
+
confirmationMessage="I understand that this may cause harm and have working database backups of all backend services."
|
9
|
+
id="forceUnlockModal"
|
10
|
+
onClick={[MockFunction]}
|
11
|
+
title="Force Unlock"
|
12
|
+
/>
|
13
|
+
`;
|
14
|
+
|
15
|
+
exports[`UnlockModal render 1`] = `
|
16
|
+
<ClickConfirmation
|
17
|
+
body="This will unlock the resources that the task is running against. Please note that this might lead to inconsistent state and should be used with caution, after making sure that the task can't be resumed."
|
18
|
+
confirmAction="Unlock"
|
19
|
+
confirmType="warning"
|
20
|
+
confirmationMessage="I understand that this may cause harm and have working database backups of all backend services."
|
21
|
+
id="unlockModal"
|
22
|
+
onClick={[MockFunction]}
|
23
|
+
title="Unlock"
|
24
|
+
/>
|
25
|
+
`;
|
@@ -0,0 +1,115 @@
|
|
1
|
+
import { sprintf } from 'foremanReact/common/I18n';
|
2
|
+
import { API } from 'foremanReact/redux/API';
|
3
|
+
import { addToast } from 'foremanReact/redux/actions/toasts';
|
4
|
+
import {
|
5
|
+
TASKS_RESUME_REQUEST,
|
6
|
+
TASKS_RESUME_SUCCESS,
|
7
|
+
TASKS_RESUME_FAILURE,
|
8
|
+
TASKS_CANCEL_REQUEST,
|
9
|
+
TASKS_CANCEL_SUCCESS,
|
10
|
+
TASKS_CANCEL_FAILURE,
|
11
|
+
TASKS_FORCE_CANCEL_REQUEST,
|
12
|
+
TASKS_FORCE_CANCEL_SUCCESS,
|
13
|
+
TASKS_FORCE_CANCEL_FAILURE,
|
14
|
+
TASKS_UNLOCK_REQUEST,
|
15
|
+
TASKS_UNLOCK_SUCCESS,
|
16
|
+
TASKS_UNLOCK_FAILURE,
|
17
|
+
} from './TaskActionsConstants';
|
18
|
+
import { infoToastData } from '../common/ToastsHelpers/';
|
19
|
+
import {
|
20
|
+
resumeToastInfo,
|
21
|
+
cancelToastInfo,
|
22
|
+
forceCancelToastInfo,
|
23
|
+
unlockToastInfo,
|
24
|
+
toastDispatch,
|
25
|
+
} from './TaskActionHelpers';
|
26
|
+
|
27
|
+
export const cancelTaskRequest = (id, name) => async dispatch => {
|
28
|
+
dispatch(addToast(infoToastData(sprintf('Trying to cancel %s task', name))));
|
29
|
+
dispatch({ type: TASKS_CANCEL_REQUEST });
|
30
|
+
try {
|
31
|
+
await API.post(`/foreman_tasks/tasks/${id}/cancel`);
|
32
|
+
dispatch({ type: TASKS_CANCEL_SUCCESS });
|
33
|
+
toastDispatch({
|
34
|
+
type: 'cancelled',
|
35
|
+
name,
|
36
|
+
toastInfo: cancelToastInfo,
|
37
|
+
dispatch,
|
38
|
+
});
|
39
|
+
} catch (error) {
|
40
|
+
dispatch({ type: TASKS_CANCEL_FAILURE, payload: error });
|
41
|
+
toastDispatch({
|
42
|
+
type: 'skipped',
|
43
|
+
name,
|
44
|
+
toastInfo: cancelToastInfo,
|
45
|
+
dispatch,
|
46
|
+
});
|
47
|
+
}
|
48
|
+
};
|
49
|
+
|
50
|
+
export const resumeTaskRequest = (id, name) => async dispatch => {
|
51
|
+
dispatch({ type: TASKS_RESUME_REQUEST });
|
52
|
+
try {
|
53
|
+
await API.post(`/foreman_tasks/tasks/${id}/resume`);
|
54
|
+
|
55
|
+
dispatch({ type: TASKS_RESUME_SUCCESS });
|
56
|
+
toastDispatch({
|
57
|
+
type: 'resumed',
|
58
|
+
name,
|
59
|
+
toastInfo: resumeToastInfo,
|
60
|
+
dispatch,
|
61
|
+
});
|
62
|
+
} catch (error) {
|
63
|
+
dispatch({ type: TASKS_RESUME_FAILURE, payload: error });
|
64
|
+
toastDispatch({
|
65
|
+
type: 'failed',
|
66
|
+
name,
|
67
|
+
toastInfo: resumeToastInfo,
|
68
|
+
dispatch,
|
69
|
+
});
|
70
|
+
}
|
71
|
+
};
|
72
|
+
|
73
|
+
export const forceCancelTaskRequest = (id, name) => async dispatch => {
|
74
|
+
dispatch({ type: TASKS_FORCE_CANCEL_REQUEST });
|
75
|
+
try {
|
76
|
+
await API.post(`/foreman_tasks/tasks/${id}/force_unlock`);
|
77
|
+
dispatch({ type: TASKS_FORCE_CANCEL_SUCCESS });
|
78
|
+
toastDispatch({
|
79
|
+
type: 'forceCancelled',
|
80
|
+
name,
|
81
|
+
toastInfo: forceCancelToastInfo,
|
82
|
+
dispatch,
|
83
|
+
});
|
84
|
+
} catch ({ response }) {
|
85
|
+
dispatch({ type: TASKS_FORCE_CANCEL_FAILURE });
|
86
|
+
toastDispatch({
|
87
|
+
type: 'failed',
|
88
|
+
name,
|
89
|
+
toastInfo: forceCancelToastInfo,
|
90
|
+
dispatch,
|
91
|
+
});
|
92
|
+
}
|
93
|
+
};
|
94
|
+
|
95
|
+
export const unlockTaskRequest = (id, name) => async dispatch => {
|
96
|
+
dispatch({ type: TASKS_UNLOCK_REQUEST });
|
97
|
+
try {
|
98
|
+
await API.post(`/foreman_tasks/tasks/${id}/unlock`);
|
99
|
+
dispatch({ type: TASKS_UNLOCK_SUCCESS });
|
100
|
+
toastDispatch({
|
101
|
+
type: 'unlocked',
|
102
|
+
name,
|
103
|
+
toastInfo: unlockToastInfo,
|
104
|
+
dispatch,
|
105
|
+
});
|
106
|
+
} catch ({ response }) {
|
107
|
+
dispatch({ type: TASKS_UNLOCK_FAILURE });
|
108
|
+
toastDispatch({
|
109
|
+
type: 'failed',
|
110
|
+
name,
|
111
|
+
toastInfo: unlockToastInfo,
|
112
|
+
dispatch,
|
113
|
+
});
|
114
|
+
}
|
115
|
+
};
|
@@ -3,7 +3,13 @@ import PropTypes from 'prop-types';
|
|
3
3
|
import { Alert, Button } from 'patternfly-react';
|
4
4
|
import { translate as __ } from 'foremanReact/common/I18n';
|
5
5
|
|
6
|
-
const RunningSteps = ({
|
6
|
+
const RunningSteps = ({
|
7
|
+
runningSteps,
|
8
|
+
id,
|
9
|
+
cancelStep,
|
10
|
+
taskReload,
|
11
|
+
taskProgressToggle,
|
12
|
+
}) => {
|
7
13
|
if (!runningSteps.length) return <span>{__('No running steps')}</span>;
|
8
14
|
return (
|
9
15
|
<div>
|
@@ -13,8 +19,12 @@ const RunningSteps = ({ runningSteps }) => {
|
|
13
19
|
<p>
|
14
20
|
<Button
|
15
21
|
bsSize="small"
|
16
|
-
|
17
|
-
|
22
|
+
onClick={() => {
|
23
|
+
if (!taskReload) {
|
24
|
+
taskProgressToggle();
|
25
|
+
}
|
26
|
+
cancelStep(id, step.id);
|
27
|
+
}}
|
18
28
|
>
|
19
29
|
{__('Cancel')}
|
20
30
|
</Button>
|
@@ -46,6 +56,10 @@ const RunningSteps = ({ runningSteps }) => {
|
|
46
56
|
|
47
57
|
RunningSteps.propTypes = {
|
48
58
|
runningSteps: PropTypes.array,
|
59
|
+
id: PropTypes.string.isRequired,
|
60
|
+
cancelStep: PropTypes.func.isRequired,
|
61
|
+
taskReload: PropTypes.bool.isRequired,
|
62
|
+
taskProgressToggle: PropTypes.func.isRequired,
|
49
63
|
};
|
50
64
|
|
51
65
|
RunningSteps.defaultProps = {
|
@@ -1,178 +1,169 @@
|
|
1
|
-
import React
|
1
|
+
import React from 'react';
|
2
2
|
import PropTypes from 'prop-types';
|
3
3
|
import { Grid, Row, Col, Button } from 'patternfly-react';
|
4
4
|
import { translate as __ } from 'foremanReact/common/I18n';
|
5
|
+
import { useForemanModal } from 'foremanReact/components/ForemanModal/ForemanModalHooks';
|
5
6
|
import TaskInfo from './TaskInfo';
|
6
|
-
import {
|
7
|
-
|
8
|
-
|
7
|
+
import {
|
8
|
+
UNLOCK_MODAL,
|
9
|
+
FORCE_UNLOCK_MODAL,
|
10
|
+
} from '../../TaskActions/TaskActionsConstants';
|
11
|
+
import { ForceUnlockModal, UnlockModal } from '../../TaskActions/UnlockModals';
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
const Task = props => {
|
14
|
+
const unlockModalActions = useForemanModal({
|
15
|
+
id: UNLOCK_MODAL,
|
16
|
+
});
|
17
|
+
const forceUnlockModalActions = useForemanModal({
|
18
|
+
id: FORCE_UNLOCK_MODAL,
|
19
|
+
});
|
20
|
+
|
21
|
+
const {
|
22
|
+
taskReload,
|
23
|
+
externalId,
|
24
|
+
id,
|
25
|
+
state,
|
26
|
+
resumable,
|
27
|
+
cancellable,
|
28
|
+
hasSubTasks,
|
29
|
+
parentTask,
|
30
|
+
cancelTaskRequest,
|
31
|
+
resumeTaskRequest,
|
32
|
+
forceCancelTaskRequest,
|
33
|
+
unlockTaskRequest,
|
34
|
+
action,
|
35
|
+
dynflowEnableConsole,
|
36
|
+
taskProgressToggle,
|
37
|
+
canEdit,
|
38
|
+
} = props;
|
39
|
+
const forceUnlock = () => {
|
40
|
+
if (!taskReload) {
|
41
|
+
taskProgressToggle();
|
24
42
|
}
|
43
|
+
forceCancelTaskRequest(id, action);
|
25
44
|
};
|
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
|
-
|
45
|
+
const unlock = () => {
|
46
|
+
if (!taskReload) {
|
47
|
+
taskProgressToggle();
|
48
|
+
}
|
49
|
+
unlockTaskRequest(id, action);
|
50
|
+
};
|
51
|
+
const editActionsTitle = canEdit
|
52
|
+
? undefined
|
53
|
+
: __('You do not have permission');
|
54
|
+
const dynflowTitle = dynflowEnableConsole
|
55
|
+
? undefined
|
56
|
+
: `dynflow_enable_console ${__('Setting is off')}`;
|
57
|
+
return (
|
58
|
+
<React.Fragment>
|
59
|
+
<UnlockModal onClick={unlock} />
|
60
|
+
<ForceUnlockModal onClick={forceUnlock} />
|
61
|
+
<Grid>
|
62
|
+
<Row>
|
63
|
+
<Col xs={12}>
|
64
|
+
<Button
|
65
|
+
className="reload-button"
|
66
|
+
bsSize="small"
|
67
|
+
onClick={taskProgressToggle}
|
68
|
+
>
|
69
|
+
<span
|
70
|
+
className={`glyphicon glyphicon-refresh ${
|
71
|
+
taskReload ? 'spin' : ''
|
72
|
+
}`}
|
73
|
+
/>
|
74
|
+
{__(`${taskReload ? 'Stop' : 'Start'} auto-reloading`)}
|
75
|
+
</Button>
|
76
|
+
<Button
|
77
|
+
className="dynflow-button"
|
78
|
+
bsSize="small"
|
79
|
+
href={`/foreman_tasks/dynflow/${externalId}`}
|
80
|
+
disabled={!dynflowEnableConsole}
|
81
|
+
rel="noopener noreferrer"
|
82
|
+
target="_blank"
|
83
|
+
>
|
84
|
+
<span title={dynflowTitle} data-original-title={dynflowTitle}>
|
85
|
+
{__('Dynflow console')}
|
86
|
+
</span>
|
87
|
+
</Button>
|
88
|
+
<Button
|
89
|
+
className="resume-button"
|
90
|
+
bsSize="small"
|
91
|
+
title={editActionsTitle}
|
92
|
+
data-original-title={editActionsTitle}
|
93
|
+
disabled={!canEdit || !resumable}
|
94
|
+
onClick={() => {
|
95
|
+
if (!taskReload) {
|
96
|
+
taskProgressToggle();
|
97
|
+
}
|
98
|
+
resumeTaskRequest(id, action);
|
99
|
+
}}
|
100
|
+
>
|
101
|
+
{__('Resume')}
|
102
|
+
</Button>
|
103
|
+
<Button
|
104
|
+
className="cancel-button"
|
105
|
+
bsSize="small"
|
106
|
+
title={editActionsTitle}
|
107
|
+
data-original-title={editActionsTitle}
|
108
|
+
disabled={!canEdit || !cancellable}
|
109
|
+
onClick={() => {
|
110
|
+
if (!taskReload) {
|
111
|
+
taskProgressToggle();
|
112
|
+
}
|
113
|
+
cancelTaskRequest(id, action);
|
114
|
+
}}
|
115
|
+
>
|
116
|
+
{__('Cancel')}
|
117
|
+
</Button>
|
118
|
+
{parentTask && (
|
87
119
|
<Button
|
88
|
-
|
89
|
-
className="reload-button"
|
120
|
+
className="parent-button"
|
90
121
|
bsSize="small"
|
91
|
-
|
122
|
+
href={`/foreman_tasks/tasks/${parentTask}`}
|
92
123
|
>
|
93
|
-
|
94
|
-
className={`glyphicon glyphicon-refresh ${
|
95
|
-
taskReload ? 'spin' : ''
|
96
|
-
}`}
|
97
|
-
/>
|
98
|
-
{__(`${taskReload ? 'Stop' : 'Start'} auto-reloading`)}
|
124
|
+
{__('Parent task')}
|
99
125
|
</Button>
|
126
|
+
)}
|
127
|
+
{hasSubTasks && (
|
100
128
|
<Button
|
129
|
+
className="subtask-button"
|
101
130
|
bsSize="small"
|
102
|
-
href={`/foreman_tasks/
|
103
|
-
disabled={!dynflowEnableConsole}
|
131
|
+
href={`/foreman_tasks/tasks/${id}/sub_tasks`}
|
104
132
|
>
|
105
|
-
{__('
|
133
|
+
{__('Sub tasks')}
|
106
134
|
</Button>
|
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
|
-
</Button>
|
136
|
-
)}
|
137
|
-
{hasSubTasks && (
|
138
|
-
<Button
|
139
|
-
bsSize="small"
|
140
|
-
href={`/foreman_tasks/tasks/${id}/sub_tasks`}
|
141
|
-
>
|
142
|
-
{__('Sub tasks')}
|
143
|
-
</Button>
|
144
|
-
)}
|
145
|
-
{allowDangerousActions && (
|
146
|
-
<Button
|
147
|
-
bsSize="small"
|
148
|
-
disabled={state !== 'paused'}
|
149
|
-
onClick={toggleUnlockModal}
|
150
|
-
>
|
151
|
-
{__('Unlock')}
|
152
|
-
</Button>
|
153
|
-
)}
|
154
|
-
{allowDangerousActions && (
|
155
|
-
<Button
|
156
|
-
bsSize="small"
|
157
|
-
disabled={state === 'stopped'}
|
158
|
-
onClick={toggleForceUnlockModal}
|
159
|
-
>
|
160
|
-
{__('Force Unlock')}
|
161
|
-
</Button>
|
162
|
-
)}
|
163
|
-
</Col>
|
164
|
-
</Row>
|
165
|
-
<TaskInfo {...this.props} />
|
166
|
-
</Grid>
|
167
|
-
</React.Fragment>
|
168
|
-
);
|
169
|
-
}
|
170
|
-
}
|
135
|
+
)}
|
136
|
+
<Button
|
137
|
+
className="unlock-button"
|
138
|
+
bsSize="small"
|
139
|
+
disabled={!canEdit || state !== 'paused'}
|
140
|
+
onClick={unlockModalActions.setModalOpen}
|
141
|
+
title={editActionsTitle}
|
142
|
+
data-original-title={editActionsTitle}
|
143
|
+
>
|
144
|
+
{__('Unlock')}
|
145
|
+
</Button>
|
146
|
+
<Button
|
147
|
+
className="force-unlock-button"
|
148
|
+
bsSize="small"
|
149
|
+
disabled={!canEdit || state === 'stopped'}
|
150
|
+
onClick={forceUnlockModalActions.setModalOpen}
|
151
|
+
title={editActionsTitle}
|
152
|
+
data-original-title={editActionsTitle}
|
153
|
+
>
|
154
|
+
{__('Force Unlock')}
|
155
|
+
</Button>
|
156
|
+
</Col>
|
157
|
+
</Row>
|
158
|
+
<TaskInfo {...props} />
|
159
|
+
</Grid>
|
160
|
+
</React.Fragment>
|
161
|
+
);
|
162
|
+
};
|
171
163
|
|
172
164
|
Task.propTypes = {
|
173
165
|
...TaskInfo.PropTypes,
|
174
166
|
state: PropTypes.string,
|
175
|
-
allowDangerousActions: PropTypes.bool,
|
176
167
|
resumable: PropTypes.bool,
|
177
168
|
cancellable: PropTypes.bool,
|
178
169
|
refetchTaskDetails: PropTypes.func,
|
@@ -180,23 +171,18 @@ Task.propTypes = {
|
|
180
171
|
parentTask: PropTypes.string,
|
181
172
|
taskReload: PropTypes.bool,
|
182
173
|
taskReloadStop: PropTypes.func,
|
183
|
-
taskReloadStart: PropTypes.func,
|
184
174
|
timeoutId: PropTypes.number,
|
185
175
|
externalId: PropTypes.string,
|
186
176
|
id: PropTypes.string.isRequired,
|
187
|
-
showUnlockModal: PropTypes.bool,
|
188
|
-
showForceUnlockModal: PropTypes.bool,
|
189
|
-
toggleUnlockModal: PropTypes.func,
|
190
|
-
toggleForceUnlockModal: PropTypes.func,
|
191
177
|
cancelTaskRequest: PropTypes.func,
|
192
178
|
resumeTaskRequest: PropTypes.func,
|
193
179
|
dynflowEnableConsole: PropTypes.bool,
|
180
|
+
canEdit: PropTypes.bool,
|
194
181
|
};
|
195
182
|
|
196
183
|
Task.defaultProps = {
|
197
184
|
...TaskInfo.defaultProps,
|
198
185
|
state: '',
|
199
|
-
allowDangerousActions: false,
|
200
186
|
resumable: false,
|
201
187
|
cancellable: false,
|
202
188
|
refetchTaskDetails: () => null,
|
@@ -204,16 +190,12 @@ Task.defaultProps = {
|
|
204
190
|
parentTask: '',
|
205
191
|
taskReload: false,
|
206
192
|
taskReloadStop: () => null,
|
207
|
-
taskReloadStart: () => null,
|
208
193
|
timeoutId: null,
|
209
194
|
externalId: '',
|
210
|
-
showUnlockModal: false,
|
211
|
-
showForceUnlockModal: false,
|
212
|
-
toggleUnlockModal: () => null,
|
213
|
-
toggleForceUnlockModal: () => null,
|
214
195
|
cancelTaskRequest: () => null,
|
215
196
|
resumeTaskRequest: () => null,
|
216
197
|
dynflowEnableConsole: false,
|
198
|
+
canEdit: false,
|
217
199
|
};
|
218
200
|
|
219
201
|
export default Task;
|