mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-25 09:03:12 +03:00
Added newsletter name in post scheduled tooltip
refs https://github.com/TryGhost/Team/issues/1576 This change was required to avoid showing 'all members' or 'all paid members', when it was in fact 'all paid subscribers of newsletter X'. The newsletter name is only shown when multiple newsletters are activated on a site.
This commit is contained in:
parent
59e7b720a2
commit
d11cf9e1c7
@ -7,7 +7,7 @@
|
||||
Scheduled
|
||||
{{#if this.isHovered}}
|
||||
<time datetime="{{@post.publishedAtUTC}}" class="ml1 green f8" data-test-schedule-countdown>
|
||||
to be sent to <GhRecipientFilterCount @filter={{@post.fullRecipientFilter}} />
|
||||
to be sent to <GhRecipientFilterCount @filter={{@post.fullRecipientFilter}} @newsletter={{@post.newsletter}} />
|
||||
{{this.scheduledTime}}
|
||||
</time>
|
||||
{{/if}}
|
||||
@ -24,7 +24,7 @@
|
||||
{{#if this.isHovered}}
|
||||
to be published
|
||||
{{#if (and @post.emailRecipientFilter (not @post.email))}}
|
||||
and sent to <GhRecipientFilterCount @filter={{@post.fullRecipientFilter}} />
|
||||
and sent to <GhRecipientFilterCount @filter={{@post.fullRecipientFilter}} @newsletter={{@post.newsletter}} />
|
||||
{{/if}}
|
||||
{{this.scheduledTime}}
|
||||
{{/if}}
|
||||
|
@ -17,7 +17,7 @@ export default class GhMembersFilterCountComponent extends Component {
|
||||
*getMembersCountTask() {
|
||||
this.memberCount = yield this.membersCountCache.countString(
|
||||
this.args.filter,
|
||||
{knownCount: this.args.knownCount}
|
||||
{knownCount: this.args.knownCount, newsletter: this.args.newsletter}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{#if @filter}}
|
||||
<GhMembersFilterCount @filter={{@filter}} @knownCount={{@knownCount}} />
|
||||
<GhMembersFilterCount @filter={{@filter}} @newsletter={{@newsletter}} @knownCount={{@knownCount}} />
|
||||
{{else}}
|
||||
0 members
|
||||
{{/if}}
|
||||
|
@ -63,7 +63,7 @@ export default class ConfirmPublishModal extends Component {
|
||||
const filter = `${newsletter.recipientFilter}+(${sendEmailWhenPublished})`;
|
||||
|
||||
this.memberCount = sendEmailWhenPublished ? (yield this.membersCountCache.count(filter)) : 0;
|
||||
this.memberCountString = sendEmailWhenPublished ? (yield this.membersCountCache.countString(filter)) : '0 members';
|
||||
this.memberCountString = sendEmailWhenPublished ? (yield this.membersCountCache.countString(filter, {newsletter})) : '0 members';
|
||||
}
|
||||
|
||||
@task
|
||||
|
@ -1071,7 +1071,8 @@ export default class EditorController extends Controller {
|
||||
publishedAtUTC,
|
||||
emailRecipientFilter,
|
||||
previewUrl,
|
||||
emailOnly
|
||||
emailOnly,
|
||||
newsletter
|
||||
} = this.post;
|
||||
let publishedAtBlogTZ = moment.tz(publishedAtUTC, this.settings.get('timezone'));
|
||||
|
||||
@ -1079,7 +1080,7 @@ export default class EditorController extends Controller {
|
||||
let description = emailOnly ? ['Will be sent'] : ['Will be published'];
|
||||
|
||||
if (emailRecipientFilter && emailRecipientFilter !== 'none') {
|
||||
const recipientCount = await this.membersCountCache.countString(this.post.fullRecipientFilter);
|
||||
const recipientCount = await this.membersCountCache.countString(this.post.fullRecipientFilter, {newsletter});
|
||||
description.push(`${!emailOnly ? 'and delivered ' : ''}to <span><strong>${recipientCount}</strong></span>`);
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ export default class MembersCountCacheService extends Service {
|
||||
@service store;
|
||||
|
||||
cache = {};
|
||||
hasMultipleNewsletters = null;
|
||||
|
||||
@action
|
||||
async count(query) {
|
||||
@ -31,10 +32,21 @@ export default class MembersCountCacheService extends Service {
|
||||
}
|
||||
|
||||
@action
|
||||
async countString(filter = '', {knownCount} = {}) {
|
||||
async countString(filter = '', {knownCount, newsletter} = {}) {
|
||||
// Determine if we need to show the name of the newsletter or not
|
||||
// TODO: replace this with a service or a settings boolean if we ever add a shortcut for this
|
||||
if (this.hasMultipleNewsletters === null) {
|
||||
const allNewsletters = await this.store.query('newsletter', {status: 'active', limit: 'all'});
|
||||
this.hasMultipleNewsletters = allNewsletters.length > 1;
|
||||
}
|
||||
|
||||
const user = this.session.user;
|
||||
|
||||
const basicFilter = filter.replace(/^newsletters\.status:active\+\((.*)\)$/, '$1');
|
||||
const nounSingular = newsletter && this.hasMultipleNewsletters ? 'subscriber' : 'member';
|
||||
const nounPlural = nounSingular + 's';
|
||||
const suffix = newsletter && this.hasMultipleNewsletters ? (' of ' + newsletter.name) : '';
|
||||
|
||||
const basicFilter = newsletter ? filter.replace(newsletter.recipientFilter, '').replace(/^\+\((.*)\)$/, '$1') : filter;
|
||||
const filterParts = basicFilter.split(',');
|
||||
const isFree = filterParts.length === 1 && filterParts[0] === 'status:free';
|
||||
const isPaid = filterParts.length === 1 && filterParts[0] === 'status:-free';
|
||||
@ -44,13 +56,13 @@ export default class MembersCountCacheService extends Service {
|
||||
// TODO: remove when editors have relevant permissions or we have a different way of fetching counts
|
||||
if (user.isEditor && knownCount === undefined) {
|
||||
if (isFree) {
|
||||
return 'all free members';
|
||||
return 'all free ' + nounPlural + suffix;
|
||||
}
|
||||
if (isPaid) {
|
||||
return 'all paid members';
|
||||
return 'all paid members' + nounPlural + suffix;
|
||||
}
|
||||
if (isAll) {
|
||||
return 'all members';
|
||||
return 'all members' + nounPlural + suffix;
|
||||
}
|
||||
|
||||
return 'a custom members segment';
|
||||
@ -59,14 +71,14 @@ export default class MembersCountCacheService extends Service {
|
||||
const recipientCount = knownCount !== undefined ? knownCount : await this.count(filter);
|
||||
|
||||
if (isFree) {
|
||||
return ghPluralize(recipientCount, 'free member');
|
||||
return ghPluralize(recipientCount, 'free ' + nounSingular) + suffix;
|
||||
}
|
||||
|
||||
if (isPaid) {
|
||||
return ghPluralize(recipientCount, 'paid member');
|
||||
return ghPluralize(recipientCount, 'paid ' + nounSingular) + suffix;
|
||||
}
|
||||
|
||||
return ghPluralize(recipientCount, 'member');
|
||||
return ghPluralize(recipientCount, nounSingular) + suffix;
|
||||
}
|
||||
|
||||
@action
|
||||
|
Loading…
Reference in New Issue
Block a user