Add button to toggle kill option after pressing stop once
This commit is contained in:
parent
326d346f92
commit
79571e1928
1 changed files with 24 additions and 10 deletions
|
@ -16,6 +16,29 @@ const GreyBox = styled.div`
|
||||||
|
|
||||||
const ChunkedConsole = lazy(() => import('@/components/server/Console'));
|
const ChunkedConsole = lazy(() => import('@/components/server/Console'));
|
||||||
|
|
||||||
|
const StopOrKillButton = ({ onPress }: { onPress: (action: string) => void }) => {
|
||||||
|
const [ clicked, setClicked ] = useState(false);
|
||||||
|
const status = ServerContext.useStoreState(state => state.status.value);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setClicked(state => ['stopping'].indexOf(status) < 0 ? false : state);
|
||||||
|
}, [status]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
className={'btn btn-red btn-xs'}
|
||||||
|
disabled={status === 'offline'}
|
||||||
|
onClick={e => {
|
||||||
|
e.preventDefault();
|
||||||
|
onPress(clicked ? 'kill' : 'stop');
|
||||||
|
setClicked(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{clicked ? 'Kill' : 'Stop'}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
const [ memory, setMemory ] = useState(0);
|
const [ memory, setMemory ] = useState(0);
|
||||||
const [ cpu, setCpu ] = useState(0);
|
const [ cpu, setCpu ] = useState(0);
|
||||||
|
@ -114,16 +137,7 @@ export default () => {
|
||||||
>
|
>
|
||||||
Restart
|
Restart
|
||||||
</button>
|
</button>
|
||||||
<button
|
<StopOrKillButton onPress={action => sendPowerCommand(action)}/>
|
||||||
className={'btn btn-red btn-xs'}
|
|
||||||
disabled={status === 'offline'}
|
|
||||||
onClick={e => {
|
|
||||||
e.preventDefault();
|
|
||||||
sendPowerCommand(status === 'stopping' ? 'kill' : 'stop');
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Stop
|
|
||||||
</button>
|
|
||||||
</GreyBox>
|
</GreyBox>
|
||||||
</div>
|
</div>
|
||||||
<React.Suspense
|
<React.Suspense
|
||||||
|
|
Loading…
Reference in a new issue