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 #7861 from NejcZdovc/feature/#7859-lion-badge
Browse files Browse the repository at this point in the history
Adds lion badge
  • Loading branch information
bsclifton authored Mar 23, 2017
2 parents 9aa3b34 + 73fdd4c commit 4cc431b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
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

0 comments on commit 4cc431b

Please sign in to comment.