Ghost/ghost/admin/app/components/gh-publishmenu.hbs
Kevin Ansfield b474e00cf8 🐛 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
2021-10-21 13:08:08 +01:00

82 lines
3.7 KiB
Handlebars

{{#if (eq this.displayState "sent")}}
<div class="gh-btn gh-btn-text sent">Sent</div>
{{else}}
<GhBasicDropdown @verticalPosition="below" @horizontalPosition="right" @onOpen={{action "open"}} @onClose={{action "close"}} as |dd|>
<dd.Trigger class="gh-btn gh-btn-editor {{if (or (eq this.displayState "published") (eq this.displayState "scheduled") (eq this.uiContext "preview")) "green"}} gh-publishmenu-trigger">
<span data-test-publishmenu-trigger>{{this.triggerText}} {{svg-jar "arrow-down"}}</span>
</dd.Trigger>
<dd.Content class="gh-publishmenu-dropdown">
{{#if (eq this.displayState "published")}}
<GhPublishmenuPublished
@post={{this.post}}
@saveType={{this.saveType}}
@setSaveType={{action "setSaveType"}}
data-test-publishmenu-published="true" />
{{else if (eq this.displayState "scheduled")}}
<GhPublishmenuScheduled
@post={{this.post}}
@saveType={{this.saveType}}
@isClosing={{this.isClosing}}
@canSendEmail={{this.canSendEmail}}
@recipientsFilter={{this.sendEmailWhenPublished}}
@setSaveType={{action "setSaveType"}}
@setTypedDateError={{action (mut this.typedDateError)}}
@isSendingEmailLimited={{this.isSendingEmailLimited}}
@sendingEmailLimitError={{this.sendingEmailLimitError}}
data-test-publishmenu-scheduled="true" />
{{else}}
<GhPublishmenuDraft
@post={{this.post}}
@saveType={{this.saveType}}
@setSaveType={{action "setSaveType"}}
@setTypedDateError={{action (mut this.typedDateError)}}
@canSendEmail={{this.canSendEmail}}
@emailOnly={{this.emailOnly}}
@recipientsFilter={{this.sendEmailWhenPublished}}
@setSendEmailWhenPublished={{action "setSendEmailWhenPublished"}}
@isSendingEmailLimited={{this.isSendingEmailLimited}}
@sendingEmailLimitError={{this.sendingEmailLimitError}}
@distributionAction={{this.distributionAction}}
@setDistributionAction={{action "setDistributionAction"}}
data-test-publishmenu-draft="true" />
{{/if}}
{{!--
save button needs to be outside of menu components so it doesn't lose state
or cancel the task when the post status updates and switches components
--}}
<footer class="gh-publishmenu-footer">
<button class="gh-btn gh-btn-outline" {{on "click" (action dd.actions.close)}} data-test-publishmenu-cancel>
<span>Cancel</span>
</button>
<GhTaskButton
@buttonText={{this.buttonText}}
@task={{this.save}}
@taskArgs={{hash dropdown=dd}}
@successText={{this.successText}}
@runningText={{this.runningText}}
@class="gh-btn gh-btn-black gh-publishmenu-button gh-btn-icon"
data-test-publishmenu-save="true"
/>
</footer>
</dd.Content>
</GhBasicDropdown>
{{/if}}
{{#if this.showEmailConfirmationModal}}
<GhFullscreenModal
@modal="confirm-email-send"
@model={{hash
sendEmailWhenPublished=this.sendEmailWhenPublished
isScheduled=(eq this.saveType "schedule")
emailOnly=this.emailOnly
retryEmailSend=this.retryEmailSend
}}
@confirm={{this.confirmEmailSend}}
@close={{this.closeEmailConfirmationModal}}
@modifier="action wide"
/>
{{/if}}