This is an automated email from the ASF dual-hosted git repository.

jiafengzheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris-manager.git


The following commit(s) were added to refs/heads/master by this push:
     new b623bf0  [fix] fix cannot redirect to the step page after refreshing 
the initialization page (#7)
b623bf0 is described below

commit b623bf02e64a05687a76add5fbfbba316d0de402
Author: zhengbowen <[email protected]>
AuthorDate: Mon Mar 21 10:42:36 2022 +0800

    [fix] fix cannot redirect to the step page after refreshing the 
initialization page (#7)
    
    fix cannot redirect to the step page after refreshing the initialization 
page
---
 frontend/src/hooks/use-auth.ts                      | 11 +++++++----
 frontend/src/routes/initialize/initialize.route.tsx | 10 +++++-----
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/frontend/src/hooks/use-auth.ts b/frontend/src/hooks/use-auth.ts
index b50fa06..956423f 100644
--- a/frontend/src/hooks/use-auth.ts
+++ b/frontend/src/hooks/use-auth.ts
@@ -18,10 +18,11 @@
 import { InitializeAPI } from '@src/routes/initialize/initialize.api';
 import { isSuccess } from '@src/utils/http';
 import { useEffect, useState } from 'react';
-import { useHistory } from 'react-router';
+import { useHistory, useLocation } from 'react-router';
 
 export function useAuth() {
     const [initialized, setInitialized] = useState(false);
+    const { pathname } = useLocation();
     const history = useHistory();
     const [initStep, setInitStep] = useState(0);
     const [authType, setAuthType] = useState();
@@ -40,7 +41,9 @@ export function useAuth() {
             } else {
                 localStorage.setItem('initialized', 'false');
                 setInitialized(false);
-                history.push('/initialize');
+                if (!pathname.includes('/initialize')) {
+                    history.push('/initialize');
+                }
             }
         }
     }
@@ -49,5 +52,5 @@ export function useAuth() {
         initStep,
         authType,
         getInitProperties,
-    }
-}
\ No newline at end of file
+    };
+}
diff --git a/frontend/src/routes/initialize/initialize.route.tsx 
b/frontend/src/routes/initialize/initialize.route.tsx
index d131288..25a0a8a 100644
--- a/frontend/src/routes/initialize/initialize.route.tsx
+++ b/frontend/src/routes/initialize/initialize.route.tsx
@@ -28,7 +28,7 @@ import styles from './initialize.less';
 export function Initialize(props: any) {
     const match = useRouteMatch();
     const history = useHistory();
-    const {initStep, authType: currentAuthType, initialized} = useAuth();
+    const { initStep, authType: currentAuthType, initialized } = useAuth();
 
     useEffect(() => {
         if (currentAuthType && initStep) {
@@ -36,7 +36,7 @@ export function Initialize(props: any) {
             let stepPage = '';
             if (currentAuthType === AuthTypeEnum.STUDIO) {
                 stepPage = StudioStepsEnum[feStep];
-            } else if (currentAuthType === AuthTypeEnum.LDAP){
+            } else if (currentAuthType === AuthTypeEnum.LDAP) {
                 stepPage = LDAPStepsEnum[feStep];
             }
             if (initialized) {
@@ -45,7 +45,7 @@ export function Initialize(props: any) {
                     if (feStep === 1) {
                         history.push('/space');
                     }
-                } else if (currentAuthType === AuthTypeEnum.LDAP){
+                } else if (currentAuthType === AuthTypeEnum.LDAP) {
                     stepPage = LDAPStepsEnum[feStep];
                     if (feStep === 2) {
                         history.push('/space');
@@ -55,11 +55,11 @@ export function Initialize(props: any) {
                 
history.push(`${match.path}/auth/${currentAuthType}/${stepPage}`);
             }
         }
-    }, [currentAuthType, initialized]);
+    }, [currentAuthType, initialized, initStep]);
     return (
         <div>
             <Sidebar mode="initialize" />
-            <div style={{marginLeft: 80}}>
+            <div style={{ marginLeft: 80 }}>
                 <div className={styles['initialize-container']}>
                     <Switch>
                         <Route exact path={`${match.path}/`} 
component={InitializePage} />

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to