mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
Fix loading spinner not appearing when running a script (#15936)
This commit is contained in:
parent
caac8fbbe2
commit
c1f961ec30
1
changes/15109-fix-scripts-spinner
Normal file
1
changes/15109-fix-scripts-spinner
Normal file
@ -0,0 +1 @@
|
|||||||
|
* Fix loading spinner not appearing when running a script on a host.
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useContext } from "react";
|
import React, { useContext, useState } from "react";
|
||||||
import { useQuery } from "react-query";
|
import { useQuery } from "react-query";
|
||||||
import { AxiosResponse } from "axios";
|
import { AxiosResponse } from "axios";
|
||||||
import { InjectedRouter } from "react-router";
|
import { InjectedRouter } from "react-router";
|
||||||
@ -43,6 +43,7 @@ const Scripts = ({
|
|||||||
router,
|
router,
|
||||||
onShowDetails,
|
onShowDetails,
|
||||||
}: IScriptsProps) => {
|
}: IScriptsProps) => {
|
||||||
|
const [isScriptRunning, setIsScriptRunning] = useState(false);
|
||||||
const { renderFlash } = useContext(NotificationContext);
|
const { renderFlash } = useContext(NotificationContext);
|
||||||
|
|
||||||
const hostId = host?.id;
|
const hostId = host?.id;
|
||||||
@ -59,6 +60,9 @@ const Scripts = ({
|
|||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
retry: false,
|
retry: false,
|
||||||
enabled: Boolean(hostId),
|
enabled: Boolean(hostId),
|
||||||
|
onSuccess: () => {
|
||||||
|
setIsScriptRunning(false);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -79,6 +83,7 @@ const Scripts = ({
|
|||||||
break;
|
break;
|
||||||
case "run":
|
case "run":
|
||||||
try {
|
try {
|
||||||
|
setIsScriptRunning(true);
|
||||||
await scriptsAPI.runScript({
|
await scriptsAPI.runScript({
|
||||||
host_id: host.id,
|
host_id: host.id,
|
||||||
script_id: script.script_id,
|
script_id: script.script_id,
|
||||||
@ -87,6 +92,7 @@ const Scripts = ({
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
const error = e as AxiosResponse<IApiError>;
|
const error = e as AxiosResponse<IApiError>;
|
||||||
renderFlash("error", error.data.errors[0].reason);
|
renderFlash("error", error.data.errors[0].reason);
|
||||||
|
setIsScriptRunning(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -125,7 +131,7 @@ const Scripts = ({
|
|||||||
isAllPagesSelected={false}
|
isAllPagesSelected={false}
|
||||||
columnConfigs={scriptColumnConfigs}
|
columnConfigs={scriptColumnConfigs}
|
||||||
data={data}
|
data={data}
|
||||||
isLoading={isLoadingScriptData}
|
isLoading={isScriptRunning}
|
||||||
onQueryChange={onQueryChange}
|
onQueryChange={onQueryChange}
|
||||||
disableNextPage={hostScriptResponse?.meta.has_next_results}
|
disableNextPage={hostScriptResponse?.meta.has_next_results}
|
||||||
defaultPageIndex={page}
|
defaultPageIndex={page}
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.data-table-block .data-table__wrapper {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
.table-container__header-left {
|
.table-container__header-left {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user