John Cowen dd280ee2b2 ui: Support Route optional parameters/segments (#10212)
Moves our URLs with 'optional namespace segment' into a separately abstracted 'optional URL segment' feature
2021-05-26 16:46:46 +00:00

17 lines
544 B
JavaScript

import Route from 'consul-ui/routing/route';
import { get } from '@ember/object';
export default class IndexRoute extends Route {
afterModel(model, transition) {
const parent = this.routeName
.split('.')
.slice(0, -1)
.join('.');
model = this.modelFor(parent);
// the default selected tab depends on whether you have any healthchecks or not
// so check the length here.
const to = get(model, 'item.Checks.length') > 0 ? 'healthchecks' : 'services';
this.replaceWith(`${parent}.${to}`, model);
}
}