foreman-tasks 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc +2 -22
  3. data/app/controllers/foreman_tasks/api/tasks_controller.rb +1 -1
  4. data/{.babelrc.js → babel.config.js} +0 -0
  5. data/lib/foreman_tasks/engine.rb +1 -1
  6. data/lib/foreman_tasks/version.rb +1 -1
  7. data/package.json +17 -69
  8. data/test/controllers/api/tasks_controller_test.rb +9 -0
  9. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Errors.test.js +1 -1
  10. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Locks.test.js +1 -1
  11. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Raw.test.js +1 -1
  12. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/RunningSteps.test.js +1 -1
  13. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +1 -1
  14. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskInfo.test.js +1 -1
  15. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.stories.js +6 -2
  16. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +1 -1
  17. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js +1 -1
  18. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsReducer.test.js +1 -1
  19. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/integration.test.js +1 -1
  20. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.stories.js +44 -40
  21. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.test.js +1 -1
  22. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.stories.js +45 -40
  23. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.test.js +1 -1
  24. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.stories.js +27 -22
  25. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.test.js +1 -1
  26. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.stories.js +61 -56
  27. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.test.js +1 -1
  28. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.stories.js +40 -35
  29. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.test.js +1 -1
  30. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.stories.js +21 -20
  31. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.test.js +1 -1
  32. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.stories.js +40 -39
  33. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.test.js +1 -1
  34. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.stories.js +16 -17
  35. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js +1 -2
  36. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.stories.mdx +57 -0
  37. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.test.js +1 -1
  38. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.stories.js +36 -18
  39. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.test.js +1 -1
  40. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboard.test.js +1 -1
  41. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardActions.test.js +1 -1
  42. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardReducer.test.js +1 -1
  43. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardSelectors.test.js +1 -1
  44. data/webpack/ForemanTasks/Components/TasksTable/Components/CancelConfirm.js +53 -0
  45. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmationModals.js +56 -0
  46. data/webpack/ForemanTasks/Components/TasksTable/Components/ResumeConfirm.js +52 -0
  47. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionSelectButton.test.js +1 -1
  48. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/CancelConfirm.test.js +26 -0
  49. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ConfirmationModals.test.js +24 -0
  50. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ResumeConfirm.test.js +26 -0
  51. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/TableSelectionCell.test.js +1 -1
  52. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/TableSelectionHeaderCell.test.js +1 -1
  53. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/CancelConfirm.test.js.snap +65 -0
  54. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ConfirmationModals.test.js.snap +30 -0
  55. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ResumeConfirm.test.js.snap +63 -0
  56. data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +22 -12
  57. data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +15 -18
  58. data/webpack/ForemanTasks/Components/TasksTable/TasksTableConstants.js +6 -2
  59. data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +54 -18
  60. data/webpack/ForemanTasks/Components/TasksTable/TasksTableReducer.js +5 -7
  61. data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +18 -16
  62. data/webpack/ForemanTasks/Components/TasksTable/__tests__/SubTasksPage.test.js +1 -1
  63. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksIndexPage.test.js +1 -1
  64. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +7 -3
  65. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.test.js +1 -1
  66. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableActions.test.js +1 -1
  67. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTablePage.test.js +1 -1
  68. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js +6 -7
  69. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +9 -3
  70. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +9 -3
  71. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +116 -18
  72. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableReducer.test.js.snap +9 -16
  73. data/webpack/ForemanTasks/Components/TasksTable/index.js +3 -2
  74. data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js +4 -4
  75. data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js +1 -1
  76. data/webpack/ForemanTasks/Components/common/ActionButtons/CancelButton.test.js +1 -2
  77. data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.test.js +2 -2
  78. data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap +3 -3
  79. data/webpack/ForemanTasks/ForemanTasks.test.js +1 -1
  80. data/webpack/ForemanTasks/Routes/ForemanTasksRouter.test.js +1 -1
  81. data/webpack/ForemanTasks/Routes/ForemanTasksRoutes.test.js +2 -3
  82. data/webpack/ForemanTasks/Routes/ShowTask/__tests__/ShowTask.test.js +1 -1
  83. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +2 -0
  84. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalHooks.js +10 -0
  85. data/webpack/__mocks__/foremanReact/components/ForemanModal/index.js +4 -0
  86. metadata +16 -16
  87. data/.storybook/addons.js +0 -2
  88. data/.storybook/config.js +0 -7
  89. data/.storybook/webpack.config.js +0 -84
  90. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.stories.js +0 -23
  91. data/webpack/ForemanTasks/Components/TasksTable/Components/ActionConfirmation.js +0 -49
  92. data/webpack/ForemanTasks/Components/TasksTable/Components/CancelResumeConfirm.js +0 -51
  93. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionConfirmation.test.js +0 -18
  94. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/CancelResumeConfirm.test.js +0 -28
  95. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ActionConfirmation.test.js.snap +0 -89
  96. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/CancelResumeConfirm.test.js.snap +0 -37
  97. data/webpack/stories/index.js +0 -10
  98. data/webpack/stories/index.scss +0 -7
  99. data/webpack/test_setup.js +0 -7
@@ -1,22 +1,21 @@
1
1
  import React from 'react';
2
- import { storiesOf } from '@storybook/react';
3
- import { withKnobs, object } from '@storybook/addon-knobs';
4
- import { action } from '@storybook/addon-actions';
5
- import { Grid } from 'patternfly-react';
2
+ import { object, action } from '@theforeman/stories';
6
3
 
7
4
  import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../TasksDashboardConstants';
8
5
  import TasksLabelsRow from './TasksLabelsRow';
9
6
 
10
- storiesOf('TasksDashboard/TasksLabelsRow', module)
11
- .addDecorator(withKnobs)
12
- .addDecorator(storyFn => <Grid style={{ padding: 40 }}>{storyFn()}</Grid>)
13
- .add('TasksLabelsRow', () => (
14
- <TasksLabelsRow
15
- query={object('query', {
16
- state: 'running',
17
- mode: 'last',
18
- time: TASKS_DASHBOARD_AVAILABLE_TIMES.H24,
19
- })}
20
- deleteQueryKey={action('deleteQueryKey')}
21
- />
22
- ));
7
+ export default {
8
+ title: 'TasksDashboard/TasksLabelsRow',
9
+ component: TasksLabelsRow,
10
+ };
11
+
12
+ export const Basic = () => (
13
+ <TasksLabelsRow
14
+ query={object('query', {
15
+ state: 'running',
16
+ mode: 'last',
17
+ time: TASKS_DASHBOARD_AVAILABLE_TIMES.H24,
18
+ })}
19
+ updateQuery={action('updateQuery')}
20
+ />
21
+ );
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
3
- import { shallow } from 'enzyme';
2
+ import { testComponentSnapshotsWithFixtures, shallow } from '@theforeman/test';
4
3
 
5
4
  import { getQueryKeyText, getQueryValueText } from '../../TasksDashboardHelper';
6
5
  import TasksLabelsRow from './TasksLabelsRow';
@@ -0,0 +1,57 @@
1
+ import { Meta, Story, Preview, Props, action } from '@theforeman/stories';
2
+
3
+ import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../../../TasksDashboardConstants';
4
+ import TimeDropDown from './TimeDropDown';
5
+
6
+ <Meta
7
+ title="TasksDashboard/TasksTimeRow/TimeDropDown"
8
+ component={TimeDropDown}
9
+ />
10
+
11
+ # TimeDropDown
12
+
13
+ Render a dropdown with the available dashboard times to render.
14
+
15
+ <Props of={TimeDropDown} />
16
+
17
+ The available-times defined as a constant at `Components/TasksDashboard/TasksDashboardConstants.js`:
18
+
19
+ ```js
20
+ import { TASKS_DASHBOARD_AVAILABLE_TIMES } from './Components/TasksDashboard/TasksDashboardConstants';
21
+ ```
22
+
23
+ To set the current selected time, set the `selectedTime` prop to `TASKS_DASHBOARD_AVAILABLE_TIMES.H24`.
24
+
25
+ <Preview>
26
+ <Story name="24 hours">
27
+ <TimeDropDown
28
+ id="time-period-dropdown"
29
+ selectedTime={TASKS_DASHBOARD_AVAILABLE_TIMES.H24}
30
+ onChange={action('onChange')}
31
+ />
32
+ </Story>
33
+ </Preview>
34
+
35
+ To set the current selected time, set the `selectedTime` prop to `TASKS_DASHBOARD_AVAILABLE_TIMES.H12`.
36
+
37
+ <Preview>
38
+ <Story name="12 hours">
39
+ <TimeDropDown
40
+ id="time-period-dropdown"
41
+ selectedTime={TASKS_DASHBOARD_AVAILABLE_TIMES.H12}
42
+ onChange={action('onChange')}
43
+ />
44
+ </Story>
45
+ </Preview>
46
+
47
+ To set the current selected time, set the `selectedTime` prop to `TASKS_DASHBOARD_AVAILABLE_TIMES.WEEK`.
48
+
49
+ <Preview>
50
+ <Story name="week">
51
+ <TimeDropDown
52
+ id="time-period-dropdown"
53
+ selectedTime={TASKS_DASHBOARD_AVAILABLE_TIMES.WEEK}
54
+ onChange={action('onChange')}
55
+ />
56
+ </Story>
57
+ </Preview>
@@ -1,4 +1,4 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../../../TasksDashboardConstants';
4
4
  import TimeDropDown from './TimeDropDown';
@@ -1,22 +1,40 @@
1
- import React from 'react';
2
- import { storiesOf } from '@storybook/react';
3
- import { withKnobs, select } from '@storybook/addon-knobs';
4
- import { action } from '@storybook/addon-actions';
5
- import { withCardsDecorator } from '../../../../../stories/decorators';
1
+ /* eslint-disable react-hooks/rules-of-hooks */
2
+ import React, { useState } from 'react';
3
+ import { select, action } from '@theforeman/stories';
6
4
 
7
5
  import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../TasksDashboardConstants';
8
6
  import TasksTimeRow from './TasksTimeRow';
9
7
 
10
- storiesOf('TasksDashboard/TasksTimeRow', module)
11
- .addDecorator(withKnobs)
12
- .addDecorator(withCardsDecorator)
13
- .add('TasksTimeRow', () => (
14
- <TasksTimeRow
15
- time={select(
16
- 'time',
17
- TASKS_DASHBOARD_AVAILABLE_TIMES,
18
- TASKS_DASHBOARD_AVAILABLE_TIMES.H24
19
- )}
20
- updateTime={action('updateTime')}
21
- />
22
- ));
8
+ export default {
9
+ title: 'TasksDashboard/TasksTimeRow',
10
+ component: TasksTimeRow,
11
+ };
12
+
13
+ export const withState = () => {
14
+ const [time, updateTime] = useState(TASKS_DASHBOARD_AVAILABLE_TIMES.H24);
15
+
16
+ return <TasksTimeRow time={time} updateTime={updateTime} />;
17
+ };
18
+
19
+ export const withKnobs = () => (
20
+ <TasksTimeRow
21
+ time={select(
22
+ 'time',
23
+ TASKS_DASHBOARD_AVAILABLE_TIMES,
24
+ TASKS_DASHBOARD_AVAILABLE_TIMES.H24
25
+ )}
26
+ updateTime={action('updateTime')}
27
+ />
28
+ );
29
+
30
+ export const with24Hours = () => (
31
+ <TasksTimeRow time={TASKS_DASHBOARD_AVAILABLE_TIMES.H24} />
32
+ );
33
+
34
+ export const with12Hours = () => (
35
+ <TasksTimeRow time={TASKS_DASHBOARD_AVAILABLE_TIMES.H12} />
36
+ );
37
+
38
+ export const withWeek = () => (
39
+ <TasksTimeRow time={TASKS_DASHBOARD_AVAILABLE_TIMES.WEEK} />
40
+ );
@@ -1,4 +1,4 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../TasksDashboardConstants';
4
4
  import TasksTimeRow from './TasksTimeRow';
@@ -1,4 +1,4 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import TasksDashboard from '../TasksDashboard';
4
4
 
@@ -1,4 +1,4 @@
1
- import { testActionSnapshotWithFixtures } from 'react-redux-test-utils';
1
+ import { testActionSnapshotWithFixtures } from '@theforeman/test';
2
2
  import API from 'foremanReact/API';
3
3
  import { timeToHoursNumber } from '../TasksDashboardHelper';
4
4
  import {
@@ -1,4 +1,4 @@
1
- import { testReducerSnapshotWithFixtures } from 'react-redux-test-utils';
1
+ import { testReducerSnapshotWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import {
4
4
  FOREMAN_TASKS_DASHBOARD_INIT,
@@ -1,4 +1,4 @@
1
- import { testSelectorsSnapshotWithFixtures } from 'react-redux-test-utils';
1
+ import { testSelectorsSnapshotWithFixtures } from '@theforeman/test';
2
2
  import {
3
3
  selectTasksDashboard,
4
4
  selectTime,
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { sprintf, translate as __ } from 'foremanReact/common/I18n';
4
+ import { Button } from 'patternfly-react';
5
+ import ForemanModal from 'foremanReact/components/ForemanModal';
6
+ import {
7
+ CANCEL_CONFIRM_MODAL_ID,
8
+ RESUME_CONFIRM_MODAL_ID,
9
+ CANCEL_SELECTED_CONFIRM_MODAL_ID,
10
+ RESUME_SELECTED_CONFIRM_MODAL_ID,
11
+ } from '../TasksTableConstants';
12
+
13
+ export const CancelConfirm = ({ closeModal, action, selectedRowsLen, id }) => (
14
+ <ForemanModal title={__('Cancel Selected Tasks')} id={id}>
15
+ <ForemanModal.Header />
16
+ {sprintf(
17
+ __(
18
+ `This will cancel %s task(s), putting them in the stopped state. Are you sure?`
19
+ ),
20
+ selectedRowsLen
21
+ )}
22
+ <ForemanModal.Footer>
23
+ <Button onClick={closeModal}>{__('No')}</Button>
24
+ <Button
25
+ bsStyle="primary"
26
+ onClick={() => {
27
+ action();
28
+ closeModal();
29
+ }}
30
+ >
31
+ {__('Yes')}
32
+ </Button>
33
+ </ForemanModal.Footer>
34
+ </ForemanModal>
35
+ );
36
+
37
+ CancelConfirm.propTypes = {
38
+ closeModal: PropTypes.func.isRequired,
39
+ selectedRowsLen: PropTypes.number.isRequired,
40
+ action: PropTypes.func,
41
+ id: PropTypes.oneOf([
42
+ CANCEL_CONFIRM_MODAL_ID,
43
+ RESUME_CONFIRM_MODAL_ID,
44
+ CANCEL_SELECTED_CONFIRM_MODAL_ID,
45
+ RESUME_SELECTED_CONFIRM_MODAL_ID,
46
+ ]).isRequired,
47
+ };
48
+
49
+ CancelConfirm.defaultProps = {
50
+ action: () => null,
51
+ };
52
+
53
+ export default CancelConfirm;
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import {
4
+ CANCEL_CONFIRM_MODAL_ID,
5
+ RESUME_CONFIRM_MODAL_ID,
6
+ CANCEL_SELECTED_CONFIRM_MODAL_ID,
7
+ RESUME_SELECTED_CONFIRM_MODAL_ID,
8
+ } from '../TasksTableConstants';
9
+ import { CancelConfirm } from './CancelConfirm';
10
+ import { ResumeConfirm } from './ResumeConfirm';
11
+
12
+ export const ConfirmationModals = ({
13
+ modalProps,
14
+ tasksActions,
15
+ selectedRowsLen,
16
+ }) => (
17
+ <React.Fragment>
18
+ <CancelConfirm
19
+ closeModal={modalProps.cancelModal.setModalClosed}
20
+ action={tasksActions.cancelTask}
21
+ selectedRowsLen={1}
22
+ id={CANCEL_CONFIRM_MODAL_ID}
23
+ />
24
+ <ResumeConfirm
25
+ closeModal={modalProps.resumeModal.setModalClosed}
26
+ action={tasksActions.resumeTask}
27
+ selectedRowsLen={1}
28
+ id={RESUME_CONFIRM_MODAL_ID}
29
+ />
30
+ <CancelConfirm
31
+ closeModal={modalProps.cancelSelectedModal.setModalClosed}
32
+ action={tasksActions.cancelSelectedTasks}
33
+ selectedRowsLen={selectedRowsLen}
34
+ id={CANCEL_SELECTED_CONFIRM_MODAL_ID}
35
+ />
36
+ <ResumeConfirm
37
+ closeModal={modalProps.resumeSelectedModal.setModalClosed}
38
+ action={tasksActions.resumeSelectedTasks}
39
+ selectedRowsLen={selectedRowsLen}
40
+ id={RESUME_SELECTED_CONFIRM_MODAL_ID}
41
+ />
42
+ </React.Fragment>
43
+ );
44
+
45
+ ConfirmationModals.propTypes = {
46
+ modalProps: PropTypes.object.isRequired,
47
+ selectedRowsLen: PropTypes.number.isRequired,
48
+ tasksActions: PropTypes.shape({
49
+ cancelTask: PropTypes.func,
50
+ resumeTask: PropTypes.func,
51
+ cancelSelectedTasks: PropTypes.func,
52
+ resumeSelectedTasks: PropTypes.func,
53
+ }).isRequired,
54
+ };
55
+
56
+ export default ConfirmationModals;
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { sprintf, translate as __ } from 'foremanReact/common/I18n';
4
+ import { Button } from 'patternfly-react';
5
+ import ForemanModal from 'foremanReact/components/ForemanModal';
6
+ import {
7
+ CANCEL_CONFIRM_MODAL_ID,
8
+ RESUME_CONFIRM_MODAL_ID,
9
+ CANCEL_SELECTED_CONFIRM_MODAL_ID,
10
+ RESUME_SELECTED_CONFIRM_MODAL_ID,
11
+ } from '../TasksTableConstants';
12
+
13
+ export const ResumeConfirm = ({ closeModal, action, selectedRowsLen, id }) => (
14
+ <ForemanModal title={__('Resume Selected Tasks')} id={id}>
15
+ {sprintf(
16
+ __(
17
+ `This will resume %s task(s), putting them in the running state. Are you sure?`
18
+ ),
19
+ selectedRowsLen
20
+ )}
21
+ <ForemanModal.Footer>
22
+ <Button onClick={closeModal}>{__('No')}</Button>
23
+ <Button
24
+ bsStyle="primary"
25
+ onClick={() => {
26
+ action();
27
+ closeModal();
28
+ }}
29
+ >
30
+ {__('Yes')}
31
+ </Button>
32
+ </ForemanModal.Footer>
33
+ </ForemanModal>
34
+ );
35
+
36
+ ResumeConfirm.propTypes = {
37
+ closeModal: PropTypes.func.isRequired,
38
+ selectedRowsLen: PropTypes.number.isRequired,
39
+ action: PropTypes.func,
40
+ id: PropTypes.oneOf([
41
+ CANCEL_CONFIRM_MODAL_ID,
42
+ RESUME_CONFIRM_MODAL_ID,
43
+ CANCEL_SELECTED_CONFIRM_MODAL_ID,
44
+ RESUME_SELECTED_CONFIRM_MODAL_ID,
45
+ ]).isRequired,
46
+ };
47
+
48
+ ResumeConfirm.defaultProps = {
49
+ action: () => null,
50
+ };
51
+
52
+ export default ResumeConfirm;
@@ -1,4 +1,4 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import { ActionSelectButton } from '../ActionSelectButton';
4
4
 
@@ -0,0 +1,26 @@
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+
3
+ import { CancelConfirm } from '../CancelConfirm';
4
+ import {
5
+ CANCEL_CONFIRM_MODAL_ID,
6
+ CANCEL_SELECTED_CONFIRM_MODAL_ID,
7
+ } from '../../TasksTableConstants';
8
+
9
+ const baseProps = {
10
+ closeModal: () => null,
11
+ selectedRowsLen: 1,
12
+ action: () => null,
13
+ };
14
+ const fixtures = {
15
+ 'renders CANCEL modal': {
16
+ ...baseProps,
17
+ id: CANCEL_CONFIRM_MODAL_ID,
18
+ },
19
+ 'renders CANCEL_SELECTED modal': {
20
+ ...baseProps,
21
+ id: CANCEL_SELECTED_CONFIRM_MODAL_ID,
22
+ },
23
+ };
24
+
25
+ describe('CancelConfirm', () =>
26
+ testComponentSnapshotsWithFixtures(CancelConfirm, fixtures));
@@ -0,0 +1,24 @@
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+
3
+ import { ConfirmationModals } from '../ConfirmationModals';
4
+
5
+ const fixtures = {
6
+ 'renders ConfirmationModals': {
7
+ modalProps: {
8
+ cancelSelectedModal: { setModalClosed: jest.fn() },
9
+ resumeSelectedModal: { setModalClosed: jest.fn() },
10
+ cancelModal: { setModalClosed: jest.fn() },
11
+ resumeModal: { setModalClosed: jest.fn() },
12
+ },
13
+ selectedRowsLen: 7,
14
+ tasksActions: {
15
+ cancelTask: jest.fn(),
16
+ resumeTask: jest.fn(),
17
+ cancelSelectedTasks: jest.fn(),
18
+ resumeSelectedTasks: jest.fn(),
19
+ },
20
+ },
21
+ };
22
+
23
+ describe('ConfirmationModals', () =>
24
+ testComponentSnapshotsWithFixtures(ConfirmationModals, fixtures));
@@ -0,0 +1,26 @@
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+
3
+ import { ResumeConfirm } from '../ResumeConfirm';
4
+ import {
5
+ RESUME_CONFIRM_MODAL_ID,
6
+ RESUME_SELECTED_CONFIRM_MODAL_ID,
7
+ } from '../../TasksTableConstants';
8
+
9
+ const baseProps = {
10
+ closeModal: () => null,
11
+ selectedRowsLen: 3,
12
+ action: () => null,
13
+ };
14
+ const fixtures = {
15
+ 'renders RESUME modal': {
16
+ ...baseProps,
17
+ id: RESUME_CONFIRM_MODAL_ID,
18
+ },
19
+ 'renders RESUME_SELECTED modal': {
20
+ ...baseProps,
21
+ id: RESUME_SELECTED_CONFIRM_MODAL_ID,
22
+ },
23
+ };
24
+
25
+ describe('ResumeConfirm', () =>
26
+ testComponentSnapshotsWithFixtures(ResumeConfirm, fixtures));