Skip to content

Commit 7a02634

Browse files
committed
fix(CVEDetails): RHINENG-19856 - Update remediation section
1 parent 90d9f35 commit 7a02634

File tree

3 files changed

+81
-48
lines changed

3 files changed

+81
-48
lines changed

src/Components/PresentationalComponents/CsawRuleBox/CsawRuleBox.js

Lines changed: 14 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Fragment } from 'react';
1+
import React from 'react';
22
import PropTypes from 'prop-types';
33
import {
44
Stack,
@@ -19,8 +19,6 @@ import {
1919
} from '@patternfly/react-core';
2020
import { InsightsLabel } from '@redhat-cloud-services/frontend-components/InsightsLabel';
2121
import {
22-
CheckCircleIcon,
23-
OutlinedQuestionCircleIcon,
2422
ExternalLinkAltIcon,
2523
PowerOffIcon
2624
} from '@patternfly/react-icons';
@@ -38,6 +36,7 @@ import CsawLabel from '../Snippets/CsawLabel';
3836
import CsawRuleSummary from './CsawRuleSummary';
3937
import './CsawRuleBox.scss';
4038
import { HashLink } from 'react-router-hash-link';
39+
import RemediationPlanSplitItem from './components/RemediationPlanSplitItem';
4140

4241
const CsawRuleBox = ({ rules = [], synopsis, intl, setHeaderFilters, headerFilters }) => {
4342
const sortedRules = [].concat(rules).sort((a, b) => (b.systems_affected - a.systems_affected));
@@ -134,54 +133,26 @@ const CsawRuleBox = ({ rules = [], synopsis, intl, setHeaderFilters, headerFilte
134133
{RISK_OF_CHANGE_LABEL[rule.change_risk]}
135134
</Tooltip>
136135
</SplitItem>
136+
137+
<RemediationPlanSplitItem rule={rule} />
138+
137139
<SplitItem>
138140
<Label className="label pf-v5-u-mb-xs">
139-
{intl.formatMessage(messages.remediationLabel)}
141+
Remediation requires reboot
140142
</Label>
141143
<Split>
142144
<SplitItem>
143-
{!rule.playbook_count
144-
? intl.formatMessage(messages.no)
145-
: (
146-
<Fragment>
147-
<Icon>
148-
<CheckCircleIcon
149-
className="checkCircleIcon pf-v5-u-mr-xs"
150-
data-testid="check-circle-icon"
151-
/>
152-
</Icon>
153-
{intl.formatMessage(messages.yes)}
154-
<Tooltip
155-
content={intl.formatMessage(
156-
messages.ansibleRemediationTooltip
157-
)}
158-
>
159-
<Icon>
160-
<OutlinedQuestionCircleIcon
161-
className="l-sm-spacer outlinedQuestionCircleIcon"
162-
/>
163-
</Icon>
164-
</Tooltip>
165-
</Fragment>
166-
)
167-
}
168-
</SplitItem>
169-
<SplitItem className="pf-v5-u-ml-md">
170-
{rule.reboot_required &&
171-
<Text>
172-
<Icon>
173-
<PowerOffIcon
174-
className="pf-v5-u-mr-xs powerOffIcon"
175-
data-testid="power-off-icon"
176-
/>
177-
</Icon>
178-
{intl.formatMessage(messages.rebootRequired)}
179-
</Text>
180-
}
145+
<Text data-testid="reboot-required">
146+
<Icon>
147+
<PowerOffIcon
148+
className="pf-v5-u-mr-xs"
149+
/>
150+
</Icon>
151+
{rule.reboot_required ? intl.formatMessage(messages.yes) : intl.formatMessage(messages.no) }
152+
</Text>
181153
</SplitItem>
182154
</Split>
183155
</SplitItem>
184-
185156
</Split>
186157
</TextContent>
187158
</StackItem>

src/Components/PresentationalComponents/CsawRuleBox/CsawRuleBox.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import CsawRuleBox from './CsawRuleBox'
22
import configureStore from 'redux-mock-store';
33
import { initialState } from '../../../Store/Reducers/CVEDetailsPageStore';
4-
import { fireEvent, render, screen } from '@testing-library/react';
4+
import { fireEvent, render, screen, within } from '@testing-library/react';
55
import TestWrapper from '../../../Utilities/TestWrapper';
66
import '@testing-library/jest-dom';
77

@@ -73,7 +73,7 @@ describe('CSAW Rule Box', () => {
7373
</TestWrapper>
7474
);
7575

76-
expect(screen.queryByTestId('power-off-icon')).toBeNull();
76+
expect(within(screen.queryByTestId('reboot-required')).getByText('No')).toBeInTheDocument();
7777
});
7878

7979
it('Should render with reboot warning', () => {
@@ -99,7 +99,7 @@ describe('CSAW Rule Box', () => {
9999
</TestWrapper>
100100
);
101101

102-
expect(screen.getByTestId('power-off-icon')).not.toBeNull();
102+
expect(within(screen.queryByTestId('reboot-required')).getByText('Yes')).toBeInTheDocument();
103103
});
104104

105105
it('Should render assosiated cve links', () => {
@@ -155,7 +155,7 @@ describe('CSAW Rule Box', () => {
155155
</TestWrapper>
156156
);
157157

158-
expect(screen.getAllByTestId('check-circle-icon')).toHaveLength(1);
158+
expect(within(screen.getByTestId("remediation-plan")).getByText("Available")).toBeInTheDocument()
159159
});
160160

161161
it('Should render without playbook', () => {
@@ -183,7 +183,7 @@ describe('CSAW Rule Box', () => {
183183
</TestWrapper>
184184
);
185185

186-
expect(screen.queryByTestId('check-circle-icon')).toBeNull();
186+
expect(within(screen.getByTestId("remediation-plan")).getByText("Not available")).toBeInTheDocument()
187187
});
188188

189189
it('Should render with knowledge base link', () => {
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import {
4+
Tooltip,
5+
SplitItem,
6+
Split,
7+
Icon
8+
} from '@patternfly/react-core';
9+
import {
10+
CheckCircleIcon,
11+
TimesIcon
12+
} from '@patternfly/react-icons';
13+
import Label from '../../Snippets/Label';
14+
15+
const RemediationPlanSplitItem = ({ rule }) => (
16+
<SplitItem>
17+
<Label className="label pf-v5-u-mb-xs">
18+
Remediation plan
19+
</Label>
20+
<Split>
21+
<SplitItem data-testid="remediation-plan">
22+
{rule?.playbook_count === 0
23+
? (
24+
<>
25+
<Tooltip
26+
content="No Ansible playbooks are available, manual remediation is required for patching."
27+
>
28+
<Icon>
29+
<TimesIcon
30+
className="pf-v5-u-mr-xs"
31+
data-testid="times-icon"
32+
/>
33+
</Icon>
34+
</Tooltip>
35+
Not available
36+
</>
37+
) : (
38+
<>
39+
<Tooltip
40+
content="You can create an Ansible playbook to remediate your systems."
41+
>
42+
<Icon>
43+
<CheckCircleIcon
44+
className="checkCircleIcon pf-v5-u-mr-xs"
45+
data-testid="check-circle-icon"
46+
/>
47+
</Icon>
48+
</Tooltip>
49+
Available
50+
</>
51+
)
52+
}
53+
</SplitItem>
54+
</Split>
55+
</SplitItem>
56+
);
57+
58+
RemediationPlanSplitItem.propTypes = {
59+
rule: PropTypes.object
60+
};
61+
62+
export default RemediationPlanSplitItem;

0 commit comments

Comments
 (0)