mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 06:17:36 -02:30
Added more context to subscription details and rearrange the order of some of the fields (#12649)
* Adds more context to subscription details and rearranges some of the fields * Fixes broken unit test after updating subscription details
This commit is contained in:
@@ -1,8 +1,13 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import { t, Trans } from '@lingui/macro';
|
import { t, Trans } from '@lingui/macro';
|
||||||
import { Button, Label } from '@patternfly/react-core';
|
import styled from 'styled-components';
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
HelperText as PFHelperText,
|
||||||
|
HelperTextItem,
|
||||||
|
Label,
|
||||||
|
} from '@patternfly/react-core';
|
||||||
import {
|
import {
|
||||||
CaretLeftIcon,
|
CaretLeftIcon,
|
||||||
CheckIcon,
|
CheckIcon,
|
||||||
@@ -14,6 +19,10 @@ import { DetailList, Detail } from 'components/DetailList';
|
|||||||
import { useConfig } from 'contexts/Config';
|
import { useConfig } from 'contexts/Config';
|
||||||
import { formatDateString, secondsToDays } from 'util/dates';
|
import { formatDateString, secondsToDays } from 'util/dates';
|
||||||
|
|
||||||
|
const HelperText = styled(PFHelperText)`
|
||||||
|
margin-top: 10px;
|
||||||
|
`;
|
||||||
|
|
||||||
function SubscriptionDetail() {
|
function SubscriptionDetail() {
|
||||||
const { me = {}, license_info, version } = useConfig();
|
const { me = {}, license_info, version } = useConfig();
|
||||||
const baseURL = '/settings/subscription';
|
const baseURL = '/settings/subscription';
|
||||||
@@ -52,25 +61,71 @@ function SubscriptionDetail() {
|
|||||||
label={t`Status`}
|
label={t`Status`}
|
||||||
value={
|
value={
|
||||||
license_info.compliant ? (
|
license_info.compliant ? (
|
||||||
<Label variant="outline" color="green" icon={<CheckIcon />}>
|
<>
|
||||||
{t`Compliant`}
|
<Label variant="outline" color="green" icon={<CheckIcon />}>
|
||||||
</Label>
|
{t`Compliant`}
|
||||||
|
</Label>
|
||||||
|
<HelperText>
|
||||||
|
<HelperTextItem>{t`The number of hosts you have automated against is below your subscription count.`}</HelperTextItem>
|
||||||
|
</HelperText>
|
||||||
|
</>
|
||||||
) : (
|
) : (
|
||||||
<Label
|
<>
|
||||||
variant="outline"
|
<Label
|
||||||
color="red"
|
variant="outline"
|
||||||
icon={<ExclamationCircleIcon />}
|
color="red"
|
||||||
>
|
icon={<ExclamationCircleIcon />}
|
||||||
{t`Out of compliance`}
|
>
|
||||||
</Label>
|
{t`Out of compliance`}
|
||||||
|
</Label>
|
||||||
|
<HelperText>
|
||||||
|
<HelperTextItem>{t`You have automated against more hosts than your subscription allows.`}</HelperTextItem>
|
||||||
|
</HelperText>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
{typeof automatedInstancesCount !== 'undefined' &&
|
||||||
|
automatedInstancesCount !== null && (
|
||||||
|
<Detail
|
||||||
|
dataCy="subscription-hosts-automated"
|
||||||
|
label={t`Hosts automated`}
|
||||||
|
value={
|
||||||
|
automated_since ? (
|
||||||
|
<Trans>
|
||||||
|
{automatedInstancesCount} since{' '}
|
||||||
|
{automatedInstancesSinceDateTime}
|
||||||
|
</Trans>
|
||||||
|
) : (
|
||||||
|
automatedInstancesCount
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Detail
|
<Detail
|
||||||
dataCy="subscription-version"
|
dataCy="subscription-hosts-imported"
|
||||||
label={t`Version`}
|
label={t`Hosts imported`}
|
||||||
value={version}
|
value={license_info.current_instances}
|
||||||
/>
|
/>
|
||||||
|
<Detail
|
||||||
|
dataCy="subscription-hosts-remaining"
|
||||||
|
label={t`Hosts remaining`}
|
||||||
|
value={license_info.free_instances}
|
||||||
|
/>
|
||||||
|
{license_info.instance_count < 9999999 && (
|
||||||
|
<Detail
|
||||||
|
dataCy="subscription-hosts-available"
|
||||||
|
label={t`Hosts available`}
|
||||||
|
value={license_info.available_instances}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{license_info.instance_count >= 9999999 && (
|
||||||
|
<Detail
|
||||||
|
dataCy="subscription-unlimited-hosts-available"
|
||||||
|
label={t`Hosts available`}
|
||||||
|
value={t`Unlimited`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Detail
|
<Detail
|
||||||
dataCy="subscription-type"
|
dataCy="subscription-type"
|
||||||
label={t`Subscription type`}
|
label={t`Subscription type`}
|
||||||
@@ -115,46 +170,10 @@ function SubscriptionDetail() {
|
|||||||
secondsToDays(license_info.time_remaining)
|
secondsToDays(license_info.time_remaining)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{license_info.instance_count < 9999999 && (
|
|
||||||
<Detail
|
|
||||||
dataCy="subscription-hosts-available"
|
|
||||||
label={t`Hosts available`}
|
|
||||||
value={license_info.available_instances}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{license_info.instance_count >= 9999999 && (
|
|
||||||
<Detail
|
|
||||||
dataCy="subscription-unlimited-hosts-available"
|
|
||||||
label={t`Hosts available`}
|
|
||||||
value={t`Unlimited`}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<Detail
|
<Detail
|
||||||
dataCy="subscription-hosts-imported"
|
dataCy="subscription-version"
|
||||||
label={t`Hosts imported`}
|
label={t`Automation controller version`}
|
||||||
value={license_info.current_instances}
|
value={version}
|
||||||
/>
|
|
||||||
{typeof automatedInstancesCount !== 'undefined' &&
|
|
||||||
automatedInstancesCount !== null && (
|
|
||||||
<Detail
|
|
||||||
dataCy="subscription-hosts-automated"
|
|
||||||
label={t`Hosts automated`}
|
|
||||||
value={
|
|
||||||
automated_since ? (
|
|
||||||
<Trans>
|
|
||||||
{automatedInstancesCount} since{' '}
|
|
||||||
{automatedInstancesSinceDateTime}
|
|
||||||
</Trans>
|
|
||||||
) : (
|
|
||||||
automatedInstancesCount
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<Detail
|
|
||||||
dataCy="subscription-hosts-remaining"
|
|
||||||
label={t`Hosts remaining`}
|
|
||||||
value={license_info.free_instances}
|
|
||||||
/>
|
/>
|
||||||
</DetailList>
|
</DetailList>
|
||||||
<br />
|
<br />
|
||||||
|
|||||||
@@ -53,8 +53,14 @@ describe('<SubscriptionDetail />', () => {
|
|||||||
expect(wrapper.find(`Detail[label="${label}"] dt`).text()).toBe(label);
|
expect(wrapper.find(`Detail[label="${label}"] dt`).text()).toBe(label);
|
||||||
expect(wrapper.find(`Detail[label="${label}"] dd`).text()).toBe(value);
|
expect(wrapper.find(`Detail[label="${label}"] dd`).text()).toBe(value);
|
||||||
}
|
}
|
||||||
assertDetail('Status', 'Compliant');
|
expect(wrapper.find(`Detail[label="Status"] dt`).text()).toBe('Status');
|
||||||
assertDetail('Version', '1.2.3');
|
expect(wrapper.find(`Detail[label="Status"] dd`).text()).toContain(
|
||||||
|
'Compliant'
|
||||||
|
);
|
||||||
|
expect(wrapper.find(`Detail[label="Status"] dd`).text()).toContain(
|
||||||
|
'The number of hosts you have automated against is below your subscription count.'
|
||||||
|
);
|
||||||
|
assertDetail('Automation controller version', '1.2.3');
|
||||||
assertDetail('Subscription type', 'enterprise');
|
assertDetail('Subscription type', 'enterprise');
|
||||||
assertDetail(
|
assertDetail(
|
||||||
'Subscription',
|
'Subscription',
|
||||||
|
|||||||
Reference in New Issue
Block a user