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
This commit is contained in:
John Cowen 2020-07-13 14:22:58 +01:00 committed by hashicorp-ci
parent 89af0212d3
commit 35fcf69914
4 changed files with 3 additions and 12 deletions

View File

@ -70,7 +70,7 @@
@loading="lazy" @loading="lazy"
/> />
</li> </li>
{{#each dcs as |item|}} {{#each (sort-by 'Name' dcs) as |item|}}
<li role="none" data-test-datacenter-picker class={{if (eq dc.Name item.Name) 'is-active'}}> <li role="none" data-test-datacenter-picker class={{if (eq dc.Name item.Name) 'is-active'}}>
<a tabindex="-1" role="menuitem" href={{href-mut (hash dc=item.Name)}}>{{item.Name}}</a> <a tabindex="-1" role="menuitem" href={{href-mut (hash dc=item.Name)}}>{{item.Name}}</a>
</li> </li>

View File

@ -10,10 +10,7 @@ export default RepositoryService.extend({
return modelName; return modelName;
}, },
findAll: function() { findAll: function() {
return this.store.query(this.getModelName(), {}).then(function(items) { return this.store.query(this.getModelName(), {});
// TODO: Move to view/template
return items.sortBy('Name');
});
}, },
findBySlug: function(name, items) { findBySlug: function(name, items) {
if (name != null) { if (name != null) {

View File

@ -1,9 +1,7 @@
import RepositoryService from 'consul-ui/services/repository'; import RepositoryService from 'consul-ui/services/repository';
import { inject as service } from '@ember/service';
const modelName = 'node'; const modelName = 'node';
export default RepositoryService.extend({ export default RepositoryService.extend({
coordinates: service('repository/coordinate'),
getModelName: function() { getModelName: function() {
return modelName; return modelName;
}, },

View File

@ -24,11 +24,7 @@ test('findAll returns the correct data for list endpoint', function(assert) {
assert.deepEqual( assert.deepEqual(
actual, actual,
expected(function(payload) { expected(function(payload) {
return payload.map(item => ({ Name: item })).sort(function(a, b) { return payload.map(item => ({ Name: item }));
if (a.Name < b.Name) return -1;
if (a.Name > b.Name) return 1;
return 0;
});
}) })
); );
} }