mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
## For #31226 New features: - Dynamic header for each possible state of a batch script run: Started, Scheduled, and Finished (corresponds to tabs at `/controls/scripts/progress` - Unique tabs for each possible status of hosts targeted by a batch script run: Ran, Errored, Pending, Incompatible, Canceled. - Within each tab, sortable, paginated host results with output preview and execution time. - View script/run details, cancel a batch, view manage hosts page filtered for the script batch run and a status. - Global script batch runs activities and and Scripts progress rows now navigate to this details page. Cleanups and improvements: - Expand tab count badge options using “alert”/“pending” variants across hosts, policies, and query results. - Misc cleanups and improvements  - [x] Changes file added for user-visible changes in `changes/`, - [x] Updated automated tests - new tests tracked for follow-up work - [x] QA'd all new/changed functionality manually --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
110 lines
3.3 KiB
TypeScript
110 lines
3.3 KiB
TypeScript
import React from "react";
|
|
|
|
import PATHS from "router/paths";
|
|
|
|
import {
|
|
SCRIPT_BATCH_HOST_EXECUTED_STATUSES,
|
|
SCRIPT_BATCH_HOST_NOT_EXECUTED_STATUSES,
|
|
ScriptBatchHostStatus,
|
|
} from "interfaces/script";
|
|
import { IScriptBatchHostResult } from "services/entities/scripts";
|
|
|
|
import { IHeaderProps, IStringCellProps } from "interfaces/datatable_config";
|
|
|
|
import TextCell from "components/TableContainer/DataTable/TextCell";
|
|
import HeaderCell from "components/TableContainer/DataTable/HeaderCell";
|
|
import { HumanTimeDiffWithDateTip } from "components/HumanTimeDiffWithDateTip";
|
|
import ViewAllHostsLink from "components/ViewAllHostsLink";
|
|
import { CellProps, Column } from "react-table";
|
|
import TooltipTruncatedText from "components/TooltipTruncatedText";
|
|
import LinkCell from "components/TableContainer/DataTable/LinkCell";
|
|
|
|
type IScriptBatchHostsTableConfig = Column<IScriptBatchHostResult>;
|
|
type ITableHeaderProps = IHeaderProps<IScriptBatchHostResult>;
|
|
type ITableStringCellProps = IStringCellProps<IScriptBatchHostResult>;
|
|
type ITimeCellProps = CellProps<IScriptBatchHostResult>;
|
|
|
|
const ScriptOutputCell = (cellProps: CellProps<IScriptBatchHostResult>) => {
|
|
return (
|
|
<span className="script-output-cell">
|
|
<TooltipTruncatedText
|
|
value={cellProps.row.original.script_output_preview}
|
|
/>
|
|
<ViewAllHostsLink
|
|
customText="View script details"
|
|
rowHover
|
|
noLink
|
|
responsive
|
|
/>
|
|
</span>
|
|
);
|
|
};
|
|
|
|
const generateColumnConfigs = (
|
|
hostStatus: ScriptBatchHostStatus
|
|
): IScriptBatchHostsTableConfig[] => {
|
|
let columns: IScriptBatchHostsTableConfig[] = [
|
|
{
|
|
Header: (cellProps: ITableHeaderProps) => (
|
|
<HeaderCell
|
|
value="Host name"
|
|
isSortedDesc={cellProps.column.isSortedDesc}
|
|
/>
|
|
),
|
|
accessor: "display_name",
|
|
Cell: (cellProps: ITableStringCellProps) => (
|
|
<span className="host-name-cell">
|
|
<LinkCell
|
|
value={cellProps.row.original.display_name}
|
|
path={PATHS.HOST_DETAILS(cellProps.row.original.id)}
|
|
customOnClick={(e) => {
|
|
e.stopPropagation();
|
|
}}
|
|
/>
|
|
{SCRIPT_BATCH_HOST_NOT_EXECUTED_STATUSES.includes(hostStatus) && (
|
|
<ViewAllHostsLink
|
|
customText="View host details"
|
|
rowHover
|
|
noLink
|
|
responsive
|
|
/>
|
|
)}
|
|
</span>
|
|
),
|
|
},
|
|
];
|
|
|
|
if (SCRIPT_BATCH_HOST_EXECUTED_STATUSES.includes(hostStatus)) {
|
|
columns = columns.concat([
|
|
{
|
|
Header: (cellProps: ITableHeaderProps) => (
|
|
<HeaderCell
|
|
value="Time"
|
|
disableSortBy={false}
|
|
isSortedDesc={cellProps.column.isSortedDesc}
|
|
/>
|
|
),
|
|
accessor: "script_executed_at",
|
|
Cell: (cellProps: ITimeCellProps) => (
|
|
<TextCell
|
|
value={
|
|
<HumanTimeDiffWithDateTip
|
|
timeString={cellProps.row.original.script_executed_at ?? ""}
|
|
/>
|
|
}
|
|
/>
|
|
),
|
|
},
|
|
{
|
|
Header: "Script output",
|
|
disableSortBy: true,
|
|
accessor: "script_output_preview",
|
|
Cell: (cellProps: any) => <ScriptOutputCell {...cellProps} />,
|
|
},
|
|
]);
|
|
}
|
|
|
|
return columns;
|
|
};
|
|
|
|
export default generateColumnConfigs;
|