Ghost/ghost/admin/app/components/gh-distribution-action-select.js
Kevin Ansfield 89a6bc683b 🐛 Fixed incorrect publish type showing in publish menu after close/re-open
closes https://github.com/TryGhost/Team/issues/1151

The publish-type state was being set directly on the model in the publish menu rather than being internal to the menu until publishing. A previous attempt had been made to fix that but it wasn't complete and resulted in the menu showing that it would "Publish" after setting it and closing/re-opening when in fact it would "Publish and send".

- moved all state for the distribution type and email settings to be stored in the `<PublishMenu>` component rather than split across the the component and model
- when saving a post from the publish menu, we now pass `emailOnly` as an option to the editor's save task the same as `sendEmailWhenPublished` (corresponding to the `email_recipient_filter` query param) so that we're back to one place controlling email behaviour for a post
- when `emailOnly` is passed as an option to the editor save task it will set the property on the model before saving and reset it back if the save fails. That way the email-only flag behaves as close to the "send when published" flag as possible without it also being sent as a query param.
2021-10-15 15:42:32 +01:00

40 lines
1022 B
JavaScript

import Component from '@glimmer/component';
import {action} from '@ember/object';
import {tracked} from '@glimmer/tracking';
export default class GhDistributionActionSelect extends Component {
@tracked
distributionValue;
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'
}];
}
@action
setDistributionAction(newAction) {
this.distributionValue = newAction;
this.args.setDistributionAction(newAction.value);
}
}