mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 11:54:33 +03:00
8d6c677b35
closes https://github.com/TryGhost/Team/issues/903 - fixes multiple instances of "Specific tier" option in post access dropdown as main visibility list was getting modified on each load instead of using a separate instance
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
import Component from '@ember/component';
|
|
import {computed} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
const VISIBILITIES = [
|
|
{label: 'Public', name: 'public'},
|
|
{label: 'Members only', name: 'members'},
|
|
{label: 'Paid-members only', name: 'paid'}
|
|
];
|
|
|
|
export default Component.extend({
|
|
|
|
settings: service(),
|
|
feature: service(),
|
|
|
|
// public attrs
|
|
post: null,
|
|
|
|
selectedVisibility: computed('post.visibility', function () {
|
|
return this.get('post.visibility') || this.settings.get('defaultContentVisibility');
|
|
}),
|
|
|
|
init() {
|
|
this._super(...arguments);
|
|
this.availableVisibilities = [...VISIBILITIES];
|
|
if (this.feature.get('multipleProducts')) {
|
|
this.availableVisibilities.push(
|
|
{label: 'Specific tier(s)', name: 'filter'}
|
|
);
|
|
}
|
|
},
|
|
|
|
actions: {
|
|
updateVisibility(newVisibility) {
|
|
this.post.set('visibility', newVisibility);
|
|
if (newVisibility !== 'filter') {
|
|
this.post.set('visibilityFilter', null);
|
|
}
|
|
}
|
|
}
|
|
});
|