mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03:30
Linkify instance/container groups job template
Linkify instance/container groups job template See: https://github.com/ansible/awx/issues/11352
This commit is contained in:
parent
099efb883d
commit
c665caaf35
@ -167,6 +167,11 @@ function JobTemplateDetail({ template }) {
|
||||
);
|
||||
};
|
||||
|
||||
const buildLinkURL = (instance) =>
|
||||
instance.is_container_group
|
||||
? '/instance_groups/container_group/'
|
||||
: '/instance_groups/';
|
||||
|
||||
if (instanceGroupsError) {
|
||||
return <ContentError error={instanceGroupsError} />;
|
||||
}
|
||||
@ -322,9 +327,11 @@ function JobTemplateDetail({ template }) {
|
||||
value={
|
||||
<ChipGroup numChips={5} totalChips={instanceGroups.length}>
|
||||
{instanceGroups.map((ig) => (
|
||||
<Chip key={ig.id} isReadOnly>
|
||||
{ig.name}
|
||||
</Chip>
|
||||
<Link to={`${buildLinkURL(ig)}${ig.id}/details`} key={ig.id}>
|
||||
<Chip key={ig.id} isReadOnly>
|
||||
{ig.name}
|
||||
</Chip>
|
||||
</Link>
|
||||
))}
|
||||
</ChipGroup>
|
||||
}
|
||||
|
||||
@ -110,6 +110,13 @@ describe('<JobTemplateDetail />', () => {
|
||||
expect(SCMBranch.prop('value')).toBe('Foo branch');
|
||||
});
|
||||
|
||||
test('should render instance groups link', async () => {
|
||||
const instanceGroups = wrapper.find('Detail[label="Instance Groups"]');
|
||||
expect(
|
||||
instanceGroups.find('Link[to="/instance_groups/2/details"]')
|
||||
).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('should show content error for failed instance group fetch', async () => {
|
||||
JobTemplatesAPI.readInstanceGroups.mockImplementationOnce(() =>
|
||||
Promise.reject(new Error())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user