From db95674becc10bc5f44922c31000fc14b69fed02 Mon Sep 17 00:00:00 2001 From: uzairr Date: Fri, 1 Jan 2021 16:18:34 +0500 Subject: [PATCH] Add remote var for login issue support url --- .env | 1 + .env.development | 1 + .env.test | 1 + src/index.jsx | 9 ++++++++- src/logistration/LoginHelpLinks.jsx | 15 +++++++++++---- src/logistration/tests/LoginHelpLinks.test.jsx | 7 ++++++- 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.env b/.env index e2d830fc..303ed329 100644 --- a/.env +++ b/.env @@ -15,3 +15,4 @@ SEGMENT_KEY=null SITE_NAME=null USER_INFO_COOKIE_NAME=null LOGISTRATION_MINIMAL_HEADER=true +LOGIN_ISSUE_SUPPORT_LINK=null diff --git a/.env.development b/.env.development index a9ae648c..74798706 100644 --- a/.env.development +++ b/.env.development @@ -20,3 +20,4 @@ SEGMENT_KEY=null SITE_NAME='edX' USER_INFO_COOKIE_NAME='edx-user-info' LOGISTRATION_MINIMAL_HEADER=true +LOGIN_ISSUE_SUPPORT_LINK='' diff --git a/.env.test b/.env.test index c99e1b99..b222ed5a 100644 --- a/.env.test +++ b/.env.test @@ -17,3 +17,4 @@ REFRESH_ACCESS_TOKEN_ENDPOINT='http://localhost:18000/login_refresh' SEGMENT_KEY=null SITE_NAME='edX' USER_INFO_COOKIE_NAME='edx-user-info' +LOGIN_ISSUE_SUPPORT_LINK='https://login-issue-support-url.com' diff --git a/src/index.jsx b/src/index.jsx index 9eb021be..8a1fc8f7 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -1,7 +1,7 @@ import 'babel-polyfill'; import { - APP_INIT_ERROR, APP_READY, subscribe, initialize, + APP_INIT_ERROR, APP_READY, subscribe, initialize, mergeConfig, } from '@edx/frontend-platform'; import { AppProvider, ErrorPage } from '@edx/frontend-platform/react'; import React from 'react'; @@ -52,6 +52,13 @@ subscribe(APP_INIT_ERROR, (error) => { }); initialize({ + handlers: { + config: () => { + mergeConfig({ + LOGIN_ISSUE_SUPPORT_LINK: process.env.LOGIN_ISSUE_SUPPORT_LINK || null, + }); + }, + }, messages: [ appMessages, headerMessages, diff --git a/src/logistration/LoginHelpLinks.jsx b/src/logistration/LoginHelpLinks.jsx index 6f90d8f7..f513fee5 100644 --- a/src/logistration/LoginHelpLinks.jsx +++ b/src/logistration/LoginHelpLinks.jsx @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faCaretDown, faCaretRight } from '@fortawesome/free-solid-svg-icons'; import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { getConfig } from '@edx/frontend-platform'; import SwitchContent from './SwitchContent'; import { @@ -33,6 +34,14 @@ const LoginHelpLinks = (props) => { ); + const loginIssueSupportURL = (config) => (config.LOGIN_ISSUE_SUPPORT_LINK + ? ( + + {intl.formatMessage(messages['logistration.other.sign.in.issues'])} + + ) + : null); + const getHelpButtonMessage = () => { let mid = 'logistration.need.other.help.signing.in.collapsible.menu'; if (page === LOGIN_PAGE) { @@ -44,10 +53,8 @@ const LoginHelpLinks = (props) => { const renderLoginHelp = () => (
- { page === LOGIN_PAGE ? forgotPasswordLink() : signUpLink()} - - {intl.formatMessage(messages['logistration.other.sign.in.issues'])} - + { page === LOGIN_PAGE ? forgotPasswordLink() : signUpLink() } + { loginIssueSupportURL(getConfig()) }
); diff --git a/src/logistration/tests/LoginHelpLinks.test.jsx b/src/logistration/tests/LoginHelpLinks.test.jsx index 12ce2bd1..bf550127 100644 --- a/src/logistration/tests/LoginHelpLinks.test.jsx +++ b/src/logistration/tests/LoginHelpLinks.test.jsx @@ -5,9 +5,14 @@ import { mount } from 'enzyme'; import LoginHelpLinks from '../LoginHelpLinks'; import { LOGIN_PAGE } from '../../data/constants'; +const otherSignInIssues = 'https://login-issue-support-url.com'; + +jest.mock('@edx/frontend-platform', () => ({ + getConfig: jest.fn().mockReturnValue({ LOGIN_ISSUE_SUPPORT_LINK: otherSignInIssues }), +})); + describe('LoginHelpLinks', () => { let props = {}; - const otherSignInIssues = 'https://support.edx.org/hc/en-us/sections/115004153367-Solve-a-Sign-in-Problem'; const reduxWrapper = children => (