Get server console page rendering (mostly) correctly
This commit is contained in:
parent
43ff67238c
commit
1e163aa792
18 changed files with 140 additions and 160 deletions
31
resources/scripts/components/server/StopOrKillButton.tsx
Normal file
31
resources/scripts/components/server/StopOrKillButton.tsx
Normal file
|
@ -0,0 +1,31 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import { ServerContext } from '@/state/server';
|
||||
import tw from 'twin.macro';
|
||||
import { PowerAction } from '@/components/server/ServerConsole';
|
||||
import Button from '@/components/elements/Button';
|
||||
|
||||
const StopOrKillButton = ({ onPress }: { onPress: (action: PowerAction) => 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
|
||||
color={'red'}
|
||||
size={'xsmall'}
|
||||
disabled={status === 'offline'}
|
||||
onClick={e => {
|
||||
e.preventDefault();
|
||||
onPress(clicked ? 'kill' : 'stop');
|
||||
setClicked(true);
|
||||
}}
|
||||
>
|
||||
{clicked ? 'Kill' : 'Stop'}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
export default StopOrKillButton;
|
Reference in a new issue