0
Fork 0
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:
Kevin Ansfield 2022-05-05 18:18:50 +01:00
parent 32ce367ee1
commit bee7760815

View file

@ -145,7 +145,7 @@ export class PublishOptions {
// both of these are set to site defaults in `setupTask` // both of these are set to site defaults in `setupTask`
@tracked newsletter = null; @tracked newsletter = null;
@tracked recipientFilter = 'status:free,status:-free'; @tracked selectedRecipientFilter = undefined;
get newsletters() { get newsletters() {
return this.allNewsletters return this.allNewsletters
@ -161,6 +161,40 @@ export class PublishOptions {
return this.newsletters.length === 1; 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() { get fullRecipientFilter() {
let filter = this.newsletter.recipientFilter; let filter = this.newsletter.recipientFilter;
@ -178,7 +212,7 @@ export class PublishOptions {
@action @action
setRecipientFilter(newFilter) { setRecipientFilter(newFilter) {
this.recipientFilter = newFilter; this.selectedRecipientFilter = newFilter;
} }
// setup ------------------------------------------------------------------- // setup -------------------------------------------------------------------