Ghost/ghost/admin/app/components/gh-psm-visibility-input.js
Rishabh 64819714a7 Added custom segment option to post settings access option
refs https://github.com/TryGhost/Team/issues/822

With multiple products flag we are re-enabling segmentation by product for posts. This change adds new segment option for post access option in post-settings menu, which allows option to choose specific products for post access.

- updates post settings and post settings labs menu to add new option for segment
- handles visibility filter changes for API based on selected segment
- the new behavior is behind the alpha flag for multiple products
2021-07-05 17:14:26 +05:30

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: 'A segment', name: 'filter'}
);
}
},
actions: {
updateVisibility(newVisibility) {
this.post.set('visibility', newVisibility);
if (newVisibility !== 'filter') {
this.post.set('visibilityFilter', null);
}
}
}
});