Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: add spinner to SignIn/SignUp button (#10814)

Liu Jif68ef3e73d0a
diff --git a/frontend/src/views/auth/Signin.vue b/frontend/src/views/auth/Signin.vue
index 0ceb9be97e..0c29066d59 100644
--- a/frontend/src/views/auth/Signin.vue
+++ b/frontend/src/views/auth/Signin.vue
@@ -88,6 +88,7 @@
attr-type="submit"
type="primary"
:disabled="!allowSignin()"
+ :loading="state.isLoading"
size="large"
style="width: 100%"
>
@@ -195,6 +196,7 @@
type="primary"
size="large"
:disabled="!allowSignin(identityProvider.name)"
+ :loading="state.isLoading"
style="width: 100%"
>
{{ $t("common.sign-in") }}
@@ -260,6 +262,7 @@ interface LocalState {
email: string;
password: string;
showPassword: boolean;
+ isLoading: boolean;
}
const router = useRouter();
@@ -272,6 +275,7 @@ const state = reactive<LocalState>({
email: "",
password: "",
showPassword: false,
+ isLoading: false,
});
const { isDemo, disallowSignup } = storeToRefs(actuatorStore);
@@ -319,22 +323,28 @@ const allowSignin = (idpName?: string) => {
};
const trySignin = async (idpName?: string) => {
- const mfaTempToken = await authStore.login({
- email: state.email,
- password: state.password,
- web: true,
- idpName: idpName,
- });
- if (mfaTempToken) {
- router.push({
- name: AUTH_MFA_MODULE,
- query: {
- mfaTempToken,
- redirect: route.query.redirect as string,
- },
+ if (state.isLoading) return;
+ state.isLoading = true;
+ try {
+ const mfaTempToken = await authStore.login({
+ email: state.email,
+ password: state.password,
+ web: true,
+ idpName: idpName,
});
- } else {
- router.push("/");
+ if (mfaTempToken) {
+ router.push({
+ name: AUTH_MFA_MODULE,
+ query: {
+ mfaTempToken,
+ redirect: route.query.redirect as string,
+ },
+ });
+ } else {
+ router.push("/");
+ }
+ } finally {
+ state.isLoading = false;
}
};
diff --git a/frontend/src/views/auth/Signup.vue b/frontend/src/views/auth/Signup.vue
index 466702ef18..1b531b17f0 100644
--- a/frontend/src/views/auth/Signup.vue
+++ b/frontend/src/views/auth/Signup.vue
@@ -178,6 +178,7 @@
type="primary"
size="large"
:disabled="!allowSignup"
+ :loading="state.isLoading"
style="width: 100%"
>
{{
@@ -233,6 +234,7 @@ interface LocalState {
nameManuallyEdited: boolean;
acceptTermsAndPolicy: boolean;
showPassword: boolean;
+ isLoading: boolean;
}
const actuatorStore = useActuatorV1Store();
@@ -247,6 +249,7 @@ const state = reactive<LocalState>({
nameManuallyEdited: false,
acceptTermsAndPolicy: true,
showPassword: false,
+ isLoading: false,
});
onUnmounted(() => {
@@ -328,24 +331,32 @@ const onTextName = () => {
};
const trySignup = async () => {
+ if (state.isLoading) return;
+
if (!passwordMatch.value) {
state.showPasswordMismatchError = true;
} else {
- const signupInfo: SignupInfo = {
- email: state.email,
- password: state.password,
- name: state.name,
- };
- await useAuthStore().signup(signupInfo);
- if (needAdminSetup.value) {
- await actuatorStore.fetchServerInfo();
- // When the first time we created an end user, the server-side will
- // generate onboarding data.
- // We write a flag here to indicate that the workspace is just created
- // and we can consume this flag somewhere else if needed.
- useOnboardingStateStore().initialize();
+ state.isLoading = true;
+
+ try {
+ const signupInfo: SignupInfo = {
+ email: state.email,
+ password: state.password,
+ name: state.name,
+ };
+ await useAuthStore().signup(signupInfo);
+ if (needAdminSetup.value) {
+ await actuatorStore.fetchServerInfo();
+ // When the first time we created an end user, the server-side will
+ // generate onboarding data.
+ // We write a flag here to indicate that the workspace is just created
+ // and we can consume this flag somewhere else if needed.
+ useOnboardingStateStore().initialize();
+ }
+ router.replace("/");
+ } finally {
+ state.isLoading = false;
}
- router.replace("/");
}
};
</script>