mirror of
https://github.com/ansible/awx.git
synced 2026-05-18 06:47:41 -02: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:
@@ -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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<RoutedTabs tabsArray={tabsArray} />
|
<RoutedTabs tabsArray={tabsArray} />
|
||||||
@@ -127,19 +134,23 @@ function SubscriptionDetail() {
|
|||||||
label={t`Hosts imported`}
|
label={t`Hosts imported`}
|
||||||
value={license_info.current_instances}
|
value={license_info.current_instances}
|
||||||
/>
|
/>
|
||||||
<Detail
|
{typeof automatedInstancesCount !== 'undefined' &&
|
||||||
dataCy="subscription-hosts-automated"
|
automatedInstancesCount !== null && (
|
||||||
label={t`Hosts automated`}
|
<Detail
|
||||||
value={
|
dataCy="subscription-hosts-automated"
|
||||||
<>
|
label={t`Hosts automated`}
|
||||||
{license_info.automated_instances} <Trans>since</Trans>{' '}
|
value={
|
||||||
{license_info.automated_since &&
|
automated_since ? (
|
||||||
formatDateString(
|
<Trans>
|
||||||
new Date(license_info.automated_since * 1000).toISOString()
|
{automatedInstancesCount} since{' '}
|
||||||
)}
|
{automatedInstancesSinceDateTime}
|
||||||
</>
|
</Trans>
|
||||||
}
|
) : (
|
||||||
/>
|
automatedInstancesCount
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Detail
|
<Detail
|
||||||
dataCy="subscription-hosts-remaining"
|
dataCy="subscription-hosts-remaining"
|
||||||
label={t`Hosts remaining`}
|
label={t`Hosts remaining`}
|
||||||
|
|||||||
@@ -82,4 +82,17 @@ describe('<SubscriptionDetail />', () => {
|
|||||||
|
|
||||||
expect(wrapper.find('Button[aria-label="edit"]').length).toBe(1);
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user