-
Notifications
You must be signed in to change notification settings - Fork 799
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new settings route and page for Privacy settings (#8993)
* Add new settings route for /privacy * add basic option for toggling, connected to setting * Add smooth scroll when user clicks Privacy link so they're taken up to where the navigation bar is so they don't miss the content and think nothing happened * Add PropTypes and declare props. Combine selectors imported from the same path. Introduce ModuleSettingsForm to use getOptionValue and isSavingAnyOption so ththe toggle now works. Simplify mapStateToProps and mapDispatchToProps. Simplify other minor code. * Combine sentence to save option with an existing one to avoid duplicating code. * Add link to privacy policy plus placeholder text * Add link to privacy blog * Update code to work with PR #9003 so we save this setting by user * Update privacy texts and links.
- Loading branch information
1 parent
9049a36
commit 4d6e28b
Showing
9 changed files
with
179 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { translate as __ } from 'i18n-calypso'; | ||
import { connect } from 'react-redux'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { ModuleSettingsForm as moduleSettingsForm } from 'components/module-settings/module-settings-form'; | ||
import SettingsCard from 'components/settings-card'; | ||
import SettingsGroup from 'components/settings-group'; | ||
import { ModuleToggle } from 'components/module-toggle'; | ||
import ExternalLink from 'components/external-link'; | ||
import { updateSettings, getSettings } from 'state/settings'; | ||
import analytics from 'lib/analytics'; | ||
|
||
const trackPrivacyPolicyView = () => analytics.tracks.recordJetpackClick( { | ||
target: 'privacy-policy', | ||
feature: 'privacy' | ||
} ); | ||
|
||
const trackWhatJetpackSyncView = () => analytics.tracks.recordJetpackClick( { | ||
target: 'what-data-jetpack-sync', | ||
feature: 'privacy' | ||
} ); | ||
|
||
const trackPrivacyBlogView = () => analytics.tracks.recordJetpackClick( { | ||
target: 'privacy-blog', | ||
feature: 'privacy' | ||
} ); | ||
|
||
class Privacy extends React.Component { | ||
static displayName = 'PrivacySettings'; | ||
|
||
static propTypes = { | ||
searchTerm: PropTypes.string, | ||
active: PropTypes.bool, | ||
|
||
// Connected | ||
toggleTracking: PropTypes.func, | ||
|
||
// Provided by moduleSettingsForm | ||
getOptionValue: PropTypes.func, | ||
isSavingAnyOption: PropTypes.func, | ||
}; | ||
|
||
static defaultProps = { | ||
searchTerm: '', | ||
active: false, | ||
}; | ||
|
||
togglePrivacy = () => this.props.toggleTracking( this.props.getOptionValue( 'jetpack_event_tracking' ) ); | ||
|
||
render() { | ||
const { | ||
searchTerm, | ||
active, | ||
getOptionValue, | ||
isSavingAnyOption, | ||
} = this.props; | ||
|
||
if ( ! searchTerm && ! active ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div> | ||
<SettingsCard | ||
{ ...this.props } | ||
header={ __( 'Privacy Settings', { context: 'Settings header' } ) } | ||
hideButton | ||
> | ||
<SettingsGroup hasChild support="https://jetpack.com/support/privacy"> | ||
<p> | ||
{ | ||
__( 'We are committed to your privacy and security. ' ) | ||
} | ||
<br /> | ||
{ __( | ||
'Read about how Jetpack uses your data in {{pp}}Automattic Privacy Policy{{/pp}} ' + | ||
'and {{js}}What Data Does Jetpack Sync{{/js}}?', { | ||
components: { | ||
pp: <ExternalLink | ||
href="https://automattic.com/privacy/" | ||
onClick={ trackPrivacyPolicyView } | ||
target="_blank" rel="noopener noreferrer" | ||
/>, | ||
js: <ExternalLink | ||
href="https://jetpack.com/support/what-data-does-jetpack-sync/" | ||
onClick={ trackWhatJetpackSyncView } | ||
target="_blank" rel="noopener noreferrer" | ||
/> | ||
} | ||
} ) | ||
} | ||
</p> | ||
<p> | ||
<ModuleToggle | ||
compact | ||
activated={ getOptionValue( 'jetpack_event_tracking' ) } | ||
toggling={ isSavingAnyOption( 'jetpack_event_tracking' ) } | ||
toggleModule={ this.togglePrivacy }> | ||
{ __( 'Send information to help us improve our products.' ) } | ||
</ModuleToggle> | ||
</p> | ||
<p> | ||
{ __( | ||
'See more WordPress privacy information and resources on {{a}}privacy.blog{{/a}}.', { | ||
components: { | ||
a: <ExternalLink | ||
href="https://privacy.blog/" | ||
onClick={ trackPrivacyBlogView } | ||
target="_blank" rel="noopener noreferrer" | ||
/> | ||
} | ||
} ) | ||
} | ||
</p> | ||
</SettingsGroup> | ||
</SettingsCard> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default connect( | ||
state => ( { | ||
settings: getSettings( state ), | ||
} ), | ||
{ | ||
toggleTracking: isEnabled => updateSettings( { jetpack_event_tracking: ! isEnabled } ), | ||
} | ||
)( moduleSettingsForm( Privacy ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters