diff --git a/src/components/Job/JobData.ts b/src/components/Job/JobData.ts deleted file mode 100644 index 8b77ed29dfe214b0b798a12bccc5cb70743e1756..0000000000000000000000000000000000000000 --- a/src/components/Job/JobData.ts +++ /dev/null @@ -1,8 +0,0 @@ -export const ACTION_TYPES = { - DEPLOY: "DEPLOY", - UNDEPLOY: "UNDEPLOY", - BATCH_DEPLOY: "BATCH_DEPLOY", - BATCH_UNDEPLOY: "BATCH_UNDEPLOY", - START: "START", - STOP: "STOP" -}; diff --git a/src/components/Job/JobTable/JobDetailsColumn.tsx b/src/components/Job/JobTable/JobDetailsColumn.tsx index 309166581d17a1cdc0fb901f979c17589689f6cb..fa2423c5cd97e3dce04fbb61bfe2b356d6a659da 100644 --- a/src/components/Job/JobTable/JobDetailsColumn.tsx +++ b/src/components/Job/JobTable/JobDetailsColumn.tsx @@ -1,9 +1,13 @@ import { useMemo } from "react"; import { Stack, Typography } from "@mui/material"; import { InternalLink } from "@ess-ics/ce-ui-common"; -import { getNoOfIOCs, getNoOfHosts, isBatchJob } from "../JobUtils"; +import { + ACTION_TYPES, + getNoOfIOCs, + getNoOfHosts, + isBatchJob +} from "../JobUtils"; import { ActionTypeIconText } from "../JobIcons"; -import { ACTION_TYPES } from "../JobData"; import { JobRevisionChip } from "../JobRevisionChip"; import { Job } from "../../../store/deployApi"; diff --git a/src/components/Job/JobUtils.jsx b/src/components/Job/JobUtils.jsx new file mode 100644 index 0000000000000000000000000000000000000000..4d76a2def2185e652f009ebde48602aa18f796b4 --- /dev/null +++ b/src/components/Job/JobUtils.jsx @@ -0,0 +1,45 @@ +import { EllipsisText, InternalLink } from "@ess-ics/ce-ui-common"; +import { Typography } from "@mui/material"; + +export const ACTION_TYPES = { + DEPLOY: "DEPLOY", + UNDEPLOY: "UNDEPLOY", + BATCH_DEPLOY: "BATCH_DEPLOY", + BATCH_UNDEPLOY: "BATCH_UNDEPLOY", + START: "START", + STOP: "STOP" +}; + +export const isBatchJob = (action) => + action === ACTION_TYPES.BATCH_DEPLOY || + action === ACTION_TYPES.BATCH_UNDEPLOY; + +export const isDeploymentJob = (action) => + action === ACTION_TYPES.BATCH_DEPLOY || action === ACTION_TYPES.DEPLOY; + +export const getNoOfIOCs = (jobs) => + [...new Set(jobs.map((job) => job.iocId))].length; + +export const getNoOfHosts = (jobs) => + [...new Set(jobs.map((job) => job.host.hostId))].length; + +export const calculateHostText = (job) => { + // host is resolvable => show link for users + if (job?.host?.hostId && job?.host?.externalIdValid) { + return ( + <InternalLink + to={`/hosts/${job.host.hostId}`} + label={`Host Details, ${job.host.fqdn}`} + width="100%" + > + <EllipsisText>{job.host.fqdn}</EllipsisText> + </InternalLink> + ); + } + // gray out hostname if it is from cache + return ( + <Typography color="gray"> + <EllipsisText>{job?.host?.fqdn}</EllipsisText> + </Typography> + ); +};