foreman-tasks 1.0.0 → 2.0.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/README.md +2 -0
  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 +1 -3
  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/foreman_tasks/troubleshooting_help_generator.rb +0 -4
  23. data/app/services/ui_notifications/tasks/task_bulk_cancel.rb +36 -0
  24. data/app/services/ui_notifications/tasks/task_bulk_resume.rb +38 -0
  25. data/app/services/ui_notifications/tasks/task_bulk_stop.rb +36 -0
  26. data/app/views/foreman_tasks/api/recurring_logics/base.json.rabl +2 -1
  27. data/app/views/foreman_tasks/api/tasks/details.json.rabl +1 -1
  28. data/app/views/foreman_tasks/api/tasks/show.json.rabl +1 -1
  29. data/app/views/foreman_tasks/recurring_logics/index.html.erb +30 -0
  30. data/app/views/foreman_tasks/tasks/show.html.erb +3 -0
  31. data/{.babelrc.js → babel.config.js} +0 -0
  32. data/config/routes.rb +8 -0
  33. data/db/migrate/20200517215015_rename_bookmarks_controller.rb +35 -0
  34. data/db/migrate/20200519093217_drop_dynflow_allow_dangerous_actions_setting.foreman_tasks.rb +5 -0
  35. data/db/seeds.d/30-notification_blueprints.rb +21 -0
  36. data/foreman-tasks.gemspec +5 -6
  37. data/gemfile.d/foreman-tasks.rb +1 -0
  38. data/lib/foreman_tasks/dynflow/console_authorizer.rb +2 -2
  39. data/lib/foreman_tasks/engine.rb +17 -14
  40. data/lib/foreman_tasks/tasks/cleanup.rake +1 -1
  41. data/lib/foreman_tasks/tasks/export_tasks.rake +2 -2
  42. data/lib/foreman_tasks/test_extensions.rb +1 -1
  43. data/lib/foreman_tasks/version.rb +1 -1
  44. data/locale/action_names.rb +2 -2
  45. data/locale/en/foreman_tasks.po +227 -41
  46. data/locale/foreman_tasks.pot +579 -288
  47. data/package.json +18 -71
  48. data/script/rails +2 -2
  49. data/script/travis_run_js_tests.sh +2 -2
  50. data/test/controllers/api/tasks_controller_test.rb +9 -0
  51. data/test/factories/task_factory.rb +34 -2
  52. data/test/foreman_tasks_test_helper.rb +4 -0
  53. data/test/lib/concerns/polling_action_extensions_test.rb +34 -0
  54. data/test/unit/actions/action_with_sub_plans_test.rb +1 -1
  55. data/test/unit/task_test.rb +160 -74
  56. data/webpack/ForemanTasks/Components/TaskActions/TaskAction.test.js +60 -0
  57. data/webpack/ForemanTasks/Components/TaskActions/TaskActionHelpers.js +67 -0
  58. data/webpack/ForemanTasks/Components/TaskActions/TaskActionHelpers.test.js +46 -0
  59. data/webpack/ForemanTasks/Components/TaskActions/TaskActionsConstants.js +16 -0
  60. data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.js +60 -0
  61. data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.test.js +14 -0
  62. data/webpack/ForemanTasks/Components/TaskActions/__snapshots__/TaskAction.test.js.snap +233 -0
  63. data/webpack/ForemanTasks/Components/TaskActions/__snapshots__/UnlockModals.test.js.snap +25 -0
  64. data/webpack/ForemanTasks/Components/TaskActions/index.js +115 -0
  65. data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +132 -150
  66. data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskInfo.js +3 -12
  67. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Errors.test.js +1 -1
  68. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Locks.test.js +1 -1
  69. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Raw.test.js +1 -1
  70. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/RunningSteps.test.js +1 -1
  71. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +68 -3
  72. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskInfo.test.js +1 -2
  73. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +104 -71
  74. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskInfo.test.js.snap +3 -9
  75. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.stories.js +6 -2
  76. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +0 -15
  77. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsConstants.js +0 -5
  78. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js +0 -6
  79. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +4 -10
  80. data/webpack/ForemanTasks/Components/TaskDetails/TasksDetailsHelper.js +6 -1
  81. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +6 -1
  82. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js +1 -1
  83. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsReducer.test.js +1 -1
  84. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +3 -7
  85. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/integration.test.js +5 -1
  86. data/webpack/ForemanTasks/Components/TaskDetails/index.js +6 -8
  87. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.stories.js +44 -40
  88. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.test.js +1 -1
  89. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.stories.js +45 -40
  90. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.test.js +1 -1
  91. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.stories.js +27 -22
  92. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.test.js +1 -1
  93. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.stories.js +61 -56
  94. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.test.js +1 -1
  95. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.stories.js +40 -35
  96. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.test.js +1 -1
  97. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.stories.js +21 -20
  98. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.test.js +1 -1
  99. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.stories.js +40 -39
  100. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.test.js +1 -1
  101. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.stories.js +16 -17
  102. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js +1 -2
  103. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.stories.mdx +57 -0
  104. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.test.js +1 -1
  105. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.stories.js +36 -18
  106. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.test.js +1 -1
  107. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardConstants.js +5 -0
  108. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardHelper.js +3 -2
  109. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboard.test.js +1 -1
  110. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardActions.test.js +1 -1
  111. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardReducer.test.js +1 -1
  112. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardSelectors.test.js +1 -1
  113. data/webpack/ForemanTasks/Components/TasksTable/Components/ActionSelectButton.js +14 -1
  114. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModal.js +83 -0
  115. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalActions.js +106 -0
  116. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalReducer.js +38 -0
  117. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js +45 -0
  118. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModal.test.js +36 -0
  119. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalActions.test.js +205 -0
  120. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalReducer.test.js +27 -0
  121. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalSelectors.test.js +54 -0
  122. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModal.test.js.snap +41 -0
  123. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalReducer.test.js.snap +19 -0
  124. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalSelectors.test.js.snap +30 -0
  125. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/index.js +29 -0
  126. data/webpack/ForemanTasks/Components/TasksTable/Components/SelectAllAlert.js +43 -0
  127. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionSelectButton.test.js +2 -1
  128. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/SelectAllAlert.test.js +29 -0
  129. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/TableSelectionCell.test.js +1 -1
  130. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/TableSelectionHeaderCell.test.js +1 -1
  131. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ActionSelectButton.test.js.snap +11 -0
  132. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/SelectAllAlert.test.js.snap +75 -0
  133. data/webpack/ForemanTasks/Components/TasksTable/SubTasksPage.js +4 -1
  134. data/webpack/ForemanTasks/Components/TasksTable/TasksBulkActions.js +247 -0
  135. data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +50 -22
  136. data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +62 -101
  137. data/webpack/ForemanTasks/Components/TasksTable/TasksTableConstants.js +21 -9
  138. data/webpack/ForemanTasks/Components/TasksTable/TasksTableHelpers.js +4 -3
  139. data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +65 -38
  140. data/webpack/ForemanTasks/Components/TasksTable/TasksTableReducer.js +26 -9
  141. data/webpack/ForemanTasks/Components/TasksTable/TasksTableSchema.js +2 -2
  142. data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +27 -16
  143. data/webpack/ForemanTasks/Components/TasksTable/__tests__/SubTasksPage.test.js +1 -1
  144. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksBulkActions.test.js +147 -0
  145. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksIndexPage.test.js +1 -1
  146. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +4 -7
  147. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.test.js +1 -1
  148. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableActions.test.js +46 -74
  149. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js +17 -1
  150. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTablePage.test.js +10 -2
  151. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js +28 -8
  152. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +5 -7
  153. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksBulkActions.test.js.snap +336 -0
  154. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +4 -7
  155. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableActions.test.js.snap +22 -158
  156. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +64 -42
  157. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableReducer.test.js.snap +43 -16
  158. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/selectionHeaderCellFormatter.test.js +1 -1
  159. data/webpack/ForemanTasks/Components/TasksTable/formatters/selectionHeaderCellFormatter.js +2 -2
  160. data/webpack/ForemanTasks/Components/TasksTable/index.js +11 -4
  161. data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js +49 -21
  162. data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js +61 -14
  163. data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap +80 -21
  164. data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.scss +9 -0
  165. data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.test.js +44 -0
  166. data/webpack/ForemanTasks/Components/common/ClickConfirmation/__snapshots__/ClickConfirmation.test.js.snap +52 -0
  167. data/webpack/ForemanTasks/Components/common/ClickConfirmation/index.js +59 -66
  168. data/webpack/ForemanTasks/Components/common/ToastsHelpers/ToastTypesConstants.js +11 -0
  169. data/webpack/ForemanTasks/Components/common/ToastsHelpers/index.js +15 -0
  170. data/webpack/ForemanTasks/ForemanTasks.test.js +1 -1
  171. data/webpack/ForemanTasks/ForemanTasksReducers.js +2 -0
  172. data/webpack/ForemanTasks/Routes/ForemanTasksRouter.test.js +1 -1
  173. data/webpack/ForemanTasks/Routes/ForemanTasksRoutes.test.js +4 -4
  174. data/webpack/ForemanTasks/Routes/ShowTask/__tests__/ShowTask.test.js +1 -1
  175. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +2 -0
  176. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalHooks.js +10 -0
  177. data/webpack/__mocks__/foremanReact/components/ForemanModal/index.js +18 -0
  178. data/webpack/__mocks__/foremanReact/components/common/ActionButtons/ActionButtons.js +3 -0
  179. metadata +71 -30
  180. data/.storybook/addons.js +0 -2
  181. data/.storybook/config.js +0 -7
  182. data/.storybook/webpack.config.js +0 -84
  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 -7
@@ -1,4 +1,4 @@
1
- import { updateURlQuery, getDuration } from '../TasksTableHelpers';
1
+ import { updateURlQuery, getDuration, getCSVurl } from '../TasksTableHelpers';
2
2
 
3
3
  describe('updateURlQuery', () => {
4
4
  it('should use url with new query', () => {
@@ -26,3 +26,19 @@ describe('updateURlQuery', () => {
26
26
  expect(duration.tooltip).toEqual('Task was canceled');
27
27
  });
28
28
  });
29
+
30
+ describe('getCSVurl', () => {
31
+ it('should return currect url for tasks with search', () => {
32
+ const url = '/foreman_tasks/tasks';
33
+ const query = { state: 'stopped' };
34
+ expect(getCSVurl(url, query)).toEqual(
35
+ '/foreman_tasks/tasks.csv?state=stopped'
36
+ );
37
+ });
38
+ it('should return currect url for subtasks', () => {
39
+ const url = '/foreman_tasks/tasks/some-id/sub_tasks';
40
+ expect(getCSVurl(url, {})).toEqual(
41
+ '/foreman_tasks/tasks/some-id/sub_tasks.csv'
42
+ );
43
+ });
44
+ });
@@ -1,12 +1,20 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
  import TasksTablePage from '../TasksTablePage';
3
3
  import { minProps } from './TasksTable.fixtures';
4
4
 
5
+ jest.mock('foremanReact/common/helpers', () => ({
6
+ getURIQuery: () => ({ state: 'stopped' }),
7
+ }));
8
+
9
+ const history = {
10
+ location: { pathname: '/foreman_tasks/tasks', search: '?action="some-name"' },
11
+ };
5
12
  const fixtures = {
6
- 'render with minimal props': minProps,
13
+ 'render with minimal props': { ...minProps, history },
7
14
 
8
15
  'render with Breadcrubs': {
9
16
  ...minProps,
17
+ history,
10
18
  getBreadcrumbs: () => ({
11
19
  breadcrumbItems: [
12
20
  { caption: 'Tasks', url: `/foreman_tasks/tasks` },
@@ -1,4 +1,5 @@
1
- import { testReducerSnapshotWithFixtures } from 'react-redux-test-utils';
1
+ import Immutable from 'seamless-immutable';
2
+ import { testReducerSnapshotWithFixtures } from '@theforeman/test';
2
3
  import {
3
4
  TASKS_TABLE_ID,
4
5
  TASKS_TABLE_SET_SORT,
@@ -6,8 +7,9 @@ import {
6
7
  SELECT_ROWS,
7
8
  UNSELECT_ROWS,
8
9
  UNSELECT_ALL_ROWS,
9
- TASKS_TABLE_SELECTED_MODAL,
10
- RESUME,
10
+ UPDATE_CLICKED,
11
+ SELECT_ALL_ROWS,
12
+ OPEN_SELECT_ALL,
11
13
  } from '../TasksTableConstants';
12
14
  import reducer from '../TasksTableReducer';
13
15
 
@@ -16,7 +18,7 @@ const fixtures = {
16
18
  'should handle TASKS_TABLE_SUCCESS': {
17
19
  action: {
18
20
  type: `${TASKS_TABLE_ID}_SUCCESS`,
19
- payload: {
21
+ response: {
20
22
  subtotal: 120,
21
23
  page: 3,
22
24
  per_page: 12,
@@ -45,7 +47,7 @@ const fixtures = {
45
47
  'should handle UNSELECT_ROWS': {
46
48
  action: {
47
49
  type: UNSELECT_ROWS,
48
- payload: 4,
50
+ payload: [{ id: 4 }],
49
51
  },
50
52
  },
51
53
  'should handle UNSELECT_ALL_ROWS': {
@@ -53,10 +55,28 @@ const fixtures = {
53
55
  type: UNSELECT_ALL_ROWS,
54
56
  },
55
57
  },
56
- 'should handle TASKS_TABLE_SELECTED_MODAL': {
58
+ 'should handle UPDATE_CLICKED': {
57
59
  action: {
58
- type: TASKS_TABLE_SELECTED_MODAL,
59
- payload: RESUME,
60
+ type: UPDATE_CLICKED,
61
+ payload: { clicked: 'task' },
62
+ },
63
+ },
64
+ 'should handle SELECT_ALL_ROWS': {
65
+ action: {
66
+ type: SELECT_ALL_ROWS,
67
+ payload: { clicked: 'task' },
68
+ },
69
+ },
70
+ 'should handle OPEN_SELECT_ALL': {
71
+ action: {
72
+ type: OPEN_SELECT_ALL,
73
+ },
74
+ },
75
+ 'should handle UNSELECT_ROWS with all rows selected': {
76
+ state: Immutable({ tasksTableQuery: { allRowsSelected: true } }),
77
+ action: {
78
+ type: UNSELECT_ROWS,
79
+ payload: { id: [4], results: [{ id: 3 }, { id: 4 }, { id: 5 }] },
60
80
  },
61
81
  },
62
82
  };
@@ -2,11 +2,9 @@
2
2
 
3
3
  exports[`SubTasksPage rendering render with minimal props 1`] = `
4
4
  <Connect(TasksTablePage)
5
- actionSelected={[MockFunction]}
6
- cancelTask={[MockFunction]}
5
+ createHeader={[Function]}
7
6
  getBreadcrumbs={[MockFunction]}
8
7
  getTableItems={[MockFunction]}
9
- hideSelcetedModal={[MockFunction]}
10
8
  history={
11
9
  Object {
12
10
  "location": Object {
@@ -22,6 +20,9 @@ exports[`SubTasksPage rendering render with minimal props 1`] = `
22
20
  },
23
21
  }
24
22
  }
23
+ openClickedModal={[MockFunction]}
24
+ openModal={[MockFunction]}
25
+ openModalAction={[MockFunction]}
25
26
  pagination={
26
27
  Object {
27
28
  "page": 1,
@@ -35,19 +36,16 @@ exports[`SubTasksPage rendering render with minimal props 1`] = `
35
36
  "b",
36
37
  ]
37
38
  }
38
- resumeTask={[MockFunction]}
39
39
  selectAllRows={[MockFunction]}
40
+ selectPage={[MockFunction]}
40
41
  selectRow={[MockFunction]}
41
42
  selectedRows={Array []}
42
- showCancelSelcetedModal={[MockFunction]}
43
- showResumeSelcetedModal={[MockFunction]}
44
43
  sort={
45
44
  Object {
46
45
  "by": "q",
47
46
  "order": "w",
48
47
  }
49
48
  }
50
- status="RESOLVED"
51
49
  unselectAllRows={[MockFunction]}
52
50
  unselectRow={[MockFunction]}
53
51
  />
@@ -0,0 +1,336 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`TasksTable bulk actions handles bulkCancelById requests 1`] = `
4
+ Array [
5
+ Array [
6
+ Object {
7
+ "type": "TASKS_CANCEL_REQUEST",
8
+ },
9
+ ],
10
+ Array [
11
+ Object {
12
+ "type": "TASKS_CANCEL_SUCCESS",
13
+ },
14
+ ],
15
+ Array [
16
+ Object {
17
+ "payload": Object {
18
+ "message": Object {
19
+ "message": "I am cancelled Task execution was cancelled",
20
+ "type": "success",
21
+ },
22
+ },
23
+ "type": "TOASTS_ADD",
24
+ },
25
+ ],
26
+ Array [
27
+ "TASKS_TABLE",
28
+ ],
29
+ Array [
30
+ [Function],
31
+ ],
32
+ ]
33
+ `;
34
+
35
+ exports[`TasksTable bulk actions handles bulkCancelById requests that are not cancellable 1`] = `
36
+ Array [
37
+ Array [
38
+ Object {
39
+ "payload": Object {
40
+ "message": Object {
41
+ "message": "Not all the selected tasks can be cancelled",
42
+ "type": "warning",
43
+ },
44
+ },
45
+ "type": "TOASTS_ADD",
46
+ },
47
+ ],
48
+ ]
49
+ `;
50
+
51
+ exports[`TasksTable bulk actions handles bulkCancelBySearch requests 1`] = `
52
+ Array [
53
+ Array [
54
+ Object {
55
+ "type": "TASKS_CANCEL_REQUEST",
56
+ },
57
+ ],
58
+ Array [
59
+ Object {
60
+ "payload": Object {
61
+ "message": Object {
62
+ "message": "Canceling selected tasks, this might take a while",
63
+ "type": "info",
64
+ },
65
+ },
66
+ "type": "TOASTS_ADD",
67
+ },
68
+ ],
69
+ ]
70
+ `;
71
+
72
+ exports[`TasksTable bulk actions handles bulkForceCancelById requests 1`] = `
73
+ Array [
74
+ Array [
75
+ Object {
76
+ "type": "TASKS_FORCE_CANCEL_REQUEST",
77
+ },
78
+ ],
79
+ Array [
80
+ Object {
81
+ "type": "TASKS_FORCE_CANCEL_SUCCESS",
82
+ },
83
+ ],
84
+ Array [
85
+ Object {
86
+ "payload": Object {
87
+ "message": Object {
88
+ "message": "2 task(s) cancelled with force",
89
+ "type": "success",
90
+ },
91
+ },
92
+ "type": "TOASTS_ADD",
93
+ },
94
+ ],
95
+ Array [
96
+ Object {
97
+ "payload": Object {
98
+ "message": Object {
99
+ "message": "4 task(s) are already stopped",
100
+ "type": "warning",
101
+ },
102
+ },
103
+ "type": "TOASTS_ADD",
104
+ },
105
+ ],
106
+ Array [
107
+ "TASKS_TABLE",
108
+ ],
109
+ Array [
110
+ [Function],
111
+ ],
112
+ ]
113
+ `;
114
+
115
+ exports[`TasksTable bulk actions handles bulkForceCancelById requests that are stopped 1`] = `
116
+ Array [
117
+ Array [
118
+ Object {
119
+ "payload": Object {
120
+ "message": Object {
121
+ "message": "1 task(s) are already stopped",
122
+ "type": "warning",
123
+ },
124
+ },
125
+ "type": "TOASTS_ADD",
126
+ },
127
+ ],
128
+ ]
129
+ `;
130
+
131
+ exports[`TasksTable bulk actions handles bulkForceCancelById requests that fail 1`] = `
132
+ Array [
133
+ Array [
134
+ Object {
135
+ "type": "TASKS_FORCE_CANCEL_REQUEST",
136
+ },
137
+ ],
138
+ Array [
139
+ Object {
140
+ "error": [Error: Network Error],
141
+ "type": "TASKS_FORCE_CANCEL_FAILURE",
142
+ },
143
+ ],
144
+ Array [
145
+ Object {
146
+ "payload": Object {
147
+ "message": Object {
148
+ "message": "Cannot force cancel tasks at the moment Error: Network Error",
149
+ "type": "error",
150
+ },
151
+ },
152
+ "type": "TOASTS_ADD",
153
+ },
154
+ ],
155
+ ]
156
+ `;
157
+
158
+ exports[`TasksTable bulk actions handles bulkForceCancelBySearch requests 1`] = `
159
+ Array [
160
+ Array [
161
+ Object {
162
+ "type": "TASKS_FORCE_CANCEL_REQUEST",
163
+ },
164
+ ],
165
+ Array [
166
+ Object {
167
+ "payload": Object {
168
+ "message": Object {
169
+ "message": "Canceling with force selected tasks, this might take a while",
170
+ "type": "info",
171
+ },
172
+ },
173
+ "type": "TOASTS_ADD",
174
+ },
175
+ ],
176
+ ]
177
+ `;
178
+
179
+ exports[`TasksTable bulk actions handles bulkResumeById requests that are not resumable 1`] = `
180
+ Array [
181
+ Array [
182
+ Object {
183
+ "payload": Object {
184
+ "message": Object {
185
+ "message": "Not all the selected tasks can be resumed",
186
+ "type": "warning",
187
+ },
188
+ },
189
+ "type": "TOASTS_ADD",
190
+ },
191
+ ],
192
+ ]
193
+ `;
194
+
195
+ exports[`TasksTable bulk actions handles bulkResumeById requests that fail 1`] = `
196
+ Array [
197
+ Array [
198
+ Object {
199
+ "type": "TASKS_RESUME_REQUEST",
200
+ },
201
+ ],
202
+ Array [
203
+ Object {
204
+ "error": [Error: Network Error],
205
+ "type": "TASKS_RESUME_FAILURE",
206
+ },
207
+ ],
208
+ Array [
209
+ Object {
210
+ "payload": Object {
211
+ "message": Object {
212
+ "message": "Cannot resume tasks at the moment Error: Network Error",
213
+ "type": "error",
214
+ },
215
+ },
216
+ "type": "TOASTS_ADD",
217
+ },
218
+ ],
219
+ ]
220
+ `;
221
+
222
+ exports[`TasksTable bulk actions handles bulkResumeBySearch requests 1`] = `
223
+ Array [
224
+ Array [
225
+ Object {
226
+ "type": "TASKS_RESUME_REQUEST",
227
+ },
228
+ ],
229
+ Array [
230
+ Object {
231
+ "payload": Object {
232
+ "message": Object {
233
+ "message": "Resuming selected tasks, this might take a while",
234
+ "type": "info",
235
+ },
236
+ },
237
+ "type": "TOASTS_ADD",
238
+ },
239
+ ],
240
+ ]
241
+ `;
242
+
243
+ exports[`TasksTable bulk actions handles resumable bulkResumeById requests 1`] = `
244
+ Array [
245
+ Array [
246
+ Object {
247
+ "type": "TASKS_RESUME_REQUEST",
248
+ },
249
+ ],
250
+ Array [
251
+ Object {
252
+ "type": "TASKS_RESUME_SUCCESS",
253
+ },
254
+ ],
255
+ Array [
256
+ Object {
257
+ "payload": Object {
258
+ "message": Object {
259
+ "message": "I am resumed Task execution was resumed",
260
+ "type": "success",
261
+ },
262
+ },
263
+ "type": "TOASTS_ADD",
264
+ },
265
+ ],
266
+ Array [
267
+ Object {
268
+ "payload": Object {
269
+ "message": Object {
270
+ "message": "I am failed Task execution could not be resumed",
271
+ "type": "error",
272
+ },
273
+ },
274
+ "type": "TOASTS_ADD",
275
+ },
276
+ ],
277
+ Array [
278
+ "TASKS_TABLE",
279
+ ],
280
+ Array [
281
+ [Function],
282
+ ],
283
+ ]
284
+ `;
285
+
286
+ exports[`TasksTable bulk actions handles skipped bulkCancelById requests 1`] = `
287
+ Array [
288
+ Array [
289
+ Object {
290
+ "type": "TASKS_CANCEL_REQUEST",
291
+ },
292
+ ],
293
+ Array [
294
+ Object {
295
+ "type": "TASKS_CANCEL_SUCCESS",
296
+ },
297
+ ],
298
+ Array [
299
+ Object {
300
+ "payload": Object {
301
+ "message": Object {
302
+ "message": "I am skipped Task execution task has to be cancellable",
303
+ "type": "warning",
304
+ },
305
+ },
306
+ "type": "TOASTS_ADD",
307
+ },
308
+ ],
309
+ ]
310
+ `;
311
+
312
+ exports[`TasksTable bulk actions handles skipped bulkResumeById requests 1`] = `
313
+ Array [
314
+ Array [
315
+ Object {
316
+ "type": "TASKS_RESUME_REQUEST",
317
+ },
318
+ ],
319
+ Array [
320
+ Object {
321
+ "type": "TASKS_RESUME_SUCCESS",
322
+ },
323
+ ],
324
+ Array [
325
+ Object {
326
+ "payload": Object {
327
+ "message": Object {
328
+ "message": "I am skipped Task execution task has to be resumable",
329
+ "type": "warning",
330
+ },
331
+ },
332
+ "type": "TOASTS_ADD",
333
+ },
334
+ ],
335
+ ]
336
+ `;