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 =>
!(
anvil.hosts.findIndex(({ state }: AnvilStatusHost) => state !== 'off') ===
-1
anvil.hosts.findIndex(
({ state }: AnvilStatusHost) => state !== 'offline',
) === -1
);
const SelectedAnvil = ({ list }: { list: AnvilListItem[] }): JSX.Element => {

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

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

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

Loading…
Cancel
Save