foreman-tasks 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_tasks/api/tasks_controller.rb +29 -1
  3. data/app/controllers/foreman_tasks/tasks_controller.rb +3 -11
  4. data/app/models/foreman_tasks/task.rb +4 -0
  5. data/app/models/setting/foreman_tasks.rb +1 -1
  6. data/app/services/ui_notifications/tasks/task_bulk_stop.rb +36 -0
  7. data/app/views/foreman_tasks/api/tasks/details.json.rabl +0 -1
  8. data/config/routes.rb +1 -0
  9. data/db/migrate/20200517215015_rename_bookmarks_controller.rb +35 -0
  10. data/db/migrate/20200519093217_drop_dynflow_allow_dangerous_actions_setting.foreman_tasks.rb +5 -0
  11. data/db/seeds.d/30-notification_blueprints.rb +7 -0
  12. data/lib/foreman_tasks/engine.rb +1 -1
  13. data/lib/foreman_tasks/tasks/cleanup.rake +2 -2
  14. data/lib/foreman_tasks/tasks/export_tasks.rake +1 -1
  15. data/lib/foreman_tasks/version.rb +1 -1
  16. data/locale/action_names.rb +1 -1
  17. data/locale/en/foreman_tasks.po +227 -41
  18. data/locale/foreman_tasks.pot +579 -288
  19. data/webpack/ForemanTasks/Components/TaskActions/TaskAction.test.js +60 -0
  20. data/webpack/ForemanTasks/Components/{TasksTable/TasksTableActionHelpers.js → TaskActions/TaskActionHelpers.js} +21 -6
  21. data/webpack/ForemanTasks/Components/{TasksTable/__tests__/TasksTableActionHelpers.test.js → TaskActions/TaskActionHelpers.test.js} +2 -2
  22. data/webpack/ForemanTasks/Components/TaskActions/TaskActionsConstants.js +16 -0
  23. data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.js +60 -0
  24. data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.test.js +14 -0
  25. data/webpack/ForemanTasks/Components/TaskActions/__snapshots__/TaskAction.test.js.snap +233 -0
  26. data/webpack/ForemanTasks/Components/TaskActions/__snapshots__/UnlockModals.test.js.snap +25 -0
  27. data/webpack/ForemanTasks/Components/TaskActions/index.js +115 -0
  28. data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +130 -152
  29. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +67 -3
  30. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskInfo.test.js +0 -1
  31. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +101 -70
  32. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +0 -15
  33. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsConstants.js +0 -5
  34. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js +0 -6
  35. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +0 -9
  36. data/webpack/ForemanTasks/Components/TaskDetails/TasksDetailsHelper.js +6 -1
  37. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +5 -0
  38. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +2 -7
  39. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/integration.test.js +4 -0
  40. data/webpack/ForemanTasks/Components/TaskDetails/index.js +4 -8
  41. data/webpack/ForemanTasks/Components/TasksTable/Components/ActionSelectButton.js +14 -1
  42. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModal.js +83 -0
  43. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalActions.js +106 -0
  44. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalReducer.js +38 -0
  45. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js +45 -0
  46. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModal.test.js +36 -0
  47. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalActions.test.js +205 -0
  48. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalReducer.test.js +27 -0
  49. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalSelectors.test.js +54 -0
  50. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModal.test.js.snap +41 -0
  51. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalReducer.test.js.snap +19 -0
  52. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalSelectors.test.js.snap +30 -0
  53. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/index.js +29 -0
  54. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionSelectButton.test.js +1 -0
  55. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ActionSelectButton.test.js.snap +11 -0
  56. data/webpack/ForemanTasks/Components/TasksTable/TasksBulkActions.js +113 -30
  57. data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +13 -9
  58. data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +23 -63
  59. data/webpack/ForemanTasks/Components/TasksTable/TasksTableConstants.js +10 -12
  60. data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +24 -94
  61. data/webpack/ForemanTasks/Components/TasksTable/TasksTableSchema.js +2 -2
  62. data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +7 -4
  63. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksBulkActions.test.js +35 -0
  64. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +2 -12
  65. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableActions.test.js +22 -26
  66. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +2 -14
  67. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksBulkActions.test.js.snap +107 -0
  68. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +2 -14
  69. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableActions.test.js.snap +17 -124
  70. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +24 -128
  71. data/webpack/ForemanTasks/Components/TasksTable/index.js +2 -2
  72. data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js +47 -19
  73. data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js +61 -14
  74. data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap +80 -21
  75. data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.scss +9 -0
  76. data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.test.js +44 -0
  77. data/webpack/ForemanTasks/Components/common/ClickConfirmation/__snapshots__/ClickConfirmation.test.js.snap +52 -0
  78. data/webpack/ForemanTasks/Components/common/ClickConfirmation/index.js +59 -66
  79. data/webpack/ForemanTasks/Components/common/{ToastTypesConstants.js → ToastsHelpers/ToastTypesConstants.js} +0 -0
  80. data/webpack/ForemanTasks/Components/common/ToastsHelpers/index.js +15 -0
  81. data/webpack/ForemanTasks/ForemanTasksReducers.js +2 -0
  82. data/webpack/ForemanTasks/Routes/ForemanTasksRoutes.test.js +2 -1
  83. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalHooks.js +2 -2
  84. data/webpack/__mocks__/foremanReact/components/ForemanModal/index.js +17 -3
  85. data/webpack/__mocks__/foremanReact/components/common/ActionButtons/ActionButtons.js +3 -0
  86. metadata +32 -22
  87. data/db/migrate/20200611090846_add_task_lock_index_on_resource_type_and_task_id.rb +0 -9
  88. data/lib/foreman_tasks/tasks/dynflow.rake +0 -6
  89. data/webpack/ForemanTasks/Components/TasksTable/Components/CancelConfirm.js +0 -53
  90. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmationModals.js +0 -56
  91. data/webpack/ForemanTasks/Components/TasksTable/Components/ResumeConfirm.js +0 -52
  92. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/CancelConfirm.test.js +0 -26
  93. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ConfirmationModals.test.js +0 -24
  94. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ResumeConfirm.test.js +0 -26
  95. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/CancelConfirm.test.js.snap +0 -65
  96. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ConfirmationModals.test.js.snap +0 -30
  97. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ResumeConfirm.test.js.snap +0 -63
  98. data/webpack/ForemanTasks/Components/common/ActionButtons/CancelButton.js +0 -23
  99. data/webpack/ForemanTasks/Components/common/ActionButtons/CancelButton.test.js +0 -26
  100. data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.js +0 -23
  101. data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.test.js +0 -27
  102. data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/CancelButton.test.js.snap +0 -15
  103. 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/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
+ };
@@ -1,14 +1,17 @@
1
- import React, { Component } from '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 { ClickConfirmation } from '../../common/ClickConfirmation';
7
- import { ResumeButton } from '../../common/ActionButtons/ResumeButton';
8
- import { CancelButton } from '../../common/ActionButtons/CancelButton';
7
+ import {
8
+ UNLOCK_MODAL,
9
+ FORCE_UNLOCK_MODAL,
10
+ } from '../../TaskActions/TaskActionsConstants';
11
+ import { ForceUnlockModal, UnlockModal } from '../../TaskActions/UnlockModals';
9
12
 
10
- class Task extends Component {
11
- taskProgressToggle = () => {
13
+ const Task = props => {
14
+ const taskProgressToggle = () => {
12
15
  const {
13
16
  timeoutId,
14
17
  refetchTaskDetails,
@@ -16,7 +19,7 @@ class Task extends Component {
16
19
  loading,
17
20
  taskReloadStop,
18
21
  taskReloadStart,
19
- } = this.props;
22
+ } = props;
20
23
  if (timeoutId) {
21
24
  taskReloadStop(timeoutId);
22
25
  } else {
@@ -24,155 +27,139 @@ class Task extends Component {
24
27
  }
25
28
  };
26
29
 
27
- render() {
28
- const {
29
- taskReload,
30
- externalId,
31
- id,
32
- state,
33
- allowDangerousActions,
34
- resumable,
35
- cancellable,
36
- hasSubTasks,
37
- parentTask,
38
- showUnlockModal,
39
- showForceUnlockModal,
40
- toggleUnlockModal,
41
- toggleForceUnlockModal,
42
- cancelTaskRequest,
43
- resumeTaskRequest,
44
- action,
45
- dynflowEnableConsole,
46
- } = this.props;
47
- const modalUnlock = (
48
- <ClickConfirmation
49
- showModal={showUnlockModal}
50
- title={__('Unlock')}
51
- body={__(
52
- "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."
53
- )}
54
- confirmationMessage={__(
55
- 'I understand that this may cause harm and have working database backups of all backend services.'
56
- )}
57
- confirmAction={__('Unlock')}
58
- path={`/foreman_tasks/tasks/${id}/unlock`}
59
- confirmType="warning"
60
- closeModal={toggleUnlockModal}
61
- />
62
- );
30
+ const unlockModalActions = useForemanModal({
31
+ id: UNLOCK_MODAL,
32
+ });
33
+ const forceUnlockModalActions = useForemanModal({
34
+ id: FORCE_UNLOCK_MODAL,
35
+ });
63
36
 
64
- const modalForceUnlock = (
65
- <ClickConfirmation
66
- showModal={showForceUnlockModal}
67
- title={__('Force Unlock')}
68
- body={__(
69
- 'Resources will be unlocked and will not prevent other tasks from being run. As the task might be still running, it should be avoided to use this unless you are really sure the task got stuck'
70
- )}
71
- confirmationMessage={__(
72
- 'I understand that this may cause harm and have working database backups of all backend services.'
73
- )}
74
- confirmAction={__('Force Unlock')}
75
- path={`/foreman_tasks/tasks/${id}/force_unlock`}
76
- confirmType="danger"
77
- closeModal={toggleForceUnlockModal}
78
- />
79
- );
80
- return (
81
- <React.Fragment>
82
- {modalUnlock}
83
- {modalForceUnlock}
84
- <Grid>
85
- <Row>
86
- <Col xs={12}>
37
+ const {
38
+ taskReload,
39
+ externalId,
40
+ id,
41
+ state,
42
+ resumable,
43
+ cancellable,
44
+ hasSubTasks,
45
+ parentTask,
46
+ cancelTaskRequest,
47
+ resumeTaskRequest,
48
+ forceCancelTaskRequest,
49
+ unlockTaskRequest,
50
+ action,
51
+ dynflowEnableConsole,
52
+ } = props;
53
+ const forceUnlock = () => {
54
+ if (!taskReload) {
55
+ taskProgressToggle();
56
+ }
57
+ forceCancelTaskRequest(id, action);
58
+ };
59
+ const unlock = () => {
60
+ if (!taskReload) {
61
+ taskProgressToggle();
62
+ }
63
+ unlockTaskRequest(id, action);
64
+ };
65
+ return (
66
+ <React.Fragment>
67
+ <UnlockModal onClick={unlock} />
68
+ <ForceUnlockModal onClick={forceUnlock} />
69
+ <Grid>
70
+ <Row>
71
+ <Col xs={12}>
72
+ <Button
73
+ className="reload-button"
74
+ bsSize="small"
75
+ onClick={taskProgressToggle}
76
+ >
77
+ <span
78
+ className={`glyphicon glyphicon-refresh ${
79
+ taskReload ? 'spin' : ''
80
+ }`}
81
+ />
82
+ {__(`${taskReload ? 'Stop' : 'Start'} auto-reloading`)}
83
+ </Button>
84
+ <Button
85
+ className="dynflow-button"
86
+ bsSize="small"
87
+ href={`/foreman_tasks/dynflow/${externalId}`}
88
+ disabled={!dynflowEnableConsole}
89
+ >
90
+ {__('Dynflow console')}
91
+ </Button>
92
+ <Button
93
+ className="resume-button"
94
+ bsSize="small"
95
+ disabled={!resumable}
96
+ onClick={() => {
97
+ if (!taskReload) {
98
+ taskProgressToggle();
99
+ }
100
+ resumeTaskRequest(id, action);
101
+ }}
102
+ >
103
+ {__('Resume')}
104
+ </Button>
105
+ <Button
106
+ className="cancel-button"
107
+ bsSize="small"
108
+ disabled={!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
- hidden={!allowDangerousActions}
89
- className="reload-button"
120
+ className="parent-button"
90
121
  bsSize="small"
91
- onClick={this.taskProgressToggle}
122
+ href={`/foreman_tasks/tasks/${parentTask}`}
92
123
  >
93
- <span
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/dynflow/${externalId}`}
103
- disabled={!dynflowEnableConsole}
131
+ href={`/foreman_tasks/tasks/${id}/sub_tasks`}
104
132
  >
105
- {__('Dynflow console')}
133
+ {__('Sub tasks')}
106
134
  </Button>
107
- <ResumeButton
108
- id={id}
109
- onClick={() => {
110
- if (!taskReload) {
111
- this.taskProgressToggle();
112
- }
113
- resumeTaskRequest(id, action);
114
- }}
115
- name={action}
116
- disabled={!resumable}
117
- />
118
- <CancelButton
119
- id={id}
120
- name={action}
121
- disabled={!cancellable}
122
- onClick={() => {
123
- if (!taskReload) {
124
- this.taskProgressToggle();
125
- }
126
- cancelTaskRequest(id, action);
127
- }}
128
- />
129
- {parentTask && (
130
- <Button
131
- bsSize="small"
132
- href={`/foreman_tasks/tasks/${parentTask}`}
133
- >
134
- {__('Parent task')}
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={state !== 'paused'}
140
+ onClick={unlockModalActions.setModalOpen}
141
+ >
142
+ {__('Unlock')}
143
+ </Button>
144
+ <Button
145
+ className="force-unlock-button"
146
+ bsSize="small"
147
+ disabled={state === 'stopped'}
148
+ onClick={forceUnlockModalActions.setModalOpen}
149
+ >
150
+ {__('Force Unlock')}
151
+ </Button>
152
+ </Col>
153
+ </Row>
154
+ <TaskInfo {...props} />
155
+ </Grid>
156
+ </React.Fragment>
157
+ );
158
+ };
171
159
 
172
160
  Task.propTypes = {
173
161
  ...TaskInfo.PropTypes,
174
162
  state: PropTypes.string,
175
- allowDangerousActions: PropTypes.bool,
176
163
  resumable: PropTypes.bool,
177
164
  cancellable: PropTypes.bool,
178
165
  refetchTaskDetails: PropTypes.func,
@@ -184,10 +171,6 @@ Task.propTypes = {
184
171
  timeoutId: PropTypes.number,
185
172
  externalId: PropTypes.string,
186
173
  id: PropTypes.string.isRequired,
187
- showUnlockModal: PropTypes.bool,
188
- showForceUnlockModal: PropTypes.bool,
189
- toggleUnlockModal: PropTypes.func,
190
- toggleForceUnlockModal: PropTypes.func,
191
174
  cancelTaskRequest: PropTypes.func,
192
175
  resumeTaskRequest: PropTypes.func,
193
176
  dynflowEnableConsole: PropTypes.bool,
@@ -196,7 +179,6 @@ Task.propTypes = {
196
179
  Task.defaultProps = {
197
180
  ...TaskInfo.defaultProps,
198
181
  state: '',
199
- allowDangerousActions: false,
200
182
  resumable: false,
201
183
  cancellable: false,
202
184
  refetchTaskDetails: () => null,
@@ -207,10 +189,6 @@ Task.defaultProps = {
207
189
  taskReloadStart: () => null,
208
190
  timeoutId: null,
209
191
  externalId: '',
210
- showUnlockModal: false,
211
- showForceUnlockModal: false,
212
- toggleUnlockModal: () => null,
213
- toggleForceUnlockModal: () => null,
214
192
  cancelTaskRequest: () => null,
215
193
  resumeTaskRequest: () => null,
216
194
  dynflowEnableConsole: false,