Skip to content

Commit 2e1a889

Browse files
committed
refactor: migrate to text inputs to primer
Signed-off-by: Adam Setch <[email protected]>
1 parent ec27b09 commit 2e1a889

File tree

4 files changed

+132
-28
lines changed

4 files changed

+132
-28
lines changed

src/renderer/routes/LoginWithOAuthApp.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { type FC, useCallback, useContext, useMemo, useState } from 'react';
22
import { useNavigate } from 'react-router-dom';
33

4-
import { BookIcon, PersonIcon, SignInIcon } from '@primer/octicons-react';
4+
import {
5+
BookIcon,
6+
EyeClosedIcon,
7+
EyeIcon,
8+
PersonIcon,
9+
SignInIcon,
10+
} from '@primer/octicons-react';
511
import {
612
Button,
713
FormControl,
@@ -73,6 +79,8 @@ export const LoginWithOAuthAppRoute: FC = () => {
7379

7480
const { loginWithOAuthApp } = useContext(AppContext);
7581

82+
const [maskToken, setMaskToken] = useState(true);
83+
7684
const [formData, setFormData] = useState({
7785
hostname: 'github.com' as Hostname,
7886
clientId: '' as ClientID,
@@ -178,14 +186,14 @@ export const LoginWithOAuthAppRoute: FC = () => {
178186
Create new OAuth App
179187
</Button>
180188
<Text className="text-xs">
181-
and use your <Text as="i">client id/secret</Text> below.
189+
and use your <Text as="i">client id & secret</Text> below.
182190
</Text>
183191
</Stack>
184192
<FormControl required>
185193
<FormControl.Label>Client ID</FormControl.Label>
186194
<TextInput
187195
name="clientId"
188-
placeholder="The 20 character Client ID as generated on GitHub"
196+
placeholder="Your generated client id (20 characters)"
189197
value={formData.clientId}
190198
onChange={handleInputChange}
191199
aria-invalid={errors.clientId ? 'true' : 'false'}
@@ -202,7 +210,8 @@ export const LoginWithOAuthAppRoute: FC = () => {
202210
<FormControl.Label>Client Secret</FormControl.Label>
203211
<TextInput
204212
name="clientSecret"
205-
placeholder="The 40 character Client Secret as generated on GitHub"
213+
type={maskToken ? 'password' : 'text'}
214+
placeholder="Your generated client secret (40 characters)"
206215
value={formData.clientSecret}
207216
onChange={handleInputChange}
208217
aria-invalid={errors.clientSecret ? 'true' : 'false'}
@@ -211,6 +220,13 @@ export const LoginWithOAuthAppRoute: FC = () => {
211220
? 'danger.emphasis'
212221
: 'border.default',
213222
}}
223+
trailingAction={
224+
<TextInput.Action
225+
onClick={() => setMaskToken(!maskToken)}
226+
icon={maskToken ? EyeIcon : EyeClosedIcon}
227+
aria-label={maskToken ? 'Show token' : 'Hide token'}
228+
/>
229+
}
214230
data-testid="login-clientSecret"
215231
block
216232
/>

src/renderer/routes/LoginWithPersonalAccessToken.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const LoginWithPersonalAccessTokenRoute: FC = () => {
6969

7070
const { loginWithPersonalAccessToken } = useContext(AppContext);
7171

72-
const [showPassword, setShowPassword] = useState(false);
72+
const [maskClientSecret, setMaskClientSecret] = useState(true);
7373

7474
const [formData, setFormData] = useState({
7575
hostname: 'github.com' as Hostname,
@@ -199,8 +199,8 @@ export const LoginWithPersonalAccessTokenRoute: FC = () => {
199199
<FormControl.Label>Token</FormControl.Label>
200200
<TextInput
201201
name="token"
202-
type={showPassword ? 'text' : 'password'}
203-
placeholder="The 40 character token as generated on GitHub"
202+
type={maskClientSecret ? 'password' : 'text'}
203+
placeholder="Your generated token (40 characters)"
204204
value={formData.token}
205205
onChange={handleInputChange}
206206
aria-invalid={errors.token ? 'true' : 'false'}
@@ -211,9 +211,9 @@ export const LoginWithPersonalAccessTokenRoute: FC = () => {
211211
}}
212212
trailingAction={
213213
<TextInput.Action
214-
onClick={() => setShowPassword(!showPassword)}
215-
icon={showPassword ? EyeClosedIcon : EyeIcon}
216-
aria-label={showPassword ? 'Hide token' : 'Show token'}
214+
onClick={() => setMaskClientSecret(!maskClientSecret)}
215+
icon={maskClientSecret ? EyeIcon : EyeClosedIcon}
216+
aria-label={maskClientSecret ? 'Show token' : 'Hide token'}
217217
/>
218218
}
219219
data-testid="login-token"

src/renderer/routes/__snapshots__/LoginWithOAuthApp.test.tsx.snap

Lines changed: 104 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer/routes/__snapshots__/LoginWithPersonalAccessToken.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)