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:
parent
328a59466c
commit
b474e00cf8
5 changed files with 31 additions and 46 deletions
|
@ -1,39 +1,24 @@
|
||||||
import Component from '@glimmer/component';
|
import Component from '@glimmer/component';
|
||||||
import {action} from '@ember/object';
|
import {action} from '@ember/object';
|
||||||
import {tracked} from '@glimmer/tracking';
|
|
||||||
|
|
||||||
export default class GhDistributionActionSelect extends Component {
|
export default class GhDistributionActionSelect extends Component {
|
||||||
@tracked
|
availablePublishActions = [{
|
||||||
distributionValue;
|
value: 'publish_send',
|
||||||
|
name: 'publish & send'
|
||||||
|
}, {
|
||||||
|
value: 'publish',
|
||||||
|
name: 'publish'
|
||||||
|
}, {
|
||||||
|
value: 'send',
|
||||||
|
name: 'send'
|
||||||
|
}];
|
||||||
|
|
||||||
constructor(...args) {
|
get distributionValue() {
|
||||||
super(...args);
|
return this.availablePublishActions.findBy('value', this.args.distributionAction);
|
||||||
|
|
||||||
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'
|
|
||||||
}];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
setDistributionAction(newAction) {
|
setDistributionAction(newAction) {
|
||||||
this.distributionValue = newAction;
|
|
||||||
this.args.setDistributionAction(newAction.value);
|
this.args.setDistributionAction(newAction.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
<div {{did-insert (fn this.setSaveType "publish")}} ...attributes>
|
<div {{did-insert (fn this.setSaveType "publish")}} ...attributes>
|
||||||
<header class="gh-publishmenu-heading">Ready to
|
<header class="gh-publishmenu-heading">Ready to
|
||||||
{{#if this.showEmailOnlyInput}}
|
{{#if @canSendEmail}}
|
||||||
<GhDistributionActionSelect
|
<GhDistributionActionSelect
|
||||||
@emailOnly={{@emailOnly}}
|
@distributionAction={{@distributionAction}}
|
||||||
@emailRecipientFilter={{@recipientsFilter}}
|
|
||||||
@setDistributionAction={{@setDistributionAction}}
|
@setDistributionAction={{@setDistributionAction}}
|
||||||
/>
|
/>
|
||||||
{{else}}
|
{{else}}
|
||||||
{{this.nextActionName}}
|
publish
|
||||||
{{/if}}
|
{{/if}}
|
||||||
this {{@post.displayName}}?
|
this {{@post.displayName}}?
|
||||||
</header>
|
</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 {{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-button" data-test-publishmenu-published-option></div>
|
||||||
<div class="gh-publishmenu-radio-content">
|
<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-label">{{#if @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-desc">{{#if @emailOnly}}Deliver this immediately{{else}}Publish this {{@post.displayName}} immediately{{/if}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="gh-publishmenu-radio {{if (eq @saveType "schedule") "active"}}" {{on "click" (fn this.setSaveType "schedule")}}>
|
<div class="gh-publishmenu-radio {{if (eq @saveType "schedule") "active"}}" {{on "click" (fn this.setSaveType "schedule")}}>
|
||||||
|
@ -36,7 +35,7 @@
|
||||||
@minDate={{this._minDate}}
|
@minDate={{this._minDate}}
|
||||||
@isActive={{eq @saveType "schedule"}}
|
@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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -24,16 +24,8 @@ export default class GhPublishMenuDraftComponent extends Component {
|
||||||
return this.session.user.isAdmin && (this.totalMemberCount === 0 || this.countTotalMembersTask.isRunning);
|
return this.session.user.isAdmin && (this.totalMemberCount === 0 || this.countTotalMembersTask.isRunning);
|
||||||
}
|
}
|
||||||
|
|
||||||
get nextActionName() {
|
|
||||||
return this.args.emailOnly ? 'send' : 'publish';
|
|
||||||
}
|
|
||||||
|
|
||||||
get showEmailSection() {
|
get showEmailSection() {
|
||||||
return this.args.canSendEmail && this.args.recipientsFilter !== 'none';
|
return this.args.canSendEmail && this.args.distributionAction !== 'publish';
|
||||||
}
|
|
||||||
|
|
||||||
get showEmailOnlyInput() {
|
|
||||||
return this.args.post.isPost;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
@setSendEmailWhenPublished={{action "setSendEmailWhenPublished"}}
|
@setSendEmailWhenPublished={{action "setSendEmailWhenPublished"}}
|
||||||
@isSendingEmailLimited={{this.isSendingEmailLimited}}
|
@isSendingEmailLimited={{this.isSendingEmailLimited}}
|
||||||
@sendingEmailLimitError={{this.sendingEmailLimitError}}
|
@sendingEmailLimitError={{this.sendingEmailLimitError}}
|
||||||
|
@distributionAction={{this.distributionAction}}
|
||||||
@setDistributionAction={{action "setDistributionAction"}}
|
@setDistributionAction={{action "setDistributionAction"}}
|
||||||
data-test-publishmenu-draft="true" />
|
data-test-publishmenu-draft="true" />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -98,16 +98,24 @@ export default Component.extend({
|
||||||
return runningText || 'Publishing';
|
return runningText || 'Publishing';
|
||||||
}),
|
}),
|
||||||
|
|
||||||
buttonText: computed('postState', 'saveType', 'distributionAction', function () {
|
buttonText: computed('postState', 'saveType', 'distributionAction', 'sendEmailWhenPublished', function () {
|
||||||
let saveType = this.saveType;
|
let saveType = this.saveType;
|
||||||
let postState = this.postState;
|
let postState = this.postState;
|
||||||
let distributionAction = this.get('distributionAction');
|
let distributionAction = this.distributionAction;
|
||||||
let buttonText;
|
let buttonText;
|
||||||
|
|
||||||
if (postState === 'draft') {
|
if (postState === 'draft') {
|
||||||
switch (distributionAction) {
|
switch (distributionAction) {
|
||||||
case 'publish_send':
|
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;
|
break;
|
||||||
case 'publish':
|
case 'publish':
|
||||||
buttonText = (saveType === 'publish') ? 'Publish' : 'Schedule';
|
buttonText = (saveType === 'publish') ? 'Publish' : 'Schedule';
|
||||||
|
|
Loading…
Add table
Reference in a new issue