summaryrefslogtreecommitdiffstats
path: root/web/react/components/user_settings/user_settings_developer.jsx
blob: 1dd564c8d4b19a3b2e0163f1e631180e92848f06 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import SettingItemMin from '../setting_item_min.jsx';
import SettingItemMax from '../setting_item_max.jsx';
import * as GlobalActions from '../../action_creators/global_actions.jsx';

import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'mm-intl';

const holders = defineMessages({
    applicationsPreview: {
        id: 'user.settings.developer.applicationsPreview',
        defaultMessage: 'Applications (Preview)'
    },
    thirdParty: {
        id: 'user.settings.developer.thirdParty',
        defaultMessage: 'Open to register a new third-party application'
    }
});

class DeveloperTab extends React.Component {
    constructor(props) {
        super(props);

        this.register = this.register.bind(this);

        this.state = {};
    }
    register() {
        this.props.closeModal();
        GlobalActions.showRegisterAppModal();
    }
    render() {
        var appSection;
        var self = this;
        const {formatMessage} = this.props.intl;
        if (this.props.activeSection === 'app') {
            var inputs = [];

            inputs.push(
                <div
                    key='registerbtn'
                    className='form-group'
                >
                    <div className='col-sm-7'>
                        <a
                            className='btn btn-sm btn-primary'
                            onClick={this.register}
                        >
                            <FormattedMessage
                                id='user.settings.developer.register'
                                defaultMessage='Register New Application'
                            />
                        </a>
                    </div>
                </div>
            );

            appSection = (
                <SettingItemMax
                    title={formatMessage(holders.applicationsPreview)}
                    inputs={inputs}
                    updateSection={function updateSection(e) {
                        self.props.updateSection('');
                        e.preventDefault();
                    }}
                />
            );
        } else {
            appSection = (
                <SettingItemMin
                    title={formatMessage(holders.applicationsPreview)}
                    describe={formatMessage(holders.thirdParty)}
                    updateSection={function updateSection() {
                        self.props.updateSection('app');
                    }}
                />
            );
        }

        return (
            <div>
                <div className='modal-header'>
                    <button
                        type='button'
                        className='close'
                        data-dismiss='modal'
                        aria-label='Close'
                        onClick={this.props.closeModal}
                    >
                        <span aria-hidden='true'>{'×'}</span>
                    </button>
                    <h4
                        className='modal-title'
                        ref='title'
                    >
                        <div className='modal-back'>
                            <i
                                className='fa fa-angle-left'
                                onClick={this.props.collapseModal}
                            />
                        </div>
                        <FormattedMessage
                            id='user.settings.developer.title'
                            defaultMessage='Developer Settings'
                        />
                    </h4>
                </div>
                <div className='user-settings'>
                    <h3 className='tab-header'>
                        <FormattedMessage
                            id='user.settings.developer.title'
                            defaultMessage='Developer Settings'
                        />
                    </h3>
                    <div className='divider-dark first'/>
                    {appSection}
                    <div className='divider-dark'/>
                </div>
            </div>
        );
    }
}

DeveloperTab.defaultProps = {
    activeSection: ''
};
DeveloperTab.propTypes = {
    intl: intlShape.isRequired,
    activeSection: React.PropTypes.string,
    updateSection: React.PropTypes.func,
    closeModal: React.PropTypes.func.isRequired,
    collapseModal: React.PropTypes.func.isRequired
};

export default injectIntl(DeveloperTab);