feat: Add restart services button in machine admin actions

This commit is contained in:
Cesar 2020-11-25 19:00:50 +00:00 committed by Josh Harvey
parent 7b1564c569
commit 35e71b9536

View file

@ -128,19 +128,19 @@ const MachineDetailsRow = ({ it: machine, onActionSuccess }) => {
/> />
<ConfirmDialog <ConfirmDialog
open={confirmDialogOpen} open={confirmDialogOpen}
title={`${action?.command} this machine?`} title={`${action?.humanReadable} this machine?`}
errorMessage={errorMessage} errorMessage={errorMessage}
toBeConfirmed={machine.name} toBeConfirmed={machine.name}
message={action?.message} message={action?.message}
confirmationMessage={action?.confirmationMessage} confirmationMessage={action?.confirmationMessage}
saveButtonAlwaysEnabled={action?.command === 'Rename'} saveButtonAlwaysEnabled={action?.command === 'rename'}
onConfirmed={value => { onConfirmed={value => {
setErrorMessage(null) setErrorMessage(null)
machineAction({ machineAction({
variables: { variables: {
deviceId: machine.deviceId, deviceId: machine.deviceId,
action: `${action?.command}`.toLowerCase(), action: `${action?.command}`,
...(action?.command === 'Rename' && { newName: value }) ...(action?.command === 'rename' && { newName: value })
} }
}) })
}} }}
@ -174,7 +174,8 @@ const MachineDetailsRow = ({ it: machine, onActionSuccess }) => {
InverseIcon={EditReversedIcon} InverseIcon={EditReversedIcon}
onClick={() => onClick={() =>
setAction({ setAction({
command: 'Rename', command: 'rename',
humanReadable: 'Rename',
confirmationMessage: 'Write the new name for this machine' confirmationMessage: 'Write the new name for this machine'
}) })
}> }>
@ -188,7 +189,8 @@ const MachineDetailsRow = ({ it: machine, onActionSuccess }) => {
disabled={loading} disabled={loading}
onClick={() => onClick={() =>
setAction({ setAction({
command: 'Unpair' command: 'unpair',
humanReadable: 'Unpair'
}) })
}> }>
Unpair Unpair
@ -201,26 +203,42 @@ const MachineDetailsRow = ({ it: machine, onActionSuccess }) => {
disabled={loading} disabled={loading}
onClick={() => onClick={() =>
setAction({ setAction({
command: 'Reboot' command: 'reboot',
humanReadable: 'Reboot'
}) })
}> }>
Reboot Reboot
</ActionButton> </ActionButton>
<ActionButton <ActionButton
className={classes.inlineChip} className={classes.mr}
disabled={loading} disabled={loading}
color="primary" color="primary"
Icon={ShutdownIcon} Icon={ShutdownIcon}
InverseIcon={ShutdownReversedIcon} InverseIcon={ShutdownReversedIcon}
onClick={() => onClick={() =>
setAction({ setAction({
command: 'Shutdown', command: 'shutdown',
humanReadable: 'Shutdown',
message: message:
'In order to bring it back online, the machine will need to be visited and its power reset.' 'In order to bring it back online, the machine will need to be visited and its power reset.'
}) })
}> }>
Shutdown Shutdown
</ActionButton> </ActionButton>
<ActionButton
color="primary"
className={classes.inlineChip}
Icon={RebootIcon}
InverseIcon={RebootReversedIcon}
disabled={loading}
onClick={() =>
setAction({
command: 'restartServices',
humanReadable: 'Restart services for'
})
}>
Restart Services
</ActionButton>
</div> </div>
</Item> </Item>
</Container> </Container>