open-vault/ui/app/helpers/has-feature.js

33 lines
806 B
JavaScript
Raw Normal View History

2018-04-03 14:16:57 +00:00
import Ember from 'ember';
const { Helper, inject, observer } = Ember;
const FEATURES = [
'HSM',
'Performance Replication',
'DR Replication',
'MFA',
'Sentinel',
'AWS KMS Autounseal',
'GCP CKMS Autounseal',
'Seal Wrapping',
'Control Groups',
];
export function hasFeature(featureName, features) {
if (!FEATURES.includes(featureName)) {
Ember.assert(`${featureName} is not one of the available values for Vault Enterprise features.`, false);
return false;
}
return features ? features.includes(featureName) : false;
}
export default Helper.extend({
version: inject.service(),
onFeaturesChange: observer('version.features.[]', function() {
this.recompute();
}),
compute([featureName]) {
return hasFeature(featureName, this.get('version.features'));
},
});