summaryrefslogtreecommitdiffstats
path: root/web/react/components/setting_item_max.jsx
blob: 996b6387345d8cad9c3f65e808b820559d5f0a02 (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
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
// See License.txt for license information.

export default class SettingItemMax extends React.Component {
    render() {
        var clientError = null;
        if (this.props.client_error) {
            clientError = (<div className='form-group'><label className='col-sm-12 has-error'>{this.props.client_error}</label></div>);
        }

        var serverError = null;
        if (this.props.server_error) {
            serverError = (<div className='form-group'><label className='col-sm-12 has-error'>{this.props.server_error}</label></div>);
        }

        var extraInfo = null;
        if (this.props.extraInfo) {
            extraInfo = (<div className='setting-list__hint'>{this.props.extraInfo}</div>);
        }

        var submit = '';
        if (this.props.submit) {
            submit = (<a
                        className='btn btn-sm btn-primary'
                        href='#'
                        onClick={this.props.submit}>
                        Submit</a>);
        }

        var inputs = this.props.inputs;

        return (
            <ul className='section-max form-horizontal'>
                <li className='col-sm-12 section-title'>{this.props.title}</li>
                <li className='col-sm-9 col-sm-offset-3'>
                    <ul className='setting-list'>
                        <li className='setting-list-item'>
                            {inputs}
                            {extraInfo}
                        </li>
                        <li className='setting-list-item'>
                            <hr />
                            {serverError}
                            {clientError}
                            {submit}
                            <a
                                className='btn btn-sm theme'
                                href='#'
                                onClick={this.props.updateSection} >
                                Cancel
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>
        );
    }
}

SettingItemMax.propTypes = {
    inputs: React.PropTypes.array,
    client_error: React.PropTypes.string,
    server_error: React.PropTypes.string,
    extraInfo: React.PropTypes.element,
    updateSection: React.PropTypes.func,
    submit: React.PropTypes.func,
    title: React.PropTypes.string
};