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

Commit

Permalink
Simplify displayed list of https upgrades in bravery panel
Browse files Browse the repository at this point in the history
Fix #1875

Auditors: @bbondy
  • Loading branch information
diracdeltas committed May 23, 2016
1 parent 00b70eb commit 981d1b0
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions js/components/braveryPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

const React = require('react')
const ipc = require('electron').ipcRenderer
const Immutable = require('immutable')
const ImmutableComponent = require('./immutableComponent')
const Dialog = require('./dialog')
const SwitchControl = require('./switchControl')
Expand Down Expand Up @@ -57,6 +58,17 @@ class BraveryPanel extends ImmutableComponent {
get redirectedResources () {
return this.props.frameProps.get('httpsEverywhere')
}
get redirectedResourcesSet () {
let result = new Immutable.Set([])
if (this.redirectedResources) {
this.redirectedResources.forEach((urls) => {
if (urls) {
result = result.union(urls)
}
})
}
return result
}
get isRedirectingResources () {
return this.redirectedResources && this.redirectedResources.size > 0
}
Expand All @@ -73,6 +85,11 @@ class BraveryPanel extends ImmutableComponent {
e.stopPropagation()
}
onToggleHttpseList (e) {
if (!this.isHttpseShown && this.redirectedResources &&
this.redirectedResources.size) {
// Display full list of rulesets in console for debugging
console.log('httpse rulesets', JSON.stringify(this.redirectedResources.toJS()))
}
windowActions.setBraveryPanelDetail({
expandHttpse: !this.isHttpseShown
})
Expand Down Expand Up @@ -136,9 +153,7 @@ class BraveryPanel extends ImmutableComponent {
<div data-l10n-id='trackersBlocked' />
</div>
<div onClick={this.onToggleHttpseList}>
<div className='braveryStat redirectedResourcesStat'>{this.redirectedResources ? this.redirectedResources.reduce((reduction, value) => {
return reduction + value.size
}, 0) : 0}</div>
<div className='braveryStat redirectedResourcesStat'>{this.redirectedResourcesSet.size || 0}</div>
<div data-l10n-id='httpReroutes' />
</div>
</div>
Expand Down Expand Up @@ -166,8 +181,8 @@ class BraveryPanel extends ImmutableComponent {
this.isRedirectingResources && this.isHttpseShown
? <li><ul>
{
this.redirectedResources.map((sites, ruleset) =>
<li key={ruleset}>{[ruleset, JSON.stringify(sites.toJS())].join(': ')}</li>)
this.redirectedResourcesSet.map((site) =>
<li key={site}>{site}</li>)
}
</ul></li>
: null
Expand Down

1 comment on commit 981d1b0

@bbondy
Copy link
Member

@bbondy bbondy commented on 981d1b0 May 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice thanks!

Please sign in to comment.