From 23709d2814c79ff277f6337dc6982022e6d779af Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Tue, 11 Apr 2023 12:16:27 -0400 Subject: [PATCH] [ui, deployments] Linking allocblocks and legends to allocation / allocations index routes (#16821) * Conditional link-to component and basic linking to allocations and allocation routes * Job versions filter added to allocations index page * Steady state legends link * Legend links * Badge count links for versions * Fix: faded class on steady-state legend items * version link now wont show completed ones * Fix a11y violations with link labels --- ui/app/components/conditional-link-to.hbs | 9 +++++ ui/app/components/conditional-link-to.js | 7 ++++ .../job-status/allocation-status-block.hbs | 24 +++++++++--- .../job-status/allocation-status-row.hbs | 12 ++++-- .../components/job-status/panel/deploying.hbs | 15 +++++-- ui/app/components/job-status/panel/steady.hbs | 17 ++++++-- ui/app/components/job-status/panel/steady.js | 2 +- ui/app/controllers/jobs/job/allocations.js | 39 ++++++++++++++++++- .../styles/components/job-status-panel.scss | 7 ++++ ui/app/templates/jobs/job/allocations.hbs | 7 ++++ 10 files changed, 120 insertions(+), 19 deletions(-) create mode 100644 ui/app/components/conditional-link-to.hbs create mode 100644 ui/app/components/conditional-link-to.js diff --git a/ui/app/components/conditional-link-to.hbs b/ui/app/components/conditional-link-to.hbs new file mode 100644 index 000000000000..00766532da50 --- /dev/null +++ b/ui/app/components/conditional-link-to.hbs @@ -0,0 +1,9 @@ +{{#if @condition}} + + {{yield}} + +{{else}} + + {{yield}} + +{{/if}} \ No newline at end of file diff --git a/ui/app/components/conditional-link-to.js b/ui/app/components/conditional-link-to.js new file mode 100644 index 000000000000..7dd1d3b31b0d --- /dev/null +++ b/ui/app/components/conditional-link-to.js @@ -0,0 +1,7 @@ +import Component from '@glimmer/component'; + +export default class ConditionalLinkToComponent extends Component { + get query() { + return this.args.query || {}; + } +} diff --git a/ui/app/components/job-status/allocation-status-block.hbs b/ui/app/components/job-status/allocation-status-block.hbs index ab5099365023..c609192633c5 100644 --- a/ui/app/components/job-status/allocation-status-block.hbs +++ b/ui/app/components/job-status/allocation-status-block.hbs @@ -4,8 +4,14 @@ > {{#if this.countToShow}}
- {{#each (range 0 this.countToShow)}} - + {{#each (range 0 this.countToShow) as |i|}} + {{#unless @steady}} {{#if (eq @status "running")}} @@ -17,12 +23,20 @@ {{/if}} {{/unless}} - + {{/each}}
{{/if}} {{#if this.remaining}} - + + {{#if this.countToShow}}+{{/if}}{{this.remaining}} {{#unless @steady}} {{#if (eq @canary "canary")}} @@ -38,6 +52,6 @@ {{/if}} {{/unless}} - + {{/if}} \ No newline at end of file diff --git a/ui/app/components/job-status/allocation-status-row.hbs b/ui/app/components/job-status/allocation-status-row.hbs index f56ba36da9ed..2b04ecb56b3a 100644 --- a/ui/app/components/job-status/allocation-status-row.hbs +++ b/ui/app/components/job-status/allocation-status-row.hbs @@ -30,8 +30,14 @@ {{#each-in allocsByStatus as |health allocsByHealth|}} {{#each-in allocsByHealth as |canary allocsByCanary|}} {{#if (gt allocsByCanary.length 0)}} - {{#each (range 0 allocsByCanary.length)}} - + {{#each (range 0 allocsByCanary.length) as |i|}} + {{#unless @steady}} {{#if (eq canary "canary")}} @@ -46,7 +52,7 @@ {{/if}} {{/unless}} - + {{/each}} {{/if}} {{/each-in}} diff --git a/ui/app/components/job-status/panel/deploying.hbs b/ui/app/components/job-status/panel/deploying.hbs index d84095725a11..25c1a5eac154 100644 --- a/ui/app/components/job-status/panel/deploying.hbs +++ b/ui/app/components/job-status/panel/deploying.hbs @@ -62,10 +62,17 @@ {{!-- Legend by Status, then by Health, then by Canary --}} {{#each-in this.newAllocsByStatus as |status count|}} - + - {{count}} {{capitalize status}} - + {{count}} {{capitalize status}} + {{/each-in}} {{#each-in this.newAllocsByHealth as |health count|}} @@ -75,7 +82,7 @@ {{#if (eq health "healthy")}} {{else}} - + {{/if}} diff --git a/ui/app/components/job-status/panel/steady.hbs b/ui/app/components/job-status/panel/steady.hbs index 759f179bccac..b76221ef707e 100644 --- a/ui/app/components/job-status/panel/steady.hbs +++ b/ui/app/components/job-status/panel/steady.hbs @@ -27,10 +27,17 @@
{{#each this.allocTypes as |type|}} - + {{get (get (get (get this.allocBlocks type.label) 'healthy') 'nonCanary') "length"}} {{capitalize type.label}} - + {{/each}} @@ -39,8 +46,10 @@
    {{#each-in this.versions as |version allocs|}}
  • - - + + + +
  • {{/each-in}}
diff --git a/ui/app/components/job-status/panel/steady.js b/ui/app/components/job-status/panel/steady.js index 3db040b52438..77a391d2a082 100644 --- a/ui/app/components/job-status/panel/steady.js +++ b/ui/app/components/job-status/panel/steady.js @@ -75,7 +75,7 @@ export default class JobStatusPanelSteadyComponent extends Component { .flatMap((allocType) => Object.values(allocType)) .flatMap((allocHealth) => Object.values(allocHealth)) .flatMap((allocCanary) => Object.values(allocCanary)) - .map((a) => (!isNaN(a?.jobVersion) ? `v${a.jobVersion}` : 'pending')) // "starting" allocs, and possibly others, do not yet have a jobVersion + .map((a) => (!isNaN(a?.jobVersion) ? a.jobVersion : 'pending')) // "starting" allocs, and possibly others, do not yet have a jobVersion .reduce( (result, item) => ({ ...result, diff --git a/ui/app/controllers/jobs/job/allocations.js b/ui/app/controllers/jobs/job/allocations.js index 68c84487a5c2..112aec007a92 100644 --- a/ui/app/controllers/jobs/job/allocations.js +++ b/ui/app/controllers/jobs/job/allocations.js @@ -41,12 +41,16 @@ export default class AllocationsController extends Controller.extend( { qpTaskGroup: 'taskGroup', }, + { + qpVersion: 'version', + }, 'activeTask', ]; qpStatus = ''; qpClient = ''; qpTaskGroup = ''; + qpVersion = ''; currentPage = 1; pageSize = 25; activeTask = null; @@ -70,10 +74,16 @@ export default class AllocationsController extends Controller.extend( 'allocations.[]', 'selectionStatus', 'selectionClient', - 'selectionTaskGroup' + 'selectionTaskGroup', + 'selectionVersion' ) get filteredAllocations() { - const { selectionStatus, selectionClient, selectionTaskGroup } = this; + const { + selectionStatus, + selectionClient, + selectionTaskGroup, + selectionVersion, + } = this; return this.allocations.filter((alloc) => { if ( @@ -94,6 +104,12 @@ export default class AllocationsController extends Controller.extend( ) { return false; } + if ( + selectionVersion.length && + !selectionVersion.includes(alloc.jobVersion) + ) { + return false; + } return true; }); } @@ -105,6 +121,7 @@ export default class AllocationsController extends Controller.extend( @selection('qpStatus') selectionStatus; @selection('qpClient') selectionClient; @selection('qpTaskGroup') selectionTaskGroup; + @selection('qpVersion') selectionVersion; @action gotoAllocation(allocation) { @@ -158,6 +175,24 @@ export default class AllocationsController extends Controller.extend( return taskGroups.sort().map((tg) => ({ key: tg, label: tg })); } + @computed('model.allocations.[]', 'selectionVersion') + get optionsVersions() { + const versions = Array.from( + new Set(this.model.allocations.mapBy('jobVersion')) + ).compact(); + + // Update query param when the list of versions changes. + scheduleOnce('actions', () => { + // eslint-disable-next-line ember/no-side-effects + this.set( + 'qpVersion', + serialize(intersection(versions, this.selectionVersion)) + ); + }); + + return versions.sort((a, b) => a - b).map((v) => ({ key: v, label: v })); + } + setFacetQueryParam(queryParam, selection) { this.set(queryParam, serialize(selection)); } diff --git a/ui/app/styles/components/job-status-panel.scss b/ui/app/styles/components/job-status-panel.scss index 7945e1a2c4e5..fb939f73aa6e 100644 --- a/ui/app/styles/components/job-status-panel.scss +++ b/ui/app/styles/components/job-status-panel.scss @@ -65,6 +65,9 @@ gap: 0.5rem; & > li { white-space: nowrap; + & a { + text-decoration: none; + } } } } @@ -302,6 +305,10 @@ } } + .legend-item .represented-allocation .flight-icon { + animation: none; + } + & > .boxed-section-body > .deployment-allocations { margin-bottom: 1rem; } diff --git a/ui/app/templates/jobs/job/allocations.hbs b/ui/app/templates/jobs/job/allocations.hbs index a7f520adba7c..767a1cd2696b 100644 --- a/ui/app/templates/jobs/job/allocations.hbs +++ b/ui/app/templates/jobs/job/allocations.hbs @@ -33,6 +33,13 @@ @selection={{this.selectionTaskGroup}} @onSelect={{action this.setFacetQueryParam "qpTaskGroup"}} /> +