Skip to content

Commit

Permalink
Enterprise version detection fix (#4547)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
meirish committed May 10, 2018
1 parent 8ea9efd commit dee9f11
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 33 deletions.
7 changes: 5 additions & 2 deletions ui/app/routes/vault/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -21,15 +22,17 @@ 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 });
}
},

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() {
Expand Down
2 changes: 1 addition & 1 deletion ui/app/services/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default Service.extend({

hasSentinel: hasFeature('Sentinel'),

isEnterprise: computed.match('version', /\+\w+$/),
isEnterprise: computed.match('version', /\+.+$/),

isOSS: computed.not('isEnterprise'),

Expand Down
7 changes: 7 additions & 0 deletions ui/app/styles/components/status-menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
<div class="level-left is-flex-1">
<div>
{{#if (or replicationUnsupported (and (eq mode 'performance') (not version.hasPerfReplication)))}}
<p>
Upgrade to Vault Enterprise Premium to use Performance Replication.
</p>
{{else if replicationEnabled}}
<span>
{{capitalize modeForUrl}}
</span>
{{#if secondaryId}}
<div class="level is-mobile">
<div class="level-left is-flex-1">
<div>
{{#if (or replicationUnsupported (and (eq mode 'performance') (not version.hasPerfReplication)))}}
<p>
Upgrade to Vault Enterprise Premium to use Performance Replication.
</p>
{{else if replicationEnabled}}
<span>
{{capitalize modeForUrl}}
</span>
{{#if secondaryId}}
<span class="tag is-light">
<code>
{{secondaryId}}
</code>
</span>
{{/if}}
<span class="tag is-light">
<code>
{{secondaryId}}
{{clusterIdDisplay}}
</code>
</span>
{{else}}
Enable
{{/if}}
<span class="tag is-light">
<code>
{{clusterIdDisplay}}
</code>
</span>
{{else}}
Enable
{{/if}}
</div>
</div>
</div>
<div class="level-right">
{{#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}}
<progress value="{{syncProgressPercent}}" max="100" class="progress is-small is-narrow is-info">
{{syncProgress.progress}} of {{syncProgress.total}} keys
</progress>
<div class="level-right">
{{#if replicationEnabled}}
{{#if (get cluster (concat mode 'StateGlyph'))}}
{{i-con size=14 glyph=(get cluster (concat mode 'StateGlyph'))}}
{{else if syncProgress}}
<progress value="{{syncProgressPercent}}" max="100" class="progress is-small is-narrow is-info">
{{syncProgress.progress}} of {{syncProgress.total}} keys
</progress>
{{/if}}
{{/if}}
{{/if}}
</div>
</div>
7 changes: 7 additions & 0 deletions ui/tests/unit/services/version-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit dee9f11

Please sign in to comment.