mirror of
https://github.com/ansible/awx.git
synced 2026-02-17 03:00:04 -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:
@@ -167,6 +167,11 @@ function JobTemplateDetail({ template }) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const buildLinkURL = (instance) =>
|
||||||
|
instance.is_container_group
|
||||||
|
? '/instance_groups/container_group/'
|
||||||
|
: '/instance_groups/';
|
||||||
|
|
||||||
if (instanceGroupsError) {
|
if (instanceGroupsError) {
|
||||||
return <ContentError error={instanceGroupsError} />;
|
return <ContentError error={instanceGroupsError} />;
|
||||||
}
|
}
|
||||||
@@ -322,9 +327,11 @@ function JobTemplateDetail({ template }) {
|
|||||||
value={
|
value={
|
||||||
<ChipGroup numChips={5} totalChips={instanceGroups.length}>
|
<ChipGroup numChips={5} totalChips={instanceGroups.length}>
|
||||||
{instanceGroups.map((ig) => (
|
{instanceGroups.map((ig) => (
|
||||||
<Chip key={ig.id} isReadOnly>
|
<Link to={`${buildLinkURL(ig)}${ig.id}/details`} key={ig.id}>
|
||||||
{ig.name}
|
<Chip key={ig.id} isReadOnly>
|
||||||
</Chip>
|
{ig.name}
|
||||||
|
</Chip>
|
||||||
|
</Link>
|
||||||
))}
|
))}
|
||||||
</ChipGroup>
|
</ChipGroup>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,6 +110,13 @@ describe('<JobTemplateDetail />', () => {
|
|||||||
expect(SCMBranch.prop('value')).toBe('Foo branch');
|
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 () => {
|
test('should show content error for failed instance group fetch', async () => {
|
||||||
JobTemplatesAPI.readInstanceGroups.mockImplementationOnce(() =>
|
JobTemplatesAPI.readInstanceGroups.mockImplementationOnce(() =>
|
||||||
Promise.reject(new Error())
|
Promise.reject(new Error())
|
||||||
|
|||||||
Reference in New Issue
Block a user