diff --git a/CHANGELOG.md b/CHANGELOG.md index 974130e17..f511a0982 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added +- Admin: redirect the homepage to any URL. ### Changed ### Fixed +### Removed +- Admin: single user mode. Now the homepage can be redirected to any URL. + ## [3.1.0] - 2023-01-13 ### Added diff --git a/app/soapbox/containers/soapbox.tsx b/app/soapbox/containers/soapbox.tsx index b9603b3b1..6c94feb50 100644 --- a/app/soapbox/containers/soapbox.tsx +++ b/app/soapbox/containers/soapbox.tsx @@ -40,6 +40,7 @@ import { useTheme, useLocale, useInstance, + useRegistrationStatus, } from 'soapbox/hooks'; import MESSAGES from 'soapbox/locales/messages'; import { normalizeSoapboxConfig } from 'soapbox/normalizers'; @@ -92,13 +93,12 @@ const SoapboxMount = () => { const account = useOwnAccount(); const soapboxConfig = useSoapboxConfig(); const features = useFeatures(); + const { pepeEnabled } = useRegistrationStatus(); const waitlisted = account && !account.source.get('approved', true); const needsOnboarding = useAppSelector(state => state.onboarding.needsOnboarding); const showOnboarding = account && !waitlisted && needsOnboarding; - const singleUserMode = soapboxConfig.singleUserMode && soapboxConfig.singleUserModeProfile; - - const pepeEnabled = soapboxConfig.getIn(['extensions', 'pepe', 'enabled']) === true; + const { redirectRootNoLogin } = soapboxConfig; // @ts-ignore: I don't actually know what these should be, lol const shouldUpdateScroll = (prevRouterProps, { location }) => { @@ -134,8 +134,8 @@ const SoapboxMount = () => { /> )} - {!me && (singleUserMode - ? + {!me && (redirectRootNoLogin + ? : )} {!me && ( diff --git a/app/soapbox/features/auth-layout/index.tsx b/app/soapbox/features/auth-layout/index.tsx index 629bb3c9b..b792bc006 100644 --- a/app/soapbox/features/auth-layout/index.tsx +++ b/app/soapbox/features/auth-layout/index.tsx @@ -4,7 +4,7 @@ import { Link, Redirect, Route, Switch, useHistory, useLocation } from 'react-ro import LandingGradient from 'soapbox/components/landing-gradient'; import SiteLogo from 'soapbox/components/site-logo'; -import { useAppSelector, useFeatures, useSoapboxConfig, useOwnAccount, useInstance } from 'soapbox/hooks'; +import { useOwnAccount, useInstance, useRegistrationStatus } from 'soapbox/hooks'; import { Button, Card, CardBody } from '../../components/ui'; import LoginPage from '../auth-login/components/login-page'; @@ -28,14 +28,8 @@ const AuthLayout = () => { const account = useOwnAccount(); const instance = useInstance(); - const features = useFeatures(); - const soapboxConfig = useSoapboxConfig(); - - const pepeEnabled = soapboxConfig.getIn(['extensions', 'pepe', 'enabled']) === true; - const isOpen = features.accountCreation && instance.registrations; - const pepeOpen = useAppSelector(state => state.verification.instance.get('registrations') === true); + const { isOpen } = useRegistrationStatus(); const isLoginPage = history.location.pathname === '/login'; - const shouldShowRegisterLink = (isLoginPage && (isOpen || (pepeEnabled && pepeOpen))); return (
@@ -50,7 +44,7 @@ const AuthLayout = () => {
- {shouldShowRegisterLink && ( + {(isLoginPage && isOpen) && (
- {(isOpen || pepeEnabled && pepeOpen) && ( + {isOpen && ( - {(isOpen || pepeEnabled && pepeOpen) && ( + {isOpen && ( diff --git a/app/soapbox/features/ui/components/modals/unauthorized-modal.tsx b/app/soapbox/features/ui/components/modals/unauthorized-modal.tsx index 9a7906e87..66d757935 100644 --- a/app/soapbox/features/ui/components/modals/unauthorized-modal.tsx +++ b/app/soapbox/features/ui/components/modals/unauthorized-modal.tsx @@ -4,7 +4,7 @@ import { useHistory } from 'react-router-dom'; import { remoteInteraction } from 'soapbox/actions/interactions'; import { Button, Modal, Stack, Text } from 'soapbox/components/ui'; -import { useAppSelector, useAppDispatch, useFeatures, useSoapboxConfig, useInstance } from 'soapbox/hooks'; +import { useAppSelector, useAppDispatch, useFeatures, useInstance, useRegistrationStatus } from 'soapbox/hooks'; import toast from 'soapbox/toast'; const messages = defineMessages({ @@ -30,8 +30,8 @@ const UnauthorizedModal: React.FC = ({ action, onClose, acco const history = useHistory(); const dispatch = useAppDispatch(); const instance = useInstance(); + const { isOpen } = useRegistrationStatus(); - const { singleUserMode } = useSoapboxConfig(); const username = useAppSelector(state => state.accounts.get(accountId)?.display_name); const features = useFeatures(); @@ -98,10 +98,10 @@ const UnauthorizedModal: React.FC = ({ action, onClose, acco } - secondaryAction={onRegister} - secondaryText={} + secondaryAction={isOpen ? onRegister : undefined} + secondaryText={isOpen ? : undefined} >
@@ -122,7 +122,7 @@ const UnauthorizedModal: React.FC = ({ action, onClose, acco
- {!singleUserMode && ( + {isOpen && ( @@ -142,8 +142,8 @@ const UnauthorizedModal: React.FC = ({ action, onClose, acco onClose={onClickClose} confirmationAction={onLogin} confirmationText={} - secondaryAction={onRegister} - secondaryText={} + secondaryAction={isOpen ? onRegister : undefined} + secondaryText={isOpen ? : undefined} > diff --git a/app/soapbox/features/ui/components/navbar.tsx b/app/soapbox/features/ui/components/navbar.tsx index d9829afca..dc8896e33 100644 --- a/app/soapbox/features/ui/components/navbar.tsx +++ b/app/soapbox/features/ui/components/navbar.tsx @@ -9,7 +9,7 @@ import { openSidebar } from 'soapbox/actions/sidebar'; import SiteLogo from 'soapbox/components/site-logo'; import { Avatar, Button, Form, HStack, IconButton, Input, Tooltip } from 'soapbox/components/ui'; import Search from 'soapbox/features/compose/components/search'; -import { useAppDispatch, useOwnAccount, useSoapboxConfig } from 'soapbox/hooks'; +import { useAppDispatch, useOwnAccount, useRegistrationStatus } from 'soapbox/hooks'; import ProfileDropdown from './profile-dropdown'; @@ -25,12 +25,9 @@ const messages = defineMessages({ const Navbar = () => { const dispatch = useAppDispatch(); const intl = useIntl(); - - const node = useRef(null); - + const { isOpen } = useRegistrationStatus(); const account = useOwnAccount(); - const soapboxConfig = useSoapboxConfig(); - const singleUserMode = soapboxConfig.get('singleUserMode'); + const node = useRef(null); const [isLoading, setLoading] = useState(false); const [username, setUsername] = useState(''); @@ -66,7 +63,7 @@ const Navbar = () => { if (mfaToken) return ; return ( -