foreman_leapp 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/app/views/foreman_leapp/job_templates/upgrade.erb +12 -4
- data/app/views/job_invocations/_leapp_preupgrade_report.html.erb +2 -1
- data/lib/foreman_leapp/version.rb +1 -1
- data/webpack/__mocks__/foremanReact/Root/Context/ForemanContext.js +4 -0
- data/webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js +2 -0
- data/webpack/components/PreupgradeReports/PreupgradeReports.js +32 -4
- data/webpack/components/PreupgradeReports/PreupgradeReportsHelpers.js +35 -0
- data/webpack/components/PreupgradeReports/PreupgradeReportsSelectors.js +1 -0
- data/webpack/components/PreupgradeReports/__tests__/PreupgradeReports.fixtures.js +34 -2
- data/webpack/components/PreupgradeReports/__tests__/PreupgradeReports.test.js +9 -0
- data/webpack/components/PreupgradeReports/__tests__/PreupgradeReportsHelpers.test.js +38 -0
- data/webpack/components/PreupgradeReports/__tests__/__snapshots__/PreupgradeReports.test.js.snap +131 -24
- data/webpack/components/PreupgradeReports/__tests__/__snapshots__/PreupgradeReportsHelpers.test.js.snap +82 -0
- data/webpack/components/PreupgradeReports/__tests__/__snapshots__/PreupgradeReportsReducer.test.js.snap +19 -0
- data/webpack/components/PreupgradeReports/__tests__/__snapshots__/PreupgradeReportsSelectors.test.js.snap +19 -0
- data/webpack/components/PreupgradeReports/components/FixAllButton.js +37 -0
- data/webpack/components/PreupgradeReports/components/FixAllButton.test.js +18 -0
- data/webpack/components/PreupgradeReports/components/__snapshots__/FixAllButton.test.js.snap +34 -0
- data/webpack/components/PreupgradeReports/index.js +7 -2
- data/webpack/components/PreupgradeReportsList/__tests__/PreupgradeReportsList.test.js +12 -2
- data/webpack/components/PreupgradeReportsList/__tests__/__snapshots__/PreupgradeReportsList.test.js.snap +81 -0
- data/webpack/components/PreupgradeReportsList/components/PreupgradeReportEntry.js +39 -5
- data/webpack/components/PreupgradeReportsList/components/__tests__/PreupgradeReportEntry.fixtures.js +38 -0
- data/webpack/components/PreupgradeReportsList/components/__tests__/__snapshots__/PreupgradeReportEntry.test.js.snap +97 -22
- data/webpack/components/PreupgradeReportsList/components/__tests__/__snapshots__/helpers.test.js.snap +196 -28
- data/webpack/components/PreupgradeReportsList/components/__tests__/helpers.test.js +21 -8
- data/webpack/components/PreupgradeReportsList/components/foreman_leapp.scss +9 -0
- data/webpack/components/PreupgradeReportsList/components/helpers.js +149 -21
- data/webpack/components/PreupgradeReportsList/index.js +21 -8
- data/webpack/csrf.js +4 -0
- metadata +27 -5
- data/webpack/components/PreupgradeReportsList/components/StringInfoItem.js +0 -49
- data/webpack/components/PreupgradeReportsList/components/__tests__/StringInfoItem.test.js +0 -13
- data/webpack/components/PreupgradeReportsList/components/__tests__/__snapshots__/StringInfoItem.test.js.snap +0 -12
@@ -0,0 +1,82 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`PreupgradeReportsHelpers should collect ids for job invocation 1`] = `
|
4
|
+
Object {
|
5
|
+
"entryIds": Array [],
|
6
|
+
"hostIds": Array [],
|
7
|
+
}
|
8
|
+
`;
|
9
|
+
|
10
|
+
exports[`PreupgradeReportsHelpers should detect a fixable entry in reports 1`] = `true`;
|
11
|
+
|
12
|
+
exports[`PreupgradeReportsHelpers should detect empty object 1`] = `true`;
|
13
|
+
|
14
|
+
exports[`PreupgradeReportsHelpers should detect entry is fixable 1`] = `true`;
|
15
|
+
|
16
|
+
exports[`PreupgradeReportsHelpers should detect entry is not fixable when not having a command 1`] = `false`;
|
17
|
+
|
18
|
+
exports[`PreupgradeReportsHelpers should detect entry is not fixable when not having remediations 1`] = `false`;
|
19
|
+
|
20
|
+
exports[`PreupgradeReportsHelpers should detect no entry is fixable 1`] = `false`;
|
21
|
+
|
22
|
+
exports[`PreupgradeReportsHelpers should detect non-empty object 1`] = `false`;
|
23
|
+
|
24
|
+
exports[`PreupgradeReportsHelpers should return entries page 1`] = `
|
25
|
+
Array [
|
26
|
+
Object {
|
27
|
+
"id": 45,
|
28
|
+
"severity": "low",
|
29
|
+
"title": "Not enough credits",
|
30
|
+
},
|
31
|
+
Object {
|
32
|
+
"id": 46,
|
33
|
+
"severity": "medium",
|
34
|
+
"title": "SELinux is turned off",
|
35
|
+
},
|
36
|
+
Object {
|
37
|
+
"id": 47,
|
38
|
+
"severity": "medium",
|
39
|
+
"title": "Root password is too short",
|
40
|
+
},
|
41
|
+
]
|
42
|
+
`;
|
43
|
+
|
44
|
+
exports[`PreupgradeReportsHelpers should return flattened entrues 1`] = `
|
45
|
+
Array [
|
46
|
+
Object {
|
47
|
+
"id": 42,
|
48
|
+
"severity": "Too severe to talk about",
|
49
|
+
"title": "Fix me!",
|
50
|
+
},
|
51
|
+
Object {
|
52
|
+
"id": 43,
|
53
|
+
"severity": "medium",
|
54
|
+
"title": "I am broken too",
|
55
|
+
},
|
56
|
+
Object {
|
57
|
+
"id": 44,
|
58
|
+
"severity": "high",
|
59
|
+
"title": "Octocat is not happy",
|
60
|
+
},
|
61
|
+
Object {
|
62
|
+
"id": 45,
|
63
|
+
"severity": "low",
|
64
|
+
"title": "Not enough credits",
|
65
|
+
},
|
66
|
+
Object {
|
67
|
+
"id": 46,
|
68
|
+
"severity": "medium",
|
69
|
+
"title": "SELinux is turned off",
|
70
|
+
},
|
71
|
+
Object {
|
72
|
+
"id": 47,
|
73
|
+
"severity": "medium",
|
74
|
+
"title": "Root password is too short",
|
75
|
+
},
|
76
|
+
Object {
|
77
|
+
"id": 49,
|
78
|
+
"severity": "high",
|
79
|
+
"title": "No chocolate chip cookies in cookie jar",
|
80
|
+
},
|
81
|
+
]
|
82
|
+
`;
|
@@ -35,10 +35,12 @@ Object {
|
|
35
35
|
Object {
|
36
36
|
"entries": Array [
|
37
37
|
Object {
|
38
|
+
"id": 42,
|
38
39
|
"severity": "Too severe to talk about",
|
39
40
|
"title": "Fix me!",
|
40
41
|
},
|
41
42
|
Object {
|
43
|
+
"id": 43,
|
42
44
|
"severity": "medium",
|
43
45
|
"title": "I am broken too",
|
44
46
|
},
|
@@ -48,13 +50,30 @@ Object {
|
|
48
50
|
Object {
|
49
51
|
"entries": Array [
|
50
52
|
Object {
|
53
|
+
"id": 44,
|
51
54
|
"severity": "high",
|
52
55
|
"title": "Octocat is not happy",
|
53
56
|
},
|
54
57
|
Object {
|
58
|
+
"id": 45,
|
55
59
|
"severity": "low",
|
56
60
|
"title": "Not enough credits",
|
57
61
|
},
|
62
|
+
Object {
|
63
|
+
"id": 46,
|
64
|
+
"severity": "medium",
|
65
|
+
"title": "SELinux is turned off",
|
66
|
+
},
|
67
|
+
Object {
|
68
|
+
"id": 47,
|
69
|
+
"severity": "medium",
|
70
|
+
"title": "Root password is too short",
|
71
|
+
},
|
72
|
+
Object {
|
73
|
+
"id": 49,
|
74
|
+
"severity": "high",
|
75
|
+
"title": "No chocolate chip cookies in cookie jar",
|
76
|
+
},
|
58
77
|
],
|
59
78
|
"hostId": 6,
|
60
79
|
},
|
@@ -14,10 +14,12 @@ Array [
|
|
14
14
|
Object {
|
15
15
|
"entries": Array [
|
16
16
|
Object {
|
17
|
+
"id": 42,
|
17
18
|
"severity": "Too severe to talk about",
|
18
19
|
"title": "Fix me!",
|
19
20
|
},
|
20
21
|
Object {
|
22
|
+
"id": 43,
|
21
23
|
"severity": "medium",
|
22
24
|
"title": "I am broken too",
|
23
25
|
},
|
@@ -27,13 +29,30 @@ Array [
|
|
27
29
|
Object {
|
28
30
|
"entries": Array [
|
29
31
|
Object {
|
32
|
+
"id": 44,
|
30
33
|
"severity": "high",
|
31
34
|
"title": "Octocat is not happy",
|
32
35
|
},
|
33
36
|
Object {
|
37
|
+
"id": 45,
|
34
38
|
"severity": "low",
|
35
39
|
"title": "Not enough credits",
|
36
40
|
},
|
41
|
+
Object {
|
42
|
+
"id": 46,
|
43
|
+
"severity": "medium",
|
44
|
+
"title": "SELinux is turned off",
|
45
|
+
},
|
46
|
+
Object {
|
47
|
+
"id": 47,
|
48
|
+
"severity": "medium",
|
49
|
+
"title": "Root password is too short",
|
50
|
+
},
|
51
|
+
Object {
|
52
|
+
"id": 49,
|
53
|
+
"severity": "high",
|
54
|
+
"title": "No chocolate chip cookies in cookie jar",
|
55
|
+
},
|
37
56
|
],
|
38
57
|
"hostId": 6,
|
39
58
|
},
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { Button } from 'patternfly-react';
|
4
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
5
|
+
|
6
|
+
import { idsForInvocation } from '../PreupgradeReportsHelpers';
|
7
|
+
|
8
|
+
const FixAllButton = ({ preupgradeReports, postUrl, disabled, csrfToken }) => {
|
9
|
+
const { hostIds, entryIds } = idsForInvocation(preupgradeReports);
|
10
|
+
|
11
|
+
return (
|
12
|
+
<form action={postUrl} method="post">
|
13
|
+
<Button type="submit" disabled={disabled}>
|
14
|
+
{__('Fix All')}
|
15
|
+
</Button>
|
16
|
+
<input type="hidden" name="authenticity_token" value={csrfToken} />
|
17
|
+
<input type="hidden" name="feature" value="leapp_remediation_plan" />
|
18
|
+
{hostIds.map(hostId => (
|
19
|
+
<input type="hidden" name="host_ids[]" key={hostId} value={hostId} />
|
20
|
+
))}
|
21
|
+
<input
|
22
|
+
type="hidden"
|
23
|
+
name="inputs[remediation_ids]"
|
24
|
+
value={entryIds.join(',')}
|
25
|
+
/>
|
26
|
+
</form>
|
27
|
+
);
|
28
|
+
};
|
29
|
+
|
30
|
+
FixAllButton.propTypes = {
|
31
|
+
preupgradeReports: PropTypes.array.isRequired,
|
32
|
+
postUrl: PropTypes.string.isRequired,
|
33
|
+
disabled: PropTypes.bool.isRequired,
|
34
|
+
csrfToken: PropTypes.string.isRequired,
|
35
|
+
};
|
36
|
+
|
37
|
+
export default FixAllButton;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
2
|
+
|
3
|
+
import FixAllButton from './FixAllButton';
|
4
|
+
|
5
|
+
import { preupgradeReports } from '../__tests__/PreupgradeReports.fixtures';
|
6
|
+
|
7
|
+
const fixtures = {
|
8
|
+
'should render': {
|
9
|
+
preupgradeReports,
|
10
|
+
postUrl: '/job_invocations/new',
|
11
|
+
disabled: false,
|
12
|
+
title: 'Button title',
|
13
|
+
csrfToken: 'abcd',
|
14
|
+
},
|
15
|
+
};
|
16
|
+
|
17
|
+
describe('FixAllButton', () =>
|
18
|
+
testComponentSnapshotsWithFixtures(FixAllButton, fixtures));
|
@@ -0,0 +1,34 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`FixAllButton should render 1`] = `
|
4
|
+
<form
|
5
|
+
action="/job_invocations/new"
|
6
|
+
method="post"
|
7
|
+
>
|
8
|
+
<Button
|
9
|
+
active={false}
|
10
|
+
block={false}
|
11
|
+
bsClass="btn"
|
12
|
+
bsStyle="default"
|
13
|
+
disabled={false}
|
14
|
+
type="submit"
|
15
|
+
>
|
16
|
+
<Component />
|
17
|
+
</Button>
|
18
|
+
<input
|
19
|
+
name="authenticity_token"
|
20
|
+
type="hidden"
|
21
|
+
value="abcd"
|
22
|
+
/>
|
23
|
+
<input
|
24
|
+
name="feature"
|
25
|
+
type="hidden"
|
26
|
+
value="leapp_remediation_plan"
|
27
|
+
/>
|
28
|
+
<input
|
29
|
+
name="inputs[remediation_ids]"
|
30
|
+
type="hidden"
|
31
|
+
value=""
|
32
|
+
/>
|
33
|
+
</form>
|
34
|
+
`;
|
@@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
|
|
4
4
|
|
5
5
|
import PreupgradeReports from './PreupgradeReports';
|
6
6
|
|
7
|
+
import getCsrfToken from '../../csrf';
|
8
|
+
|
7
9
|
import {
|
8
10
|
selectPreupgradeReports,
|
9
11
|
selectLoadingPreupgradeReports,
|
@@ -12,7 +14,7 @@ import {
|
|
12
14
|
|
13
15
|
import { getPreupgradeReports } from './PreupgradeReportsActions';
|
14
16
|
|
15
|
-
const WrappedPreupgradeReports = ({ url }) => {
|
17
|
+
const WrappedPreupgradeReports = ({ url, newJobInvocationUrl }) => {
|
16
18
|
const loading = useSelector(state => selectLoadingPreupgradeReports(state));
|
17
19
|
const preupgradeReports = useSelector(state =>
|
18
20
|
selectPreupgradeReports(state)
|
@@ -23,19 +25,22 @@ const WrappedPreupgradeReports = ({ url }) => {
|
|
23
25
|
|
24
26
|
useEffect(() => {
|
25
27
|
dispatch(getPreupgradeReports(url));
|
26
|
-
}, [url]);
|
28
|
+
}, [url, dispatch]);
|
27
29
|
|
28
30
|
return (
|
29
31
|
<PreupgradeReports
|
30
32
|
preupgradeReports={preupgradeReports}
|
31
33
|
error={error}
|
32
34
|
loading={loading}
|
35
|
+
csrfToken={getCsrfToken()}
|
36
|
+
newJobInvocationUrl={newJobInvocationUrl}
|
33
37
|
/>
|
34
38
|
);
|
35
39
|
};
|
36
40
|
|
37
41
|
WrappedPreupgradeReports.propTypes = {
|
38
42
|
url: PropTypes.string.isRequired,
|
43
|
+
newJobInvocationUrl: PropTypes.string.isRequired,
|
39
44
|
};
|
40
45
|
|
41
46
|
export default WrappedPreupgradeReports;
|
@@ -2,11 +2,21 @@ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
|
2
2
|
|
3
3
|
import PreupgradeReportsList from '../index';
|
4
4
|
|
5
|
-
|
5
|
+
const allEntries = [
|
6
|
+
{ title: 'Fix me!', severity: 'Too severe to talk about' },
|
7
|
+
{ title: 'I am broken too', severity: 'medium' },
|
8
|
+
{ title: 'Octocat is not happy', severity: 'high' },
|
9
|
+
{ title: 'Not enough credits', severity: 'low' },
|
10
|
+
];
|
6
11
|
|
7
12
|
const fixtures = {
|
8
13
|
'should render': {
|
9
|
-
|
14
|
+
allEntries,
|
15
|
+
fixAllWorking: false,
|
16
|
+
},
|
17
|
+
'should render when working': {
|
18
|
+
allEntries,
|
19
|
+
fixAllWorking: true,
|
10
20
|
},
|
11
21
|
};
|
12
22
|
|
@@ -40,5 +40,86 @@ exports[`PreupgradeReportsList should render 1`] = `
|
|
40
40
|
}
|
41
41
|
key="3"
|
42
42
|
/>
|
43
|
+
<PaginationWrapper
|
44
|
+
dropdownButtonId="preupgrade-report-entries-pagination-dropdown"
|
45
|
+
itemCount={4}
|
46
|
+
onChange={[Function]}
|
47
|
+
pagination={
|
48
|
+
Object {
|
49
|
+
"page": 1,
|
50
|
+
"perPage": 20,
|
51
|
+
"perPageOptions": Array [
|
52
|
+
5,
|
53
|
+
10,
|
54
|
+
20,
|
55
|
+
30,
|
56
|
+
50,
|
57
|
+
],
|
58
|
+
}
|
59
|
+
}
|
60
|
+
viewType="list"
|
61
|
+
/>
|
62
|
+
</ListView>
|
63
|
+
`;
|
64
|
+
|
65
|
+
exports[`PreupgradeReportsList should render when working 1`] = `
|
66
|
+
<ListView
|
67
|
+
className=""
|
68
|
+
>
|
69
|
+
<PreupgradeReportEntry
|
70
|
+
entry={
|
71
|
+
Object {
|
72
|
+
"severity": "Too severe to talk about",
|
73
|
+
"title": "Fix me!",
|
74
|
+
}
|
75
|
+
}
|
76
|
+
key="0"
|
77
|
+
/>
|
78
|
+
<PreupgradeReportEntry
|
79
|
+
entry={
|
80
|
+
Object {
|
81
|
+
"severity": "medium",
|
82
|
+
"title": "I am broken too",
|
83
|
+
}
|
84
|
+
}
|
85
|
+
key="1"
|
86
|
+
/>
|
87
|
+
<PreupgradeReportEntry
|
88
|
+
entry={
|
89
|
+
Object {
|
90
|
+
"severity": "high",
|
91
|
+
"title": "Octocat is not happy",
|
92
|
+
}
|
93
|
+
}
|
94
|
+
key="2"
|
95
|
+
/>
|
96
|
+
<PreupgradeReportEntry
|
97
|
+
entry={
|
98
|
+
Object {
|
99
|
+
"severity": "low",
|
100
|
+
"title": "Not enough credits",
|
101
|
+
}
|
102
|
+
}
|
103
|
+
key="3"
|
104
|
+
/>
|
105
|
+
<PaginationWrapper
|
106
|
+
dropdownButtonId="preupgrade-report-entries-pagination-dropdown"
|
107
|
+
itemCount={4}
|
108
|
+
onChange={[Function]}
|
109
|
+
pagination={
|
110
|
+
Object {
|
111
|
+
"page": 1,
|
112
|
+
"perPage": 20,
|
113
|
+
"perPageOptions": Array [
|
114
|
+
5,
|
115
|
+
10,
|
116
|
+
20,
|
117
|
+
30,
|
118
|
+
50,
|
119
|
+
],
|
120
|
+
}
|
121
|
+
}
|
122
|
+
viewType="list"
|
123
|
+
/>
|
43
124
|
</ListView>
|
44
125
|
`;
|
@@ -1,16 +1,50 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { ListView } from 'patternfly-react';
|
2
|
+
import { ListView, Grid, Icon } from 'patternfly-react';
|
3
3
|
import PropTypes from 'prop-types';
|
4
|
+
import './foreman_leapp.scss';
|
4
5
|
|
5
|
-
import {
|
6
|
+
import {
|
7
|
+
itemIteratorId,
|
8
|
+
presentSeverity,
|
9
|
+
hasRemediations,
|
10
|
+
getExternals,
|
11
|
+
getRemediations,
|
12
|
+
getTitle,
|
13
|
+
getSeverity,
|
14
|
+
getSummary,
|
15
|
+
getTags,
|
16
|
+
} from './helpers';
|
6
17
|
|
7
18
|
const PreupgradeReportEntry = ({ entry }) => (
|
8
19
|
<ListView.Item
|
9
20
|
key={entry.id}
|
10
|
-
className="listViewItem--listItemVariants"
|
11
21
|
stacked
|
12
|
-
|
13
|
-
|
22
|
+
checkboxInput={<input type="checkbox" />}
|
23
|
+
description={entry.title}
|
24
|
+
additionalInfo={[
|
25
|
+
<ListView.InfoItem key={itemIteratorId(entry, entry.hostname)}>
|
26
|
+
<Icon type="pf" name="cluster" /> {entry.hostname}
|
27
|
+
</ListView.InfoItem>,
|
28
|
+
<ListView.InfoItem key={itemIteratorId(entry, entry.severity)}>
|
29
|
+
<Icon
|
30
|
+
type="pf"
|
31
|
+
name="resources-full"
|
32
|
+
style={{ color: presentSeverity(entry.severity) }}
|
33
|
+
/>
|
34
|
+
{entry.severity}
|
35
|
+
</ListView.InfoItem>,
|
36
|
+
hasRemediations(entry),
|
37
|
+
]}
|
38
|
+
>
|
39
|
+
<Grid fluid>
|
40
|
+
{getTitle(entry)}
|
41
|
+
{getSeverity(entry)}
|
42
|
+
{getSummary(entry)}
|
43
|
+
{getTags(entry)}
|
44
|
+
{getExternals(entry)}
|
45
|
+
{getRemediations(entry)}
|
46
|
+
</Grid>
|
47
|
+
</ListView.Item>
|
14
48
|
);
|
15
49
|
|
16
50
|
PreupgradeReportEntry.propTypes = {
|