open-vault/ui/lib/core/addon/helpers/has-feature.js
Matthew Irish 0ccc8467ec
UI ember engines (#6718)
Adds replication engine and core in-repo addon
2019-05-13 14:05:25 -05:00

35 lines
920 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',
'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(),
/* eslint-disable-next-line ember/no-observers */
onFeaturesChange: observer('version.features.[]', function() {
this.recompute();
}),
compute([featureName]) {
return hasFeature(featureName, this.get('version.features'));
},
});