mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
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
This commit is contained in:
parent
71120d6855
commit
64819714a7
@ -74,35 +74,22 @@
|
|||||||
{{#if (feature "multipleProducts")}}
|
{{#if (feature "multipleProducts")}}
|
||||||
<GhFormGroup @errors={{this.post.errors}} @hasValidated={{this.post.hasValidated}} @property="visibility">
|
<GhFormGroup @errors={{this.post.errors}} @hasValidated={{this.post.hasValidated}} @property="visibility">
|
||||||
<label for="visibility-input">Post access</label>
|
<label for="visibility-input">Post access</label>
|
||||||
<div
|
<GhPsmVisibilityInput @post={{this.post}} @triggerId="visibility-input" />
|
||||||
class="gh-radio {{if this.post.isPublic "active"}}"
|
|
||||||
{{on "click" (action "setVisibility" "public")}}
|
|
||||||
>
|
|
||||||
<div class="gh-radio-button"></div>
|
|
||||||
<div class="gh-radio-content">
|
|
||||||
<div class="gh-radio-label">Public</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="gh-radio {{if (not this.post.isPublic) "active"}}"
|
|
||||||
{{on "click" (action "setVisibility" this.post.visibilitySegment)}}
|
|
||||||
>
|
|
||||||
<div class="gh-radio-button"></div>
|
|
||||||
<div class="gh-radio-content">
|
|
||||||
<div class="gh-radio-label">Members-only</div>
|
|
||||||
<div class="gh-radio-desc">
|
|
||||||
<GhMembersSegmentSelect
|
|
||||||
@hideLabels={{true}}
|
|
||||||
@segment={{this.post.visibilitySegment}}
|
|
||||||
@onChange={{action "setVisibility"}}
|
|
||||||
@renderInPlace={{true}}
|
|
||||||
@hideOptionsWhenAllSelected={{true}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<GhErrorMessage @errors={{this.post.errors}} @property="visibility" class="no-selection" data-test-error="visibility" />
|
|
||||||
</GhFormGroup>
|
</GhFormGroup>
|
||||||
|
|
||||||
|
{{#if (eq this.post.visibility "filter")}}
|
||||||
|
<GhFormGroup @errors={{this.post.errors}} @hasValidated={{this.post.hasValidated}} @property="visibilityFilter">
|
||||||
|
<GhMembersSegmentSelect
|
||||||
|
@hideLabels={{true}}
|
||||||
|
@segment={{this.post.visibilitySegment}}
|
||||||
|
@onChange={{action "setVisibility"}}
|
||||||
|
@renderInPlace={{true}}
|
||||||
|
@hideDefaultSegments={{true}}
|
||||||
|
@hideOptionsWhenAllSelected={{true}}
|
||||||
|
/>
|
||||||
|
<GhErrorMessage @errors={{this.post.errors}} @property="visibilityFilter" data-test-error="visibilityFilter" />
|
||||||
|
</GhFormGroup>
|
||||||
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="visibility-input">Post access</label>
|
<label for="visibility-input">Post access</label>
|
||||||
|
@ -138,10 +138,11 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
async setVisibility(segment) {
|
async setVisibility(segment) {
|
||||||
this.post.set('visibility', segment);
|
this.post.set('visibilityFilter', segment);
|
||||||
try {
|
try {
|
||||||
await this.post.validate({property: 'visibility'});
|
await this.post.validate({property: 'visibility'});
|
||||||
if (this.post.changedAttributes().visibility) {
|
await this.post.validate({property: 'visibilityFilter'});
|
||||||
|
if (this.post.changedAttributes().visibilityFilter) {
|
||||||
await this.savePostTask.perform();
|
await this.savePostTask.perform();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -11,6 +11,7 @@ const VISIBILITIES = [
|
|||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
|
|
||||||
settings: service(),
|
settings: service(),
|
||||||
|
feature: service(),
|
||||||
|
|
||||||
// public attrs
|
// public attrs
|
||||||
post: null,
|
post: null,
|
||||||
@ -22,11 +23,19 @@ export default Component.extend({
|
|||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
this.availableVisibilities = VISIBILITIES;
|
this.availableVisibilities = VISIBILITIES;
|
||||||
|
if (this.feature.get('multipleProducts')) {
|
||||||
|
this.availableVisibilities.push(
|
||||||
|
{label: 'A segment', name: 'filter'}
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
updateVisibility(newVisibility) {
|
updateVisibility(newVisibility) {
|
||||||
this.post.set('visibility', newVisibility);
|
this.post.set('visibility', newVisibility);
|
||||||
|
if (newVisibility !== 'filter') {
|
||||||
|
this.post.set('visibilityFilter', null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -37,7 +37,8 @@ describe('Integration: Component: gh-psm-visibility-input', function () {
|
|||||||
await fillIn('select', 'paid');
|
await fillIn('select', 'paid');
|
||||||
await blur('select');
|
await blur('select');
|
||||||
|
|
||||||
expect(setVisibility.calledOnce).to.be.true;
|
expect(setVisibility.calledTwice).to.be.true;
|
||||||
expect(setVisibility.calledWith('visibility', 'paid')).to.be.true;
|
expect(setVisibility.calledWith('visibility', 'paid')).to.be.true;
|
||||||
|
expect(setVisibility.calledWith('visibilityFilter', null)).to.be.true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user