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>
77 lines
2.1 KiB
TypeScript
77 lines
2.1 KiB
TypeScript
import { HumanTimeDiffWithFleetLaunchCutoff } from "components/HumanTimeDiffWithDateTip";
|
|
import Icon from "components/Icon";
|
|
import React from "react";
|
|
import { IScriptBatchSummaryV2 } from "services/entities/scripts";
|
|
|
|
import { isDateTimePast } from "utilities/helpers";
|
|
|
|
const getWhen = (summary: IScriptBatchSummaryV2) => {
|
|
const {
|
|
batch_execution_id: id,
|
|
not_before,
|
|
started_at,
|
|
finished_at,
|
|
canceled,
|
|
} = summary;
|
|
switch (summary.status) {
|
|
case "started":
|
|
if (!started_at || !isDateTimePast(started_at)) {
|
|
console.warn(
|
|
`Batch run with execution id ${id} is marked as 'started' but has no past 'started_at'`
|
|
);
|
|
return null;
|
|
}
|
|
return (
|
|
<>
|
|
<Icon name="pending-outline" color="ui-fleet-black-50" size="small" />
|
|
Started{" "}
|
|
<HumanTimeDiffWithFleetLaunchCutoff
|
|
timeString={started_at}
|
|
tooltipPosition="right"
|
|
/>
|
|
</>
|
|
);
|
|
case "scheduled":
|
|
if (!not_before || isDateTimePast(not_before)) {
|
|
console.warn(
|
|
`Batch run with execution id ${id} is marked as 'scheduled' but has no future scheduled start time`
|
|
);
|
|
return null;
|
|
}
|
|
return (
|
|
<>
|
|
<Icon name="clock" color="ui-fleet-black-50" size="small" />
|
|
Will start{" "}
|
|
<HumanTimeDiffWithFleetLaunchCutoff
|
|
timeString={not_before}
|
|
tooltipPosition="right"
|
|
/>
|
|
</>
|
|
);
|
|
case "finished":
|
|
if (!finished_at || !isDateTimePast(finished_at)) {
|
|
console.warn(
|
|
`Batch run with execution id ${id} is marked as 'finished' but has no past 'finished_at' data`
|
|
);
|
|
return null;
|
|
}
|
|
return (
|
|
<>
|
|
<Icon
|
|
name={canceled ? "close-filled" : "success"}
|
|
color="ui-fleet-black-50"
|
|
size="small"
|
|
/>
|
|
{canceled ? "Canceled" : "Completed"}
|
|
<HumanTimeDiffWithFleetLaunchCutoff
|
|
timeString={finished_at}
|
|
tooltipPosition="right"
|
|
/>
|
|
</>
|
|
);
|
|
default:
|
|
return null;
|
|
}
|
|
};
|
|
|
|
export default getWhen;
|