foreman-tasks 12.0.0 → 12.1.0

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.
Files changed (166) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby_tests.yml +1 -0
  3. data/app/assets/javascripts/foreman-tasks/locale/de/foreman_tasks.js +58 -22
  4. data/app/assets/javascripts/foreman-tasks/locale/en/foreman_tasks.js +56 -20
  5. data/app/assets/javascripts/foreman-tasks/locale/es/foreman_tasks.js +59 -23
  6. data/app/assets/javascripts/foreman-tasks/locale/fr/foreman_tasks.js +61 -25
  7. data/app/assets/javascripts/foreman-tasks/locale/ja/foreman_tasks.js +61 -25
  8. data/app/assets/javascripts/foreman-tasks/locale/ka/foreman_tasks.js +60 -24
  9. data/app/assets/javascripts/foreman-tasks/locale/ko/foreman_tasks.js +61 -25
  10. data/app/assets/javascripts/foreman-tasks/locale/pt_BR/foreman_tasks.js +59 -23
  11. data/app/assets/javascripts/foreman-tasks/locale/ru/foreman_tasks.js +58 -22
  12. data/app/assets/javascripts/foreman-tasks/locale/zh_CN/foreman_tasks.js +61 -25
  13. data/app/assets/javascripts/foreman-tasks/locale/zh_TW/foreman_tasks.js +57 -21
  14. data/app/controllers/foreman_tasks/api/tasks_controller.rb +4 -19
  15. data/app/controllers/foreman_tasks/tasks_controller.rb +4 -5
  16. data/app/models/foreman_tasks/task.rb +1 -1
  17. data/app/views/foreman_tasks/api/tasks/dependency_summary.json.rabl +1 -3
  18. data/app/views/foreman_tasks/api/tasks/show.json.rabl +4 -1
  19. data/config/routes.rb +3 -3
  20. data/foreman-tasks.gemspec +3 -1
  21. data/lib/foreman_tasks/engine.rb +1 -1
  22. data/lib/foreman_tasks/tasks/export_tasks.rake +1 -1
  23. data/lib/foreman_tasks/version.rb +1 -1
  24. data/locale/de/LC_MESSAGES/foreman_tasks.mo +0 -0
  25. data/locale/de/foreman_tasks.po +59 -23
  26. data/locale/en/LC_MESSAGES/foreman_tasks.mo +0 -0
  27. data/locale/en/foreman_tasks.po +56 -20
  28. data/locale/es/LC_MESSAGES/foreman_tasks.mo +0 -0
  29. data/locale/es/foreman_tasks.po +59 -23
  30. data/locale/foreman_tasks.pot +173 -100
  31. data/locale/fr/LC_MESSAGES/foreman_tasks.mo +0 -0
  32. data/locale/fr/foreman_tasks.po +61 -25
  33. data/locale/ja/LC_MESSAGES/foreman_tasks.mo +0 -0
  34. data/locale/ja/foreman_tasks.po +61 -25
  35. data/locale/ka/LC_MESSAGES/foreman_tasks.mo +0 -0
  36. data/locale/ka/foreman_tasks.po +60 -24
  37. data/locale/ko/LC_MESSAGES/foreman_tasks.mo +0 -0
  38. data/locale/ko/foreman_tasks.po +61 -25
  39. data/locale/pt_BR/LC_MESSAGES/foreman_tasks.mo +0 -0
  40. data/locale/pt_BR/foreman_tasks.po +59 -23
  41. data/locale/ru/LC_MESSAGES/foreman_tasks.mo +0 -0
  42. data/locale/ru/foreman_tasks.po +58 -22
  43. data/locale/zh_CN/LC_MESSAGES/foreman_tasks.mo +0 -0
  44. data/locale/zh_CN/foreman_tasks.po +61 -25
  45. data/locale/zh_TW/LC_MESSAGES/foreman_tasks.mo +0 -0
  46. data/locale/zh_TW/foreman_tasks.po +57 -21
  47. data/test/controllers/api/tasks_controller_test.rb +29 -3
  48. data/test/controllers/tasks_controller_test.rb +46 -2
  49. data/webpack/ForemanTasks/Components/TaskActions/TaskAction.test.js +8 -0
  50. data/webpack/ForemanTasks/Components/TaskActions/TaskActionHelpers.js +8 -2
  51. data/webpack/ForemanTasks/Components/TaskActions/TaskActionHelpers.test.js +25 -33
  52. data/webpack/ForemanTasks/Components/TaskActions/index.js +24 -3
  53. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskInfo.test.js.snap +6 -6
  54. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js +9 -0
  55. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsActions.test.js.snap +16 -11
  56. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.js +2 -3
  57. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/__snapshots__/TasksTimeRow.test.js.snap +4 -8
  58. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboard.js +2 -4
  59. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboard.scss +0 -3
  60. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboard.test.js.snap +2 -5
  61. data/webpack/ForemanTasks/Components/{common/ActionButtons/ActionButton.js → TasksTable/Components/CellActionButton.js} +36 -21
  62. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/index.test.js +32 -29
  63. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/createBulkTaskModal.js +14 -18
  64. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/createTaskModal.js +13 -15
  65. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/index.js +7 -7
  66. data/webpack/ForemanTasks/Components/TasksTable/TasksBulkActions.js +16 -23
  67. data/webpack/ForemanTasks/Components/TasksTable/TasksColumns.js +56 -0
  68. data/webpack/ForemanTasks/Components/TasksTable/TasksIndexPage.js +277 -3
  69. data/webpack/ForemanTasks/Components/TasksTable/TasksModals.js +96 -0
  70. data/webpack/ForemanTasks/Components/TasksTable/TasksTableConstants.js +10 -18
  71. data/webpack/ForemanTasks/Components/TasksTable/TasksTableHelpers.js +3 -3
  72. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksBulkActions.test.js +130 -63
  73. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksIndexPage.test.js +315 -8
  74. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +214 -41
  75. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js +20 -12
  76. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksBulkActions.test.js.snap +18 -35
  77. data/webpack/ForemanTasks/ForemanTasksReducers.js +0 -4
  78. data/webpack/Routes/routes.js +22 -0
  79. data/webpack/Routes/routes.test.js +95 -0
  80. data/webpack/global_index.js +10 -0
  81. data/webpack/index.js +0 -18
  82. data/webpack/test_setup.js +1 -0
  83. metadata +15 -89
  84. data/app/controllers/foreman_tasks/react_controller.rb +0 -17
  85. data/app/views/foreman_tasks/layouts/react.html.erb +0 -13
  86. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js +0 -30
  87. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalSelectors.test.js +0 -66
  88. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalSelectors.test.js.snap +0 -33
  89. data/webpack/ForemanTasks/Components/TasksTable/Components/SelectAllAlert.js +0 -49
  90. data/webpack/ForemanTasks/Components/TasksTable/Components/TableSelectionCell.js +0 -32
  91. data/webpack/ForemanTasks/Components/TasksTable/Components/TableSelectionHeaderCell.js +0 -38
  92. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/SelectAllAlert.test.js +0 -29
  93. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/TableSelectionCell.test.js +0 -15
  94. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/TableSelectionHeaderCell.test.js +0 -15
  95. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/SelectAllAlert.test.js.snap +0 -81
  96. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/TableSelectionCell.test.js.snap +0 -14
  97. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/TableSelectionHeaderCell.test.js.snap +0 -15
  98. data/webpack/ForemanTasks/Components/TasksTable/SubTasksPage.js +0 -40
  99. data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +0 -163
  100. data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +0 -108
  101. data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +0 -234
  102. data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.scss +0 -20
  103. data/webpack/ForemanTasks/Components/TasksTable/TasksTableReducer.js +0 -68
  104. data/webpack/ForemanTasks/Components/TasksTable/TasksTableSchema.js +0 -85
  105. data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +0 -63
  106. data/webpack/ForemanTasks/Components/TasksTable/__tests__/SubTasksPage.test.js +0 -20
  107. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.test.js +0 -9
  108. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableActions.test.js +0 -65
  109. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTablePage.test.js +0 -35
  110. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js +0 -87
  111. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +0 -48
  112. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +0 -39
  113. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTable.test.js.snap +0 -52
  114. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableActions.test.js.snap +0 -40
  115. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +0 -368
  116. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableReducer.test.js.snap +0 -116
  117. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/actionCellFormatter.test.js.snap +0 -15
  118. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/actionNameCellFormatter.test.js.snap +0 -10
  119. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/dateCellFormmatter.test.js.snap +0 -9
  120. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/durationCellFormmatter.test.js.snap +0 -18
  121. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/selectionCellFormatter.test.js.snap +0 -12
  122. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/selectionHeaderCellFormatter.test.js.snap +0 -11
  123. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/actionCellFormatter.test.js +0 -11
  124. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/actionNameCellFormatter.test.js +0 -8
  125. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/dateCellFormmatter.test.js +0 -7
  126. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/durationCellFormmatter.test.js +0 -12
  127. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/selectionCellFormatter.test.js +0 -12
  128. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/selectionHeaderCellFormatter.test.js +0 -12
  129. data/webpack/ForemanTasks/Components/TasksTable/formatters/actionCellFormatter.js +0 -19
  130. data/webpack/ForemanTasks/Components/TasksTable/formatters/actionNameCellFormatter.js +0 -9
  131. data/webpack/ForemanTasks/Components/TasksTable/formatters/dateCellFormmatter.js +0 -7
  132. data/webpack/ForemanTasks/Components/TasksTable/formatters/durationCellFormmatter.js +0 -7
  133. data/webpack/ForemanTasks/Components/TasksTable/formatters/index.js +0 -7
  134. data/webpack/ForemanTasks/Components/TasksTable/formatters/selectionCellFormatter.js +0 -17
  135. data/webpack/ForemanTasks/Components/TasksTable/formatters/selectionHeaderCellFormatter.js +0 -11
  136. data/webpack/ForemanTasks/Components/TasksTable/index.js +0 -42
  137. data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js +0 -101
  138. data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap +0 -95
  139. data/webpack/ForemanTasks/ForemanTasks.js +0 -11
  140. data/webpack/ForemanTasks/ForemanTasks.test.js +0 -10
  141. data/webpack/ForemanTasks/Routes/ForemanTasksRouter.js +0 -14
  142. data/webpack/ForemanTasks/Routes/ForemanTasksRouter.test.js +0 -26
  143. data/webpack/ForemanTasks/Routes/ForemanTasksRoutes.js +0 -23
  144. data/webpack/ForemanTasks/Routes/ForemanTasksRoutes.test.js +0 -16
  145. data/webpack/ForemanTasks/Routes/__snapshots__/ForemanTasksRouter.test.js.snap +0 -16
  146. data/webpack/ForemanTasks/Routes/__snapshots__/ForemanTasksRoutes.test.js.snap +0 -37
  147. data/webpack/ForemanTasks/__snapshots__/ForemanTasks.test.js.snap +0 -7
  148. data/webpack/ForemanTasks/index.js +0 -1
  149. data/webpack/__mocks__/foremanReact/common/I18n.js +0 -7
  150. data/webpack/__mocks__/foremanReact/common/helpers.js +0 -6
  151. data/webpack/__mocks__/foremanReact/common/urlHelpers.js +0 -1
  152. data/webpack/__mocks__/foremanReact/components/Layout/LayoutActions.js +0 -2
  153. data/webpack/__mocks__/foremanReact/components/Pagination/index.js +0 -2
  154. data/webpack/__mocks__/foremanReact/components/ToastsList/index.js +0 -8
  155. data/webpack/__mocks__/foremanReact/components/common/ActionButtons/ActionButtons.js +0 -3
  156. data/webpack/__mocks__/foremanReact/components/common/MessageBox.js +0 -4
  157. data/webpack/__mocks__/foremanReact/components/common/dates/LongDateTime.js +0 -5
  158. data/webpack/__mocks__/foremanReact/components/common/dates/RelativeDateTime.js +0 -3
  159. data/webpack/__mocks__/foremanReact/components/common/table/actionsHelpers/actionTypeCreator.js +0 -7
  160. data/webpack/__mocks__/foremanReact/components/common/table.js +0 -5
  161. data/webpack/__mocks__/foremanReact/constants.js +0 -24
  162. data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +0 -10
  163. data/webpack/__mocks__/foremanReact/redux/API/index.js +0 -10
  164. data/webpack/__mocks__/foremanReact/redux/middlewares/IntervalMiddleware.js +0 -5
  165. data/webpack/__mocks__/foremanReact/routes/common/PageLayout/PageLayout.js +0 -10
  166. data/webpack/__mocks__/foremanReact/routes/common/PageLayout/components/ExportButton/ExportButton.js +0 -5
@@ -24,7 +24,11 @@ import {
24
24
  toastDispatch,
25
25
  } from './TaskActionHelpers';
26
26
 
27
- export const cancelTaskRequest = (id, name) => async dispatch => {
27
+ export const cancelTaskRequest = (
28
+ id,
29
+ name,
30
+ reloadPage = null
31
+ ) => async dispatch => {
28
32
  dispatch(addToast(infoToastData(sprintf('Trying to cancel %s task', name))));
29
33
  dispatch({ type: TASKS_CANCEL_REQUEST });
30
34
  try {
@@ -36,6 +40,9 @@ export const cancelTaskRequest = (id, name) => async dispatch => {
36
40
  toastInfo: cancelToastInfo,
37
41
  dispatch,
38
42
  });
43
+ if (reloadPage) {
44
+ reloadPage();
45
+ }
39
46
  } catch (error) {
40
47
  dispatch({ type: TASKS_CANCEL_FAILURE, payload: error });
41
48
  toastDispatch({
@@ -47,7 +54,11 @@ export const cancelTaskRequest = (id, name) => async dispatch => {
47
54
  }
48
55
  };
49
56
 
50
- export const resumeTaskRequest = (id, name) => async dispatch => {
57
+ export const resumeTaskRequest = (
58
+ id,
59
+ name,
60
+ reloadPage = null
61
+ ) => async dispatch => {
51
62
  dispatch({ type: TASKS_RESUME_REQUEST });
52
63
  try {
53
64
  await API.post(`/foreman_tasks/tasks/${id}/resume`);
@@ -59,6 +70,9 @@ export const resumeTaskRequest = (id, name) => async dispatch => {
59
70
  toastInfo: resumeToastInfo,
60
71
  dispatch,
61
72
  });
73
+ if (reloadPage) {
74
+ reloadPage();
75
+ }
62
76
  } catch (error) {
63
77
  dispatch({ type: TASKS_RESUME_FAILURE, payload: error });
64
78
  toastDispatch({
@@ -70,7 +84,11 @@ export const resumeTaskRequest = (id, name) => async dispatch => {
70
84
  }
71
85
  };
72
86
 
73
- export const forceCancelTaskRequest = (id, name) => async dispatch => {
87
+ export const forceCancelTaskRequest = (
88
+ id,
89
+ name,
90
+ reloadPage = null
91
+ ) => async dispatch => {
74
92
  dispatch({ type: TASKS_FORCE_CANCEL_REQUEST });
75
93
  try {
76
94
  await API.post(`/foreman_tasks/tasks/${id}/force_unlock`);
@@ -81,6 +99,9 @@ export const forceCancelTaskRequest = (id, name) => async dispatch => {
81
99
  toastInfo: forceCancelToastInfo,
82
100
  dispatch,
83
101
  });
102
+ if (reloadPage) {
103
+ reloadPage();
104
+ }
84
105
  } catch ({ response }) {
85
106
  dispatch({ type: TASKS_FORCE_CANCEL_FAILURE });
86
107
  toastDispatch({
@@ -55,7 +55,7 @@ exports[`TaskInfo rendering render with Props 1`] = `
55
55
  md={3}
56
56
  sm={6}
57
57
  >
58
- <_default
58
+ <RelativeDateTime
59
59
  date="2019-06-17 16:04:09 +0300"
60
60
  defaultValue="N/A"
61
61
  />
@@ -114,7 +114,7 @@ exports[`TaskInfo rendering render with Props 1`] = `
114
114
  md={3}
115
115
  sm={6}
116
116
  >
117
- <_default
117
+ <RelativeDateTime
118
118
  date="2019-06-17 16:04:09 +0300"
119
119
  defaultValue="N/A"
120
120
  />
@@ -167,7 +167,7 @@ exports[`TaskInfo rendering render with Props 1`] = `
167
167
  md={3}
168
168
  sm={6}
169
169
  >
170
- <_default
170
+ <RelativeDateTime
171
171
  date={null}
172
172
  defaultValue="N/A"
173
173
  />
@@ -359,7 +359,7 @@ exports[`TaskInfo rendering render without Props 1`] = `
359
359
  md={3}
360
360
  sm={6}
361
361
  >
362
- <_default
362
+ <RelativeDateTime
363
363
  date=""
364
364
  defaultValue="N/A"
365
365
  />
@@ -418,7 +418,7 @@ exports[`TaskInfo rendering render without Props 1`] = `
418
418
  md={3}
419
419
  sm={6}
420
420
  >
421
- <_default
421
+ <RelativeDateTime
422
422
  date=""
423
423
  defaultValue="N/A"
424
424
  />
@@ -469,7 +469,7 @@ exports[`TaskInfo rendering render without Props 1`] = `
469
469
  md={3}
470
470
  sm={6}
471
471
  >
472
- <_default
472
+ <RelativeDateTime
473
473
  date=""
474
474
  defaultValue="N/A"
475
475
  />
@@ -5,6 +5,15 @@ import {
5
5
  cancelStep,
6
6
  } from '../TaskDetailsActions';
7
7
 
8
+ jest.mock('foremanReact/components/ToastsList', () => ({
9
+ addToast: toast => ({
10
+ type: 'TOASTS_ADD',
11
+ payload: {
12
+ message: toast,
13
+ },
14
+ }),
15
+ }));
16
+
8
17
  const fixtures = {
9
18
  'should start reload': () => taskReloadStart(1),
10
19
  'should stop reload': () => taskReloadStop(),
@@ -15,11 +15,13 @@ Array [
15
15
  ],
16
16
  Array [
17
17
  Object {
18
- "handleError": [Function],
19
- "handleSuccess": [Function],
20
- "key": "TASK_STEP_CANCEL",
21
- "type": "post-some-type",
22
- "url": "foreman/foreman_tasks/tasks/task-id/cancel_step?step_id=step-id",
18
+ "payload": Object {
19
+ "handleError": [Function],
20
+ "handleSuccess": [Function],
21
+ "key": "TASK_STEP_CANCEL",
22
+ "url": "/foreman_tasks/tasks/task-id/cancel_step?step_id=step-id",
23
+ },
24
+ "type": "API_POST",
23
25
  },
24
26
  ],
25
27
  ]
@@ -29,12 +31,14 @@ exports[`TaskDetails - Actions should start reload 1`] = `
29
31
  Array [
30
32
  Array [
31
33
  Object {
32
- "handleError": [Function],
33
- "handleSuccess": [Function],
34
34
  "interval": 5000,
35
- "key": "FOREMAN_TASK_DETAILS",
36
- "type": "get-some-type",
37
- "url": "foreman/foreman_tasks/api/tasks/1/details?include_permissions",
35
+ "payload": Object {
36
+ "handleError": [Function],
37
+ "handleSuccess": [Function],
38
+ "key": "FOREMAN_TASK_DETAILS",
39
+ "url": "/foreman_tasks/api/tasks/1/details?include_permissions",
40
+ },
41
+ "type": "API_GET",
38
42
  },
39
43
  ],
40
44
  ]
@@ -42,6 +46,7 @@ Array [
42
46
 
43
47
  exports[`TaskDetails - Actions should stop reload 1`] = `
44
48
  Object {
45
- "type": "stop",
49
+ "key": "FOREMAN_TASK_DETAILS",
50
+ "type": "STOP_INTERVAL",
46
51
  }
47
52
  `;
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { Row } from 'patternfly-react';
4
3
  import { noop } from 'foremanReact/common/helpers';
5
4
  import { translate as __ } from 'foremanReact/common/I18n';
6
5
 
@@ -10,14 +9,14 @@ import TimeDropDown from './Components/TimeDropDown/TimeDropDown';
10
9
  import './TasksTimeRow.scss';
11
10
 
12
11
  const TasksTimeRow = ({ time, updateTime }) => (
13
- <Row className="tasks-time-row">
12
+ <div className="tasks-time-row">
14
13
  <span className="time-label">{__('With focus on last')}</span>
15
14
  <TimeDropDown
16
15
  id="tasks-dashboard-time-period-dropdown"
17
16
  selectedTime={time}
18
17
  onChange={updateTime}
19
18
  />
20
- </Row>
19
+ </div>
21
20
  );
22
21
 
23
22
  TasksTimeRow.propTypes = {
@@ -1,10 +1,8 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`TasksTimeRow render with minimal props 1`] = `
4
- <Row
5
- bsClass="row"
4
+ <div
6
5
  className="tasks-time-row"
7
- componentClass="div"
8
6
  >
9
7
  <span
10
8
  className="time-label"
@@ -17,14 +15,12 @@ exports[`TasksTimeRow render with minimal props 1`] = `
17
15
  onChange={[Function]}
18
16
  selectedTime="H24"
19
17
  />
20
- </Row>
18
+ </div>
21
19
  `;
22
20
 
23
21
  exports[`TasksTimeRow render with props 1`] = `
24
- <Row
25
- bsClass="row"
22
+ <div
26
23
  className="tasks-time-row"
27
- componentClass="div"
28
24
  >
29
25
  <span
30
26
  className="time-label"
@@ -37,5 +33,5 @@ exports[`TasksTimeRow render with props 1`] = `
37
33
  onChange={[MockFunction]}
38
34
  selectedTime="WEEK"
39
35
  />
40
- </Row>
36
+ </div>
41
37
  `;
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { Grid } from 'patternfly-react';
4
3
  import { noop } from 'foremanReact/common/helpers';
5
4
 
6
5
  import TasksTimeRow from './Components/TasksTimeRow/TasksTimeRow';
@@ -26,7 +25,6 @@ class TasksDashboard extends React.Component {
26
25
  time: query.time,
27
26
  query,
28
27
  });
29
-
30
28
  // dont fetch if time is going to be changed
31
29
  if (!query.time || query.time === time) {
32
30
  fetchTasksSummary(time, parentTaskID);
@@ -47,7 +45,7 @@ class TasksDashboard extends React.Component {
47
45
  updateQuery(labelQuery, this.props.history);
48
46
  };
49
47
  return (
50
- <Grid fluid className="tasks-dashboard-grid">
48
+ <div className="tasks-dashboard-grid">
51
49
  <TasksTimeRow time={time} updateTime={updateTime} />
52
50
  <TasksCardsGrid
53
51
  time={time}
@@ -56,7 +54,7 @@ class TasksDashboard extends React.Component {
56
54
  updateQuery={updateQueryHistory}
57
55
  />
58
56
  <TasksLabelsRow query={query} updateQuery={updateQueryHistory} />
59
- </Grid>
57
+ </div>
60
58
  );
61
59
  }
62
60
  }
@@ -14,9 +14,6 @@
14
14
 
15
15
  .tasks-dashboard-grid {
16
16
  min-height: 200px;
17
- background-color: #f5f5f5;
18
- margin: 5px -60px 20px -60px;
19
- padding: 20px 50px;
20
17
 
21
18
  .row > div {
22
19
  @include create-tasks-dashboard-column(12, 0);
@@ -1,11 +1,8 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`TasksDashboard rendering render without Props 1`] = `
4
- <Grid
5
- bsClass="container"
4
+ <div
6
5
  className="tasks-dashboard-grid"
7
- componentClass="div"
8
- fluid={true}
9
6
  >
10
7
  <TasksTimeRow
11
8
  time="H24"
@@ -50,5 +47,5 @@ exports[`TasksDashboard rendering render without Props 1`] = `
50
47
  query={Object {}}
51
48
  updateQuery={[Function]}
52
49
  />
53
- </Grid>
50
+ </div>
54
51
  `;
@@ -2,13 +2,21 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { translate as __ } from 'foremanReact/common/I18n';
4
4
  import { ActionButtons } from 'foremanReact/components/common/ActionButtons/ActionButtons';
5
+ import {
6
+ RESUME_MODAL,
7
+ CANCEL_MODAL,
8
+ FORCE_UNLOCK_MODAL,
9
+ } from '../TasksTableConstants';
5
10
 
6
- export const ActionButton = ({
7
- canEdit,
11
+ export const CellActionButton = ({
8
12
  id,
9
- name,
10
- availableActions: { resumable, cancellable, stoppable },
11
- taskActions,
13
+ action,
14
+ canEdit,
15
+ resumable,
16
+ cancellable,
17
+ stoppable,
18
+ setClickedTask,
19
+ openModal,
12
20
  }) => {
13
21
  const buttons = [];
14
22
  const isTitle = canEdit && !(resumable || cancellable || stoppable);
@@ -19,7 +27,10 @@ export const ActionButton = ({
19
27
  title: __('Resume'),
20
28
  action: {
21
29
  disabled: !resumable,
22
- onClick: () => taskActions.resumeTask(id, name),
30
+ onClick: () => {
31
+ setClickedTask({ id, action });
32
+ openModal(RESUME_MODAL);
33
+ },
23
34
  id: `task-resume-button-${id}`,
24
35
  },
25
36
  });
@@ -30,7 +41,10 @@ export const ActionButton = ({
30
41
  title: __('Cancel'),
31
42
  action: {
32
43
  disabled: !cancellable,
33
- onClick: () => taskActions.cancelTask(id, name),
44
+ onClick: () => {
45
+ setClickedTask({ id, action });
46
+ openModal(CANCEL_MODAL);
47
+ },
34
48
  id: `task-cancel-button-${id}`,
35
49
  },
36
50
  });
@@ -41,7 +55,10 @@ export const ActionButton = ({
41
55
  title: __('Force Cancel'),
42
56
  action: {
43
57
  disabled: !stoppable,
44
- onClick: () => taskActions.forceCancelTask(id, name),
58
+ onClick: () => {
59
+ setClickedTask({ id, action });
60
+ openModal(FORCE_UNLOCK_MODAL);
61
+ },
45
62
  id: `task-force-cancel-button-${id}`,
46
63
  },
47
64
  });
@@ -54,22 +71,20 @@ export const ActionButton = ({
54
71
  );
55
72
  };
56
73
 
57
- ActionButton.propTypes = {
74
+ CellActionButton.propTypes = {
58
75
  canEdit: PropTypes.bool,
59
76
  id: PropTypes.string.isRequired,
60
- name: PropTypes.string.isRequired,
61
- availableActions: PropTypes.shape({
62
- cancellable: PropTypes.bool,
63
- resumable: PropTypes.bool,
64
- stoppable: PropTypes.bool,
65
- }).isRequired,
66
- taskActions: PropTypes.shape({
67
- cancelTask: PropTypes.func,
68
- resumeTask: PropTypes.func,
69
- forceCancelTask: PropTypes.func,
70
- }).isRequired,
77
+ action: PropTypes.string.isRequired,
78
+ resumable: PropTypes.bool,
79
+ cancellable: PropTypes.bool,
80
+ stoppable: PropTypes.bool,
81
+ setClickedTask: PropTypes.func.isRequired,
82
+ openModal: PropTypes.func.isRequired,
71
83
  };
72
84
 
73
- ActionButton.defaultProps = {
85
+ CellActionButton.defaultProps = {
74
86
  canEdit: false,
87
+ resumable: false,
88
+ cancellable: false,
89
+ stoppable: false,
75
90
  };
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import PropTypes from 'prop-types';
2
3
  import { render, screen, fireEvent } from '@testing-library/react';
3
4
  import '@testing-library/jest-dom';
4
5
  import { Provider } from 'react-redux';
@@ -12,10 +13,11 @@ import {
12
13
  ForceUnlockSelectedModal,
13
14
  } from '../index';
14
15
 
15
- // Mock the action creators
16
- jest.mock('../../../TasksTableActions', () => ({
17
- cancelTask: jest.fn(() => ({ type: 'CANCEL_TASK' })),
18
- resumeTask: jest.fn(() => ({ type: 'RESUME_TASK' })),
16
+ // Mock TaskActions: return a sync thunk so dispatch doesn't receive a Promise
17
+ jest.mock('../../../../TaskActions', () => ({
18
+ cancelTaskRequest: jest.fn(() => () => ({ type: 'MOCK_CANCEL' })),
19
+ resumeTaskRequest: jest.fn(() => () => ({ type: 'MOCK_RESUME' })),
20
+ forceCancelTaskRequest: jest.fn(() => () => ({ type: 'MOCK_FORCE_CANCEL' })),
19
21
  }));
20
22
 
21
23
  jest.mock('../../../TasksBulkActions', () => ({
@@ -23,29 +25,14 @@ jest.mock('../../../TasksBulkActions', () => ({
23
25
  bulkCancelById: jest.fn(() => ({ type: 'BULK_CANCEL_BY_ID' })),
24
26
  bulkResumeBySearch: jest.fn(() => ({ type: 'BULK_RESUME_BY_SEARCH' })),
25
27
  bulkResumeById: jest.fn(() => ({ type: 'BULK_RESUME_BY_ID' })),
26
- bulkForceUnlockBySearch: jest.fn(() => ({
28
+ bulkForceCancelBySearch: jest.fn(() => ({
27
29
  type: 'BULK_FORCE_UNLOCK_BY_SEARCH',
28
30
  })),
29
- bulkForceUnlockById: jest.fn(() => ({ type: 'BULK_FORCE_UNLOCK_BY_ID' })),
31
+ bulkForceCancelById: jest.fn(() => ({ type: 'BULK_FORCE_UNLOCK_BY_ID' })),
30
32
  }));
31
33
 
32
- // Mock the selectors
33
- jest.mock('../ConfirmModalSelectors', () => ({
34
- selectClicked: jest.fn(() => ({ taskId: '123', taskName: 'Test Task' })),
35
- selectSelectedTasks: jest.fn(() => [
36
- { id: 1, name: 'Task 1' },
37
- { id: 2, name: 'Task 2' },
38
- ]),
39
- selectSelectedRowsLen: jest.fn(() => 2),
40
- }));
41
-
42
- jest.mock('../../../TasksTableSelectors', () => ({
43
- selectAllRowsSelected: jest.fn(() => false),
44
- }));
45
-
46
- // Create a mock store
47
- const createMockStore = (initialState = {}) => {
48
- return configureStore({
34
+ const createMockStore = (initialState = {}) =>
35
+ configureStore({
49
36
  reducer: {
50
37
  foremanTasks: (state = initialState, action) => state,
51
38
  },
@@ -53,19 +40,32 @@ const createMockStore = (initialState = {}) => {
53
40
  foremanTasks: initialState,
54
41
  },
55
42
  });
56
- };
57
43
 
58
44
  // Test wrapper component
59
45
  const TestWrapper = ({ children, store }) => (
60
46
  <Provider store={store}>{children}</Provider>
61
47
  );
48
+ TestWrapper.propTypes = {
49
+ children: PropTypes.node.isRequired,
50
+ store: PropTypes.object.isRequired,
51
+ };
52
+
53
+ const defaultSelectAllOptions = {
54
+ selectedCount: 2,
55
+ areAllRowsSelected: () => false,
56
+ selectedResults: [
57
+ { id: 1, name: 'Task 1' },
58
+ { id: 2, name: 'Task 2' },
59
+ ],
60
+ };
62
61
 
63
62
  describe('ConfirmModal Components', () => {
64
63
  const defaultProps = {
64
+ reloadPage: jest.fn(),
65
65
  isModalOpen: true,
66
66
  setIsModalOpen: jest.fn(),
67
- url: '/api/tasks',
68
- parentTaskID: 'parent-123',
67
+ taskId: '123',
68
+ taskName: 'Test Task',
69
69
  };
70
70
 
71
71
  const mockStore = createMockStore();
@@ -185,7 +185,8 @@ describe('ConfirmModal Components', () => {
185
185
  describe('CancelSelectedModal', () => {
186
186
  const selectedProps = {
187
187
  ...defaultProps,
188
- uriQuery: { search: 'test' },
188
+ uriQuery: 'search=test',
189
+ selectAllOptions: defaultSelectAllOptions,
189
190
  };
190
191
 
191
192
  it('renders with correct title and content', () => {
@@ -245,7 +246,8 @@ describe('ConfirmModal Components', () => {
245
246
  describe('ResumeSelectedModal', () => {
246
247
  const selectedProps = {
247
248
  ...defaultProps,
248
- uriQuery: { search: 'test' },
249
+ uriQuery: 'search=test',
250
+ selectAllOptions: defaultSelectAllOptions,
249
251
  };
250
252
 
251
253
  it('renders with correct title and content', () => {
@@ -321,7 +323,8 @@ describe('ConfirmModal Components', () => {
321
323
  describe('ForceUnlockSelectedModal', () => {
322
324
  const selectedProps = {
323
325
  ...defaultProps,
324
- uriQuery: { search: 'test' },
326
+ uriQuery: 'search=test',
327
+ selectAllOptions: defaultSelectAllOptions,
325
328
  };
326
329
 
327
330
  it('renders with correct title and content', () => {
@@ -1,12 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { useSelector } from 'react-redux';
4
3
  import { sprintf } from 'foremanReact/common/I18n';
5
- import {
6
- selectSelectedTasks,
7
- selectSelectedRowsLen,
8
- } from './ConfirmModalSelectors';
9
- import { selectAllRowsSelected } from '../../TasksTableSelectors';
10
4
  import { GenericConfirmModal } from './GenericConfirmModal';
11
5
 
12
6
  export const createBulkTaskModal = ({
@@ -20,22 +14,23 @@ export const createBulkTaskModal = ({
20
14
  const BulkTaskModal = ({
21
15
  isModalOpen,
22
16
  setIsModalOpen,
23
- url,
24
17
  uriQuery,
25
18
  parentTaskID,
19
+ selectAllOptions,
20
+ reloadPage,
26
21
  }) => {
27
- const allRowsSelected = useSelector(selectAllRowsSelected);
28
- const selectedTasks = useSelector(selectSelectedTasks);
29
- const selectedRowsLen = useSelector(selectSelectedRowsLen);
30
-
22
+ const {
23
+ selectedCount = 0,
24
+ areAllRowsSelected = () => false,
25
+ selectedResults = [],
26
+ } = selectAllOptions;
27
+ const allRowsSelected = areAllRowsSelected();
28
+ const selectedTasks = selectedResults;
29
+ const selectedRowsLen = selectedCount;
31
30
  const handleConfirm = () =>
32
31
  allRowsSelected
33
32
  ? bulkActionBySearch({ query: uriQuery, parentTaskID })
34
- : bulkActionById({
35
- selected: selectedTasks,
36
- url,
37
- parentTaskID,
38
- });
33
+ : bulkActionById({ selected: selectedTasks, reloadPage });
39
34
 
40
35
  return (
41
36
  <GenericConfirmModal
@@ -53,9 +48,10 @@ export const createBulkTaskModal = ({
53
48
  BulkTaskModal.propTypes = {
54
49
  isModalOpen: PropTypes.bool.isRequired,
55
50
  setIsModalOpen: PropTypes.func.isRequired,
56
- url: PropTypes.string.isRequired,
57
- uriQuery: PropTypes.object,
51
+ uriQuery: PropTypes.string,
58
52
  parentTaskID: PropTypes.string,
53
+ selectAllOptions: PropTypes.object.isRequired,
54
+ reloadPage: PropTypes.func.isRequired,
59
55
  };
60
56
 
61
57
  BulkTaskModal.defaultProps = {
@@ -1,8 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { useSelector } from 'react-redux';
4
3
  import { sprintf } from 'foremanReact/common/I18n';
5
- import { selectClicked } from './ConfirmModalSelectors';
6
4
  import { GenericConfirmModal } from './GenericConfirmModal';
7
5
 
8
6
  export const createTaskModal = ({
@@ -12,16 +10,14 @@ export const createTaskModal = ({
12
10
  confirmButtonVariant = 'primary',
13
11
  ouiaIdPrefix,
14
12
  }) => {
15
- const TaskModal = ({ isModalOpen, setIsModalOpen, url, parentTaskID }) => {
16
- const { taskId, taskName } = useSelector(selectClicked);
17
-
18
- const handleConfirm = () =>
19
- actionCreator({
20
- taskId,
21
- taskName,
22
- url,
23
- parentTaskID,
24
- });
13
+ const TaskModal = ({
14
+ isModalOpen,
15
+ setIsModalOpen,
16
+ reloadPage,
17
+ taskId,
18
+ taskName,
19
+ }) => {
20
+ const handleConfirm = () => actionCreator(taskId, taskName, reloadPage);
25
21
 
26
22
  return (
27
23
  <GenericConfirmModal
@@ -39,12 +35,14 @@ export const createTaskModal = ({
39
35
  TaskModal.propTypes = {
40
36
  isModalOpen: PropTypes.bool.isRequired,
41
37
  setIsModalOpen: PropTypes.func.isRequired,
42
- url: PropTypes.string.isRequired,
43
- parentTaskID: PropTypes.string,
38
+ reloadPage: PropTypes.func.isRequired,
39
+ taskId: PropTypes.string,
40
+ taskName: PropTypes.string,
44
41
  };
45
42
 
46
43
  TaskModal.defaultProps = {
47
- parentTaskID: null,
44
+ taskId: null,
45
+ taskName: null,
48
46
  };
49
47
 
50
48
  return TaskModal;
@@ -2,10 +2,10 @@ import { translate as __ } from 'foremanReact/common/I18n';
2
2
  import { createTaskModal } from './createTaskModal';
3
3
  import { createBulkTaskModal } from './createBulkTaskModal';
4
4
  import {
5
- cancelTask,
6
- forceCancelTask,
7
- resumeTask,
8
- } from '../../TasksTableActions';
5
+ cancelTaskRequest,
6
+ resumeTaskRequest,
7
+ forceCancelTaskRequest,
8
+ } from '../../../TaskActions';
9
9
  import {
10
10
  bulkCancelBySearch,
11
11
  bulkCancelById,
@@ -16,7 +16,7 @@ import {
16
16
  } from '../../TasksBulkActions';
17
17
 
18
18
  export const CancelModal = createTaskModal({
19
- actionCreator: cancelTask,
19
+ actionCreator: cancelTaskRequest,
20
20
  title: __('Cancel Task'),
21
21
  messageTemplate: __(
22
22
  'This will cancel task "%(taskName)s", putting it in the stopped state. Are you sure?'
@@ -37,7 +37,7 @@ export const CancelSelectedModal = createBulkTaskModal({
37
37
  });
38
38
 
39
39
  export const ForceUnlockModal = createTaskModal({
40
- actionCreator: forceCancelTask,
40
+ actionCreator: forceCancelTaskRequest,
41
41
  title: __('Force Unlock Task'),
42
42
  messageTemplate: __(
43
43
  'This will force unlock task "%(taskName)s". This may cause harm and should be used with caution. Are you sure?'
@@ -58,7 +58,7 @@ export const ForceUnlockSelectedModal = createBulkTaskModal({
58
58
  });
59
59
 
60
60
  export const ResumeModal = createTaskModal({
61
- actionCreator: resumeTask,
61
+ actionCreator: resumeTaskRequest,
62
62
  title: __('Resume Task'),
63
63
  messageTemplate: __(
64
64
  'This will resume task "%(taskName)s", putting it in the running state. Are you sure?'