2018-09-25 16:28:26 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import { equal } from '@ember/object/computed';
|
|
|
|
import { getProperties, get, computed } from '@ember/object';
|
|
|
|
import Component from '@ember/component';
|
2018-04-03 14:16:57 +00:00
|
|
|
|
|
|
|
const replicationAttr = function(attr) {
|
|
|
|
return computed('mode', `cluster.{dr,performance}.${attr}`, function() {
|
|
|
|
const { mode, cluster } = getProperties(this, 'mode', 'cluster');
|
|
|
|
return get(cluster, `${mode}.${attr}`);
|
|
|
|
});
|
|
|
|
};
|
2018-08-16 17:48:24 +00:00
|
|
|
export default Component.extend({
|
2018-09-25 16:28:26 +00:00
|
|
|
version: service(),
|
|
|
|
router: service(),
|
|
|
|
namespace: service(),
|
2018-08-22 19:08:43 +00:00
|
|
|
classNameBindings: ['isMenu::box', 'isMenu::level'],
|
2018-04-03 14:16:57 +00:00
|
|
|
attributeBindings: ['href', 'target'],
|
|
|
|
display: 'banner',
|
2018-09-25 16:28:26 +00:00
|
|
|
isMenu: equal('display', 'menu'),
|
2018-04-03 14:16:57 +00:00
|
|
|
href: computed('display', 'mode', 'replicationEnabled', 'version.hasPerfReplication', function() {
|
|
|
|
const display = this.get('display');
|
|
|
|
const mode = this.get('mode');
|
|
|
|
if (mode === 'performance' && display === 'menu' && this.get('version.hasPerfReplication') === false) {
|
|
|
|
return 'https://www.hashicorp.com/products/vault';
|
|
|
|
}
|
|
|
|
if (this.get('replicationEnabled') || display === 'menu') {
|
2018-08-16 17:48:24 +00:00
|
|
|
return this.get('router').urlFor(
|
|
|
|
'vault.cluster.replication.mode.index',
|
|
|
|
this.get('cluster.name'),
|
2018-08-22 19:08:43 +00:00
|
|
|
mode
|
2018-08-16 17:48:24 +00:00
|
|
|
);
|
2018-04-03 14:16:57 +00:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}),
|
|
|
|
target: computed('isPerformance', 'version.hasPerfReplication', function() {
|
|
|
|
if (this.get('isPerformance') && this.get('version.hasPerfReplication') === false) {
|
|
|
|
return '_blank';
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}),
|
2018-08-22 19:08:43 +00:00
|
|
|
internalLink: false,
|
2018-09-25 16:28:26 +00:00
|
|
|
isPerformance: equal('mode', 'performance'),
|
2018-04-03 14:16:57 +00:00
|
|
|
replicationEnabled: replicationAttr('replicationEnabled'),
|
2018-09-25 16:28:26 +00:00
|
|
|
replicationUnsupported: equal('cluster.mode', 'unsupported'),
|
2018-04-03 14:16:57 +00:00
|
|
|
replicationDisabled: replicationAttr('replicationDisabled'),
|
|
|
|
syncProgressPercent: replicationAttr('syncProgressPercent'),
|
|
|
|
syncProgress: replicationAttr('syncProgress'),
|
|
|
|
secondaryId: replicationAttr('secondaryId'),
|
|
|
|
modeForUrl: replicationAttr('modeForUrl'),
|
|
|
|
clusterIdDisplay: replicationAttr('clusterIdDisplay'),
|
|
|
|
mode: null,
|
|
|
|
cluster: null,
|
|
|
|
partialName: computed('display', function() {
|
|
|
|
return this.get('display') === 'menu'
|
|
|
|
? 'partials/replication/replication-mode-summary-menu'
|
|
|
|
: 'partials/replication/replication-mode-summary';
|
|
|
|
}),
|
|
|
|
});
|