foreman-tasks 0.17.6 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc +2 -22
  3. data/.rubocop.yml +12 -12
  4. data/.rubocop_todo.yml +34 -116
  5. data/.travis.yml +2 -2
  6. data/app/controllers/foreman_tasks/api/recurring_logics_controller.rb +20 -1
  7. data/app/controllers/foreman_tasks/api/tasks_controller.rb +66 -11
  8. data/app/controllers/foreman_tasks/concerns/hosts_controller_extension.rb +1 -1
  9. data/app/controllers/foreman_tasks/recurring_logics_controller.rb +19 -0
  10. data/app/controllers/foreman_tasks/tasks_controller.rb +3 -11
  11. data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +0 -2
  12. data/app/lib/actions/helpers/humanizer.rb +1 -3
  13. data/app/lib/actions/proxy_action.rb +33 -12
  14. data/app/lib/foreman_tasks/concerns/polling_action_extensions.rb +12 -0
  15. data/app/models/foreman_tasks/concerns/action_triggering.rb +1 -1
  16. data/app/models/foreman_tasks/recurring_logic.rb +1 -0
  17. data/app/models/foreman_tasks/remote_task.rb +1 -0
  18. data/app/models/foreman_tasks/task.rb +8 -0
  19. data/app/models/foreman_tasks/task/dynflow_task.rb +1 -1
  20. data/app/models/foreman_tasks/task/search.rb +11 -1
  21. data/app/models/setting/foreman_tasks.rb +7 -2
  22. data/app/services/ui_notifications/tasks/task_bulk_cancel.rb +36 -0
  23. data/app/services/ui_notifications/tasks/task_bulk_resume.rb +38 -0
  24. data/app/services/ui_notifications/tasks/task_bulk_stop.rb +36 -0
  25. data/app/views/foreman_tasks/api/recurring_logics/base.json.rabl +2 -1
  26. data/app/views/foreman_tasks/api/tasks/details.json.rabl +1 -1
  27. data/app/views/foreman_tasks/api/tasks/show.json.rabl +1 -1
  28. data/app/views/foreman_tasks/recurring_logics/index.html.erb +30 -0
  29. data/app/views/foreman_tasks/tasks/show.html.erb +3 -0
  30. data/babel.config.js +3 -0
  31. data/config/routes.rb +8 -0
  32. data/db/migrate/20200517215015_rename_bookmarks_controller.rb +35 -0
  33. data/db/migrate/20200519093217_drop_dynflow_allow_dangerous_actions_setting.foreman_tasks.rb +5 -0
  34. data/db/seeds.d/30-notification_blueprints.rb +21 -0
  35. data/foreman-tasks.gemspec +5 -6
  36. data/gemfile.d/foreman-tasks.rb +1 -0
  37. data/lib/foreman_tasks/dynflow/console_authorizer.rb +2 -2
  38. data/lib/foreman_tasks/engine.rb +17 -14
  39. data/lib/foreman_tasks/tasks/cleanup.rake +1 -1
  40. data/lib/foreman_tasks/tasks/export_tasks.rake +2 -2
  41. data/lib/foreman_tasks/test_extensions.rb +1 -1
  42. data/lib/foreman_tasks/version.rb +1 -1
  43. data/locale/action_names.rb +2 -2
  44. data/locale/en/foreman_tasks.po +227 -41
  45. data/locale/foreman_tasks.pot +579 -288
  46. data/package.json +19 -79
  47. data/script/rails +2 -2
  48. data/script/travis_run_js_tests.sh +2 -2
  49. data/test/controllers/api/tasks_controller_test.rb +9 -0
  50. data/test/factories/task_factory.rb +34 -2
  51. data/test/foreman_tasks_test_helper.rb +4 -0
  52. data/test/lib/concerns/polling_action_extensions_test.rb +34 -0
  53. data/test/unit/actions/action_with_sub_plans_test.rb +1 -1
  54. data/test/unit/task_test.rb +160 -74
  55. data/webpack/ForemanTasks/Components/TaskActions/TaskAction.test.js +60 -0
  56. data/webpack/ForemanTasks/Components/TaskActions/TaskActionHelpers.js +67 -0
  57. data/webpack/ForemanTasks/Components/TaskActions/TaskActionHelpers.test.js +46 -0
  58. data/webpack/ForemanTasks/Components/TaskActions/TaskActionsConstants.js +16 -0
  59. data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.js +60 -0
  60. data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.test.js +14 -0
  61. data/webpack/ForemanTasks/Components/TaskActions/__snapshots__/TaskAction.test.js.snap +233 -0
  62. data/webpack/ForemanTasks/Components/TaskActions/__snapshots__/UnlockModals.test.js.snap +25 -0
  63. data/webpack/ForemanTasks/Components/TaskActions/index.js +115 -0
  64. data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +132 -150
  65. data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskInfo.js +1 -4
  66. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Errors.test.js +1 -1
  67. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Locks.test.js +1 -1
  68. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Raw.test.js +1 -1
  69. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/RunningSteps.test.js +1 -1
  70. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +68 -3
  71. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskInfo.test.js +1 -2
  72. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +104 -71
  73. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskInfo.test.js.snap +9 -15
  74. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.stories.js +6 -2
  75. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +2 -17
  76. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsConstants.js +0 -5
  77. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js +0 -6
  78. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +3 -9
  79. data/webpack/ForemanTasks/Components/TaskDetails/TasksDetailsHelper.js +6 -1
  80. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +6 -1
  81. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js +1 -1
  82. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsReducer.test.js +1 -1
  83. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +3 -7
  84. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/integration.test.js +5 -1
  85. data/webpack/ForemanTasks/Components/TaskDetails/index.js +6 -8
  86. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.stories.js +44 -40
  87. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.test.js +1 -1
  88. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.stories.js +45 -40
  89. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.test.js +1 -1
  90. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.stories.js +27 -22
  91. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.test.js +1 -1
  92. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.stories.js +61 -56
  93. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.test.js +1 -1
  94. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.stories.js +40 -35
  95. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.test.js +1 -1
  96. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.stories.js +21 -20
  97. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.test.js +1 -1
  98. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.stories.js +40 -39
  99. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.test.js +1 -1
  100. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.stories.js +16 -17
  101. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js +1 -2
  102. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.stories.mdx +57 -0
  103. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.test.js +1 -1
  104. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.stories.js +36 -18
  105. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.test.js +1 -1
  106. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardConstants.js +5 -0
  107. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardHelper.js +3 -2
  108. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboard.test.js +1 -1
  109. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardActions.test.js +1 -1
  110. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardReducer.test.js +1 -1
  111. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardSelectors.test.js +1 -1
  112. data/webpack/ForemanTasks/Components/TasksTable/Components/ActionSelectButton.js +14 -1
  113. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModal.js +83 -0
  114. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalActions.js +106 -0
  115. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalReducer.js +38 -0
  116. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js +45 -0
  117. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModal.test.js +36 -0
  118. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalActions.test.js +205 -0
  119. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalReducer.test.js +27 -0
  120. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalSelectors.test.js +54 -0
  121. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModal.test.js.snap +41 -0
  122. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalReducer.test.js.snap +19 -0
  123. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalSelectors.test.js.snap +30 -0
  124. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/index.js +29 -0
  125. data/webpack/ForemanTasks/Components/TasksTable/Components/SelectAllAlert.js +43 -0
  126. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionSelectButton.test.js +2 -1
  127. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/SelectAllAlert.test.js +29 -0
  128. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/TableSelectionCell.test.js +1 -1
  129. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/TableSelectionHeaderCell.test.js +1 -1
  130. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ActionSelectButton.test.js.snap +11 -0
  131. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/SelectAllAlert.test.js.snap +75 -0
  132. data/webpack/ForemanTasks/Components/TasksTable/SubTasksPage.js +4 -1
  133. data/webpack/ForemanTasks/Components/TasksTable/TasksBulkActions.js +247 -0
  134. data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +50 -22
  135. data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +62 -101
  136. data/webpack/ForemanTasks/Components/TasksTable/TasksTableConstants.js +18 -5
  137. data/webpack/ForemanTasks/Components/TasksTable/TasksTableHelpers.js +4 -3
  138. data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +65 -38
  139. data/webpack/ForemanTasks/Components/TasksTable/TasksTableReducer.js +26 -9
  140. data/webpack/ForemanTasks/Components/TasksTable/TasksTableSchema.js +2 -2
  141. data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +27 -16
  142. data/webpack/ForemanTasks/Components/TasksTable/__tests__/SubTasksPage.test.js +1 -1
  143. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksBulkActions.test.js +147 -0
  144. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksIndexPage.test.js +1 -1
  145. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +4 -7
  146. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.test.js +1 -1
  147. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableActions.test.js +46 -74
  148. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js +17 -1
  149. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTablePage.test.js +10 -2
  150. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js +28 -8
  151. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +5 -7
  152. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksBulkActions.test.js.snap +336 -0
  153. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +4 -7
  154. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableActions.test.js.snap +22 -158
  155. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +66 -44
  156. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableReducer.test.js.snap +43 -16
  157. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/selectionHeaderCellFormatter.test.js +1 -1
  158. data/webpack/ForemanTasks/Components/TasksTable/formatters/selectionHeaderCellFormatter.js +2 -2
  159. data/webpack/ForemanTasks/Components/TasksTable/index.js +11 -4
  160. data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js +49 -21
  161. data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js +61 -14
  162. data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap +80 -21
  163. data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.scss +9 -0
  164. data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.test.js +44 -0
  165. data/webpack/ForemanTasks/Components/common/ClickConfirmation/__snapshots__/ClickConfirmation.test.js.snap +52 -0
  166. data/webpack/ForemanTasks/Components/common/ClickConfirmation/index.js +59 -66
  167. data/webpack/ForemanTasks/Components/common/ToastsHelpers/ToastTypesConstants.js +11 -0
  168. data/webpack/ForemanTasks/Components/common/ToastsHelpers/index.js +15 -0
  169. data/webpack/ForemanTasks/ForemanTasks.test.js +1 -1
  170. data/webpack/ForemanTasks/ForemanTasksReducers.js +2 -0
  171. data/webpack/ForemanTasks/Routes/ForemanTasksRouter.test.js +1 -1
  172. data/webpack/ForemanTasks/Routes/ForemanTasksRoutes.test.js +4 -4
  173. data/webpack/ForemanTasks/Routes/ShowTask/__tests__/ShowTask.test.js +1 -1
  174. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +2 -0
  175. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalHooks.js +10 -0
  176. data/webpack/__mocks__/foremanReact/components/ForemanModal/index.js +18 -0
  177. data/webpack/__mocks__/foremanReact/components/common/ActionButtons/ActionButtons.js +3 -0
  178. metadata +71 -30
  179. data/.babelrc +0 -35
  180. data/.storybook/addons.js +0 -2
  181. data/.storybook/config.js +0 -7
  182. data/.storybook/webpack.config.js +0 -63
  183. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.stories.js +0 -23
  184. data/webpack/ForemanTasks/Components/TasksTable/Components/ActionConfirmation.js +0 -49
  185. data/webpack/ForemanTasks/Components/TasksTable/Components/CancelResumeConfirm.js +0 -51
  186. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionConfirmation.test.js +0 -18
  187. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/CancelResumeConfirm.test.js +0 -28
  188. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ActionConfirmation.test.js.snap +0 -89
  189. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/CancelResumeConfirm.test.js.snap +0 -37
  190. data/webpack/ForemanTasks/Components/common/ActionButtons/CancelButton.js +0 -23
  191. data/webpack/ForemanTasks/Components/common/ActionButtons/CancelButton.test.js +0 -27
  192. data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.js +0 -23
  193. data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.test.js +0 -27
  194. data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/CancelButton.test.js.snap +0 -15
  195. data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ResumeButton.test.js.snap +0 -15
  196. data/webpack/stories/index.js +0 -10
  197. data/webpack/stories/index.scss +0 -7
  198. data/webpack/test_setup.js +0 -6
@@ -1,9 +1,26 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`TasksTableReducer reducer should handle OPEN_SELECT_ALL 1`] = `
4
+ Object {
5
+ "tasksTableQuery": Object {
6
+ "selectedRows": Array [],
7
+ "showSelectAll": true,
8
+ },
9
+ }
10
+ `;
11
+
12
+ exports[`TasksTableReducer reducer should handle SELECT_ALL_ROWS 1`] = `
13
+ Object {
14
+ "tasksTableQuery": Object {
15
+ "allRowsSelected": true,
16
+ "selectedRows": Array [],
17
+ },
18
+ }
19
+ `;
20
+
3
21
  exports[`TasksTableReducer reducer should handle SELECT_ROWS 1`] = `
4
22
  Object {
5
23
  "tasksTableQuery": Object {
6
- "modalStatus": "CLOSED",
7
24
  "selectedRows": Array [
8
25
  1,
9
26
  2,
@@ -17,19 +34,9 @@ Object {
17
34
  }
18
35
  `;
19
36
 
20
- exports[`TasksTableReducer reducer should handle TASKS_TABLE_SELECTED_MODAL 1`] = `
21
- Object {
22
- "tasksTableQuery": Object {
23
- "modalStatus": "RESUME",
24
- "selectedRows": Array [],
25
- },
26
- }
27
- `;
28
-
29
37
  exports[`TasksTableReducer reducer should handle TASKS_TABLE_SET_PAGINATION 1`] = `
30
38
  Object {
31
39
  "tasksTableQuery": Object {
32
- "modalStatus": "CLOSED",
33
40
  "selectedRows": Array [],
34
41
  },
35
42
  }
@@ -38,7 +45,6 @@ Object {
38
45
  exports[`TasksTableReducer reducer should handle TASKS_TABLE_SET_SORT 1`] = `
39
46
  Object {
40
47
  "tasksTableQuery": Object {
41
- "modalStatus": "CLOSED",
42
48
  "selectedRows": Array [],
43
49
  },
44
50
  }
@@ -49,7 +55,6 @@ Object {
49
55
  "tasksTableQuery": Object {
50
56
  "actionName": undefined,
51
57
  "itemCount": 120,
52
- "modalStatus": "CLOSED",
53
58
  "pagination": Object {
54
59
  "page": 3,
55
60
  "perPage": 12,
@@ -62,8 +67,9 @@ Object {
62
67
  exports[`TasksTableReducer reducer should handle UNSELECT_ALL_ROWS 1`] = `
63
68
  Object {
64
69
  "tasksTableQuery": Object {
65
- "modalStatus": "CLOSED",
70
+ "allRowsSelected": false,
66
71
  "selectedRows": Array [],
72
+ "showSelectAll": false,
67
73
  },
68
74
  }
69
75
  `;
@@ -71,7 +77,29 @@ Object {
71
77
  exports[`TasksTableReducer reducer should handle UNSELECT_ROWS 1`] = `
72
78
  Object {
73
79
  "tasksTableQuery": Object {
74
- "modalStatus": "CLOSED",
80
+ "selectedRows": Array [],
81
+ },
82
+ }
83
+ `;
84
+
85
+ exports[`TasksTableReducer reducer should handle UNSELECT_ROWS with all rows selected 1`] = `
86
+ Object {
87
+ "tasksTableQuery": Object {
88
+ "allRowsSelected": false,
89
+ "selectedRows": Array [
90
+ 3,
91
+ 4,
92
+ 5,
93
+ ],
94
+ "showSelectAll": false,
95
+ },
96
+ }
97
+ `;
98
+
99
+ exports[`TasksTableReducer reducer should handle UPDATE_CLICKED 1`] = `
100
+ Object {
101
+ "tasksTableQuery": Object {
102
+ "clicked": "task",
75
103
  "selectedRows": Array [],
76
104
  },
77
105
  }
@@ -80,7 +108,6 @@ Object {
80
108
  exports[`TasksTableReducer reducer should return the initial state 1`] = `
81
109
  Object {
82
110
  "tasksTableQuery": Object {
83
- "modalStatus": "CLOSED",
84
111
  "selectedRows": Array [],
85
112
  },
86
113
  }
@@ -4,7 +4,7 @@ describe('selectionHeaderCellFormatter', () => {
4
4
  it('render', () => {
5
5
  expect(
6
6
  selectionHeaderCellFormatter(
7
- { allRowsSelected: () => true },
7
+ { allPageSelected: () => true },
8
8
  'some-label'
9
9
  )
10
10
  ).toMatchSnapshot();
@@ -4,7 +4,7 @@ import TableSelectionHeaderCell from '../Components/TableSelectionHeaderCell';
4
4
  export default (selectionController, label) => (
5
5
  <TableSelectionHeaderCell
6
6
  label={label}
7
- checked={selectionController.allRowsSelected()}
8
- onChange={() => selectionController.selectAllRows()}
7
+ checked={selectionController.allPageSelected()}
8
+ onChange={selectionController.selectPage}
9
9
  />
10
10
  );
@@ -2,7 +2,8 @@ import { connect } from 'react-redux';
2
2
  import { bindActionCreators } from 'redux';
3
3
  import TasksTablePage from './TasksTablePage';
4
4
  import reducer from './TasksTableReducer';
5
- import * as actions from './TasksTableActions';
5
+ import * as tableActions from './TasksTableActions';
6
+ import * as bulkActions from './TasksBulkActions';
6
7
  import {
7
8
  selectStatus,
8
9
  selectError,
@@ -12,7 +13,9 @@ import {
12
13
  selectSort,
13
14
  selectActionName,
14
15
  selectSelectedRows,
15
- selectModalStatus,
16
+ selectAllRowsSelected,
17
+ selectShowSelectAll,
18
+ selectModalID,
16
19
  } from './TasksTableSelectors';
17
20
 
18
21
  const mapStateToProps = state => ({
@@ -24,9 +27,13 @@ const mapStateToProps = state => ({
24
27
  itemCount: selectItemCount(state),
25
28
  actionName: selectActionName(state),
26
29
  selectedRows: selectSelectedRows(state),
27
- modalStatus: selectModalStatus(state),
30
+ allRowsSelected: selectAllRowsSelected(state),
31
+ showSelectAll: selectShowSelectAll(state),
32
+ modalID: selectModalID(state),
28
33
  });
29
- const mapDispatchToProps = dispatch => bindActionCreators(actions, dispatch);
34
+
35
+ const mapDispatchToProps = dispatch =>
36
+ bindActionCreators({ ...tableActions, ...bulkActions }, dispatch);
30
37
 
31
38
  export const reducers = { tasksTable: reducer };
32
39
 
@@ -1,27 +1,53 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { CancelButton } from './CancelButton';
4
- import { ResumeButton } from './ResumeButton';
3
+ import { translate as __ } from 'foremanReact/common/I18n';
4
+ import { ActionButtons } from 'foremanReact/components/common/ActionButtons/ActionButtons';
5
5
 
6
- export const ActionButton = ({ id, name, availableActions, taskActions }) => {
7
- const isResume = availableActions.resumable;
8
- if (isResume) {
9
- return (
10
- <ResumeButton
11
- id={id}
12
- name={name}
13
- onClick={taskActions.resume}
14
- disabled={false}
15
- />
16
- );
6
+ export const ActionButton = ({
7
+ id,
8
+ name,
9
+ availableActions: { resumable, cancellable, stoppable },
10
+ taskActions,
11
+ }) => {
12
+ const buttons = [];
13
+ const isTitle = !(resumable || cancellable || stoppable);
14
+ const title = isTitle ? __('Task cannot be canceled') : undefined;
15
+ if (resumable) {
16
+ buttons.push({
17
+ title: __('Resume'),
18
+ action: {
19
+ disabled: !resumable,
20
+ onClick: () => taskActions.resumeTask(id, name),
21
+ id: `task-resume-button-${id}`,
22
+ },
23
+ });
24
+ }
25
+ if (cancellable || (!stoppable && !resumable)) {
26
+ // Cancel is the default button that should be shown if no task action can be done
27
+ buttons.push({
28
+ title: __('Cancel'),
29
+ action: {
30
+ disabled: !cancellable,
31
+ onClick: () => taskActions.cancelTask(id, name),
32
+ id: `task-cancel-button-${id}`,
33
+ },
34
+ });
35
+ }
36
+
37
+ if (stoppable) {
38
+ buttons.push({
39
+ title: __('Force Cancel'),
40
+ action: {
41
+ disabled: !stoppable,
42
+ onClick: () => taskActions.forceCancelTask(id, name),
43
+ id: `task-force-cancel-button-${id}`,
44
+ },
45
+ });
17
46
  }
18
47
  return (
19
- <CancelButton
20
- id={id}
21
- name={name}
22
- disabled={!availableActions.cancellable}
23
- onClick={taskActions.cancel}
24
- />
48
+ <span title={title}>
49
+ <ActionButtons buttons={buttons} />
50
+ </span>
25
51
  );
26
52
  };
27
53
 
@@ -31,9 +57,11 @@ ActionButton.propTypes = {
31
57
  availableActions: PropTypes.shape({
32
58
  cancellable: PropTypes.bool,
33
59
  resumable: PropTypes.bool,
60
+ stoppable: PropTypes.bool,
34
61
  }).isRequired,
35
62
  taskActions: PropTypes.shape({
36
- cancel: PropTypes.func,
37
- resume: PropTypes.func,
63
+ cancelTask: PropTypes.func,
64
+ resumeTask: PropTypes.func,
65
+ forceCancelTask: PropTypes.func,
38
66
  }).isRequired,
39
67
  };
@@ -1,17 +1,19 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import React from 'react';
2
+ import { testComponentSnapshotsWithFixtures, shallow } from '@theforeman/test';
2
3
 
3
4
  import { ActionButton } from './ActionButton';
4
5
 
6
+ const resumeTask = jest.fn();
7
+ const cancelTask = jest.fn();
8
+ const forceCancelTask = jest.fn();
9
+ const taskActions = { resumeTask, cancelTask, forceCancelTask };
5
10
  const fixtures = {
6
11
  'render with cancellable true props': {
7
12
  availableActions: {
8
13
  cancellable: true,
9
14
  resumable: false,
10
15
  },
11
- taskActions: {
12
- cancel: jest.fn(),
13
- resume: jest.fn(),
14
- },
16
+ taskActions,
15
17
  id: 'id',
16
18
  name: 'some-name',
17
19
  },
@@ -20,10 +22,16 @@ const fixtures = {
20
22
  cancellable: false,
21
23
  resumable: true,
22
24
  },
23
- taskActions: {
24
- cancel: jest.fn(),
25
- resume: jest.fn(),
25
+ taskActions,
26
+ id: 'id',
27
+ name: 'some-name',
28
+ },
29
+ 'render with stoppable and cancellable true props': {
30
+ availableActions: {
31
+ cancellable: true,
32
+ stoppable: true,
26
33
  },
34
+ taskActions,
27
35
  id: 'id',
28
36
  name: 'some-name',
29
37
  },
@@ -32,14 +40,53 @@ const fixtures = {
32
40
  cancellable: false,
33
41
  resumable: false,
34
42
  },
35
- taskActions: {
36
- cancel: jest.fn(),
37
- resume: jest.fn(),
38
- },
43
+ taskActions,
39
44
  id: 'id',
40
45
  name: 'some-name',
41
46
  },
42
47
  };
43
48
 
44
- describe('ActionButton', () =>
45
- testComponentSnapshotsWithFixtures(ActionButton, fixtures));
49
+ describe('ActionButton', () => {
50
+ describe('snapshot test', () =>
51
+ testComponentSnapshotsWithFixtures(ActionButton, fixtures));
52
+ describe('click test', () => {
53
+ const id = 'some-id';
54
+ const name = 'some-name';
55
+ it('cancel', () => {
56
+ const component = shallow(
57
+ <ActionButton
58
+ id={id}
59
+ name={name}
60
+ availableActions={{ cancellable: true }}
61
+ taskActions={taskActions}
62
+ />
63
+ ).children();
64
+ component.props().buttons[0].action.onClick();
65
+ expect(cancelTask).toHaveBeenCalledWith(id, name);
66
+ });
67
+ it('resume', () => {
68
+ const component = shallow(
69
+ <ActionButton
70
+ id={id}
71
+ name={name}
72
+ availableActions={{ resumable: true }}
73
+ taskActions={taskActions}
74
+ />
75
+ ).children();
76
+ component.props().buttons[0].action.onClick();
77
+ expect(resumeTask).toHaveBeenCalledWith(id, name);
78
+ });
79
+ it('force cancel', () => {
80
+ const component = shallow(
81
+ <ActionButton
82
+ id={id}
83
+ name={name}
84
+ availableActions={{ stoppable: true }}
85
+ taskActions={taskActions}
86
+ />
87
+ ).children();
88
+ component.props().buttons[0].action.onClick();
89
+ expect(cancelTask).toHaveBeenCalledWith(id, name);
90
+ });
91
+ });
92
+ });
@@ -1,28 +1,87 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`ActionButton render with cancellable false props 1`] = `
4
- <CancelButton
5
- disabled={true}
6
- id="id"
7
- name="some-name"
8
- onClick={[MockFunction]}
9
- />
3
+ exports[`ActionButton snapshot test render with cancellable false props 1`] = `
4
+ <span
5
+ title="Task cannot be canceled"
6
+ >
7
+ <ActionButtons
8
+ buttons={
9
+ Array [
10
+ Object {
11
+ "action": Object {
12
+ "disabled": true,
13
+ "id": "task-cancel-button-id",
14
+ "onClick": [Function],
15
+ },
16
+ "title": "Cancel",
17
+ },
18
+ ]
19
+ }
20
+ />
21
+ </span>
10
22
  `;
11
23
 
12
- exports[`ActionButton render with cancellable true props 1`] = `
13
- <CancelButton
14
- disabled={false}
15
- id="id"
16
- name="some-name"
17
- onClick={[MockFunction]}
18
- />
24
+ exports[`ActionButton snapshot test render with cancellable true props 1`] = `
25
+ <span>
26
+ <ActionButtons
27
+ buttons={
28
+ Array [
29
+ Object {
30
+ "action": Object {
31
+ "disabled": false,
32
+ "id": "task-cancel-button-id",
33
+ "onClick": [Function],
34
+ },
35
+ "title": "Cancel",
36
+ },
37
+ ]
38
+ }
39
+ />
40
+ </span>
19
41
  `;
20
42
 
21
- exports[`ActionButton render with resumable true props 1`] = `
22
- <ResumeButton
23
- disabled={false}
24
- id="id"
25
- name="some-name"
26
- onClick={[MockFunction]}
27
- />
43
+ exports[`ActionButton snapshot test render with resumable true props 1`] = `
44
+ <span>
45
+ <ActionButtons
46
+ buttons={
47
+ Array [
48
+ Object {
49
+ "action": Object {
50
+ "disabled": false,
51
+ "id": "task-resume-button-id",
52
+ "onClick": [Function],
53
+ },
54
+ "title": "Resume",
55
+ },
56
+ ]
57
+ }
58
+ />
59
+ </span>
60
+ `;
61
+
62
+ exports[`ActionButton snapshot test render with stoppable and cancellable true props 1`] = `
63
+ <span>
64
+ <ActionButtons
65
+ buttons={
66
+ Array [
67
+ Object {
68
+ "action": Object {
69
+ "disabled": false,
70
+ "id": "task-cancel-button-id",
71
+ "onClick": [Function],
72
+ },
73
+ "title": "Cancel",
74
+ },
75
+ Object {
76
+ "action": Object {
77
+ "disabled": false,
78
+ "id": "task-force-cancel-button-id",
79
+ "onClick": [Function],
80
+ },
81
+ "title": "Force Cancel",
82
+ },
83
+ ]
84
+ }
85
+ />
86
+ </span>
28
87
  `;