open-vault/ui/app/routes/vault.js
Matthew Irish d509588cd2
Ember update (#5386)
Ember update - update ember-cli, ember-data, and ember to 3.4 series
2018-09-25 11:28:26 -05:00

38 lines
936 B
JavaScript

import { later } from '@ember/runloop';
import { Promise } from 'rsvp';
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import Ember from 'ember';
const SPLASH_DELAY = Ember.testing ? 0 : 300;
export default Route.extend({
version: service(),
beforeModel() {
return this.get('version').fetchVersion();
},
model() {
// hardcode single cluster
const fixture = {
data: {
id: '1',
type: 'cluster',
attributes: {
name: 'vault',
},
},
};
this.store.push(fixture);
return new Promise(resolve => {
later(() => {
resolve(this.store.peekAll('cluster'));
}, SPLASH_DELAY);
});
},
redirect(model, transition) {
if (model.get('length') === 1 && transition.targetName === 'vault.index') {
return this.transitionTo('vault.cluster', model.get('firstObject.name'));
}
},
});