From dee9f11655c5d1841686a0cc74af53745bd6611d Mon Sep 17 00:00:00 2001 From: Matthew Irish Date: Thu, 10 May 2018 16:44:17 -0500 Subject: [PATCH] Enterprise version detection fix (#4547) * fix version service parsing of .hsm in a version string * remove race condition where the replication menu would show the enterprise upsell in an enterprise binary * fix styling and layout of replication status menu * move version check to beforeModel --- ui/app/routes/vault/cluster.js | 7 ++- ui/app/services/version.js | 2 +- ui/app/styles/components/status-menu.scss | 7 +++ .../replication-mode-summary-menu.hbs | 62 ++++++++++--------- ui/tests/unit/services/version-test.js | 7 +++ 5 files changed, 52 insertions(+), 33 deletions(-) diff --git a/ui/app/routes/vault/cluster.js b/ui/app/routes/vault/cluster.js index 9b86deb70831..433c7f701dc1 100644 --- a/ui/app/routes/vault/cluster.js +++ b/ui/app/routes/vault/cluster.js @@ -6,6 +6,7 @@ const POLL_INTERVAL_MS = 10000; const { inject } = Ember; export default Ember.Route.extend(ModelBoundaryRoute, ClusterRoute, { + version: inject.service(), store: inject.service(), auth: inject.service(), currentCluster: Ember.inject.service(), @@ -21,7 +22,8 @@ export default Ember.Route.extend(ModelBoundaryRoute, ClusterRoute, { const params = this.paramsFor(this.routeName); const id = this.getClusterId(params); if (id) { - return this.get('auth').setCluster(id); + this.get('auth').setCluster(id); + return this.get('version').fetchFeatures(); } else { return Ember.RSVP.reject({ httpStatus: 404, message: 'not found', path: params.cluster_name }); } @@ -29,7 +31,8 @@ export default Ember.Route.extend(ModelBoundaryRoute, ClusterRoute, { model(params) { const id = this.getClusterId(params); - return this.get('store').findRecord('cluster', id); + + return this.get('store').findRecord('cluster', id); }, stopPoll: Ember.on('deactivate', function() { diff --git a/ui/app/services/version.js b/ui/app/services/version.js index 4284c44fd71c..8b07823051a9 100644 --- a/ui/app/services/version.js +++ b/ui/app/services/version.js @@ -24,7 +24,7 @@ export default Service.extend({ hasSentinel: hasFeature('Sentinel'), - isEnterprise: computed.match('version', /\+\w+$/), + isEnterprise: computed.match('version', /\+.+$/), isOSS: computed.not('isEnterprise'), diff --git a/ui/app/styles/components/status-menu.scss b/ui/app/styles/components/status-menu.scss index 5f841db15484..1c6937dae0f7 100644 --- a/ui/app/styles/components/status-menu.scss +++ b/ui/app/styles/components/status-menu.scss @@ -91,9 +91,16 @@ width: 100%; text-align: left; + .icon { + color: $menu-item-hover-background-color; + } &:hover { background-color: $menu-item-hover-background-color; color: $menu-item-hover-color; + .icon { + color: $menu-item-hover-color; + } + } &.is-active { diff --git a/ui/app/templates/partials/replication/replication-mode-summary-menu.hbs b/ui/app/templates/partials/replication/replication-mode-summary-menu.hbs index db4d76dc12db..475a01fce606 100644 --- a/ui/app/templates/partials/replication/replication-mode-summary-menu.hbs +++ b/ui/app/templates/partials/replication/replication-mode-summary-menu.hbs @@ -1,38 +1,40 @@ -
-
- {{#if (or replicationUnsupported (and (eq mode 'performance') (not version.hasPerfReplication)))}} -

- Upgrade to Vault Enterprise Premium to use Performance Replication. -

- {{else if replicationEnabled}} - - {{capitalize modeForUrl}} - - {{#if secondaryId}} +
+
+
+ {{#if (or replicationUnsupported (and (eq mode 'performance') (not version.hasPerfReplication)))}} +

+ Upgrade to Vault Enterprise Premium to use Performance Replication. +

+ {{else if replicationEnabled}} + + {{capitalize modeForUrl}} + + {{#if secondaryId}} + + + {{secondaryId}} + + + {{/if}} - {{secondaryId}} + {{clusterIdDisplay}} + {{else}} + Enable {{/if}} - - - {{clusterIdDisplay}} - - - {{else}} - Enable - {{/if}} +
-
-
- {{#if replicationEnabled}} - {{#if (get cluster (concat mode 'StateGlyph'))}} - {{i-con size=14 glyph=(get cluster (concat mode 'StateGlyph')) class="has-text-info" aria-label=(concat mode 'StateDisplay')}} - {{else if syncProgress}} - - {{syncProgress.progress}} of {{syncProgress.total}} keys - +
+ {{#if replicationEnabled}} + {{#if (get cluster (concat mode 'StateGlyph'))}} + {{i-con size=14 glyph=(get cluster (concat mode 'StateGlyph'))}} + {{else if syncProgress}} + + {{syncProgress.progress}} of {{syncProgress.total}} keys + + {{/if}} {{/if}} - {{/if}} +
diff --git a/ui/tests/unit/services/version-test.js b/ui/tests/unit/services/version-test.js index 9ad182ce1b70..717e08ff2309 100644 --- a/ui/tests/unit/services/version-test.js +++ b/ui/tests/unit/services/version-test.js @@ -16,6 +16,13 @@ test('setting version computes isEnterprise properly', function(assert) { assert.equal(service.get('isEnterprise'), true); }); +test('setting version with hsm ending computes isEnterprise properly', function(assert) { + let service = this.subject(); + service.set('version', '0.9.5+prem.hsm'); + assert.equal(service.get('isOSS'), false); + assert.equal(service.get('isEnterprise'), true); +}); + test('hasPerfReplication', function(assert) { let service = this.subject(); assert.equal(service.get('hasPerfReplication'), false);