refactor: update host state following specs

main
Josue 4 years ago committed by Tsu-ba-me
parent 7199e1899e
commit 0e1098d893
  1. 5
      striker-ui/components/Anvils/SelectedAnvil.tsx
  2. 19
      striker-ui/components/Hosts/AnvilHost.tsx
  3. 2
      striker-ui/components/Hosts/index.tsx
  4. 2
      striker-ui/types/AnvilStatus.d.ts

@ -35,8 +35,9 @@ const selectDecorator = (state: string): Colours => {
const isAnvilOn = (anvil: AnvilListItem): boolean => const isAnvilOn = (anvil: AnvilListItem): boolean =>
!( !(
anvil.hosts.findIndex(({ state }: AnvilStatusHost) => state !== 'off') === anvil.hosts.findIndex(
-1 ({ state }: AnvilStatusHost) => state !== 'offline',
) === -1
); );
const SelectedAnvil = ({ list }: { list: AnvilListItem[] }): JSX.Element => { const SelectedAnvil = ({ list }: { list: AnvilListItem[] }): JSX.Element => {

@ -50,15 +50,12 @@ const selectStateMessage = (regex: RegExp, message: string): string => {
const selectDecorator = (state: string): Colours => { const selectDecorator = (state: string): Colours => {
switch (state) { switch (state) {
case 'ready': case 'online':
return 'ok'; return 'ok';
case 'off': case 'offline':
return 'off'; return 'off';
case 'accessible':
case 'on':
return 'warning';
default: default:
return 'error'; return 'warning';
} }
}; };
@ -103,11 +100,11 @@ const AnvilHost = ({
</Box> </Box>
<Box flexGrow={1}> <Box flexGrow={1}>
<Switch <Switch
checked={host.state === 'ready'} checked={host.state === 'online'}
onChange={() => onChange={() =>
putJSON('/set_power', { putJSON('/set_power', {
host_uuid: host.host_uuid, host_uuid: host.host_uuid,
is_on: !(host.state === 'ready'), is_on: !(host.state === 'online'),
}) })
} }
/> />
@ -117,18 +114,18 @@ const AnvilHost = ({
</Box> </Box>
<Box> <Box>
<Switch <Switch
checked={host.state === 'ready'} checked={host.state === 'online'}
disabled={!host.removable} disabled={!host.removable}
onChange={() => onChange={() =>
putJSON('/set_membership', { putJSON('/set_membership', {
host_uuid: host.host_uuid, host_uuid: host.host_uuid,
is_member: !(host.state === 'ready'), is_member: !(host.state === 'online'),
}) })
} }
/> />
</Box> </Box>
</Box> </Box>
{host.state !== 'ready' && ( {host.state !== 'online' && (
<> <>
<Box display="flex" width="100%" className={classes.state}> <Box display="flex" width="100%" className={classes.state}>
<Box> <Box>

@ -14,7 +14,7 @@ const Hosts = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
return ( return (
<Panel> <Panel>
<HeaderText text="Hosts" /> <HeaderText text="Nodes" />
{anvil.findIndex((a) => a.anvil_uuid === uuid) !== -1 && data && ( {anvil.findIndex((a) => a.anvil_uuid === uuid) !== -1 && data && (
<AnvilHost <AnvilHost
hosts={anvil[anvil.findIndex((a) => a.anvil_uuid === uuid)].hosts.map( hosts={anvil[anvil.findIndex((a) => a.anvil_uuid === uuid)].hosts.map(

@ -1,5 +1,5 @@
declare type AnvilStatusHost = { declare type AnvilStatusHost = {
state: 'unknown' | 'off' | 'on' | 'accessible' | 'ready'; state: 'offline' | 'booted' | 'crmd' | 'in_ccm' | 'online';
host_uuid: string; host_uuid: string;
host_name: string; host_name: string;
state_percent: number; state_percent: number;

Loading…
Cancel
Save