Skip to content

Commit c7967ff

Browse files
refactor(ClusterInfo): shape component types
1 parent 1d54db4 commit c7967ff

File tree

1 file changed

+11
-30
lines changed

1 file changed

+11
-30
lines changed

src/components/ClusterInfo/ClusterInfo.tsx

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {ReactNode} from 'react';
22
import cn from 'bem-cn-lite';
33
import {connect} from 'react-redux';
4+
import {Link, Loader} from '@gravity-ui/uikit';
45

56
//@ts-ignore
67
import EntityStatus from '../EntityStatus/EntityStatus';
@@ -23,41 +24,29 @@ import {clusterName, backend, customBackend} from '../../store';
2324
import {formatStorageValues} from '../../utils';
2425
//@ts-ignore
2526
import {TxAllocator} from '../../utils/constants';
26-
27-
import './ClusterInfo.scss';
2827
import {AutoFetcher} from '../../utils/autofetcher';
29-
import {Link, Loader} from '@gravity-ui/uikit';
3028
//@ts-ignore
3129
import Icon from '../Icon/Icon';
3230
import {setHeader} from '../../store/reducers/header';
3331
import routes, {CLUSTER_PAGES, createHref} from '../../routes';
3432

33+
import type {TClusterInfo} from '../../types/api/cluster';
34+
import type {TTabletStateInfo} from '../../types/api/tablet';
35+
36+
import './ClusterInfo.scss';
37+
3538
const b = cn('cluster-info');
3639

3740
export interface IClusterInfoItem {
3841
label: string;
3942
value: ReactNode;
4043
}
4144

42-
interface ICluster {
43-
StorageTotal: string;
44-
StorageUsed: string;
45-
NodesAlive: number;
46-
NodesTotal: number;
47-
LoadAverage: number;
48-
NumberOfCpus: number;
49-
Versions: string[];
50-
Name?: string;
51-
Overall: string;
52-
DataCenters?: string[];
53-
SystemTablets?: ITablet[];
54-
}
55-
5645
interface ClusterInfoProps {
5746
className?: string;
58-
cluster?: ICluster;
47+
cluster?: TClusterInfo;
5948
hideTooltip: VoidFunction;
60-
showTooltip: Function;
49+
showTooltip: (...args: Parameters<typeof showTooltip>) => void;
6150
setHeader: any;
6251
getClusterInfo: (clusterName: string) => void;
6352
clusterTitle?: string;
@@ -68,12 +57,8 @@ interface ClusterInfoProps {
6857
error?: {statusText: string};
6958
}
7059

71-
interface ITablet {
72-
Type: string;
73-
}
74-
7560
class ClusterInfo extends React.Component<ClusterInfoProps> {
76-
static compareTablets(tablet1: ITablet, tablet2: ITablet) {
61+
static compareTablets(tablet1: TTabletStateInfo, tablet2: TTabletStateInfo) {
7762
if (tablet1.Type === TxAllocator) {
7863
return 1;
7964
}
@@ -127,11 +112,7 @@ class ClusterInfo extends React.Component<ClusterInfoProps> {
127112
private autofetcher: any;
128113

129114
private getInfo() {
130-
const {
131-
cluster = {} as ICluster,
132-
additionalClusterInfo = [],
133-
singleClusterMode,
134-
} = this.props;
115+
const {cluster = {}, additionalClusterInfo = [], singleClusterMode} = this.props;
135116
const {StorageTotal, StorageUsed} = cluster;
136117

137118
let link = backend + '/internal';
@@ -192,7 +173,7 @@ class ClusterInfo extends React.Component<ClusterInfoProps> {
192173

193174
private renderContent = () => {
194175
const {
195-
cluster = {} as ICluster,
176+
cluster = {},
196177
showTooltip,
197178
hideTooltip,
198179
clusterTitle,

0 commit comments

Comments
 (0)