mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Added post.{isPost,isPage} computed properties
no issue - removes the need to check `post.displayName === 'post/page'` any time we need a conditional on post type
This commit is contained in:
parent
202468c025
commit
56f18c8886
6 changed files with 12 additions and 8 deletions
|
@ -129,7 +129,7 @@
|
|||
</button>
|
||||
{{svg-jar "arrow-right"}}
|
||||
</li>
|
||||
{{#if (and this.feature.members (eq this.post.displayName "post") showEmailNewsletter)}}
|
||||
{{#if (and this.feature.members this.post.isPost) showEmailNewsletter)}}
|
||||
<li class="nav-list-item" {{action "showSubview" "email-settings"}} data-test-button="email-settings">
|
||||
<button type="button">
|
||||
<b>Email newsletter</b>
|
||||
|
|
|
@ -47,10 +47,10 @@ export default Component.extend({
|
|||
return '';
|
||||
}),
|
||||
|
||||
canSendEmail: computed('feature.labs.members', 'post.{displayName,email}', 'settings.{mailgunApiKey,mailgunDomain,mailgunBaseUrl}', 'config.mailgunIsConfigured', function () {
|
||||
canSendEmail: computed('feature.labs.members', 'post.{isPost,email}', 'settings.{mailgunApiKey,mailgunDomain,mailgunBaseUrl}', 'config.mailgunIsConfigured', function () {
|
||||
let membersEnabled = this.feature.get('labs.members');
|
||||
let mailgunIsConfigured = this.get('settings.mailgunApiKey') && this.get('settings.mailgunDomain') && this.get('settings.mailgunBaseUrl') || this.get('config.mailgunIsConfigured');
|
||||
let isPost = this.post.displayName === 'post';
|
||||
let isPost = this.post.isPost;
|
||||
let hasSentEmail = !!this.post.email;
|
||||
|
||||
return membersEnabled && mailgunIsConfigured && isPost && !hasSentEmail;
|
||||
|
|
|
@ -46,10 +46,10 @@ export default Component.extend({
|
|||
return '';
|
||||
}),
|
||||
|
||||
canSendEmail: computed('feature.labs.members', 'post.{displayName,email}', 'settings.{mailgunApiKey,mailgunDomain,mailgunBaseUrl}', 'config.mailgunIsConfigured', function () {
|
||||
canSendEmail: computed('feature.labs.members', 'post.{isPost,email}', 'settings.{mailgunApiKey,mailgunDomain,mailgunBaseUrl}', 'config.mailgunIsConfigured', function () {
|
||||
let membersEnabled = this.feature.get('labs.members');
|
||||
let mailgunIsConfigured = this.get('settings.mailgunApiKey') && this.get('settings.mailgunDomain') && this.get('settings.mailgunBaseUrl') || this.get('config.mailgunIsConfigured');
|
||||
let isPost = this.post.displayName === 'post';
|
||||
let isPost = this.post.isPost;
|
||||
let hasSentEmail = !!this.post.email;
|
||||
|
||||
return membersEnabled && mailgunIsConfigured && isPost && !hasSentEmail;
|
||||
|
|
|
@ -38,10 +38,10 @@ export default Component.extend({
|
|||
|
||||
hasEmailPermission: or('session.user.isOwner', 'session.user.isAdmin', 'session.user.isEditor'),
|
||||
|
||||
canSendEmail: computed('feature.labs.members', 'post.{displayName,email}', 'settings.{mailgunApiKey,mailgunDomain,mailgunBaseUrl}', 'config.mailgunIsConfigured', function () {
|
||||
canSendEmail: computed('feature.labs.members', 'post.{isPost,email}', 'settings.{mailgunApiKey,mailgunDomain,mailgunBaseUrl}', 'config.mailgunIsConfigured', function () {
|
||||
let membersEnabled = this.feature.get('labs.members');
|
||||
let mailgunIsConfigured = this.get('settings.mailgunApiKey') && this.get('settings.mailgunDomain') && this.get('settings.mailgunBaseUrl') || this.get('config.mailgunIsConfigured');
|
||||
let isPost = this.post.displayName === 'post';
|
||||
let isPost = this.post.isPost;
|
||||
let hasSentEmail = !!this.post.email;
|
||||
|
||||
return membersEnabled && mailgunIsConfigured && isPost && !hasSentEmail;
|
||||
|
|
|
@ -6,6 +6,7 @@ import isNumber from 'ghost-admin/utils/isNumber';
|
|||
import moment from 'moment';
|
||||
import {action, computed} from '@ember/object';
|
||||
import {alias, mapBy} from '@ember/object/computed';
|
||||
import {capitalize} from '@ember/string';
|
||||
import {inject as controller} from '@ember/controller';
|
||||
import {get} from '@ember/object';
|
||||
import {htmlSafe} from '@ember/string';
|
||||
|
@ -865,7 +866,7 @@ export default Controller.extend({
|
|||
let actions, type, path;
|
||||
|
||||
if (status === 'published' || status === 'scheduled') {
|
||||
type = this.get('post.displayName') === 'page' ? 'Page' : 'Post';
|
||||
type = capitalize(this.get('post.displayName'));
|
||||
path = this.get('post.url');
|
||||
actions = `<a href="${path}" target="_blank">View ${type}</a>`;
|
||||
} else {
|
||||
|
|
|
@ -149,6 +149,9 @@ export default Model.extend(Comparable, ValidationEngine, {
|
|||
internalTags: filterBy('tags', 'isInternal', true),
|
||||
isScheduled: equal('status', 'scheduled'),
|
||||
|
||||
isPost: equal('displayName', 'post'),
|
||||
isPage: equal('displayName', 'page'),
|
||||
|
||||
willEmail: computed('emailRecipientFilter', function () {
|
||||
return this.emailRecipientFilter !== 'none';
|
||||
}),
|
||||
|
|
Loading…
Add table
Reference in a new issue