refactor: use regex instead of a map to display node state

main
Josue 4 years ago committed by Tsu-ba-me
parent 431b88aa11
commit e775b4ac16
  1. 8
      striker-ui/components/Nodes/AnvilNode.tsx

@ -3,7 +3,6 @@ import { makeStyles } from '@material-ui/core/styles';
import { InnerPanel, PanelHeader } from '../Panels';
import { ProgressBar } from '../Bars';
import { BodyText } from '../Text';
import nodeState from '../../lib/consts/NODES';
import Decorator, { Colours } from '../Decorator';
import putJSON from '../../lib/fetchers/putJSON';
@ -59,6 +58,8 @@ const AnvilNode = ({
nodes: Array<AnvilStatusNode & AnvilListItemNode>;
}): JSX.Element => {
const classes = useStyles();
const regex = /(^|| )+[a-zA-Z0-9]/;
return (
<Box className={classes.root}>
{nodes &&
@ -76,7 +77,10 @@ const AnvilNode = ({
</Box>
<Box>
<BodyText
text={nodeState.get(node.state) || 'Not Available'}
text={
node?.state?.replace(regex, (c) => c.toUpperCase()) ||
'Not Available'
}
/>
</Box>
</Box>

Loading…
Cancel
Save