2018-09-25 16:28:26 +00:00
|
|
|
import { later } from '@ember/runloop';
|
|
|
|
import { Promise } from 'rsvp';
|
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import Route from '@ember/routing/route';
|
2018-04-03 14:16:57 +00:00
|
|
|
import Ember from 'ember';
|
2019-04-19 01:50:05 +00:00
|
|
|
/* eslint-disable ember/no-ember-testing-in-module-scope */
|
2018-04-03 14:16:57 +00:00
|
|
|
const SPLASH_DELAY = Ember.testing ? 0 : 300;
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
export default Route.extend({
|
|
|
|
version: service(),
|
2018-04-03 14:16:57 +00:00
|
|
|
beforeModel() {
|
|
|
|
return this.get('version').fetchVersion();
|
|
|
|
},
|
|
|
|
model() {
|
|
|
|
// hardcode single cluster
|
|
|
|
const fixture = {
|
|
|
|
data: {
|
|
|
|
id: '1',
|
|
|
|
type: 'cluster',
|
|
|
|
attributes: {
|
|
|
|
name: 'vault',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
this.store.push(fixture);
|
2018-09-25 16:28:26 +00:00
|
|
|
return new Promise(resolve => {
|
|
|
|
later(() => {
|
2018-04-03 14:16:57 +00:00
|
|
|
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'));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|