Ghost/ghost/admin/app/components/gh-feature-flag.js
Rish 57f9663b6e Added members feature to labs
no issue

- Added new members settings/toggle to labs
2019-02-26 15:33:38 +07:00

52 lines
1.4 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: 'checkbox',
attributeBindings: ['for', 'disabled'],
disabled: computed('_disabled', function () {
if (this.get('_disabled')) {
return true;
}
return false;
}),
value: computed('_flagValue', {
get() {
return this.get('_flagValue');
},
set(key, value) {
if (this.get('flag') === 'members' && value === true) {
this.set(`feature.subscribers`, false);
}
return this.set(`feature.${this.get('flag')}`, value);
}
}),
for: computed('flag', function () {
return `labs-${this.get('flag')}`;
}),
name: computed('flag', function () {
return `labs[${this.get('flag')}]`;
}),
init() {
this._super(...arguments);
defineProperty(this, '_flagValue', readOnly(`feature.${this.get('flag')}`), function () {
return this.get(`feature.${this.get('flag')}`);
});
}
});
FeatureFlagComponent.reopenClass({
positionalParams: ['flag', '_disabled']
});
export default FeatureFlagComponent;