From 67505f838c07e500b0126335899ec3859e684857 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Thu, 5 May 2022 11:18:41 +0100 Subject: [PATCH] Added first pass of recipient options to new publish flow closes https://github.com/TryGhost/Team/issues/1585 - adds newsletter select, free/paid checkboxes, and specific label select to the email recipients area in publish flow - updated `PublishOptions` - `willEmail` getter now takes into account the recipient filter so when free+paid+specific are all unchecked the flow corresponds to email not being sent - save task passes through the real recipient filter - added `fullRecipientFilter` for use in count fetchers so the selected newsletter is taken into account whilst we use `recipientFilter` as the main filter value - fixed issues with dropdowns being cut off - `{{liquid-if}}` uses `overflow: hidden` to make it's animation work, this means any popups that are larger than the expanded option size are cut off - switched away from rendering the selects inline so they aren't limited by parent container size - fixed `z-index` issues to they appear on top of the modal --- .../modals/publish-flow/confirm.hbs | 2 +- .../modals/publish-flow/options.hbs | 25 ++++++++++++--- .../editor-labs/publish-management.js | 29 +++++++++++++---- .../publish-options/email-recipients.hbs | 32 +++++++++++++++++++ .../gh-members-recipient-select.hbs | 3 +- .../components/gh-members-recipient-select.js | 4 +++ .../app/styles/components/publishmenu.css | 4 +++ 7 files changed, 86 insertions(+), 13 deletions(-) create mode 100644 ghost/admin/app/components/editor-labs/publish-options/email-recipients.hbs diff --git a/ghost/admin/app/components/editor-labs/modals/publish-flow/confirm.hbs b/ghost/admin/app/components/editor-labs/modals/publish-flow/confirm.hbs index 58749a9d28..cff48803cf 100644 --- a/ghost/admin/app/components/editor-labs/modals/publish-flow/confirm.hbs +++ b/ghost/admin/app/components/editor-labs/modals/publish-flow/confirm.hbs @@ -23,7 +23,7 @@ {{#if @publishOptions.willEmail}} will be delivered to - {{#let (members-count-fetcher query=(hash filter=@publishOptions.recipientFilter)) as |countFetcher|}} + {{#let (members-count-fetcher query=(hash filter=@publishOptions.fullRecipientFilter)) as |countFetcher|}} {{pluralize countFetcher.count "member"}} {{/let}} diff --git a/ghost/admin/app/components/editor-labs/modals/publish-flow/options.hbs b/ghost/admin/app/components/editor-labs/modals/publish-flow/options.hbs index cbd5971f4f..c16fd6b32c 100644 --- a/ghost/admin/app/components/editor-labs/modals/publish-flow/options.hbs +++ b/ghost/admin/app/components/editor-labs/modals/publish-flow/options.hbs @@ -24,21 +24,36 @@
{{svg-jar "member"}} -
- {{#if (not-eq @publishOptions.publishType "publish")}} - {{#let (members-count-fetcher query=(hash filter=@publishOptions.recipientFilter)) as |countFetcher|}} + {{#if @publishOptions.willEmail}} + + {{else}} + {{#if (eq @publishOptions.publishType "publish")}} +
+ Not sent to any members +
{{else}} - Not sent to any members + {{/if}} -
+ {{/if}} {{svg-jar "arrow-down" class="icon-expand"}}
+ {{#liquid-if (eq this.openSection "emailRecipients")}} +
+ +
+ {{/liquid-if}}
diff --git a/ghost/admin/app/components/editor-labs/publish-management.js b/ghost/admin/app/components/editor-labs/publish-management.js index e72e45689e..e53f743dab 100644 --- a/ghost/admin/app/components/editor-labs/publish-management.js +++ b/ghost/admin/app/components/editor-labs/publish-management.js @@ -29,7 +29,7 @@ export class PublishOptions { } get willEmail() { - return this.publishType !== 'publish'; + return this.publishType !== 'publish' && this.recipientFilter; } get willPublish() { @@ -139,7 +139,9 @@ export class PublishOptions { // set in constructor because services are not injected allNewsletters = []; - @tracked newsletter = null; // set to default in constructor + // both of these are set to site defaults in `setupTask` + @tracked newsletter = null; + @tracked recipientFilter = 'status:free,status:-free'; get newsletters() { return this.allNewsletters @@ -155,8 +157,24 @@ export class PublishOptions { return this.newsletters.length === 1; } - get recipientFilter() { - return `newsletters:${this.newsletter.slug}`; + get fullRecipientFilter() { + let filter = `newsletters:${this.newsletter.slug}`; + + if (this.recipientFilter) { + filter += `+(${this.recipientFilter})`; + } + + return filter; + } + + @action + setNewsletter(newsletter) { + this.newsletter = newsletter; + } + + @action + setRecipientFilter(newFilter) { + this.recipientFilter = newFilter; } // setup ------------------------------------------------------------------- @@ -217,8 +235,7 @@ export class PublishOptions { if (this.willEmail) { adapterOptions.newsletterId = this.newsletter.id; - // TODO: replace with real filter - adapterOptions.emailRecipientFilter = 'status:free,status:-free'; + adapterOptions.emailRecipientFilter = this.recipientFilter; } try { diff --git a/ghost/admin/app/components/editor-labs/publish-options/email-recipients.hbs b/ghost/admin/app/components/editor-labs/publish-options/email-recipients.hbs new file mode 100644 index 0000000000..47c3e43571 --- /dev/null +++ b/ghost/admin/app/components/editor-labs/publish-options/email-recipients.hbs @@ -0,0 +1,32 @@ +{{#if (eq @publishOptions.totalMemberCount 0)}} +

+ Add members + to start sending newsletters! +

+{{else}} +
+ {{#if (gt @publishOptions.newsletters.length 1)}} +
+ Newsletter: + + {{newsletter.name}} + +
+ {{/if}} + + +
+{{/if}} \ No newline at end of file diff --git a/ghost/admin/app/components/gh-members-recipient-select.hbs b/ghost/admin/app/components/gh-members-recipient-select.hbs index a2eb7b0177..9afffafbcc 100644 --- a/ghost/admin/app/components/gh-members-recipient-select.hbs +++ b/ghost/admin/app/components/gh-members-recipient-select.hbs @@ -58,13 +58,14 @@ {{#if this.isSpecificChecked}} diff --git a/ghost/admin/app/components/gh-members-recipient-select.js b/ghost/admin/app/components/gh-members-recipient-select.js index 268b4fdf31..11cdd8a5ca 100644 --- a/ghost/admin/app/components/gh-members-recipient-select.js +++ b/ghost/admin/app/components/gh-members-recipient-select.js @@ -27,6 +27,10 @@ export default class GhMembersRecipientSelect extends Component { this.fetchMemberCountsTask.perform(); } + get renderInPlace() { + return this.args.renderInPlace === undefined ? true : this.args.renderInPlace; + } + get baseFilters() { const filterItems = (this.args.filter || '').split(','); const filterItemsArray = filterItems.filter(item => BASE_FILTERS.includes(item?.trim())); diff --git a/ghost/admin/app/styles/components/publishmenu.css b/ghost/admin/app/styles/components/publishmenu.css index f5f9ab9c56..ce269e4088 100644 --- a/ghost/admin/app/styles/components/publishmenu.css +++ b/ghost/admin/app/styles/components/publishmenu.css @@ -377,6 +377,10 @@ right: 10px; } +.gh-publishmenu-newsletter-dropdown { + z-index: 99999; +} + .gh-publishmenu-newsletter-dropdown .ember-power-select-option[aria-selected="true"] { color: var(--black); font-weight: 600;