23
23
*/
24
24
25
25
import * as React from 'react' ;
26
- import Transition from 'react-transition-group/Transition' ;
27
26
import { useAuth } from "react-oidc-context" ;
28
27
import { Theme } from '@mui/material' ;
29
28
import { WithStyles } from '@mui/styles' ;
30
29
import createStyles from '@mui/styles/createStyles' ;
31
30
import withStyles from '@mui/styles/withStyles' ;
31
+ import { deepOrange } from '@mui/material/colors' ;
32
32
import Avatar from '@mui/material/Avatar' ;
33
33
import Button from '@mui/material/Button' ;
34
34
import CircularProgress from '@mui/material/CircularProgress' ;
@@ -40,45 +40,44 @@ import IconButton from '@mui/material/IconButton';
40
40
import Menu from '@mui/material/Menu' ;
41
41
import MenuItem from '@mui/material/MenuItem' ;
42
42
import PersonIcon from '@mui/icons-material/Person' ;
43
- import i18n from '../i18n' ;
44
43
44
+ import i18n from '../i18n' ;
45
45
import { WithLocale } from '../util/lang' ;
46
46
import { Config } from '../config' ;
47
47
import UserProfile from '../components/UserProfile' ;
48
- import { deepOrange } from '@mui/material/colors' ;
49
48
50
49
51
50
const styles = ( theme : Theme ) => createStyles (
52
- {
53
- imageAvatar : {
54
- width : 32 ,
55
- height : 32 ,
56
- color : '#fff' ,
57
- backgroundColor : deepOrange [ 300 ] ,
58
- } ,
59
- letterAvatar : {
60
- width : 32 ,
61
- height : 32 ,
62
- color : '#fff' ,
63
- backgroundColor : deepOrange [ 300 ] ,
64
- } ,
65
- signInWrapper : {
66
- margin : theme . spacing ( 1 ) ,
67
- position : 'relative' ,
68
- } ,
69
- signInProgress : {
70
- color : deepOrange [ 300 ] ,
71
- position : 'absolute' ,
72
- top : '50%' ,
73
- left : '50%' ,
74
- zIndex : 1 ,
75
- marginTop : - 12 ,
76
- marginLeft : - 12 ,
77
- } ,
78
- iconButton : {
79
- padding : 0 ,
80
- }
51
+ {
52
+ imageAvatar : {
53
+ width : 32 ,
54
+ height : 32 ,
55
+ color : '#fff' ,
56
+ backgroundColor : deepOrange [ 300 ] ,
57
+ } ,
58
+ letterAvatar : {
59
+ width : 32 ,
60
+ height : 32 ,
61
+ color : '#fff' ,
62
+ backgroundColor : deepOrange [ 300 ] ,
63
+ } ,
64
+ signInWrapper : {
65
+ margin : theme . spacing ( 1 ) ,
66
+ position : 'relative' ,
67
+ } ,
68
+ signInProgress : {
69
+ color : deepOrange [ 300 ] ,
70
+ position : 'absolute' ,
71
+ top : '50%' ,
72
+ left : '50%' ,
73
+ zIndex : 1 ,
74
+ marginTop : - 12 ,
75
+ marginLeft : - 12 ,
76
+ } ,
77
+ iconButton : {
78
+ padding : 0 ,
81
79
}
80
+ }
82
81
) ;
83
82
84
83
interface UserControlProps extends WithStyles < typeof styles > , WithLocale {
@@ -95,7 +94,9 @@ const UserControlContent: React.FC<UserControlProps> = ({classes, updateAccessTo
95
94
}
96
95
97
96
React . useEffect ( ( ) => {
98
- console . log ( "User changed:" , auth . user ) ;
97
+ if ( process . env . NODE_ENV === 'development' ) {
98
+ console . log ( "User changed:" , auth . user ) ;
99
+ }
99
100
if ( auth . user && auth . user . access_token ) {
100
101
updateAccessToken ( auth . user . access_token ) ;
101
102
} else {
@@ -166,57 +167,57 @@ const UserControlContent: React.FC<UserControlProps> = ({classes, updateAccessTo
166
167
avatar = < Avatar className = { classes . letterAvatar } > { avatarContent } </ Avatar > ;
167
168
}
168
169
return (
169
- < React . Fragment >
170
- < IconButton
171
- onClick = { handleUserMenuOpen }
172
- aria-controls = "user-menu"
173
- aria-haspopup = "true"
174
- size = "small"
175
- className = { classes . iconButton }
176
- >
177
- { avatar }
178
- </ IconButton >
179
- < Menu
180
- id = "user-menu"
181
- anchorEl = { userMenuAnchorEl }
182
- keepMounted
183
- open = { Boolean ( userMenuAnchorEl ) }
184
- onClose = { handleUserMenuClose }
185
- >
186
- < MenuItem onClick = { handleUserProfileMenuItemClicked } > { i18n . get ( 'Profile' ) } </ MenuItem >
187
- < MenuItem onClick = { handleSignOutMenuItemClicked } > { i18n . get ( 'Log out' ) } </ MenuItem >
188
- </ Menu >
189
- < Dialog
190
- open = { profileDialogOpen }
191
- keepMounted
192
- onClose = { handleUserProfileDialogClose }
193
- aria-labelledby = "alert-dialog-slide-title"
194
- aria-describedby = "alert-dialog-slide-description"
195
- >
196
- < DialogTitle id = "alert-dialog-slide-title" > { i18n . get ( 'User Profile' ) } </ DialogTitle >
197
- < DialogContent >
198
- < UserProfile userInfo = { auth . user . profile } />
199
- </ DialogContent >
200
- < DialogActions >
201
- < Button onClick = { handleUserProfileDialogClose } color = "primary" >
202
- OK
203
- </ Button >
204
- </ DialogActions >
205
- </ Dialog >
206
- </ React . Fragment >
170
+ < React . Fragment >
171
+ < IconButton
172
+ onClick = { handleUserMenuOpen }
173
+ aria-controls = "user-menu"
174
+ aria-haspopup = "true"
175
+ size = "small"
176
+ className = { classes . iconButton }
177
+ >
178
+ { avatar }
179
+ </ IconButton >
180
+ < Menu
181
+ id = "user-menu"
182
+ anchorEl = { userMenuAnchorEl }
183
+ keepMounted
184
+ open = { Boolean ( userMenuAnchorEl ) }
185
+ onClose = { handleUserMenuClose }
186
+ >
187
+ < MenuItem onClick = { handleUserProfileMenuItemClicked } > { i18n . get ( 'Profile' ) } </ MenuItem >
188
+ < MenuItem onClick = { handleSignOutMenuItemClicked } > { i18n . get ( 'Log out' ) } </ MenuItem >
189
+ </ Menu >
190
+ < Dialog
191
+ open = { profileDialogOpen }
192
+ keepMounted
193
+ onClose = { handleUserProfileDialogClose }
194
+ aria-labelledby = "alert-dialog-slide-title"
195
+ aria-describedby = "alert-dialog-slide-description"
196
+ >
197
+ < DialogTitle id = "alert-dialog-slide-title" > { i18n . get ( 'User Profile' ) } </ DialogTitle >
198
+ < DialogContent >
199
+ < UserProfile userInfo = { auth . user . profile } />
200
+ </ DialogContent >
201
+ < DialogActions >
202
+ < Button onClick = { handleUserProfileDialogClose } color = "primary" >
203
+ OK
204
+ </ Button >
205
+ </ DialogActions >
206
+ </ Dialog >
207
+ </ React . Fragment >
207
208
) ;
208
209
} else {
209
210
let userButton = (
210
- < IconButton onClick = { auth . isLoading ? undefined : handleSignInButtonClicked } size = "small" >
211
- < PersonIcon />
212
- </ IconButton >
211
+ < IconButton onClick = { auth . isLoading ? undefined : handleSignInButtonClicked } size = "small" >
212
+ < PersonIcon />
213
+ </ IconButton >
213
214
) ;
214
215
if ( auth . isLoading ) {
215
216
userButton = (
216
- < div className = { classes . signInWrapper } >
217
- { userButton }
218
- < CircularProgress size = { 24 } className = { classes . signInProgress } />
219
- </ div >
217
+ < div className = { classes . signInWrapper } >
218
+ { userButton }
219
+ < CircularProgress size = { 24 } className = { classes . signInProgress } />
220
+ </ div >
220
221
) ;
221
222
}
222
223
return userButton ;
0 commit comments