🐛 Fixed newsletter button not hidden in Portal (#20732)
ref ONC-225 - Wires up the `editor_default_email_recipients` key to the settings public / content api endpoint. - This key is then wired up to Portal to determine whether it's hiding or showing the Member subscribe toggle
This commit is contained in:
parent
b629dc02ac
commit
da691bf0d7
@ -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();
|
||||
});
|
||||
});
|
||||
|
@ -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 (
|
||||
<div>
|
||||
<div className='gh-portal-list'>
|
||||
@ -40,7 +42,13 @@ const AccountActions = () => {
|
||||
{
|
||||
showEmailPreferences
|
||||
? <EmailPreferencesAction />
|
||||
: <EmailNewsletterAction />
|
||||
: <></>
|
||||
}
|
||||
|
||||
{
|
||||
showEmailUnsubscribe && !showEmailPreferences
|
||||
? <EmailNewsletterAction />
|
||||
: <></>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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'
|
||||
};
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user