Ghost/ghost/admin/app/components/gh-distribution-action-select.js
Naz 9e84441e75 Added publishing action dropdown to publish menu
refs https://github.com/TryGhost/Team/issues/947

- Added a "distribution" dropdown component to the post publish menu allowing to select from one of three available types of distribution: publish, poblush&send, and send
2021-08-25 22:20:11 +12:00

51 lines
1.4 KiB
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.post.emailOnly
? 'send'
: (this.args.post.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
setPublishAction(newAction) {
this.distributionValue = newAction;
if (newAction.value === 'publish_send') {
this.args.post.emailOnly = false;
this.args.post.emailRecipientFilter = null;
} else if (newAction.value === 'publish') {
this.args.post.emailOnly = false;
this.args.post.emailRecipientFilter = 'none';
} else if (newAction.value === 'send') {
this.args.post.emailOnly = true;
this.args.post.emailRecipientFilter = null;
}
this.args.post.save();
}
}