Skip to content

Commit

Permalink
feat: Allow disable account deletion (#817)
Browse files Browse the repository at this point in the history
* feat: allow disable account deletion

* test: add disable account deletion to test case

* style: fix lint errors

* docs: Add ENABLE_ACCOUNT_DELETION to README.rst
  • Loading branch information
JonasBM authored Aug 28, 2023
1 parent c31beee commit 49bc817
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 28 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ STUDIO_BASE_URL=''
SUPPORT_URL=''
USER_INFO_COOKIE_NAME=''
ENABLE_COPPA_COMPLIANCE=''
ENABLE_ACCOUNT_DELETION=''
ENABLE_DOB_UPDATE=''
MARKETING_EMAILS_OPT_IN=''
APP_ID=
Expand Down
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ STUDIO_BASE_URL=''
SUPPORT_URL='http://localhost:18000/support'
USER_INFO_COOKIE_NAME='edx-user-info'
ENABLE_COPPA_COMPLIANCE=''
ENABLE_ACCOUNT_DELETION=''
ENABLE_DOB_UPDATE=''
MARKETING_EMAILS_OPT_IN=''
APP_ID=
Expand Down
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ STUDIO_BASE_URL=''
SUPPORT_URL='http://localhost:18000/support'
USER_INFO_COOKIE_NAME='edx-user-info'
ENABLE_COPPA_COMPLIANCE=''
ENABLE_ACCOUNT_DELETION=''
ENABLE_DOB_UPDATE=''
MARKETING_EMAILS_OPT_IN=''
APP_ID=
Expand Down
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ Examples:

The fully-qualified URL to the support page or email to request the support from in the target environment.

``ENABLE_ACCOUNT_DELETION``

Example: ``'false'`` | ``''`` (empty strings are true)

Enable the account deletion option, defaults to true.
To disable account deletion set ``ENABLE_ACCOUNT_DELETION`` to ``'false'`` (string), otherwise it will default to true.

edX-specific Environment Variables
**********************************

Expand Down
15 changes: 9 additions & 6 deletions src/account-settings/AccountSettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -779,12 +779,15 @@ class AccountSettingsPage extends React.Component {
<ThirdPartyAuth />
</div>

<div className="account-section pt-3 mb-5" id="delete-account" ref={this.navLinkRefs['#delete-account']}>
<DeleteAccount
isVerifiedAccount={this.props.isActive}
hasLinkedTPA={hasLinkedTPA}
/>
</div>
{getConfig().ENABLE_ACCOUNT_DELETION
&& (
<div className="account-section pt-3 mb-5" id="delete-account" ref={this.navLinkRefs['#delete-account']}>
<DeleteAccount
isVerifiedAccount={this.props.isActive}
hasLinkedTPA={hasLinkedTPA}
/>
</div>
)}

</>
);
Expand Down
13 changes: 8 additions & 5 deletions src/account-settings/JumpNav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@ const JumpNav = ({
{intl.formatMessage(messages['account.settings.section.linked.accounts'])}
</NavHashLink>
</li>
<li>
<NavHashLink to="#delete-account">
{intl.formatMessage(messages['account.settings.jump.nav.delete.account'])}
</NavHashLink>
</li>
{getConfig().ENABLE_ACCOUNT_DELETION
&& (
<li>
<NavHashLink to="#delete-account">
{intl.formatMessage(messages['account.settings.jump.nav.delete.account'])}
</NavHashLink>
</li>
)}
</Scrollspy>
{showPreferences && (
<>
Expand Down
10 changes: 8 additions & 2 deletions src/account-settings/test/JumpNav.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const IntlJumpNav = injectIntl(JumpNav);
describe('JumpNav', () => {
mergeConfig({
ENABLE_DEMOGRAPHICS_COLLECTION: false,
ENABLE_ACCOUNT_DELETION: true,
});

let props = {};
Expand All @@ -38,7 +39,11 @@ describe('JumpNav', () => {
});
});

it('should not render Optional Information link', () => {
it('should not render Optional Information or delete account link', () => {
setConfig({
ENABLE_ACCOUNT_DELETION: false,
});

const tree = renderer.create((
<IntlProvider locale="en">
<AppProvider store={store}>
Expand All @@ -51,9 +56,10 @@ describe('JumpNav', () => {
expect(tree).toMatchSnapshot();
});

it('should render Optional Information link', () => {
it('should render Optional Information and delete account link', () => {
setConfig({
ENABLE_DEMOGRAPHICS_COLLECTION: true,
ENABLE_ACCOUNT_DELETION: true,
});

props = {
Expand Down
17 changes: 2 additions & 15 deletions src/account-settings/test/__snapshots__/JumpNav.test.jsx.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`JumpNav should not render Optional Information link 1`] = `
exports[`JumpNav should not render Optional Information or delete account link 1`] = `
<div
className="jump-nav px-2.25 jump-nav-sm position-sticky pt-3"
>
Expand Down Expand Up @@ -73,24 +73,11 @@ exports[`JumpNav should not render Optional Information link 1`] = `
Linked Accounts
</a>
</li>
<li
className=""
>
<a
aria-current="page"
className="active"
href="/#delete-account"
isActive={[Function]}
onClick={[Function]}
>
Delete My Account
</a>
</li>
</ul>
</div>
`;

exports[`JumpNav should render Optional Information link 1`] = `
exports[`JumpNav should render Optional Information and delete account link 1`] = `
<div
className="jump-nav px-2.25 jump-nav-sm position-sticky pt-3"
>
Expand Down
1 change: 1 addition & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ initialize({
ENABLE_DEMOGRAPHICS_COLLECTION: (process.env.ENABLE_DEMOGRAPHICS_COLLECTION || false),
DEMOGRAPHICS_BASE_URL: process.env.DEMOGRAPHICS_BASE_URL,
ENABLE_COPPA_COMPLIANCE: (process.env.ENABLE_COPPA_COMPLIANCE || false),
ENABLE_ACCOUNT_DELETION: (process.env.ENABLE_ACCOUNT_DELETION !== 'false'),
ENABLE_DOB_UPDATE: (process.env.ENABLE_DOB_UPDATE || false),
MARKETING_EMAILS_OPT_IN: (process.env.MARKETING_EMAILS_OPT_IN || false),
PASSWORD_RESET_SUPPORT_LINK: process.env.PASSWORD_RESET_SUPPORT_LINK,
Expand Down

0 comments on commit 49bc817

Please sign in to comment.