0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

🐛 Fixed inconsistent publish/send messaging in publish menu

no issue

- fixes the "publish/send" dropdown showing when mail is not allowed by tying it to the `canSendEmail` property rather than always showing when editing a draft post
  - was previously showing when mailgun is not configured and when default email recipients is set to "disabled", in both cases the recipient selection was never available so the dropdown was confusing and lead to invalid states
  - removed the unnecessary property`showEmailOnlyInput` - replaced with `@canSendEmail`
  - removed the unnecessary property `nextActionName` - it always resulted in "publish" because it was only being shown for pages and pages can't be sent by email
- removed the logic for setting the initial selected option in `<GhDistributionActionSelect>` because it meant the select was not directly tied to the real distribution action value leading to mixed states across components. Switched to using the passed in `@distributionAction` value directly.
- fixed the publish button incorrectly showing "Publish & send" when no send would be occurring for a post
  - if "Publish & Send" is selected, the button will now show "Publish" when no recipients are selected
- fixed the publish button incorrectly showing "Publish & send" for pages
- fixed the now/schedule radio texts not changing when publish type was set to "Send" - the conditionals were incorrectly looking at `this.args.post.emailOnly` which is incorrect syntax would only update _after_ saving, switched to the menu's internal `@emailOnly` argument instead
This commit is contained in:
Kevin Ansfield 2021-10-21 13:07:56 +01:00
parent 328a59466c
commit b474e00cf8
5 changed files with 31 additions and 46 deletions

View file

@ -1,39 +1,24 @@
import Component from '@glimmer/component';
import {action} from '@ember/object';
import {tracked} from '@glimmer/tracking';
export default class GhDistributionActionSelect extends Component {
@tracked
distributionValue;
availablePublishActions = [{
value: 'publish_send',
name: 'publish & send'
}, {
value: 'publish',
name: 'publish'
}, {
value: 'send',
name: 'send'
}];
constructor(...args) {
super(...args);
let distributionValue = this.args.emailOnly
? 'send'
: (this.args.emailRecipientFilter !== 'none')
? 'publish_send'
: 'publish';
this.distributionValue = this.availablePublishActions.findBy('value', distributionValue);
}
get availablePublishActions() {
return [{
value: 'publish_send',
name: 'publish & send'
}, {
value: 'publish',
name: 'publish'
}, {
value: 'send',
name: 'send'
}];
get distributionValue() {
return this.availablePublishActions.findBy('value', this.args.distributionAction);
}
@action
setDistributionAction(newAction) {
this.distributionValue = newAction;
this.args.setDistributionAction(newAction.value);
}
}

View file

@ -1,13 +1,12 @@
<div {{did-insert (fn this.setSaveType "publish")}} ...attributes>
<header class="gh-publishmenu-heading">Ready to
{{#if this.showEmailOnlyInput}}
{{#if @canSendEmail}}
<GhDistributionActionSelect
@emailOnly={{@emailOnly}}
@emailRecipientFilter={{@recipientsFilter}}
@distributionAction={{@distributionAction}}
@setDistributionAction={{@setDistributionAction}}
/>
{{else}}
{{this.nextActionName}}
publish
{{/if}}
this {{@post.displayName}}?
</header>
@ -16,8 +15,8 @@
<div class="gh-publishmenu-radio {{if (eq @saveType "publish") "active"}}" {{on "click" (fn this.setSaveType "publish")}}>
<div class="gh-publishmenu-radio-button" data-test-publishmenu-published-option></div>
<div class="gh-publishmenu-radio-content">
<div class="gh-publishmenu-radio-label">{{#if this.args.post.emailOnly}}Send email now{{else}}Set it live now{{/if}}</div>
<div class="gh-publishmenu-radio-desc">{{#if this.args.post.emailOnly}}Deliver this immediately{{else}}Publish this {{@post.displayName}} immediately{{/if}}</div>
<div class="gh-publishmenu-radio-label">{{#if @emailOnly}}Send email now{{else}}Set it live now{{/if}}</div>
<div class="gh-publishmenu-radio-desc">{{#if @emailOnly}}Deliver this immediately{{else}}Publish this {{@post.displayName}} immediately{{/if}}</div>
</div>
</div>
<div class="gh-publishmenu-radio {{if (eq @saveType "schedule") "active"}}" {{on "click" (fn this.setSaveType "schedule")}}>
@ -36,7 +35,7 @@
@minDate={{this._minDate}}
@isActive={{eq @saveType "schedule"}}
/>
<div class="gh-publishmenu-radio-desc">{{#if this.args.post.emailOnly}}Send email at a specific time{{else}}Set automatic future publish date{{/if}}</div>
<div class="gh-publishmenu-radio-desc">{{#if @emailOnly}}Send email at a specific time{{else}}Set automatic future publish date{{/if}}</div>
</div>
</div>
</div>

View file

@ -24,16 +24,8 @@ export default class GhPublishMenuDraftComponent extends Component {
return this.session.user.isAdmin && (this.totalMemberCount === 0 || this.countTotalMembersTask.isRunning);
}
get nextActionName() {
return this.args.emailOnly ? 'send' : 'publish';
}
get showEmailSection() {
return this.args.canSendEmail && this.args.recipientsFilter !== 'none';
}
get showEmailOnlyInput() {
return this.args.post.isPost;
return this.args.canSendEmail && this.args.distributionAction !== 'publish';
}
constructor() {

View file

@ -39,6 +39,7 @@
@setSendEmailWhenPublished={{action "setSendEmailWhenPublished"}}
@isSendingEmailLimited={{this.isSendingEmailLimited}}
@sendingEmailLimitError={{this.sendingEmailLimitError}}
@distributionAction={{this.distributionAction}}
@setDistributionAction={{action "setDistributionAction"}}
data-test-publishmenu-draft="true" />
{{/if}}

View file

@ -98,16 +98,24 @@ export default Component.extend({
return runningText || 'Publishing';
}),
buttonText: computed('postState', 'saveType', 'distributionAction', function () {
buttonText: computed('postState', 'saveType', 'distributionAction', 'sendEmailWhenPublished', function () {
let saveType = this.saveType;
let postState = this.postState;
let distributionAction = this.get('distributionAction');
let distributionAction = this.distributionAction;
let buttonText;
if (postState === 'draft') {
switch (distributionAction) {
case 'publish_send':
buttonText = (saveType === 'publish') ? 'Publish & send' : 'Schedule';
if (saveType === 'publish') {
buttonText = 'Publish';
if (this.canSendEmail && this.sendEmailWhenPublished && this.sendEmailWhenPublished !== 'none') {
buttonText = `${buttonText} & send`;
}
} else {
buttonText = 'Schedule';
}
break;
case 'publish':
buttonText = (saveType === 'publish') ? 'Publish' : 'Schedule';