mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
Fix unreleased bug in run script UI (#14462)
This commit is contained in:
parent
05c5af1f2c
commit
e139eb412f
2 changed files with 27 additions and 3 deletions
|
|
@ -67,7 +67,10 @@ const Scripts = ({ hostId, page = 0, isHostOnline, router }: IScriptsProps) => {
|
|||
break;
|
||||
case "run":
|
||||
try {
|
||||
await scriptsAPI.runScript(script.script_id);
|
||||
await scriptsAPI.runScript({
|
||||
host_id: hostId,
|
||||
script_id: script.script_id,
|
||||
});
|
||||
refetchScriptsData();
|
||||
} catch (e) {
|
||||
const error = e as AxiosResponse<IApiError>;
|
||||
|
|
|
|||
|
|
@ -72,6 +72,27 @@ export interface IHostScriptsResponse {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Request body for POST /scripts/run
|
||||
*
|
||||
* https://fleetdm.com/docs/rest-api/rest-api#run-script-asynchronously
|
||||
*/
|
||||
export interface IScriptRunRequest {
|
||||
host_id: number;
|
||||
script_id: number; // script_id is not required by the API currently, but we require it here to ensure it is always provided
|
||||
// script_contents: string; // script_contents is only supported for the CLI currently
|
||||
}
|
||||
|
||||
/**
|
||||
* Response body for POST /scripts/run
|
||||
*
|
||||
* https://fleetdm.com/docs/rest-api/rest-api#run-script-asynchronously
|
||||
*/
|
||||
export interface IScriptRunResponse {
|
||||
host_id: number;
|
||||
execution_id: string;
|
||||
}
|
||||
|
||||
export default {
|
||||
getHostScripts(id: number, page?: number) {
|
||||
const { HOST_SCRIPTS } = endpoints;
|
||||
|
|
@ -126,8 +147,8 @@ export default {
|
|||
return sendRequest("GET", SCRIPT_RESULT(executionId));
|
||||
},
|
||||
|
||||
runScript(id: number) {
|
||||
runScript(request: IScriptRunRequest): Promise<IScriptRunResponse> {
|
||||
const { SCRIPT_RUN } = endpoints;
|
||||
return sendRequest("POST", SCRIPT_RUN, { script_id: id });
|
||||
return sendRequest("POST", SCRIPT_RUN, request);
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue