Skip to content

Commit 9b5ee0a

Browse files
authored
fix(config-ui): remove redirect offline when api throw a error (#5547)
1 parent 958d62f commit 9b5ee0a

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

config-ui/src/layouts/base/base.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717
*/
1818

1919
import React from 'react';
20-
import { useLocation } from 'react-router-dom';
20+
import { useHistory, useLocation } from 'react-router-dom';
2121
import { Menu, MenuItem, Tag, Navbar, Intent, Alignment, Button } from '@blueprintjs/core';
2222

2323
import { PageLoading, Logo, ExternalLink } from '@/components';
2424
import { useRefreshData } from '@/hooks';
25-
import { history } from '@/utils/history';
2625

2726
import DashboardIcon from '@/images/icons/dashborad.svg';
2827
import FileIcon from '@/images/icons/file.svg';
@@ -39,10 +38,11 @@ interface Props {
3938
}
4039

4140
export const BaseLayout = ({ children }: Props) => {
42-
const menu = useMenu();
41+
const history = useHistory();
4342
const { pathname } = useLocation();
4443

45-
const { ready, data } = useRefreshData<{ version: string }>(() => API.getVersion(), []);
44+
const menu = useMenu();
45+
const { ready, data, error } = useRefreshData<{ version: string }>(() => API.getVersion(), []);
4646

4747
const token = window.localStorage.getItem('accessToken');
4848

@@ -66,6 +66,10 @@ export const BaseLayout = ({ children }: Props) => {
6666
return import.meta.env.DEV ? `${protocol}//${hostname}:3002${suffix}` : `/grafana${suffix}`;
6767
};
6868

69+
if (error) {
70+
history.push('/offline');
71+
}
72+
6973
if (!ready || !data) {
7074
return <PageLoading />;
7175
}

config-ui/src/utils/request.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ instance.interceptors.response.use(
4343
history.push('/db-migrate');
4444
}
4545

46-
if (status === 500) {
47-
history.push('/offline');
48-
}
49-
5046
return Promise.reject(error);
5147
},
5248
);

0 commit comments

Comments
 (0)