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

Commit

Permalink
Merge pull request #420 from brave/feature/more-hamburger
Browse files Browse the repository at this point in the history
Add bravery menu to the hamburger menu
  • Loading branch information
diracdeltas committed Jan 29, 2016
2 parents d516a83 + b62954b commit 85bae78
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 18 deletions.
8 changes: 4 additions & 4 deletions app/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ const aboutUrl = 'https://brave.com/'

const path = require('path')

const httpsEverywhere = 'httpsEverywhere'
const adblock = 'adblock'
const adInsertion = 'adInsertion'
const trackingProtection = 'trackingProtection'
const httpsEverywhere = AppConfig.resourceNames.HTTPS_EVERYWHERE
const adblock = AppConfig.resourceNames.ADBLOCK
const adInsertion = AppConfig.resourceNames.AD_INSERTION
const trackingProtection = AppConfig.resourceNames.TRACKING_PROTECTION

/**
* Sets up the menu.
Expand Down
8 changes: 4 additions & 4 deletions js/commonMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const AppConfig = require('./constants/appConfig')
const AppActions = require('../js/actions/appActions')
const messages = require('../js/constants/messages')

const httpsEverywhere = 'httpsEverywhere'
const adblock = 'adblock'
const adInsertion = 'adInsertion'
const trackingProtection = 'trackingProtection'
const httpsEverywhere = AppConfig.resourceNames.HTTPS_EVERYWHERE
const adblock = AppConfig.resourceNames.ADBLOCK
const adInsertion = AppConfig.resourceNames.AD_INSERTION
const trackingProtection = AppConfig.resourceNames.TRACKING_PROTECTION

let electron
try {
Expand Down
15 changes: 15 additions & 0 deletions js/components/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ class Main extends ImmutableComponent {
// TODO
}

onHamburgerMenu () {
let settings = {}
Object.keys(AppConfig.resourceNames).forEach((name) => {
let value = AppConfig.resourceNames[name]
let enabled = this.props.appState.getIn([value, 'enabled'])
settings[value] = enabled === undefined ? AppConfig[value].enabled : enabled
})
// whether the current page is bookmarked. needed to re-initialize the
// application menu.
settings.bookmarked = this.navBar.bookmarked
contextMenus.onHamburgerMenu(settings)
}

onMainFocus () {
// When the main container is in focus, set the URL bar to inactive.
WindowActions.setUrlBarActive(false)
Expand Down Expand Up @@ -150,6 +163,7 @@ class Main extends ImmutableComponent {
onClick={this.onForward.bind(this)} />
</div>
<NavigationBar
ref={node => this.navBar = node}
navbar={activeFrame && activeFrame.get('navbar')}
frames={this.props.windowState.get('frames')}
sites={this.props.appState.get('sites')}
Expand Down Expand Up @@ -182,6 +196,7 @@ class Main extends ImmutableComponent {
sites={this.props.appState.get('sites')}
key='tab-bar'
activeFrame={activeFrame}
onMenu={this.onHamburgerMenu.bind(this)}
/>
<UpdateBar updates={this.props.appState.get('updates')} />
</div>
Expand Down
10 changes: 3 additions & 7 deletions js/components/tabsToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,16 @@ const Button = require('./button')
const PinnedTabs = require('./pinnedTabs')
const WindowActions = require('../actions/windowActions')
import Config from '../constants/config.js'
const contextMenus = require('../contextMenus')

class TabsToolbarButtons extends ImmutableComponent {
onMenu () {
contextMenus.onHamburgerMenu()
}

render () {
return <div className='tabsToolbarButtons'>
{ this.props.partOfFullPageSet || this.props.noFrames
? <Button label='+'
className='navbutton newFrameButton' onClick={WindowActions.newFrame} /> : null }
<Button iconClass='fa-bars'
className='navbutton menu-button'
onClick={this.onMenu.bind(this)} />
onClick={this.props.onMenu} />
</div>
}
}
Expand Down Expand Up @@ -53,7 +48,8 @@ class TabsToolbar extends ImmutableComponent {
partOfFullPageSet={currentFrames.size === Config.tabs.tabsPerPage}
/>
<TabsToolbarButtons partOfFullPageSet={currentFrames.size === Config.tabs.tabsPerPage}
noFrames={currentFrames.size === 0}/>
noFrames={currentFrames.size === 0}
onMenu={this.props.onMenu}/>
</div>
}
}
Expand Down
6 changes: 6 additions & 0 deletions js/constants/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ const crashURL = process.env.CRASH_URL || 'https://laptop-updates.brave.com/1/cr

module.exports = {
name: 'Brave',
resourceNames: {
ADBLOCK: 'adblock',
HTTPS_EVERYWHERE: 'httpsEverywhere',
TRACKING_PROTECTION: 'trackingProtection',
AD_INSERTION: 'adInsertion'
},
adblock: {
url: 'https://s3.amazonaws.com/adblock-data/{version}/ABPFilterParserData.dat',
version: '1',
Expand Down
11 changes: 8 additions & 3 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const WindowActions = require('./actions/windowActions')
const AppActions = require('./actions/appActions')
const SiteTags = require('./constants/siteTags')
const CommonMenu = require('./commonMenu')
const ipc = global.require('electron').ipcRenderer

function tabPageTemplateInit (framePropsList) {
const muteAll = (framePropsList, mute) => {
Expand Down Expand Up @@ -138,7 +139,7 @@ function getEditableItems (hasSelection) {
}]
}

function hamburgerTemplateInit () {
function hamburgerTemplateInit (settings) {
const template = [
CommonMenu.newTabMenuItem,
CommonMenu.newPrivateTabMenuItem,
Expand All @@ -148,6 +149,10 @@ function hamburgerTemplateInit () {
CommonMenu.findOnPageMenuItem,
CommonMenu.printMenuItem,
CommonMenu.separatorMenuItem,
CommonMenu.buildBraveryMenu(settings, function () {
ipc.send(messages.UPDATE_APP_MENU, {bookmarked: settings.bookmarked})
}),
CommonMenu.separatorMenuItem,
CommonMenu.quitMenuItem
]
return template
Expand Down Expand Up @@ -269,8 +274,8 @@ function mainTemplateInit (nodeProps) {
return template
}

export function onHamburgerMenu () {
const hamburgerMenu = Menu.buildFromTemplate(hamburgerTemplateInit())
export function onHamburgerMenu (settings) {
const hamburgerMenu = Menu.buildFromTemplate(hamburgerTemplateInit(settings))
hamburgerMenu.popup(remote.getCurrentWindow())
}

Expand Down

0 comments on commit 85bae78

Please sign in to comment.