foreman-tasks 2.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/js_tests.yml +31 -0
  3. data/.github/workflows/ruby_tests.yml +74 -0
  4. data/.rubocop.yml +12 -4
  5. data/.rubocop_todo.yml +32 -25
  6. data/Gemfile +5 -0
  7. data/app/controllers/foreman_tasks/api/tasks_controller.rb +36 -60
  8. data/app/controllers/foreman_tasks/concerns/parameters/triggering.rb +1 -1
  9. data/app/controllers/foreman_tasks/recurring_logics_controller.rb +7 -0
  10. data/app/controllers/foreman_tasks/tasks_controller.rb +6 -3
  11. data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +3 -3
  12. data/app/lib/actions/proxy_action.rb +1 -1
  13. data/app/models/foreman_tasks/recurring_logic.rb +1 -1
  14. data/app/models/foreman_tasks/task.rb +11 -0
  15. data/app/models/foreman_tasks/task/dynflow_task.rb +29 -33
  16. data/app/models/foreman_tasks/task/status_explicator.rb +1 -1
  17. data/app/models/foreman_tasks/triggering.rb +1 -1
  18. data/app/models/setting/foreman_tasks.rb +9 -9
  19. data/app/services/foreman_tasks/dashboard_table_filter.rb +5 -1
  20. data/app/views/foreman_tasks/api/tasks/index.json.rabl +2 -0
  21. data/app/views/foreman_tasks/api/tasks/show.json.rabl +2 -0
  22. data/app/views/foreman_tasks/layouts/react.html.erb +1 -2
  23. data/app/views/foreman_tasks/recurring_logics/index.html.erb +3 -1
  24. data/app/views/foreman_tasks/tasks/show.html.erb +1 -6
  25. data/config/routes.rb +2 -1
  26. data/db/migrate/20200517215015_rename_bookmarks_controller.rb +2 -2
  27. data/db/migrate/20200611090846_add_task_lock_index_on_resource_type_and_task_id.rb +9 -0
  28. data/db/seeds.d/30-notification_blueprints.rb +7 -7
  29. data/db/seeds.d/61-foreman_tasks_bookmarks.rb +1 -1
  30. data/foreman-tasks.gemspec +1 -0
  31. data/lib/foreman_tasks/cleaner.rb +4 -6
  32. data/lib/foreman_tasks/dynflow/configuration.rb +1 -1
  33. data/lib/foreman_tasks/dynflow/persistence.rb +4 -6
  34. data/lib/foreman_tasks/engine.rb +2 -7
  35. data/lib/foreman_tasks/tasks/cleanup.rake +2 -2
  36. data/lib/foreman_tasks/tasks/dynflow.rake +6 -0
  37. data/lib/foreman_tasks/tasks/export_tasks.rake +1 -1
  38. data/lib/foreman_tasks/version.rb +1 -1
  39. data/locale/en/LC_MESSAGES/foreman_tasks.mo +0 -0
  40. data/locale/en/foreman_tasks.po +50 -20
  41. data/locale/foreman_tasks.pot +173 -126
  42. data/locale/fr/LC_MESSAGES/foreman_tasks.mo +0 -0
  43. data/locale/fr/foreman_tasks.po +817 -0
  44. data/locale/ja/LC_MESSAGES/foreman_tasks.mo +0 -0
  45. data/locale/ja/foreman_tasks.po +817 -0
  46. data/locale/zh_CN/LC_MESSAGES/foreman_tasks.mo +0 -0
  47. data/locale/zh_CN/foreman_tasks.po +816 -0
  48. data/package.json +1 -1
  49. data/script/npm_link_foreman_js.sh +26 -0
  50. data/test/controllers/api/recurring_logics_controller_test.rb +1 -1
  51. data/test/controllers/api/tasks_controller_test.rb +17 -7
  52. data/test/controllers/tasks_controller_test.rb +6 -6
  53. data/test/core/unit/runner_test.rb +20 -20
  54. data/test/core/unit/task_launcher_test.rb +8 -8
  55. data/test/helpers/foreman_tasks/foreman_tasks_helper_test.rb +7 -7
  56. data/test/helpers/foreman_tasks/tasks_helper_test.rb +3 -3
  57. data/test/lib/actions/middleware/keep_current_request_id_test.rb +3 -3
  58. data/test/support/history_tasks_builder.rb +1 -1
  59. data/test/tasks/generate_task_actions_test.rb +1 -1
  60. data/test/unit/actions/action_with_sub_plans_test.rb +2 -2
  61. data/test/unit/actions/bulk_action_test.rb +6 -6
  62. data/test/unit/actions/proxy_action_test.rb +20 -20
  63. data/test/unit/actions/recurring_action_test.rb +30 -32
  64. data/test/unit/cleaner_test.rb +24 -24
  65. data/test/unit/dashboard_table_filter_test.rb +5 -5
  66. data/test/unit/otp_manager_test.rb +2 -2
  67. data/test/unit/proxy_selector_test.rb +9 -9
  68. data/test/unit/recurring_logic_test.rb +32 -32
  69. data/test/unit/remote_task_test.rb +2 -2
  70. data/test/unit/task_groups_test.rb +4 -4
  71. data/test/unit/task_test.rb +18 -18
  72. data/test/unit/triggering_test.rb +8 -8
  73. data/test/unit/troubleshooting_help_generator_test.rb +6 -6
  74. data/test/unit/ui_notifications_test.rb +11 -11
  75. data/webpack/ForemanTasks/Components/TaskActions/TaskAction.test.js +2 -2
  76. data/webpack/ForemanTasks/Components/TaskActions/index.js +1 -1
  77. data/webpack/ForemanTasks/Components/TaskDetails/Components/RunningSteps.js +17 -3
  78. data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +8 -153
  79. data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskButtons.js +168 -0
  80. data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskInfo.js +6 -7
  81. data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskSkeleton.js +48 -0
  82. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/RunningSteps.test.js +8 -1
  83. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +13 -70
  84. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskButtons.test.js +95 -0
  85. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/RunningSteps.test.js.snap +1 -1
  86. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +78 -208
  87. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskButtons.test.js.snap +212 -0
  88. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskInfo.test.js.snap +8 -4
  89. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.js +100 -53
  90. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.scss +13 -14
  91. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +57 -95
  92. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsConstants.js +3 -12
  93. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +57 -28
  94. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.fixtures.js +8 -0
  95. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +8 -1
  96. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js +6 -6
  97. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +84 -12
  98. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsActions.test.js.snap +25 -21
  99. data/webpack/ForemanTasks/Components/TaskDetails/index.js +8 -3
  100. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.scss +4 -0
  101. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/OtherInfo.js +53 -0
  102. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/OtherInfo.test.js +14 -0
  103. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.js +27 -19
  104. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.scss +14 -0
  105. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.test.js +1 -34
  106. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/{StoppedTasksCardHelper.js → StoppedTasksCardTable.js} +28 -1
  107. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardTable.test.js +54 -0
  108. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/OtherInfo.test.js.snap +48 -0
  109. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/StoppedTasksCard.test.js.snap +60 -1367
  110. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/StoppedTasksCardTable.test.js.snap +960 -0
  111. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/__snapshots__/TasksCardsGrid.test.js.snap +14 -11
  112. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardActions.js +1 -1
  113. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardConstants.js +2 -0
  114. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js +17 -11
  115. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardActions.test.js +2 -2
  116. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardSelectors.test.js +26 -14
  117. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboard.test.js.snap +14 -11
  118. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboardSelectors.test.js.snap +38 -22
  119. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js +1 -0
  120. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalSelectors.test.js +1 -0
  121. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalSelectors.test.js.snap +2 -0
  122. data/webpack/ForemanTasks/Components/TasksTable/TasksBulkActions.js +25 -8
  123. data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +3 -3
  124. data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +6 -3
  125. data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.scss +0 -10
  126. data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +1 -0
  127. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksBulkActions.test.js +15 -2
  128. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +1 -0
  129. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTablePage.test.js +2 -1
  130. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +1 -0
  131. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksBulkActions.test.js.snap +48 -0
  132. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +1 -0
  133. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +39 -7
  134. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/actionCellFormatter.test.js.snap +1 -0
  135. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/selectionCellFormatter.test.js.snap +2 -0
  136. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/actionCellFormatter.test.js +1 -1
  137. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/selectionCellFormatter.test.js +1 -1
  138. data/webpack/ForemanTasks/Components/TasksTable/formatters/actionCellFormatter.js +10 -7
  139. data/webpack/ForemanTasks/Components/TasksTable/formatters/selectionCellFormatter.js +7 -0
  140. data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js +39 -31
  141. data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js +17 -8
  142. data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap +8 -0
  143. data/webpack/ForemanTasks/Components/common/urlHelpers.js +7 -0
  144. data/webpack/ForemanTasks/ForemanTasksReducers.js +0 -2
  145. data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
  146. data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +10 -0
  147. data/webpack/__mocks__/foremanReact/redux/API/index.js +10 -0
  148. data/webpack/__mocks__/foremanReact/redux/middlewares/IntervalMiddleware.js +5 -0
  149. metadata +35 -17
  150. data/.travis.yml +0 -5
  151. data/app/assets/stylesheets/foreman_tasks/tasks.scss +0 -9
  152. data/script/travis_run_js_tests.sh +0 -7
  153. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js +0 -38
  154. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsReducer.test.js +0 -33
  155. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsReducer.test.js.snap +0 -26
  156. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/integration.test.js.snap +0 -122
  157. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/integration.test.js +0 -67
  158. data/webpack/__mocks__/foremanReact/API.js +0 -7
@@ -0,0 +1,8 @@
1
+ export const minProps = {
2
+ cancelStep: jest.fn(),
3
+ taskReload: false,
4
+ taskReloadStop: jest.fn(),
5
+ taskReloadStart: jest.fn(),
6
+ taskProgressToggle: jest.fn(),
7
+ status: 'RESOLVED',
8
+ };
@@ -1,9 +1,16 @@
1
1
  import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import TaskDetails from '../TaskDetails';
4
+ import { minProps } from './TaskDetails.fixtures';
4
5
 
5
6
  const fixtures = {
6
- 'render without Props': {},
7
+ 'render with loading Props': { ...minProps, isLoading: true },
8
+ 'render with error Props': {
9
+ ...minProps,
10
+ status: 'ERROR',
11
+ APIerror: { message: 'some-error' },
12
+ },
13
+ 'render with min Props': minProps,
7
14
  };
8
15
 
9
16
  delete window.location;
@@ -1,19 +1,19 @@
1
1
  import { testActionSnapshotWithFixtures } from '@theforeman/test';
2
- import API from 'foremanReact/API';
2
+ import { API } from 'foremanReact/redux/API';
3
3
  import {
4
4
  taskReloadStop,
5
5
  taskReloadStart,
6
- fetchTaskDetails,
6
+ cancelStep,
7
7
  } from '../TaskDetailsActions';
8
8
 
9
- jest.mock('foremanReact/API');
9
+ jest.mock('foremanReact/redux/API');
10
10
 
11
- API.get.mockImplementation(async () => ({ data: 'some-data' }));
11
+ API.post.mockImplementation(async () => ({ data: 'some-data' }));
12
12
 
13
13
  const fixtures = {
14
14
  'should start reload': () => taskReloadStart(1),
15
- 'should stop reload': () => taskReloadStop(2),
16
- 'should fetch-task-details and success': () => fetchTaskDetails(),
15
+ 'should stop reload': () => taskReloadStop(),
16
+ 'should cancelStep': () => cancelStep('task-id', 'step-id'),
17
17
  };
18
18
 
19
19
  describe('TaskDetails - Actions', () =>
@@ -1,6 +1,80 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`TaskDetails rendering render without Props 1`] = `
3
+ exports[`TaskDetails rendering render with error Props 1`] = `
4
+ <MessageBox
5
+ icontype="error-circle-o"
6
+ key="task-details-error"
7
+ msg="Could not receive data: some-error"
8
+ />
9
+ `;
10
+
11
+ exports[`TaskDetails rendering render with loading Props 1`] = `
12
+ <div
13
+ className="task-details-react well"
14
+ >
15
+ <ForwardRef
16
+ animation={false}
17
+ defaultActiveKey={1}
18
+ id="task-details-tabs"
19
+ >
20
+ <Tab
21
+ eventKey={1}
22
+ title="Task"
23
+ >
24
+ <TaskSkeleton />
25
+ </Tab>
26
+ <Tab
27
+ disabled={true}
28
+ eventKey={2}
29
+ title="Running Steps"
30
+ >
31
+ <RunningSteps
32
+ cancelStep={[MockFunction]}
33
+ id="a15dd820-32f1-4ced-9ab7-c0fab8234c47"
34
+ runningSteps={Array []}
35
+ taskReload={false}
36
+ taskReloadStart={[MockFunction]}
37
+ />
38
+ </Tab>
39
+ <Tab
40
+ disabled={true}
41
+ eventKey={3}
42
+ title="Errors"
43
+ >
44
+ <Errors
45
+ executionPlan={Object {}}
46
+ failedSteps={Array []}
47
+ />
48
+ </Tab>
49
+ <Tab
50
+ disabled={true}
51
+ eventKey={4}
52
+ title="Locks"
53
+ >
54
+ <Locks
55
+ locks={Array []}
56
+ />
57
+ </Tab>
58
+ <Tab
59
+ disabled={true}
60
+ eventKey={5}
61
+ title="Raw"
62
+ >
63
+ <Raw
64
+ endedAt=""
65
+ externalId=""
66
+ id="a15dd820-32f1-4ced-9ab7-c0fab8234c47"
67
+ input={Array []}
68
+ label=""
69
+ output={Object {}}
70
+ startedAt=""
71
+ />
72
+ </Tab>
73
+ </ForwardRef>
74
+ </div>
75
+ `;
76
+
77
+ exports[`TaskDetails rendering render with min Props 1`] = `
4
78
  <div
5
79
  className="task-details-react well"
6
80
  >
@@ -15,37 +89,32 @@ exports[`TaskDetails rendering render without Props 1`] = `
15
89
  >
16
90
  <Task
17
91
  action=""
92
+ canEdit={false}
18
93
  cancelTaskRequest={[Function]}
19
94
  cancellable={false}
20
95
  dynflowEnableConsole={false}
21
96
  endedAt=""
22
- error={Array []}
23
- executionPlan={Object {}}
97
+ errors={Array []}
24
98
  externalId=""
25
- failedSteps={Array []}
26
- fetchTaskDetails={[Function]}
27
99
  hasSubTasks={false}
28
100
  help=""
29
101
  id="a15dd820-32f1-4ced-9ab7-c0fab8234c47"
30
102
  input={Array []}
31
103
  label=""
32
- locks={Array []}
33
104
  output={Object {}}
34
105
  parentTask=""
35
106
  progress={0}
36
- refetchTaskDetails={[Function]}
37
107
  result="error"
38
108
  resumable={false}
39
109
  resumeTaskRequest={[Function]}
40
- runningSteps={Array []}
41
110
  startAt=""
42
111
  startBefore=""
43
112
  startedAt=""
44
113
  state=""
114
+ status="RESOLVED"
115
+ taskProgressToggle={[Function]}
45
116
  taskReload={false}
46
- taskReloadStart={[Function]}
47
- taskReloadStop={[Function]}
48
- timeoutId={null}
117
+ taskReloadStart={[MockFunction]}
49
118
  username=""
50
119
  usernamePath=""
51
120
  />
@@ -55,8 +124,11 @@ exports[`TaskDetails rendering render without Props 1`] = `
55
124
  title="Running Steps"
56
125
  >
57
126
  <RunningSteps
58
- executionPlan={Object {}}
127
+ cancelStep={[MockFunction]}
128
+ id="a15dd820-32f1-4ced-9ab7-c0fab8234c47"
59
129
  runningSteps={Array []}
130
+ taskReload={false}
131
+ taskReloadStart={[MockFunction]}
60
132
  />
61
133
  </Tab>
62
134
  <Tab
@@ -1,43 +1,47 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`TaskDetails - Actions should fetch-task-details and success 1`] = `
3
+ exports[`TaskDetails - Actions should cancelStep 1`] = `
4
4
  Array [
5
5
  Array [
6
6
  Object {
7
- "type": "FOREMAN_TASK_DETAILS_FETCH_TASK_REQUEST",
7
+ "payload": Object {
8
+ "message": Object {
9
+ "message": "Trying to cancel step step-id",
10
+ "type": "info",
11
+ },
12
+ },
13
+ "type": "TOASTS_ADD",
8
14
  },
9
15
  ],
10
16
  Array [
11
17
  Object {
12
- "payload": "some-data",
13
- "type": "FOREMAN_TASK_DETAILS_FETCH_TASK_SUCCESS",
18
+ "handleError": [Function],
19
+ "handleSuccess": [Function],
20
+ "key": "TASK_STEP_CANCEL",
21
+ "type": "post-some-type",
22
+ "url": "foreman/foreman_tasks/tasks/task-id/cancel_step?step_id=step-id",
14
23
  },
15
24
  ],
25
+ ]
26
+ `;
27
+
28
+ exports[`TaskDetails - Actions should start reload 1`] = `
29
+ Array [
16
30
  Array [
17
31
  Object {
18
- "payload": Object {
19
- "timeoutId": 7,
20
- },
21
- "type": "FOREMAN_TASK_DETAILS_START_POLLING",
32
+ "handleError": [Function],
33
+ "handleSuccess": [Function],
34
+ "interval": 5000,
35
+ "key": "FOREMAN_TASK_DETAILS",
36
+ "type": "get-some-type",
37
+ "url": "foreman/foreman_tasks/api/tasks/1/details?include_permissions",
22
38
  },
23
39
  ],
24
40
  ]
25
41
  `;
26
42
 
27
- exports[`TaskDetails - Actions should start reload 1`] = `
28
- Object {
29
- "payload": Object {
30
- "timeoutId": 1,
31
- },
32
- "type": "FOREMAN_TASK_DETAILS_START_POLLING",
33
- }
34
- `;
35
-
36
43
  exports[`TaskDetails - Actions should stop reload 1`] = `
37
44
  Object {
38
- "payload": Object {
39
- "timeoutId": 2,
40
- },
41
- "type": "FOREMAN_TASK_DETAILS_STOP_POLLING",
45
+ "type": "stop",
42
46
  }
43
47
  `;
@@ -3,7 +3,6 @@ import { connect } from 'react-redux';
3
3
  import TaskDetails from './TaskDetails';
4
4
  import * as taskDetailsActions from './TaskDetailsActions';
5
5
  import * as taskActions from '../TaskActions';
6
- import reducer from './TaskDetailsReducer';
7
6
  import {
8
7
  selectEndedAt,
9
8
  selectStartAt,
@@ -32,6 +31,10 @@ import {
32
31
  selectParentTask,
33
32
  selectExternalId,
34
33
  selectDynflowEnableConsole,
34
+ selectCanEdit,
35
+ selectStatus,
36
+ selectAPIError,
37
+ selectIsLoading,
35
38
  } from './TaskDetailsSelectors';
36
39
 
37
40
  const mapStateToProps = state => ({
@@ -62,11 +65,13 @@ const mapStateToProps = state => ({
62
65
  parentTask: selectParentTask(state),
63
66
  externalId: selectExternalId(state),
64
67
  dynflowEnableConsole: selectDynflowEnableConsole(state),
68
+ canEdit: selectCanEdit(state),
69
+ status: selectStatus(state),
70
+ APIerror: selectAPIError(state),
71
+ isLoading: selectIsLoading(state),
65
72
  });
66
73
 
67
74
  const mapDispatchToProps = dispatch =>
68
75
  bindActionCreators({ ...taskActions, ...taskDetailsActions }, dispatch);
69
76
 
70
- export const reducers = { taskDetails: reducer };
71
-
72
77
  export default connect(mapStateToProps, mapDispatchToProps)(TaskDetails);
@@ -1,15 +1,19 @@
1
1
  .scheduled-tasks-card {
2
2
  text-align: center;
3
+
3
4
  .scheduled-data {
5
+ margin-top: 30px;
4
6
  padding-right: 15px;
5
7
  cursor: pointer;
6
8
  font-size: 40px;
7
9
  font-weight: 300;
8
10
  transition: font-weight 50ms ease-in;
11
+
9
12
  p {
10
13
  font-size: 20px;
11
14
  margin: 0;
12
15
  }
16
+
13
17
  * {
14
18
  margin: 10px;
15
19
  }
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classNames from 'classnames';
4
+
5
+ import { Icon, Button, OverlayTrigger, Tooltip } from 'patternfly-react';
6
+ import { translate as __ } from 'foremanReact/common/I18n';
7
+ import {
8
+ TASKS_DASHBOARD_AVAILABLE_QUERY_STATES,
9
+ TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS,
10
+ } from '../../../../TasksDashboardConstants';
11
+ import { queryPropType } from '../../../../TasksDashboardPropTypes';
12
+
13
+ const tooltip = (
14
+ <Tooltip id="stopped-tooltip">
15
+ {__('Other includes all stopped tasks that are cancelled or pending')}
16
+ </Tooltip>
17
+ );
18
+
19
+ export const OtherInfo = ({ updateQuery, otherCount, query }) => {
20
+ const { OTHER } = TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS;
21
+ const { STOPPED } = TASKS_DASHBOARD_AVAILABLE_QUERY_STATES;
22
+ const active = query.state === STOPPED && query.result === OTHER;
23
+ return (
24
+ <span className={classNames(active && 'other-active')}>
25
+ <OverlayTrigger
26
+ overlay={tooltip}
27
+ trigger={['hover', 'focus']}
28
+ placement="bottom"
29
+ >
30
+ <span>
31
+ <Icon type="pf" name="info" />
32
+ <span>{__('Other:')} </span>
33
+ </span>
34
+ </OverlayTrigger>
35
+ <Button
36
+ bsStyle="link"
37
+ onClick={() =>
38
+ updateQuery({
39
+ state: STOPPED,
40
+ result: OTHER,
41
+ })
42
+ }
43
+ >
44
+ {otherCount}
45
+ </Button>
46
+ </span>
47
+ );
48
+ };
49
+ OtherInfo.propTypes = {
50
+ updateQuery: PropTypes.func.isRequired,
51
+ otherCount: PropTypes.number.isRequired,
52
+ query: queryPropType.isRequired,
53
+ };
@@ -0,0 +1,14 @@
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+
3
+ import { OtherInfo } from './OtherInfo';
4
+
5
+ const fixtures = {
6
+ render: {
7
+ updateQuery: jest.fn,
8
+ otherCount: 7,
9
+ query: { state: 'STOPPED', result: 'OTHER' },
10
+ },
11
+ };
12
+
13
+ describe('OtherInfo', () =>
14
+ testComponentSnapshotsWithFixtures(OtherInfo, fixtures));
@@ -4,8 +4,8 @@ import { Card } from 'patternfly-react';
4
4
  import classNames from 'classnames';
5
5
  import { noop } from 'foremanReact/common/helpers';
6
6
  import { translate as __ } from 'foremanReact/common/I18n';
7
-
8
- import { StoppedTable } from './StoppedTasksCardHelper';
7
+ import { OtherInfo } from './OtherInfo';
8
+ import { StoppedTable } from './StoppedTasksCardTable';
9
9
  import {
10
10
  timePropType,
11
11
  queryPropType,
@@ -14,7 +14,6 @@ import {
14
14
  TASKS_DASHBOARD_AVAILABLE_TIMES,
15
15
  TASKS_DASHBOARD_AVAILABLE_QUERY_STATES,
16
16
  } from '../../../../TasksDashboardConstants';
17
- import { getQueryValueText } from '../../../../TasksDashboardHelper';
18
17
  import './StoppedTasksCard.scss';
19
18
 
20
19
  const StoppedTasksCard = ({
@@ -44,16 +43,19 @@ const StoppedTasksCard = ({
44
43
  {__('Stopped')}
45
44
  </Card.Title>
46
45
  <Card.Body>
47
- <table className="table table-bordered table-striped stopped-table">
48
- <thead>
49
- <tr>
50
- <th />
51
- <th>{__('Total')}</th>
52
- <th>{getQueryValueText(time)}</th>
53
- </tr>
54
- </thead>
55
- <tbody>{StoppedTable(data, query, time, updateQuery)}</tbody>
56
- </table>
46
+ <React.Fragment>
47
+ <StoppedTable
48
+ data={data.results}
49
+ query={query}
50
+ time={time}
51
+ updateQuery={updateQuery}
52
+ />
53
+ <OtherInfo
54
+ updateQuery={updateQuery}
55
+ otherCount={data.other}
56
+ query={query}
57
+ />
58
+ </React.Fragment>
57
59
  </Card.Body>
58
60
  </Card>
59
61
  );
@@ -66,9 +68,12 @@ const resultPropType = PropTypes.shape({
66
68
 
67
69
  StoppedTasksCard.propTypes = {
68
70
  data: PropTypes.shape({
69
- error: resultPropType.isRequired,
70
- warning: resultPropType.isRequired,
71
- success: resultPropType.isRequired,
71
+ results: PropTypes.shape({
72
+ error: resultPropType.isRequired,
73
+ warning: resultPropType.isRequired,
74
+ success: resultPropType.isRequired,
75
+ }),
76
+ other: PropTypes.number,
72
77
  }),
73
78
  time: timePropType,
74
79
  query: queryPropType,
@@ -78,9 +83,12 @@ StoppedTasksCard.propTypes = {
78
83
 
79
84
  StoppedTasksCard.defaultProps = {
80
85
  data: {
81
- error: { total: 0, last: 0 },
82
- warning: { total: 0, last: 0 },
83
- success: { total: 0, last: 0 },
86
+ results: {
87
+ error: { total: 0, last: 0 },
88
+ warning: { total: 0, last: 0 },
89
+ success: { total: 0, last: 0 },
90
+ },
91
+ other: 0,
84
92
  },
85
93
  time: TASKS_DASHBOARD_AVAILABLE_TIMES.H24,
86
94
  query: {},