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

mintsweet pushed a commit to branch release-v0.17
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/release-v0.17 by this push:
     new 9b5ee0a50 fix(config-ui): remove redirect offline when api throw a 
error (#5547)
9b5ee0a50 is described below

commit 9b5ee0a50a1cdcc261cfbf31a30e2ff44dc47583
Author: 青湛 <[email protected]>
AuthorDate: Wed Jun 21 14:05:02 2023 +0800

    fix(config-ui): remove redirect offline when api throw a error (#5547)
---
 config-ui/src/layouts/base/base.tsx | 12 ++++++++----
 config-ui/src/utils/request.ts      |  4 ----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/config-ui/src/layouts/base/base.tsx 
b/config-ui/src/layouts/base/base.tsx
index 5ee3cfa43..9cfdc1039 100644
--- a/config-ui/src/layouts/base/base.tsx
+++ b/config-ui/src/layouts/base/base.tsx
@@ -17,12 +17,11 @@
  */
 
 import React from 'react';
-import { useLocation } from 'react-router-dom';
+import { useHistory, useLocation } from 'react-router-dom';
 import { Menu, MenuItem, Tag, Navbar, Intent, Alignment, Button } from 
'@blueprintjs/core';
 
 import { PageLoading, Logo, ExternalLink } from '@/components';
 import { useRefreshData } from '@/hooks';
-import { history } from '@/utils/history';
 
 import DashboardIcon from '@/images/icons/dashborad.svg';
 import FileIcon from '@/images/icons/file.svg';
@@ -39,10 +38,11 @@ interface Props {
 }
 
 export const BaseLayout = ({ children }: Props) => {
-  const menu = useMenu();
+  const history = useHistory();
   const { pathname } = useLocation();
 
-  const { ready, data } = useRefreshData<{ version: string }>(() => 
API.getVersion(), []);
+  const menu = useMenu();
+  const { ready, data, error } = useRefreshData<{ version: string }>(() => 
API.getVersion(), []);
 
   const token = window.localStorage.getItem('accessToken');
 
@@ -66,6 +66,10 @@ export const BaseLayout = ({ children }: Props) => {
     return import.meta.env.DEV ? `${protocol}//${hostname}:3002${suffix}` : 
`/grafana${suffix}`;
   };
 
+  if (error) {
+    history.push('/offline');
+  }
+
   if (!ready || !data) {
     return <PageLoading />;
   }
diff --git a/config-ui/src/utils/request.ts b/config-ui/src/utils/request.ts
index 388236481..14afa85a7 100644
--- a/config-ui/src/utils/request.ts
+++ b/config-ui/src/utils/request.ts
@@ -43,10 +43,6 @@ instance.interceptors.response.use(
       history.push('/db-migrate');
     }
 
-    if (status === 500) {
-      history.push('/offline');
-    }
-
     return Promise.reject(error);
   },
 );

Reply via email to