open-vault/ui/app/helpers/has-feature.js
Matthew Irish d509588cd2
Ember update (#5386)
Ember update - update ember-cli, ember-data, and ember to 3.4 series
2018-09-25 11:28:26 -05:00

36 lines
917 B
JavaScript

import { inject as service } from '@ember/service';
import { assert } from '@ember/debug';
import Helper from '@ember/component/helper';
import { observer } from '@ember/object';
const FEATURES = [
'HSM',
'Performance Replication',
'DR Replication',
'MFA',
'Sentinel',
'AWS KMS Autounseal',
'GCP CKMS Autounseal',
'Seal Wrapping',
'Control Groups',
'Namespaces',
];
export function hasFeature(featureName, features) {
if (!FEATURES.includes(featureName)) {
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: service(),
onFeaturesChange: observer('version.features.[]', function() {
this.recompute();
}),
compute([featureName]) {
return hasFeature(featureName, this.get('version.features'));
},
});