From 10f71e319c6cde44b721b0abf8d862f08e272420 Mon Sep 17 00:00:00 2001 From: Jonas Burigo Martins Date: Mon, 28 Aug 2023 11:40:48 +0100 Subject: [PATCH] feat: Allow disable account deletion (#817) * 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 --- .env | 1 + .env.development | 1 + .env.test | 1 + README.rst | 7 +++++++ src/account-settings/AccountSettingsPage.jsx | 15 +++++++++------ src/account-settings/JumpNav.jsx | 13 ++++++++----- src/account-settings/test/JumpNav.test.jsx | 10 ++++++++-- .../test/__snapshots__/JumpNav.test.jsx.snap | 17 ++--------------- src/index.jsx | 1 + 9 files changed, 38 insertions(+), 28 deletions(-) diff --git a/.env b/.env index e9fd02514..d24534170 100644 --- a/.env +++ b/.env @@ -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= diff --git a/.env.development b/.env.development index 27d7a25fe..b2f1e3807 100644 --- a/.env.development +++ b/.env.development @@ -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= diff --git a/.env.test b/.env.test index 7329bd438..4be694bc5 100644 --- a/.env.test +++ b/.env.test @@ -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= diff --git a/README.rst b/README.rst index 923ab0106..b187ed3b2 100644 --- a/README.rst +++ b/README.rst @@ -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 ********************************** diff --git a/src/account-settings/AccountSettingsPage.jsx b/src/account-settings/AccountSettingsPage.jsx index e9ac1087d..bcca2f4ea 100644 --- a/src/account-settings/AccountSettingsPage.jsx +++ b/src/account-settings/AccountSettingsPage.jsx @@ -779,12 +779,15 @@ class AccountSettingsPage extends React.Component { -
- -
+ {getConfig().ENABLE_ACCOUNT_DELETION + && ( +
+ +
+ )} ); diff --git a/src/account-settings/JumpNav.jsx b/src/account-settings/JumpNav.jsx index f94c10d39..aaf2c9174 100644 --- a/src/account-settings/JumpNav.jsx +++ b/src/account-settings/JumpNav.jsx @@ -67,11 +67,14 @@ const JumpNav = ({ {intl.formatMessage(messages['account.settings.section.linked.accounts'])} -
  • - - {intl.formatMessage(messages['account.settings.jump.nav.delete.account'])} - -
  • + {getConfig().ENABLE_ACCOUNT_DELETION + && ( +
  • + + {intl.formatMessage(messages['account.settings.jump.nav.delete.account'])} + +
  • + )} {showPreferences && ( <> diff --git a/src/account-settings/test/JumpNav.test.jsx b/src/account-settings/test/JumpNav.test.jsx index 2b5793415..3eeb07806 100644 --- a/src/account-settings/test/JumpNav.test.jsx +++ b/src/account-settings/test/JumpNav.test.jsx @@ -12,6 +12,7 @@ const IntlJumpNav = injectIntl(JumpNav); describe('JumpNav', () => { mergeConfig({ ENABLE_DEMOGRAPHICS_COLLECTION: false, + ENABLE_ACCOUNT_DELETION: true, }); let props = {}; @@ -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(( @@ -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 = { diff --git a/src/account-settings/test/__snapshots__/JumpNav.test.jsx.snap b/src/account-settings/test/__snapshots__/JumpNav.test.jsx.snap index a69f0ea07..536ee23c6 100644 --- a/src/account-settings/test/__snapshots__/JumpNav.test.jsx.snap +++ b/src/account-settings/test/__snapshots__/JumpNav.test.jsx.snap @@ -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`] = `
    @@ -73,24 +73,11 @@ exports[`JumpNav should not render Optional Information link 1`] = ` Linked Accounts -
  • - - Delete My Account - -
  • `; -exports[`JumpNav should render Optional Information link 1`] = ` +exports[`JumpNav should render Optional Information and delete account link 1`] = `
    diff --git a/src/index.jsx b/src/index.jsx index b6d0054ad..88be4e779 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -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,