-
Notifications
You must be signed in to change notification settings - Fork 58
fix(CVEDetails): RHINENG-19856 - Update remediation section #2423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Reviewer's GuideThis PR refactors the remediation section in CsawRuleBox by extracting display logic into a new RemediationPlanSplitItem component, integrating it into the main component, simplifying the reboot requirement to an icon-based yes/no label, and updating tests to match the new UI structure. Class diagram for CsawRuleBox and RemediationPlanSplitItem refactorclassDiagram
class CsawRuleBox {
+rules
+synopsis
+intl
+setHeaderFilters
+headerFilters
+render()
}
class RemediationPlanSplitItem {
+rule
+render()
}
CsawRuleBox --> RemediationPlanSplitItem: uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
94f90a7 to
7a02634
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- Use intl.formatMessage and message definitions for all new user-facing text (e.g. “Remediation plan”, “Available”, “Not available” and tooltip content) to maintain localization support.
- Add aria-labels or accessible text to the icon elements in RemediationPlanSplitItem so screen readers can convey their purpose.
- Consider extracting the reboot-required UI into its own small component to mirror RemediationPlanSplitItem and keep CsawRuleBox concerns separated.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Use intl.formatMessage and message definitions for all new user-facing text (e.g. “Remediation plan”, “Available”, “Not available” and tooltip content) to maintain localization support.
- Add aria-labels or accessible text to the icon elements in RemediationPlanSplitItem so screen readers can convey their purpose.
- Consider extracting the reboot-required UI into its own small component to mirror RemediationPlanSplitItem and keep CsawRuleBox concerns separated.
## Individual Comments
### Comment 1
<location> `src/Components/PresentationalComponents/CsawRuleBox/CsawRuleBox.js:141` </location>
<code_context>
<SplitItem>
<Label className="label pf-v5-u-mb-xs">
- {intl.formatMessage(messages.remediationLabel)}
+ Remediation requires reboot
</Label>
<Split>
</code_context>
<issue_to_address>
**suggestion:** The label 'Remediation requires reboot' may be misleading if reboot is not always required.
If reboot is only needed in certain cases, update the label to indicate when a reboot is actually required.
Suggested implementation:
```javascript
<Label className="label pf-v5-u-mb-xs">
{rule.requires_reboot
? 'Remediation requires reboot'
: 'Remediation does not require reboot'}
</Label>
```
If the `rule` object does not have a `requires_reboot` property, you will need to add or derive this property based on your application's logic.
</issue_to_address>
### Comment 2
<location> `src/Components/PresentationalComponents/CsawRuleBox/components/RemediationPlanSplitItem.js:22` </location>
<code_context>
+ </Label>
+ <Split>
+ <SplitItem data-testid="remediation-plan">
+ {rule?.playbook_count === 0
+ ? (
+ <>
</code_context>
<issue_to_address>
**issue (complexity):** Consider refactoring the repeated status rendering logic into a reusable StatusIndicator component with a lookup map.
You can collapse all of that nested JSX and duplicated fragments into a small, self-contained `StatusIndicator` component and a simple lookup map. For example:
```jsx
// StatusIndicator.js
import React from 'react';
import PropTypes from 'prop-types';
import { Tooltip, Icon } from '@patternfly/react-core';
import { CheckCircleIcon, TimesIcon } from '@patternfly/react-icons';
const STATUS_MAP = {
available: {
IconComponent: CheckCircleIcon,
tooltip: 'You can create an Ansible playbook to remediate your systems.',
label: 'Available',
iconClass: 'pf-v5-u-mr-xs',
},
unavailable: {
IconComponent: TimesIcon,
tooltip: 'No Ansible playbooks are available, manual remediation is required for patching.',
label: 'Not available',
iconClass: 'pf-v5-u-mr-xs',
},
};
const StatusIndicator = ({ status }) => {
const { IconComponent, tooltip, label, iconClass } = STATUS_MAP[status];
return (
<>
<Tooltip content={tooltip}>
<Icon>
<IconComponent className={iconClass} />
</Icon>
</Tooltip>
{label}
</>
);
};
StatusIndicator.propTypes = {
status: PropTypes.oneOf(['available', 'unavailable']).isRequired,
};
export default StatusIndicator;
```
Then simplify your main component to:
```jsx
import React from 'react';
import PropTypes from 'prop-types';
import { Split, SplitItem } from '@patternfly/react-core';
import Label from '../../Snippets/Label';
import StatusIndicator from './StatusIndicator';
const RemediationPlanSplitItem = ({ rule }) => {
const status = rule?.playbook_count > 0 ? 'available' : 'unavailable';
return (
<SplitItem>
<Label className="label pf-v5-u-mb-xs">Remediation plan</Label>
<Split>
<SplitItem data-testid="remediation-plan">
<StatusIndicator status={status} />
</SplitItem>
</Split>
</SplitItem>
);
};
RemediationPlanSplitItem.propTypes = {
rule: PropTypes.shape({
playbook_count: PropTypes.number,
}),
};
export default RemediationPlanSplitItem;
```
This removes the inline fragments, duplicate tooltips/icons, and makes it trivial to extend or tweak in the future.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| </Label> | ||
| <Split> | ||
| <SplitItem data-testid="remediation-plan"> | ||
| {rule?.playbook_count === 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): Consider refactoring the repeated status rendering logic into a reusable StatusIndicator component with a lookup map.
You can collapse all of that nested JSX and duplicated fragments into a small, self-contained StatusIndicator component and a simple lookup map. For example:
// StatusIndicator.js
import React from 'react';
import PropTypes from 'prop-types';
import { Tooltip, Icon } from '@patternfly/react-core';
import { CheckCircleIcon, TimesIcon } from '@patternfly/react-icons';
const STATUS_MAP = {
available: {
IconComponent: CheckCircleIcon,
tooltip: 'You can create an Ansible playbook to remediate your systems.',
label: 'Available',
iconClass: 'pf-v5-u-mr-xs',
},
unavailable: {
IconComponent: TimesIcon,
tooltip: 'No Ansible playbooks are available, manual remediation is required for patching.',
label: 'Not available',
iconClass: 'pf-v5-u-mr-xs',
},
};
const StatusIndicator = ({ status }) => {
const { IconComponent, tooltip, label, iconClass } = STATUS_MAP[status];
return (
<>
<Tooltip content={tooltip}>
<Icon>
<IconComponent className={iconClass} />
</Icon>
</Tooltip>
{label}
</>
);
};
StatusIndicator.propTypes = {
status: PropTypes.oneOf(['available', 'unavailable']).isRequired,
};
export default StatusIndicator;Then simplify your main component to:
import React from 'react';
import PropTypes from 'prop-types';
import { Split, SplitItem } from '@patternfly/react-core';
import Label from '../../Snippets/Label';
import StatusIndicator from './StatusIndicator';
const RemediationPlanSplitItem = ({ rule }) => {
const status = rule?.playbook_count > 0 ? 'available' : 'unavailable';
return (
<SplitItem>
<Label className="label pf-v5-u-mb-xs">Remediation plan</Label>
<Split>
<SplitItem data-testid="remediation-plan">
<StatusIndicator status={status} />
</SplitItem>
</Split>
</SplitItem>
);
};
RemediationPlanSplitItem.propTypes = {
rule: PropTypes.shape({
playbook_count: PropTypes.number,
}),
};
export default RemediationPlanSplitItem;This removes the inline fragments, duplicate tooltips/icons, and makes it trivial to extend or tweak in the future.
|
@adonispuente I think the font weight difference may just be a rendering thing or just accidental, at least I think there is no reason that this would have a different weight. The lack of colour when it's "Not available"/"No" is mentioned in the mocks as somewhat intentional only the "Availbal"/"Yes" states have "color":
|
7a02634 to
73f9f8c
Compare
73f9f8c to
20d1b58
Compare
LightOfHeaven1994
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, good work!
20d1b58 to
c8bc01d
Compare
|
Referenced Jiras: |



This updates the "remediation section" on the CVE details page.
Before:
After:
How to test:
Summary by Sourcery
Update the remediation section in CsawRuleBox by introducing a dedicated component for remediation plan availability and streamlining the reboot requirement display
Enhancements:
Summary by Sourcery
Update the remediation section in CsawRuleBox by extracting remediation plan availability into its own component and simplifying the reboot requirement display
New Features:
Enhancements:
Tests: