open-nomad/ui/app/routes/jobs.js
Michael Lange 9f3a37f1c2 Simplify the control flow around changing namespaces and regions
The UI will no longer try to redirect to the appropriate namespace or
region if one is found in localStorage. Instead, it will assume that
the lack of query param means the default namespaces or region is
desired.
2018-08-09 18:22:39 -07:00

44 lines
934 B
JavaScript

import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import WithForbiddenState from 'nomad-ui/mixins/with-forbidden-state';
import notifyForbidden from 'nomad-ui/utils/notify-forbidden';
export default Route.extend(WithForbiddenState, {
system: service(),
store: service(),
breadcrumbs: [
{
label: 'Jobs',
args: ['jobs.index'],
},
],
queryParams: {
jobNamespace: {
refreshModel: true,
},
},
beforeModel(transition) {
return this.get('system.namespaces').then(namespaces => {
const queryParam = transition.queryParams.namespace;
this.set('system.activeNamespace', queryParam || 'default');
return namespaces;
});
},
model() {
return this.get('store')
.findAll('job', { reload: true })
.catch(notifyForbidden(this));
},
actions: {
refreshRoute() {
this.refresh();
},
},
});