From 7408f476f2d442b5d114ebd44c26b49276d20f7b Mon Sep 17 00:00:00 2001 From: Mubbshar Anwar <78487564+mubbsharanwar@users.noreply.github.com> Date: Fri, 18 Jun 2021 12:46:14 +0500 Subject: [PATCH] fix: Redirection using Tab component (#360) using Paragon Tab component for redirection instead Link VAN-554 --- src/redesign/_style.scss | 13 +------ .../common-components/Logistration.jsx | 36 ++++++++++--------- .../forgot-password/ForgotPasswordPage.jsx | 4 +-- .../reset-password/ResetPasswordPage.jsx | 33 ++++++++++++----- .../tests/ResetPasswordPage.test.jsx | 20 ++++++++++- 5 files changed, 66 insertions(+), 40 deletions(-) diff --git a/src/redesign/_style.scss b/src/redesign/_style.scss index efbd748e..18aa6f8b 100644 --- a/src/redesign/_style.scss +++ b/src/redesign/_style.scss @@ -32,15 +32,6 @@ $accent-a-light: #c9f2f5; margin-bottom: 0.75rem; } -.nav-tabs { - a { - color: $primary !important; - :hover { - color: $primary !important; - } - } -} - .sr-only { position: absolute; left: -10000px; @@ -663,7 +654,5 @@ select.form-control { } .arrow-back-icon { - max-width: 1rem; - max-height: 1rem; - margin-top:6px; + margin-top:2px; } diff --git a/src/redesign/common-components/Logistration.jsx b/src/redesign/common-components/Logistration.jsx index 48b10128..9813aeed 100644 --- a/src/redesign/common-components/Logistration.jsx +++ b/src/redesign/common-components/Logistration.jsx @@ -4,9 +4,12 @@ import { Redirect } from 'react-router-dom'; import { sendPageEvent, sendTrackEvent } from '@edx/frontend-platform/analytics'; import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; -import { Button, Tabs, Tab } from '@edx/paragon'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faChevronLeft } from '@fortawesome/free-solid-svg-icons'; +import { + Tabs, + Tab, + Icon, +} from '@edx/paragon'; +import { ChevronLeft } from '@edx/paragon/icons'; import messages from './messages'; import { LOGIN_PAGE, REGISTER_PAGE } from '../data/constants'; @@ -32,23 +35,24 @@ const Logistration = (props) => { setKey(tabKey); }; + const tabTitle = ( +
+ + + {selectedPage === LOGIN_PAGE + ? intl.formatMessage(messages['logistration.sign.in']) + : intl.formatMessage(messages['logistration.register'])} + +
+ ); + return (
{institutionLogin ? ( - - - - + + + ) : ( <> diff --git a/src/redesign/forgot-password/ForgotPasswordPage.jsx b/src/redesign/forgot-password/ForgotPasswordPage.jsx index 0c1bf40b..7fea862d 100644 --- a/src/redesign/forgot-password/ForgotPasswordPage.jsx +++ b/src/redesign/forgot-password/ForgotPasswordPage.jsx @@ -17,7 +17,7 @@ import { Tab, Icon, } from '@edx/paragon'; -import { ArrowBackIos } from '@edx/paragon/icons'; +import { ChevronLeft } from '@edx/paragon/icons'; import { forgotPassword } from './data/actions'; import { forgotPasswordResultSelector } from './data/selectors'; @@ -57,7 +57,7 @@ const ForgotPasswordPage = (props) => { const tabTitle = (
- + {intl.formatMessage(messages['sign.in.text'])}
); diff --git a/src/redesign/reset-password/ResetPasswordPage.jsx b/src/redesign/reset-password/ResetPasswordPage.jsx index 8aa300c1..8e064574 100644 --- a/src/redesign/reset-password/ResetPasswordPage.jsx +++ b/src/redesign/reset-password/ResetPasswordPage.jsx @@ -2,13 +2,19 @@ import React, { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; import { Helmet } from 'react-helmet'; import { connect } from 'react-redux'; -import { Link, Redirect } from 'react-router-dom'; +import { Redirect } from 'react-router-dom'; -import { Form, Spinner, StatefulButton } from '@edx/paragon'; +import { + Form, + Spinner, + StatefulButton, + Tabs, + Tab, + Icon, +} from '@edx/paragon'; +import { ChevronLeft } from '@edx/paragon/icons'; import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; import { getQueryParameters, getConfig } from '@edx/frontend-platform'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faChevronLeft } from '@fortawesome/free-solid-svg-icons'; import messages from './messages'; import { resetPassword, validateToken } from './data/actions'; @@ -31,6 +37,7 @@ const ResetPasswordPage = (props) => { const [confirmPassword, setConfirmPassword] = useState(''); const [formErrors, setFormErrors] = useState({}); const [errorCode, setErrorCode] = useState(null); + const [key, setKey] = useState(''); useEffect(() => { if (props.status !== TOKEN_STATE.PENDING && props.status !== PASSWORD_RESET_ERROR) { @@ -107,6 +114,13 @@ const ResetPasswordPage = (props) => { } }; + const tabTitle = ( +
+ + {intl.formatMessage(messages['sign.in'])} +
+ ); + if (props.status === TOKEN_STATE.PENDING) { const { token } = props.match.params; if (token) { @@ -125,11 +139,12 @@ const ResetPasswordPage = (props) => { { siteName: getConfig().SITE_NAME })} - - - {intl.formatMessage(messages['sign.in'])} - - + setKey(k)}> + + + { key && ( + + )}
diff --git a/src/redesign/reset-password/tests/ResetPasswordPage.test.jsx b/src/redesign/reset-password/tests/ResetPasswordPage.test.jsx index 82891cb7..5f94c3ed 100644 --- a/src/redesign/reset-password/tests/ResetPasswordPage.test.jsx +++ b/src/redesign/reset-password/tests/ResetPasswordPage.test.jsx @@ -4,7 +4,8 @@ import { act } from 'react-dom/test-utils'; import { mount } from 'enzyme'; import configureStore from 'redux-mock-store'; import { Provider } from 'react-redux'; -import { MemoryRouter } from 'react-router-dom'; +import { MemoryRouter, Router } from 'react-router-dom'; +import { createMemoryHistory } from 'history'; import * as auth from '@edx/frontend-platform/auth'; import CookiePolicyBanner from '@edx/frontend-component-cookie-policy-banner'; @@ -12,12 +13,14 @@ import { IntlProvider, injectIntl } from '@edx/frontend-platform/i18n'; import { resetPassword } from '../data/actions'; import { PASSWORD_RESET, TOKEN_STATE } from '../data/constants'; +import { LOGIN_PAGE } from '../../data/constants'; import ResetPasswordPage from '../ResetPasswordPage'; jest.mock('@edx/frontend-platform/auth'); const IntlResetPasswordPage = injectIntl(ResetPasswordPage); const mockStore = configureStore(); +const history = createMemoryHistory(); describe('ResetPasswordPage', () => { let props = {}; @@ -155,4 +158,19 @@ describe('ResetPasswordPage', () => { const resetPasswordPage = mount(reduxWrapper()); expect(resetPasswordPage.find('div.spinner-header')).toBeTruthy(); }); + + // ******** redirection tests ******** + + it('by clicking on sign in tab should redirect onto login page', async () => { + const resetPasswordPage = mount(reduxWrapper( + + + , + )); + + await act(async () => { await resetPasswordPage.find('nav').find('a').first().simulate('click'); }); + + resetPasswordPage.update(); + expect(history.location.pathname).toEqual(LOGIN_PAGE); + }); });