Updated email role restrictions

no issue.
Only admins and owners should have access to sending emails. Updated relevant templates
to restrict access to emails for non-admins/owners
This commit is contained in:
Peter Zimon 2019-11-26 13:20:49 +01:00
parent 727a38d5d1
commit e866808193
7 changed files with 72 additions and 65 deletions

View File

@ -6,6 +6,7 @@ import {inject as service} from '@ember/service';
export default Component.extend({
ghostPaths: service(),
session: service(),
tagName: 'li',
classNames: ['gh-list-row', 'gh-posts-list-item'],

View File

@ -8,6 +8,7 @@ import {inject as service} from '@ember/service';
export default Component.extend({
feature: service(),
settings: service(),
session: service(),
post: null,
saveType: null,

View File

@ -9,6 +9,7 @@ export default Component.extend({
post: null,
saveType: null,
session: service(),
isClosing: null,
// used to set minDate in datepicker

View File

@ -130,7 +130,7 @@
</button>
{{svg-jar "arrow-right"}}
</li>
{{#if (and this.feature.members (eq this.post.displayName "post"))}}
{{#if (and this.feature.members (eq this.post.displayName "post") this.session.user.isOwnerOrAdmin)}}
<li class="nav-list-item" {{action "showSubview" "email-settings"}} data-test-button="email-settings">
<button type="button">
<b>Email newsletter</b>

View File

@ -43,20 +43,22 @@
</span>
{{/if}}
{{#if (or this.post.email (and this.post.isScheduled this.post.sendEmailWhenPublished))}}
{{#if (eq this.post.email.status "failed")}}
<span data-tooltip="Failed to send post by email" class="gh-content-status-emailed error">
{{svg-jar "send-email" class="stroke-red"}}
</span>
{{else}}
{{#if this.isScheduled}}
<span data-tooltip="To be sent by email" class="gh-content-status-emailed scheduled">
{{svg-jar "send-email" class="stroke-green-d2"}}
{{#if this.session.user.isOwnerOrAdmin}}
{{#if (or this.post.email (and this.post.isScheduled this.post.sendEmailWhenPublished))}}
{{#if (eq this.post.email.status "failed")}}
<span data-tooltip="Failed to send post by email" class="gh-content-status-emailed error">
{{svg-jar "send-email" class="stroke-red"}}
</span>
{{else}}
<span data-tooltip="Sent by email" class="gh-content-status-emailed">
{{svg-jar "send-email" class="stroke-midgrey"}}
</span>
{{#if this.isScheduled}}
<span data-tooltip="To be sent by email" class="gh-content-status-emailed scheduled">
{{svg-jar "send-email" class="stroke-green-d2"}}
</span>
{{else}}
<span data-tooltip="Sent by email" class="gh-content-status-emailed">
{{svg-jar "send-email" class="stroke-midgrey"}}
</span>
{{/if}}
{{/if}}
{{/if}}
{{/if}}

View File

@ -27,36 +27,36 @@
</div>
</div>
{{#if this.canSendEmail}}
<div class="gh-publishmenu-section">
<div class="gh-publishmenu-radio gh-publishmenu-email">
{{#if this.backgroundLoader.isRunning}}
<div class="gh-loading-spinner" style="zoom: 50%"></div>
{{else}}
<div class="gh-publishmenu-email-label {{if disableEmailOption "pe-none"}}">
<label class="gh-publishmenu-radio-label {{unless this.memberCount "midgrey"}}" for="email-when-published-checkbox">Send by email</label>
{{#if this.memberCount}}
<div class="gh-publishmenu-radio-desc">Deliver post to members</div>
{{else}}
<div class="gh-publishmenu-radio-desc">You haven't got any members</div>
{{/if}}
</div>
<div class="for-switch small {{if disableEmailOption "pe-none"}}">
<div class="switch container" for="email-when-published-checkbox">
<Input
@checked={{this.sendEmailWhenPublished}}
@type="checkbox"
@id="email-when-published-checkbox"
@name="email-when-published"
@disabled={{disableEmailOption}}
/>
<span class="input-toggle-component gh-publishmenu-email-checkbox"
{{on "click" (toggle "sendEmailWhenPublished" this)}}></span>
{{#if (and this.canSendEmail this.session.user.isOwnerOrAdmin)}}
<div class="gh-publishmenu-section">
<div class="gh-publishmenu-radio gh-publishmenu-email">
{{#if this.backgroundLoader.isRunning}}
<div class="gh-loading-spinner" style="zoom: 50%"></div>
{{else}}
<div class="gh-publishmenu-email-label {{if disableEmailOption "pe-none"}}">
<label class="gh-publishmenu-radio-label {{unless this.memberCount "midgrey"}}" for="email-when-published-checkbox">Send by email</label>
{{#if this.memberCount}}
<div class="gh-publishmenu-radio-desc">Deliver post to members</div>
{{else}}
<div class="gh-publishmenu-radio-desc">You haven't got any members</div>
{{/if}}
</div>
</div>
{{/if}}
<div class="for-switch small {{if disableEmailOption "pe-none"}}">
<div class="switch container" for="email-when-published-checkbox">
<Input
@checked={{this.sendEmailWhenPublished}}
@type="checkbox"
@id="email-when-published-checkbox"
@name="email-when-published"
@disabled={{disableEmailOption}}
/>
<span class="input-toggle-component gh-publishmenu-email-checkbox"
{{on "click" (toggle "sendEmailWhenPublished" this)}}></span>
</div>
</div>
{{/if}}
</div>
</div>
</div>
{{/if}}
</section>

View File

@ -26,31 +26,33 @@
</div>
</div>
</section>
{{#unless this.post.email}}
<section class="gh-publishmenu-section">
<div class="gh-publishmenu-radio gh-publishmenu-email">
{{#if this.backgroundLoader.isRunning}}
<div class="gh-loading-spinner" style="zoom: 50%"></div>
{{else}}
<div class="gh-publishmenu-email-label">
<label class="gh-publishmenu-radio-label pe-none midgrey"
for="email-when-published-checkbox">Send by email</label>
{{#if this.memberCount}}
<div class="gh-publishmenu-radio-desc">Deliver post to members</div>
{{#if this.session.user.isOwnerOrAdmin}}
{{#unless this.post.email}}
<section class="gh-publishmenu-section">
<div class="gh-publishmenu-radio gh-publishmenu-email">
{{#if this.backgroundLoader.isRunning}}
<div class="gh-loading-spinner" style="zoom: 50%"></div>
{{else}}
<div class="gh-publishmenu-radio-desc">You haven't got any members</div>
<div class="gh-publishmenu-email-label">
<label class="gh-publishmenu-radio-label pe-none midgrey"
for="email-when-published-checkbox">Send by email</label>
{{#if this.memberCount}}
<div class="gh-publishmenu-radio-desc">Deliver post to members</div>
{{else}}
<div class="gh-publishmenu-radio-desc">You haven't got any members</div>
{{/if}}
</div>
<div class="for-switch small pe-none">
<div class="switch container" for="email-when-published-checkbox">
<Input @checked={{post.sendEmailWhenPublished}} @type="checkbox" @id="email-when-published-checkbox"
@name="email-when-published" @disabled={{disableEmailOption}} />
<span class="input-toggle-component gh-publishmenu-email-checkbox"
{{on "click" (toggle "sendEmailWhenPublished" this)}}></span>
</div>
</div>
{{/if}}
</div>
<div class="for-switch small pe-none">
<div class="switch container" for="email-when-published-checkbox">
<Input @checked={{post.sendEmailWhenPublished}} @type="checkbox" @id="email-when-published-checkbox"
@name="email-when-published" @disabled={{disableEmailOption}} />
<span class="input-toggle-component gh-publishmenu-email-checkbox"
{{on "click" (toggle "sendEmailWhenPublished" this)}}></span>
</div>
</div>
{{/if}}
</div>
</section>
{{/unless}}
</section>
{{/unless}}
{{/if}}
</div>