mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Added default recipient settings handling to publishing flow
closes https://github.com/TryGhost/Team/issues/1593 - swapped `recipientFilter` for `selectedRecipientFilter` tracked property with a default value of `undefined` - added `defaultRecipientFilter` getter that uses settings and post attributes to return a filter string that matches the defined default recipient settings - added `recipientFilter` getter to replace the previous tracked property, this checks `selectedRecipientFilter` being `undefined` and will return `defaultRecipientFilter` instead - changing the filter updates `selectedRecipientFilter` acting as an override of the default - keeping `recipientFilter` naming means the options part of the flow requires no changes
This commit is contained in:
parent
32ce367ee1
commit
bee7760815
1 changed files with 36 additions and 2 deletions
|
@ -145,7 +145,7 @@ export class PublishOptions {
|
|||
|
||||
// both of these are set to site defaults in `setupTask`
|
||||
@tracked newsletter = null;
|
||||
@tracked recipientFilter = 'status:free,status:-free';
|
||||
@tracked selectedRecipientFilter = undefined;
|
||||
|
||||
get newsletters() {
|
||||
return this.allNewsletters
|
||||
|
@ -161,6 +161,40 @@ export class PublishOptions {
|
|||
return this.newsletters.length === 1;
|
||||
}
|
||||
|
||||
get recipientFilter() {
|
||||
return this.selectedRecipientFilter === undefined ? this.defaultRecipientFilter : this.selectedRecipientFilter;
|
||||
}
|
||||
|
||||
get defaultRecipientFilter() {
|
||||
const defaultEmailRecipients = this.settings.get('editorDefaultEmailRecipients');
|
||||
|
||||
if (defaultEmailRecipients === 'disabled') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (defaultEmailRecipients === 'visibility') {
|
||||
if (this.post.visibility === 'public') {
|
||||
return 'status:free,status:-free';
|
||||
}
|
||||
|
||||
if (this.post.visibility === 'members') {
|
||||
return 'status:free,status:-free';
|
||||
}
|
||||
|
||||
if (this.post.visibility === 'paid') {
|
||||
return 'status:-free';
|
||||
}
|
||||
|
||||
if (this.post.visibility === 'tiers') {
|
||||
return this.post.visibilitySegment;
|
||||
}
|
||||
|
||||
return this.post.visibility;
|
||||
}
|
||||
|
||||
return this.settings.get('editorDefaultEmailRecipientsFilter');
|
||||
}
|
||||
|
||||
get fullRecipientFilter() {
|
||||
let filter = this.newsletter.recipientFilter;
|
||||
|
||||
|
@ -178,7 +212,7 @@ export class PublishOptions {
|
|||
|
||||
@action
|
||||
setRecipientFilter(newFilter) {
|
||||
this.recipientFilter = newFilter;
|
||||
this.selectedRecipientFilter = newFilter;
|
||||
}
|
||||
|
||||
// setup -------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Reference in a new issue