@@ -5,13 +5,17 @@ import { bindActionCreators } from 'redux';
55import { Tab , Tabs , TabList , TabPanel } from 'react-tabs' ;
66import { Helmet } from 'react-helmet' ;
77import { withTranslation } from 'react-i18next' ;
8+ import { withRouter , browserHistory } from 'react-router' ;
9+ import { parse } from 'query-string' ;
810import { updateSettings , initiateVerification , createApiKey , removeApiKey } from '../actions' ;
911import AccountForm from '../components/AccountForm' ;
1012import apiClient from '../../../utils/apiClient' ;
1113import { validateSettings } from '../../../utils/reduxFormUtils' ;
1214import SocialAuthButton from '../components/SocialAuthButton' ;
1315import APIKeyForm from '../components/APIKeyForm' ;
1416import Nav from '../../../components/Nav' ;
17+ import ErrorModal from '../../IDE/components/ErrorModal' ;
18+ import Overlay from '../../App/components/Overlay' ;
1519
1620function SocialLoginPanel ( props ) {
1721 const { user } = props ;
@@ -53,6 +57,9 @@ class AccountView extends React.Component {
5357 }
5458
5559 render ( ) {
60+ const queryParams = parse ( this . props . location . search ) ;
61+ const showError = ! ! queryParams . error ;
62+ const errorType = queryParams . error ;
5663 const accessTokensUIEnabled = window . process . env . UI_ACCESS_TOKEN_ENABLED ;
5764
5865 return (
@@ -63,6 +70,20 @@ class AccountView extends React.Component {
6370
6471 < Nav layout = "dashboard" />
6572
73+ { showError &&
74+ < Overlay
75+ title = "Error Linking Account"
76+ ariaLabel = "OAuth Error"
77+ closeOverlay = { ( ) => {
78+ browserHistory . push ( this . props . location . pathname ) ;
79+ } }
80+ >
81+ < ErrorModal
82+ type = "oauthError"
83+ />
84+ </ Overlay >
85+ }
86+
6687 < main className = "account-settings" >
6788 < header className = "account-settings__header" >
6889 < h1 className = "account-settings__title" > { this . props . t ( 'AccountView.Settings' ) } </ h1 >
@@ -127,13 +148,17 @@ function asyncValidate(formProps, dispatch, props) {
127148AccountView . propTypes = {
128149 previousPath : PropTypes . string . isRequired ,
129150 theme : PropTypes . string . isRequired ,
130- t : PropTypes . func . isRequired
151+ t : PropTypes . func . isRequired ,
152+ location : PropTypes . shape ( {
153+ search : PropTypes . string . isRequired ,
154+ pathname : PropTypes . string . isRequired
155+ } ) . isRequired
131156} ;
132157
133- export default withTranslation ( ) ( reduxForm ( {
158+ export default withTranslation ( ) ( withRouter ( reduxForm ( {
134159 form : 'updateAllSettings' ,
135160 fields : [ 'username' , 'email' , 'currentPassword' , 'newPassword' ] ,
136161 validate : validateSettings ,
137162 asyncValidate,
138163 asyncBlurFields : [ 'username' , 'email' , 'currentPassword' ]
139- } , mapStateToProps , mapDispatchToProps ) ( AccountView ) ) ;
164+ } , mapStateToProps , mapDispatchToProps ) ( AccountView ) ) ) ;
0 commit comments