Merge pull request #959 from chaotixkilla/fix-restart-services-autofocus
Fix autofocus on 'Restart Services' button
This commit is contained in:
commit
31dcf890de
1 changed files with 16 additions and 13 deletions
|
|
@ -70,6 +70,7 @@ const Label = ({ children }) => {
|
||||||
|
|
||||||
const MachineActions = memo(({ machine, onActionSuccess }) => {
|
const MachineActions = memo(({ machine, onActionSuccess }) => {
|
||||||
const [action, setAction] = useState({ command: null })
|
const [action, setAction] = useState({ command: null })
|
||||||
|
const [preflightOptions, setPreflightOptions] = useState({})
|
||||||
const [errorMessage, setErrorMessage] = useState(null)
|
const [errorMessage, setErrorMessage] = useState(null)
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
|
|
||||||
|
|
@ -82,17 +83,7 @@ const MachineActions = memo(({ machine, onActionSuccess }) => {
|
||||||
|
|
||||||
const [fetchMachineEvents, { loading: loadingEvents }] = useLazyQuery(
|
const [fetchMachineEvents, { loading: loadingEvents }] = useLazyQuery(
|
||||||
MACHINE,
|
MACHINE,
|
||||||
{
|
preflightOptions
|
||||||
variables: {
|
|
||||||
deviceId: machine.deviceId
|
|
||||||
},
|
|
||||||
onCompleted: machineEventsLazy => {
|
|
||||||
const message = !isStaticState(getState(machineEventsLazy))
|
|
||||||
? warningMessage
|
|
||||||
: null
|
|
||||||
setAction(action => ({ ...action, message }))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const [machineAction, { loading }] = useMutation(MACHINE_ACTION, {
|
const [machineAction, { loading }] = useMutation(MACHINE_ACTION, {
|
||||||
|
|
@ -109,6 +100,19 @@ const MachineActions = memo(({ machine, onActionSuccess }) => {
|
||||||
const confirmDialogOpen = Boolean(action.command)
|
const confirmDialogOpen = Boolean(action.command)
|
||||||
const disabled = !!(action?.command === 'restartServices' && loadingEvents)
|
const disabled = !!(action?.command === 'restartServices' && loadingEvents)
|
||||||
|
|
||||||
|
const machineStatusPreflight = actionToDo => {
|
||||||
|
setPreflightOptions({
|
||||||
|
variables: { deviceId: machine.deviceId },
|
||||||
|
onCompleted: machineEventsLazy => {
|
||||||
|
const message = !isStaticState(getState(machineEventsLazy))
|
||||||
|
? warningMessage
|
||||||
|
: null
|
||||||
|
setAction({ ...actionToDo, message })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
fetchMachineEvents()
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Label>Actions</Label>
|
<Label>Actions</Label>
|
||||||
|
|
@ -179,8 +183,7 @@ const MachineActions = memo(({ machine, onActionSuccess }) => {
|
||||||
InverseIcon={RebootReversedIcon}
|
InverseIcon={RebootReversedIcon}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
fetchMachineEvents()
|
machineStatusPreflight({
|
||||||
setAction({
|
|
||||||
command: 'restartServices',
|
command: 'restartServices',
|
||||||
display: 'Restart services for'
|
display: 'Restart services for'
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue