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
@@ -2,8 +2,8 @@ import React, { Component } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { Grid, Row, Col, ProgressBar } from 'patternfly-react';
4
4
  import { translate as __ } from 'foremanReact/common/I18n';
5
- import EllipsisWithTooltip from 'react-ellipsis-with-tooltip';
6
5
  import RelativeDateTime from 'foremanReact/components/common/dates/RelativeDateTime';
6
+ import ReactHtmlParser from 'react-html-parser';
7
7
 
8
8
  class TaskInfo extends Component {
9
9
  isDelayed = () => {
@@ -69,9 +69,7 @@ class TaskInfo extends Component {
69
69
  [
70
70
  {
71
71
  title: 'Name',
72
- value: (
73
- <EllipsisWithTooltip>{action || __('N/A')}</EllipsisWithTooltip>
74
- ),
72
+ value: action || __('N/A'),
75
73
  },
76
74
  {
77
75
  title: 'Start at',
@@ -173,14 +171,7 @@ class TaskInfo extends Component {
173
171
  <b>{__('Troubleshooting')}</b>
174
172
  </span>
175
173
  </p>
176
- <p>
177
- {help.split('\n').map((item, i) => (
178
- <React.Fragment key={i}>
179
- {item}
180
- <br />
181
- </React.Fragment>
182
- ))}
183
- </p>
174
+ <p>{ReactHtmlParser(help)}</p>
184
175
  </Col>
185
176
  </Row>
186
177
  )}
@@ -1,4 +1,4 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import Errors from '../Errors';
4
4
 
@@ -1,4 +1,4 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import Locks from '../Locks';
4
4
 
@@ -1,4 +1,4 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import Raw from '../Raw';
4
4
 
@@ -1,4 +1,4 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import RunningSteps from '../RunningSteps';
4
4
 
@@ -1,6 +1,15 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
-
1
+ import React from 'react';
2
+ import {
3
+ testComponentSnapshotsWithFixtures,
4
+ mount,
5
+ shallow,
6
+ } from '@theforeman/test';
7
+ import { useForemanModal } from 'foremanReact/components/ForemanModal/ForemanModalHooks';
3
8
  import Task from '../Task';
9
+ import {
10
+ UNLOCK_MODAL,
11
+ FORCE_UNLOCK_MODAL,
12
+ } from '../../../TaskActions/TaskActionsConstants';
4
13
 
5
14
  const fixtures = {
6
15
  'render without Props': { id: 'test' },
@@ -8,11 +17,67 @@ const fixtures = {
8
17
  id: 'test',
9
18
  state: 'paused',
10
19
  hasSubTasks: true,
11
- allowDangerousActions: true,
20
+ dynflowEnableConsole: true,
21
+ parentTask: 'parent-id',
22
+ taskReload: true,
12
23
  },
13
24
  };
14
25
 
15
26
  describe('Task', () => {
16
27
  describe('rendering', () =>
17
28
  testComponentSnapshotsWithFixtures(Task, fixtures));
29
+ describe('click test', () => {
30
+ const setModalOpen = jest.fn();
31
+ useForemanModal.mockImplementation(id => ({
32
+ setModalOpen: () => setModalOpen(id),
33
+ }));
34
+ const cancelTaskRequest = jest.fn();
35
+ const resumeTaskRequest = jest.fn();
36
+ const taskReloadStart = jest.fn();
37
+ const id = 'some-id';
38
+ const action = 'some-action';
39
+ const props = {
40
+ taskReload: false,
41
+ taskReloadStart,
42
+ id,
43
+ action,
44
+ cancelTaskRequest,
45
+ resumeTaskRequest,
46
+ };
47
+ afterEach(() => {
48
+ jest.clearAllMocks();
49
+ });
50
+ it('reload', () => {
51
+ const component = mount(<Task {...props} />);
52
+ const reloadButton = component.find('.reload-button').at(0);
53
+ reloadButton.simulate('click');
54
+ expect(taskReloadStart).toBeCalled();
55
+ });
56
+ it('resume', () => {
57
+ const component = shallow(<Task {...props} />);
58
+ const resumeButton = component.find('.resume-button').at(0);
59
+ resumeButton.props().onClick();
60
+ expect(taskReloadStart).toBeCalled();
61
+ expect(resumeTaskRequest).toBeCalledWith(id, action);
62
+ });
63
+ it('cancel', () => {
64
+ const component = shallow(<Task {...props} />);
65
+ const cancelButton = component.find('.cancel-button').at(0);
66
+ cancelButton.props().onClick();
67
+ expect(taskReloadStart).toBeCalled();
68
+ expect(cancelTaskRequest).toBeCalledWith(id, action);
69
+ });
70
+ it('unlock', () => {
71
+ const component = shallow(<Task {...props} />);
72
+ const unlockButton = component.find('.unlock-button').at(0);
73
+ unlockButton.props().onClick();
74
+ expect(setModalOpen).toBeCalledWith({ id: UNLOCK_MODAL });
75
+ });
76
+ it('focrce unlock', () => {
77
+ const component = shallow(<Task {...props} />);
78
+ const forceUnlockButton = component.find('.force-unlock-button').at(0);
79
+ forceUnlockButton.props().onClick();
80
+ expect(setModalOpen).toBeCalledWith({ id: FORCE_UNLOCK_MODAL });
81
+ });
82
+ });
18
83
  });
@@ -1,4 +1,4 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import TaskInfo from '../TaskInfo';
4
4
 
@@ -41,7 +41,6 @@ const fixtures = {
41
41
  help:
42
42
  "A paused task represents a process that has not finished properly. Any task in paused state can lead to potential inconsistency and needs to be resolved.\nThe recommended approach is to investigate the error messages below and in 'errors' tab, address the primary cause of the issue and resume the task.",
43
43
  hasSubTasks: false,
44
- allowDangerousActions: false,
45
44
  locks: [
46
45
  {
47
46
  name: 'task_owner',
@@ -2,25 +2,14 @@
2
2
 
3
3
  exports[`Task rendering render with some Props 1`] = `
4
4
  <Fragment>
5
- <ClickConfirmation
6
- body="This will unlock the resources that the task is running against. Please note that this might lead to inconsistent state and should be used with caution, after making sure that the task can't be resumed."
7
- closeModal={[Function]}
8
- confirmAction="Unlock"
9
- confirmType="warning"
10
- confirmationMessage="I understand that this may cause harm and have working database backups of all backend services."
11
- path="/foreman_tasks/tasks/test/unlock"
12
- showModal={false}
13
- title="Unlock"
5
+ <UnlockModal
6
+ id="unlockModal"
7
+ onClick={[Function]}
14
8
  />
15
- <ClickConfirmation
16
- body="Resources will be unlocked and will not prevent other tasks from being run. As the task might be still running, it should be avoided to use this unless you are really sure the task got stuck"
17
- closeModal={[Function]}
18
- confirmAction="Force Unlock"
19
- confirmType="danger"
20
- confirmationMessage="I understand that this may cause harm and have working database backups of all backend services."
21
- path="/foreman_tasks/tasks/test/force_unlock"
22
- showModal={false}
23
- title="Force Unlock"
9
+ <ForceUnlockModal
10
+ id="forceUnlockModal"
11
+ onClick={[Function]}
12
+ selectedRowsLen={1}
24
13
  />
25
14
  <Grid
26
15
  bsClass="container"
@@ -44,13 +33,12 @@ exports[`Task rendering render with some Props 1`] = `
44
33
  bsStyle="default"
45
34
  className="reload-button"
46
35
  disabled={false}
47
- hidden={false}
48
36
  onClick={[Function]}
49
37
  >
50
38
  <span
51
- className="glyphicon glyphicon-refresh "
39
+ className="glyphicon glyphicon-refresh spin"
52
40
  />
53
- Start auto-reloading
41
+ Stop auto-reloading
54
42
  </Button>
55
43
  <Button
56
44
  active={false}
@@ -58,29 +46,55 @@ exports[`Task rendering render with some Props 1`] = `
58
46
  bsClass="btn"
59
47
  bsSize="small"
60
48
  bsStyle="default"
49
+ className="dynflow-button"
61
50
  disabled={false}
62
51
  href="/foreman_tasks/dynflow/"
63
52
  >
64
53
  Dynflow console
65
54
  </Button>
66
- <ResumeButton
55
+ <Button
56
+ active={false}
57
+ block={false}
58
+ bsClass="btn"
59
+ bsSize="small"
60
+ bsStyle="default"
61
+ className="resume-button"
67
62
  disabled={true}
68
- id="test"
69
- name=""
70
63
  onClick={[Function]}
71
- />
72
- <CancelButton
64
+ >
65
+ Resume
66
+ </Button>
67
+ <Button
68
+ active={false}
69
+ block={false}
70
+ bsClass="btn"
71
+ bsSize="small"
72
+ bsStyle="default"
73
+ className="cancel-button"
73
74
  disabled={true}
74
- id="test"
75
- name=""
76
75
  onClick={[Function]}
77
- />
76
+ >
77
+ Cancel
78
+ </Button>
78
79
  <Button
79
80
  active={false}
80
81
  block={false}
81
82
  bsClass="btn"
82
83
  bsSize="small"
83
84
  bsStyle="default"
85
+ className="parent-button"
86
+ disabled={false}
87
+ href="/foreman_tasks/tasks/parent-id"
88
+ >
89
+ Parent task
90
+ </Button>
91
+ <Button
92
+ active={false}
93
+ block={false}
94
+ bsClass="btn"
95
+ bsSize="small"
96
+ bsStyle="default"
97
+ className="subtask-button"
84
98
  disabled={false}
85
99
  href="/foreman_tasks/tasks/test/sub_tasks"
86
100
  >
@@ -92,8 +106,9 @@ exports[`Task rendering render with some Props 1`] = `
92
106
  bsClass="btn"
93
107
  bsSize="small"
94
108
  bsStyle="default"
109
+ className="unlock-button"
95
110
  disabled={false}
96
- onClick={[Function]}
111
+ onClick={[MockFunction]}
97
112
  >
98
113
  Unlock
99
114
  </Button>
@@ -103,8 +118,9 @@ exports[`Task rendering render with some Props 1`] = `
103
118
  bsClass="btn"
104
119
  bsSize="small"
105
120
  bsStyle="default"
121
+ className="force-unlock-button"
106
122
  disabled={false}
107
- onClick={[Function]}
123
+ onClick={[MockFunction]}
108
124
  >
109
125
  Force Unlock
110
126
  </Button>
@@ -112,9 +128,9 @@ exports[`Task rendering render with some Props 1`] = `
112
128
  </Row>
113
129
  <TaskInfo
114
130
  action=""
115
- allowDangerousActions={true}
116
131
  cancelTaskRequest={[Function]}
117
132
  cancellable={false}
133
+ dynflowEnableConsole={true}
118
134
  endedAt=""
119
135
  error={Array []}
120
136
  externalId=""
@@ -122,24 +138,20 @@ exports[`Task rendering render with some Props 1`] = `
122
138
  help=""
123
139
  id="test"
124
140
  output=""
125
- parentTask=""
141
+ parentTask="parent-id"
126
142
  progress={0}
127
143
  refetchTaskDetails={[Function]}
128
144
  result="error"
129
145
  resumable={false}
130
146
  resumeTaskRequest={[Function]}
131
- showForceUnlockModal={false}
132
- showUnlockModal={false}
133
147
  startAt=""
134
148
  startBefore=""
135
149
  startedAt=""
136
150
  state="paused"
137
- taskReload={false}
151
+ taskReload={true}
138
152
  taskReloadStart={[Function]}
139
153
  taskReloadStop={[Function]}
140
154
  timeoutId={null}
141
- toggleForceUnlockModal={[Function]}
142
- toggleUnlockModal={[Function]}
143
155
  username=""
144
156
  usernamePath=""
145
157
  />
@@ -149,25 +161,14 @@ exports[`Task rendering render with some Props 1`] = `
149
161
 
150
162
  exports[`Task rendering render without Props 1`] = `
151
163
  <Fragment>
152
- <ClickConfirmation
153
- body="This will unlock the resources that the task is running against. Please note that this might lead to inconsistent state and should be used with caution, after making sure that the task can't be resumed."
154
- closeModal={[Function]}
155
- confirmAction="Unlock"
156
- confirmType="warning"
157
- confirmationMessage="I understand that this may cause harm and have working database backups of all backend services."
158
- path="/foreman_tasks/tasks/test/unlock"
159
- showModal={false}
160
- title="Unlock"
164
+ <UnlockModal
165
+ id="unlockModal"
166
+ onClick={[Function]}
161
167
  />
162
- <ClickConfirmation
163
- body="Resources will be unlocked and will not prevent other tasks from being run. As the task might be still running, it should be avoided to use this unless you are really sure the task got stuck"
164
- closeModal={[Function]}
165
- confirmAction="Force Unlock"
166
- confirmType="danger"
167
- confirmationMessage="I understand that this may cause harm and have working database backups of all backend services."
168
- path="/foreman_tasks/tasks/test/force_unlock"
169
- showModal={false}
170
- title="Force Unlock"
168
+ <ForceUnlockModal
169
+ id="forceUnlockModal"
170
+ onClick={[Function]}
171
+ selectedRowsLen={1}
171
172
  />
172
173
  <Grid
173
174
  bsClass="container"
@@ -191,7 +192,6 @@ exports[`Task rendering render without Props 1`] = `
191
192
  bsStyle="default"
192
193
  className="reload-button"
193
194
  disabled={false}
194
- hidden={true}
195
195
  onClick={[Function]}
196
196
  >
197
197
  <span
@@ -205,30 +205,67 @@ exports[`Task rendering render without Props 1`] = `
205
205
  bsClass="btn"
206
206
  bsSize="small"
207
207
  bsStyle="default"
208
- disabled={false}
208
+ className="dynflow-button"
209
+ disabled={true}
209
210
  href="/foreman_tasks/dynflow/"
210
211
  >
211
212
  Dynflow console
212
213
  </Button>
213
- <ResumeButton
214
+ <Button
215
+ active={false}
216
+ block={false}
217
+ bsClass="btn"
218
+ bsSize="small"
219
+ bsStyle="default"
220
+ className="resume-button"
214
221
  disabled={true}
215
- id="test"
216
- name=""
217
222
  onClick={[Function]}
218
- />
219
- <CancelButton
223
+ >
224
+ Resume
225
+ </Button>
226
+ <Button
227
+ active={false}
228
+ block={false}
229
+ bsClass="btn"
230
+ bsSize="small"
231
+ bsStyle="default"
232
+ className="cancel-button"
220
233
  disabled={true}
221
- id="test"
222
- name=""
223
234
  onClick={[Function]}
224
- />
235
+ >
236
+ Cancel
237
+ </Button>
238
+ <Button
239
+ active={false}
240
+ block={false}
241
+ bsClass="btn"
242
+ bsSize="small"
243
+ bsStyle="default"
244
+ className="unlock-button"
245
+ disabled={true}
246
+ onClick={[MockFunction]}
247
+ >
248
+ Unlock
249
+ </Button>
250
+ <Button
251
+ active={false}
252
+ block={false}
253
+ bsClass="btn"
254
+ bsSize="small"
255
+ bsStyle="default"
256
+ className="force-unlock-button"
257
+ disabled={false}
258
+ onClick={[MockFunction]}
259
+ >
260
+ Force Unlock
261
+ </Button>
225
262
  </Col>
226
263
  </Row>
227
264
  <TaskInfo
228
265
  action=""
229
- allowDangerousActions={false}
230
266
  cancelTaskRequest={[Function]}
231
267
  cancellable={false}
268
+ dynflowEnableConsole={false}
232
269
  endedAt=""
233
270
  error={Array []}
234
271
  externalId=""
@@ -242,8 +279,6 @@ exports[`Task rendering render without Props 1`] = `
242
279
  result="error"
243
280
  resumable={false}
244
281
  resumeTaskRequest={[Function]}
245
- showForceUnlockModal={false}
246
- showUnlockModal={false}
247
282
  startAt=""
248
283
  startBefore=""
249
284
  startedAt=""
@@ -252,8 +287,6 @@ exports[`Task rendering render without Props 1`] = `
252
287
  taskReloadStart={[Function]}
253
288
  taskReloadStop={[Function]}
254
289
  timeoutId={null}
255
- toggleForceUnlockModal={[Function]}
256
- toggleUnlockModal={[Function]}
257
290
  username=""
258
291
  usernamePath=""
259
292
  />