Skip to content

Commit

Permalink
Harmonize menu bar and settings in sidebar (#2263)
Browse files Browse the repository at this point in the history
The web app has settings/keyboard shortcuts/about items in the navigation bar but those are absent from Electron.
Electron already provides access to the settings through the OS menu but it's confusing to jump between the web and
the electron app to discover those items are missing in one place.

In this PR we stop hiding the settings and other items in the navigation sidebar when running in Electron.

The Electron OS menu has also been missing "Empty Trash" and "Sign Out" as the native apps have. "Sign Out" is particularly
convenient to have there and its absence makes logging-out particularly inconvenient.

As a result of the overall state refactor in the app we're adding those menu items to make it more convenient again.
  • Loading branch information
dmsnell authored Aug 6, 2020
1 parent a87d55b commit 93f6da7
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 38 deletions.
7 changes: 7 additions & 0 deletions desktop/menus/mac-app-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ const buildMacAppMenu = (isAuthenticated) => {
{ role: 'hide' },
{ role: 'hideothers' },
{ role: 'unhide' },
...(isAuthenticated
? [
{ type: 'separator' },
menuItems.emptyTrash(isAuthenticated),
menuItems.signout(isAuthenticated),
]
: []),
{ type: 'separator' },
{ role: 'quit' },
];
Expand Down
20 changes: 20 additions & 0 deletions desktop/menus/menu-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ const checkForUpdates = {
click: updater.pingAndShowProgress.bind(updater),
};

const emptyTrash = (isAuthenticated) => {
return {
label: '&Empty Trash',
visible: isAuthenticated,
click: appCommandSender({ action: 'emptyTrash' }),
};
};

const preferences = (isAuthenticated) => {
return {
label: 'P&references…',
Expand All @@ -28,8 +36,20 @@ const preferences = (isAuthenticated) => {
};
};

const signout = (isAuthenticated) => {
return {
label: '&Sign Out',
visible: isAuthenticated,
click: appCommandSender({
action: 'logout',
}),
};
};

module.exports = {
about,
checkForUpdates,
emptyTrash,
preferences,
signout,
};
71 changes: 33 additions & 38 deletions lib/navigation-bar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { Component, Fragment } from 'react';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import onClickOutside from 'react-onclickoutside';

import { isElectron } from '../utils/platform';
import ConnectionStatus from '../connection-status';
import NavigationBarItem from './item';
import TagList from '../tag-list';
Expand Down Expand Up @@ -91,42 +90,38 @@ export class NavigationBar extends Component<Props> {
</div>
</div>

{(!isElectron || autoHideMenuBar) && (
<Fragment>
<div className="navigation-bar__tools theme-color-border">
<NavigationBarItem
icon={<SettingsIcon />}
label="Settings"
onClick={onSettings}
/>
</div>
<div className="navigation-bar__footer">
<button
type="button"
className="navigation-bar__footer-item theme-color-fg-dim"
onClick={this.props.showKeyboardShortcuts}
>
Keyboard Shortcuts
</button>
</div>
<div className="navigation-bar__footer">
<button
type="button"
className="navigation-bar__footer-item theme-color-fg-dim"
onClick={this.onHelpClicked}
>
Help &amp; Support
</button>
<button
type="button"
className="navigation-bar__footer-item theme-color-fg-dim"
onClick={onAbout}
>
About
</button>
</div>
</Fragment>
)}
<div className="navigation-bar__tools theme-color-border">
<NavigationBarItem
icon={<SettingsIcon />}
label="Settings"
onClick={onSettings}
/>
</div>
<div className="navigation-bar__footer">
<button
type="button"
className="navigation-bar__footer-item theme-color-fg-dim"
onClick={this.props.showKeyboardShortcuts}
>
Keyboard Shortcuts
</button>
</div>
<div className="navigation-bar__footer">
<button
type="button"
className="navigation-bar__footer-item theme-color-fg-dim"
onClick={this.onHelpClicked}
>
Help &amp; Support
</button>
<button
type="button"
className="navigation-bar__footer-item theme-color-fg-dim"
onClick={onAbout}
>
About
</button>
</div>
</div>
);
}
Expand Down
8 changes: 8 additions & 0 deletions lib/state/electron/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ import * as S from '../';
export const middleware: S.Middleware = ({ dispatch, getState }) => {
window.electron.receive('appCommand', (command) => {
switch (command.action) {
case 'emptyTrash':
dispatch(actions.ui.emptyTrash());
return;

case 'exportNotes':
dispatch(actions.data.exportNotes());
return;

case 'logout':
dispatch({ type: 'LOGOUT' });
return;

case 'printNote':
window.print();
return;
Expand Down

0 comments on commit 93f6da7

Please sign in to comment.