2020-10-05 17:07:35 +00:00
|
|
|
import Route from '@ember/routing/route';
|
|
|
|
import { get } from '@ember/object';
|
2020-04-08 09:56:36 +00:00
|
|
|
|
|
|
|
export default Route.extend({
|
2020-10-05 17:07:35 +00:00
|
|
|
afterModel: function(model, transition) {
|
|
|
|
const parent = this.routeName
|
|
|
|
.split('.')
|
|
|
|
.slice(0, -1)
|
|
|
|
.join('.');
|
|
|
|
// the default selected tab depends on whether you have any healthchecks or not
|
|
|
|
// so check the length here.
|
|
|
|
let to = 'topology';
|
|
|
|
const parentModel = this.modelFor(parent);
|
2020-10-23 13:45:10 +00:00
|
|
|
const hasProxy = get(parentModel, 'proxies');
|
2020-10-05 17:07:35 +00:00
|
|
|
const kind = get(parentModel, 'items.firstObject.Service.Kind');
|
|
|
|
|
2020-10-23 13:45:10 +00:00
|
|
|
if (hasProxy.length === 0) {
|
|
|
|
to = 'instances';
|
|
|
|
} else {
|
|
|
|
switch (kind) {
|
|
|
|
case 'ingress-gateway':
|
|
|
|
if (!get(parentModel, 'topology.Datacenter')) {
|
|
|
|
to = 'upstreams';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'terminating-gateway':
|
|
|
|
to = 'services';
|
|
|
|
break;
|
|
|
|
case 'mesh-gateway':
|
2020-10-05 17:07:35 +00:00
|
|
|
to = 'instances';
|
2020-10-23 13:45:10 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!get(parentModel, 'topology.Datacenter')) {
|
|
|
|
to = 'instances';
|
|
|
|
}
|
|
|
|
}
|
2020-10-05 17:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.replaceWith(`${parent}.${to}`, parentModel);
|
|
|
|
},
|
2020-04-08 09:56:36 +00:00
|
|
|
});
|