foreman-tasks 11.0.5 → 11.0.7

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 (75) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/foreman-tasks/locale/de/foreman_tasks.js +5 -2
  3. data/app/assets/javascripts/foreman-tasks/locale/en/foreman_tasks.js +4 -1
  4. data/app/assets/javascripts/foreman-tasks/locale/es/foreman_tasks.js +5 -2
  5. data/app/assets/javascripts/foreman-tasks/locale/fr/foreman_tasks.js +11 -8
  6. data/app/assets/javascripts/foreman-tasks/locale/ja/foreman_tasks.js +12 -9
  7. data/app/assets/javascripts/foreman-tasks/locale/ka/foreman_tasks.js +5 -2
  8. data/app/assets/javascripts/foreman-tasks/locale/ko/foreman_tasks.js +167 -165
  9. data/app/assets/javascripts/foreman-tasks/locale/pt_BR/foreman_tasks.js +5 -2
  10. data/app/assets/javascripts/foreman-tasks/locale/ru/foreman_tasks.js +5 -2
  11. data/app/assets/javascripts/foreman-tasks/locale/zh_CN/foreman_tasks.js +11 -8
  12. data/app/assets/javascripts/foreman-tasks/locale/zh_TW/foreman_tasks.js +5 -2
  13. data/lib/foreman_tasks/dynflow/console_authorizer.rb +1 -3
  14. data/lib/foreman_tasks/version.rb +1 -1
  15. data/locale/Makefile +18 -7
  16. data/locale/de/LC_MESSAGES/foreman_tasks.mo +0 -0
  17. data/locale/de/foreman_tasks.po +5 -2
  18. data/locale/en/LC_MESSAGES/foreman_tasks.mo +0 -0
  19. data/locale/en/foreman_tasks.po +4 -1
  20. data/locale/es/LC_MESSAGES/foreman_tasks.mo +0 -0
  21. data/locale/es/foreman_tasks.po +5 -2
  22. data/locale/foreman_tasks.pot +10 -6
  23. data/locale/fr/LC_MESSAGES/foreman_tasks.mo +0 -0
  24. data/locale/fr/foreman_tasks.po +11 -8
  25. data/locale/ja/LC_MESSAGES/foreman_tasks.mo +0 -0
  26. data/locale/ja/foreman_tasks.po +12 -9
  27. data/locale/ka/LC_MESSAGES/foreman_tasks.mo +0 -0
  28. data/locale/ka/foreman_tasks.po +5 -2
  29. data/locale/ko/LC_MESSAGES/foreman_tasks.mo +0 -0
  30. data/locale/ko/foreman_tasks.po +167 -165
  31. data/locale/pt_BR/LC_MESSAGES/foreman_tasks.mo +0 -0
  32. data/locale/pt_BR/foreman_tasks.po +5 -2
  33. data/locale/ru/LC_MESSAGES/foreman_tasks.mo +0 -0
  34. data/locale/ru/foreman_tasks.po +5 -2
  35. data/locale/zh_CN/LC_MESSAGES/foreman_tasks.mo +0 -0
  36. data/locale/zh_CN/foreman_tasks.po +11 -8
  37. data/locale/zh_TW/LC_MESSAGES/foreman_tasks.mo +0 -0
  38. data/locale/zh_TW/foreman_tasks.po +5 -2
  39. data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +37 -9
  40. data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskButtons.js +19 -16
  41. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskButtons.test.js +197 -71
  42. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +24 -40
  43. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +2 -16
  44. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js +0 -16
  45. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/GenericConfirmModal.js +70 -0
  46. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalSelectors.test.js +25 -14
  47. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalSelectors.test.js.snap +8 -7
  48. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/index.test.js +409 -0
  49. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/createBulkTaskModal.js +67 -0
  50. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/createTaskModal.js +51 -0
  51. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/index.js +73 -23
  52. data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +5 -2
  53. data/webpack/ForemanTasks/Components/TasksTable/TasksTableConstants.js +1 -1
  54. data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +67 -11
  55. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +86 -6
  56. data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.test.js +225 -39
  57. data/webpack/ForemanTasks/Components/common/ClickConfirmation/index.js +136 -37
  58. metadata +6 -19
  59. data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.js +0 -60
  60. data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.test.js +0 -14
  61. data/webpack/ForemanTasks/Components/TaskActions/__snapshots__/UnlockModals.test.js.snap +0 -25
  62. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskButtons.test.js.snap +0 -212
  63. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModal.js +0 -83
  64. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalActions.js +0 -106
  65. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalReducer.js +0 -38
  66. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModal.test.js +0 -36
  67. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalActions.test.js +0 -205
  68. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalReducer.test.js +0 -27
  69. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModal.test.js.snap +0 -41
  70. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalReducer.test.js.snap +0 -19
  71. data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.scss +0 -9
  72. data/webpack/ForemanTasks/Components/common/ClickConfirmation/__snapshots__/ClickConfirmation.test.js.snap +0 -52
  73. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +0 -2
  74. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalHooks.js +0 -10
  75. data/webpack/__mocks__/foremanReact/components/ForemanModal/index.js +0 -18
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.0.5
4
+ version: 11.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
@@ -396,10 +396,7 @@ files:
396
396
  - webpack/ForemanTasks/Components/TaskActions/TaskActionHelpers.js
397
397
  - webpack/ForemanTasks/Components/TaskActions/TaskActionHelpers.test.js
398
398
  - webpack/ForemanTasks/Components/TaskActions/TaskActionsConstants.js
399
- - webpack/ForemanTasks/Components/TaskActions/UnlockModals.js
400
- - webpack/ForemanTasks/Components/TaskActions/UnlockModals.test.js
401
399
  - webpack/ForemanTasks/Components/TaskActions/__snapshots__/TaskAction.test.js.snap
402
- - webpack/ForemanTasks/Components/TaskActions/__snapshots__/UnlockModals.test.js.snap
403
400
  - webpack/ForemanTasks/Components/TaskActions/index.js
404
401
  - webpack/ForemanTasks/Components/TaskDetails/Components/Errors.js
405
402
  - webpack/ForemanTasks/Components/TaskDetails/Components/Locks.js
@@ -423,7 +420,6 @@ files:
423
420
  - webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Raw.test.js.snap
424
421
  - webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/RunningSteps.test.js.snap
425
422
  - webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap
426
- - webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskButtons.test.js.snap
427
423
  - webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskInfo.test.js.snap
428
424
  - webpack/ForemanTasks/Components/TaskDetails/TaskDetails.js
429
425
  - webpack/ForemanTasks/Components/TaskDetails/TaskDetails.scss
@@ -504,17 +500,13 @@ files:
504
500
  - webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboardSelectors.test.js.snap
505
501
  - webpack/ForemanTasks/Components/TasksDashboard/index.js
506
502
  - webpack/ForemanTasks/Components/TasksTable/Components/ActionSelectButton.js
507
- - webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModal.js
508
- - webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalActions.js
509
- - webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalReducer.js
510
503
  - webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js
511
- - webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModal.test.js
512
- - webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalActions.test.js
513
- - webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalReducer.test.js
504
+ - webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/GenericConfirmModal.js
514
505
  - webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalSelectors.test.js
515
- - webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModal.test.js.snap
516
- - webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalReducer.test.js.snap
517
506
  - webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalSelectors.test.js.snap
507
+ - webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/index.test.js
508
+ - webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/createBulkTaskModal.js
509
+ - webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/createTaskModal.js
518
510
  - webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/index.js
519
511
  - webpack/ForemanTasks/Components/TasksTable/Components/SelectAllAlert.js
520
512
  - webpack/ForemanTasks/Components/TasksTable/Components/TableSelectionCell.js
@@ -578,9 +570,7 @@ files:
578
570
  - webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js
579
571
  - webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js
580
572
  - webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap
581
- - webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.scss
582
573
  - webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.test.js
583
- - webpack/ForemanTasks/Components/common/ClickConfirmation/__snapshots__/ClickConfirmation.test.js.snap
584
574
  - webpack/ForemanTasks/Components/common/ClickConfirmation/index.js
585
575
  - webpack/ForemanTasks/Components/common/ToastsHelpers/ToastTypesConstants.js
586
576
  - webpack/ForemanTasks/Components/common/ToastsHelpers/index.js
@@ -605,9 +595,6 @@ files:
605
595
  - webpack/__mocks__/foremanReact/common/I18n.js
606
596
  - webpack/__mocks__/foremanReact/common/helpers.js
607
597
  - webpack/__mocks__/foremanReact/common/urlHelpers.js
608
- - webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js
609
- - webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalHooks.js
610
- - webpack/__mocks__/foremanReact/components/ForemanModal/index.js
611
598
  - webpack/__mocks__/foremanReact/components/Layout/LayoutActions.js
612
599
  - webpack/__mocks__/foremanReact/components/Pagination/index.js
613
600
  - webpack/__mocks__/foremanReact/components/ToastsList/index.js
@@ -642,7 +629,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
642
629
  - !ruby/object:Gem::Version
643
630
  version: '0'
644
631
  requirements: []
645
- rubygems_version: 3.6.9
632
+ rubygems_version: 4.0.3
646
633
  specification_version: 4
647
634
  summary: Foreman plugin for showing tasks information for resources and users
648
635
  test_files:
@@ -1,60 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { translate as __, sprintf } from 'foremanReact/common/I18n';
4
- import { ClickConfirmation } from '../common/ClickConfirmation';
5
- import { UNLOCK_MODAL, FORCE_UNLOCK_MODAL } from './TaskActionsConstants';
6
-
7
- const confirmationMessage = __(
8
- 'I understand that this may cause harm and have working database backups of all backend services.'
9
- );
10
-
11
- export const UnlockModal = ({ onClick, id }) => (
12
- <ClickConfirmation
13
- id={id}
14
- title={__('Unlock')}
15
- body={__(
16
- "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."
17
- )}
18
- confirmationMessage={confirmationMessage}
19
- confirmAction={__('Unlock')}
20
- onClick={onClick}
21
- confirmType="warning"
22
- />
23
- );
24
-
25
- export const ForceUnlockModal = ({ onClick, id, selectedRowsLen }) => (
26
- <ClickConfirmation
27
- id={id}
28
- title={__('Force Unlock')}
29
- body={sprintf(
30
- __(
31
- `Resources for %s task(s) will be unlocked and will not prevent other tasks from being run. As the task(s) might be still running, it should be avoided to use this unless you are really sure the task(s) got stuck.`
32
- ),
33
- selectedRowsLen
34
- )}
35
- confirmationMessage={confirmationMessage}
36
- confirmAction={__('Force Unlock')}
37
- onClick={onClick}
38
- confirmType="danger"
39
- />
40
- );
41
-
42
- UnlockModal.propTypes = {
43
- onClick: PropTypes.func.isRequired,
44
- id: PropTypes.string,
45
- };
46
-
47
- ForceUnlockModal.propTypes = {
48
- onClick: PropTypes.func.isRequired,
49
- id: PropTypes.string,
50
- selectedRowsLen: PropTypes.number,
51
- };
52
-
53
- UnlockModal.defaultProps = {
54
- id: UNLOCK_MODAL,
55
- };
56
-
57
- ForceUnlockModal.defaultProps = {
58
- id: FORCE_UNLOCK_MODAL,
59
- selectedRowsLen: 1,
60
- };
@@ -1,14 +0,0 @@
1
- import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
-
3
- import { UnlockModal, ForceUnlockModal } from './UnlockModals';
4
-
5
- const fixtures = {
6
- render: { taskID: 'some-id', onClick: jest.fn() },
7
- };
8
-
9
- describe('UnlockModal', () => {
10
- testComponentSnapshotsWithFixtures(UnlockModal, fixtures);
11
- });
12
- describe('ForceUnlockModal', () => {
13
- testComponentSnapshotsWithFixtures(ForceUnlockModal, fixtures);
14
- });
@@ -1,25 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`ForceUnlockModal render 1`] = `
4
- <ClickConfirmation
5
- body="Resources for 1 task(s) will be unlocked and will not prevent other tasks from being run. As the task(s) might be still running, it should be avoided to use this unless you are really sure the task(s) got stuck."
6
- confirmAction="Force Unlock"
7
- confirmType="danger"
8
- confirmationMessage="I understand that this may cause harm and have working database backups of all backend services."
9
- id="forceUnlockModal"
10
- onClick={[MockFunction]}
11
- title="Force Unlock"
12
- />
13
- `;
14
-
15
- exports[`UnlockModal render 1`] = `
16
- <ClickConfirmation
17
- 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."
18
- confirmAction="Unlock"
19
- confirmType="warning"
20
- confirmationMessage="I understand that this may cause harm and have working database backups of all backend services."
21
- id="unlockModal"
22
- onClick={[MockFunction]}
23
- title="Unlock"
24
- />
25
- `;
@@ -1,212 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Task rendering render with minimal Props 1`] = `
4
- <Col
5
- bsClass="col"
6
- componentClass="div"
7
- xs={12}
8
- >
9
- <Button
10
- active={false}
11
- block={false}
12
- bsClass="btn"
13
- bsSize="small"
14
- bsStyle="default"
15
- className="reload-button"
16
- disabled={false}
17
- onClick={[MockFunction]}
18
- >
19
- <span
20
- className="glyphicon glyphicon-refresh "
21
- />
22
- Start auto-reloading
23
- </Button>
24
- <Button
25
- active={false}
26
- block={false}
27
- bsClass="btn"
28
- bsSize="small"
29
- bsStyle="default"
30
- className="dynflow-button"
31
- disabled={true}
32
- href="/foreman_tasks/dynflow/"
33
- rel="noopener noreferrer"
34
- target="_blank"
35
- >
36
- <span
37
- data-original-title="dynflow_enable_console Setting is off"
38
- title="dynflow_enable_console Setting is off"
39
- >
40
- Dynflow console
41
- </span>
42
- </Button>
43
- <Button
44
- active={false}
45
- block={false}
46
- bsClass="btn"
47
- bsSize="small"
48
- bsStyle="default"
49
- className="resume-button"
50
- data-original-title="You do not have permission"
51
- disabled={true}
52
- onClick={[Function]}
53
- title="You do not have permission"
54
- >
55
- Resume
56
- </Button>
57
- <Button
58
- active={false}
59
- block={false}
60
- bsClass="btn"
61
- bsSize="small"
62
- bsStyle="default"
63
- className="cancel-button"
64
- data-original-title="You do not have permission"
65
- disabled={true}
66
- onClick={[Function]}
67
- title="You do not have permission"
68
- >
69
- Cancel
70
- </Button>
71
- <Button
72
- active={false}
73
- block={false}
74
- bsClass="btn"
75
- bsSize="small"
76
- bsStyle="default"
77
- className="unlock-button"
78
- data-original-title="You do not have permission"
79
- disabled={true}
80
- onClick={[MockFunction]}
81
- title="You do not have permission"
82
- >
83
- Unlock
84
- </Button>
85
- <Button
86
- active={false}
87
- block={false}
88
- bsClass="btn"
89
- bsSize="small"
90
- bsStyle="default"
91
- className="force-unlock-button"
92
- data-original-title="You do not have permission"
93
- disabled={true}
94
- onClick={[MockFunction]}
95
- title="You do not have permission"
96
- >
97
- Force Unlock
98
- </Button>
99
- </Col>
100
- `;
101
-
102
- exports[`Task rendering render with some Props 1`] = `
103
- <Col
104
- bsClass="col"
105
- componentClass="div"
106
- xs={12}
107
- >
108
- <Button
109
- active={false}
110
- block={false}
111
- bsClass="btn"
112
- bsSize="small"
113
- bsStyle="default"
114
- className="reload-button"
115
- disabled={false}
116
- onClick={[MockFunction]}
117
- >
118
- <span
119
- className="glyphicon glyphicon-refresh spin"
120
- />
121
- Stop auto-reloading
122
- </Button>
123
- <Button
124
- active={false}
125
- block={false}
126
- bsClass="btn"
127
- bsSize="small"
128
- bsStyle="default"
129
- className="dynflow-button"
130
- disabled={false}
131
- href="/foreman_tasks/dynflow/"
132
- rel="noopener noreferrer"
133
- target="_blank"
134
- >
135
- <span>
136
- Dynflow console
137
- </span>
138
- </Button>
139
- <Button
140
- active={false}
141
- block={false}
142
- bsClass="btn"
143
- bsSize="small"
144
- bsStyle="default"
145
- className="resume-button"
146
- disabled={true}
147
- onClick={[Function]}
148
- >
149
- Resume
150
- </Button>
151
- <Button
152
- active={false}
153
- block={false}
154
- bsClass="btn"
155
- bsSize="small"
156
- bsStyle="default"
157
- className="cancel-button"
158
- disabled={true}
159
- onClick={[Function]}
160
- >
161
- Cancel
162
- </Button>
163
- <Button
164
- active={false}
165
- block={false}
166
- bsClass="btn"
167
- bsSize="small"
168
- bsStyle="default"
169
- className="parent-button"
170
- disabled={false}
171
- href="/foreman_tasks/tasks/parent-id"
172
- >
173
- Parent task
174
- </Button>
175
- <Button
176
- active={false}
177
- block={false}
178
- bsClass="btn"
179
- bsSize="small"
180
- bsStyle="default"
181
- className="subtask-button"
182
- disabled={false}
183
- href="/foreman_tasks/tasks/test/sub_tasks"
184
- >
185
- Sub tasks
186
- </Button>
187
- <Button
188
- active={false}
189
- block={false}
190
- bsClass="btn"
191
- bsSize="small"
192
- bsStyle="default"
193
- className="unlock-button"
194
- disabled={false}
195
- onClick={[MockFunction]}
196
- >
197
- Unlock
198
- </Button>
199
- <Button
200
- active={false}
201
- block={false}
202
- bsClass="btn"
203
- bsSize="small"
204
- bsStyle="default"
205
- className="force-unlock-button"
206
- disabled={false}
207
- onClick={[MockFunction]}
208
- >
209
- Force Unlock
210
- </Button>
211
- </Col>
212
- `;
@@ -1,83 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { startCase } from 'lodash';
4
- import { sprintf, translate as __ } from 'foremanReact/common/I18n';
5
- import { Button } from 'patternfly-react';
6
- import ForemanModal from 'foremanReact/components/ForemanModal';
7
- import { FORCE_UNLOCK_MODAL } from '../../../TaskActions/TaskActionsConstants';
8
- import { FORCE_UNLOCK_SELECTED_MODAL } from '../../TasksTableConstants';
9
- import { ForceUnlockModal } from '../../../TaskActions/UnlockModals';
10
-
11
- export const ConfirmModal = ({
12
- actionText,
13
- actionState,
14
- actionType,
15
- selectedRowsLen,
16
- id,
17
- parentTaskID,
18
- url,
19
- uriQuery: query,
20
- setModalClosed,
21
- ...props
22
- }) => {
23
- if ([FORCE_UNLOCK_MODAL, FORCE_UNLOCK_SELECTED_MODAL].includes(actionType)) {
24
- return (
25
- <ForceUnlockModal
26
- onClick={() => {
27
- props[actionType]({ url, query, parentTaskID });
28
- setModalClosed();
29
- }}
30
- id={id}
31
- selectedRowsLen={selectedRowsLen}
32
- />
33
- );
34
- }
35
- return (
36
- <ForemanModal
37
- title={sprintf(__('%s Selected Tasks'), startCase(actionText))}
38
- id={id}
39
- >
40
- {sprintf(
41
- __(
42
- `This will %(action)s %(number)s task(s), putting them in the %(state)s state. Are you sure?`
43
- ),
44
- { action: actionText, number: selectedRowsLen, state: actionState }
45
- )}
46
- <ForemanModal.Footer>
47
- <Button onClick={setModalClosed}>{__('No')}</Button>
48
- <Button
49
- className="confirm-button"
50
- bsStyle="primary"
51
- onClick={() => {
52
- props[actionType]({ url, query, parentTaskID });
53
- setModalClosed();
54
- }}
55
- >
56
- {__('Yes')}
57
- </Button>
58
- </ForemanModal.Footer>
59
- </ForemanModal>
60
- );
61
- };
62
-
63
- ConfirmModal.propTypes = {
64
- actionText: PropTypes.string,
65
- actionState: PropTypes.string,
66
- selectedRowsLen: PropTypes.number.isRequired,
67
- actionType: PropTypes.string,
68
- id: PropTypes.string.isRequired,
69
- parentTaskID: PropTypes.string,
70
- url: PropTypes.string.isRequired,
71
- uriQuery: PropTypes.object,
72
- setModalClosed: PropTypes.func.isRequired,
73
- };
74
-
75
- ConfirmModal.defaultProps = {
76
- actionType: '',
77
- actionText: '',
78
- actionState: '',
79
- parentTaskID: '',
80
- uriQuery: {},
81
- };
82
-
83
- export default ConfirmModal;
@@ -1,106 +0,0 @@
1
- import {
2
- resumeTask,
3
- cancelTask,
4
- forceCancelTask,
5
- } from '../../TasksTableActions';
6
- import {
7
- bulkCancelBySearch,
8
- bulkCancelById,
9
- bulkResumeBySearch,
10
- bulkResumeById,
11
- bulkForceCancelBySearch,
12
- bulkForceCancelById,
13
- } from '../../TasksBulkActions';
14
- import { selectClicked, selectSelectedTasks } from './ConfirmModalSelectors';
15
- import { selectAllRowsSelected } from '../../TasksTableSelectors';
16
- import {
17
- CANCEL_MODAL,
18
- RESUME_MODAL,
19
- CANCEL_SELECTED_MODAL,
20
- RESUME_SELECTED_MODAL,
21
- FORCE_UNLOCK_SELECTED_MODAL,
22
- } from '../../TasksTableConstants';
23
- import { FORCE_UNLOCK_MODAL } from '../../../TaskActions/TaskActionsConstants';
24
-
25
- export default {
26
- [CANCEL_SELECTED_MODAL]: ({ url, query, parentTaskID }) => (
27
- dispatch,
28
- getState
29
- ) => {
30
- if (selectAllRowsSelected(getState())) {
31
- return dispatch(bulkCancelBySearch({ query, parentTaskID }));
32
- }
33
- return dispatch(
34
- bulkCancelById({
35
- selected: selectSelectedTasks(getState()),
36
- url,
37
- parentTaskID,
38
- })
39
- );
40
- },
41
- [CANCEL_MODAL]: ({ url, parentTaskID }) => (dispatch, getState) => {
42
- const { taskId, taskName } = selectClicked(getState());
43
- return dispatch(
44
- cancelTask({
45
- taskId,
46
- taskName,
47
- url,
48
- parentTaskID,
49
- })
50
- );
51
- },
52
- [RESUME_SELECTED_MODAL]: ({ url, query, parentTaskID }) => (
53
- dispatch,
54
- getState
55
- ) => {
56
- if (selectAllRowsSelected(getState())) {
57
- return dispatch(bulkResumeBySearch({ query, parentTaskID }));
58
- }
59
- return dispatch(
60
- bulkResumeById({
61
- selected: selectSelectedTasks(getState()),
62
- url,
63
- parentTaskID,
64
- })
65
- );
66
- },
67
-
68
- [RESUME_MODAL]: ({ url, parentTaskID }) => (dispatch, getState) => {
69
- const { taskId, taskName } = selectClicked(getState());
70
- return dispatch(
71
- resumeTask({
72
- taskId,
73
- taskName,
74
- url,
75
- parentTaskID,
76
- })
77
- );
78
- },
79
-
80
- [FORCE_UNLOCK_MODAL]: ({ url, parentTaskID }) => (dispatch, getState) => {
81
- const { taskId, taskName } = selectClicked(getState());
82
- return dispatch(
83
- forceCancelTask({
84
- taskId,
85
- taskName,
86
- url,
87
- parentTaskID,
88
- })
89
- );
90
- },
91
- [FORCE_UNLOCK_SELECTED_MODAL]: ({ url, query, parentTaskID }) => (
92
- dispatch,
93
- getState
94
- ) => {
95
- if (selectAllRowsSelected(getState())) {
96
- return dispatch(bulkForceCancelBySearch({ query, parentTaskID }));
97
- }
98
- return dispatch(
99
- bulkForceCancelById({
100
- selected: selectSelectedTasks(getState()),
101
- url,
102
- parentTaskID,
103
- })
104
- );
105
- },
106
- };
@@ -1,38 +0,0 @@
1
- import Immutable from 'seamless-immutable';
2
- import {
3
- UPDATE_MODAL,
4
- CANCEL_SELECTED_MODAL,
5
- RESUME_SELECTED_MODAL,
6
- RESUME_MODAL,
7
- CANCEL_MODAL,
8
- } from '../../TasksTableConstants';
9
-
10
- const initialState = Immutable({});
11
-
12
- export const ConfirmModalReducer = (state = initialState, action) => {
13
- const { type, payload } = action;
14
- switch (type) {
15
- case UPDATE_MODAL:
16
- switch (payload.modalID) {
17
- case CANCEL_SELECTED_MODAL:
18
- case CANCEL_MODAL:
19
- return state.merge({
20
- actionText: 'cancel',
21
- actionState: 'stopped',
22
- actionType: payload.modalID,
23
- });
24
- case RESUME_SELECTED_MODAL:
25
- case RESUME_MODAL:
26
- return state.merge({
27
- actionText: 'resume',
28
- actionState: 'running',
29
- actionType: payload.modalID,
30
- });
31
- default:
32
- return state.set('actionType', payload.modalID);
33
- }
34
- default:
35
- return state;
36
- }
37
- };
38
- export default ConfirmModalReducer;
@@ -1,36 +0,0 @@
1
- import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
- import { ConfirmModal } from '../ConfirmModal';
3
- import { RESUME_SELECTED_MODAL } from '../../../TasksTableConstants';
4
- import { FORCE_UNLOCK_MODAL } from '../../../../TaskActions/TaskActionsConstants';
5
-
6
- const fixtures = {
7
- 'renders ConfirmModal': {
8
- actionType: RESUME_SELECTED_MODAL,
9
- actionText: 'some text',
10
- actionState: 'some state',
11
- selectedRowsLen: 1,
12
- id: 'modalID',
13
- parentTaskID: 'parent-id',
14
- allRowsSelected: true,
15
- url: 'some-url',
16
- uriQuery: { state: 'stopped' },
17
- setModalClosed: jest.fn(),
18
- },
19
-
20
- 'renders ConfirmModal for unlock ': {
21
- actionType: FORCE_UNLOCK_MODAL,
22
- actionText: 'some text',
23
- actionState: 'some state',
24
- selectedRowsLen: 1,
25
- id: 'modalID',
26
- parentTaskID: 'parent-id',
27
- allRowsSelected: true,
28
- url: 'some-url',
29
- uriQuery: { state: 'stopped' },
30
- setModalClosed: jest.fn(),
31
- },
32
- };
33
-
34
- describe('ConfirmModal', () => {
35
- testComponentSnapshotsWithFixtures(ConfirmModal, fixtures);
36
- });