2024-02-07 21:32:51 +00:00
import { HOST_LINUX_PLATFORMS } from "./platform" ;
2024-01-29 14:37:54 +00:00
export interface IScript {
id : number ;
team_id : number | null ;
name : string ;
created_at : string ;
updated_at : string ;
}
2024-02-07 21:32:51 +00:00
export const isScriptSupportedPlatform = ( hostPlatform : string ) = >
2025-02-26 18:03:56 +00:00
[ "darwin" , "windows" , . . . HOST_LINUX_PLATFORMS ] . includes ( hostPlatform ) ; // excludes chrome, ios, ipados, android see also https://github.com/fleetdm/fleet/blob/5a21e2cfb029053ddad0508869eb9f1f23997bf2/server/fleet/hosts.go#L775
2024-01-29 14:37:54 +00:00
2025-06-23 17:03:22 +00:00
export const addTeamIdCriteria = (
pred : any ,
teamId : number ,
isFreeTier? : boolean
) = > ( isFreeTier ? { . . . pred } : { . . . pred , team_id : teamId } ) ;
2024-01-29 14:37:54 +00:00
export type IScriptExecutionStatus = "ran" | "pending" | "error" ;
export interface ILastExecution {
execution_id : string ;
executed_at : string ;
status : IScriptExecutionStatus ;
}
2025-02-03 22:27:44 +00:00
export type ScriptContent = string ;
2024-01-29 14:37:54 +00:00
export interface IHostScript {
script_id : number ;
name : string ;
last_execution : ILastExecution | null ;
}
2025-08-14 15:10:45 +00:00
const SCRIPT_BATCH_STATUSES = [ "started" , "scheduled" , "finished" ] as const ;
export type ScriptBatchStatus = typeof SCRIPT_BATCH_STATUSES [ number ] ;
export const isValidScriptBatchStatus = (
status : string | null | undefined
) : status is ScriptBatchStatus = > {
return SCRIPT_BATCH_STATUSES . includes ( ( status ? ? "" ) as ScriptBatchStatus ) ;
} ;
UI: Batch script run detail page (#32333)
## 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>
2025-08-29 15:37:05 +00:00
export const SCRIPT_BATCH_HOST_EXECUTED_STATUSES = [ "ran" , "errored" ] ;
export const SCRIPT_BATCH_HOST_NOT_EXECUTED_STATUSES = [
"pending" ,
"incompatible" ,
"canceled" ,
] ;
export const SCRIPT_BATCH_HOST_STATUSES = SCRIPT_BATCH_HOST_EXECUTED_STATUSES . concat (
SCRIPT_BATCH_HOST_NOT_EXECUTED_STATUSES
) ;
export type ScriptBatchHostStatus = typeof SCRIPT_BATCH_HOST_STATUSES [ number ] ;
export const isValidScriptBatchHostStatus = (
status : string | null | undefined
) : status is ScriptBatchHostStatus = > {
return SCRIPT_BATCH_HOST_STATUSES . includes (
( status ? ? "" ) as ScriptBatchHostStatus
) ;
} ;