1
1
import {
2
2
FeedPersonIcon ,
3
3
KeyIcon ,
4
+ MarkGithubIcon ,
4
5
PersonIcon ,
5
6
PlusIcon ,
6
7
SignOutIcon ,
@@ -9,6 +10,7 @@ import {
9
10
SyncIcon ,
10
11
} from '@primer/octicons-react' ;
11
12
13
+ import log from 'electron-log' ;
12
14
import { type FC , useCallback , useContext } from 'react' ;
13
15
import { useNavigate } from 'react-router-dom' ;
14
16
import { Header } from '../components/Header' ;
@@ -29,7 +31,8 @@ import {
29
31
import { saveState } from '../utils/storage' ;
30
32
31
33
export const AccountsRoute : FC = ( ) => {
32
- const { auth, settings, logoutFromAccount } = useContext ( AppContext ) ;
34
+ const { auth, settings, loginWithGitHubApp, logoutFromAccount } =
35
+ useContext ( AppContext ) ;
33
36
const navigate = useNavigate ( ) ;
34
37
35
38
const logoutAccount = useCallback (
@@ -48,6 +51,14 @@ export const AccountsRoute: FC = () => {
48
51
navigate ( '/accounts' , { replace : true } ) ;
49
52
} , [ ] ) ;
50
53
54
+ const loginWithGitHub = useCallback ( async ( ) => {
55
+ try {
56
+ await loginWithGitHubApp ( ) ;
57
+ } catch ( err ) {
58
+ log . error ( 'Auth: failed to login with GitHub' , err ) ;
59
+ }
60
+ } , [ ] ) ;
61
+
51
62
const loginWithPersonalAccessToken = useCallback ( ( ) => {
52
63
return navigate ( '/login-personal-access-token' , { replace : true } ) ;
53
64
} , [ ] ) ;
@@ -97,7 +108,7 @@ export const AccountsRoute: FC = () => {
97
108
onClick = { ( ) => openHost ( account . hostname ) }
98
109
>
99
110
< PlatformIcon type = { account . platform } size = { Size . XSMALL } />
100
- { account . platform } - { account . hostname }
111
+ { account . hostname }
101
112
</ button >
102
113
</ div >
103
114
< div >
@@ -172,6 +183,18 @@ export const AccountsRoute: FC = () => {
172
183
< div className = "flex items-center justify-between bg-gray-200 px-8 py-1 text-sm dark:bg-gray-darker" >
173
184
< div className = "font-semibold italic" > Add new account</ div >
174
185
< div >
186
+ < button
187
+ type = "button"
188
+ className = { BUTTON_CLASS_NAME }
189
+ title = "Login with GitHub App"
190
+ onClick = { loginWithGitHub }
191
+ >
192
+ < MarkGithubIcon
193
+ size = { Size . LARGE }
194
+ aria-label = "Login with GitHub App"
195
+ />
196
+ < PlusIcon size = { Size . SMALL } className = "mb-2 ml-1" />
197
+ </ button >
175
198
< button
176
199
type = "button"
177
200
className = { BUTTON_CLASS_NAME }
0 commit comments