mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
Add host link on scheduled query report table (#34971)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #33249 # Details This PR makes the host names in the scheduled query report link to the respective host query reports. The requirement of having the host names in the live query report link to the host details page was already fulfilled in #34019. # Checklist for submitter If some of the following don't apply, delete the relevant line. ## Testing - [ ] Added/updated automated tests trying but it's tricky to test a `Link` component's `href` without a router. - [X] QA'd all new/changed functionality manually For unreleased bug fixes in a release candidate, one of: - [X] Confirmed that the fix is not expected to adversely impact load test results
This commit is contained in:
parent
abc1040f4b
commit
7b7dd17772
2 changed files with 20 additions and 2 deletions
|
|
@ -31,6 +31,7 @@ const CSV_TITLE = "Query";
|
|||
const flattenResults = (results: IQueryReportResultRow[]) => {
|
||||
return results.map((result: IQueryReportResultRow) => {
|
||||
const hostInfoColumns = {
|
||||
host_id: result.host_id,
|
||||
host_display_name: result.host_name,
|
||||
last_fetched: result.last_fetched,
|
||||
};
|
||||
|
|
@ -55,7 +56,8 @@ const QueryReport = ({
|
|||
useEffect(() => {
|
||||
if (queryReport && queryReport.results && queryReport.results.length > 0) {
|
||||
const newColumnConfigs = generateReportColumnConfigsFromResults(
|
||||
flattenResults(queryReport.results)
|
||||
flattenResults(queryReport.results),
|
||||
queryReport.query_id
|
||||
);
|
||||
|
||||
// Update tableHeaders if new headers are found
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ import {
|
|||
} from "utilities/helpers";
|
||||
import { IHeaderProps, IWebSocketData } from "interfaces/datatable_config";
|
||||
|
||||
import PATHS from "router/paths";
|
||||
import LinkCell from "components/TableContainer/DataTable/LinkCell";
|
||||
|
||||
type IQueryReportTableColumnConfig = Column<IWebSocketData>;
|
||||
type ITableHeaderProps = IHeaderProps<IWebSocketData>;
|
||||
type ITableCellProps = CellProps<IWebSocketData, string | unknown>;
|
||||
|
|
@ -40,7 +43,8 @@ const _unshiftHostname = (headers: IQueryReportTableColumnConfig[]) => {
|
|||
};
|
||||
|
||||
const generateReportColumnConfigsFromResults = (
|
||||
results: IWebSocketData[]
|
||||
results: IWebSocketData[],
|
||||
queryId: number | null
|
||||
): IQueryReportTableColumnConfig[] => {
|
||||
const colsAreNumTypes = getUniqueColsAreNumTypeFromRows(results) as Map<
|
||||
string,
|
||||
|
|
@ -64,6 +68,18 @@ const generateReportColumnConfigsFromResults = (
|
|||
accessor: (data) => data[colName],
|
||||
Cell: (cellProps: ITableCellProps) => {
|
||||
if (typeof cellProps.cell.value !== "string") return null;
|
||||
if (cellProps.column.id === "Host") {
|
||||
const hostID = cellProps.row.original.host_id as number;
|
||||
if (queryId === null) {
|
||||
return cellProps.cell.value;
|
||||
}
|
||||
return (
|
||||
<LinkCell
|
||||
value={cellProps.cell.value}
|
||||
path={PATHS.HOST_QUERY_REPORT(hostID, queryId)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// Sorts chronologically by date, but UI displays readable last fetched
|
||||
if (cellProps.column.id === "last_fetched") {
|
||||
|
|
|
|||
Loading…
Reference in a new issue