diff --git a/ui/src/Signin.tsx b/ui/src/Signin.tsx index 91558ce562..4614039ac9 100644 --- a/ui/src/Signin.tsx +++ b/ui/src/Signin.tsx @@ -2,9 +2,6 @@ import React, {ReactElement, PureComponent} from 'react' import {withRouter, WithRouterProps} from 'react-router' -// APIs -import {trySources} from 'src/onboarding/apis' - // Components import {ErrorHandling} from 'src/shared/decorators/errors' import {getMe} from 'src/shared/apis/v2/user' @@ -14,7 +11,6 @@ import {RemoteDataState} from 'src/types' interface State { loading: RemoteDataState - isUserSignedIn: boolean } interface OwnProps { @@ -33,19 +29,13 @@ export class Signin extends PureComponent { this.state = { loading: RemoteDataState.NotStarted, - isUserSignedIn: false, } } public async componentDidMount() { - const isSourcesAllowed = await trySources() - const isUserSignedIn = isSourcesAllowed - this.setState({loading: RemoteDataState.Done, isUserSignedIn}) + this.setState({loading: RemoteDataState.Done}) this.checkForLogin() this.intervalID = setInterval(this.checkForLogin, FETCH_WAIT) - if (!isUserSignedIn) { - this.props.router.push('/signin') - } } public componentWillUnmount() { @@ -73,7 +63,6 @@ export class Signin extends PureComponent { await getMe() } catch (error) { clearInterval(this.intervalID) - this.setState({isUserSignedIn: false}) this.props.router.push('/signin') } } diff --git a/ui/src/index.tsx b/ui/src/index.tsx index 62f1dae174..ef3d6bc19d 100644 --- a/ui/src/index.tsx +++ b/ui/src/index.tsx @@ -75,6 +75,19 @@ window.addEventListener('keyup', event => { } }) +const MainLine = ({children}) => { + const {pathname} = window.location + if ( + pathname.includes('signin') || + pathname.includes('onboarding') || + pathname.includes('logout') + ) { + return null + } + + return children +} + class Root extends PureComponent { public render() { return ( @@ -91,43 +104,45 @@ class Root extends PureComponent { component={OnboardingWizardPage} /> - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/ui/src/onboarding/containers/SigninPage.tsx b/ui/src/onboarding/containers/SigninPage.tsx index e2c57fb1fb..7a7d4c5946 100644 --- a/ui/src/onboarding/containers/SigninPage.tsx +++ b/ui/src/onboarding/containers/SigninPage.tsx @@ -1,25 +1,54 @@ // Libraries import React, {PureComponent} from 'react' +import {withRouter, WithRouterProps} from 'react-router' import _ from 'lodash' +// apis +import {getSetupStatus} from 'src/onboarding/apis' + // Components import {ErrorHandling} from 'src/shared/decorators/errors' import SplashPage from 'src/shared/components/splash_page/SplashPage' import SigninForm from 'src/onboarding/components/SigninForm' +import {Spinner} from 'src/clockface' +import {RemoteDataState} from 'src/types' + +interface State { + status: RemoteDataState +} @ErrorHandling -class SigninPage extends PureComponent<{}> { +class SigninPage extends PureComponent { + constructor(props) { + super(props) + + this.state = { + status: RemoteDataState.Loading, + } + } + public async componentDidMount() { + const isSetupAllowed = await getSetupStatus() + + if (isSetupAllowed) { + this.props.router.push('/onboarding/0') + } + + this.setState({status: RemoteDataState.Done}) + } + public render() { return ( - - - - - - - + + + + + + + + + ) } } -export default SigninPage +export default withRouter(SigninPage)