Cleanup getWindowHeaderConfig (#1378)

This commit is contained in:
Albin Ekblom 2017-01-10 23:05:19 +01:00 committed by Guillermo Rauch
parent fc685c7d02
commit 95e98006c0

View file

@ -102,19 +102,21 @@ export default class Header extends Component {
getWindowHeaderConfig() { getWindowHeaderConfig() {
const {showHamburgerMenu, showWindowControls} = this.props; const {showHamburgerMenu, showWindowControls} = this.props;
const ret = {
const defaults = {
hambMenu: process.platform === 'win32', // show by default on windows hambMenu: process.platform === 'win32', // show by default on windows
winCtrls: !this.props.isMac // show by default on windows and linux winCtrls: !this.props.isMac // show by default on windows and linux
}; };
if (!this.props.isMac) { // allow the user to override the defaults if not on macOS
if (showHamburgerMenu !== '') { // don't allow the user to change defaults on MacOS
ret.hambMenu = showHamburgerMenu; if (this.props.isMac) {
} return defaults;
if (showWindowControls !== '') {
ret.winCtrls = showWindowControls;
}
} }
return ret;
return {
hambMenu: showHamburgerMenu === '' ? defaults.hambMenu : showHamburgerMenu,
winCtrls: showWindowControls === '' ? defaults.winCtrls : showWindowControls
};
} }
template(css) { template(css) {