Skip to content

Commit

Permalink
feat(client): restore tabs context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Sep 24, 2018
1 parent 12f7ff4 commit 772b163
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions client/src/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ export class App extends Component {
return tabs.find(t => t.file && t.file.path === file.path);
}

openTabMenu = (tab, event) => {
event.preventDefault();

this.props.onContextMenu('tab', { tabId: tab.id });
}

/**
* Mark the active tab as shown.
*/
Expand Down Expand Up @@ -627,6 +633,7 @@ export class App extends Component {
isDirty={ this.isDirty }
activeTab={ activeTab }
onSelect={ this.selectTab }
onContextMenu={ this.openTabMenu }
onClose={ (tab) => {
this.triggerAction('close-tab', { tabId: tab.id }).catch(console.error);
} }
Expand Down
5 changes: 5 additions & 0 deletions client/src/app/AppParent.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export default class AppParent extends Component {
this.getApp().openFiles(files);
}

handleContextMenu = (type, options) => {
this.getBackend().showContextMenu(type, options);
}

handleToolStateChanged = (tab, state) => {
this.getBackend().updateMenu(state);
}
Expand Down Expand Up @@ -98,6 +102,7 @@ export default class AppParent extends Component {
tabsProvider={ tabsProvider }
globals={ globals }
onToolStateChanged={ this.handleToolStateChanged }
onContextMenu={ this.handleContextMenu }
onReady={ this.handleReady }
/>
);
Expand Down
6 changes: 5 additions & 1 deletion client/src/app/primitives/TabLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import classNames from 'classnames';

import { linksContainer } from './Tabbed.less';

const noop = () => {};


export default class TabLinks extends Component {

Expand All @@ -14,6 +16,7 @@ export default class TabLinks extends Component {
tabs,
isDirty,
onSelect,
onContextMenu,
onClose,
onCreate,
className
Expand All @@ -32,7 +35,8 @@ export default class TabLinks extends Component {
active: tab === activeTab,
dirty: isDirty && isDirty(tab)
}) }
onClick={ () => onSelect(tab) }
onClick={ () => onSelect(tab, event) }
onContextMenu={ (event) => (onContextMenu || noop)(tab, event) }
>
{tab.name}
{
Expand Down
4 changes: 4 additions & 0 deletions client/src/remote/Backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export default class Backend {
this.send('client:ready');
}

showContextMenu = (type, options) => {
this.send('context-menu:open', type, options);
}

updateMenu = (state) => {
this.send('menu:update', state);
}
Expand Down

0 comments on commit 772b163

Please sign in to comment.