@@ -10,6 +10,8 @@ import type { AuthTokenOptions } from '../types';
10
10
import { openExternalLink } from '../utils/comms' ;
11
11
import { Constants } from '../utils/constants' ;
12
12
13
+ import { format } from 'date-fns' ;
14
+
13
15
interface IValues {
14
16
token ?: string ;
15
17
hostname ?: string ;
@@ -53,40 +55,46 @@ export const LoginWithToken: FC = () => {
53
55
const renderForm = ( formProps : FormRenderProps ) => {
54
56
const { handleSubmit, submitting, pristine, values } = formProps ;
55
57
58
+ const buttonClasses =
59
+ 'rounded bg-gray-300 font-semibold rounded text-sm text-center hover:bg-gray-500 hover:text-white dark:text-black focus:outline-none cursor-pointer' ;
60
+
56
61
return (
57
62
< form onSubmit = { handleSubmit } >
58
63
< FieldInput
59
64
name = "token"
60
65
label = "Token"
61
66
placeholder = "The 40 characters token generated on GitHub"
62
67
helpText = {
63
- < >
64
- To generate a token, go to GitHub,{ ' ' }
65
- < button
66
- type = "button"
67
- className = "underline hover:text-gray-500 dark:hover:text-gray-300 cursor-pointer"
68
- onClick = { ( ) =>
69
- openLink (
70
- 'https://github.com/settings/tokens/new?scopes=notifications,read:user,repo&description=gitify_token' ,
71
- )
72
- }
73
- >
74
- personal access tokens
75
- </ button > { ' ' }
76
- and create one with the { Constants . AUTH_SCOPE . length } scopes{ ' ' }
77
- < span className = "underline font-extrabold text-yellow-500" >
78
- { Constants . AUTH_SCOPE . join ( ', ' ) } { ' ' }
79
- </ span >
80
- .
81
- </ >
68
+ < div >
69
+ < div >
70
+ Create a Personal Access Token on GitHub and paste above.
71
+ </ div >
72
+ < div >
73
+ The required scopes will be selected for you.{ ' ' }
74
+ < button
75
+ type = "button"
76
+ className = { `px-2 py-1 my-2 text-xs ${ buttonClasses } ` }
77
+ onClick = { ( ) => openLink ( getNewTokenURL ( ) ) }
78
+ >
79
+ Generate a PAT
80
+ </ button >
81
+ </ div >
82
+ </ div >
82
83
}
83
84
/>
84
85
85
86
< FieldInput
86
87
name = "hostname"
87
88
label = "Hostname"
88
89
placeholder = "github.202132.xyzpany.com"
89
- helpText = "Defaults to github.com. Change only if you are using GitHub for Enterprise."
90
+ helpText = {
91
+ < div >
92
+ < div > Defaults to github.com.</ div >
93
+ < div className = "italic" >
94
+ Change only if you are using GitHub Enterprise Server.
95
+ </ div >
96
+ </ div >
97
+ }
90
98
/>
91
99
92
100
{ ! isValidToken && (
@@ -96,7 +104,7 @@ export const LoginWithToken: FC = () => {
96
104
) }
97
105
98
106
< button
99
- className = " float-right px-4 py-2 my-4 bg-gray-300 font-semibold rounded text-sm text-center hover:bg-gray-500 hover:text-white dark:text-black focus:outline-none"
107
+ className = { ` float-right px-4 py-2 my-4 ${ buttonClasses } ` }
100
108
title = "Submit Button"
101
109
disabled = { submitting || pristine }
102
110
type = "submit"
@@ -134,7 +142,7 @@ export const LoginWithToken: FC = () => {
134
142
</ button >
135
143
136
144
< h3 className = "text-lg font-semibold" >
137
- Login with personal access token
145
+ Login with Personal Access Token
138
146
</ h3 >
139
147
</ div >
140
148
@@ -153,3 +161,12 @@ export const LoginWithToken: FC = () => {
153
161
</ div >
154
162
) ;
155
163
} ;
164
+
165
+ function getNewTokenURL ( ) : string {
166
+ const date = format ( new Date ( ) , 'PP p' ) ;
167
+ const newTokenURL = new URL ( 'https://github.com/settings/tokens/new' ) ;
168
+ newTokenURL . searchParams . append ( 'description' , `Gitify (Created on ${ date } )` ) ;
169
+ newTokenURL . searchParams . append ( 'scopes' , Constants . AUTH_SCOPE . join ( ',' ) ) ;
170
+
171
+ return newTokenURL . toString ( ) ;
172
+ }
0 commit comments