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
|
|
|
|
2020-11-09 09:25:35 +00:00
|
|
|
export default class IndexRoute extends Route {
|
|
|
|
afterModel(model, transition) {
|
2020-10-05 17:07:35 +00:00
|
|
|
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-11-02 18:38:43 +00:00
|
|
|
const hasProxy = get(parentModel, 'proxies.length') !== 0;
|
2020-10-05 17:07:35 +00:00
|
|
|
const kind = get(parentModel, 'items.firstObject.Service.Kind');
|
|
|
|
|
2020-11-02 18:38:43 +00:00
|
|
|
switch (kind) {
|
|
|
|
case 'ingress-gateway':
|
|
|
|
if (!get(parentModel, 'topology.Datacenter')) {
|
|
|
|
to = 'upstreams';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'terminating-gateway':
|
|
|
|
to = 'services';
|
|
|
|
break;
|
|
|
|
case 'mesh-gateway':
|
|
|
|
to = 'instances';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!hasProxy || !get(parentModel, 'topology.Datacenter')) {
|
2020-10-05 17:07:35 +00:00
|
|
|
to = 'instances';
|
2020-11-02 18:38:43 +00:00
|
|
|
}
|
2020-10-05 17:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.replaceWith(`${parent}.${to}`, parentModel);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
}
|