diff --git a/apps/portal/src/components/pages/AccountHomePage/AccountHomePage.test.js b/apps/portal/src/components/pages/AccountHomePage/AccountHomePage.test.js
index ac6679bf47..6b4c6aa143 100644
--- a/apps/portal/src/components/pages/AccountHomePage/AccountHomePage.test.js
+++ b/apps/portal/src/components/pages/AccountHomePage/AccountHomePage.test.js
@@ -48,4 +48,11 @@ describe('Account Home Page', () => {
fireEvent.click(manageBtn);
expect(mockOnActionFn).toHaveBeenCalledWith('switchPage', {lastPage: 'accountHome', page: 'accountEmail'});
});
+
+ test('hides Newsletter toggle if newsletters are disabled', () => {
+ const siteData = getSiteData({editorDefaultEmailRecipients: 'disabled'});
+ const {logoutBtn, utils} = setup({site: siteData});
+ expect(logoutBtn).toBeInTheDocument();
+ expect(utils.queryByText('Email newsletter')).not.toBeInTheDocument();
+ });
});
diff --git a/apps/portal/src/components/pages/AccountHomePage/components/AccountActions.js b/apps/portal/src/components/pages/AccountHomePage/components/AccountActions.js
index 6a0a03402f..f243f431ae 100644
--- a/apps/portal/src/components/pages/AccountHomePage/components/AccountActions.js
+++ b/apps/portal/src/components/pages/AccountHomePage/components/AccountActions.js
@@ -1,6 +1,6 @@
import AppContext from '../../../../AppContext';
import {useContext} from 'react';
-import {hasCommentsEnabled, hasMultipleNewsletters, isEmailSuppressed} from '../../../../utils/helpers';
+import {hasCommentsEnabled, hasMultipleNewsletters, isEmailSuppressed, hasNewsletterSendingEnabled} from '../../../../utils/helpers';
import PaidAccountActions from './PaidAccountActions';
import EmailNewsletterAction from './EmailNewsletterAction';
@@ -19,6 +19,8 @@ const AccountActions = () => {
const showEmailPreferences = hasMultipleNewsletters({site}) || hasCommentsEnabled({site}) || isEmailSuppressed({member});
+ const showEmailUnsubscribe = hasNewsletterSendingEnabled({site});
+
return (
@@ -40,7 +42,13 @@ const AccountActions = () => {
{
showEmailPreferences
?
- :
+ : <>>
+ }
+
+ {
+ showEmailUnsubscribe && !showEmailPreferences
+ ?
+ : <>>
}
diff --git a/apps/portal/src/utils/fixtures-generator.js b/apps/portal/src/utils/fixtures-generator.js
index 4fda8d6de3..74adfd1369 100644
--- a/apps/portal/src/utils/fixtures-generator.js
+++ b/apps/portal/src/utils/fixtures-generator.js
@@ -39,6 +39,7 @@ export function getSiteData({
portalButtonSignupText: portal_button_signup_text = 'Subscribe now',
portalButtonStyle: portal_button_style = 'icon-and-text',
membersSupportAddress: members_support_address = 'support@example.com',
+ editorDefaultEmailRecipients: editor_default_email_recipients = 'visibility',
newsletters = [],
commentsEnabled,
recommendations = [],
@@ -69,7 +70,8 @@ export function getSiteData({
comments_enabled: commentsEnabled !== 'off',
newsletters,
recommendations,
- recommendations_enabled: !!recommendationsEnabled
+ recommendations_enabled: !!recommendationsEnabled,
+ editor_default_email_recipients
};
}
diff --git a/apps/portal/src/utils/helpers.js b/apps/portal/src/utils/helpers.js
index 0b45f80893..c178c4c11a 100644
--- a/apps/portal/src/utils/helpers.js
+++ b/apps/portal/src/utils/helpers.js
@@ -86,6 +86,10 @@ export function getNewsletterFromUuid({site, uuid}) {
});
}
+export function hasNewsletterSendingEnabled({site}) {
+ return site?.editor_default_email_recipients === 'visibility';
+}
+
export function allowCompMemberUpgrade({member}) {
return member?.subscriptions?.[0]?.tier?.expiry_at !== undefined;
}
diff --git a/ghost/core/core/shared/settings-cache/public.js b/ghost/core/core/shared/settings-cache/public.js
index fde8a8667e..30fe80f346 100644
--- a/ghost/core/core/shared/settings-cache/public.js
+++ b/ghost/core/core/shared/settings-cache/public.js
@@ -45,5 +45,6 @@ module.exports = {
recommendations_enabled: 'recommendations_enabled',
outbound_link_tagging: 'outbound_link_tagging',
default_email_address: 'default_email_address',
- support_email_address: 'support_email_address'
+ support_email_address: 'support_email_address',
+ editor_default_email_recipients: 'editor_default_email_recipients'
};
diff --git a/ghost/core/test/e2e-api/content/__snapshots__/settings.test.js.snap b/ghost/core/test/e2e-api/content/__snapshots__/settings.test.js.snap
index a103edbdab..c61c0a5f86 100644
--- a/ghost/core/test/e2e-api/content/__snapshots__/settings.test.js.snap
+++ b/ghost/core/test/e2e-api/content/__snapshots__/settings.test.js.snap
@@ -12,6 +12,7 @@ Object {
"cover_image": "https://static.ghost.org/v5.0.0/images/publication-cover.jpg",
"default_email_address": "noreply@127.0.0.1",
"description": "Thoughts, stories and ideas",
+ "editor_default_email_recipients": "visibility",
"facebook": "ghost",
"firstpromoter_account": null,
"icon": null,
diff --git a/ghost/core/test/e2e-api/shared/__snapshots__/version.test.js.snap b/ghost/core/test/e2e-api/shared/__snapshots__/version.test.js.snap
index 2e9ea09beb..d2d688d07a 100644
--- a/ghost/core/test/e2e-api/shared/__snapshots__/version.test.js.snap
+++ b/ghost/core/test/e2e-api/shared/__snapshots__/version.test.js.snap
@@ -1364,6 +1364,7 @@ Object {
"cover_image": "https://static.ghost.org/v5.0.0/images/publication-cover.jpg",
"default_email_address": "noreply@127.0.0.1",
"description": "Thoughts, stories and ideas",
+ "editor_default_email_recipients": "visibility",
"facebook": "ghost",
"firstpromoter_account": null,
"icon": null,
@@ -1466,6 +1467,7 @@ Object {
"cover_image": "https://static.ghost.org/v5.0.0/images/publication-cover.jpg",
"default_email_address": "noreply@127.0.0.1",
"description": "Thoughts, stories and ideas",
+ "editor_default_email_recipients": "visibility",
"facebook": "ghost",
"firstpromoter_account": null,
"icon": null,