From 8a92a01652665168c3b24f2b562f6f7625bca376 Mon Sep 17 00:00:00 2001 From: nixocio Date: Fri, 10 Jun 2022 14:04:20 -0400 Subject: [PATCH] Add column to display resource related to a schedule Add column to display what resource is related to a schedule See: https://github.com/ansible/awx/issues/5012 --- .../Schedule/ScheduleList/ScheduleList.js | 3 +- .../Schedule/ScheduleList/ScheduleListItem.js | 16 +++++++- .../ScheduleList/ScheduleListItem.test.js | 39 +++++++++++++++++-- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/awx/ui/src/components/Schedule/ScheduleList/ScheduleList.js b/awx/ui/src/components/Schedule/ScheduleList/ScheduleList.js index 7f69eddb0a..0e559ef5ef 100644 --- a/awx/ui/src/components/Schedule/ScheduleList/ScheduleList.js +++ b/awx/ui/src/components/Schedule/ScheduleList/ScheduleList.js @@ -166,7 +166,8 @@ function ScheduleList({ headerRow={ {t`Name`} - {t`Type`} + {t`Related resource`} + {t`Resource type`} {t`Next Run`} {t`Actions`} diff --git a/awx/ui/src/components/Schedule/ScheduleList/ScheduleListItem.js b/awx/ui/src/components/Schedule/ScheduleList/ScheduleListItem.js index 6e26bdba61..0291f41597 100644 --- a/awx/ui/src/components/Schedule/ScheduleList/ScheduleListItem.js +++ b/awx/ui/src/components/Schedule/ScheduleList/ScheduleListItem.js @@ -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; @@ -94,7 +100,15 @@ function ScheduleListItem({ )} - + + + {schedule.summary_fields.unified_job_template.name} + + + { jobTypeLabels[ schedule.summary_fields.unified_job_template.unified_job_type diff --git a/awx/ui/src/components/Schedule/ScheduleList/ScheduleListItem.test.js b/awx/ui/src/components/Schedule/ScheduleList/ScheduleListItem.test.js index d10b6d2f00..9b35c0bbfb 100644 --- a/awx/ui/src/components/Schedule/ScheduleList/ScheduleListItem.test.js +++ b/awx/ui/src/components/Schedule/ScheduleList/ScheduleListItem.test.js @@ -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', () => { @@ -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); });