mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
Translate contents of Hosts Automated field as a single string (#12480)
* Translate contents of Hosts Automated field as a single string * Adds unit test case for hiding Hosts automated detail when no value is present
This commit is contained in:
parent
bd93ac7edd
commit
8031b3d402
@ -35,6 +35,13 @@ function SubscriptionDetail() {
|
||||
},
|
||||
];
|
||||
|
||||
const { automated_instances: automatedInstancesCount, automated_since } =
|
||||
license_info;
|
||||
|
||||
const automatedInstancesSinceDateTime = automated_since
|
||||
? formatDateString(new Date(automated_since * 1000).toISOString())
|
||||
: null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<RoutedTabs tabsArray={tabsArray} />
|
||||
@ -127,19 +134,23 @@ function SubscriptionDetail() {
|
||||
label={t`Hosts imported`}
|
||||
value={license_info.current_instances}
|
||||
/>
|
||||
<Detail
|
||||
dataCy="subscription-hosts-automated"
|
||||
label={t`Hosts automated`}
|
||||
value={
|
||||
<>
|
||||
{license_info.automated_instances} <Trans>since</Trans>{' '}
|
||||
{license_info.automated_since &&
|
||||
formatDateString(
|
||||
new Date(license_info.automated_since * 1000).toISOString()
|
||||
)}
|
||||
</>
|
||||
}
|
||||
/>
|
||||
{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`}
|
||||
|
||||
@ -82,4 +82,17 @@ describe('<SubscriptionDetail />', () => {
|
||||
|
||||
expect(wrapper.find('Button[aria-label="edit"]').length).toBe(1);
|
||||
});
|
||||
|
||||
test('should not render Hosts Automated Detail if license_info.automated_instances is undefined', () => {
|
||||
wrapper = mountWithContexts(<SubscriptionDetail />, {
|
||||
context: {
|
||||
config: {
|
||||
...config,
|
||||
license_info: { ...config.license_info, automated_instances: null },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.find(`Detail[label="Hosts automated"]`).length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user