Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Add new context menu to entire tab bar (including Reopen last closed tab) #8320

Merged
merged 2 commits into from
Apr 27, 2017
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
11 changes: 11 additions & 0 deletions app/common/commonMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,17 @@ module.exports.bookmarksToolbarMenuItem = () => {
}
}

module.exports.showTabPreviewsMenuItem = () => {
return {
label: locale.translation('showTabPreviews'),
type: 'checkbox',
checked: getSetting(settings.SHOW_TAB_PREVIEWS),
click: (item, focusedWindow) => {
appActions.changeSetting(settings.SHOW_TAB_PREVIEWS, !getSetting(settings.SHOW_TAB_PREVIEWS))
}
}
}

module.exports.autoHideMenuBarMenuItem = () => {
const autoHideMenuBar = getSetting(settings.AUTO_HIDE_MENU)
return {
Expand Down
1 change: 1 addition & 0 deletions app/extensions/brave/locales/en-US/menu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,4 @@ downloadItemDelete=Delete Download
downloadItemClear=Clear Download
downloadToolbarHide=Hide downloads bar
downloadItemClearCompleted=Clear completed downloads
showTabPreviews=Show Tab Previews
1 change: 1 addition & 0 deletions app/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ var rendererIdentifiers = function () {
'learnSpelling',
'ignoreSpelling',
'lookupSelection',
'showTabPreviews',
// Other identifiers
'aboutBlankTitle',
'urlCopied',
Expand Down
3 changes: 2 additions & 1 deletion app/renderer/components/tabs/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ class Tabs extends ImmutableComponent {
const index = this.props.previewTabPageIndex !== undefined
? this.props.previewTabPageIndex : this.props.tabPageIndex
return <div className='tabs'
onMouseLeave={this.props.fixTabWidth ? this.onMouseLeave : null}>
onMouseLeave={this.props.fixTabWidth ? this.onMouseLeave : null}
onContextMenu={contextMenus.onTabsBarContextMenu.bind(this, windowStore.getFrames())}>
<span className={cx({
tabStripContainer: true,
isPreview: this.props.previewTabPageIndex !== undefined,
Expand Down
33 changes: 33 additions & 0 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,31 @@ function tabTemplateInit (frameProps) {
return menuUtil.sanitizeTemplateItems(template)
}

function tabsBarTemplateInit (framePropsList) {
const template = []

template.push(
CommonMenu.newTabMenuItem(),
CommonMenu.separatorMenuItem,
CommonMenu.newPrivateTabMenuItem(),
CommonMenu.newPartitionedTabMenuItem(),
CommonMenu.newWindowMenuItem(),
CommonMenu.separatorMenuItem,
CommonMenu.showTabPreviewsMenuItem(),
CommonMenu.separatorMenuItem,
CommonMenu.bookmarksManagerMenuItem(),
CommonMenu.bookmarksToolbarMenuItem(),
CommonMenu.separatorMenuItem
)

template.push(Object.assign({},
CommonMenu.reopenLastClosedTabItem(),
{ enabled: windowStore.getState().get('closedFrames').size > 0 }
))

return menuUtil.sanitizeTemplateItems(template)
}

function getMisspelledSuggestions (selection, isMisspelled, suggestions) {
const hasSelection = selection.length > 0
const template = []
Expand Down Expand Up @@ -1362,6 +1387,13 @@ function onTabContextMenu (frameProps, e) {
tabMenu.destroy()
}

function onTabsBarContextMenu (framePropsList, e) {
e.stopPropagation()
const tabsMenu = Menu.buildFromTemplate(tabsBarTemplateInit(framePropsList))
tabsMenu.popup(getCurrentWindow())
tabsMenu.destroy()
}

function onNewTabContextMenu (target) {
const menuTemplate = [
CommonMenu.newTabMenuItem(),
Expand Down Expand Up @@ -1518,6 +1550,7 @@ module.exports = {
onFlashContextMenu,
onMainContextMenu,
onTabContextMenu,
onTabsBarContextMenu,
onNewTabContextMenu,
onTabsToolbarContextMenu,
onDownloadsToolbarContextMenu,
Expand Down