958991db94
* Create ConsulServiceInstanceList with styling and test * Implement ConsulServiceInstanceList to Service Detail page * Implement ConsulExternalSource to Services Show page header * Update services/show page object * Update the styling of CompositeRow * Refactor ConsulServiceList component and styling * Update ConsulExternalSource to say 'Registered via...' * Upgrade consul-api-double to patch 2.14.1 * Fix up tests to not use Kind in service models * Update ListCollection with clickFirstAnchor action * Add $typo-size-450 to typography base variables
50 lines
1.9 KiB
JavaScript
50 lines
1.9 KiB
JavaScript
import Route from '@ember/routing/route';
|
|
import { inject as service } from '@ember/service';
|
|
import { hash } from 'rsvp';
|
|
import { get } from '@ember/object';
|
|
|
|
export default Route.extend({
|
|
repo: service('repository/service'),
|
|
intentionRepo: service('repository/intention'),
|
|
chainRepo: service('repository/discovery-chain'),
|
|
proxyRepo: service('repository/proxy'),
|
|
settings: service('settings'),
|
|
model: function(params, transition = {}) {
|
|
const dc = this.modelFor('dc').dc.Name;
|
|
const nspace = this.modelFor('nspace').nspace.substr(1);
|
|
return hash({
|
|
item: this.repo.findBySlug(params.name, dc, nspace),
|
|
intentions: this.intentionRepo.findByService(params.name, dc, nspace),
|
|
urls: this.settings.findBySlug('urls'),
|
|
dc: dc,
|
|
}).then(model => {
|
|
return ['connect-proxy', 'mesh-gateway'].includes(get(model, 'item.Service.Kind'))
|
|
? model
|
|
: hash({
|
|
chain: this.chainRepo.findBySlug(params.name, dc, nspace).catch(function(e) {
|
|
const code = get(e, 'errors.firstObject.status');
|
|
// Currently we are specifically catching a 500, but we return null
|
|
// by default, so null for all errors.
|
|
// The extra code here is mainly for documentation purposes
|
|
// and for if we need to perform different actions based on the error code
|
|
// in the future
|
|
switch (code) {
|
|
case '500':
|
|
// connect is likely to be disabled
|
|
// we just return a null to hide the tab
|
|
// `Connect must be enabled in order to use this endpoint`
|
|
return null;
|
|
default:
|
|
return null;
|
|
}
|
|
}),
|
|
proxies: this.proxyRepo.findAllBySlug(params.name, dc, nspace),
|
|
...model,
|
|
});
|
|
});
|
|
},
|
|
setupController: function(controller, model) {
|
|
controller.setProperties(model);
|
|
},
|
|
});
|