mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-30 14:22:07 +03:00
0caa539330
refs https://github.com/TryGhost/Team/issues/581 requires https://github.com/TryGhost/Ghost/pull/12932 - added segment option and select to default newsletter recipients setting - updated segment selector to fetch labels/products and show as options - updated segment selector and count component to call an action when count changes so we can use it in the email confirmation modal - removed usage and mapping of older `'none'`, `'all'`, `'free'`, and `'paid'` email recipient filter values
100 lines
3.2 KiB
JavaScript
100 lines
3.2 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import {action} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
export default class SettingsDefaultEmailRecipientsComponent extends Component {
|
|
@service settings;
|
|
|
|
@tracked segmentSelected = false;
|
|
|
|
get isDisabled() {
|
|
return this.settings.get('membersSignupAccess') === 'none';
|
|
}
|
|
|
|
get isDisabledSelected() {
|
|
return this.isDisabled ||
|
|
this.settings.get('editorDefaultEmailRecipients') === 'disabled';
|
|
}
|
|
|
|
get isVisibilitySelected() {
|
|
return !this.isDisabled &&
|
|
this.settings.get('editorDefaultEmailRecipients') === 'visibility';
|
|
}
|
|
|
|
get isNobodySelected() {
|
|
return !this.isDisabled &&
|
|
!this.segmentSelected &&
|
|
this.settings.get('editorDefaultEmailRecipients') === 'filter' &&
|
|
this.settings.get('editorDefaultEmailRecipientsFilter') === null;
|
|
}
|
|
|
|
get isAllSelected() {
|
|
return !this.isDisabled &&
|
|
!this.segmentSelected &&
|
|
this.settings.get('editorDefaultEmailRecipients') === 'filter' &&
|
|
this.settings.get('editorDefaultEmailRecipientsFilter') === 'status:free,status:-free';
|
|
}
|
|
|
|
get isFreeSelected() {
|
|
return !this.isDisabled &&
|
|
!this.segmentSelected &&
|
|
this.settings.get('editorDefaultEmailRecipients') === 'filter' &&
|
|
this.settings.get('editorDefaultEmailRecipientsFilter') === 'status:free';
|
|
}
|
|
|
|
get isPaidSelected() {
|
|
return !this.isDisabled &&
|
|
!this.segmentSelected &&
|
|
this.settings.get('editorDefaultEmailRecipients') === 'filter' &&
|
|
this.settings.get('editorDefaultEmailRecipientsFilter') === 'status:-free';
|
|
}
|
|
|
|
get isSegmentSelected() {
|
|
const isCustomSegment = this.settings.get('editorDefaultEmailRecipients') === 'filter' &&
|
|
!this.isNobodySelected &&
|
|
!this.isAllSelected &&
|
|
!this.isFreeSelected &&
|
|
!this.isPaidSelected;
|
|
|
|
return !this.isDisabled && (this.segmentSelected || isCustomSegment);
|
|
}
|
|
|
|
@action
|
|
setDefaultEmailRecipients(value) {
|
|
this.segmentSelected = false;
|
|
|
|
if (['disabled', 'visibility'].includes(value)) {
|
|
this.settings.set('editorDefaultEmailRecipients', value);
|
|
return;
|
|
}
|
|
|
|
if (value === 'none') {
|
|
this.settings.set('editorDefaultEmailRecipientsFilter', null);
|
|
}
|
|
|
|
if (value === 'all') {
|
|
this.settings.set('editorDefaultEmailRecipientsFilter', 'status:free,status:-free');
|
|
}
|
|
|
|
if (value === 'free') {
|
|
this.settings.set('editorDefaultEmailRecipientsFilter', 'status:free');
|
|
}
|
|
|
|
if (value === 'paid') {
|
|
this.settings.set('editorDefaultEmailRecipientsFilter', 'status:-free');
|
|
}
|
|
|
|
if (value === 'segment') {
|
|
this.segmentSelected = true;
|
|
}
|
|
|
|
this.settings.set('editorDefaultEmailRecipients', 'filter');
|
|
}
|
|
|
|
@action
|
|
setDefaultEmailRecipientsFilter(filter) {
|
|
this.settings.set('editorDefaultEmailRecipientsFilter', filter);
|
|
}
|
|
}
|