Skip to content

Commit 307fb4f

Browse files
refactor(Header): remove unneeded getClusterInfo request
1 parent 83501b5 commit 307fb4f

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

src/containers/Header/Header.tsx

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import React, {useEffect} from 'react';
2-
import {useDispatch, useSelector} from 'react-redux';
2+
import {useDispatch} from 'react-redux';
33
import cn from 'bem-cn-lite';
4-
import {useHistory, useLocation} from 'react-router';
4+
import {useHistory} from 'react-router';
55
import {Breadcrumbs, BreadcrumbsItem, Link} from '@gravity-ui/uikit';
66

77
import Divider from '../../components/Divider/Divider';
88
import {Icon} from '../../components/Icon';
99

10-
import {clusterName as clusterNameLocation, backend, customBackend} from '../../store';
11-
import {getClusterInfo} from '../../store/reducers/cluster/cluster';
10+
import {backend, customBackend} from '../../store';
1211
import {getHostInfo} from '../../store/reducers/host';
1312
import {HeaderItemType} from '../../store/reducers/header';
13+
import {useTypedSelector} from '../../utils/hooks';
1414

1515
import './Header.scss';
1616

@@ -31,26 +31,19 @@ interface HeaderProps {
3131

3232
function Header({clusterName}: HeaderProps) {
3333
const dispatch = useDispatch();
34-
const {data: host}: {data: {ClusterName?: string}} = useSelector((state: any) => state.host);
34+
3535
const {singleClusterMode, header}: {singleClusterMode: boolean; header: HeaderItemType[]} =
36-
useSelector((state: any) => state);
36+
useTypedSelector((state) => state);
37+
const {data: host} = useTypedSelector((state) => state.host);
3738

38-
const location = useLocation();
3939
const history = useHistory();
4040

41-
const {pathname} = location;
42-
4341
useEffect(() => {
44-
const isClustersPage = pathname.includes('/clusters');
45-
46-
if (!isClustersPage && !clusterName && !singleClusterMode) {
47-
dispatch(getClusterInfo(clusterNameLocation));
48-
}
4942
dispatch(getHostInfo());
50-
}, []);
43+
}, [dispatch]);
5144

5245
const renderHeader = () => {
53-
const clusterNameFinal = singleClusterMode ? host.ClusterName : clusterName;
46+
const clusterNameFinal = singleClusterMode ? host?.ClusterName : clusterName;
5447

5548
let link = backend + '/internal';
5649

0 commit comments

Comments
 (0)