blob: 66568e1c866dfad053d37a7e356ed709a5e962bc (
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
|
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
export default class SettingsSidebar extends React.Component {
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick(tab, e) {
e.preventDefault();
this.props.updateTab(tab.name);
$(e.target).closest('.settings-modal').addClass('display--content');
}
render() {
let tabList = this.props.tabs.map(function makeTab(tab) {
let key = `${tab.name}_li`;
let className = '';
if (this.props.activeTab === tab.name) {
className = 'active';
}
return (
<li
key={key}
className={className}
>
<a
href='#'
onClick={this.handleClick.bind(null, tab)}
>
<i className={tab.icon} />
{tab.uiName}
</a>
</li>
);
}.bind(this));
return (
<div>
<ul className='nav nav-pills nav-stacked'>
{tabList}
</ul>
</div>
);
}
}
SettingsSidebar.propTypes = {
tabs: React.PropTypes.arrayOf(React.PropTypes.shape({
name: React.PropTypes.string.isRequired,
uiName: React.PropTypes.string.isRequired,
icon: React.PropTypes.string.isRequired
})).isRequired,
activeTab: React.PropTypes.string,
updateTab: React.PropTypes.func.isRequired
};
|