summaryrefslogtreecommitdiffstats
path: root/web/react/components/signup_team.jsx
blob: 1858703efb71e2a2b7985624415c167d1b8efa37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

const ChoosePage = require('./team_signup_choose_auth.jsx');
const EmailSignUpPage = require('./team_signup_with_email.jsx');
const SSOSignupPage = require('./team_signup_with_sso.jsx');
const Constants = require('../utils/constants.jsx');

export default class TeamSignUp extends React.Component {
    constructor(props) {
        super(props);

        this.updatePage = this.updatePage.bind(this);

        var count = 0;

        if (global.window.mm_config.EnableSignUpWithEmail === 'true') {
            count = count + 1;
        }

        if (global.window.mm_config.EnableSignUpWithGitLab === 'true') {
            count = count + 1;
        }

        if (count > 1) {
            this.state = {page: 'choose'};
        } else if (global.window.mm_config.EnableSignUpWithEmail === 'true') {
            this.state = {page: 'email'};
        } else if (global.window.mm_config.EnableSignUpWithGitLab === 'true') {
            this.state = {page: 'gitlab'};
        }
    }

    updatePage(page) {
        this.setState({page});
    }

    render() {
        if (this.state.page === 'choose') {
            return (
                <ChoosePage
                    updatePage={this.updatePage}
                />
            );
        }

        if (this.state.page === 'email') {
            return <EmailSignUpPage />;
        } else if (this.state.page === 'gitlab') {
            return <SSOSignupPage service={Constants.GITLAB_SERVICE} />;
        }
    }
}