From 35fcf69914fe93f13b6a3c2673562a4734213546 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Mon, 13 Jul 2020 14:22:58 +0100 Subject: [PATCH] ui: Move dc sorting to the view/template (#8297) * ui: Move dc sorting to the view/template * Cleanup unused coordinates service from Node repo * Fix up integration test to not expect a sorted result --- ui-v2/app/components/hashicorp-consul/index.hbs | 2 +- ui-v2/app/services/repository/dc.js | 5 +---- ui-v2/app/services/repository/node.js | 2 -- ui-v2/tests/integration/services/repository/dc-test.js | 6 +----- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/ui-v2/app/components/hashicorp-consul/index.hbs b/ui-v2/app/components/hashicorp-consul/index.hbs index a41d1c15d1..c9fb5bdd83 100644 --- a/ui-v2/app/components/hashicorp-consul/index.hbs +++ b/ui-v2/app/components/hashicorp-consul/index.hbs @@ -70,7 +70,7 @@ @loading="lazy" /> - {{#each dcs as |item|}} + {{#each (sort-by 'Name' dcs) as |item|}}
  • {{item.Name}}
  • diff --git a/ui-v2/app/services/repository/dc.js b/ui-v2/app/services/repository/dc.js index d81106b40d..e343796254 100644 --- a/ui-v2/app/services/repository/dc.js +++ b/ui-v2/app/services/repository/dc.js @@ -10,10 +10,7 @@ export default RepositoryService.extend({ return modelName; }, findAll: function() { - return this.store.query(this.getModelName(), {}).then(function(items) { - // TODO: Move to view/template - return items.sortBy('Name'); - }); + return this.store.query(this.getModelName(), {}); }, findBySlug: function(name, items) { if (name != null) { diff --git a/ui-v2/app/services/repository/node.js b/ui-v2/app/services/repository/node.js index bb4e2ea3ce..b5cb4b39c8 100644 --- a/ui-v2/app/services/repository/node.js +++ b/ui-v2/app/services/repository/node.js @@ -1,9 +1,7 @@ import RepositoryService from 'consul-ui/services/repository'; -import { inject as service } from '@ember/service'; const modelName = 'node'; export default RepositoryService.extend({ - coordinates: service('repository/coordinate'), getModelName: function() { return modelName; }, diff --git a/ui-v2/tests/integration/services/repository/dc-test.js b/ui-v2/tests/integration/services/repository/dc-test.js index 7333fab6b7..6a71f98ff6 100644 --- a/ui-v2/tests/integration/services/repository/dc-test.js +++ b/ui-v2/tests/integration/services/repository/dc-test.js @@ -24,11 +24,7 @@ test('findAll returns the correct data for list endpoint', function(assert) { assert.deepEqual( actual, expected(function(payload) { - return payload.map(item => ({ Name: item })).sort(function(a, b) { - if (a.Name < b.Name) return -1; - if (a.Name > b.Name) return 1; - return 0; - }); + return payload.map(item => ({ Name: item })); }) ); }