@@ -5,15 +5,20 @@ import { bindActionCreators } from 'redux';
5
5
import { Tab , Tabs , TabList , TabPanel } from 'react-tabs' ;
6
6
import { Helmet } from 'react-helmet' ;
7
7
import { withTranslation } from 'react-i18next' ;
8
+ import { withRouter , browserHistory } from 'react-router' ;
9
+ import { parse } from 'query-string' ;
8
10
import { updateSettings , initiateVerification , createApiKey , removeApiKey } from '../actions' ;
9
11
import AccountForm from '../components/AccountForm' ;
10
12
import apiClient from '../../../utils/apiClient' ;
11
13
import { validateSettings } from '../../../utils/reduxFormUtils' ;
12
14
import SocialAuthButton from '../components/SocialAuthButton' ;
13
15
import APIKeyForm from '../components/APIKeyForm' ;
14
16
import Nav from '../../../components/Nav' ;
17
+ import ErrorModal from '../../IDE/components/ErrorModal' ;
18
+ import Overlay from '../../App/components/Overlay' ;
15
19
16
20
function SocialLoginPanel ( props ) {
21
+ const { user } = props ;
17
22
return (
18
23
< React . Fragment >
19
24
< AccountForm { ...props } />
@@ -24,19 +29,37 @@ function SocialLoginPanel(props) {
24
29
{ props . t ( 'AccountView.SocialLoginDescription' ) }
25
30
</ p >
26
31
< 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
+ />
29
42
</ div >
30
43
</ React . Fragment >
31
44
) ;
32
45
}
33
46
47
+ SocialLoginPanel . propTypes = {
48
+ user : PropTypes . shape ( {
49
+ github : PropTypes . string ,
50
+ google : PropTypes . string
51
+ } ) . isRequired
52
+ } ;
53
+
34
54
class AccountView extends React . Component {
35
55
componentDidMount ( ) {
36
56
document . body . className = this . props . theme ;
37
57
}
38
58
39
59
render ( ) {
60
+ const queryParams = parse ( this . props . location . search ) ;
61
+ const showError = ! ! queryParams . error ;
62
+ const errorType = queryParams . error ;
40
63
const accessTokensUIEnabled = window . process . env . UI_ACCESS_TOKEN_ENABLED ;
41
64
42
65
return (
@@ -47,6 +70,21 @@ class AccountView extends React.Component {
47
70
48
71
< Nav layout = "dashboard" />
49
72
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
+
50
88
< main className = "account-settings" >
51
89
< header className = "account-settings__header" >
52
90
< h1 className = "account-settings__title" > { this . props . t ( 'AccountView.Settings' ) } </ h1 >
@@ -111,13 +149,17 @@ function asyncValidate(formProps, dispatch, props) {
111
149
AccountView . propTypes = {
112
150
previousPath : PropTypes . string . isRequired ,
113
151
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
115
157
} ;
116
158
117
- export default withTranslation ( ) ( reduxForm ( {
159
+ export default withTranslation ( ) ( withRouter ( reduxForm ( {
118
160
form : 'updateAllSettings' ,
119
161
fields : [ 'username' , 'email' , 'currentPassword' , 'newPassword' ] ,
120
162
validate : validateSettings ,
121
163
asyncValidate,
122
164
asyncBlurFields : [ 'username' , 'email' , 'currentPassword' ]
123
- } , mapStateToProps , mapDispatchToProps ) ( AccountView ) ) ;
165
+ } , mapStateToProps , mapDispatchToProps ) ( AccountView ) ) ) ;
0 commit comments