fix: use AnvilStatus type for hosts info instead of Anvil type

main
Josue 4 years ago committed by Tsu-ba-me
parent 1255ca2599
commit 982a8e4f00
  1. 2
      striker-ui/components/Anvils/index.tsx
  2. 10
      striker-ui/components/Nodes/AnvilNode.tsx
  3. 4
      striker-ui/components/Nodes/index.tsx
  4. 9
      striker-ui/types/AnvilList.d.ts
  5. 6
      striker-ui/types/AnvilStatus.d.ts

@ -14,7 +14,7 @@ const Anvils = ({ list }: { list: AnvilList | undefined }): JSX.Element => {
); );
anvils.push({ anvils.push({
...anvil, ...anvil,
anvil_state: data?.anvil_state, ...data,
}); });
}); });
return ( return (

@ -65,7 +65,7 @@ const selectDecorator = (state: string): Colours => {
const AnvilNode = ({ const AnvilNode = ({
nodes, nodes,
}: { }: {
nodes: Array<AnvilStatusNode & AnvilListItemNode>; nodes: Array<AnvilStatusNode>;
}): JSX.Element => { }): JSX.Element => {
const classes = useStyles(); const classes = useStyles();
const stateRegex = /^[a-zA-Z]/; const stateRegex = /^[a-zA-Z]/;
@ -77,11 +77,11 @@ const AnvilNode = ({
nodes.map( nodes.map(
(node): JSX.Element => { (node): JSX.Element => {
return ( return (
<InnerPanel key={node.node_uuid}> <InnerPanel key={node.host_uuid}>
<PanelHeader> <PanelHeader>
<Box display="flex" width="100%" className={classes.header}> <Box display="flex" width="100%" className={classes.header}>
<Box flexGrow={1}> <Box flexGrow={1}>
<BodyText text={node.node_name} /> <BodyText text={node.host_name} />
</Box> </Box>
<Box className={classes.decoratorBox}> <Box className={classes.decoratorBox}>
<Decorator colour={selectDecorator(node.state)} /> <Decorator colour={selectDecorator(node.state)} />
@ -106,7 +106,7 @@ const AnvilNode = ({
checked={node.state === 'ready'} checked={node.state === 'ready'}
onChange={() => onChange={() =>
putJSON('/anvils/set_power', { putJSON('/anvils/set_power', {
host_uuid: node.node_uuid, host_uuid: node.host_uuid,
is_on: !(node.state === 'ready'), is_on: !(node.state === 'ready'),
}) })
} }
@ -121,7 +121,7 @@ const AnvilNode = ({
disabled={!node.removable} disabled={!node.removable}
onChange={() => onChange={() =>
putJSON('/anvils/set_membership', { putJSON('/anvils/set_membership', {
host_uuid: node.node_uuid, host_uuid: node.host_uuid,
is_member: !(node.state === 'ready'), is_member: !(node.state === 'ready'),
}) })
} }

@ -15,11 +15,11 @@ const Nodes = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
return ( return (
<Panel> <Panel>
<HeaderText text="Nodes" /> <HeaderText text="Nodes" />
{anvil.findIndex((a) => a.anvil_uuid === uuid) !== -1 && ( {anvil.findIndex((a) => a.anvil_uuid === uuid) !== -1 && data && (
<AnvilNode <AnvilNode
nodes={anvil[anvil.findIndex((a) => a.anvil_uuid === uuid)].nodes.map( nodes={anvil[anvil.findIndex((a) => a.anvil_uuid === uuid)].nodes.map(
(node, index) => { (node, index) => {
return { ...node, ...data?.nodes[index] }; return data.nodes[index];
}, },
)} )}
/> />

@ -1,14 +1,7 @@
declare type AnvilListItemNode = {
node_name: string;
node_uuid: string;
};
declare type AnvilListItem = { declare type AnvilListItem = {
anvil_name: string; anvil_name: string;
anvil_uuid: string; anvil_uuid: string;
anvil_state: string; } & AnvilStatus;
nodes: Array<AnvilListItemNode>;
};
declare type AnvilList = { declare type AnvilList = {
anvils: Array<AnvilListItem>; anvils: Array<AnvilListItem>;

@ -1,5 +1,7 @@
declare type AnvilStatusNode = { declare type AnvilStatusNode = {
state: 'unknown' | 'off' | 'on' | 'accessible' | 'ready'; state: 'unknown' | 'off' | 'on' | 'accessible' | 'ready';
host_uuid: string;
host_name: string;
state_percent: number; state_percent: number;
state_message: string; state_message: string;
removable: boolean; removable: boolean;
@ -7,7 +9,5 @@ declare type AnvilStatusNode = {
declare type AnvilStatus = { declare type AnvilStatus = {
anvil_state: 'optimal' | 'not_ready' | 'degraded'; anvil_state: 'optimal' | 'not_ready' | 'degraded';
nodes: Array<{ nodes: Array<AnvilStatusNode>;
AnvilStatusNode;
}>;
}; };

Loading…
Cancel
Save