Skip to content

Commit

Permalink
Add ReopenClosedTab context menu to entire tab bar
Browse files Browse the repository at this point in the history
Added options for tabsToolbar context menu

Fixes brave#8303

Auditors: @bsclifton
  • Loading branch information
philkloose authored and bsclifton committed Apr 26, 2017
1 parent fe070af commit 90a7751
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
20 changes: 20 additions & 0 deletions app/common/commonMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down Expand Up @@ -334,6 +343,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 @@ -165,3 +165,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 @@ -172,6 +172,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.onTabsContextMenu.bind(this, this.frame)}>
<span className={cx({
tabStripContainer: true,
isPreview: this.props.previewTabPageIndex !== undefined,
Expand Down
34 changes: 34 additions & 0 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,32 @@ function tabTemplateInit (frameProps) {
return menuUtil.sanitizeTemplateItems(template)
}

function tabsTemplateInit () {

const template = []

template.push( CommonMenu.newTabMenuItem(),
CommonMenu.separatorMenuItem,
CommonMenu.newPrivateTabMenuItem(),
CommonMenu.newPartitionedTabMenuItem(),
CommonMenu.newWindowMenuItem(),
CommonMenu.separatorMenuItem,
CommonMenu.muteAllTabsMenuItem(),
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 +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(),
Expand Down Expand Up @@ -1518,6 +1551,7 @@ module.exports = {
onFlashContextMenu,
onMainContextMenu,
onTabContextMenu,
onTabsContextMenu,
onNewTabContextMenu,
onTabsToolbarContextMenu,
onDownloadsToolbarContextMenu,
Expand Down

0 comments on commit 90a7751

Please sign in to comment.