foreman-tasks 0.17.1 → 0.17.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/lib/foreman_tasks/version.rb +1 -1
  3. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +3 -1
  4. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +2 -2
  5. data/webpack/ForemanTasks/Components/TaskDetails/index.js +1 -4
  6. data/webpack/ForemanTasks/Components/TasksDashboard/index.js +1 -4
  7. data/webpack/ForemanTasks/Components/TasksTable/Components/ActionConfirmation.js +49 -0
  8. data/webpack/ForemanTasks/Components/TasksTable/Components/ActionSelectButton.js +37 -0
  9. data/webpack/ForemanTasks/Components/TasksTable/Components/CancelResumeConfirm.js +51 -0
  10. data/webpack/ForemanTasks/Components/TasksTable/Components/TableSelectionCell.js +32 -0
  11. data/webpack/ForemanTasks/Components/TasksTable/Components/TableSelectionHeaderCell.js +38 -0
  12. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionConfirmation.test.js +18 -0
  13. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionSelectButton.test.js +13 -0
  14. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/CancelResumeConfirm.test.js +28 -0
  15. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/TableSelectionCell.test.js +15 -0
  16. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/TableSelectionHeaderCell.test.js +15 -0
  17. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ActionConfirmation.test.js.snap +89 -0
  18. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ActionSelectButton.test.js.snap +32 -0
  19. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/CancelResumeConfirm.test.js.snap +37 -0
  20. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/TableSelectionCell.test.js.snap +14 -0
  21. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/TableSelectionHeaderCell.test.js.snap +15 -0
  22. data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +29 -1
  23. data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +78 -3
  24. data/webpack/ForemanTasks/Components/TasksTable/TasksTableConstants.js +11 -0
  25. data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +47 -1
  26. data/webpack/ForemanTasks/Components/TasksTable/TasksTableReducer.js +30 -11
  27. data/webpack/ForemanTasks/Components/TasksTable/TasksTableSchema.js +23 -5
  28. data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +8 -0
  29. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +9 -1
  30. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableActions.test.js +46 -1
  31. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js +29 -1
  32. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +9 -5
  33. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +9 -5
  34. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableActions.test.js.snap +77 -17
  35. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +46 -10
  36. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableReducer.test.js.snap +62 -7
  37. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/actionCellFormatter.test.js.snap +14 -0
  38. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/actionNameCellFormatter.test.js.snap +9 -0
  39. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/dateCellFormmatter.test.js.snap +9 -0
  40. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/durationCellFormmatter.test.js.snap +18 -0
  41. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/selectionCellFormatter.test.js.snap +10 -0
  42. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/selectionHeaderCellFormatter.test.js.snap +10 -0
  43. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/actionCellFormatter.test.js +11 -0
  44. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/actionNameCellFormatter.test.js +8 -0
  45. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/dateCellFormmatter.test.js +7 -0
  46. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/durationCellFormmatter.test.js +12 -0
  47. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/selectionCellFormatter.test.js +12 -0
  48. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/selectionHeaderCellFormatter.test.js +12 -0
  49. data/webpack/ForemanTasks/Components/TasksTable/formatters/actionCellFormatter.js +16 -0
  50. data/webpack/ForemanTasks/Components/TasksTable/formatters/actionNameCellFormatter.js +5 -0
  51. data/webpack/ForemanTasks/Components/TasksTable/formatters/dateCellFormmatter.js +7 -0
  52. data/webpack/ForemanTasks/Components/TasksTable/formatters/durationCellFormmatter.js +7 -0
  53. data/webpack/ForemanTasks/Components/TasksTable/formatters/index.js +7 -0
  54. data/webpack/ForemanTasks/Components/TasksTable/formatters/selectionCellFormatter.js +10 -0
  55. data/webpack/ForemanTasks/Components/TasksTable/formatters/selectionHeaderCellFormatter.js +10 -0
  56. data/webpack/ForemanTasks/Components/TasksTable/index.js +5 -4
  57. data/webpack/__mocks__/foremanReact/components/common/table.js +1 -0
  58. metadata +36 -3
  59. data/webpack/ForemanTasks/Components/TasksTable/TaskTableFormmatters.js +0 -53
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfc833d42aeafa9f146457f33ffe29db5f4ddc374a372511a384f05d6932754e
4
- data.tar.gz: eda50a6c4a0e2c1257fd72c5764c5eed7df097beb230579304ccf1943a472477
3
+ metadata.gz: 619dcecc5e332cffdf42333007062050274669c3f4e9c312e99ef7ea5c34bf4c
4
+ data.tar.gz: 9af4ff95aff9ceaefc7b0cf18cfa63aea31636771b76ad32b87b20e847ef0edf
5
5
  SHA512:
6
- metadata.gz: cbbb4c98796edf5e91c2f7b3fd731a40162c6865b94e5c262f61865a5f4b18f939e38a76920756b9f6919501a72ba47b02653ba27fec54ad035e461d33df60bd
7
- data.tar.gz: 868cbea935b39e9dd74ff7a616983e1e68d89355716134f493fd29485280c0cc2e4f01ea015358c1285ac82f3ece89c9234c5cac5a73add22edb6213cfbacd43
6
+ metadata.gz: f9e7f4627493ff41d015766564442406357820b4f29a678eb47d26d41f540926c9ddd0050e569ca6e08a555c18b995a9e4c0daf8d32167619c1ce408689bc38e
7
+ data.tar.gz: 9a758f517b217ae729c3442aeb0d8808bad99b29cbe329e2ab833473a99152d24734109780cb195f8ed92f3db5bee3ec3ceac607f8e62ee7274d28a051371280
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = '0.17.1'.freeze
2
+ VERSION = '0.17.2'.freeze
3
3
  end
@@ -29,7 +29,9 @@ export const selectErrors = state => {
29
29
  };
30
30
 
31
31
  export const selectProgress = state =>
32
- selectTaskDetails(state).progress * 100 || 0;
32
+ selectTaskDetails(state).progress
33
+ ? selectTaskDetails(state).progress.toFixed(4) * 100
34
+ : 0;
33
35
 
34
36
  export const selectUsername = state =>
35
37
  selectTaskDetails(state).username || null;
@@ -4,7 +4,7 @@ exports[`TaskDetails rendering render without Props 1`] = `
4
4
  <div
5
5
  className="task-details-react well"
6
6
  >
7
- <Uncontrolled(Tabs)
7
+ <ForwardRef
8
8
  animation={false}
9
9
  defaultActiveKey={1}
10
10
  id="task-details-tabs"
@@ -94,6 +94,6 @@ exports[`TaskDetails rendering render without Props 1`] = `
94
94
  startedAt=""
95
95
  />
96
96
  </Tab>
97
- </Uncontrolled(Tabs)>
97
+ </ForwardRef>
98
98
  </div>
99
99
  `;
@@ -71,7 +71,4 @@ const mapDispatchToProps = dispatch => bindActionCreators(actions, dispatch);
71
71
 
72
72
  export const reducers = { taskDetails: reducer };
73
73
 
74
- export default connect(
75
- mapStateToProps,
76
- mapDispatchToProps
77
- )(TaskDetails);
74
+ export default connect(mapStateToProps, mapDispatchToProps)(TaskDetails);
@@ -19,7 +19,4 @@ const mapDispatchToProps = dispatch => bindActionCreators(actions, dispatch);
19
19
 
20
20
  export const reducers = { tasksDashboard: reducer };
21
21
 
22
- export default connect(
23
- mapStateToProps,
24
- mapDispatchToProps
25
- )(TasksDashboard);
22
+ export default connect(mapStateToProps, mapDispatchToProps)(TasksDashboard);
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Modal, Button } from 'patternfly-react';
4
+
5
+ export const ActionConfirmation = ({
6
+ showModal,
7
+ closeModal,
8
+ title,
9
+ message,
10
+ onClick,
11
+ confirmAction,
12
+ abortAction,
13
+ }) => (
14
+ <Modal show={showModal} onHide={closeModal}>
15
+ <Modal.Header>
16
+ <Button
17
+ className="close"
18
+ onClick={closeModal}
19
+ aria-hidden="true"
20
+ aria-label="Close"
21
+ >
22
+ &times;
23
+ </Button>
24
+ <Modal.Title>
25
+ <span className="glyphicon glyphicon-warning-sign" />
26
+ {` ${title}`}
27
+ </Modal.Title>
28
+ </Modal.Header>
29
+ <Modal.Body>{message}</Modal.Body>
30
+ <Modal.Footer>
31
+ <Button onClick={closeModal}>{abortAction}</Button>
32
+ <Button bsStyle="primary" onClick={onClick}>
33
+ {confirmAction}
34
+ </Button>
35
+ </Modal.Footer>
36
+ </Modal>
37
+ );
38
+
39
+ ActionConfirmation.propTypes = {
40
+ showModal: PropTypes.bool.isRequired,
41
+ title: PropTypes.string.isRequired,
42
+ message: PropTypes.string.isRequired,
43
+ confirmAction: PropTypes.string.isRequired,
44
+ abortAction: PropTypes.string.isRequired,
45
+ closeModal: PropTypes.func.isRequired,
46
+ onClick: PropTypes.func.isRequired,
47
+ };
48
+
49
+ export default ActionConfirmation;
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { DropdownButton, MenuItem } from 'patternfly-react';
3
+ import PropTypes from 'prop-types';
4
+ import { translate as __ } from 'foremanReact/common/I18n';
5
+
6
+ export const ActionSelectButton = ({ onCancel, onResume, disabled }) => (
7
+ <DropdownButton
8
+ title={__('Select Action')}
9
+ disabled={disabled}
10
+ id="selcted-action-type"
11
+ >
12
+ <MenuItem
13
+ title={__('Cancel selected tasks')}
14
+ onClick={onCancel}
15
+ eventKey="1"
16
+ >
17
+ {__('Cancel Selected')}
18
+ </MenuItem>
19
+ <MenuItem
20
+ title={__('Resume selected tasks')}
21
+ onClick={onResume}
22
+ eventKey="2"
23
+ >
24
+ {__('Resume Selected')}
25
+ </MenuItem>
26
+ </DropdownButton>
27
+ );
28
+
29
+ ActionSelectButton.propTypes = {
30
+ disabled: PropTypes.bool,
31
+ onCancel: PropTypes.func.isRequired,
32
+ onResume: PropTypes.func.isRequired,
33
+ };
34
+
35
+ ActionSelectButton.defaultProps = {
36
+ disabled: false,
37
+ };
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { sprintf, translate as __ } from 'foremanReact/common/I18n';
4
+ import { ActionConfirmation } from './ActionConfirmation';
5
+ import { CANCEL, RESUME, CLOSED } from '../TasksTableConstants';
6
+
7
+ export const CancelResumeConfirm = ({
8
+ closeModal,
9
+ modalStatus,
10
+ action,
11
+ selected,
12
+ selectedRowsLen,
13
+ }) => (
14
+ <ActionConfirmation
15
+ showModal={modalStatus !== CLOSED}
16
+ closeModal={closeModal}
17
+ title={`${modalStatus === CANCEL ? __('Cancel') : __('Resume')} ${__(
18
+ 'Selected Tasks'
19
+ )}`}
20
+ message={sprintf(
21
+ __(
22
+ `This will ${
23
+ modalStatus === CANCEL ? 'stop' : 'resume'
24
+ } %s tasks, putting them in the ${
25
+ modalStatus === CANCEL ? 'canceled' : 'running'
26
+ } state. Are you sure?`
27
+ ),
28
+ selectedRowsLen
29
+ )}
30
+ onClick={() => {
31
+ if (modalStatus === CANCEL) {
32
+ action(CANCEL, selected);
33
+ } else if (modalStatus === RESUME) {
34
+ action(RESUME, selected);
35
+ }
36
+ closeModal();
37
+ }}
38
+ confirmAction={__('Yes')}
39
+ abortAction={__('No')}
40
+ />
41
+ );
42
+
43
+ CancelResumeConfirm.propTypes = {
44
+ closeModal: PropTypes.func.isRequired,
45
+ modalStatus: PropTypes.oneOf([CANCEL, RESUME, CLOSED]).isRequired,
46
+ selectedRowsLen: PropTypes.number.isRequired,
47
+ action: PropTypes.func.isRequired,
48
+ selected: PropTypes.array.isRequired,
49
+ };
50
+
51
+ export default CancelResumeConfirm;
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Table } from 'patternfly-react';
4
+ import { translate as __ } from 'foremanReact/common/I18n';
5
+ import { noop } from 'foremanReact/common/helpers';
6
+
7
+ const TableSelectionCell = ({ id, label, checked, onChange, ...props }) => (
8
+ <Table.SelectionCell>
9
+ <Table.Checkbox
10
+ id={id}
11
+ label={label}
12
+ checked={checked}
13
+ onChange={onChange}
14
+ {...props}
15
+ />
16
+ </Table.SelectionCell>
17
+ );
18
+
19
+ TableSelectionCell.propTypes = {
20
+ id: PropTypes.string.isRequired,
21
+ label: PropTypes.string,
22
+ checked: PropTypes.bool,
23
+ onChange: PropTypes.func,
24
+ };
25
+
26
+ TableSelectionCell.defaultProps = {
27
+ label: __('Select row'),
28
+ checked: false,
29
+ onChange: noop,
30
+ };
31
+
32
+ export default TableSelectionCell;
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Table } from 'patternfly-react';
4
+ import { noop } from 'foremanReact/common/helpers';
5
+
6
+ const TableSelectionHeaderCell = ({
7
+ id,
8
+ label,
9
+ checked,
10
+ onChange,
11
+ ...props
12
+ }) => (
13
+ <Table.SelectionHeading aria-label={label}>
14
+ <Table.Checkbox
15
+ id={id}
16
+ label={label}
17
+ checked={checked}
18
+ onChange={onChange}
19
+ {...props}
20
+ />
21
+ </Table.SelectionHeading>
22
+ );
23
+
24
+ TableSelectionHeaderCell.propTypes = {
25
+ id: PropTypes.string,
26
+ label: PropTypes.string,
27
+ checked: PropTypes.bool,
28
+ onChange: PropTypes.func,
29
+ };
30
+
31
+ TableSelectionHeaderCell.defaultProps = {
32
+ id: 'selectAll',
33
+ label: '',
34
+ checked: false,
35
+ onChange: noop,
36
+ };
37
+
38
+ export default TableSelectionHeaderCell;
@@ -0,0 +1,18 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import { ActionConfirmation } from '../ActionConfirmation';
4
+
5
+ const fixtures = {
6
+ 'renders ActionConfirmation': {
7
+ showModal: true,
8
+ title: 'title',
9
+ message: 'message',
10
+ confirmAction: 'confirmAction',
11
+ abortAction: 'abortAction',
12
+ closeModal: () => null,
13
+ onClick: () => null,
14
+ },
15
+ };
16
+
17
+ describe('ActionConfirmation', () =>
18
+ testComponentSnapshotsWithFixtures(ActionConfirmation, fixtures));
@@ -0,0 +1,13 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import { ActionSelectButton } from '../ActionSelectButton';
4
+
5
+ const fixtures = {
6
+ 'renders with minimal props': {
7
+ onCancel: jest.fn(),
8
+ onResume: jest.fn(),
9
+ },
10
+ };
11
+
12
+ describe('ActionSelectButton', () =>
13
+ testComponentSnapshotsWithFixtures(ActionSelectButton, fixtures));
@@ -0,0 +1,28 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import { CancelResumeConfirm } from '../CancelResumeConfirm';
4
+ import { CANCEL, RESUME, CLOSED } from '../../TasksTableConstants';
5
+
6
+ const baseProps = {
7
+ closeModal: () => null,
8
+ selectedRowsLen: 3,
9
+ action: () => null,
10
+ selected: [1, 2, 3],
11
+ };
12
+ const fixtures = {
13
+ 'renders CANCEL modal': {
14
+ ...baseProps,
15
+ modalStatus: CANCEL,
16
+ },
17
+ 'renders RESUME modal': {
18
+ ...baseProps,
19
+ modalStatus: RESUME,
20
+ },
21
+ 'renders CLOSED modal': {
22
+ ...baseProps,
23
+ modalStatus: CLOSED,
24
+ },
25
+ };
26
+
27
+ describe('CancelResumeConfirm', () =>
28
+ testComponentSnapshotsWithFixtures(CancelResumeConfirm, fixtures));
@@ -0,0 +1,15 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import TableSelectionCell from '../TableSelectionCell';
4
+
5
+ const fixtures = {
6
+ 'renders TableSelectionCell': {
7
+ id: 'some id',
8
+ label: 'some label',
9
+ checked: true,
10
+ onChange: jest.fn(),
11
+ },
12
+ };
13
+
14
+ describe('TableSelectionCell', () =>
15
+ testComponentSnapshotsWithFixtures(TableSelectionCell, fixtures));
@@ -0,0 +1,15 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import TableSelectionHeaderCell from '../TableSelectionHeaderCell';
4
+
5
+ const fixtures = {
6
+ 'renders TableSelectionHeaderCell': {
7
+ id: 'some id',
8
+ label: 'some label',
9
+ checked: true,
10
+ onChange: jest.fn(),
11
+ },
12
+ };
13
+
14
+ describe('TableSelectionHeaderCell', () =>
15
+ testComponentSnapshotsWithFixtures(TableSelectionHeaderCell, fixtures));
@@ -0,0 +1,89 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ActionConfirmation renders ActionConfirmation 1`] = `
4
+ <Modal
5
+ animation={true}
6
+ autoFocus={true}
7
+ backdrop={true}
8
+ bsClass="modal"
9
+ dialogComponentClass={[Function]}
10
+ enforceFocus={true}
11
+ keyboard={true}
12
+ manager={
13
+ ModalManager {
14
+ "add": [Function],
15
+ "containers": Array [],
16
+ "data": Array [],
17
+ "handleContainerOverflow": true,
18
+ "hideSiblingNodes": true,
19
+ "isTopModal": [Function],
20
+ "modals": Array [],
21
+ "remove": [Function],
22
+ }
23
+ }
24
+ onHide={[Function]}
25
+ renderBackdrop={[Function]}
26
+ restoreFocus={true}
27
+ show={true}
28
+ >
29
+ <ModalHeader
30
+ bsClass="modal-header"
31
+ closeButton={false}
32
+ closeLabel="Close"
33
+ >
34
+ <Button
35
+ active={false}
36
+ aria-hidden="true"
37
+ aria-label="Close"
38
+ block={false}
39
+ bsClass="btn"
40
+ bsStyle="default"
41
+ className="close"
42
+ disabled={false}
43
+ onClick={[Function]}
44
+ >
45
+ ×
46
+ </Button>
47
+ <ModalTitle
48
+ bsClass="modal-title"
49
+ componentClass="h4"
50
+ >
51
+ <span
52
+ className="glyphicon glyphicon-warning-sign"
53
+ />
54
+ title
55
+ </ModalTitle>
56
+ </ModalHeader>
57
+ <ModalBody
58
+ bsClass="modal-body"
59
+ componentClass="div"
60
+ >
61
+ message
62
+ </ModalBody>
63
+ <ModalFooter
64
+ bsClass="modal-footer"
65
+ componentClass="div"
66
+ >
67
+ <Button
68
+ active={false}
69
+ block={false}
70
+ bsClass="btn"
71
+ bsStyle="default"
72
+ disabled={false}
73
+ onClick={[Function]}
74
+ >
75
+ abortAction
76
+ </Button>
77
+ <Button
78
+ active={false}
79
+ block={false}
80
+ bsClass="btn"
81
+ bsStyle="primary"
82
+ disabled={false}
83
+ onClick={[Function]}
84
+ >
85
+ confirmAction
86
+ </Button>
87
+ </ModalFooter>
88
+ </Modal>
89
+ `;