foreman-tasks 1.1.2 → 2.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 (132) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/README.md +2 -0
  4. data/app/controllers/foreman_tasks/api/tasks_controller.rb +33 -1
  5. data/app/controllers/foreman_tasks/tasks_controller.rb +9 -14
  6. data/app/lib/actions/proxy_action.rb +1 -1
  7. data/app/models/foreman_tasks/task.rb +4 -0
  8. data/app/models/foreman_tasks/task/dynflow_task.rb +3 -1
  9. data/app/models/setting/foreman_tasks.rb +1 -1
  10. data/app/services/ui_notifications/tasks/task_bulk_stop.rb +36 -0
  11. data/app/views/foreman_tasks/api/tasks/details.json.rabl +0 -1
  12. data/app/views/foreman_tasks/api/tasks/show.json.rabl +2 -0
  13. data/config/routes.rb +1 -0
  14. data/db/migrate/20200517215015_rename_bookmarks_controller.rb +35 -0
  15. data/db/migrate/20200519093217_drop_dynflow_allow_dangerous_actions_setting.foreman_tasks.rb +5 -0
  16. data/db/migrate/20200611090846_add_task_lock_index_on_resource_type_and_task_id.rb +3 -3
  17. data/db/seeds.d/30-notification_blueprints.rb +7 -0
  18. data/lib/foreman_tasks/engine.rb +2 -7
  19. data/lib/foreman_tasks/version.rb +1 -1
  20. data/locale/action_names.rb +1 -1
  21. data/locale/en/LC_MESSAGES/foreman_tasks.mo +0 -0
  22. data/locale/en/foreman_tasks.po +270 -54
  23. data/locale/foreman_tasks.pot +630 -292
  24. data/locale/fr/LC_MESSAGES/foreman_tasks.mo +0 -0
  25. data/locale/fr/foreman_tasks.po +817 -0
  26. data/locale/ja/LC_MESSAGES/foreman_tasks.mo +0 -0
  27. data/locale/ja/foreman_tasks.po +817 -0
  28. data/locale/zh_CN/LC_MESSAGES/foreman_tasks.mo +0 -0
  29. data/locale/zh_CN/foreman_tasks.po +816 -0
  30. data/package.json +1 -0
  31. data/script/npm_link_foreman_js.sh +26 -0
  32. data/webpack/ForemanTasks/Components/TaskActions/TaskAction.test.js +60 -0
  33. data/webpack/ForemanTasks/Components/{TasksTable/TasksTableActionHelpers.js → TaskActions/TaskActionHelpers.js} +21 -6
  34. data/webpack/ForemanTasks/Components/{TasksTable/__tests__/TasksTableActionHelpers.test.js → TaskActions/TaskActionHelpers.test.js} +2 -2
  35. data/webpack/ForemanTasks/Components/TaskActions/TaskActionsConstants.js +16 -0
  36. data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.js +60 -0
  37. data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.test.js +14 -0
  38. data/webpack/ForemanTasks/Components/TaskActions/__snapshots__/TaskAction.test.js.snap +233 -0
  39. data/webpack/ForemanTasks/Components/TaskActions/__snapshots__/UnlockModals.test.js.snap +25 -0
  40. data/webpack/ForemanTasks/Components/TaskActions/index.js +115 -0
  41. data/webpack/ForemanTasks/Components/TaskDetails/Components/RunningSteps.js +17 -3
  42. data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +149 -167
  43. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/RunningSteps.test.js +8 -1
  44. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +68 -3
  45. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskInfo.test.js +0 -1
  46. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/RunningSteps.test.js.snap +1 -1
  47. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +124 -76
  48. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.js +35 -5
  49. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.scss +3 -14
  50. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +40 -16
  51. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsConstants.js +3 -4
  52. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js +0 -6
  53. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +4 -10
  54. data/webpack/ForemanTasks/Components/TaskDetails/TasksDetailsHelper.js +6 -1
  55. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.fixtures.js +8 -0
  56. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +7 -1
  57. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js +18 -2
  58. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +30 -13
  59. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsActions.test.js.snap +91 -0
  60. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/integration.test.js +13 -4
  61. data/webpack/ForemanTasks/Components/TaskDetails/index.js +6 -8
  62. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardActions.js +1 -1
  63. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardActions.test.js +2 -2
  64. data/webpack/ForemanTasks/Components/TasksTable/Components/ActionSelectButton.js +14 -1
  65. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModal.js +83 -0
  66. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalActions.js +106 -0
  67. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalReducer.js +38 -0
  68. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js +46 -0
  69. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModal.test.js +36 -0
  70. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalActions.test.js +205 -0
  71. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalReducer.test.js +27 -0
  72. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalSelectors.test.js +55 -0
  73. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModal.test.js.snap +41 -0
  74. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalReducer.test.js.snap +19 -0
  75. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalSelectors.test.js.snap +32 -0
  76. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/index.js +29 -0
  77. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionSelectButton.test.js +1 -0
  78. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ActionSelectButton.test.js.snap +11 -0
  79. data/webpack/ForemanTasks/Components/TasksTable/TasksBulkActions.js +135 -35
  80. data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +13 -9
  81. data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +26 -66
  82. data/webpack/ForemanTasks/Components/TasksTable/TasksTableConstants.js +10 -12
  83. data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +30 -96
  84. data/webpack/ForemanTasks/Components/TasksTable/TasksTableSchema.js +2 -2
  85. data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +8 -4
  86. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksBulkActions.test.js +50 -2
  87. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +3 -12
  88. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableActions.test.js +22 -26
  89. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTablePage.test.js +2 -1
  90. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +3 -14
  91. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksBulkActions.test.js.snap +155 -0
  92. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +3 -14
  93. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableActions.test.js.snap +17 -124
  94. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +63 -133
  95. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/actionCellFormatter.test.js.snap +1 -0
  96. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/selectionCellFormatter.test.js.snap +2 -0
  97. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/actionCellFormatter.test.js +1 -1
  98. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/selectionCellFormatter.test.js +1 -1
  99. data/webpack/ForemanTasks/Components/TasksTable/formatters/actionCellFormatter.js +10 -7
  100. data/webpack/ForemanTasks/Components/TasksTable/formatters/selectionCellFormatter.js +7 -0
  101. data/webpack/ForemanTasks/Components/TasksTable/index.js +2 -2
  102. data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js +55 -19
  103. data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js +75 -19
  104. data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap +88 -21
  105. data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.scss +9 -0
  106. data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.test.js +44 -0
  107. data/webpack/ForemanTasks/Components/common/ClickConfirmation/__snapshots__/ClickConfirmation.test.js.snap +52 -0
  108. data/webpack/ForemanTasks/Components/common/ClickConfirmation/index.js +59 -66
  109. data/webpack/ForemanTasks/Components/common/{ToastTypesConstants.js → ToastsHelpers/ToastTypesConstants.js} +0 -0
  110. data/webpack/ForemanTasks/Components/common/ToastsHelpers/index.js +15 -0
  111. data/webpack/ForemanTasks/ForemanTasksReducers.js +2 -0
  112. data/webpack/ForemanTasks/Routes/ForemanTasksRoutes.test.js +2 -1
  113. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalHooks.js +2 -2
  114. data/webpack/__mocks__/foremanReact/components/ForemanModal/index.js +17 -3
  115. data/webpack/__mocks__/foremanReact/components/common/ActionButtons/ActionButtons.js +3 -0
  116. data/webpack/__mocks__/foremanReact/{API.js → redux/API.js} +1 -1
  117. metadata +41 -21
  118. data/webpack/ForemanTasks/Components/TasksTable/Components/CancelConfirm.js +0 -53
  119. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmationModals.js +0 -56
  120. data/webpack/ForemanTasks/Components/TasksTable/Components/ResumeConfirm.js +0 -52
  121. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/CancelConfirm.test.js +0 -26
  122. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ConfirmationModals.test.js +0 -24
  123. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ResumeConfirm.test.js +0 -26
  124. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/CancelConfirm.test.js.snap +0 -65
  125. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ConfirmationModals.test.js.snap +0 -30
  126. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ResumeConfirm.test.js.snap +0 -63
  127. data/webpack/ForemanTasks/Components/common/ActionButtons/CancelButton.js +0 -23
  128. data/webpack/ForemanTasks/Components/common/ActionButtons/CancelButton.test.js +0 -26
  129. data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.js +0 -23
  130. data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.test.js +0 -27
  131. data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/CancelButton.test.js.snap +0 -15
  132. data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ResumeButton.test.js.snap +0 -15
@@ -2,9 +2,16 @@ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import RunningSteps from '../RunningSteps';
4
4
 
5
+ const minProps = {
6
+ id: 'task-id1',
7
+ taskReload: true,
8
+ cancelStep: jest.fn(),
9
+ taskProgressToggle: jest.fn(),
10
+ };
5
11
  const fixtures = {
6
- 'render without Props': {},
12
+ 'render with min Props': minProps,
7
13
  'render with Props': {
14
+ ...minProps,
8
15
  executionPlan: {
9
16
  state: 'paused',
10
17
  cancellable: false,
@@ -1,6 +1,15 @@
1
- import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
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,12 +17,68 @@ const fixtures = {
8
17
  id: 'test',
9
18
  state: 'paused',
10
19
  hasSubTasks: true,
11
- allowDangerousActions: true,
12
20
  dynflowEnableConsole: true,
21
+ parentTask: 'parent-id',
22
+ taskReload: true,
23
+ canEdit: true,
13
24
  },
14
25
  };
15
26
 
16
27
  describe('Task', () => {
17
28
  describe('rendering', () =>
18
29
  testComponentSnapshotsWithFixtures(Task, fixtures));
30
+ describe('click test', () => {
31
+ const setModalOpen = jest.fn();
32
+ useForemanModal.mockImplementation(id => ({
33
+ setModalOpen: () => setModalOpen(id),
34
+ }));
35
+ const cancelTaskRequest = jest.fn();
36
+ const resumeTaskRequest = jest.fn();
37
+ const taskProgressToggle = jest.fn();
38
+ const id = 'some-id';
39
+ const action = 'some-action';
40
+ const props = {
41
+ taskReload: false,
42
+ id,
43
+ action,
44
+ cancelTaskRequest,
45
+ resumeTaskRequest,
46
+ taskProgressToggle,
47
+ };
48
+ afterEach(() => {
49
+ jest.clearAllMocks();
50
+ });
51
+ it('reload', () => {
52
+ const component = mount(<Task {...props} />);
53
+ const reloadButton = component.find('.reload-button').at(0);
54
+ reloadButton.simulate('click');
55
+ expect(taskProgressToggle).toBeCalled();
56
+ });
57
+ it('resume', () => {
58
+ const component = shallow(<Task {...props} />);
59
+ const resumeButton = component.find('.resume-button').at(0);
60
+ resumeButton.props().onClick();
61
+ expect(taskProgressToggle).toBeCalled();
62
+ expect(resumeTaskRequest).toBeCalledWith(id, action);
63
+ });
64
+ it('cancel', () => {
65
+ const component = shallow(<Task {...props} />);
66
+ const cancelButton = component.find('.cancel-button').at(0);
67
+ cancelButton.props().onClick();
68
+ expect(taskProgressToggle).toBeCalled();
69
+ expect(cancelTaskRequest).toBeCalledWith(id, action);
70
+ });
71
+ it('unlock', () => {
72
+ const component = shallow(<Task {...props} />);
73
+ const unlockButton = component.find('.unlock-button').at(0);
74
+ unlockButton.props().onClick();
75
+ expect(setModalOpen).toBeCalledWith({ id: UNLOCK_MODAL });
76
+ });
77
+ it('focrce unlock', () => {
78
+ const component = shallow(<Task {...props} />);
79
+ const forceUnlockButton = component.find('.force-unlock-button').at(0);
80
+ forceUnlockButton.props().onClick();
81
+ expect(setModalOpen).toBeCalledWith({ id: FORCE_UNLOCK_MODAL });
82
+ });
83
+ });
19
84
  });
@@ -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',
@@ -55,7 +55,7 @@ exports[`RunningSteps rendering render with Props 1`] = `
55
55
  </div>
56
56
  `;
57
57
 
58
- exports[`RunningSteps rendering render without Props 1`] = `
58
+ exports[`RunningSteps rendering render with min Props 1`] = `
59
59
  <span>
60
60
  No running steps
61
61
  </span>
@@ -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,11 @@ 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
- onClick={[Function]}
49
36
  >
50
37
  <span
51
- className="glyphicon glyphicon-refresh "
38
+ className="glyphicon glyphicon-refresh spin"
52
39
  />
53
- Start auto-reloading
40
+ Stop auto-reloading
54
41
  </Button>
55
42
  <Button
56
43
  active={false}
@@ -58,29 +45,59 @@ exports[`Task rendering render with some Props 1`] = `
58
45
  bsClass="btn"
59
46
  bsSize="small"
60
47
  bsStyle="default"
48
+ className="dynflow-button"
61
49
  disabled={false}
62
50
  href="/foreman_tasks/dynflow/"
51
+ rel="noopener noreferrer"
52
+ target="_blank"
63
53
  >
64
- Dynflow console
54
+ <span>
55
+ Dynflow console
56
+ </span>
65
57
  </Button>
66
- <ResumeButton
58
+ <Button
59
+ active={false}
60
+ block={false}
61
+ bsClass="btn"
62
+ bsSize="small"
63
+ bsStyle="default"
64
+ className="resume-button"
67
65
  disabled={true}
68
- id="test"
69
- name=""
70
66
  onClick={[Function]}
71
- />
72
- <CancelButton
67
+ >
68
+ Resume
69
+ </Button>
70
+ <Button
71
+ active={false}
72
+ block={false}
73
+ bsClass="btn"
74
+ bsSize="small"
75
+ bsStyle="default"
76
+ className="cancel-button"
73
77
  disabled={true}
74
- id="test"
75
- name=""
76
78
  onClick={[Function]}
77
- />
79
+ >
80
+ Cancel
81
+ </Button>
78
82
  <Button
79
83
  active={false}
80
84
  block={false}
81
85
  bsClass="btn"
82
86
  bsSize="small"
83
87
  bsStyle="default"
88
+ className="parent-button"
89
+ disabled={false}
90
+ href="/foreman_tasks/tasks/parent-id"
91
+ >
92
+ Parent task
93
+ </Button>
94
+ <Button
95
+ active={false}
96
+ block={false}
97
+ bsClass="btn"
98
+ bsSize="small"
99
+ bsStyle="default"
100
+ className="subtask-button"
84
101
  disabled={false}
85
102
  href="/foreman_tasks/tasks/test/sub_tasks"
86
103
  >
@@ -92,8 +109,9 @@ exports[`Task rendering render with some Props 1`] = `
92
109
  bsClass="btn"
93
110
  bsSize="small"
94
111
  bsStyle="default"
112
+ className="unlock-button"
95
113
  disabled={false}
96
- onClick={[Function]}
114
+ onClick={[MockFunction]}
97
115
  >
98
116
  Unlock
99
117
  </Button>
@@ -103,8 +121,9 @@ exports[`Task rendering render with some Props 1`] = `
103
121
  bsClass="btn"
104
122
  bsSize="small"
105
123
  bsStyle="default"
124
+ className="force-unlock-button"
106
125
  disabled={false}
107
- onClick={[Function]}
126
+ onClick={[MockFunction]}
108
127
  >
109
128
  Force Unlock
110
129
  </Button>
@@ -112,7 +131,7 @@ exports[`Task rendering render with some Props 1`] = `
112
131
  </Row>
113
132
  <TaskInfo
114
133
  action=""
115
- allowDangerousActions={true}
134
+ canEdit={true}
116
135
  cancelTaskRequest={[Function]}
117
136
  cancellable={false}
118
137
  dynflowEnableConsole={true}
@@ -123,24 +142,19 @@ exports[`Task rendering render with some Props 1`] = `
123
142
  help=""
124
143
  id="test"
125
144
  output=""
126
- parentTask=""
145
+ parentTask="parent-id"
127
146
  progress={0}
128
147
  refetchTaskDetails={[Function]}
129
148
  result="error"
130
149
  resumable={false}
131
150
  resumeTaskRequest={[Function]}
132
- showForceUnlockModal={false}
133
- showUnlockModal={false}
134
151
  startAt=""
135
152
  startBefore=""
136
153
  startedAt=""
137
154
  state="paused"
138
- taskReload={false}
139
- taskReloadStart={[Function]}
155
+ taskReload={true}
140
156
  taskReloadStop={[Function]}
141
157
  timeoutId={null}
142
- toggleForceUnlockModal={[Function]}
143
- toggleUnlockModal={[Function]}
144
158
  username=""
145
159
  usernamePath=""
146
160
  />
@@ -150,25 +164,14 @@ exports[`Task rendering render with some Props 1`] = `
150
164
 
151
165
  exports[`Task rendering render without Props 1`] = `
152
166
  <Fragment>
153
- <ClickConfirmation
154
- 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."
155
- closeModal={[Function]}
156
- confirmAction="Unlock"
157
- confirmType="warning"
158
- confirmationMessage="I understand that this may cause harm and have working database backups of all backend services."
159
- path="/foreman_tasks/tasks/test/unlock"
160
- showModal={false}
161
- title="Unlock"
167
+ <UnlockModal
168
+ id="unlockModal"
169
+ onClick={[Function]}
162
170
  />
163
- <ClickConfirmation
164
- 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"
165
- closeModal={[Function]}
166
- confirmAction="Force Unlock"
167
- confirmType="danger"
168
- confirmationMessage="I understand that this may cause harm and have working database backups of all backend services."
169
- path="/foreman_tasks/tasks/test/force_unlock"
170
- showModal={false}
171
- title="Force Unlock"
171
+ <ForceUnlockModal
172
+ id="forceUnlockModal"
173
+ onClick={[Function]}
174
+ selectedRowsLen={1}
172
175
  />
173
176
  <Grid
174
177
  bsClass="container"
@@ -192,8 +195,6 @@ exports[`Task rendering render without Props 1`] = `
192
195
  bsStyle="default"
193
196
  className="reload-button"
194
197
  disabled={false}
195
- hidden={true}
196
- onClick={[Function]}
197
198
  >
198
199
  <span
199
200
  className="glyphicon glyphicon-refresh "
@@ -206,28 +207,80 @@ exports[`Task rendering render without Props 1`] = `
206
207
  bsClass="btn"
207
208
  bsSize="small"
208
209
  bsStyle="default"
210
+ className="dynflow-button"
209
211
  disabled={true}
210
212
  href="/foreman_tasks/dynflow/"
213
+ rel="noopener noreferrer"
214
+ target="_blank"
211
215
  >
212
- Dynflow console
216
+ <span
217
+ data-original-title="dynflow_enable_console Setting is off"
218
+ title="dynflow_enable_console Setting is off"
219
+ >
220
+ Dynflow console
221
+ </span>
213
222
  </Button>
214
- <ResumeButton
223
+ <Button
224
+ active={false}
225
+ block={false}
226
+ bsClass="btn"
227
+ bsSize="small"
228
+ bsStyle="default"
229
+ className="resume-button"
230
+ data-original-title="You do not have permission"
215
231
  disabled={true}
216
- id="test"
217
- name=""
218
232
  onClick={[Function]}
219
- />
220
- <CancelButton
233
+ title="You do not have permission"
234
+ >
235
+ Resume
236
+ </Button>
237
+ <Button
238
+ active={false}
239
+ block={false}
240
+ bsClass="btn"
241
+ bsSize="small"
242
+ bsStyle="default"
243
+ className="cancel-button"
244
+ data-original-title="You do not have permission"
221
245
  disabled={true}
222
- id="test"
223
- name=""
224
246
  onClick={[Function]}
225
- />
247
+ title="You do not have permission"
248
+ >
249
+ Cancel
250
+ </Button>
251
+ <Button
252
+ active={false}
253
+ block={false}
254
+ bsClass="btn"
255
+ bsSize="small"
256
+ bsStyle="default"
257
+ className="unlock-button"
258
+ data-original-title="You do not have permission"
259
+ disabled={true}
260
+ onClick={[MockFunction]}
261
+ title="You do not have permission"
262
+ >
263
+ Unlock
264
+ </Button>
265
+ <Button
266
+ active={false}
267
+ block={false}
268
+ bsClass="btn"
269
+ bsSize="small"
270
+ bsStyle="default"
271
+ className="force-unlock-button"
272
+ data-original-title="You do not have permission"
273
+ disabled={true}
274
+ onClick={[MockFunction]}
275
+ title="You do not have permission"
276
+ >
277
+ Force Unlock
278
+ </Button>
226
279
  </Col>
227
280
  </Row>
228
281
  <TaskInfo
229
282
  action=""
230
- allowDangerousActions={false}
283
+ canEdit={false}
231
284
  cancelTaskRequest={[Function]}
232
285
  cancellable={false}
233
286
  dynflowEnableConsole={false}
@@ -244,18 +297,13 @@ exports[`Task rendering render without Props 1`] = `
244
297
  result="error"
245
298
  resumable={false}
246
299
  resumeTaskRequest={[Function]}
247
- showForceUnlockModal={false}
248
- showUnlockModal={false}
249
300
  startAt=""
250
301
  startBefore=""
251
302
  startedAt=""
252
303
  state=""
253
304
  taskReload={false}
254
- taskReloadStart={[Function]}
255
305
  taskReloadStop={[Function]}
256
306
  timeoutId={null}
257
- toggleForceUnlockModal={[Function]}
258
- toggleUnlockModal={[Function]}
259
307
  username=""
260
308
  usernamePath=""
261
309
  />
@@ -20,6 +20,22 @@ class TaskDetails extends Component {
20
20
  componentWillUnmount() {
21
21
  this.props.taskReloadStop(this.props.timeoutId);
22
22
  }
23
+ taskProgressToggle = () => {
24
+ const {
25
+ timeoutId,
26
+ refetchTaskDetails,
27
+ id,
28
+ loading,
29
+ taskReloadStop,
30
+ taskReloadStart,
31
+ } = this.props;
32
+ if (timeoutId) {
33
+ taskReloadStop(timeoutId);
34
+ } else {
35
+ taskReloadStart(timeoutId, refetchTaskDetails, id, loading);
36
+ }
37
+ };
38
+
23
39
  render() {
24
40
  const {
25
41
  externalId,
@@ -32,6 +48,7 @@ class TaskDetails extends Component {
32
48
  failedSteps,
33
49
  runningSteps,
34
50
  locks,
51
+ cancelStep,
35
52
  } = this.props;
36
53
  const id = getTaskID();
37
54
  const resumable = executionPlan ? executionPlan.state === 'paused' : false;
@@ -40,12 +57,23 @@ class TaskDetails extends Component {
40
57
  <div className="task-details-react well">
41
58
  <Tabs defaultActiveKey={1} animation={false} id="task-details-tabs">
42
59
  <Tab eventKey={1} title={__('Task')}>
43
- <Task {...{ ...this.props, cancellable, resumable, id }} />
60
+ <Task
61
+ {...{
62
+ ...this.props,
63
+ cancellable,
64
+ resumable,
65
+ id,
66
+ taskProgressToggle: this.taskProgressToggle,
67
+ }}
68
+ />
44
69
  </Tab>
45
70
  <Tab eventKey={2} title={__('Running Steps')}>
46
71
  <RunningSteps
47
- executionPlan={executionPlan}
48
72
  runningSteps={runningSteps}
73
+ id={id}
74
+ cancelStep={cancelStep}
75
+ taskReload={this.props.taskReload}
76
+ taskProgressToggle={this.taskProgressToggle}
49
77
  />
50
78
  </Tab>
51
79
  <Tab eventKey={3} title={__('Errors')}>
@@ -67,16 +95,18 @@ class TaskDetails extends Component {
67
95
 
68
96
  TaskDetails.propTypes = {
69
97
  label: PropTypes.string,
70
- fetchTaskDetails: PropTypes.func,
98
+ fetchTaskDetails: PropTypes.func.isRequired,
99
+ runningSteps: PropTypes.array,
100
+ cancelStep: PropTypes.func.isRequired,
101
+ taskReload: PropTypes.bool.isRequired,
71
102
  ...Task.propTypes,
72
- ...RunningSteps.propTypes,
73
103
  ...Errors.propTypes,
74
104
  ...Locks.propTypes,
75
105
  ...Raw.propTypes,
76
106
  };
77
107
  TaskDetails.defaultProps = {
78
108
  label: '',
79
- fetchTaskDetails: () => null,
109
+ runningSteps: [],
80
110
  ...Task.defaultProps,
81
111
  ...RunningSteps.defaultProps,
82
112
  ...Errors.defaultProps,