mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
f5f37e822f
- 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
45 lines
1.1 KiB
JavaScript
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;
|