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

Harmonize menu bar and settings in sidebar #2263

Merged
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
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