summaryrefslogtreecommitdiffstats
path: root/webapp/components/admin_console/dropdown_setting.jsx
blob: fca8dd1709ef53a13ac5237639450a192c5641f4 (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
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import React from 'react';

import Setting from './setting.jsx';

export default class DropdownSetting extends React.Component {
    render() {
        const options = [];
        for (const {value, text} of this.props.values) {
            options.push(
                <option
                    value={value}
                    key={value}
                >
                    {text}
                </option>
            );
        }

        return (
            <Setting
                label={this.props.label}
                margin={this.props.margin}
            >
                <select
                    className='form-control'
                    value={this.props.currentValue}
                    onChange={this.props.handleChange}
                    disabled={this.props.isDisabled}
                >
                    {options}
                </select>
                {this.props.helpText}
            </Setting>
        );
    }
}
DropdownSetting.defaultProps = {
};

DropdownSetting.propTypes = {
    values: React.PropTypes.array.isRequired,
    label: React.PropTypes.node.isRequired,
    currentValue: React.PropTypes.string.isRequired,
    handleChange: React.PropTypes.func.isRequired,
    isDisabled: React.PropTypes.bool.isRequired,
    helpText: React.PropTypes.node.isRequired,
    margin: React.PropTypes.oneOf(['', 'small'])
};