Remove the guestExperience setting
This commit is contained in:
parent
adf4789317
commit
89e0eef60f
|
@ -5,6 +5,7 @@ import { Route, Switch } from 'react-router-dom';
|
|||
import { render, screen, waitFor } from '../../../jest/test-helpers';
|
||||
import { normalizeAccount } from '../../../normalizers';
|
||||
import UI from '../index';
|
||||
import { WrappedRoute } from '../util/react_router_helpers';
|
||||
|
||||
const TestableComponent = () => (
|
||||
<Switch>
|
||||
|
@ -12,6 +13,9 @@ const TestableComponent = () => (
|
|||
<Route path='/@:username/media' exact><UI /></Route>
|
||||
<Route path='/@:username' exact><UI /></Route>
|
||||
<Route path='/login' exact><span data-testid='sign-in'>Sign in</span></Route>
|
||||
|
||||
{/* WrappedRount will redirect to /login for logged out users... which will resolve to the route above! */}
|
||||
<WrappedRoute path='/notifications' />
|
||||
</Switch>
|
||||
);
|
||||
|
||||
|
@ -33,11 +37,6 @@ describe('<UI />', () => {
|
|||
});
|
||||
|
||||
describe('when logged out', () => {
|
||||
describe('with guest experience disabled', () => {
|
||||
beforeEach(() => {
|
||||
store = { ...store, soapbox: ImmutableMap({ guestExperience: false }) };
|
||||
});
|
||||
|
||||
describe('when viewing a Profile Page', () => {
|
||||
it('should render the Profile page', async() => {
|
||||
render(
|
||||
|
@ -68,13 +67,13 @@ describe('<UI />', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('when viewing any other page', () => {
|
||||
describe('when viewing Notifications', () => {
|
||||
it('should redirect to the login page', async() => {
|
||||
render(
|
||||
<TestableComponent />,
|
||||
{},
|
||||
store,
|
||||
{ initialEntries: ['/@username/media'] },
|
||||
{ initialEntries: ['/notifications'] },
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
|
@ -83,5 +82,4 @@ describe('<UI />', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|||
import { HotKeys } from 'react-hotkeys';
|
||||
import { defineMessages, useIntl } from 'react-intl';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { Switch, useHistory, useLocation, matchPath, Redirect } from 'react-router-dom';
|
||||
import { Switch, useHistory, useLocation, Redirect } from 'react-router-dom';
|
||||
|
||||
import { fetchFollowRequests } from 'soapbox/actions/accounts';
|
||||
import { fetchReports, fetchUsers, fetchConfig } from 'soapbox/actions/admin';
|
||||
|
@ -34,7 +34,6 @@ import ProfilePage from 'soapbox/pages/profile_page';
|
|||
import RemoteInstancePage from 'soapbox/pages/remote_instance_page';
|
||||
import StatusPage from 'soapbox/pages/status_page';
|
||||
import { getAccessToken, getVapidKey } from 'soapbox/utils/auth';
|
||||
import { cacheCurrentUrl } from 'soapbox/utils/redirect';
|
||||
import { isStandalone } from 'soapbox/utils/state';
|
||||
// import GroupSidebarPanel from '../groups/sidebar_panel';
|
||||
|
||||
|
@ -329,7 +328,6 @@ const UI: React.FC = ({ children }) => {
|
|||
const intl = useIntl();
|
||||
const history = useHistory();
|
||||
const dispatch = useDispatch();
|
||||
const { guestExperience } = useSoapboxConfig();
|
||||
|
||||
const [draggingOver, setDraggingOver] = useState<boolean>(false);
|
||||
const [mobile, setMobile] = useState<boolean>(isMobile(window.innerWidth));
|
||||
|
@ -608,23 +606,6 @@ const UI: React.FC = ({ children }) => {
|
|||
// Wait for login to succeed or fail
|
||||
if (me === null) return null;
|
||||
|
||||
const isProfileOrStatusPage = !!matchPath(
|
||||
history.location.pathname,
|
||||
[
|
||||
'/@:username',
|
||||
'/@:username/posts/:statusId',
|
||||
'/users/:username',
|
||||
'/users/:username/statuses/:statusId',
|
||||
],
|
||||
);
|
||||
|
||||
// Require login if Guest Experience is disabled and we're not trying
|
||||
// to render a Profile or Status.
|
||||
if (!me && (!guestExperience && !isProfileOrStatusPage)) {
|
||||
cacheCurrentUrl(history.location);
|
||||
return <Redirect to='/login' />;
|
||||
}
|
||||
|
||||
type HotkeyHandlers = { [key: string]: (keyEvent?: KeyboardEvent) => void };
|
||||
|
||||
const handlers: HotkeyHandlers = {
|
||||
|
|
|
@ -115,7 +115,6 @@ export const SoapboxConfigRecord = ImmutableRecord({
|
|||
singleUserMode: false,
|
||||
singleUserModeProfile: '',
|
||||
linkFooterMessage: '',
|
||||
guestExperience: true,
|
||||
links: ImmutableMap<string, string>(),
|
||||
}, 'SoapboxConfig');
|
||||
|
||||
|
|
Loading…
Reference in New Issue