@@ -26,37 +26,43 @@ import AccountBoxIcon from '@mui/icons-material/AccountBox';
26
26
import { UserSettingsRoutes } from 'openvsx-webui' ;
27
27
import { MainContext } from 'openvsx-webui/lib/context' ;
28
28
import { MobileMenuItem , itemIcon , MobileMenuItemText , MobileUserAvatar , headerItem , MenuLink , MenuRouteLink } from 'openvsx-webui/lib/default/menu-content'
29
+ import { LoginComponent } from 'openvsx-webui/lib/default/login'
29
30
import { UserAvatar } from 'openvsx-webui/lib/pages/user/avatar' ;
30
31
31
32
//-------------------- Mobile View --------------------//
32
33
33
34
export const MobileMenuContent : FunctionComponent = ( ) => {
34
- const { service , user } = useContext ( MainContext )
35
+ const { user , loginProviders } = useContext ( MainContext )
35
36
return < >
36
- {
37
- user
38
- ? < MobileUserAvatar />
39
- : < MobileMenuItem >
40
- < Link href = { service . getLoginUrl ( ) } >
41
- < MobileMenuItemText >
42
- < AccountBoxIcon sx = { itemIcon } />
43
- Log In
44
- </ MobileMenuItemText >
45
- </ Link >
37
+ { loginProviders && (
38
+ user ? (
39
+ < MobileUserAvatar />
40
+ ) : (
41
+ < MobileMenuItem >
42
+ < LoginComponent
43
+ loginProviders = { loginProviders }
44
+ renderButton = { ( href , onClick ) => {
45
+ return ( < Link href = { href } onClick = { onClick } >
46
+ < MobileMenuItemText >
47
+ < AccountBoxIcon sx = { itemIcon } />
48
+ Log In
49
+ </ MobileMenuItemText >
50
+ </ Link > ) ;
51
+ } }
52
+ />
46
53
</ MobileMenuItem >
47
- }
48
- {
49
- ! location . pathname . startsWith ( UserSettingsRoutes . ROOT )
50
- ? < MobileMenuItem >
54
+ )
55
+ ) }
56
+ { loginProviders && ! location . pathname . startsWith ( UserSettingsRoutes . ROOT ) && (
57
+ < MobileMenuItem >
51
58
< RouteLink to = '/user-settings/extensions' >
52
59
< MobileMenuItemText >
53
60
< PublishIcon sx = { itemIcon } />
54
61
Publish Extension
55
62
</ MobileMenuItemText >
56
63
</ RouteLink >
57
64
</ MobileMenuItem >
58
- : null
59
- }
65
+ ) }
60
66
< MobileMenuItem >
61
67
< Link target = '_blank' href = 'https://github.com/eclipse/openvsx' >
62
68
< MobileMenuItemText >
@@ -156,7 +162,7 @@ const SubMenuLink = styled(Link)(subMenuLink);
156
162
157
163
158
164
export const DefaultMenuContent : FunctionComponent = ( ) => {
159
- const { service , user} = useContext ( MainContext )
165
+ const { loginProviders , user} = useContext ( MainContext )
160
166
const [ workingGroupMenuOpen , setWorkingGroupMenuOpen ] = useState ( false ) ;
161
167
const workingGroupMenuEl = useRef < HTMLButtonElement | null > ( null ) ;
162
168
const toggleWorkingGroupMenu = ( ) => setWorkingGroupMenuOpen ( ! workingGroupMenuOpen ) ;
@@ -191,16 +197,37 @@ export const DefaultMenuContent: FunctionComponent = () => {
191
197
< Button variant = 'contained' color = 'secondary' href = '/user-settings/extensions' sx = { { mx : 2.5 } } >
192
198
Publish
193
199
</ Button >
194
- {
195
- user ?
196
- < UserAvatar />
197
- :
198
- < IconButton
199
- href = { service . getLoginUrl ( ) }
200
- title = 'Log In'
201
- aria-label = 'Log In' >
202
- < AccountBoxIcon />
203
- </ IconButton >
204
- }
200
+ { loginProviders && (
201
+ < >
202
+ < Button variant = 'contained' color = 'secondary' href = '/user-settings/extensions' sx = { { mx : 2.5 } } >
203
+ Publish
204
+ </ Button >
205
+ {
206
+ user ?
207
+ < UserAvatar />
208
+ :
209
+ < LoginComponent
210
+ loginProviders = { loginProviders }
211
+ renderButton = { ( href , onClick ) => {
212
+ if ( href ) {
213
+ return ( < IconButton
214
+ href = { href }
215
+ title = 'Log In'
216
+ aria-label = 'Log In' >
217
+ < AccountBoxIcon />
218
+ </ IconButton > ) ;
219
+ } else {
220
+ return ( < IconButton
221
+ onClick = { onClick }
222
+ title = 'Log In'
223
+ aria-label = 'Log In' >
224
+ < AccountBoxIcon />
225
+ </ IconButton > ) ;
226
+ }
227
+ } }
228
+ />
229
+ }
230
+ </ >
231
+ ) }
205
232
</ > ;
206
233
}
0 commit comments