From a0f44c5ac29df4c6dba2e0479af1a26dd5b8f0d9 Mon Sep 17 00:00:00 2001 From: Sachin Chaurasiya Date: Tue, 18 Oct 2022 17:47:39 +0530 Subject: [PATCH] Fix #8204 UI : While login just show the loader in login button. (#8205) * Fix #8204 UI : While login just show the loader in login button. * Addressing review comment --- .../auth-provider/basic-auth.provider.tsx | 4 --- .../ui/src/locale/languages/en-us.json | 8 +++++ .../resources/ui/src/pages/login/index.tsx | 33 +++++++++++-------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/authentication/auth-provider/basic-auth.provider.tsx b/openmetadata-ui/src/main/resources/ui/src/authentication/auth-provider/basic-auth.provider.tsx index c59f0ffd510..cde2e6030db 100644 --- a/openmetadata-ui/src/main/resources/ui/src/authentication/auth-provider/basic-auth.provider.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/authentication/auth-provider/basic-auth.provider.tsx @@ -82,12 +82,10 @@ const BasicAuthProvider = ({ }: BasicAuthProps) => { const { setLoadingIndicator } = useAuthContext(); const [loginError, setLoginError] = useState(null); - const history = useHistory(); const handleLogin = async (email: string, password: string) => { try { - setLoadingIndicator(true); setLoginError(null); try { const response = await basicAuthSignIn({ email, password }); @@ -118,8 +116,6 @@ const BasicAuthProvider = ({ err as AxiosError, jsonData['api-error-messages']['unauthorized-user'] ); - } finally { - setLoadingIndicator(false); } }; diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json index 8da9c32df5a..0e57b310179 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json @@ -10,6 +10,14 @@ "tags": "Tags", "settings": "Settings", "search-global": "Search for Tables, Topics, Dashboards, Pipelines and ML Models", + "om-description": "Centralized Metadata Store, Discover, Collaborate and get your Data Right", + "login": "Login", + "forgot-password": "Forgot Password", + "or-lowercase": "or", + "new-to-the-platform": "New to the platform?", + "create-account": "Create Account", + "username-or-email": "Username or Email", + "password": "Password", "success": "Success", "aborted": "Aborted", "failed": "Failed", diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/login/index.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/login/index.tsx index c32f37d3823..53801691bdc 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/login/index.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/login/index.tsx @@ -15,7 +15,8 @@ import { Button, Divider, Form, Input, Typography } from 'antd'; import classNames from 'classnames'; import jwtDecode, { JwtPayload } from 'jwt-decode'; import { observer } from 'mobx-react'; -import React, { useEffect, useMemo } from 'react'; +import React, { useEffect, useMemo, useState } from 'react'; +import { useTranslation } from 'react-i18next'; import { useHistory } from 'react-router-dom'; import loginBG from '../../assets/img/login-bg.png'; import { useAuthContext } from '../../authentication/auth-provider/AuthProvider'; @@ -31,6 +32,7 @@ import './login.style.less'; import LoginCarousel from './LoginCarousel'; const SigninPage = () => { + const [loading, setLoading] = useState(false); const [form] = Form.useForm(); const history = useHistory(); @@ -42,6 +44,8 @@ const SigninPage = () => { isAuthenticated, } = useAuthContext(); + const { t } = useTranslation(); + const { isAuthProviderBasic } = useMemo(() => { return { isAuthProviderBasic: authConfig?.provider === AuthTypes.BASIC, @@ -160,7 +164,9 @@ const SigninPage = () => { email: string; password: string; }) => { - handleLogin(email, password); + setLoading(true); + await Promise.resolve(handleLogin(email, password)); + setLoading(false); }; const onClickSignUp = () => history.push(ROUTES.REGISTER); @@ -179,8 +185,7 @@ const SigninPage = () => { })}> - Centralized Metadata Store, Discover, Collaborate and get your - Data Right + {t('label.om-description')}{' '} {isAuthProviderBasic ? ( @@ -193,27 +198,29 @@ const SigninPage = () => { onFinish={handleSubmit}> - + - + {loginError && ( @@ -237,7 +244,7 @@ const SigninPage = () => { )}
- Forgot Password + {t('label.forgot-password')}
@@ -245,20 +252,20 @@ const SigninPage = () => { <> - or + {t('label.or-lowercase')}
- New to the platform? + {t('label.new-to-the-platform')}