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 [action, setAction] = useState({ command: null })
|
||||
const [preflightOptions, setPreflightOptions] = useState({})
|
||||
const [errorMessage, setErrorMessage] = useState(null)
|
||||
const classes = useStyles()
|
||||
|
||||
|
|
@ -82,17 +83,7 @@ const MachineActions = memo(({ machine, onActionSuccess }) => {
|
|||
|
||||
const [fetchMachineEvents, { loading: loadingEvents }] = useLazyQuery(
|
||||
MACHINE,
|
||||
{
|
||||
variables: {
|
||||
deviceId: machine.deviceId
|
||||
},
|
||||
onCompleted: machineEventsLazy => {
|
||||
const message = !isStaticState(getState(machineEventsLazy))
|
||||
? warningMessage
|
||||
: null
|
||||
setAction(action => ({ ...action, message }))
|
||||
}
|
||||
}
|
||||
preflightOptions
|
||||
)
|
||||
|
||||
const [machineAction, { loading }] = useMutation(MACHINE_ACTION, {
|
||||
|
|
@ -109,6 +100,19 @@ const MachineActions = memo(({ machine, onActionSuccess }) => {
|
|||
const confirmDialogOpen = Boolean(action.command)
|
||||
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 (
|
||||
<div>
|
||||
<Label>Actions</Label>
|
||||
|
|
@ -179,8 +183,7 @@ const MachineActions = memo(({ machine, onActionSuccess }) => {
|
|||
InverseIcon={RebootReversedIcon}
|
||||
disabled={loading}
|
||||
onClick={() => {
|
||||
fetchMachineEvents()
|
||||
setAction({
|
||||
machineStatusPreflight({
|
||||
command: 'restartServices',
|
||||
display: 'Restart services for'
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue