John Cowen 8b002d086a
ui: Address some Admin Partition FIXMEs (#11057)
This commit addresses some left over admin partition FIXMEs

1. Adds Partition correctly to Service Instances
2. Converts non-important 'we can do this later' FIXMEs to TODOs
3. Removes some FIXMEs that I've double checked and addressed.

Most of the remaining FIXMEs I'm waiting on responses to questions from
the consul core folks for. I'll address those in a separate PR.
2021-10-01 11:07:58 +01:00

30 lines
889 B
JavaScript

import Error from '@ember/error';
import RepositoryService from 'consul-ui/services/repository';
import dataSource from 'consul-ui/decorators/data-source';
const modelName = 'dc';
export default class DcService extends RepositoryService {
getModelName() {
return modelName;
}
@dataSource('/:partition/:ns/:dc/datacenters')
async findAll() {
return super.findAll(...arguments);
}
@dataSource('/:partition/:ns/:dc/datacenter/:name')
async findBySlug(params) {
const items = this.store.peekAll('dc');
const item = items.findBy('Name', params.name);
if (typeof item === 'undefined') {
// TODO: We should use a HTTPError error here and remove all occurances of
// the custom shaped ember-data error throughout the app
const e = new Error('Page not found');
e.status = '404';
throw { errors: [e] };
}
return item;
}
}