Make CtaBanner and ThreadLoginCta optional
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
26a0c567bc
commit
1343928406
4 changed files with 15 additions and 3 deletions
|
@ -48,6 +48,7 @@ const messages = defineMessages({
|
||||||
promoPanelIconsLink: { id: 'soapbox_config.hints.promo_panel_icons.link', defaultMessage: 'Soapbox Icons List' },
|
promoPanelIconsLink: { id: 'soapbox_config.hints.promo_panel_icons.link', defaultMessage: 'Soapbox Icons List' },
|
||||||
authenticatedProfileLabel: { id: 'soapbox_config.authenticated_profile_label', defaultMessage: 'Profiles require authentication' },
|
authenticatedProfileLabel: { id: 'soapbox_config.authenticated_profile_label', defaultMessage: 'Profiles require authentication' },
|
||||||
authenticatedProfileHint: { id: 'soapbox_config.authenticated_profile_hint', defaultMessage: 'Users must be logged-in to view replies and media on user profiles.' },
|
authenticatedProfileHint: { id: 'soapbox_config.authenticated_profile_hint', defaultMessage: 'Users must be logged-in to view replies and media on user profiles.' },
|
||||||
|
displayCtaLabel: { id: 'soapbox_config.cta_label', defaultMessage: 'Display call to action panels if not authenticated' },
|
||||||
singleUserModeLabel: { id: 'soapbox_config.single_user_mode_label', defaultMessage: 'Single user mode' },
|
singleUserModeLabel: { id: 'soapbox_config.single_user_mode_label', defaultMessage: 'Single user mode' },
|
||||||
singleUserModeHint: { id: 'soapbox_config.single_user_mode_hint', defaultMessage: 'Front page will redirect to a given user profile.' },
|
singleUserModeHint: { id: 'soapbox_config.single_user_mode_hint', defaultMessage: 'Front page will redirect to a given user profile.' },
|
||||||
singleUserModeProfileLabel: { id: 'soapbox_config.single_user_mode_profile_label', defaultMessage: 'Main user handle' },
|
singleUserModeProfileLabel: { id: 'soapbox_config.single_user_mode_profile_label', defaultMessage: 'Main user handle' },
|
||||||
|
@ -261,6 +262,13 @@ const SoapboxConfig: React.FC = () => {
|
||||||
/>
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|
||||||
|
<ListItem label={intl.formatMessage(messages.displayCtaLabel)}>
|
||||||
|
<Toggle
|
||||||
|
checked={soapbox.displayCta === true}
|
||||||
|
onChange={handleChange(['displayCta'], (e) => e.target.checked)}
|
||||||
|
/>
|
||||||
|
</ListItem>
|
||||||
|
|
||||||
<ListItem
|
<ListItem
|
||||||
label={intl.formatMessage(messages.authenticatedProfileLabel)}
|
label={intl.formatMessage(messages.authenticatedProfileLabel)}
|
||||||
hint={intl.formatMessage(messages.authenticatedProfileHint)}
|
hint={intl.formatMessage(messages.authenticatedProfileHint)}
|
||||||
|
|
|
@ -2,12 +2,15 @@ import React from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
import { Card, CardTitle, Text, Stack, Button } from 'soapbox/components/ui';
|
import { Card, CardTitle, Text, Stack, Button } from 'soapbox/components/ui';
|
||||||
import { useAppSelector } from 'soapbox/hooks';
|
import { useAppSelector, useSoapboxConfig } from 'soapbox/hooks';
|
||||||
|
|
||||||
/** Prompts logged-out users to log in when viewing a thread. */
|
/** Prompts logged-out users to log in when viewing a thread. */
|
||||||
const ThreadLoginCta: React.FC = () => {
|
const ThreadLoginCta: React.FC = () => {
|
||||||
|
const { displayCta } = useSoapboxConfig();
|
||||||
const siteTitle = useAppSelector(state => state.instance.title);
|
const siteTitle = useAppSelector(state => state.instance.title);
|
||||||
|
|
||||||
|
if (!displayCta) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className='px-6 py-12 space-y-6 text-center' variant='rounded'>
|
<Card className='px-6 py-12 space-y-6 text-center' variant='rounded'>
|
||||||
<Stack>
|
<Stack>
|
||||||
|
|
|
@ -5,11 +5,11 @@ import { Banner, Button, HStack, Stack, Text } from 'soapbox/components/ui';
|
||||||
import { useAppSelector, useSoapboxConfig } from 'soapbox/hooks';
|
import { useAppSelector, useSoapboxConfig } from 'soapbox/hooks';
|
||||||
|
|
||||||
const CtaBanner = () => {
|
const CtaBanner = () => {
|
||||||
const { singleUserMode } = useSoapboxConfig();
|
const { displayCta, singleUserMode } = useSoapboxConfig();
|
||||||
const siteTitle = useAppSelector((state) => state.instance.title);
|
const siteTitle = useAppSelector((state) => state.instance.title);
|
||||||
const me = useAppSelector((state) => state.me);
|
const me = useAppSelector((state) => state.me);
|
||||||
|
|
||||||
if (me || singleUserMode) return null;
|
if (me || !displayCta || singleUserMode) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div data-testid='cta-banner' className='hidden lg:block'>
|
<div data-testid='cta-banner' className='hidden lg:block'>
|
||||||
|
|
|
@ -112,6 +112,7 @@ export const SoapboxConfigRecord = ImmutableRecord({
|
||||||
singleUserModeProfile: '',
|
singleUserModeProfile: '',
|
||||||
linkFooterMessage: '',
|
linkFooterMessage: '',
|
||||||
links: ImmutableMap<string, string>(),
|
links: ImmutableMap<string, string>(),
|
||||||
|
displayCta: true,
|
||||||
}, 'SoapboxConfig');
|
}, 'SoapboxConfig');
|
||||||
|
|
||||||
type SoapboxConfigMap = ImmutableMap<string, any>;
|
type SoapboxConfigMap = ImmutableMap<string, any>;
|
||||||
|
|
Loading…
Reference in a new issue