Ghost/ghost/admin/app/components/gh-feature-flag.js
Hannah Wolfe f5f37e822f Added UI for match helper labs flag
- Ensure the feature flag is available in the feature service so that it knows where to pull the setting from (labs)
- Added a toggle UI to the alpha features list in labs as this is a new feature and is therefore alpha
- Changed the old gh-feature-flag helper to use the switch class instead of checkbox as that's a new pattern since we used this helper
2021-06-07 20:49:32 +01:00

45 lines
1.1 KiB
JavaScript

import Component from '@ember/component';
import {computed, defineProperty} from '@ember/object';
import {readOnly} from '@ember/object/computed';
import {inject as service} from '@ember/service';
const FeatureFlagComponent = Component.extend({
feature: service(),
tagName: 'label',
classNames: 'switch',
attributeBindings: ['for', 'disabled'],
disabled: computed('_disabled', function () {
if (this._disabled) {
return true;
}
return false;
}),
value: computed('_flagValue', {
get() {
return this._flagValue;
},
set(key, value) {
return this.set(`feature.${this.flag}`, value);
}
}),
for: computed('flag', function () {
return `labs-${this.flag}`;
}),
name: computed('flag', function () {
return `labs[${this.flag}]`;
}),
init() {
this._super(...arguments);
defineProperty(this, '_flagValue', readOnly(`feature.${this.flag}`), function () {
return this.get(`feature.${this.flag}`);
});
}
});
export default FeatureFlagComponent;