2018-09-25 16:28:26 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import { alias } from '@ember/object/computed';
|
|
|
|
import Controller from '@ember/controller';
|
|
|
|
import { observer, computed } from '@ember/object';
|
2018-04-03 14:16:57 +00:00
|
|
|
export default Controller.extend({
|
2018-09-25 16:28:26 +00:00
|
|
|
auth: service(),
|
|
|
|
store: service(),
|
|
|
|
media: service(),
|
2018-10-02 13:53:39 +00:00
|
|
|
router: service(),
|
2018-09-25 16:28:26 +00:00
|
|
|
namespaceService: service('namespace'),
|
2018-08-16 17:48:24 +00:00
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
vaultVersion: service('version'),
|
|
|
|
console: service(),
|
2018-08-16 17:48:24 +00:00
|
|
|
|
|
|
|
queryParams: [
|
|
|
|
{
|
|
|
|
namespaceQueryParam: {
|
|
|
|
scope: 'controller',
|
|
|
|
as: 'namespace',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
|
|
|
namespaceQueryParam: '',
|
|
|
|
|
|
|
|
onQPChange: observer('namespaceQueryParam', function() {
|
|
|
|
this.get('namespaceService').setNamespace(this.get('namespaceQueryParam'));
|
|
|
|
}),
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
consoleOpen: alias('console.isOpen'),
|
2018-08-16 17:48:24 +00:00
|
|
|
|
|
|
|
activeCluster: computed('auth.activeCluster', function() {
|
|
|
|
return this.get('store').peekRecord('cluster', this.get('auth.activeCluster'));
|
|
|
|
}),
|
|
|
|
|
|
|
|
activeClusterName: computed('activeCluster', function() {
|
|
|
|
const activeCluster = this.get('activeCluster');
|
|
|
|
return activeCluster ? activeCluster.get('name') : null;
|
|
|
|
}),
|
|
|
|
|
|
|
|
showNav: computed(
|
2018-10-02 13:53:39 +00:00
|
|
|
'router.currentRouteName',
|
2018-08-16 17:48:24 +00:00
|
|
|
'activeClusterName',
|
|
|
|
'auth.currentToken',
|
2018-09-25 16:28:26 +00:00
|
|
|
'activeCluster.{dr.isSecondary,needsInit,sealed}',
|
2018-08-16 17:48:24 +00:00
|
|
|
function() {
|
|
|
|
if (
|
|
|
|
this.get('activeCluster.dr.isSecondary') ||
|
|
|
|
this.get('activeCluster.needsInit') ||
|
|
|
|
this.get('activeCluster.sealed')
|
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-10-02 13:53:39 +00:00
|
|
|
if (
|
|
|
|
this.activeClusterName &&
|
|
|
|
this.auth.currentToken &&
|
|
|
|
this.router.currentRouteName !== 'vault.cluster.auth'
|
|
|
|
) {
|
2018-08-16 17:48:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
toggleConsole() {
|
|
|
|
this.toggleProperty('consoleOpen');
|
|
|
|
},
|
|
|
|
},
|
2018-04-03 14:16:57 +00:00
|
|
|
});
|