Skip to content

Commit f365dd8

Browse files
refactor(ProblemFilter): migrate to ts
1 parent 2d28a2a commit f365dd8

File tree

9 files changed

+31
-34
lines changed

9 files changed

+31
-34
lines changed

src/components/ProblemFilter/ProblemFilter.js

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {RadioButton} from '@gravity-ui/uikit';
2+
3+
import {ALL, PROBLEMS, IProblemFilterValues} from '../../utils/constants';
4+
5+
interface ProblemFilterProps {
6+
value: IProblemFilterValues;
7+
onChange: (value: string) => void;
8+
className?: string;
9+
}
10+
11+
export const ProblemFilter = ({value, onChange, className}: ProblemFilterProps) => {
12+
return (
13+
<RadioButton value={value} onUpdate={onChange} className={className}>
14+
<RadioButton.Option value={ALL}>{ALL}</RadioButton.Option>
15+
<RadioButton.Option value={PROBLEMS}>{PROBLEMS}</RadioButton.Option>
16+
</RadioButton>
17+
);
18+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './ProblemFilter';

src/containers/Nodes/Nodes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {connect} from 'react-redux';
66
import DataTable from '@yandex-cloud/react-data-table';
77
import {Loader, TextInput, Label} from '@gravity-ui/uikit';
88

9-
import ProblemFilter, {problemFilterType} from '../../components/ProblemFilter/ProblemFilter';
9+
import {ProblemFilter} from '../../components/ProblemFilter';
1010
import {Illustration} from '../../components/Illustration';
1111
import {AccessDenied} from '../../components/Errors/403';
1212
import {UptimeFilter} from '../../components/UptimeFIlter';
@@ -46,7 +46,7 @@ class Nodes extends React.Component {
4646
hideTooltip: PropTypes.func,
4747
searchQuery: PropTypes.string,
4848
handleSearchQuery: PropTypes.func,
49-
problemFilter: problemFilterType,
49+
problemFilter: PropTypes.string,
5050
changeFilter: PropTypes.func,
5151
setHeader: PropTypes.func,
5252
className: PropTypes.string,

src/containers/NodesViewer/NodesViewer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {connect} from 'react-redux';
66
import {TextInput, Label} from '@gravity-ui/uikit';
77
import DataTable from '@yandex-cloud/react-data-table';
88

9-
import ProblemFilter, {problemFilterType} from '../../components/ProblemFilter/ProblemFilter';
9+
import {ProblemFilter} from '../../components/ProblemFilter';
1010
import {UptimeFilter} from '../../components/UptimeFIlter';
1111
import {Illustration} from '../../components/Illustration';
1212

@@ -48,7 +48,7 @@ class NodesViewer extends React.PureComponent {
4848
handleSearchQuery: PropTypes.func,
4949
showTooltip: PropTypes.func,
5050
hideTooltip: PropTypes.func,
51-
problemFilter: problemFilterType,
51+
problemFilter: PropTypes.string,
5252
nodesUptimeFilter: PropTypes.string,
5353
setNodesUptimeFilter: PropTypes.func,
5454
changeFilter: PropTypes.func,

src/containers/Pool/Pool.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import ReactList from 'react-list';
1010
import EntityStatus from '../../components/EntityStatus/EntityStatus';
1111
import GroupTreeViewer from '../../components/GroupTreeViewer/GroupTreeViewer';
1212
import Breadcrumbs from '../../components/Breadcrumbs/Breadcrumbs';
13-
import ProblemFilter, {problemFilterType} from '../../components/ProblemFilter/ProblemFilter';
13+
import {ProblemFilter} from '../../components/ProblemFilter/ProblemFilter';
1414
import {Illustration} from '../../components/Illustration';
1515

1616
import {getPoolInfo} from '../../store/reducers/pool';
@@ -38,7 +38,7 @@ class Pool extends React.Component {
3838
pool: PropTypes.object,
3939
poolName: PropTypes.string,
4040
match: PropTypes.object,
41-
filter: problemFilterType,
41+
filter: PropTypes.string,
4242
changeFilter: PropTypes.func,
4343
};
4444

src/containers/Tenant/Diagnostics/Network/Network.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {Loader, Checkbox} from '@gravity-ui/uikit';
99

1010
import NodeNetwork from './NodeNetwork/NodeNetwork';
1111
import Icon from '../../../../components/Icon/Icon';
12-
import ProblemFilter, {problemFilterType} from '../../../../components/ProblemFilter/ProblemFilter';
12+
import {ProblemFilter} from '../../../../components/ProblemFilter';
1313
import {Illustration} from '../../../../components/Illustration';
1414

1515
import {getNetworkInfo, setDataWasNotLoaded} from '../../../../store/reducers/network';
@@ -35,7 +35,7 @@ class Network extends React.Component {
3535
loading: PropTypes.bool,
3636
autorefresh: PropTypes.bool,
3737
path: PropTypes.string,
38-
filter: problemFilterType,
38+
filter: PropTypes.string,
3939
changeFilter: PropTypes.func,
4040
};
4141

src/containers/Tenants/Tenants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {Loader, TextInput, Button} from '@gravity-ui/uikit';
1010
import EntityStatus from '../../components/EntityStatus/EntityStatus';
1111
import PoolsGraph from '../../components/PoolsGraph/PoolsGraph';
1212
import TabletsStatistic from '../../components/TabletsStatistic/TabletsStatistic';
13-
import ProblemFilter, {problemFilterType} from '../../components/ProblemFilter/ProblemFilter';
13+
import {ProblemFilter} from '../../components/ProblemFilter';
1414
import {Illustration} from '../../components/Illustration';
1515
import {AutoFetcher} from '../../utils/autofetcher';
1616

@@ -50,7 +50,7 @@ class Tenants extends React.Component {
5050
searchQuery: PropTypes.string,
5151
handleSearchQuery: PropTypes.func,
5252
setHeader: PropTypes.func,
53-
filter: problemFilterType,
53+
filter: PropTypes.string,
5454
changeFilter: PropTypes.func,
5555
cluster: PropTypes.object,
5656
singleClusterMode: PropTypes.bool,

src/utils/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ export const COLORS_PRIORITY = {
118118
export const ALL = 'All';
119119
export const PROBLEMS = 'With problems';
120120

121+
export type IProblemFilterValues = typeof ALL | typeof PROBLEMS;
122+
121123
export const THEME_KEY = 'theme';
122124
export const INVERTED_DISKS_KEY = 'invertedDisks';
123125
export const SAVED_QUERIES_KEY = 'saved_queries';

0 commit comments

Comments
 (0)