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

GH-1607: Remove Ghostery rewards toggle, and add language for Cliqz Browser #450

Merged
merged 2 commits into from Sep 17, 2019
Merged
Changes from 1 commit
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Next

Remove ghostery rewards toggle and add language for Cliqz Browser

  • Loading branch information
benstrumeyer committed Sep 17, 2019
commit 363cb0af6317dcb5fc12104f7414ab992723d422
@@ -1535,6 +1535,17 @@
"hub_setup_smartblocking_description_smartblocking": {
"message": "Automatically block and unblock trackers to optimize page performance."
},
"hub_setup_feature_already_active": {
"message": "This feature is already active in Cliqz by default. $LINK_LM_START$Learn More$LINK_LM_END$",
"placeholders": {
"link_lm_start": {
"content": "<a href=\"https://www.ghostery.com/faqs/what-are-the-new-ghostery-8-features/\" target=\"_blank\" rel=\"noopener noreferrer\">"
},
"link_lm_end": {
"content": "</a>"
}
}
},
"hub_setup_ghosteryrewards_name_rewards": {
"message": "Rewards"
},
@@ -40,6 +40,7 @@ const SetupAntiSuiteView = props => (
<ToggleSwitch
checked={feature.enabled}
onChange={feature.toggle}
locked={feature.locked}
/>
</div>
</div>
@@ -61,13 +62,12 @@ const SetupAntiSuiteView = props => (
<ToggleSwitch
checked={feature.enabled}
onChange={feature.toggle}
locked={feature.locked}
/>
</div>
</div>
</div>
<div className="SetupAntiSuite__featureDescription">
{feature.description}
</div>
<div className="SetupAntiSuite__featureDescription" dangerouslySetInnerHTML={{ __html: feature.description }} />
</div>
</div>
);
@@ -14,6 +14,9 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import SetupAntiSuiteView from './SetupAntiSuiteView';
import globals from '../../../../../src/classes/Globals';
// simple consts
const { IS_CLIQZ } = globals;

/**
* @class Implement the Setup Anti-Suite View for the Ghostery Hub
@@ -43,7 +46,7 @@ class SetupAntiSuiteViewContainer extends Component {
enable_anti_tracking,
enable_ad_block,
enable_smart_block,
enable_ghostery_rewards,
enable_ghostery_rewards
} = setup;
props.actions.setSetupStep({ setup_step: 9 });
props.actions.setAntiTracking({ enable_anti_tracking });
@@ -94,44 +97,49 @@ class SetupAntiSuiteViewContainer extends Component {
enable_smart_block,
enable_ghostery_rewards,
} = this.props.setup;

const anti_tracking_enabled = IS_CLIQZ ? false : enable_anti_tracking;
const ad_block_enabled = IS_CLIQZ ? false : enable_ad_block;
const ghostery_rewards_enabled = !IS_CLIQZ;
const features = [
{
id: 'anti-tracking',
name: t('hub_setup_antisuite_name_antitracking'),
enabled: enable_anti_tracking,
toggle: () => {
this._handleToggle('anti-tracking');
},
description: t('hub_setup_antisuite_description_antitracking'),
enabled: anti_tracking_enabled,
locked: IS_CLIQZ,
toggle: IS_CLIQZ ?
() => {} :
() => this._handleToggle('anti-tracking'),
description: IS_CLIQZ ? t('hub_setup_feature_already_active') : t('hub_setup_antisuite_description_antitracking')
},
{
id: 'ad-block',
name: t('hub_setup_adblock_name_adblocking'),
enabled: enable_ad_block,
toggle: () => {
this._handleToggle('ad-block');
},
description: t('hub_setup_adblock_description_adblocking'),
enabled: ad_block_enabled,
locked: IS_CLIQZ,
toggle: IS_CLIQZ ?
() => {} :
() => this._handleToggle('ad-block'),
description: IS_CLIQZ ? t('hub_setup_feature_already_active') : t('hub_setup_adblock_description_adblocking'),
},
{
id: 'smart-blocking',
name: t('hub_setup_smartblocking_name_smartblocking'),
enabled: enable_smart_block,
toggle: () => {
this._handleToggle('smart-blocking');
},
toggle: () => this._handleToggle('smart-blocking'),
description: t('hub_setup_smartblocking_description_smartblocking'),
},
{
}
];

if (ghostery_rewards_enabled) {
This conversation was marked as resolved by jsignanini

This comment has been minimized.

@jsignanini

jsignanini Sep 17, 2019
Member

It looks like we're only using ghostery_rewards_enabled right here, would it be clearer to replace this with !IS_CLIQZ instead?

This comment has been minimized.

@benstrumeyer

benstrumeyer Sep 17, 2019
Author Contributor

Definitely agree. I've removed the variable entirely and replaced it with !IS_CLIQZ.

features.push({
id: 'ghostery-rewards',
name: t('hub_setup_ghosteryrewards_name_rewards'),
enabled: enable_ghostery_rewards,
toggle: () => {
this._handleToggle('ghostery-rewards');
},
toggle: () => this._handleToggle('ghostery-rewards'),
description: t('hub_setup_ghosteryrewards_description_rewards'),
},
];
});
}

return <SetupAntiSuiteView features={features} />;
}
@@ -146,7 +154,7 @@ SetupAntiSuiteViewContainer.propTypes = {
setAntiTracking: PropTypes.func.isRequired,
setAdBlock: PropTypes.func.isRequired,
setSmartBlocking: PropTypes.func.isRequired,
setGhosteryRewards: PropTypes.func.isRequired,
setGhosteryRewards: PropTypes.func.isRequired
}).isRequired,
sendMountActions: PropTypes.bool.isRequired,
};
@@ -87,9 +87,12 @@ exports[`app/hub/Views/SetupViews/SetupAntiSuiteView component Snapshot tests wi
</div>
<div
className="SetupAntiSuite__featureDescription"
>
The first test feature
</div>
dangerouslySetInnerHTML={
Object {
"__html": "The first test feature",
}
}
/>
</div>
</div>
<div
@@ -157,9 +160,12 @@ exports[`app/hub/Views/SetupViews/SetupAntiSuiteView component Snapshot tests wi
</div>
<div
className="SetupAntiSuite__featureDescription"
>
The second test feature
</div>
dangerouslySetInnerHTML={
Object {
"__html": "The second test feature",
}
}
/>
</div>
</div>
</div>
@@ -23,8 +23,15 @@ import ClassNames from 'classnames';
const ToggleSwitch = (props) => {
const switchClassNames = ClassNames('ToggleSwitch', {
'ToggleSwitch--active': props.checked,
'ToggleSwitch--locked': props.locked,
'ToggleSwitch--removed': props.removed
});

ToggleSwitch.defaultProps = {
locked: false,
removed: false
};

This conversation was marked as resolved by jsignanini

This comment has been minimized.

@jsignanini

jsignanini Sep 17, 2019
Member

We add the .defaultProps at the bottom of the file, separate from the class or function declaration. See other .defaultProps declarations as guidance.

This comment has been minimized.

@benstrumeyer

benstrumeyer Sep 17, 2019
Author Contributor

Very neat. I have moved it to the bottom of the file.

return (
<div className={switchClassNames} onClick={props.onChange}>
<div className="ToggleSwitch__bar" />
@@ -36,6 +43,8 @@ const ToggleSwitch = (props) => {
// PropTypes ensure we pass required props of the correct type
ToggleSwitch.propTypes = {
checked: PropTypes.bool.isRequired,
locked: PropTypes.bool,
removed: PropTypes.bool,
onChange: PropTypes.func.isRequired,
};

@@ -49,3 +49,9 @@
margin-left: 14px;
background-color: #1dafed;
}
.ToggleSwitch.ToggleSwitch--locked {
cursor: not-allowed;
}
.ToggleSwitch.ToggleSwitch--removed {
display: none;
}
@@ -21,6 +21,8 @@ describe('app/shared-components/ToggleSwitch component', () => {
test('toggle switch is rendered correctly when checked', () => {
const initialState = {
checked: true,
locked: false,
removed: false,
onChange: () => {},
};

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