Add timeout detail to node view modal

This commit is contained in:
Marliana Lara 2020-03-31 13:13:57 -04:00
parent 5cba34c34d
commit c18aa90534
No known key found for this signature in database
GPG Key ID: 38C73B40DFA809EE

View File

@ -1,7 +1,7 @@
import React from 'react';
import { shape } from 'prop-types';
import { withI18n } from '@lingui/react';
import { t } from '@lingui/macro';
import { t, Trans } from '@lingui/macro';
import { Chip, ChipGroup } from '@patternfly/react-core';
import { VariablesDetail } from '@components/CodeMirrorInput';
import { DetailList, Detail } from '@components/DetailList';
@ -27,6 +27,15 @@ function hasPromptData(launchData) {
);
}
function formatTimeout(timeout) {
if (typeof timeout === "undefined" || timeout === null) {
return null;
}
const minutes = Math.floor(timeout / 60);
const seconds = timeout - Math.floor(timeout / 60) * 60;
return <>{minutes} <Trans>min</Trans> {seconds} <Trans>sec</Trans></>;
}
function PromptDetail({ i18n, resource, launchConfig = {} }) {
const { defaults = {} } = launchConfig;
const VERBOSITY = {
@ -46,6 +55,10 @@ function PromptDetail({ i18n, resource, launchConfig = {} }) {
label={i18n._(t`Type`)}
value={resource.unified_job_type || resource.type}
/>
<Detail
label={i18n._(t`Timeout`)}
value={formatTimeout(resource?.timeout)}
/>
</DetailList>
{hasPromptData(launchConfig) && (