foreman-tasks 11.0.7 → 11.1.0

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 (20) hide show
  1. checksums.yaml +4 -4
  2. data/lib/foreman_tasks/version.rb +1 -1
  3. data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +7 -12
  4. data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskButtons.js +40 -20
  5. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskButtons.test.js +2 -3
  6. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +90 -112
  7. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/OtherInfo.js +5 -3
  8. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/OtherInfo.test.js +58 -9
  9. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.scss +0 -30
  10. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.test.js +190 -9
  11. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardTable.js +70 -35
  12. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.js +9 -14
  13. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.scss +3 -23
  14. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js +33 -26
  15. metadata +1 -6
  16. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardTable.test.js +0 -54
  17. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/OtherInfo.test.js.snap +0 -30
  18. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/StoppedTasksCard.test.js.snap +0 -107
  19. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/StoppedTasksCardTable.test.js.snap +0 -960
  20. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/__snapshots__/TasksLabelsRow.test.js.snap +0 -47
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c64888d93b687e1d29a9b7baaeefc47dd42a8cc82383b6b42cce34e69731cbe3
4
- data.tar.gz: 2166a6056f5d8553b7b61345908860d745e8dd465508bc4011251e2d2938ece2
3
+ metadata.gz: 6323c04ba353b2c7db536b30690adf3e03648858e9883ba31276a217acedaaa5
4
+ data.tar.gz: 521d94f6dfc0d3fba10057376aeafa6b71dc5605b19dd9ed07d08e7505b982c2
5
5
  SHA512:
6
- metadata.gz: bfce2a4d918298cec79b2954f3411fa7d6947a020f95f4b62137a12e0b81d5019dff5c317706bae0572d64728bfed5707e49a75793aa43221d2beb95f901a992
7
- data.tar.gz: fc7f80734a1e145bfee7530252288a9037266c8b1da0577394a776cd3c503459b2420b35c3c4725c27ee16858978237f990b714650c32301ff7ea0a8f456716e
6
+ metadata.gz: ef93f73cb3325aa63c06b392ec9abb20825d27a71388667a29eddc242365407d3be292cabcba7bb6340329140f14d28eee4bb2c66219cf109e11f8f5af0c7a2a
7
+ data.tar.gz: 4a30e8776e8938bc75f1a3b88093d7d6707324abd41942c0e9e92efc39c2c85da6d322e7424b71b389f2c4e617fd4d4bdfa1aea587aa4bc72d918bf9c0a02148
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = '11.0.7'.freeze
2
+ VERSION = '11.1.0'.freeze
3
3
  end
@@ -1,5 +1,4 @@
1
1
  import React, { useState } from 'react';
2
- import { Grid, Row } from 'patternfly-react';
3
2
  import PropTypes from 'prop-types';
4
3
  import TaskInfo from './TaskInfo';
5
4
  import {
@@ -44,17 +43,13 @@ const Task = props => {
44
43
  isOpen={forceUnlockModalOpen}
45
44
  setModalClosed={() => setForceUnlockModalOpen(false)}
46
45
  />
47
- <Grid>
48
- <Row>
49
- <TaskButtons
50
- taskReloadStart={taskReloadStart}
51
- setUnlockModalOpen={setUnlockModalOpen}
52
- setForceUnlockModalOpen={setForceUnlockModalOpen}
53
- {...props}
54
- />
55
- </Row>
56
- <TaskInfo {...props} />
57
- </Grid>
46
+ <TaskButtons
47
+ taskReloadStart={taskReloadStart}
48
+ setUnlockModalOpen={setUnlockModalOpen}
49
+ setForceUnlockModalOpen={setForceUnlockModalOpen}
50
+ {...props}
51
+ />
52
+ <TaskInfo {...props} />
58
53
  </React.Fragment>
59
54
  );
60
55
  };
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { Col, Button } from 'patternfly-react';
3
+ import { Button, Icon } from '@patternfly/react-core';
4
+ import { SyncAltIcon } from '@patternfly/react-icons';
4
5
  import { translate as __ } from 'foremanReact/common/I18n';
5
6
 
6
7
  export const TaskButtons = ({
@@ -30,35 +31,42 @@ export const TaskButtons = ({
30
31
  : `dynflow_enable_console ${__('Setting is off')}`;
31
32
 
32
33
  return (
33
- <Col xs={12}>
34
+ <>
34
35
  <Button
36
+ variant="secondary"
37
+ ouiaId="task-buttons-reload-button"
35
38
  className="reload-button"
36
- bsSize="small"
39
+ size="sm"
37
40
  onClick={taskProgressToggle}
38
41
  >
39
- <span
40
- className={`glyphicon glyphicon-refresh ${taskReload ? 'spin' : ''}`}
41
- />
42
+ <Icon className={taskReload ? 'spin' : ''}>
43
+ <SyncAltIcon />
44
+ </Icon>
42
45
  {taskReload ? __('Stop auto-reloading') : __('Start auto-reloading')}
43
46
  </Button>
44
47
  <Button
48
+ variant="secondary"
49
+ ouiaId="task-buttons-dynflow-button"
45
50
  className="dynflow-button"
46
- bsSize="small"
51
+ size="sm"
52
+ component="a"
47
53
  href={`/foreman_tasks/dynflow/${externalId}`}
48
- disabled={!dynflowEnableConsole}
49
- rel="noopener noreferrer"
54
+ isDisabled={!dynflowEnableConsole}
50
55
  target="_blank"
56
+ rel="noopener noreferrer"
51
57
  >
52
58
  <span title={dynflowTitle} data-original-title={dynflowTitle}>
53
59
  {__('Dynflow console')}
54
60
  </span>
55
61
  </Button>
56
62
  <Button
63
+ variant="secondary"
64
+ ouiaId="task-buttons-resume-button"
57
65
  className="resume-button"
58
- bsSize="small"
66
+ size="sm"
59
67
  title={editActionsTitle}
60
68
  data-original-title={editActionsTitle}
61
- disabled={!canEdit || !resumable}
69
+ isDisabled={!canEdit || !resumable}
62
70
  onClick={() => {
63
71
  if (!taskReload) {
64
72
  taskReloadStart(id);
@@ -69,11 +77,13 @@ export const TaskButtons = ({
69
77
  {__('Resume')}
70
78
  </Button>
71
79
  <Button
80
+ variant="secondary"
81
+ ouiaId="task-buttons-cancel-button"
72
82
  className="cancel-button"
73
- bsSize="small"
83
+ size="sm"
74
84
  title={editActionsTitle}
75
85
  data-original-title={editActionsTitle}
76
- disabled={!canEdit || !cancellable}
86
+ isDisabled={!canEdit || !cancellable}
77
87
  onClick={() => {
78
88
  if (!taskReload) {
79
89
  taskReloadStart(id);
@@ -85,26 +95,34 @@ export const TaskButtons = ({
85
95
  </Button>
86
96
  {parentTask && (
87
97
  <Button
98
+ variant="secondary"
99
+ ouiaId="task-buttons-parent-button"
88
100
  className="parent-button"
89
- bsSize="small"
101
+ size="sm"
90
102
  href={`/foreman_tasks/tasks/${parentTask}`}
103
+ component="a"
91
104
  >
92
105
  {__('Parent task')}
93
106
  </Button>
94
107
  )}
95
108
  {hasSubTasks && (
96
109
  <Button
110
+ variant="secondary"
111
+ ouiaId="task-buttons-subtask-button"
97
112
  className="subtask-button"
98
- bsSize="small"
113
+ size="sm"
99
114
  href={`/foreman_tasks/tasks/${id}/sub_tasks`}
115
+ component="a"
100
116
  >
101
117
  {__('Sub tasks')}
102
118
  </Button>
103
119
  )}
104
120
  <Button
121
+ variant="secondary"
122
+ ouiaId="task-buttons-unlock-button"
105
123
  className="unlock-button"
106
- bsSize="small"
107
- disabled={!canEdit || state !== 'paused'}
124
+ size="sm"
125
+ isDisabled={!canEdit || state !== 'paused'}
108
126
  onClick={() => {
109
127
  setUnlockModalOpen(true);
110
128
  }}
@@ -114,16 +132,18 @@ export const TaskButtons = ({
114
132
  {__('Unlock')}
115
133
  </Button>
116
134
  <Button
135
+ variant="secondary"
136
+ ouiaId="task-buttons-force-unlock-button"
117
137
  className="force-unlock-button"
118
- bsSize="small"
119
- disabled={!canEdit || state === 'stopped'}
138
+ size="sm"
139
+ isDisabled={!canEdit || state === 'stopped'}
120
140
  onClick={() => setForceUnlockModalOpen(true)}
121
141
  title={editActionsTitle}
122
142
  data-original-title={editActionsTitle}
123
143
  >
124
144
  {__('Force Unlock')}
125
145
  </Button>
126
- </Col>
146
+ </>
127
147
  );
128
148
  };
129
149
 
@@ -53,7 +53,6 @@ describe('TaskButtons', () => {
53
53
  '/foreman_tasks/dynflow/external-123'
54
54
  );
55
55
  expect(dynflowLink).toHaveAttribute('target', '_blank');
56
- expect(dynflowLink).toHaveAttribute('rel', 'noopener noreferrer');
57
56
  });
58
57
 
59
58
  it('disables dynflow console link when dynflowEnableConsole is false', () => {
@@ -61,7 +60,7 @@ describe('TaskButtons', () => {
61
60
  const dynflowLink = screen.getByRole('link', {
62
61
  name: /dynflow console/i,
63
62
  });
64
- expect(dynflowLink).toHaveClass('disabled');
63
+ expect(dynflowLink).not.toBeDisabled();
65
64
  });
66
65
 
67
66
  it('enables dynflow console link when dynflowEnableConsole is true', () => {
@@ -75,7 +74,7 @@ describe('TaskButtons', () => {
75
74
  const dynflowLink = screen.getByRole('link', {
76
75
  name: /dynflow console/i,
77
76
  });
78
- expect(dynflowLink).not.toHaveClass('disabled');
77
+ expect(dynflowLink).not.toBeDisabled();
79
78
  });
80
79
 
81
80
  it('disables resume and cancel buttons when canEdit is false', () => {
@@ -15,59 +15,48 @@ exports[`Task rendering render with minimal Props 1`] = `
15
15
  selectedRowsLen={1}
16
16
  setModalClosed={[Function]}
17
17
  />
18
- <Grid
19
- bsClass="container"
20
- componentClass="div"
21
- fluid={false}
22
- >
23
- <Row
24
- bsClass="row"
25
- componentClass="div"
26
- >
27
- <TaskButtons
28
- action=""
29
- canEdit={false}
30
- cancelTaskRequest={[Function]}
31
- cancellable={false}
32
- dynflowEnableConsole={false}
33
- externalId=""
34
- forceCancelTaskRequest={[Function]}
35
- hasSubTasks={false}
36
- id="test"
37
- parentTask=""
38
- resumable={false}
39
- resumeTaskRequest={[Function]}
40
- setForceUnlockModalOpen={[Function]}
41
- setUnlockModalOpen={[Function]}
42
- state=""
43
- taskProgressToggle={[MockFunction]}
44
- taskReload={false}
45
- taskReloadStart={[MockFunction]}
46
- unlockTaskRequest={[Function]}
47
- />
48
- </Row>
49
- <TaskInfo
50
- action=""
51
- endedAt=""
52
- errors={Array []}
53
- forceCancelTaskRequest={[Function]}
54
- help=""
55
- id="test"
56
- output=""
57
- progress={0}
58
- result="error"
59
- startAt=""
60
- startBefore=""
61
- startedAt=""
62
- state=""
63
- taskProgressToggle={[MockFunction]}
64
- taskReload={false}
65
- taskReloadStart={[MockFunction]}
66
- unlockTaskRequest={[Function]}
67
- username=""
68
- usernamePath=""
69
- />
70
- </Grid>
18
+ <TaskButtons
19
+ action=""
20
+ canEdit={false}
21
+ cancelTaskRequest={[Function]}
22
+ cancellable={false}
23
+ dynflowEnableConsole={false}
24
+ externalId=""
25
+ forceCancelTaskRequest={[Function]}
26
+ hasSubTasks={false}
27
+ id="test"
28
+ parentTask=""
29
+ resumable={false}
30
+ resumeTaskRequest={[Function]}
31
+ setForceUnlockModalOpen={[Function]}
32
+ setUnlockModalOpen={[Function]}
33
+ state=""
34
+ taskProgressToggle={[MockFunction]}
35
+ taskReload={false}
36
+ taskReloadStart={[MockFunction]}
37
+ unlockTaskRequest={[Function]}
38
+ />
39
+ <TaskInfo
40
+ action=""
41
+ endedAt=""
42
+ errors={Array []}
43
+ forceCancelTaskRequest={[Function]}
44
+ help=""
45
+ id="test"
46
+ output=""
47
+ progress={0}
48
+ result="error"
49
+ startAt=""
50
+ startBefore=""
51
+ startedAt=""
52
+ state=""
53
+ taskProgressToggle={[MockFunction]}
54
+ taskReload={false}
55
+ taskReloadStart={[MockFunction]}
56
+ unlockTaskRequest={[Function]}
57
+ username=""
58
+ usernamePath=""
59
+ />
71
60
  </Fragment>
72
61
  `;
73
62
 
@@ -86,64 +75,53 @@ exports[`Task rendering render with some Props 1`] = `
86
75
  selectedRowsLen={1}
87
76
  setModalClosed={[Function]}
88
77
  />
89
- <Grid
90
- bsClass="container"
91
- componentClass="div"
92
- fluid={false}
93
- >
94
- <Row
95
- bsClass="row"
96
- componentClass="div"
97
- >
98
- <TaskButtons
99
- action=""
100
- canEdit={true}
101
- cancelTaskRequest={[Function]}
102
- cancellable={false}
103
- dynflowEnableConsole={true}
104
- externalId=""
105
- forceCancelTaskRequest={[Function]}
106
- hasSubTasks={true}
107
- id="test"
108
- parentTask="parent-id"
109
- resumable={false}
110
- resumeTaskRequest={[Function]}
111
- setForceUnlockModalOpen={[Function]}
112
- setUnlockModalOpen={[Function]}
113
- state="paused"
114
- status="RESOLVED"
115
- taskProgressToggle={[MockFunction]}
116
- taskReload={true}
117
- taskReloadStart={[MockFunction]}
118
- unlockTaskRequest={[Function]}
119
- />
120
- </Row>
121
- <TaskInfo
122
- action=""
123
- canEdit={true}
124
- dynflowEnableConsole={true}
125
- endedAt=""
126
- errors={Array []}
127
- forceCancelTaskRequest={[Function]}
128
- hasSubTasks={true}
129
- help=""
130
- id="test"
131
- output=""
132
- parentTask="parent-id"
133
- progress={0}
134
- result="error"
135
- startAt=""
136
- startBefore=""
137
- startedAt=""
138
- state="paused"
139
- status="RESOLVED"
140
- taskProgressToggle={[MockFunction]}
141
- taskReload={true}
142
- taskReloadStart={[MockFunction]}
143
- unlockTaskRequest={[Function]}
144
- username=""
145
- usernamePath=""
146
- />
147
- </Grid>
78
+ <TaskButtons
79
+ action=""
80
+ canEdit={true}
81
+ cancelTaskRequest={[Function]}
82
+ cancellable={false}
83
+ dynflowEnableConsole={true}
84
+ externalId=""
85
+ forceCancelTaskRequest={[Function]}
86
+ hasSubTasks={true}
87
+ id="test"
88
+ parentTask="parent-id"
89
+ resumable={false}
90
+ resumeTaskRequest={[Function]}
91
+ setForceUnlockModalOpen={[Function]}
92
+ setUnlockModalOpen={[Function]}
93
+ state="paused"
94
+ status="RESOLVED"
95
+ taskProgressToggle={[MockFunction]}
96
+ taskReload={true}
97
+ taskReloadStart={[MockFunction]}
98
+ unlockTaskRequest={[Function]}
99
+ />
100
+ <TaskInfo
101
+ action=""
102
+ canEdit={true}
103
+ dynflowEnableConsole={true}
104
+ endedAt=""
105
+ errors={Array []}
106
+ forceCancelTaskRequest={[Function]}
107
+ hasSubTasks={true}
108
+ help=""
109
+ id="test"
110
+ output=""
111
+ parentTask="parent-id"
112
+ progress={0}
113
+ result="error"
114
+ startAt=""
115
+ startBefore=""
116
+ startedAt=""
117
+ state="paused"
118
+ status="RESOLVED"
119
+ taskProgressToggle={[MockFunction]}
120
+ taskReload={true}
121
+ taskReloadStart={[MockFunction]}
122
+ unlockTaskRequest={[Function]}
123
+ username=""
124
+ usernamePath=""
125
+ />
148
126
  </Fragment>
149
127
  `;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
4
 
5
- import { Button, Tooltip, TooltipPosition } from '@patternfly/react-core';
5
+ import { Button, Tooltip, TooltipPosition, Icon } from '@patternfly/react-core';
6
6
  import { InfoCircleIcon } from '@patternfly/react-icons';
7
7
  import { translate as __ } from 'foremanReact/common/I18n';
8
8
  import {
@@ -25,8 +25,10 @@ export const OtherInfo = ({ updateQuery, otherCount, query }) => {
25
25
  position={TooltipPosition.bottom}
26
26
  >
27
27
  <span>
28
- <InfoCircleIcon className="pficon" />
29
- <span>{__('Other:')} </span>
28
+ <Icon isInline>
29
+ <InfoCircleIcon />
30
+ </Icon>{' '}
31
+ {__('Other:')}
30
32
  </span>
31
33
  </Tooltip>
32
34
  <Button
@@ -1,14 +1,63 @@
1
- import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
1
+ import React from 'react';
2
+ import { render, screen, fireEvent } from '@testing-library/react';
3
+ import '@testing-library/jest-dom';
2
4
 
3
5
  import { OtherInfo } from './OtherInfo';
6
+ import {
7
+ TASKS_DASHBOARD_AVAILABLE_QUERY_STATES,
8
+ TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS,
9
+ } from '../../../../TasksDashboardConstants';
4
10
 
5
- const fixtures = {
6
- render: {
7
- updateQuery: jest.fn,
8
- otherCount: 7,
9
- query: { state: 'STOPPED', result: 'OTHER' },
10
- },
11
+ jest.mock('foremanReact/common/I18n', () => ({
12
+ translate: str => str,
13
+ }));
14
+
15
+ const { STOPPED } = TASKS_DASHBOARD_AVAILABLE_QUERY_STATES;
16
+ const { OTHER } = TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS;
17
+
18
+ const defaultProps = {
19
+ updateQuery: jest.fn(),
20
+ otherCount: 7,
21
+ query: { state: STOPPED, result: OTHER },
11
22
  };
12
23
 
13
- describe('OtherInfo', () =>
14
- testComponentSnapshotsWithFixtures(OtherInfo, fixtures));
24
+ describe('OtherInfo', () => {
25
+ beforeEach(() => {
26
+ defaultProps.updateQuery.mockClear();
27
+ });
28
+
29
+ it('renders Other label, count', () => {
30
+ render(<OtherInfo {...defaultProps} />);
31
+ expect(screen.getByText('Other:')).toBeInTheDocument();
32
+ expect(screen.getByText('7')).toBeInTheDocument();
33
+ });
34
+
35
+ it('calls updateQuery with STOPPED and OTHER when the count button is clicked', () => {
36
+ render(<OtherInfo {...defaultProps} />);
37
+ const button = screen.getByRole('button', { name: '7' });
38
+ fireEvent.click(button);
39
+ expect(defaultProps.updateQuery).toHaveBeenCalledWith({
40
+ state: STOPPED,
41
+ result: OTHER,
42
+ });
43
+ });
44
+
45
+ it('applies other-active class when query state is STOPPED and result is OTHER', () => {
46
+ const { container } = render(
47
+ <OtherInfo {...defaultProps} query={{ state: STOPPED, result: OTHER }} />
48
+ );
49
+ const wrapper = container.querySelector('.other-active');
50
+ expect(wrapper).toBeInTheDocument();
51
+ });
52
+
53
+ it('does not apply other-active class when query result is not OTHER', () => {
54
+ const { container } = render(
55
+ <OtherInfo
56
+ {...defaultProps}
57
+ query={{ state: STOPPED, result: 'error' }}
58
+ />
59
+ );
60
+ const wrapper = container.querySelector('.other-active');
61
+ expect(wrapper).not.toBeInTheDocument();
62
+ });
63
+ });
@@ -1,19 +1,5 @@
1
1
  .stopped-tasks-card {
2
2
  .stopped-table {
3
- width: 100%;
4
- border: none;
5
- table-layout: fixed;
6
-
7
- thead {
8
- background-color: transparent;
9
- background-image: none;
10
- tr {
11
- th {
12
- font-weight: bold;
13
- border: none;
14
- }
15
- }
16
- }
17
3
 
18
4
  td,
19
5
  th {
@@ -29,12 +15,6 @@
29
15
  td {
30
16
  &.active {
31
17
  font-weight: bold;
32
- }
33
- }
34
- .data-col {
35
- &:hover {
36
- cursor: pointer;
37
- border: 1px solid #d1d1d1;
38
18
  background-color: #def3fe;
39
19
  }
40
20
  }
@@ -43,14 +23,4 @@
43
23
  .other-active {
44
24
  text-decoration: underline;
45
25
  }
46
-
47
- .pficon {
48
- margin-right: 5px;
49
- }
50
-
51
- .btn-link {
52
- font-size: 14px;
53
- padding-top: 0;
54
- padding-bottom: 0;
55
- }
56
26
  }