From 7b7dd17772e07ac818828b52562c474aebcc2418 Mon Sep 17 00:00:00 2001 From: Scott Gress Date: Wed, 29 Oct 2025 17:56:45 -0500 Subject: [PATCH] Add host link on scheduled query report table (#34971) **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 --- .../components/QueryReport/QueryReport.tsx | 4 +++- .../QueryReport/QueryReportTableConfig.tsx | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/frontend/pages/queries/details/components/QueryReport/QueryReport.tsx b/frontend/pages/queries/details/components/QueryReport/QueryReport.tsx index 93a97f9983..827a53dd0d 100644 --- a/frontend/pages/queries/details/components/QueryReport/QueryReport.tsx +++ b/frontend/pages/queries/details/components/QueryReport/QueryReport.tsx @@ -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 diff --git a/frontend/pages/queries/details/components/QueryReport/QueryReportTableConfig.tsx b/frontend/pages/queries/details/components/QueryReport/QueryReportTableConfig.tsx index 7fefa10f85..1a7af70128 100644 --- a/frontend/pages/queries/details/components/QueryReport/QueryReportTableConfig.tsx +++ b/frontend/pages/queries/details/components/QueryReport/QueryReportTableConfig.tsx @@ -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; type ITableHeaderProps = IHeaderProps; type ITableCellProps = CellProps; @@ -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 ( + + ); + } // Sorts chronologically by date, but UI displays readable last fetched if (cellProps.column.id === "last_fetched") {