refactor: change server states to match values defined in the design document

main
Josue 4 years ago committed by Tsu-ba-me
parent 514755c559
commit 4861bbd91a
  1. 44
      striker-ui/components/Servers.tsx

@ -5,8 +5,16 @@ import { ClassNameMap } from '@material-ui/styles';
import Panel from './Panel'; import Panel from './Panel';
import PeriodicFetch from '../lib/fetchers/periodicFetch'; import PeriodicFetch from '../lib/fetchers/periodicFetch';
import { HeaderText, BodyText } from './Text'; import { HeaderText, BodyText } from './Text';
import { BLUE, GREY, HOVER, DIVIDER } from '../lib/consts/DEFAULT_THEME'; import {
BLUE,
GREY,
HOVER,
DIVIDER,
PURPLE_OFF,
RED_ON,
} from '../lib/consts/DEFAULT_THEME';
import { AnvilContext } from './AnvilContext'; import { AnvilContext } from './AnvilContext';
import serverState from '../lib/consts/SERVERS';
const useStyles = makeStyles(() => ({ const useStyles = makeStyles(() => ({
root: { root: {
@ -31,24 +39,32 @@ const useStyles = makeStyles(() => ({
height: '100%', height: '100%',
borderRadius: 2, borderRadius: 2,
}, },
started: { running: {
backgroundColor: BLUE, backgroundColor: BLUE,
}, },
stopped: { shut_off: {
backgroundColor: GREY, backgroundColor: GREY,
}, },
crashed: {
backgroundColor: RED_ON,
},
warning: {
backgroundColor: PURPLE_OFF,
},
})); }));
const selectDecorator = ( const selectDecorator = (
state: string, state: string,
): keyof ClassNameMap<'started' | 'stopped'> => { ): keyof ClassNameMap<'running' | 'shut_off' | 'crashed' | 'warning'> => {
switch (state) { switch (state) {
case 'Started': case 'running':
return 'started'; return 'running';
case 'Stopped': case 'shut_off':
return 'stopped'; return 'shut_off';
case 'crashed':
return 'crashed';
default: default:
return 'stopped'; return 'warning';
} }
}; };
@ -87,9 +103,15 @@ const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
</Box> </Box>
<Box p={1} flexGrow={1} className={classes.noPaddingLeft}> <Box p={1} flexGrow={1} className={classes.noPaddingLeft}>
<BodyText text={server.server_name} /> <BodyText text={server.server_name} />
<BodyText text={server.server_state} /> <BodyText
text={
serverState.get(server.server_state) ||
'Not Available'
}
/>
</Box> </Box>
{server.server_state === 'Started' && {server.server_state !== 'shut_off' &&
server.server_state !== 'crashed' &&
anvil[ anvil[
anvil.findIndex((a) => a.anvil_uuid === uuid) anvil.findIndex((a) => a.anvil_uuid === uuid)
].nodes.map( ].nodes.map(

Loading…
Cancel
Save