Skip to content
Snippets Groups Projects
Commit d97163c3 authored by Johanna Szepanski's avatar Johanna Szepanski
Browse files

Merge branch 'CE-2866-UI-updates-host-details' into 'develop'

CE-2866: UI updates in host details

See merge request !473
parents 8cfca729 da61c21f
No related branches found
No related tags found
2 merge requests!497CE-2790: Prepare for 4.0.0,!473CE-2866: UI updates in host details
Pipeline #190298 waiting for manual action
import React from "react"; import React from "react";
import { KeyValueTable, InternalLink, EmptyValue } from "@ess-ics/ce-ui-common"; import { KeyValueTable, EmptyValue } from "@ess-ics/ce-ui-common";
import { Stack, Typography } from "@mui/material"; import { Chip, Stack } from "@mui/material";
export const HostDetailsTable = ({ host }) => { const Tags = ({ tags }) => (
function listToString(list) { <Stack
if (list) { direction="row"
if (Array.isArray(list)) { gap={1.5}
return list.join(", "); flexWrap="wrap"
} >
return list; {tags.map((tag) => (
} <Chip
key={tag}
label={tag}
sx={{ minWidth: "50px" }}
/>
))}
</Stack>
);
return ""; const getTableData = (host) => ({
} "device type": host?.netBoxHost?.vm
? "Virtual machine"
: host?.netBoxHost?.deviceType,
description: host?.netBoxHost?.description ? (
host.netBoxHost.description
) : (
<EmptyValue />
),
scope: host?.netBoxHost?.scope,
tags: host?.netBoxHost?.tags ? (
<Tags tags={host?.netBoxHost?.tags} />
) : (
<EmptyValue />
)
});
function renderVmOwners(owners) { export const HostDetailsTable = ({ host }) => (
if (owners && owners.length > 0) { <KeyValueTable
return ( obj={getTableData(host)}
<Stack variant="overline"
direction="row" />
flexWrap="wrap" );
divider={<Typography component="span">,&nbsp;</Typography>}
>
{owners.map((username) => (
<InternalLink
to={`/user/${username}`}
label={`${username} VM Owner User profile`}
key={username}
>
{username}
</InternalLink>
))}
</Stack>
);
} else {
return <EmptyValue />;
}
}
const obj = {
"device type": host?.netBoxHost?.deviceType,
description: host?.netBoxHost?.description,
scope: host?.netBoxHost?.scope,
"vm owner": renderVmOwners(host?.netBoxHost?.vmOwner),
"ansible groups": listToString(host?.netBoxHost?.ansibleGroups)
};
return (
<KeyValueTable
obj={obj}
variant="overline"
/>
);
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment