Skip to content

Commit

Permalink
Only show report page advisory filter/column when FF is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
leSamo committed Jul 31, 2023
1 parent 7707261 commit 1d8a227
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 370 deletions.
54 changes: 28 additions & 26 deletions src/Components/SmartComponents/Modals/ReportConfigModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ const ReportConfigModal = ({
setReportTitle,
inheritGlobalTags,
setInheritGlobalTags,
globalFilterTags
globalFilterTags,
cvesWithoutErrata
}) => {
const dispatch = useDispatch();
const [includeAllColumns, setIncludeAllColumns] = useState(true);
const operatingSystems = useSelector(({ ReportsPageStore }) => ReportsPageStore?.operatingSystems?.data);
const osGroups = buildOSGroups(operatingSystems || []);

const activeFilters = [
const ACTIVE_FILTERS = [
'rule_presence',
'known_exploit',
'impact',
Expand All @@ -58,7 +59,7 @@ const ReportConfigModal = ({
'status_id',
'publish_date',
'rhel_version',
'advisory_available'
...cvesWithoutErrata ? ['advisory_available'] : []
];

const handleCheckboxChange = (parameter, value) => {
Expand Down Expand Up @@ -130,28 +131,27 @@ const ReportConfigModal = ({
label={intl.formatMessage(messages.customReportFilterDataByLabel)}
>
<div className="custom-report-select-wrapper">
{activeFilters &&
activeFilters.map((filterId) => {
return (
CVE_REPORT_FILTERS[filterId]?.component({
...CVE_REPORT_FILTERS[filterId],
filterData,
setFilterData,
selectProps: {
className: 'pf-u-mr-sm pf-u-mb-sm',
...CVE_REPORT_FILTERS[filterId].selectProps
},
options: CVE_REPORT_FILTERS[filterId].items,
filterId,
filterName: CVE_REPORT_FILTERS[filterId].title,
...(filterId === 'rhel_version' ? {
// overriding parameters specific to the OS filter
options: Object.values(osGroups).flat(),
groups: osGroups
} : {})
})
);
})}
{ACTIVE_FILTERS.map((filterId) => {
return (
CVE_REPORT_FILTERS[filterId]?.component({
...CVE_REPORT_FILTERS[filterId],
filterData,
setFilterData,
selectProps: {
className: 'pf-u-mr-sm pf-u-mb-sm',
...CVE_REPORT_FILTERS[filterId].selectProps
},
options: CVE_REPORT_FILTERS[filterId].items,
filterId,
filterName: CVE_REPORT_FILTERS[filterId].title,
...(filterId === 'rhel_version' ? {
// overriding parameters specific to the OS filter
options: Object.values(osGroups).flat(),
groups: osGroups
} : {})
})
);
})}
</div>
</FormGroup>
<FormGroup
Expand Down Expand Up @@ -202,6 +202,7 @@ const ReportConfigModal = ({
/>
{
Object.entries(CVE_REPORT_FILTERS)
.filter(([key]) => cvesWithoutErrata || key !== 'advisory_available')
.filter(([, value]) => value.hasColumn !== false)
.map(([key, value]) =>
<Checkbox
Expand Down Expand Up @@ -268,7 +269,8 @@ ReportConfigModal.propTypes = {
setReportTitle: propTypes.func,
inheritGlobalTags: propTypes.bool,
setInheritGlobalTags: propTypes.func,
globalFilterTags: propTypes.array
globalFilterTags: propTypes.array,
cvesWithoutErrata: propTypes.bool
};

export default ReportConfigModal;
Loading

0 comments on commit 1d8a227

Please sign in to comment.