[unreleased bug] Fleet UI: Hide exploit/severity vuln filters for fleet free (#21511)

This commit is contained in:
RachelElysia 2024-08-23 12:02:21 -04:00 committed by GitHub
parent 6b42d7c45a
commit cfafb92c2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 23 deletions

View file

@ -37,7 +37,6 @@ import AddSoftwareModal from "./components/AddSoftwareModal";
import {
buildSoftwareFilterQueryParams,
getSoftwareFilterFromQueryParams,
buildSoftwareVulnFiltersQueryParams,
getSoftwareVulnFiltersFromQueryParams,
ISoftwareVulnFilters,
} from "./SoftwareTitles/SoftwareTable/helpers";
@ -485,6 +484,7 @@ const SoftwarePage = ({ children, router, location }: ISoftwarePageProps) => {
onExit={toggleSoftwareFiltersModal}
onSubmit={onApplyVulnFilters}
vulnFilters={softwareVulnFilters}
isPremiumTier={isPremiumTier || false}
/>
)}
</div>

View file

@ -20,12 +20,14 @@ interface ISoftwareFiltersModalProps {
onExit: () => void;
onSubmit: (vulnFilters: ISoftwareVulnFilters) => void;
vulnFilters: ISoftwareVulnFiltersParams;
isPremiumTier: boolean;
}
const SoftwareFiltersModal = ({
onExit,
onSubmit,
vulnFilters,
isPremiumTier,
}: ISoftwareFiltersModalProps) => {
const [vulnSoftwareFilterEnabled, setVulnSoftwareFilterEnabled] = useState(
vulnFilters.vulnerable || false
@ -50,7 +52,7 @@ const SoftwareFiltersModal = ({
const onApplyFilters = () => {
onSubmit({
vulnerable: vulnSoftwareFilterEnabled,
exploit: hasKnownExploit,
exploit: hasKnownExploit || undefined,
min_cvss_score: severity?.minSeverity || undefined,
max_cvss_score: severity?.maxSeverity || undefined,
});
@ -78,27 +80,31 @@ const SoftwareFiltersModal = ({
inactiveText="Vulnerable software"
activeText="Vulnerable software"
/>
<Dropdown
label={renderSeverityLabel()}
options={SEVERITY_DROPDOWN_OPTIONS}
value={severity}
onChange={onChangeSeverity}
placeholder="Any severity"
className={`${baseClass}__select-severity`}
disabled={!vulnSoftwareFilterEnabled}
/>
<Checkbox
onChange={({ value }: { value: boolean }) =>
setHasKnownExploit(value)
}
name="hasKnownExploit"
value={hasKnownExploit}
parseTarget
helpText="Software has vulnerabilities that have been actively exploited in the wild."
disabled={!vulnSoftwareFilterEnabled}
>
Has known exploit
</Checkbox>
{isPremiumTier && (
<Dropdown
label={renderSeverityLabel()}
options={SEVERITY_DROPDOWN_OPTIONS}
value={severity}
onChange={onChangeSeverity}
placeholder="Any severity"
className={`${baseClass}__select-severity`}
disabled={!vulnSoftwareFilterEnabled}
/>
)}
{isPremiumTier && (
<Checkbox
onChange={({ value }: { value: boolean }) =>
setHasKnownExploit(value)
}
name="hasKnownExploit"
value={hasKnownExploit}
parseTarget
helpText="Software has vulnerabilities that have been actively exploited in the wild."
disabled={!vulnSoftwareFilterEnabled}
>
Has known exploit
</Checkbox>
)}
<div className="modal-cta-wrap">
<Button variant="brand" onClick={onApplyFilters}>
Apply