mirror of
https://github.com/fleetdm/fleet
synced 2026-05-22 00:18:27 +00:00
Fleet UI: Fix dropdown from changing when vuln filters change (#27620)
This commit is contained in:
parent
6e32e31896
commit
eaa3ce071c
3 changed files with 18 additions and 9 deletions
|
|
@ -88,6 +88,7 @@ export const buildSoftwareFilterQueryParams = (
|
|||
}
|
||||
};
|
||||
|
||||
// TODO: Consider parsing SoftwarePage query params to change from type string
|
||||
export const getSoftwareFilterFromQueryParams = (queryParams: QueryParams) => {
|
||||
const { available_for_install, self_service } = queryParams;
|
||||
switch (true) {
|
||||
|
|
|
|||
|
|
@ -30,14 +30,17 @@ import SoftwareFiltersModal from "pages/SoftwarePage/components/SoftwareFiltersM
|
|||
import {
|
||||
buildSoftwareFilterQueryParams,
|
||||
buildSoftwareVulnFiltersQueryParams,
|
||||
getSoftwareFilterFromQueryParams,
|
||||
getSoftwareVulnFiltersFromQueryParams,
|
||||
ISoftwareVulnFiltersParams,
|
||||
} from "pages/SoftwarePage/SoftwareTitles/SoftwareTable/helpers";
|
||||
import { generateSoftwareTableHeaders as generateHostSoftwareTableConfig } from "./HostSoftwareTableConfig";
|
||||
import { generateSoftwareTableHeaders as generateDeviceSoftwareTableConfig } from "./DeviceSoftwareTableConfig";
|
||||
import HostSoftwareTable from "./HostSoftwareTable";
|
||||
import { getInstallErrorMessage, getUninstallErrorMessage } from "./helpers";
|
||||
import {
|
||||
getHostSoftwareFilterFromQueryParams,
|
||||
getInstallErrorMessage,
|
||||
getUninstallErrorMessage,
|
||||
} from "./helpers";
|
||||
|
||||
const baseClass = "software-card";
|
||||
|
||||
|
|
@ -131,7 +134,7 @@ const HostSoftware = ({
|
|||
|
||||
const isUnsupported =
|
||||
isAndroid(platform) || (isIPadOrIPhone(platform) && queryParams.vulnerable); // no Android software and no vulnerable software for iOS
|
||||
const softwareFilter = getSoftwareFilterFromQueryParams(queryParams);
|
||||
const softwareFilter = getHostSoftwareFilterFromQueryParams(queryParams);
|
||||
|
||||
// disables install/uninstall actions after click
|
||||
const [softwareIdActionPending, setSoftwareIdActionPending] = useState<
|
||||
|
|
@ -330,11 +333,6 @@ const HostSoftware = ({
|
|||
]
|
||||
);
|
||||
|
||||
const getHostSoftwareFilterFromQueryParams = useCallback(() => {
|
||||
const { available_for_install } = queryParams;
|
||||
return available_for_install ? "installableSoftware" : "allSoftware";
|
||||
}, [queryParams]);
|
||||
|
||||
const tableConfig = useMemo(() => {
|
||||
return isMyDevicePage
|
||||
? generateDeviceSoftwareTableConfig()
|
||||
|
|
@ -393,7 +391,7 @@ const HostSoftware = ({
|
|||
searchQuery={queryParams.query}
|
||||
page={queryParams.page}
|
||||
pagePath={pathname}
|
||||
hostSoftwareFilter={getHostSoftwareFilterFromQueryParams()}
|
||||
hostSoftwareFilter={softwareFilter}
|
||||
vulnFilters={getSoftwareVulnFiltersFromQueryParams(queryParams)}
|
||||
onAddFiltersClick={toggleSoftwareFiltersModal}
|
||||
pathPrefix={pathname}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import React from "react";
|
||||
import { QueryParams } from "utilities/url";
|
||||
import { getErrorReason } from "interfaces/errors";
|
||||
import { trimEnd, upperFirst } from "lodash";
|
||||
|
||||
|
|
@ -69,3 +70,12 @@ export const getUninstallErrorMessage = (e: unknown) => {
|
|||
|
||||
return DEFAULT_UNINSTALL_ERROR_MESSAGE;
|
||||
};
|
||||
|
||||
// available_for_install string > boolean conversion in parseHostSoftwareQueryParams
|
||||
export const getHostSoftwareFilterFromQueryParams = (
|
||||
queryParams: QueryParams
|
||||
) => {
|
||||
const { available_for_install } = queryParams;
|
||||
|
||||
return available_for_install ? "installableSoftware" : "allSoftware";
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue