Ghost/ghost/admin/app/components/gh-feature-flag.js
Kevin Ansfield 2da6673197 Synchronous feature service
supersedes #6773
- update `feature` service and `gh-feature-flag` component to work synchronously rather than async
- use the application route's `afterModel` hook so that settings are loaded before first load
- override `session` service's `authenticate` method to load the settings after successful authentication before any other routes are processed
2016-05-07 15:00:06 +02:00

46 lines
922 B
JavaScript

import Ember from 'ember';
const {
computed,
inject: {service},
Component
} = Ember;
const FeatureFlagComponent = Component.extend({
tagName: 'label',
classNames: 'checkbox',
attributeBindings: ['for'],
_flagValue: null,
feature: service(),
init() {
this._super(...arguments);
this.set('_flagValue', this.get(`feature.${this.get('flag')}`));
},
value: computed('_flagValue', {
get() {
return this.get('_flagValue');
},
set(key, value) {
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')}]`;
})
});
FeatureFlagComponent.reopenClass({
positionalParams: ['flag']
});
export default FeatureFlagComponent;