diff --git a/awx/ui/client/features/jobs/jobsList.controller.js b/awx/ui/client/features/jobs/jobsList.controller.js index d09101037e..2a7225de6a 100644 --- a/awx/ui/client/features/jobs/jobsList.controller.js +++ b/awx/ui/client/features/jobs/jobsList.controller.js @@ -142,28 +142,14 @@ function ListJobsController ( return { icon, link, value }; }); - vm.getSliceJobDetails = (job) => { - if (!job.job_slice_count) { - return null; - } - - if (job.job_slice_count === 1) { - return null; - } - - if (job.job_slice_number && job.job_slice_count) { + vm.getSecondaryTagLabel = (job) => { + if (job.job_slice_number && job.job_slice_count && job.job_slice_count > 1) { return `${strings.get('list.SLICE_JOB')} ${job.job_slice_number}/${job.job_slice_count}`; } - - return null; - }; - - vm.getWebhookDetails = (job) => { - if (job.launch_type !== 'webhook') { - return null; + if (job.launch_type === 'webhook') { + return strings.get('list.ROW_ITEM_LABEL_WEBHOOK'); } - - return strings.get('list.ROW_ITEM_LABEL_WEBHOOK'); + return null; }; vm.getTranslatedStatusString = (status) => { diff --git a/awx/ui/client/features/jobs/jobsList.view.html b/awx/ui/client/features/jobs/jobsList.view.html index 9c4cdff56f..50b25c1aff 100644 --- a/awx/ui/client/features/jobs/jobsList.view.html +++ b/awx/ui/client/features/jobs/jobsList.view.html @@ -34,7 +34,7 @@ header-value="{{ job.id }} - {{ job.name }}" header-state="{{ vm.getSref(job) }}" header-tag="{{ vm.jobTypes[job.type] }}" - secondary-tag="{{ vm.getSliceJobDetails(job) || vm.getWebhookDetails(job) }}"> + secondary-tag="{{ vm.getSecondaryTagLabel(job) }}">
diff --git a/awx/ui/test/unit/components/index.js b/awx/ui/test/unit/components/index.js index 16d45da9c7..7ae48d5dbc 100644 --- a/awx/ui/test/unit/components/index.js +++ b/awx/ui/test/unit/components/index.js @@ -6,6 +6,6 @@ import './file.unit'; import './layout.unit'; import './side-nav.unit'; import './side-nav-item.unit'; -import './jobs-list-split-jobs.unit'; +import './jobs-list.unit'; import './job-details-split-jobs.unit'; import './stream.unit'; diff --git a/awx/ui/test/unit/components/jobs-list-split-jobs.unit.js b/awx/ui/test/unit/components/jobs-list.unit.js similarity index 71% rename from awx/ui/test/unit/components/jobs-list-split-jobs.unit.js rename to awx/ui/test/unit/components/jobs-list.unit.js index 6cc4ff7ae0..845225201c 100644 --- a/awx/ui/test/unit/components/jobs-list-split-jobs.unit.js +++ b/awx/ui/test/unit/components/jobs-list.unit.js @@ -36,6 +36,9 @@ describe('View: Split Jobs List', () => { if (str === 'list.SLICE_JOB') { return 'Slice Job'; } + if (str === 'list.ROW_ITEM_LABEL_WEBHOOK') { + return 'Webhook'; + } return ''; } }; @@ -96,40 +99,51 @@ describe('View: Split Jobs List', () => { it('is created successfully', () => { expect(JobList).toBeDefined(); }); - it('has method "getSplitJobDetails"', () => { - expect(JobList.getSliceJobDetails).toBeDefined(); + it('has method "getSecondaryTagLabel"', () => { + expect(JobList.getSecondaryTagLabel).toBeDefined(); }); - it('returns a string', () => { + it('returns the expected string when slice data is available', () => { const data = { job_slice_number: 1, - job_slice_count: 2 + job_slice_count: 2, + launch_type: 'manual', }; - const result = JobList.getSliceJobDetails(data); + const result = JobList.getSecondaryTagLabel(data); expect(result).toEqual('Slice Job 1/2'); }); - it('returns null when data is null', () => { + it('returns null when slice data is null', () => { const data = { job_slice_number: null, - job_slice_count: null + job_slice_count: null, + launch_type: 'manual', }; - const result = JobList.getSliceJobDetails(data); + const result = JobList.getSecondaryTagLabel(data); expect(result).toBeNull(); }); - it('returns null when data is undefined', () => { + it('returns null when slice data is undefined', () => { const data = { job_slice_number: undefined, - job_slice_count: undefined + job_slice_count: undefined, + launch_type: 'manual', }; - const result = JobList.getSliceJobDetails(data); + const result = JobList.getSecondaryTagLabel(data); expect(result).toBeNull(); }); - it('returns null when job is not a sliced job', () => { + it('returns null when job is not a sliced or webhook job', () => { const data = { job_slice_number: null, - job_slice_count: 1 + job_slice_count: 1, + launch_type: 'manual', }; - const result = JobList.getSliceJobDetails(data); + const result = JobList.getSecondaryTagLabel(data); expect(result).toBeNull(); }); + it('returns the expected string for webhook jobs', () => { + const data = { + launch_type: 'webhook', + }; + const result = JobList.getSecondaryTagLabel(data); + expect(result).toEqual('Webhook'); + }); }); });