From 4abd72856f697b93186771cd324de8a39c2f2f8d Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Tue, 7 Nov 2017 22:06:42 +0900 Subject: [PATCH] Move enableServerManagement key from defaultPreferences to buildConfig --- src/browser/components/SettingsPage.jsx | 5 +++-- src/browser/index.jsx | 2 +- src/browser/settings.jsx | 6 +++++- src/common/config/buildConfig.js | 4 +++- src/common/config/defaultPreferences.js | 3 +-- src/main/menus/app.js | 2 +- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/browser/components/SettingsPage.jsx b/src/browser/components/SettingsPage.jsx index 63ff2924..f5eb56f0 100644 --- a/src/browser/components/SettingsPage.jsx +++ b/src/browser/components/SettingsPage.jsx @@ -30,7 +30,8 @@ const CONFIG_TYPE_APP_OPTIONS = 'appOptions'; const SettingsPage = createReactClass({ propTypes: { - configFile: PropTypes.string + configFile: PropTypes.string, + enableServerManagement: PropTypes.bool }, getInitialState() { @@ -342,7 +343,7 @@ const SettingsPage = createReactClass({ ); var srvMgmt; - if (this.state.enableServerManagement || this.state.teams.length === 0) { + if (this.props.enableServerManagement || this.state.teams.length === 0) { srvMgmt = (
{serversRow} diff --git a/src/browser/index.jsx b/src/browser/index.jsx index bd09839f..ce7364e1 100644 --- a/src/browser/index.jsx +++ b/src/browser/index.jsx @@ -169,7 +169,7 @@ ReactDOM.render( useSpellChecker={AppConfig.data.useSpellChecker} onSelectSpellCheckerLocale={handleSelectSpellCheckerLocale} deeplinkingUrl={deeplinkingUrl} - showAddServerButton={AppConfig.data.enableServerManagement} + showAddServerButton={buildConfig.enableServerManagement} requestingPermission={requestingPermission} onClickPermissionDialog={handleClickPermissionDialog} />, diff --git a/src/browser/settings.jsx b/src/browser/settings.jsx index 305a4a06..1f463bf6 100644 --- a/src/browser/settings.jsx +++ b/src/browser/settings.jsx @@ -9,13 +9,17 @@ const React = require('react'); const ReactDOM = require('react-dom'); const SettingsPage = require('./components/SettingsPage.jsx'); const contextMenu = require('./js/contextMenu'); +const buildConfig = require('../common/config/buildConfig'); const configFile = remote.app.getPath('userData') + '/config.json'; contextMenu.setup(remote.getCurrentWindow()); ReactDOM.render( - , + , document.getElementById('content') ); diff --git a/src/common/config/buildConfig.js b/src/common/config/buildConfig.js index af4065f4..141c82f4 100644 --- a/src/common/config/buildConfig.js +++ b/src/common/config/buildConfig.js @@ -5,6 +5,7 @@ * @prop {string} defaultTeams[].url - The URL for default team. * @prop {string} helpLink - The URL for "Help->Learn More..." menu item. * If null is specified, the menu disappears. + * @prop {boolean} enableServerManagement - Whether users can edit servers configuration. */ const buildConfig = { defaultTeams: [/* @@ -13,7 +14,8 @@ const buildConfig = { 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; diff --git a/src/common/config/defaultPreferences.js b/src/common/config/defaultPreferences.js index 69b6ade3..39f96219 100644 --- a/src/common/config/defaultPreferences.js +++ b/src/common/config/defaultPreferences.js @@ -13,8 +13,7 @@ const defaultPreferences = { }, showUnreadBadge: true, useSpellChecker: true, - spellCheckerLocale: 'en-US', - enableServerManagement: true + spellCheckerLocale: 'en-US' }; module.exports = defaultPreferences; diff --git a/src/main/menus/app.js b/src/main/menus/app.js index 89e6cd6c..114c48d1 100644 --- a/src/main/menus/app.js +++ b/src/main/menus/app.js @@ -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({ label: 'Sign in to Another Server', click() {