diff --git a/ghost/admin/app/components/modals/edit-newsletter.js b/ghost/admin/app/components/modals/edit-newsletter.js index bf6d399fd8..d37faf2af4 100644 --- a/ghost/admin/app/components/modals/edit-newsletter.js +++ b/ghost/admin/app/components/modals/edit-newsletter.js @@ -8,6 +8,7 @@ import {tracked} from '@glimmer/tracking'; export default class EditNewsletterModal extends Component { @service modals; + @service store; static modalOptions = { className: 'fullscreen-modal-full-overlay fullscreen-modal-portal-settings' @@ -16,6 +17,14 @@ export default class EditNewsletterModal extends Component { @tracked tab = 'settings'; @tracked optInExisting = this.args.data.newsletter.isNew; + get activeNewsletterSlugs() { + const activeNewsletters = this.store.peekAll('newsletter').filter((n) => { + return n.status === 'active' && !n.isNew && !n.isDestroyed; + }); + + return activeNewsletters.map(n => n.slug); + } + willDestroy() { super.willDestroy(...arguments); this.args.data.newsletter.rollbackAttributes(); @@ -48,7 +57,8 @@ export default class EditNewsletterModal extends Component { const shouldCreate = yield this.modals.open(ConfirmCreateModal, { optInExisting, - newsletter: this.args.data.newsletter + newsletter: this.args.data.newsletter, + activeNewsletterSlugs: this.activeNewsletterSlugs }); if (!shouldCreate) { diff --git a/ghost/admin/app/components/modals/edit-newsletter/confirm-create.hbs b/ghost/admin/app/components/modals/edit-newsletter/confirm-create.hbs index a54a081c76..8bc2c6c373 100644 --- a/ghost/admin/app/components/modals/edit-newsletter/confirm-create.hbs +++ b/ghost/admin/app/components/modals/edit-newsletter/confirm-create.hbs @@ -7,17 +7,12 @@
{{#if @data.optInExisting}} - {{!-- TODO: add members count once API supports it --}} - {{!-- {{#let (members-count-fetcher query=(hash filter="")) as |countFetcher|}} + {{#let (members-count-fetcher query=(hash filter=(concat "newsletters:[" (join @data.activeNewsletterSlugs ", ") "]"))) as |countFetcher|}} Your newsletter {{@data.newsletter.name}} will be immediately made live and your {{#if countFetcher.count}}{{countFetcher.count}}{{/if}} existing newsletter subscribers will be automatically opted-in to receive it. - {{/let}} --}} - - Your newsletter {{@data.newsletter.name}} will be - immediately made live and your existing newsletter subscribers - will be automatically opted-in to receive it. + {{/let}} {{else}} Your newsletter {{@data.newsletter.name}} will be immediately made live. Your existing newsletter subscribers will diff --git a/ghost/admin/ember-cli-build.js b/ghost/admin/ember-cli-build.js index 3f5b2743b2..87b0cb8231 100644 --- a/ghost/admin/ember-cli-build.js +++ b/ghost/admin/ember-cli-build.js @@ -117,7 +117,7 @@ module.exports = function (defaults) { includePolyfill: false }, 'ember-composable-helpers': { - only: ['optional', 'pick', 'toggle', 'toggle-action'] + only: ['join', 'optional', 'pick', 'toggle', 'toggle-action'] }, 'ember-promise-modals': { excludeCSS: true