Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add column to display resource related to a schedule #12360

Merged
merged 1 commit into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion awx/ui/src/components/Schedule/ScheduleList/ScheduleList.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ function ScheduleList({
headerRow={
<HeaderRow qsConfig={QS_CONFIG}>
<HeaderCell sortKey="name">{t`Name`}</HeaderCell>
<HeaderCell sortKey="unified_job_template__polymorphic_ctype__model">{t`Type`}</HeaderCell>
<HeaderCell sortKey="unified_job_template">{t`Related resource`}</HeaderCell>
<HeaderCell sortKey="unified_job_template__polymorphic_ctype__model">{t`Resource type`}</HeaderCell>
<HeaderCell sortKey="next_run">{t`Next Run`}</HeaderCell>
<HeaderCell>{t`Actions`}</HeaderCell>
</HeaderRow>
Expand Down
16 changes: 15 additions & 1 deletion awx/ui/src/components/Schedule/ScheduleList/ScheduleListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,28 @@ function ScheduleListItem({
};

let scheduleBaseUrl;
let relatedResourceUrl;

switch (schedule.summary_fields.unified_job_template.unified_job_type) {
case 'inventory_update':
scheduleBaseUrl = `/inventories/inventory/${schedule.summary_fields.inventory.id}/sources/${schedule.summary_fields.unified_job_template.id}/schedules/${schedule.id}`;
relatedResourceUrl = `/inventories/inventory/${schedule.summary_fields.inventory.id}/sources/${schedule.summary_fields.unified_job_template.id}/details`;
break;
case 'job':
scheduleBaseUrl = `/templates/job_template/${schedule.summary_fields.unified_job_template.id}/schedules/${schedule.id}`;
relatedResourceUrl = `/templates/job_template/${schedule.summary_fields.unified_job_template.id}/details`;
break;
case 'project_update':
scheduleBaseUrl = `/projects/${schedule.summary_fields.unified_job_template.id}/schedules/${schedule.id}`;
relatedResourceUrl = `/projects/${schedule.summary_fields.unified_job_template.id}/details`;
break;
case 'system_job':
scheduleBaseUrl = `/management_jobs/${schedule.summary_fields.unified_job_template.id}/schedules/${schedule.id}`;
relatedResourceUrl = `/management_jobs`;
break;
case 'workflow_job':
scheduleBaseUrl = `/templates/workflow_job_template/${schedule.summary_fields.unified_job_template.id}/schedules/${schedule.id}`;
relatedResourceUrl = `/templates/workflow_job_template/${schedule.summary_fields.unified_job_template.id}/details`;
break;
default:
break;
Expand Down Expand Up @@ -94,7 +100,15 @@ function ScheduleListItem({
</span>
)}
</TdBreakWord>
<Td dataLabel={t`Type`}>
<TdBreakWord
id={`related-resource-${schedule.id}`}
dataLabel={t`Related resource`}
>
<Link to={`${relatedResourceUrl}`}>
<b>{schedule.summary_fields.unified_job_template.name}</b>
</Link>
</TdBreakWord>
<Td dataLabel={t`Resource type`}>
{
jobTypeLabels[
schedule.summary_fields.unified_job_template.unified_job_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,30 @@ describe('ScheduleListItem', () => {
});

test('Name correctly shown with correct link', () => {
expect(wrapper.find('Td').at(1).prop('dataLabel')).toBe('Name');
expect(wrapper.find('Td').at(1).text()).toBe('Mock Schedule');
expect(wrapper.find('Td').at(1).find('Link').props().to).toBe(
'/templates/job_template/12/schedules/6/details'
);
});

test('Type correctly shown', () => {
expect(wrapper.find('Td').at(2).text()).toBe('Playbook Run');
test('Related resource correctly shown', () => {
expect(wrapper.find('Td').at(2).prop('dataLabel')).toBe(
'Related resource'
);
expect(wrapper.find('Td').at(2).text()).toBe('Mock JT');
});

test('Resource type correctly shown', () => {
expect(wrapper.find('Td').at(3).prop('dataLabel')).toBe('Resource type');
expect(wrapper.find('Td').at(3).text()).toBe('Playbook Run');
});

test('Next run correctly shown', () => {
expect(wrapper.find('Td').at(4).prop('dataLabel')).toBe('Next Run');
expect(wrapper.find('Td').at(4).text()).toBe(
'Next Run2/20/2020, 12:00:00 AM'
);
});

test('Edit button shown with correct link', () => {
Expand Down Expand Up @@ -120,16 +136,31 @@ describe('ScheduleListItem', () => {
});

test('Name correctly shown with correct link', () => {
expect(wrapper.find('Td').at(1).prop('dataLabel')).toBe('Name');
expect(wrapper.find('Td').at(1).text()).toBe('Mock Schedule');
expect(wrapper.find('Td').at(1).find('Link').props().to).toBe(
'/templates/job_template/12/schedules/6/details'
);
});

test('Type correctly shown', () => {
expect(wrapper.find('Td').at(2).text()).toBe('Playbook Run');
test('Related resource correctly shown', () => {
expect(wrapper.find('Td').at(2).prop('dataLabel')).toBe(
'Related resource'
);
expect(wrapper.find('Td').at(2).text()).toBe('Mock JT');
});

test('Resource type correctly shown', () => {
expect(wrapper.find('Td').at(3).prop('dataLabel')).toBe('Resource type');
expect(wrapper.find('Td').at(3).text()).toBe('Playbook Run');
});

test('Next run correctly shown', () => {
expect(wrapper.find('Td').at(4).prop('dataLabel')).toBe('Next Run');
expect(wrapper.find('Td').at(4).text()).toBe(
'Next Run2/20/2020, 12:00:00 AM'
);
});
test('Edit button hidden', () => {
expect(wrapper.find('PencilAltIcon').length).toBe(0);
});
Expand Down