From 648b71c96aa727a9dc5b1bf09710ea75ce48716b Mon Sep 17 00:00:00 2001 From: Luiz Aoqui Date: Fri, 17 Dec 2021 17:38:04 -0500 Subject: [PATCH] ui: display empty message in the client details page if there are no allocations to show --- ui/app/controllers/clients/client/index.js | 19 ++--- ui/app/templates/clients/client/index.hbs | 99 +++++++++++++--------- ui/tests/acceptance/client-detail-test.js | 22 +++++ ui/tests/pages/clients/detail.js | 6 ++ 4 files changed, 95 insertions(+), 51 deletions(-) diff --git a/ui/app/controllers/clients/client/index.js b/ui/app/controllers/clients/client/index.js index b3cc6fea0..a918a7b82 100644 --- a/ui/app/controllers/clients/client/index.js +++ b/ui/app/controllers/clients/client/index.js @@ -61,19 +61,16 @@ export default class ClientController extends Controller.extend(Sortable, Search onlyPreemptions = false; - @computed( - 'model.allocations.[]', - 'preemptions.[]', - 'onlyPreemptions', - 'selectionNamespace', - 'selectionJob', - 'selectionStatus' - ) + @computed('model.allocations.[]', 'preemptions.[]', 'onlyPreemptions') get visibleAllocations() { - const allocations = this.onlyPreemptions ? this.preemptions : this.model.allocations; + return this.onlyPreemptions ? this.preemptions : this.model.allocations; + } + + @computed('visibleAllocations.[]', 'selectionNamespace', 'selectionJob', 'selectionStatus') + get filteredAllocations() { const { selectionNamespace, selectionJob, selectionStatus } = this; - return allocations.filter(alloc => { + return this.visibleAllocations.filter(alloc => { if (selectionNamespace.length && !selectionNamespace.includes(alloc.get('namespace'))) { return false; } @@ -87,7 +84,7 @@ export default class ClientController extends Controller.extend(Sortable, Search }); } - @alias('visibleAllocations') listToSort; + @alias('filteredAllocations') listToSort; @alias('listSorted') listToSearch; @alias('listSearched') sortedAllocations; diff --git a/ui/app/templates/clients/client/index.hbs b/ui/app/templates/clients/client/index.hbs index 429cbce55..7e623678c 100644 --- a/ui/app/templates/clients/client/index.hbs +++ b/ui/app/templates/clients/client/index.hbs @@ -325,47 +325,66 @@ /> -
- - - - - ID - Created - Modified - Status - Job - Version - Volume - CPU - Memory - - - - - -
- +
+ {{#if this.sortedAllocations.length}} + + + + + ID + Created + Modified + Status + Job + Version + Volume + CPU + Memory + + + + + +
+ +
+
+ {{else}} +
+ {{#if (eq this.visibleAllocations.length 0)}} +

No Allocations

+

+ The node doesn't have any allocations. +

+ {{else if this.searchTerm}} +

No Matches

+

No allocations match the term {{this.searchTerm}}

+ {{else if (eq this.sortedAllocations.length 0)}} +

No Matches

+

+ No allocations match your current filter selection. +

+ {{/if}}
- + {{/if}}
diff --git a/ui/tests/acceptance/client-detail-test.js b/ui/tests/acceptance/client-detail-test.js index f44718255..cfd9042ad 100644 --- a/ui/tests/acceptance/client-detail-test.js +++ b/ui/tests/acceptance/client-detail-test.js @@ -130,6 +130,15 @@ module('Acceptance | client detail', function(hooks) { ); }); + test('/clients/:id should show empty message if there are no allocations on the node', async function(assert) { + const emptyNode = server.create('node'); + + await ClientDetail.visit({ id: emptyNode.id }); + + assert.true(ClientDetail.emptyAllocations.isVisible, 'Empty message is visible'); + assert.equal(ClientDetail.emptyAllocations.headline, 'No Allocations'); + }); + test('each allocation should have high-level details for the allocation', async function(assert) { const allocation = server.db.allocations .where({ nodeId: node.id }) @@ -1028,6 +1037,19 @@ module('Acceptance | client detail', function(hooks) { }, filter: (alloc, selection) => selection.includes(alloc.clientStatus), }); + + test('fiter results with no matches display empty message', async function(assert) { + const job = server.create('job', { createAllocations: false }); + server.create('allocation', { jobId: job.id, clientStatus: 'running' }); + + await ClientDetail.visit({ id: node.id }); + const statusFacet = ClientDetail.facets.status; + await statusFacet.toggle(); + await statusFacet.options.objectAt(0).toggle(); + + assert.true(ClientDetail.emptyAllocations.isVisible); + assert.equal(ClientDetail.emptyAllocations.headline, 'No Matches'); + }); }); module('Acceptance | client detail (multi-namespace)', function(hooks) { diff --git a/ui/tests/pages/clients/detail.js b/ui/tests/pages/clients/detail.js index daa6e647a..bcfe0d2de 100644 --- a/ui/tests/pages/clients/detail.js +++ b/ui/tests/pages/clients/detail.js @@ -39,6 +39,12 @@ export default create({ ...allocations(), + emptyAllocations: { + scope: '[data-test-empty-allocations-list]', + headline: text('[data-test-empty-allocations-list-headline]'), + body: text('[data-test-empty-allocations-list-body]'), + }, + allocationFilter: { preemptions: clickable('[data-test-filter-preemptions]'), all: clickable('[data-test-filter-all]'),