mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* Updating client dependancies. Switching to using yarn. * Updating React * Moving pure components to using function syntax (performance gains with newer react version) * Updating client dependancies. * Ignore .yarninstall * Enabling pre-lockfile because it's the entire point of using yarn. * Removing old webpack config * Moving to new prop-types * Fixing ESLint Errors * Updating jest snapshots. * Cleaning up package.json
70 lines
1.9 KiB
JavaScript
70 lines
1.9 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
import $ from 'jquery';
|
|
import * as UserAgent from 'utils/user_agent.jsx';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
|
|
|
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');
|
|
}
|
|
componentDidMount() {
|
|
if (UserAgent.isFirefox()) {
|
|
$('.settings-modal .settings-table .nav').addClass('position--top');
|
|
}
|
|
}
|
|
render() {
|
|
const tabList = this.props.tabs.map((tab) => {
|
|
const 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>
|
|
);
|
|
});
|
|
|
|
return (
|
|
<div>
|
|
<ul className='nav nav-pills nav-stacked'>
|
|
{tabList}
|
|
</ul>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
SettingsSidebar.propTypes = {
|
|
tabs: PropTypes.arrayOf(PropTypes.shape({
|
|
name: PropTypes.string.isRequired,
|
|
uiName: PropTypes.string.isRequired,
|
|
icon: PropTypes.string.isRequired
|
|
})).isRequired,
|
|
activeTab: PropTypes.string,
|
|
updateTab: PropTypes.func.isRequired
|
|
};
|