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

Merge branch 'CE-2451-shorten-fqdn-to-hostname' into 'develop'

CE-2451: Shorten fqdn hostname, display only first part

See merge request !449
parents 4568e2a7 c8d69fb0
No related branches found
No related tags found
2 merge requests!497CE-2790: Prepare for 4.0.0,!449CE-2451: Shorten fqdn hostname, display only first part
Pipeline #177850 waiting for manual action
......@@ -13,6 +13,32 @@ function createRequest(fqdn) {
};
}
function shortenFqdn(fqdn) {
return fqdn.split(".")[0];
}
function createHostLink(fqdn, hostInfo) {
// if the fqdn field is empty for some reason
if (fqdn === null || fqdn.trim() === "") {
return <Typography>{"---"}</Typography>;
}
// create host link only if the host exists in CSEntry
if (hostInfo) {
return (
<InternalLink
to={`/hosts/${hostInfo.externalId}`}
label={`Record host details, ${fqdn}}`}
width="100%"
>
<EllipsisText>{shortenFqdn(fqdn)}</EllipsisText>
</InternalLink>
);
}
return <Typography>{fqdn}</Typography>;
}
export const RecordHostLink = ({ fqdn }) => {
const client = useContext(apiContext);
......@@ -27,28 +53,6 @@ export const RecordHostLink = ({ fqdn }) => {
params
});
function createHostLink() {
// if the fqdn field is empty for some reason
if (fqdn === null || fqdn.trim() === "") {
return <Typography>{"---"}</Typography>;
}
// create host link only if the host exists in CSEntry
if (hostInfo) {
return (
<InternalLink
to={`/hosts/${hostInfo.externalId}`}
label={`Record host details, ${fqdn}`}
width="100%"
>
<EllipsisText>{fqdn}</EllipsisText>
</InternalLink>
);
}
return <Typography>{fqdn}</Typography>;
}
return (
<Grid
container
......@@ -56,7 +60,11 @@ export const RecordHostLink = ({ fqdn }) => {
justifyContent="center"
alignItems="center"
>
{loading || !dataReady ? <Skeleton width="100%" /> : createHostLink()}
{loading || !dataReady ? (
<Skeleton width="100%" />
) : (
createHostLink(fqdn, hostInfo)
)}
</Grid>
);
};
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