Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android browser develop #97

Merged
merged 6 commits into from Aug 6, 2018
Merged
Changes from 1 commit
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Allow user to click on a category's checkbox to block/unblock all tra…
…ckers inside
  • Loading branch information
mai-cliqz committed Jul 20, 2018
commit 7d6459172010f2bf0e36b565ea50e7eecf8d4777
@@ -195,7 +195,7 @@ export function blockUnblockGlobalTracker({ actionData, state }) {
}

export function blockUnBlockAllTrackers({ actionData, state }) {
const { type, block } = actionData;
const { type, block, categoryId } = actionData; // categoryId is set when clicking on category's check box
const isSiteTrackers = type === 'site';

const updated_app_ids = JSON.parse(JSON.stringify(state.blocking.selected_app_ids)) || {};
@@ -206,6 +206,10 @@ export function blockUnBlockAllTrackers({ actionData, state }) {

if (isSiteTrackers) {
updated_blocking_categories.forEach((category) => {
if (categoryId && category.id !== categoryId) {
return;
}

const updated_settings_category = updated_settings_categories.find(item => item.id === category.id);
category.num_blocked = 0;
// TODO: change the logic here
@@ -242,6 +246,10 @@ export function blockUnBlockAllTrackers({ actionData, state }) {
});
} else {
updated_settings_categories.forEach((category) => {
if (categoryId && category.id !== categoryId) {
return;
}

category.num_blocked = 0;
category.trackers.forEach((tracker) => {
if (tracker.shouldShow) {
@@ -121,6 +121,30 @@ export default class Accordion extends React.Component {
});
}

handleCategoryClicked = () => {
if (!this.blockingStatus) {
const type = this.props.type === 'site-trackers' ? 'site' : 'global';
this.context.callGlobalAction({
actionName: 'blockUnBlockAllTrackers',
actionData: {
block: true,
type,
categoryId: this.props.id,
}
});
} else if (this.blockingStatus === 'blocked') {
const type = this.props.type === 'site-trackers' ? 'site' : 'global';
this.context.callGlobalAction({
actionName: 'blockUnBlockAllTrackers',
actionData: {
block: false,
type,
categoryId: this.props.id,
}
});
}
}

itemHeight = 50;
nExtraItems = 40;
headerheight = 32;
@@ -131,7 +155,7 @@ export default class Accordion extends React.Component {

return (
<div className={`accordion ${this.props.index}`}>
<span className={`accordionSelect ${this.blockingStatus}`} />
<span className={`accordionSelect ${this.blockingStatus}`} onClick={this.handleCategoryClicked} />
<div className={`accordionTitle ${this.state.isActive ? 'active' : ''}`} style={titleStyle} onClick={this.toggleContent}>
<h2>{this.props.name}</h2>
<p>
@@ -193,4 +217,5 @@ Accordion.defaultProps = {

Accordion.contextTypes = {
siteProps: PropTypes.object,
callGlobalAction: PropTypes.func,
};
@@ -69,7 +69,12 @@ export default class TrackerItem extends React.Component {
this.props.toggleMenu(this.props.index);
}

clickButtonBlock = () => {
clickButtonBlock = (hideMenu = true) => {
// onClick={(e) => { e.stopPropagation(); this.clickButtonBlock(false); }}
if (this.disabledStatus) {
return;
}

const blocked = !this.props.tracker.blocked;

if (this.props.type === 'site-trackers') {
@@ -93,7 +98,10 @@ export default class TrackerItem extends React.Component {
}
});
}
this.props.toggleMenu(this.props.index);

if (hideMenu) {
this.props.toggleMenu(this.props.index);
}
}

openTrackerLink = () => {
@@ -12,6 +12,7 @@
background-color: #eee;
background-repeat: no-repeat;
background-position: center;
z-index: 1;

&.blocked, &.trusted, &.restricted {
border: none;
@@ -7791,16 +7791,18 @@ prop-types@15.5.10:
fbjs "^0.8.9"
loose-envify "^1.3.1"

<<<<<<< HEAD
prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2:
prop-types@^15.5.10, prop-types@^15.6.2:
version "15.6.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102"
=======
prop-types@^15.5.4, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1:
dependencies:
loose-envify "^1.3.1"
object-assign "^4.1.1"

prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1:
version "15.6.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.1.tgz#36644453564255ddda391191fb3a125cbdf654ca"
>>>>>>> Update package.json
dependencies:
fbjs "^0.8.16"
loose-envify "^1.3.1"
object-assign "^4.1.1"

ProTip! Use n and p to navigate between commits in a pull request.