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({
...anvil,
anvil_state: data?.anvil_state,
...data,
});
});
return (

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

@ -15,11 +15,11 @@ const Nodes = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
return (
<Panel>
<HeaderText text="Nodes" />
{anvil.findIndex((a) => a.anvil_uuid === uuid) !== -1 && (
{anvil.findIndex((a) => a.anvil_uuid === uuid) !== -1 && data && (
<AnvilNode
nodes={anvil[anvil.findIndex((a) => a.anvil_uuid === uuid)].nodes.map(
(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 = {
anvil_name: string;
anvil_uuid: string;
anvil_state: string;
nodes: Array<AnvilListItemNode>;
};
} & AnvilStatus;
declare type AnvilList = {
anvils: Array<AnvilListItem>;

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

Loading…
Cancel
Save