Skip to content

Commit

Permalink
Clean up code and keep TabBar.jsx stateless
Browse files Browse the repository at this point in the history
  • Loading branch information
David Meza committed Oct 25, 2017
1 parent 241839e commit 4209e58
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/browser/components/MainPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const MainPage = createReactClass({
initialIndex: PropTypes.number.isRequired,
useSpellChecker: PropTypes.bool.isRequired,
onSelectSpellCheckerLocale: PropTypes.func.isRequired,
deeplinkingUrl: PropTypes.string
deeplinkingUrl: PropTypes.string,
showAddServerButton: PropTypes.bool.isRequired
},

getInitialState() {
Expand Down Expand Up @@ -258,6 +259,7 @@ const MainPage = createReactClass({
activeKey={this.state.key}
onSelect={this.handleSelect}
onAddServer={this.addServer}
showAddServerButton={this.props.showAddServerButton}
/>
</Row>
);
Expand Down
3 changes: 1 addition & 2 deletions src/browser/components/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,7 @@ const SettingsPage = createReactClass({
</Checkbox>);
}

var shouldShowDarwinTray = this.state.allowDarwinIconTray && process.platform === 'darwin';
if (process.platform === 'linux' || shouldShowDarwinTray) {
if (process.platform === 'darwin' || process.platform === 'linux') {
options.push(
<Checkbox
key='inputShowTrayIcon'
Expand Down
7 changes: 3 additions & 4 deletions src/browser/components/TabBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ const React = require('react');
const PropTypes = require('prop-types');
const {Glyphicon, Nav, NavItem} = require('react-bootstrap');

const AppConfig = require('../config/AppConfig.js');

function TabBar(props) {
const tabs = props.teams.map((team, index) => {
let unreadCount = 0;
Expand Down Expand Up @@ -55,7 +53,7 @@ function TabBar(props) {
{ badgeDiv }
</NavItem>);
});
if (AppConfig.data.enableMultiTeams === true) {
if (props.showAddServerButton === true) {
tabs.push(
<NavItem
className='TabBar-addServerButton'
Expand Down Expand Up @@ -96,7 +94,8 @@ TabBar.propTypes = {
unreadAtActive: PropTypes.array,
mentionCounts: PropTypes.array,
mentionAtActiveCounts: PropTypes.array,
onAddServer: PropTypes.func
onAddServer: PropTypes.func,
showAddServerButton: PropTypes.bool
};

module.exports = TabBar;
1 change: 1 addition & 0 deletions src/browser/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ ReactDOM.render(
useSpellChecker={AppConfig.data.useSpellChecker}
onSelectSpellCheckerLocale={handleSelectSpellCheckerLocale}
deeplinkingUrl={deeplinkingUrl}
showAddServerButton={AppConfig.data.enableMultiTeams}
/>,
document.getElementById('content')
);
Expand Down
6 changes: 2 additions & 4 deletions src/common/config/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"spellCheckerLocale": "en-US",
"helpLink": "https://docs.mattermost.com/help/apps/desktop-guide.html",
"enableMultiTeams": true,
"enableServerManagement": true,
"allowDarwinIconTray": true
"enableServerManagement": true
},
"1": {
"teams": [],
Expand All @@ -30,7 +29,6 @@
"spellCheckerLocale": "en-US",
"helpLink": "https://docs.mattermost.com/help/apps/desktop-guide.html",
"enableMultiTeams": true,
"enableServerManagement": true,
"allowDarwinIconTray": true
"enableServerManagement": true
}
}

0 comments on commit 4209e58

Please sign in to comment.