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

Adds lion badge #7861

Merged
merged 1 commit into from
Mar 23, 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
32 changes: 32 additions & 0 deletions js/components/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const React = require('react')
const ImmutableComponent = require('./immutableComponent')
const Immutable = require('immutable')
const electron = require('electron')
const {StyleSheet, css} = require('aphrodite')
const ipc = electron.ipcRenderer
// const systemPreferences = electron.remote.systemPreferences

Expand Down Expand Up @@ -880,6 +881,14 @@ class Main extends ImmutableComponent {
return null
}

getTotalBlocks (frames) {
const ads = frames.getIn(['adblock', 'blocked'])
const trackers = frames.getIn(['trackingProtection', 'blocked'])
const blocked = (ads ? ads.size : 0) + (trackers ? trackers.size : 0)

return (blocked > 99) ? '99+' : blocked
}

render () {
const comparatorByKeyAsc = (a, b) => a.get('key') > b.get('key')
? 1 : b.get('key') > a.get('key') ? -1 : 0
Expand Down Expand Up @@ -1067,6 +1076,13 @@ class Main extends ImmutableComponent {
? <span className='buttonSeparator' />
: null
}
{
!this.braveShieldsDisabled
? <div className={css(styles.lionBadge)} data-test-id='lionBadge'>
{this.getTotalBlocks(activeFrame)}
</div>
: null
}
</div>
</div>
</div>
Expand Down Expand Up @@ -1342,4 +1358,20 @@ class Main extends ImmutableComponent {
}
}

const styles = StyleSheet.create({
lionBadge: {
right: '2px',
position: 'absolute',
top: '15px',
color: '#FFF',
borderRadius: '2px',
padding: '1px 2px',
pointerEvents: 'none',
font: '7pt "Arial Narrow"',
textAlign: 'center',
border: '.5px solid #FFF',
background: '#555555'
}
})

module.exports = Main
1 change: 1 addition & 0 deletions less/navigationBar.less
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@
display: flex;
flex-direction: row;
margin-left: 3px;
position: relative;

.extensionButton {
-webkit-app-region: no-drag;
Expand Down
9 changes: 9 additions & 0 deletions test/bravery-components/braveryPanelTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ describe('Bravery Panel', function () {
.windowByUrl(Brave.browserWindowUrl)
.waitForVisible(braveMenu)
})
it('lion badge', function * () {
const url = Brave.server.url('tracking.html')
yield this.app.client
.waitForDataFile('trackingProtection')
.tabByIndex(0)
.loadUrl(url)
.windowByUrl(Brave.browserWindowUrl)
.waitForTextValue('[data-test-id="lionBadge"]', '2')
})
})
describe('Stats', function () {
Brave.beforeEach(this)
Expand Down
5 changes: 4 additions & 1 deletion test/lib/brave.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,10 @@ var exports = {
return this
.waitForVisible(selector)
.waitUntil(function () {
return this.getText(selector).then((value) => { return value === text })
return this.getText(selector).then((value) => {
logVerbose('waitForTextValue("' + selector + '", ' + text + ') => ' + value)
return value === text
})
}, 5000, null, 100)
})

Expand Down