From e2706d795670c9ec894e3030029b8affd1b56e4a Mon Sep 17 00:00:00 2001 From: philkloose Date: Fri, 14 Apr 2017 00:22:46 -0500 Subject: [PATCH 1/2] Add ReopenClosedTab context menu to entire tab bar Added options for tabsToolbar context menu Fixes https://github.com/brave/browser-laptop/issues/8303 Auditors: @bsclifton --- app/common/commonMenu.js | 20 +++++++++++ .../brave/locales/en-US/menu.properties | 1 + app/locale.js | 1 + app/renderer/components/tabs/tabs.js | 3 +- js/contextMenus.js | 34 +++++++++++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) diff --git a/app/common/commonMenu.js b/app/common/commonMenu.js index a4a97c7f4e4..4dbc658a0d7 100644 --- a/app/common/commonMenu.js +++ b/app/common/commonMenu.js @@ -134,6 +134,15 @@ module.exports.reopenLastClosedTabItem = () => { } } +module.exports.muteAllTabsMenuItem = () => { + return { + label: locale.translation('muteTabs'), + click: (item) => { + windowActions.muteAllAudio(framePropsList, true) + } + } +} + module.exports.separatorMenuItem = { type: 'separator' } @@ -344,6 +353,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 { diff --git a/app/extensions/brave/locales/en-US/menu.properties b/app/extensions/brave/locales/en-US/menu.properties index 84a42c1d0b5..9335f10e72d 100644 --- a/app/extensions/brave/locales/en-US/menu.properties +++ b/app/extensions/brave/locales/en-US/menu.properties @@ -173,3 +173,4 @@ downloadItemDelete=Delete Download downloadItemClear=Clear Download downloadToolbarHide=Hide downloads bar downloadItemClearCompleted=Clear completed downloads +showTabPreviews=Show Tab Previews diff --git a/app/locale.js b/app/locale.js index 964a9d3f4d5..c9b40611c20 100644 --- a/app/locale.js +++ b/app/locale.js @@ -180,6 +180,7 @@ var rendererIdentifiers = function () { 'learnSpelling', 'ignoreSpelling', 'lookupSelection', + 'showTabPreviews', // Other identifiers 'aboutBlankTitle', 'urlCopied', diff --git a/app/renderer/components/tabs/tabs.js b/app/renderer/components/tabs/tabs.js index f74829057fe..861d21b5002 100644 --- a/app/renderer/components/tabs/tabs.js +++ b/app/renderer/components/tabs/tabs.js @@ -132,7 +132,8 @@ class Tabs extends ImmutableComponent { const index = this.props.previewTabPageIndex !== undefined ? this.props.previewTabPageIndex : this.props.tabPageIndex return
+ onMouseLeave={this.props.fixTabWidth ? this.onMouseLeave : null} + onContextMenu={contextMenus.onTabsContextMenu.bind(this, this.frame)}> 0 } + )) + + return menuUtil.sanitizeTemplateItems(template) +} + function getMisspelledSuggestions (selection, isMisspelled, suggestions) { const hasSelection = selection.length > 0 const template = [] @@ -1362,6 +1388,13 @@ function onTabContextMenu (frameProps, e) { tabMenu.destroy() } +function onTabsContextMenu (frameProps, e) { + e.stopPropagation() + const tabsMenu = Menu.buildFromTemplate(tabsTemplateInit(frameProps)) + tabsMenu.popup(getCurrentWindow()) + tabsMenu.destroy() +} + function onNewTabContextMenu (target) { const menuTemplate = [ CommonMenu.newTabMenuItem(), @@ -1518,6 +1551,7 @@ module.exports = { onFlashContextMenu, onMainContextMenu, onTabContextMenu, + onTabsContextMenu, onNewTabContextMenu, onTabsToolbarContextMenu, onDownloadsToolbarContextMenu, From 6ebb6d29e1c56cf24ed3af66ac3aa77ac784555d Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Thu, 27 Apr 2017 12:32:49 -0700 Subject: [PATCH 2/2] Cleanup for PR https://github.com/brave/browser-laptop/pull/8320/ Mute all tabs moved functionality moved to https://github.com/brave/browser-laptop/issues/8540 Auditors: @philkloose --- app/common/commonMenu.js | 9 --------- app/renderer/components/tabs/tabs.js | 2 +- js/contextMenus.js | 13 ++++++------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/app/common/commonMenu.js b/app/common/commonMenu.js index 4dbc658a0d7..28e94e572e7 100644 --- a/app/common/commonMenu.js +++ b/app/common/commonMenu.js @@ -134,15 +134,6 @@ module.exports.reopenLastClosedTabItem = () => { } } -module.exports.muteAllTabsMenuItem = () => { - return { - label: locale.translation('muteTabs'), - click: (item) => { - windowActions.muteAllAudio(framePropsList, true) - } - } -} - module.exports.separatorMenuItem = { type: 'separator' } diff --git a/app/renderer/components/tabs/tabs.js b/app/renderer/components/tabs/tabs.js index 861d21b5002..9b9db2532a9 100644 --- a/app/renderer/components/tabs/tabs.js +++ b/app/renderer/components/tabs/tabs.js @@ -133,7 +133,7 @@ class Tabs extends ImmutableComponent { ? this.props.previewTabPageIndex : this.props.tabPageIndex return
+ onContextMenu={contextMenus.onTabsBarContextMenu.bind(this, windowStore.getFrames())}>