From 2917231d7dfb59dc71b030df3efa8c297311ac95 Mon Sep 17 00:00:00 2001 From: Jai <41024828+ChaiWithJai@users.noreply.github.com> Date: Thu, 18 May 2023 12:47:11 -0400 Subject: [PATCH] ui: add option to filter for jobs that are packs (#17226) * refact: update job model * refact: update view layer * refact: update test --- ui/app/controllers/jobs/index.js | 9 ++++++++- ui/app/controllers/optimize.js | 2 +- ui/app/models/job.js | 12 ++++++++---- ui/app/templates/components/job-row.hbs | 2 +- ui/tests/acceptance/jobs-list-test.js | 1 + 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ui/app/controllers/jobs/index.js b/ui/app/controllers/jobs/index.js index 906051ab9..9e5648065 100644 --- a/ui/app/controllers/jobs/index.js +++ b/ui/app/controllers/jobs/index.js @@ -91,6 +91,7 @@ export default class IndexController extends Controller.extend( get optionsType() { return [ { key: 'batch', label: 'Batch' }, + { key: 'pack', label: 'Pack' }, { key: 'parameterized', label: 'Parameterized' }, { key: 'periodic', label: 'Periodic' }, { key: 'service', label: 'Service' }, @@ -224,7 +225,13 @@ export default class IndexController extends Controller.extend( // A job must match ALL filter facets, but it can match ANY selection within a facet // Always return early to prevent unnecessary facet predicates. return this.visibleJobs.filter((job) => { - if (types.length && !types.includes(job.get('displayType'))) { + const shouldShowPack = types.includes('pack') && job.displayType.isPack; + + if (types.length && shouldShowPack) { + return true; + } + + if (types.length && !types.includes(job.get('displayType.type'))) { return false; } diff --git a/ui/app/controllers/optimize.js b/ui/app/controllers/optimize.js index 440891903..55164deda 100644 --- a/ui/app/controllers/optimize.js +++ b/ui/app/controllers/optimize.js @@ -192,7 +192,7 @@ export default class OptimizeController extends Controller { return false; } - if (types.length && !types.includes(job.get('displayType'))) { + if (types.length && !types.includes(job.get('displayType.type'))) { return false; } diff --git a/ui/app/models/job.js b/ui/app/models/job.js index 4f5f0a35c..35f7ddd02 100644 --- a/ui/app/models/job.js +++ b/ui/app/models/job.js @@ -31,6 +31,10 @@ export default class Job extends Model { @fragment('structured-attributes') meta; + get isPack() { + return !!this.meta?.structured?.pack; + } + // True when the job is the parent periodic or parameterized jobs // Instances of periodic or parameterized jobs are false for both properties @attr('boolean') periodic; @@ -69,14 +73,14 @@ export default class Job extends Model { // A composite of type and other job attributes to determine // a better type descriptor for human interpretation rather // than for scheduling. - @computed('type', 'periodic', 'parameterized') + @computed('isPack', 'type', 'periodic', 'parameterized') get displayType() { if (this.periodic) { - return 'periodic'; + return { type: 'periodic', isPack: this.isPack }; } else if (this.parameterized) { - return 'parameterized'; + return { type: 'parameterized', isPack: this.isPack }; } - return this.type; + return { type: this.type, isPack: this.isPack }; } // A composite of type and other job attributes to determine diff --git a/ui/app/templates/components/job-row.hbs b/ui/app/templates/components/job-row.hbs index 35065b49a..779167aae 100644 --- a/ui/app/templates/components/job-row.hbs +++ b/ui/app/templates/components/job-row.hbs @@ -41,7 +41,7 @@ - {{this.job.displayType}} + {{this.job.displayType.type}} {{this.job.priority}} diff --git a/ui/tests/acceptance/jobs-list-test.js b/ui/tests/acceptance/jobs-list-test.js index 234f5816e..9ce183430 100644 --- a/ui/tests/acceptance/jobs-list-test.js +++ b/ui/tests/acceptance/jobs-list-test.js @@ -270,6 +270,7 @@ module('Acceptance | jobs list', function (hooks) { paramName: 'type', expectedOptions: [ 'Batch', + 'Pack', 'Parameterized', 'Periodic', 'Service',