Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BASH-18 Add configs to show/hide server management and multiteam settings #600

Merged
merged 1 commit into from
Nov 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
142 changes: 78 additions & 64 deletions src/browser/components/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,41 @@ const SettingsPage = createReactClass({
},

render() {
const settingsPage = {
navbar: {
backgroundColor: '#fff'
},
close: {
textDecoration: 'none',
position: 'absolute',
right: '0',
top: '5px',
fontSize: '35px',
fontWeight: 'normal',
color: '#bbb'
},
heading: {
textAlign: 'center',
fontSize: '24px',
margin: '0',
padding: '1em 0'
},
sectionHeading: {
fontSize: '20px',
margin: '0',
padding: '1em 0',
float: 'left'
},
sectionHeadingLink: {
marginTop: '24px',
display: 'inline-block',
fontSize: '15px'
},
footer: {
padding: '0.4em 0'
}
};

var teamsRow = (
<Row>
<Col md={12}>
Expand All @@ -267,11 +302,53 @@ const SettingsPage = createReactClass({
updateTeam={this.updateTeam}
addServer={this.addServer}
onTeamClick={backToIndex}
allowTeamEdit={this.state.enableTeamModification}
/>
</Col>
</Row>
);

var serversRow = (
<Row>
<Col
md={10}
xs={8}
>
<h2 style={settingsPage.sectionHeading}>{'Server Management'}</h2>
<div className='IndicatorContainer'>
<AutoSaveIndicator
savingState={this.state.savingState.servers}
errorMessage={'Can\'t save your changes. Please try again.'}
/>
</div>
</Col>
<Col
md={2}
xs={4}
>
<p className='text-right'>
<a
style={settingsPage.sectionHeadingLink}
id='addNewServer'
href='#'
onClick={this.toggleShowTeamForm}
>{'⊞ Add new server'}</a>
</p>
</Col>
</Row>
);

var srvMgmt;
if (this.state.enableServerManagement || this.state.teams.length === 0) {
srvMgmt = (
<div>
{serversRow}
{teamsRow}
<hr/>
</div>
);
}

var options = [];

// MacOS has an option in the Dock, to set the app to autostart, so we choose to not support this option for OSX
Expand Down Expand Up @@ -404,41 +481,6 @@ const SettingsPage = createReactClass({
</Checkbox>);
}

const settingsPage = {
navbar: {
backgroundColor: '#fff'
},
close: {
textDecoration: 'none',
position: 'absolute',
right: '0',
top: '5px',
fontSize: '35px',
fontWeight: 'normal',
color: '#bbb'
},
heading: {
textAlign: 'center',
fontSize: '24px',
margin: '0',
padding: '1em 0'
},
sectionHeading: {
fontSize: '20px',
margin: '0',
padding: '1em 0',
float: 'left'
},
sectionHeadingLink: {
marginTop: '24px',
display: 'inline-block',
fontSize: '15px'
},
footer: {
padding: '0.4em 0'
}
};

var optionsRow = (options.length > 0) ? (
<Row>
<Col md={12}>
Expand Down Expand Up @@ -482,35 +524,7 @@ const SettingsPage = createReactClass({
className='settingsPage'
style={{paddingTop: '100px'}}
>
<Row>
<Col
md={10}
xs={8}
>
<h2 style={settingsPage.sectionHeading}>{'Server Management'}</h2>
<div className='IndicatorContainer'>
<AutoSaveIndicator
savingState={this.state.savingState.servers}
errorMessage={'Can\'t save your changes. Please try again.'}
/>
</div>
</Col>
<Col
md={2}
xs={4}
>
<p className='text-right'>
<a
style={settingsPage.sectionHeadingLink}
id='addNewServer'
href='#'
onClick={this.toggleShowTeamForm}
>{'⊞ Add new server'}</a>
</p>
</Col>
</Row>
{ teamsRow }
<hr/>
{ srvMgmt }
{ optionsRow }
</Grid>
</div>
Expand Down
27 changes: 15 additions & 12 deletions src/browser/components/TabBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,19 @@ function TabBar(props) {
{ badgeDiv }
</NavItem>);
});
tabs.push(
<NavItem
className='TabBar-addServerButton'
key='addServerButton'
id='addServerButton'
eventKey='addServerButton'
title='Add new server'
>
<Glyphicon glyph='plus'/>
</NavItem>
);
if (props.showAddServerButton === true) {
tabs.push(
<NavItem
className='TabBar-addServerButton'
key='addServerButton'
id='addServerButton'
eventKey='addServerButton'
title='Add new server'
>
<Glyphicon glyph='plus'/>
</NavItem>
);
}
return (
<Nav
className='TabBar'
Expand Down Expand Up @@ -92,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.enableServerManagement}
/>,
document.getElementById('content')
);
Expand Down
6 changes: 4 additions & 2 deletions src/common/config/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"showUnreadBadge": true,
"useSpellChecker": true,
"spellCheckerLocale": "en-US",
"helpLink": "https://docs.mattermost.com/help/apps/desktop-guide.html"
"helpLink": "https://docs.mattermost.com/help/apps/desktop-guide.html",
"enableServerManagement": true
},
"1": {
"teams": [],
Expand All @@ -25,6 +26,7 @@
"showUnreadBadge": true,
"useSpellChecker": true,
"spellCheckerLocale": "en-US",
"helpLink": "https://docs.mattermost.com/help/apps/desktop-guide.html"
"helpLink": "https://docs.mattermost.com/help/apps/desktop-guide.html",
"enableServerManagement": true
}
}
53 changes: 28 additions & 25 deletions src/main/menus/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function createTemplate(mainWindow, config, isDev) {
var firstMenuName = (process.platform === 'darwin') ? appName : 'File';
var template = [];

const platformAppMenu = process.platform === 'darwin' ? [{
var platformAppMenu = process.platform === 'darwin' ? [{
label: 'About ' + appName,
role: 'about',
click() {
Expand All @@ -30,38 +30,41 @@ function createTemplate(mainWindow, config, isDev) {
click() {
mainWindow.loadURL(settingsURL);
}
}, {
label: 'Sign in to Another Server',
click() {
mainWindow.webContents.send('add-server');
}
}, separatorItem, {
role: 'hide'
}, {
role: 'hideothers'
}, {
role: 'unhide'
}, separatorItem, {
role: 'quit'
}] : [{
label: 'Settings...',
accelerator: 'CmdOrCtrl+,',
click() {
mainWindow.loadURL(settingsURL);
}
}, {
label: 'Sign in to Another Server',
click() {
mainWindow.webContents.send('add-server');
}
}, separatorItem, {
role: 'quit',
accelerator: 'CmdOrCtrl+Q',
click() {
electron.app.quit();
}
}];

if (config.enableServerManagement === true || config.teams.length === 0) {
platformAppMenu.push({
label: 'Sign in to Another Server',
click() {
mainWindow.webContents.send('add-server');
}
});
}

platformAppMenu = platformAppMenu.concat(process.platform === 'darwin' ? [
separatorItem, {
role: 'hide'
}, {
role: 'hideothers'
}, {
role: 'unhide'
}, separatorItem, {
role: 'quit'
}] : [separatorItem, {
role: 'quit',
accelerator: 'CmdOrCtrl+Q',
click() {
electron.app.quit();
}
}]
);

template.push({
label: '&' + firstMenuName,
submenu: [
Expand Down