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"
/>
</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'}}>
<a tabindex="-1" role="menuitem" href={{href-mut (hash dc=item.Name)}}>{{item.Name}}</a>
</li>

View File

@ -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) {

View File

@ -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;
},

View File

@ -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 }));
})
);
}