feat(user-data): Add a 'download data' button to privacy section (#17252)
Closes #17123
This commit is contained in:
committed by
mrugesh mohapatra
parent
23eb3713c9
commit
05176b8bd2
@ -3,20 +3,20 @@ import PropTypes from 'prop-types';
|
|||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import { Button } from 'react-bootstrap';
|
||||||
|
|
||||||
import { updateMyProfileUI } from '../redux';
|
import { updateMyProfileUI } from '../redux';
|
||||||
import { userSelector } from '../../../redux';
|
import { userSelector } from '../../../redux';
|
||||||
|
|
||||||
import { FullWidthRow } from '../../../helperComponents';
|
import { FullWidthRow, Spacer } from '../../../helperComponents';
|
||||||
import SectionHeader from './SectionHeader.jsx';
|
import SectionHeader from './SectionHeader.jsx';
|
||||||
import ToggleSetting from './ToggleSetting.jsx';
|
import ToggleSetting from './ToggleSetting.jsx';
|
||||||
|
|
||||||
const mapStateToProps = createSelector(
|
const mapStateToProps = createSelector(
|
||||||
userSelector,
|
userSelector,
|
||||||
({
|
user => ({
|
||||||
profileUI = {}
|
...user.profileUI,
|
||||||
}) => ({
|
user
|
||||||
...profileUI
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -33,7 +33,8 @@ const propTypes = {
|
|||||||
showPoints: PropTypes.bool,
|
showPoints: PropTypes.bool,
|
||||||
showPortfolio: PropTypes.bool,
|
showPortfolio: PropTypes.bool,
|
||||||
showTimeLine: PropTypes.bool,
|
showTimeLine: PropTypes.bool,
|
||||||
updateMyProfileUI: PropTypes.func.isRequired
|
updateMyProfileUI: PropTypes.func.isRequired,
|
||||||
|
user: PropTypes.object
|
||||||
};
|
};
|
||||||
|
|
||||||
function PrivacySettings(props) {
|
function PrivacySettings(props) {
|
||||||
@ -47,7 +48,8 @@ function PrivacySettings(props) {
|
|||||||
showPoints,
|
showPoints,
|
||||||
showPortfolio,
|
showPortfolio,
|
||||||
showTimeLine,
|
showTimeLine,
|
||||||
updateMyProfileUI
|
updateMyProfileUI,
|
||||||
|
user
|
||||||
} = props;
|
} = props;
|
||||||
const toggleFlag = flag =>
|
const toggleFlag = flag =>
|
||||||
() => updateMyProfileUI({ profileUI: { [flag]: !props[flag] } });
|
() => updateMyProfileUI({ profileUI: { [flag]: !props[flag] } });
|
||||||
@ -56,9 +58,10 @@ function PrivacySettings(props) {
|
|||||||
<SectionHeader>Privacy Settings</SectionHeader>
|
<SectionHeader>Privacy Settings</SectionHeader>
|
||||||
<FullWidthRow>
|
<FullWidthRow>
|
||||||
<p>
|
<p>
|
||||||
The settings in this section enable you to control what is show on{' '}
|
The settings in this section enable you to control what is shown on{' '}
|
||||||
your freeCodeCamp public portfolio.
|
your freeCodeCamp public portfolio.
|
||||||
</p>
|
</p>
|
||||||
|
<p>There is also a button to see what data we hold on your account</p>
|
||||||
<ToggleSetting
|
<ToggleSetting
|
||||||
action='Make my profile completely private'
|
action='Make my profile completely private'
|
||||||
explain={
|
explain={
|
||||||
@ -137,6 +140,22 @@ function PrivacySettings(props) {
|
|||||||
toggleFlag={ toggleFlag('showTimeLine') }
|
toggleFlag={ toggleFlag('showTimeLine') }
|
||||||
/>
|
/>
|
||||||
</FullWidthRow>
|
</FullWidthRow>
|
||||||
|
<FullWidthRow>
|
||||||
|
<Spacer />
|
||||||
|
<Button
|
||||||
|
block={true}
|
||||||
|
bsSize='lg'
|
||||||
|
bsStyle='primary'
|
||||||
|
download={`${user.username}.json`}
|
||||||
|
href={
|
||||||
|
`data:text/json;charset=utf-8,${
|
||||||
|
encodeURIComponent(JSON.stringify(user))
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Download all your data
|
||||||
|
</Button>
|
||||||
|
</FullWidthRow>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user