Skip to content
Snippets Groups Projects
Commit b2c9b50d authored by Diana Huang's avatar Diana Huang
Browse files

Add a warning message when there are social auth links connected.

parent a84884ff
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,7 @@ const wrapperRendered = setInterval(() => { ...@@ -16,6 +16,7 @@ const wrapperRendered = setInterval(() => {
component: StudentAccountDeletion, component: StudentAccountDeletion,
selector: `#${accountDeletionWrapperId}`, selector: `#${accountDeletionWrapperId}`,
componentName: 'StudentAccountDeletion', componentName: 'StudentAccountDeletion',
props: { socialAccountLinks: window.auth },
}); });
} }
......
/* globals gettext */ /* globals gettext */
/* eslint-disable react/no-danger, import/prefer-default-export */ /* eslint-disable react/no-danger, import/prefer-default-export */
import React from 'react'; import React from 'react';
import { Button } from '@edx/paragon/static'; import { Button, Icon, StatusAlert } from '@edx/paragon/static';
import StringUtils from 'edx-ui-toolkit/js/utils/string-utils'; import StringUtils from 'edx-ui-toolkit/js/utils/string-utils';
import StudentAccountDeletionModal from './StudentAccountDeletionModal'; import StudentAccountDeletionModal from './StudentAccountDeletionModal';
...@@ -10,7 +10,10 @@ export class StudentAccountDeletion extends React.Component { ...@@ -10,7 +10,10 @@ export class StudentAccountDeletion extends React.Component {
super(props); super(props);
this.closeDeletionModal = this.closeDeletionModal.bind(this); this.closeDeletionModal = this.closeDeletionModal.bind(this);
this.loadDeletionModal = this.loadDeletionModal.bind(this); this.loadDeletionModal = this.loadDeletionModal.bind(this);
this.state = { deletionModalOpen: false }; this.state = {
deletionModalOpen: false,
socialAuthConnected: props.socialAccountLinks.providers.reduce((acc, value) => acc || value.connected, false)
};
} }
closeDeletionModal() { closeDeletionModal() {
...@@ -23,7 +26,7 @@ export class StudentAccountDeletion extends React.Component { ...@@ -23,7 +26,7 @@ export class StudentAccountDeletion extends React.Component {
} }
render() { render() {
const { deletionModalOpen } = this.state; const { deletionModalOpen, socialAuthConnected } = this.state
const loseAccessText = StringUtils.interpolate( const loseAccessText = StringUtils.interpolate(
gettext('You may also lose access to verified certificates and other program credentials like MicroMasters certificates. If you want to make a copy of these for your records before proceeding with deletion, follow the instructions for {htmlStart}printing or downloading a certificate{htmlEnd}.'), gettext('You may also lose access to verified certificates and other program credentials like MicroMasters certificates. If you want to make a copy of these for your records before proceeding with deletion, follow the instructions for {htmlStart}printing or downloading a certificate{htmlEnd}.'),
{ {
...@@ -32,6 +35,14 @@ export class StudentAccountDeletion extends React.Component { ...@@ -32,6 +35,14 @@ export class StudentAccountDeletion extends React.Component {
}, },
); );
const socialAuthError = StringUtils.interpolate(
gettext('Before proceeding, please {htmlStart}unlink all social media accounts{htmlEnd}.'),
{
htmlStart: '<a href="https://support.edx.org/hc/en-us/articles/207206067" target="_blank">',
htmlEnd: '</a>',
}
);
return ( return (
<div className="account-deletion-details"> <div className="account-deletion-details">
<p className="account-settings-header-subtitle">{ gettext('We’re sorry to see you go!') }</p> <p className="account-settings-header-subtitle">{ gettext('We’re sorry to see you go!') }</p>
...@@ -45,10 +56,26 @@ export class StudentAccountDeletion extends React.Component { ...@@ -45,10 +56,26 @@ export class StudentAccountDeletion extends React.Component {
<Button <Button
id="delete-account-btn" id="delete-account-btn"
className={['btn-outline-primary']} className={['btn-outline-primary']}
disabled={socialAuthConnected}
label={gettext('Delete My Account')} label={gettext('Delete My Account')}
inputRef={(input) => { this.modalTrigger = input; }} inputRef={(input) => { this.modalTrigger = input; }}
onClick={this.loadDeletionModal} onClick={this.loadDeletionModal}
/> />
{socialAuthConnected && <StatusAlert
dialog={(
<div className="modal-alert">
<div className="icon-wrapper">
<Icon id="delete-confirmation-body-error-icon" className={['fa', 'fa-exclamation-circle']} />
</div>
<div className="alert-content">
<p dangerouslySetInnerHTML={{ __html: socialAuthError }}/>
</div>
</div>
)}
alertType="danger"
dismissible={false}
open
/>}
{deletionModalOpen && <StudentAccountDeletionModal onClose={this.closeDeletionModal} />} {deletionModalOpen && <StudentAccountDeletionModal onClose={this.closeDeletionModal} />}
</div> </div>
); );
......
...@@ -8,6 +8,8 @@ from django.conf import settings ...@@ -8,6 +8,8 @@ from django.conf import settings
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_string from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_string
from openedx.core.djangolib.markup import HTML
from webpack_loader.templatetags.webpack_loader import render_bundle
# GDPR Flag # GDPR Flag
from openedx.features.course_experience import ENABLE_GDPR_COMPAT_FLAG from openedx.features.course_experience import ENABLE_GDPR_COMPAT_FLAG
...@@ -70,6 +72,10 @@ from openedx.features.course_experience import ENABLE_GDPR_COMPAT_FLAG ...@@ -70,6 +72,10 @@ from openedx.features.course_experience import ENABLE_GDPR_COMPAT_FLAG
); );
</%static:require_module> </%static:require_module>
% if ENABLE_GDPR_COMPAT_FLAG.is_enabled_without_course_context(): % if ENABLE_GDPR_COMPAT_FLAG.is_enabled_without_course_context():
<%static:webpack entry="StudentAccountDeletionInitializer"></%static:webpack> <script type="text/javascript">
window.auth = ${ auth | n, dump_js_escaped_json }
</script>
<%static:webpack entry="StudentAccountDeletionInitializer">
</%static:webpack>
% endif % endif
</%block> </%block>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment