Skip to content

Commit 61b8678

Browse files
committed
feat: loading indicators
Signed-off-by: Adam Setch <[email protected]>
1 parent 9e9c047 commit 61b8678

File tree

4 files changed

+165
-132
lines changed

4 files changed

+165
-132
lines changed

src/renderer/routes/LoginWithOAuthApp.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export const LoginWithOAuthAppRoute: FC = () => {
7878
const { loginWithOAuthApp } = useContext(AppContext);
7979

8080
const [maskToken, setMaskToken] = useState(true);
81+
const [isVerifyingCredentials, setIsVerifyingCredentials] = useState(false);
8182

8283
const [formData, setFormData] = useState({
8384
hostname: 'github.com' as Hostname,
@@ -92,13 +93,16 @@ export const LoginWithOAuthAppRoute: FC = () => {
9293
}, [errors]);
9394

9495
const handleSubmit = async () => {
96+
setIsVerifyingCredentials(true);
97+
9598
const newErrors = validateForm(formData);
9699

97100
setErrors(newErrors);
98101

99102
if (!newErrors.hostname && !newErrors.clientId && !newErrors.clientSecret) {
100103
verifyLoginCredentials(formData);
101104
}
105+
setIsVerifyingCredentials(false);
102106
};
103107

104108
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
@@ -249,6 +253,7 @@ export const LoginWithOAuthAppRoute: FC = () => {
249253
variant="primary"
250254
leadingVisual={SignInIcon}
251255
onClick={handleSubmit}
256+
loading={isVerifyingCredentials}
252257
data-testid="login-submit"
253258
>
254259
Login

src/renderer/routes/LoginWithPersonalAccessToken.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export const LoginWithPersonalAccessTokenRoute: FC = () => {
7070
const { loginWithPersonalAccessToken } = useContext(AppContext);
7171

7272
const [maskClientSecret, setMaskClientSecret] = useState(true);
73+
const [isVerifyingCredentials, setIsVerifyingCredentials] = useState(false);
7374

7475
const [formData, setFormData] = useState({
7576
hostname: 'github.com' as Hostname,
@@ -83,13 +84,15 @@ export const LoginWithPersonalAccessTokenRoute: FC = () => {
8384
}, [errors]);
8485

8586
const handleSubmit = async () => {
87+
setIsVerifyingCredentials(true);
8688
const newErrors = validateForm(formData);
8789

8890
setErrors(newErrors);
8991

9092
if (!newErrors.hostname && !newErrors.token) {
9193
verifyLoginCredentials(formData);
9294
}
95+
setIsVerifyingCredentials(false);
9396
};
9497

9598
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
@@ -240,6 +243,7 @@ export const LoginWithPersonalAccessTokenRoute: FC = () => {
240243
variant="primary"
241244
leadingVisual={SignInIcon}
242245
onClick={handleSubmit}
246+
loading={isVerifyingCredentials}
243247
data-testid="login-submit"
244248
>
245249
Login

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

+78-66
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)