2024-02-13 18:24:57 +00:00
|
|
|
/**
|
|
|
|
|
software/titles Software tab > Table
|
|
|
|
|
software/versions Software tab > Table (version toggle on)
|
|
|
|
|
*/
|
|
|
|
|
|
2024-05-09 21:44:50 +00:00
|
|
|
import React, { useCallback, useMemo } from "react";
|
2024-01-25 18:03:44 +00:00
|
|
|
import { InjectedRouter } from "react-router";
|
|
|
|
|
import { Row } from "react-table";
|
|
|
|
|
|
|
|
|
|
import PATHS from "router/paths";
|
|
|
|
|
import { getNextLocationPath } from "utilities/helpers";
|
2024-05-06 12:49:49 +00:00
|
|
|
import { GITHUB_NEW_ISSUE_LINK } from "utilities/constants";
|
2024-01-25 18:03:44 +00:00
|
|
|
import {
|
Update UI for software self-service features (#19244)
Issues https://github.com/fleetdm/fleet/issues/17587,
https://github.com/fleetdm/fleet/issues/18836,
https://github.com/fleetdm/fleet/issues/18837,
https://github.com/fleetdm/fleet/pull/18339, and
https://github.com/fleetdm/fleet/pull/18340
# TODOS
- Integrate backend
- Unit/integration tests
- Various todos noted in comments
- Cleanup styles and organization of components (de-duplicating and
consolidating where possible)
- Activity feed updates (if any)
# Checklist for submitter
If some of the following don't apply, delete the relevant line.
<!-- Note that API documentation changes are now addressed by the
product design team. -->
- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [ ] Added/updated tests
- [ ] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [ ] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [ ] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
---------
Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
2024-05-31 10:09:53 +00:00
|
|
|
buildQueryStringFromParams,
|
|
|
|
|
convertParamsToSnakeCase,
|
|
|
|
|
} from "utilities/url";
|
|
|
|
|
import {
|
|
|
|
|
ISoftwareApiParams,
|
2024-01-25 18:03:44 +00:00
|
|
|
ISoftwareTitlesResponse,
|
|
|
|
|
ISoftwareVersionsResponse,
|
|
|
|
|
} from "services/entities/software";
|
2024-07-18 09:20:17 +00:00
|
|
|
import { ISoftwareTitle, ISoftwareVersion } from "interfaces/software";
|
2024-01-25 18:03:44 +00:00
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
import Dropdown from "components/forms/fields/Dropdown";
|
|
|
|
|
import TableContainer from "components/TableContainer";
|
|
|
|
|
import Slider from "components/forms/fields/Slider";
|
|
|
|
|
import CustomLink from "components/CustomLink";
|
|
|
|
|
import LastUpdatedText from "components/LastUpdatedText";
|
|
|
|
|
import { ITableQueryData } from "components/TableContainer/TableContainer";
|
2024-06-14 17:12:56 +00:00
|
|
|
import TableCount from "components/TableContainer/TableCount";
|
2024-08-20 13:41:49 +00:00
|
|
|
import Button from "components/buttons/Button";
|
|
|
|
|
import Icon from "components/Icon";
|
|
|
|
|
import TooltipWrapper from "components/TooltipWrapper";
|
2024-01-25 18:03:44 +00:00
|
|
|
|
|
|
|
|
import EmptySoftwareTable from "pages/SoftwarePage/components/EmptySoftwareTable";
|
|
|
|
|
|
|
|
|
|
import generateTitlesTableConfig from "./SoftwareTitlesTableConfig";
|
|
|
|
|
import generateVersionsTableConfig from "./SoftwareVersionsTableConfig";
|
2024-05-06 12:49:49 +00:00
|
|
|
import {
|
|
|
|
|
ISoftwareDropdownFilterVal,
|
2024-08-20 13:41:49 +00:00
|
|
|
ISoftwareVulnFiltersParams,
|
2024-05-06 12:49:49 +00:00
|
|
|
SOFTWARE_TITLES_DROPDOWN_OPTIONS,
|
2024-08-21 13:43:27 +00:00
|
|
|
buildSoftwareFilterQueryParams,
|
|
|
|
|
buildSoftwareVulnFiltersQueryParams,
|
|
|
|
|
getVulnFilterRenderDetails,
|
2024-05-06 12:49:49 +00:00
|
|
|
} from "./helpers";
|
2024-01-25 18:03:44 +00:00
|
|
|
|
|
|
|
|
interface IRowProps extends Row {
|
|
|
|
|
original: {
|
|
|
|
|
id?: number;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ITableConfigGenerator = (router: InjectedRouter, teamId?: number) => void;
|
|
|
|
|
|
|
|
|
|
const isSoftwareTitles = (
|
|
|
|
|
data?: ISoftwareTitlesResponse | ISoftwareVersionsResponse
|
|
|
|
|
): data is ISoftwareTitlesResponse => {
|
|
|
|
|
if (!data) return false;
|
|
|
|
|
return (data as ISoftwareTitlesResponse).software_titles !== undefined;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
interface ISoftwareTableProps {
|
|
|
|
|
router: InjectedRouter;
|
|
|
|
|
data?: ISoftwareTitlesResponse | ISoftwareVersionsResponse;
|
|
|
|
|
showVersions: boolean;
|
2024-08-07 16:26:39 +00:00
|
|
|
installableSoftwareExists: boolean;
|
2024-01-25 18:03:44 +00:00
|
|
|
isSoftwareEnabled: boolean;
|
|
|
|
|
query: string;
|
|
|
|
|
perPage: number;
|
|
|
|
|
orderDirection: "asc" | "desc";
|
|
|
|
|
orderKey: string;
|
2024-05-06 12:49:49 +00:00
|
|
|
softwareFilter: ISoftwareDropdownFilterVal;
|
2024-08-20 13:41:49 +00:00
|
|
|
vulnFilters: ISoftwareVulnFiltersParams;
|
2024-01-25 18:03:44 +00:00
|
|
|
currentPage: number;
|
|
|
|
|
teamId?: number;
|
|
|
|
|
isLoading: boolean;
|
2024-06-03 13:42:34 +00:00
|
|
|
resetPageIndex: boolean;
|
2024-08-21 13:43:27 +00:00
|
|
|
onAddFiltersClick: () => void;
|
2024-01-25 18:03:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const baseClass = "software-table";
|
|
|
|
|
|
|
|
|
|
const SoftwareTable = ({
|
|
|
|
|
router,
|
|
|
|
|
data,
|
|
|
|
|
showVersions,
|
2024-08-07 16:26:39 +00:00
|
|
|
installableSoftwareExists,
|
2024-01-25 18:03:44 +00:00
|
|
|
isSoftwareEnabled,
|
|
|
|
|
query,
|
|
|
|
|
perPage,
|
|
|
|
|
orderDirection,
|
|
|
|
|
orderKey,
|
2024-05-06 12:49:49 +00:00
|
|
|
softwareFilter,
|
2024-08-20 13:41:49 +00:00
|
|
|
vulnFilters,
|
2024-01-25 18:03:44 +00:00
|
|
|
currentPage,
|
|
|
|
|
teamId,
|
|
|
|
|
isLoading,
|
2024-06-03 13:42:34 +00:00
|
|
|
resetPageIndex,
|
2024-08-21 13:43:27 +00:00
|
|
|
onAddFiltersClick,
|
2024-01-25 18:03:44 +00:00
|
|
|
}: ISoftwareTableProps) => {
|
|
|
|
|
const currentPath = showVersions
|
|
|
|
|
? PATHS.SOFTWARE_VERSIONS
|
|
|
|
|
: PATHS.SOFTWARE_TITLES;
|
|
|
|
|
|
|
|
|
|
const determineQueryParamChange = useCallback(
|
|
|
|
|
(newTableQuery: ITableQueryData) => {
|
|
|
|
|
const changedEntry = Object.entries(newTableQuery).find(([key, val]) => {
|
|
|
|
|
switch (key) {
|
|
|
|
|
case "searchQuery":
|
|
|
|
|
return val !== query;
|
|
|
|
|
case "sortDirection":
|
|
|
|
|
return val !== orderDirection;
|
|
|
|
|
case "sortHeader":
|
|
|
|
|
return val !== orderKey;
|
|
|
|
|
case "pageIndex":
|
|
|
|
|
return val !== currentPage;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return changedEntry?.[0] ?? "";
|
|
|
|
|
},
|
2024-05-06 12:49:49 +00:00
|
|
|
[currentPage, orderDirection, orderKey, query]
|
2024-01-25 18:03:44 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const generateNewQueryParams = useCallback(
|
|
|
|
|
(newTableQuery: ITableQueryData, changedParam: string) => {
|
2024-05-06 12:49:49 +00:00
|
|
|
const newQueryParam: Record<string, string | number | undefined> = {
|
2024-01-25 18:03:44 +00:00
|
|
|
query: newTableQuery.searchQuery,
|
|
|
|
|
team_id: teamId,
|
|
|
|
|
order_direction: newTableQuery.sortDirection,
|
|
|
|
|
order_key: newTableQuery.sortHeader,
|
|
|
|
|
page: changedParam === "pageIndex" ? newTableQuery.pageIndex : 0,
|
2024-08-21 13:43:27 +00:00
|
|
|
...buildSoftwareVulnFiltersQueryParams(vulnFilters),
|
2024-01-25 18:03:44 +00:00
|
|
|
};
|
2024-05-06 12:49:49 +00:00
|
|
|
if (softwareFilter === "installableSoftware") {
|
|
|
|
|
newQueryParam.available_for_install = true.toString();
|
2024-08-20 13:41:49 +00:00
|
|
|
}
|
|
|
|
|
if (softwareFilter === "selfServiceSoftware") {
|
|
|
|
|
newQueryParam.self_service = true.toString();
|
2024-05-06 12:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
2024-08-21 13:43:27 +00:00
|
|
|
return newQueryParam;
|
2024-01-25 18:03:44 +00:00
|
|
|
},
|
2024-08-20 13:41:49 +00:00
|
|
|
[softwareFilter, teamId, vulnFilters]
|
2024-01-25 18:03:44 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// NOTE: this is called once on initial render and every time the query changes
|
|
|
|
|
const onQueryChange = useCallback(
|
|
|
|
|
(newTableQuery: ITableQueryData) => {
|
|
|
|
|
// we want to determine which query param has changed in order to
|
|
|
|
|
// reset the page index to 0 if any other param has changed.
|
|
|
|
|
const changedParam = determineQueryParamChange(newTableQuery);
|
|
|
|
|
|
|
|
|
|
// if nothing has changed, don't update the route. this can happen when
|
2024-05-06 12:49:49 +00:00
|
|
|
// this handler is called on the inital render. Can also happen when
|
|
|
|
|
// the filter dropdown is changed. That is handled on the onChange handler
|
|
|
|
|
// for the dropdown.
|
2024-01-25 18:03:44 +00:00
|
|
|
if (changedParam === "") return;
|
|
|
|
|
|
|
|
|
|
const newRoute = getNextLocationPath({
|
|
|
|
|
pathPrefix: currentPath,
|
|
|
|
|
routeTemplate: "",
|
|
|
|
|
queryParams: generateNewQueryParams(newTableQuery, changedParam),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
router.replace(newRoute);
|
|
|
|
|
},
|
|
|
|
|
[determineQueryParamChange, generateNewQueryParams, router, currentPath]
|
|
|
|
|
);
|
|
|
|
|
|
2024-07-18 09:20:17 +00:00
|
|
|
let tableData: ISoftwareTitle[] | ISoftwareVersion[] | undefined;
|
2024-01-25 18:03:44 +00:00
|
|
|
let generateTableConfig: ITableConfigGenerator;
|
|
|
|
|
|
|
|
|
|
if (data === undefined) {
|
|
|
|
|
tableData;
|
|
|
|
|
generateTableConfig = () => [];
|
|
|
|
|
} else if (isSoftwareTitles(data)) {
|
|
|
|
|
tableData = data.software_titles;
|
|
|
|
|
generateTableConfig = generateTitlesTableConfig;
|
|
|
|
|
} else {
|
|
|
|
|
tableData = data.software;
|
|
|
|
|
generateTableConfig = generateVersionsTableConfig;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const softwareTableHeaders = useMemo(() => {
|
|
|
|
|
if (!data) return [];
|
|
|
|
|
return generateTableConfig(router, teamId);
|
|
|
|
|
}, [generateTableConfig, data, router, teamId]);
|
|
|
|
|
|
2024-08-20 13:41:49 +00:00
|
|
|
// Determines if a user should be able to filter or search in the table
|
|
|
|
|
const hasData = tableData && tableData.length > 0;
|
|
|
|
|
const hasQuery = query !== "";
|
|
|
|
|
const hasSoftwareFilter = softwareFilter !== "allSoftware";
|
|
|
|
|
const hasVersionFilter = showVersions;
|
2024-08-21 13:43:27 +00:00
|
|
|
const vulnFilterDetails = getVulnFilterRenderDetails(vulnFilters);
|
|
|
|
|
const hasVulnFilters = vulnFilterDetails.filterCount > 0;
|
2024-08-20 13:41:49 +00:00
|
|
|
|
|
|
|
|
const showFilterHeaders =
|
|
|
|
|
isSoftwareEnabled &&
|
|
|
|
|
(hasData ||
|
|
|
|
|
hasQuery ||
|
|
|
|
|
hasSoftwareFilter ||
|
|
|
|
|
hasVersionFilter ||
|
|
|
|
|
hasVulnFilters);
|
2024-01-25 18:03:44 +00:00
|
|
|
|
|
|
|
|
const handleShowVersionsToggle = () => {
|
2024-08-20 13:41:49 +00:00
|
|
|
const queryParams: Record<string, string | number | boolean | undefined> = {
|
2024-05-06 12:49:49 +00:00
|
|
|
query,
|
|
|
|
|
team_id: teamId,
|
|
|
|
|
order_direction: orderDirection,
|
|
|
|
|
order_key: orderKey,
|
|
|
|
|
page: 0, // resets page index
|
2024-08-21 13:43:27 +00:00
|
|
|
...buildSoftwareFilterQueryParams("allSoftware"), // Reset to all software
|
|
|
|
|
...buildSoftwareVulnFiltersQueryParams(vulnFilters),
|
2024-05-06 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
2024-01-25 18:03:44 +00:00
|
|
|
router.replace(
|
|
|
|
|
getNextLocationPath({
|
|
|
|
|
pathPrefix: showVersions
|
|
|
|
|
? PATHS.SOFTWARE_TITLES
|
|
|
|
|
: PATHS.SOFTWARE_VERSIONS,
|
|
|
|
|
routeTemplate: "",
|
2024-05-06 12:49:49 +00:00
|
|
|
queryParams,
|
2024-01-25 18:03:44 +00:00
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
Update UI for software self-service features (#19244)
Issues https://github.com/fleetdm/fleet/issues/17587,
https://github.com/fleetdm/fleet/issues/18836,
https://github.com/fleetdm/fleet/issues/18837,
https://github.com/fleetdm/fleet/pull/18339, and
https://github.com/fleetdm/fleet/pull/18340
# TODOS
- Integrate backend
- Unit/integration tests
- Various todos noted in comments
- Cleanup styles and organization of components (de-duplicating and
consolidating where possible)
- Activity feed updates (if any)
# Checklist for submitter
If some of the following don't apply, delete the relevant line.
<!-- Note that API documentation changes are now addressed by the
product design team. -->
- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [ ] Added/updated tests
- [ ] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [ ] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [ ] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
---------
Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
2024-05-31 10:09:53 +00:00
|
|
|
const handleCustomFilterDropdownChange = (
|
2024-05-06 12:49:49 +00:00
|
|
|
value: ISoftwareDropdownFilterVal
|
|
|
|
|
) => {
|
Update UI for software self-service features (#19244)
Issues https://github.com/fleetdm/fleet/issues/17587,
https://github.com/fleetdm/fleet/issues/18836,
https://github.com/fleetdm/fleet/issues/18837,
https://github.com/fleetdm/fleet/pull/18339, and
https://github.com/fleetdm/fleet/pull/18340
# TODOS
- Integrate backend
- Unit/integration tests
- Various todos noted in comments
- Cleanup styles and organization of components (de-duplicating and
consolidating where possible)
- Activity feed updates (if any)
# Checklist for submitter
If some of the following don't apply, delete the relevant line.
<!-- Note that API documentation changes are now addressed by the
product design team. -->
- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [ ] Added/updated tests
- [ ] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [ ] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [ ] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
---------
Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
2024-05-31 10:09:53 +00:00
|
|
|
const queryParams: ISoftwareApiParams = {
|
2024-05-06 12:49:49 +00:00
|
|
|
query,
|
Update UI for software self-service features (#19244)
Issues https://github.com/fleetdm/fleet/issues/17587,
https://github.com/fleetdm/fleet/issues/18836,
https://github.com/fleetdm/fleet/issues/18837,
https://github.com/fleetdm/fleet/pull/18339, and
https://github.com/fleetdm/fleet/pull/18340
# TODOS
- Integrate backend
- Unit/integration tests
- Various todos noted in comments
- Cleanup styles and organization of components (de-duplicating and
consolidating where possible)
- Activity feed updates (if any)
# Checklist for submitter
If some of the following don't apply, delete the relevant line.
<!-- Note that API documentation changes are now addressed by the
product design team. -->
- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [ ] Added/updated tests
- [ ] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [ ] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [ ] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
---------
Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
2024-05-31 10:09:53 +00:00
|
|
|
teamId,
|
|
|
|
|
orderDirection,
|
|
|
|
|
orderKey,
|
2024-05-06 12:49:49 +00:00
|
|
|
page: 0, // resets page index
|
2024-08-21 13:43:27 +00:00
|
|
|
...buildSoftwareVulnFiltersQueryParams(vulnFilters),
|
|
|
|
|
...buildSoftwareFilterQueryParams(value),
|
2024-05-06 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
2024-01-25 18:03:44 +00:00
|
|
|
router.replace(
|
|
|
|
|
getNextLocationPath({
|
|
|
|
|
pathPrefix: currentPath,
|
|
|
|
|
routeTemplate: "",
|
Update UI for software self-service features (#19244)
Issues https://github.com/fleetdm/fleet/issues/17587,
https://github.com/fleetdm/fleet/issues/18836,
https://github.com/fleetdm/fleet/issues/18837,
https://github.com/fleetdm/fleet/pull/18339, and
https://github.com/fleetdm/fleet/pull/18340
# TODOS
- Integrate backend
- Unit/integration tests
- Various todos noted in comments
- Cleanup styles and organization of components (de-duplicating and
consolidating where possible)
- Activity feed updates (if any)
# Checklist for submitter
If some of the following don't apply, delete the relevant line.
<!-- Note that API documentation changes are now addressed by the
product design team. -->
- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [ ] Added/updated tests
- [ ] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [ ] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [ ] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
---------
Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
2024-05-31 10:09:53 +00:00
|
|
|
queryParams: convertParamsToSnakeCase(queryParams),
|
2024-01-25 18:03:44 +00:00
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleRowSelect = (row: IRowProps) => {
|
2024-09-30 11:34:43 +00:00
|
|
|
const queryParams = showVersions
|
|
|
|
|
? buildQueryStringFromParams({
|
2024-01-25 18:03:44 +00:00
|
|
|
software_version_id: row.original.id,
|
|
|
|
|
team_id: teamId,
|
2024-09-30 11:34:43 +00:00
|
|
|
})
|
|
|
|
|
: buildQueryStringFromParams({
|
2024-01-25 18:03:44 +00:00
|
|
|
software_title_id: row.original.id,
|
|
|
|
|
team_id: teamId,
|
2024-09-30 11:34:43 +00:00
|
|
|
});
|
2024-01-25 18:03:44 +00:00
|
|
|
|
2024-09-30 11:34:43 +00:00
|
|
|
const path = `${PATHS.MANAGE_HOSTS}?${queryParams}`;
|
2024-01-25 18:03:44 +00:00
|
|
|
|
|
|
|
|
router.push(path);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const renderSoftwareCount = () => {
|
2024-08-30 23:12:19 +00:00
|
|
|
if (!tableData || !data) return null;
|
2024-01-25 18:03:44 +00:00
|
|
|
|
|
|
|
|
return (
|
2024-06-14 17:12:56 +00:00
|
|
|
<>
|
|
|
|
|
<TableCount name="items" count={data?.count} />
|
|
|
|
|
{tableData && data?.counts_updated_at && (
|
|
|
|
|
<LastUpdatedText
|
|
|
|
|
lastUpdatedAt={data.counts_updated_at}
|
2024-06-27 13:41:35 +00:00
|
|
|
customTooltipText={
|
|
|
|
|
<>
|
|
|
|
|
The last time software data was <br />
|
|
|
|
|
updated, including vulnerabilities <br />
|
|
|
|
|
and host counts.
|
|
|
|
|
</>
|
|
|
|
|
}
|
2024-06-14 17:12:56 +00:00
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
2024-01-25 18:03:44 +00:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2024-08-20 13:41:49 +00:00
|
|
|
const renderCustomControls = () => {
|
2024-01-25 18:03:44 +00:00
|
|
|
return (
|
|
|
|
|
<div className={`${baseClass}__filter-controls`}>
|
2024-08-20 13:41:49 +00:00
|
|
|
{!showVersions && ( // Hidden when viewing versions table
|
|
|
|
|
<Dropdown
|
|
|
|
|
value={softwareFilter}
|
|
|
|
|
className={`${baseClass}__vuln_dropdown`}
|
2024-08-21 13:43:27 +00:00
|
|
|
options={SOFTWARE_TITLES_DROPDOWN_OPTIONS}
|
2024-08-20 13:41:49 +00:00
|
|
|
searchable={false}
|
|
|
|
|
onChange={handleCustomFilterDropdownChange}
|
2024-09-17 17:10:34 +00:00
|
|
|
iconName="filter"
|
2024-01-25 18:03:44 +00:00
|
|
|
/>
|
2024-08-20 13:41:49 +00:00
|
|
|
)}
|
|
|
|
|
<Slider
|
|
|
|
|
value={showVersions}
|
|
|
|
|
onChange={handleShowVersionsToggle}
|
|
|
|
|
inactiveText="Show versions"
|
|
|
|
|
activeText="Show versions"
|
2024-01-25 18:03:44 +00:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2024-08-21 13:43:27 +00:00
|
|
|
const renderCustomFiltersButton = () => {
|
2024-08-20 13:41:49 +00:00
|
|
|
return (
|
|
|
|
|
<TooltipWrapper
|
|
|
|
|
className={`${baseClass}__filters`}
|
|
|
|
|
position="left"
|
|
|
|
|
underline={false}
|
|
|
|
|
showArrow
|
|
|
|
|
tipOffset={12}
|
|
|
|
|
tipContent={vulnFilterDetails.tooltipText}
|
2024-08-21 13:43:27 +00:00
|
|
|
disableTooltip={!hasVulnFilters}
|
2024-08-20 13:41:49 +00:00
|
|
|
>
|
2024-08-21 13:43:27 +00:00
|
|
|
<Button variant="text-link" onClick={onAddFiltersClick}>
|
2024-08-20 13:41:49 +00:00
|
|
|
<Icon name="filter" color="core-fleet-blue" />
|
|
|
|
|
<span>{vulnFilterDetails.buttonText}</span>
|
|
|
|
|
</Button>
|
|
|
|
|
</TooltipWrapper>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2024-08-21 20:12:42 +00:00
|
|
|
const renderTableHelpText = () => (
|
|
|
|
|
<div>
|
|
|
|
|
Seeing unexpected software or vulnerabilities?{" "}
|
|
|
|
|
<CustomLink
|
|
|
|
|
url={GITHUB_NEW_ISSUE_LINK}
|
|
|
|
|
text="File an issue on GitHub"
|
|
|
|
|
newTab
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2024-01-25 18:03:44 +00:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={baseClass}>
|
|
|
|
|
<TableContainer
|
|
|
|
|
columnConfigs={softwareTableHeaders}
|
|
|
|
|
data={tableData ?? []}
|
|
|
|
|
isLoading={isLoading}
|
2024-02-23 14:57:18 +00:00
|
|
|
resultsTitle="items"
|
2024-01-25 18:03:44 +00:00
|
|
|
emptyComponent={() => (
|
|
|
|
|
<EmptySoftwareTable
|
2024-05-06 12:49:49 +00:00
|
|
|
softwareFilter={softwareFilter}
|
2024-08-20 13:41:49 +00:00
|
|
|
vulnFilters={vulnFilters}
|
2024-01-25 18:03:44 +00:00
|
|
|
isSoftwareDisabled={!isSoftwareEnabled}
|
2024-08-06 22:29:15 +00:00
|
|
|
noSearchQuery={query === ""}
|
2024-08-07 16:26:39 +00:00
|
|
|
installableSoftwareExists={installableSoftwareExists}
|
2024-01-25 18:03:44 +00:00
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
defaultSortHeader={orderKey}
|
|
|
|
|
defaultSortDirection={orderDirection}
|
|
|
|
|
defaultPageIndex={currentPage}
|
|
|
|
|
defaultSearchQuery={query}
|
|
|
|
|
manualSortBy
|
|
|
|
|
pageSize={perPage}
|
|
|
|
|
showMarkAllPages={false}
|
|
|
|
|
isAllPagesSelected={false}
|
|
|
|
|
disableNextPage={!data?.meta.has_next_results}
|
2024-08-20 13:41:49 +00:00
|
|
|
searchable={showFilterHeaders}
|
|
|
|
|
inputPlaceHolder="Search by name or vulnerability (CVE)"
|
2024-01-25 18:03:44 +00:00
|
|
|
onQueryChange={onQueryChange}
|
|
|
|
|
// additionalQueries serves as a trigger for the useDeepEffect hook
|
2024-10-16 15:02:06 +00:00
|
|
|
// to fire onQueryChange for events happening outside of
|
2024-01-25 18:03:44 +00:00
|
|
|
// the TableContainer.
|
2024-05-06 12:49:49 +00:00
|
|
|
// additionalQueries={softwareFilter}
|
2024-08-20 13:41:49 +00:00
|
|
|
customControl={showFilterHeaders ? renderCustomControls : undefined}
|
2024-08-21 13:43:27 +00:00
|
|
|
customFiltersButton={
|
|
|
|
|
showFilterHeaders ? renderCustomFiltersButton : undefined
|
|
|
|
|
}
|
2024-01-25 18:03:44 +00:00
|
|
|
stackControls
|
|
|
|
|
renderCount={renderSoftwareCount}
|
2024-08-21 20:12:42 +00:00
|
|
|
renderTableHelpText={renderTableHelpText}
|
2024-01-25 18:03:44 +00:00
|
|
|
disableMultiRowSelect
|
|
|
|
|
onSelectSingleRow={handleRowSelect}
|
2024-06-03 13:42:34 +00:00
|
|
|
resetPageIndex={resetPageIndex}
|
2024-01-25 18:03:44 +00:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default SoftwareTable;
|