mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 15:36:04 -03:30
Add remaining expanded template list item details
This commit is contained in:
@@ -225,25 +225,27 @@ function TemplateListItem({
|
|||||||
<Td colSpan={4}>
|
<Td colSpan={4}>
|
||||||
<ExpandableRowContent>
|
<ExpandableRowContent>
|
||||||
<DetailList>
|
<DetailList>
|
||||||
|
<Detail
|
||||||
|
label={i18n._(t`Description`)}
|
||||||
|
value={template.description}
|
||||||
|
dataCy={`template-${template.id}-description`}
|
||||||
|
/>
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Activity`)}
|
label={i18n._(t`Activity`)}
|
||||||
value={<Sparkline jobs={summaryFields.recent_jobs} />}
|
value={<Sparkline jobs={summaryFields.recent_jobs} />}
|
||||||
dataCy={`template-${template.id}-activity`}
|
dataCy={`template-${template.id}-activity`}
|
||||||
/>
|
/>
|
||||||
{summaryFields.credentials && summaryFields.credentials.length && (
|
{summaryFields.organization && (
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Credentials`)}
|
label={i18n._(t`Organization`)}
|
||||||
value={
|
value={
|
||||||
<ChipGroup
|
<Link
|
||||||
numChips={5}
|
to={`/organizations/${summaryFields.organization.id}/details`}
|
||||||
totalChips={summaryFields.credentials.length}
|
|
||||||
>
|
>
|
||||||
{summaryFields.credentials.map(c => (
|
{summaryFields.organization.name}
|
||||||
<CredentialChip key={c.id} credential={c} isReadOnly />
|
</Link>
|
||||||
))}
|
|
||||||
</ChipGroup>
|
|
||||||
}
|
}
|
||||||
dataCy={`template-${template.id}-credentials`}
|
dataCy={`template-${template.id}-organization`}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{summaryFields.inventory ? (
|
{summaryFields.inventory ? (
|
||||||
@@ -260,24 +262,6 @@ function TemplateListItem({
|
|||||||
<DeletedDetail label={i18n._(t`Inventory`)} />
|
<DeletedDetail label={i18n._(t`Inventory`)} />
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
{summaryFields.labels && summaryFields.labels.results.length > 0 && (
|
|
||||||
<Detail
|
|
||||||
label={i18n._(t`Labels`)}
|
|
||||||
value={
|
|
||||||
<ChipGroup
|
|
||||||
numChips={5}
|
|
||||||
totalChips={summaryFields.labels.results.length}
|
|
||||||
>
|
|
||||||
{summaryFields.labels.results.map(l => (
|
|
||||||
<Chip key={l.id} isReadOnly>
|
|
||||||
{l.name}
|
|
||||||
</Chip>
|
|
||||||
))}
|
|
||||||
</ChipGroup>
|
|
||||||
}
|
|
||||||
dataCy={`template-${template.id}-labels`}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{summaryFields.project && (
|
{summaryFields.project && (
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Project`)}
|
label={i18n._(t`Project`)}
|
||||||
@@ -294,6 +278,42 @@ function TemplateListItem({
|
|||||||
value={formatDateString(template.modified)}
|
value={formatDateString(template.modified)}
|
||||||
dataCy={`template-${template.id}-last-modified`}
|
dataCy={`template-${template.id}-last-modified`}
|
||||||
/>
|
/>
|
||||||
|
{summaryFields.credentials && summaryFields.credentials.length && (
|
||||||
|
<Detail
|
||||||
|
fullWidth
|
||||||
|
label={i18n._(t`Credentials`)}
|
||||||
|
value={
|
||||||
|
<ChipGroup
|
||||||
|
numChips={5}
|
||||||
|
totalChips={summaryFields.credentials.length}
|
||||||
|
>
|
||||||
|
{summaryFields.credentials.map(c => (
|
||||||
|
<CredentialChip key={c.id} credential={c} isReadOnly />
|
||||||
|
))}
|
||||||
|
</ChipGroup>
|
||||||
|
}
|
||||||
|
dataCy={`template-${template.id}-credentials`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{summaryFields.labels && summaryFields.labels.results.length > 0 && (
|
||||||
|
<Detail
|
||||||
|
fullWidth
|
||||||
|
label={i18n._(t`Labels`)}
|
||||||
|
value={
|
||||||
|
<ChipGroup
|
||||||
|
numChips={5}
|
||||||
|
totalChips={summaryFields.labels.results.length}
|
||||||
|
>
|
||||||
|
{summaryFields.labels.results.map(l => (
|
||||||
|
<Chip key={l.id} isReadOnly>
|
||||||
|
{l.name}
|
||||||
|
</Chip>
|
||||||
|
))}
|
||||||
|
</ChipGroup>
|
||||||
|
}
|
||||||
|
dataCy={`template-${template.id}-labels`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</DetailList>
|
</DetailList>
|
||||||
</ExpandableRowContent>
|
</ExpandableRowContent>
|
||||||
</Td>
|
</Td>
|
||||||
|
|||||||
@@ -377,4 +377,66 @@ describe('<TemplateListItem />', () => {
|
|||||||
'Custom virtual environment /var/lib/awx/env must be replaced by an execution environment.'
|
'Custom virtual environment /var/lib/awx/env must be replaced by an execution environment.'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render expected details in expanded section', async () => {
|
||||||
|
const wrapper = mountWithContexts(
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<TemplateListItem
|
||||||
|
isSelected={false}
|
||||||
|
detailUrl="/templates/job_template/1/details"
|
||||||
|
template={{
|
||||||
|
...mockJobTemplateData,
|
||||||
|
description: 'mock description',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
wrapper
|
||||||
|
.find('Tr')
|
||||||
|
.last()
|
||||||
|
.prop('isExpanded')
|
||||||
|
).toBe(false);
|
||||||
|
await act(async () =>
|
||||||
|
wrapper.find('button[aria-label="Details"]').simulate('click')
|
||||||
|
);
|
||||||
|
wrapper.update();
|
||||||
|
expect(
|
||||||
|
wrapper
|
||||||
|
.find('Tr')
|
||||||
|
.last()
|
||||||
|
.prop('isExpanded')
|
||||||
|
).toBe(true);
|
||||||
|
|
||||||
|
function assertDetail(label, value) {
|
||||||
|
expect(wrapper.find(`Detail[label="${label}"] dt`).text()).toBe(label);
|
||||||
|
expect(wrapper.find(`Detail[label="${label}"] dd`).text()).toBe(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertDetail('Description', 'mock description');
|
||||||
|
assertDetail('Organization', "Mike's Org");
|
||||||
|
assertDetail('Inventory', "Mike's Inventory");
|
||||||
|
assertDetail('Project', "Mike's Project");
|
||||||
|
expect(
|
||||||
|
wrapper.find('Detail[label="Credentials"]').containsAllMatchingElements([
|
||||||
|
<span>
|
||||||
|
<strong>SSH:</strong>Credential 1
|
||||||
|
</span>,
|
||||||
|
<span>
|
||||||
|
<strong>Awx:</strong>Credential 2
|
||||||
|
</span>,
|
||||||
|
])
|
||||||
|
).toEqual(true);
|
||||||
|
expect(
|
||||||
|
wrapper
|
||||||
|
.find('Detail[label="Labels"]')
|
||||||
|
.containsAllMatchingElements([<span>L_91o2</span>])
|
||||||
|
).toEqual(true);
|
||||||
|
expect(wrapper.find('Detail[label="Organization"] dd a').prop('href')).toBe(
|
||||||
|
'/organizations/1/details'
|
||||||
|
);
|
||||||
|
expect(wrapper.find(`Detail[label="Activity"] Sparkline`)).toHaveLength(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,6 +28,11 @@
|
|||||||
"webhook_key": "/api/v2/job_templates/7/webhook_key/"
|
"webhook_key": "/api/v2/job_templates/7/webhook_key/"
|
||||||
},
|
},
|
||||||
"summary_fields": {
|
"summary_fields": {
|
||||||
|
"organization": {
|
||||||
|
"id": 1,
|
||||||
|
"name": "Mike's Org",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
"inventory": {
|
"inventory": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"name": "Mike's Inventory",
|
"name": "Mike's Inventory",
|
||||||
|
|||||||
Reference in New Issue
Block a user