Move enableServerManagement key from defaultPreferences to buildConfig

This commit is contained in:
Yuya Ochiai 2017-11-07 22:06:42 +09:00
parent 51e6d5f039
commit 4abd72856f
6 changed files with 14 additions and 8 deletions

View file

@ -30,7 +30,8 @@ const CONFIG_TYPE_APP_OPTIONS = 'appOptions';
const SettingsPage = createReactClass({ const SettingsPage = createReactClass({
propTypes: { propTypes: {
configFile: PropTypes.string configFile: PropTypes.string,
enableServerManagement: PropTypes.bool
}, },
getInitialState() { getInitialState() {
@ -342,7 +343,7 @@ const SettingsPage = createReactClass({
); );
var srvMgmt; var srvMgmt;
if (this.state.enableServerManagement || this.state.teams.length === 0) { if (this.props.enableServerManagement || this.state.teams.length === 0) {
srvMgmt = ( srvMgmt = (
<div> <div>
{serversRow} {serversRow}

View file

@ -169,7 +169,7 @@ ReactDOM.render(
useSpellChecker={AppConfig.data.useSpellChecker} useSpellChecker={AppConfig.data.useSpellChecker}
onSelectSpellCheckerLocale={handleSelectSpellCheckerLocale} onSelectSpellCheckerLocale={handleSelectSpellCheckerLocale}
deeplinkingUrl={deeplinkingUrl} deeplinkingUrl={deeplinkingUrl}
showAddServerButton={AppConfig.data.enableServerManagement} showAddServerButton={buildConfig.enableServerManagement}
requestingPermission={requestingPermission} requestingPermission={requestingPermission}
onClickPermissionDialog={handleClickPermissionDialog} onClickPermissionDialog={handleClickPermissionDialog}
/>, />,

View file

@ -9,13 +9,17 @@ const React = require('react');
const ReactDOM = require('react-dom'); const ReactDOM = require('react-dom');
const SettingsPage = require('./components/SettingsPage.jsx'); const SettingsPage = require('./components/SettingsPage.jsx');
const contextMenu = require('./js/contextMenu'); const contextMenu = require('./js/contextMenu');
const buildConfig = require('../common/config/buildConfig');
const configFile = remote.app.getPath('userData') + '/config.json'; const configFile = remote.app.getPath('userData') + '/config.json';
contextMenu.setup(remote.getCurrentWindow()); contextMenu.setup(remote.getCurrentWindow());
ReactDOM.render( ReactDOM.render(
<SettingsPage configFile={configFile}/>, <SettingsPage
configFile={configFile}
enableServerManagement={buildConfig.enableServerManagement}
/>,
document.getElementById('content') document.getElementById('content')
); );

View file

@ -5,6 +5,7 @@
* @prop {string} defaultTeams[].url - The URL for default team. * @prop {string} defaultTeams[].url - The URL for default team.
* @prop {string} helpLink - The URL for "Help->Learn More..." menu item. * @prop {string} helpLink - The URL for "Help->Learn More..." menu item.
* If null is specified, the menu disappears. * If null is specified, the menu disappears.
* @prop {boolean} enableServerManagement - Whether users can edit servers configuration.
*/ */
const buildConfig = { const buildConfig = {
defaultTeams: [/* defaultTeams: [/*
@ -13,7 +14,8 @@ const buildConfig = {
url: 'https://example.com' url: 'https://example.com'
}*/ }*/
], ],
helpLink: 'https://docs.mattermost.com/help/apps/desktop-guide.html' helpLink: 'https://docs.mattermost.com/help/apps/desktop-guide.html',
enableServerManagement: true
}; };
module.exports = buildConfig; module.exports = buildConfig;

View file

@ -13,8 +13,7 @@ const defaultPreferences = {
}, },
showUnreadBadge: true, showUnreadBadge: true,
useSpellChecker: true, useSpellChecker: true,
spellCheckerLocale: 'en-US', spellCheckerLocale: 'en-US'
enableServerManagement: true
}; };
module.exports = defaultPreferences; module.exports = defaultPreferences;

View file

@ -40,7 +40,7 @@ function createTemplate(mainWindow, config, isDev) {
} }
}]; }];
if (config.enableServerManagement === true || config.teams.length === 0) { if (buildConfig.enableServerManagement === true || config.teams.length === 0) {
platformAppMenu.push({ platformAppMenu.push({
label: 'Sign in to Another Server', label: 'Sign in to Another Server',
click() { click() {