@@ -5,15 +5,20 @@ 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 ) {
21+ const { user } = props ;
1722 return (
1823 < React . Fragment >
1924 < AccountForm { ...props } />
@@ -24,19 +29,37 @@ function SocialLoginPanel(props) {
2429 { props . t ( 'AccountView.SocialLoginDescription' ) }
2530 </ p >
2631 < div className = "account__social-stack" >
27- < SocialAuthButton service = { SocialAuthButton . services . github } />
28- < SocialAuthButton service = { SocialAuthButton . services . google } />
32+ < SocialAuthButton
33+ service = { SocialAuthButton . services . github }
34+ linkStyle
35+ isConnected = { ! ! user . github }
36+ />
37+ < SocialAuthButton
38+ service = { SocialAuthButton . services . google }
39+ linkStyle
40+ isConnected = { ! ! user . google }
41+ />
2942 </ div >
3043 </ React . Fragment >
3144 ) ;
3245}
3346
47+ SocialLoginPanel . propTypes = {
48+ user : PropTypes . shape ( {
49+ github : PropTypes . string ,
50+ google : PropTypes . string
51+ } ) . isRequired
52+ } ;
53+
3454class AccountView extends React . Component {
3555 componentDidMount ( ) {
3656 document . body . className = this . props . theme ;
3757 }
3858
3959 render ( ) {
60+ const queryParams = parse ( this . props . location . search ) ;
61+ const showError = ! ! queryParams . error ;
62+ const errorType = queryParams . error ;
4063 const accessTokensUIEnabled = window . process . env . UI_ACCESS_TOKEN_ENABLED ;
4164
4265 return (
@@ -47,6 +70,21 @@ class AccountView extends React.Component {
4770
4871 < Nav layout = "dashboard" />
4972
73+ { showError &&
74+ < Overlay
75+ title = { this . props . t ( 'ErrorModal.LinkTitle' ) }
76+ ariaLabel = { this . props . t ( 'ErrorModal.LinkTitle' ) }
77+ closeOverlay = { ( ) => {
78+ browserHistory . push ( this . props . location . pathname ) ;
79+ } }
80+ >
81+ < ErrorModal
82+ type = "oauthError"
83+ service = { errorType }
84+ />
85+ </ Overlay >
86+ }
87+
5088 < main className = "account-settings" >
5189 < header className = "account-settings__header" >
5290 < h1 className = "account-settings__title" > { this . props . t ( 'AccountView.Settings' ) } </ h1 >
@@ -111,13 +149,17 @@ function asyncValidate(formProps, dispatch, props) {
111149AccountView . propTypes = {
112150 previousPath : PropTypes . string . isRequired ,
113151 theme : PropTypes . string . isRequired ,
114- t : PropTypes . func . isRequired
152+ t : PropTypes . func . isRequired ,
153+ location : PropTypes . shape ( {
154+ search : PropTypes . string . isRequired ,
155+ pathname : PropTypes . string . isRequired
156+ } ) . isRequired
115157} ;
116158
117- export default withTranslation ( ) ( reduxForm ( {
159+ export default withTranslation ( ) ( withRouter ( reduxForm ( {
118160 form : 'updateAllSettings' ,
119161 fields : [ 'username' , 'email' , 'currentPassword' , 'newPassword' ] ,
120162 validate : validateSettings ,
121163 asyncValidate,
122164 asyncBlurFields : [ 'username' , 'email' , 'currentPassword' ]
123- } , mapStateToProps , mapDispatchToProps ) ( AccountView ) ) ;
165+ } , mapStateToProps , mapDispatchToProps ) ( AccountView ) ) ) ;
0 commit comments