From 85c59025594528d6e64bfaf913fdd2bd8ab5ea4b Mon Sep 17 00:00:00 2001 From: Dmytro <98233552+DmytroAlipov@users.noreply.github.com> Date: Thu, 21 Sep 2023 11:28:45 +0300 Subject: [PATCH] feat: add toggling for the hardcode support link (for master) (#864) * feat: add toggling for the hardcode support link (master) Add a toggling mechanism for the "unlink all social media accounts" text to show it as a link or text depending on the MFE env setting. * fix(deps): update dependency @edx/frontend-platform to v5.3.0 * Revert "fix(deps): update dependency @edx/frontend-platform to v5.3.0" (#870) This reverts commit 757e446be7a90bf32684263f89915a591e012f60. * feat: add toggling for the hardcode support link (master) Add a toggling mechanism for the "unlink all social media accounts" text to show it as a link or text depending on the MFE env setting. --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Muhammad Abdullah Waheed <42172960+abdullahwaheed@users.noreply.github.com> --- .env | 1 + .env.development | 1 + .env.test | 1 + .../delete-account/BeforeProceedingBanner.jsx | 4 +- .../BeforeProceedingBanner.test.jsx | 48 +++++++++++++ .../delete-account/DeleteAccount.jsx | 3 +- .../BeforeProceedingBanner.test.jsx.snap | 68 +++++++++++++++++++ 7 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 src/account-settings/delete-account/BeforeProceedingBanner.test.jsx create mode 100644 src/account-settings/delete-account/__snapshots__/BeforeProceedingBanner.test.jsx.snap diff --git a/.env b/.env index d245341..ff90ec6 100644 --- a/.env +++ b/.env @@ -33,3 +33,4 @@ APP_ID= MFE_CONFIG_API_URL= PASSWORD_RESET_SUPPORT_LINK='' LEARNER_FEEDBACK_URL='' +SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT='https://support.edx.org/hc/en-us/articles/207206067' diff --git a/.env.development b/.env.development index b2f1e38..522910d 100644 --- a/.env.development +++ b/.env.development @@ -34,3 +34,4 @@ APP_ID= MFE_CONFIG_API_URL= PASSWORD_RESET_SUPPORT_LINK='mailto:support@example.com' LEARNER_FEEDBACK_URL='' +SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT='https://support.edx.org/hc/en-us/articles/207206067' diff --git a/.env.test b/.env.test index 4be694b..e05bbcd 100644 --- a/.env.test +++ b/.env.test @@ -32,3 +32,4 @@ MARKETING_EMAILS_OPT_IN='' APP_ID= MFE_CONFIG_API_URL= LEARNER_FEEDBACK_URL='' +SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT='https://support.edx.org/hc/en-us/articles/207206067' diff --git a/src/account-settings/delete-account/BeforeProceedingBanner.jsx b/src/account-settings/delete-account/BeforeProceedingBanner.jsx index 6f05132..36eb748 100644 --- a/src/account-settings/delete-account/BeforeProceedingBanner.jsx +++ b/src/account-settings/delete-account/BeforeProceedingBanner.jsx @@ -25,10 +25,12 @@ const BeforeProceedingBanner = (props) => { defaultMessage="Before proceeding, please {actionLink}." description="Error that appears if you are trying to delete your account, but something about your account needs attention first. The actionLink will be instructions, such as 'unlink your Facebook account'." values={{ - actionLink: ( + actionLink: supportArticleUrl ? ( {intl.formatMessage(messages[instructionMessageId])} + ) : ( + intl.formatMessage(messages[instructionMessageId]) ), siteName: getConfig().SITE_NAME, }} diff --git a/src/account-settings/delete-account/BeforeProceedingBanner.test.jsx b/src/account-settings/delete-account/BeforeProceedingBanner.test.jsx new file mode 100644 index 0000000..4800cdf --- /dev/null +++ b/src/account-settings/delete-account/BeforeProceedingBanner.test.jsx @@ -0,0 +1,48 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import renderer from 'react-test-renderer'; +import { IntlProvider, injectIntl, createIntl } from '@edx/frontend-platform/i18n'; + +ReactDOM.createPortal = node => node; + +import BeforeProceedingBanner from './BeforeProceedingBanner'; // eslint-disable-line import/first + +const IntlBeforeProceedingBanner = injectIntl(BeforeProceedingBanner); + +describe('BeforeProceedingBanner', () => { + it('should match the snapshot if SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT does not have a support link', () => { + const props = { + instructionMessageId: 'account.settings.delete.account.please.unlink', + intl: createIntl({ locale: 'en' }), + supportArticleUrl: '', + }; + const tree = renderer + .create(( + + + + )) + .toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('should match the snapshot when SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT has a support link', () => { + const props = { + instructionMessageId: 'account.settings.delete.account.please.unlink', + intl: createIntl({ locale: 'en' }), + supportArticleUrl: 'http://test-support.edx', + }; + const tree = renderer + .create(( + + + + )) + .toJSON(); + expect(tree).toMatchSnapshot(); + }); +}); diff --git a/src/account-settings/delete-account/DeleteAccount.jsx b/src/account-settings/delete-account/DeleteAccount.jsx index 5cf806a..6a6323d 100644 --- a/src/account-settings/delete-account/DeleteAccount.jsx +++ b/src/account-settings/delete-account/DeleteAccount.jsx @@ -59,6 +59,7 @@ export class DeleteAccount extends React.Component { hasLinkedTPA, isVerifiedAccount, status, errorType, intl, } = this.props; const canDelete = isVerifiedAccount && !hasLinkedTPA; + const supportArticleUrl = process.env.SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT; // TODO: We lack a good way of providing custom language for a particular site. This is a hack // to allow edx.org to fulfill its business requirements. @@ -122,7 +123,7 @@ export class DeleteAccount extends React.Component { {hasLinkedTPA ? ( ) : null} diff --git a/src/account-settings/delete-account/__snapshots__/BeforeProceedingBanner.test.jsx.snap b/src/account-settings/delete-account/__snapshots__/BeforeProceedingBanner.test.jsx.snap new file mode 100644 index 0000000..9a62d94 --- /dev/null +++ b/src/account-settings/delete-account/__snapshots__/BeforeProceedingBanner.test.jsx.snap @@ -0,0 +1,68 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`BeforeProceedingBanner should match the snapshot if SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT does not have a support link 1`] = ` +
+
+ +
+
+ Before proceeding, please unlink all social media accounts. +
+
+`; + +exports[`BeforeProceedingBanner should match the snapshot when SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT has a support link 1`] = ` +
+
+ +
+
+ Before proceeding, please + + unlink all social media accounts + + . +
+
+`;