Skip to content

Commit 99a24ce

Browse files
authored
feat(autoRefresh): use user settings to store auto refresh interval (#956)
1 parent 9919358 commit 99a24ce

File tree

30 files changed

+72
-111
lines changed

30 files changed

+72
-111
lines changed

src/containers/Heatmap/Heatmap.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import {Checkbox, Select} from '@gravity-ui/uikit';
44

55
import {ResponseError} from '../../components/Errors/ResponseError';
66
import {Loader} from '../../components/Loader';
7-
import {selectAutoRefreshInterval} from '../../store/reducers/autoRefreshControl';
87
import {heatmapApi, setHeatmapOptions} from '../../store/reducers/heatmap';
98
import {hideTooltip, showTooltip} from '../../store/reducers/tooltip';
109
import type {IHeatmapMetricValue} from '../../types/store/heatmap';
1110
import {cn} from '../../utils/cn';
1211
import {formatNumber} from '../../utils/dataFormatters/dataFormatters';
13-
import {useTypedDispatch, useTypedSelector} from '../../utils/hooks';
12+
import {useAutoRefreshInterval, useTypedDispatch, useTypedSelector} from '../../utils/hooks';
1413

1514
import {HeatmapCanvas} from './HeatmapCanvas/HeatmapCanvas';
1615
import {Histogram} from './Histogram/Histogram';
@@ -30,7 +29,7 @@ export const Heatmap = ({path}: HeatmapProps) => {
3029

3130
const itemsContainer = React.createRef<HTMLDivElement>();
3231

33-
const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval);
32+
const [autoRefreshInterval] = useAutoRefreshInterval();
3433

3534
const {currentData, isFetching, error} = heatmapApi.useGetHeatmapTabletsInfoQuery(
3635
{path},

src/containers/Nodes/Nodes.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {ResizeableDataTable} from '../../components/ResizeableDataTable/Resizeab
1313
import {Search} from '../../components/Search';
1414
import {TableWithControlsLayout} from '../../components/TableWithControlsLayout/TableWithControlsLayout';
1515
import {UptimeFilter} from '../../components/UptimeFIlter';
16-
import {selectAutoRefreshInterval} from '../../store/reducers/autoRefreshControl';
1716
import {nodesApi} from '../../store/reducers/nodes/nodes';
1817
import {filterNodes} from '../../store/reducers/nodes/selectors';
1918
import type {NodesSortParams} from '../../store/reducers/nodes/types';
@@ -30,7 +29,13 @@ import {
3029
DEFAULT_TABLE_SETTINGS,
3130
USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY,
3231
} from '../../utils/constants';
33-
import {useSetting, useTableSort, useTypedDispatch, useTypedSelector} from '../../utils/hooks';
32+
import {
33+
useAutoRefreshInterval,
34+
useSetting,
35+
useTableSort,
36+
useTypedDispatch,
37+
useTypedSelector,
38+
} from '../../utils/hooks';
3439
import {
3540
NodesUptimeFilterValues,
3641
isSortableNodesProperty,
@@ -63,7 +68,7 @@ export const Nodes = ({path, additionalNodesProps = {}}: NodesProps) => {
6368
const isClusterNodes = !path;
6469

6570
const problemFilter = useTypedSelector(selectProblemFilter);
66-
const autorefresh = useTypedSelector(selectAutoRefreshInterval);
71+
const [autorefresh] = useAutoRefreshInterval();
6772

6873
const [useNodesEndpoint] = useSetting(USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY);
6974

src/containers/Storage/Storage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {ArrayParam, StringParam, useQueryParams, withDefault} from 'use-query-pa
55
import {AccessDenied} from '../../components/Errors/403';
66
import {ResponseError} from '../../components/Errors/ResponseError';
77
import {TableWithControlsLayout} from '../../components/TableWithControlsLayout/TableWithControlsLayout';
8-
import {selectAutoRefreshInterval} from '../../store/reducers/autoRefreshControl';
98
import type {NodesSortParams} from '../../store/reducers/nodes/types';
109
import {selectNodesMap} from '../../store/reducers/nodesList';
1110
import {STORAGE_TYPES, VISIBLE_ENTITIES} from '../../store/reducers/storage/constants';
@@ -24,6 +23,7 @@ import type {
2423
import type {AdditionalNodesProps} from '../../types/additionalProps';
2524
import {DEFAULT_POLLING_INTERVAL, DEFAULT_TABLE_SETTINGS} from '../../utils/constants';
2625
import {
26+
useAutoRefreshInterval,
2727
useNodesRequestParams,
2828
useStorageRequestParams,
2929
useTableSort,
@@ -63,7 +63,7 @@ interface StorageProps {
6363
}
6464

6565
export const Storage = ({additionalNodesProps, tenant, nodeId}: StorageProps) => {
66-
const autorefresh = useTypedSelector(selectAutoRefreshInterval);
66+
const [autorefresh] = useAutoRefreshInterval();
6767
const [queryParams, setQueryParams] = useQueryParams({
6868
type: StringParam,
6969
visible: StringParam,

src/containers/Tablets/Tablets.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ import {InternalLink} from '../../components/InternalLink';
1010
import {ResizeableDataTable} from '../../components/ResizeableDataTable/ResizeableDataTable';
1111
import {TableSkeleton} from '../../components/TableSkeleton/TableSkeleton';
1212
import routes, {createHref} from '../../routes';
13-
import {selectAutoRefreshInterval} from '../../store/reducers/autoRefreshControl';
1413
import {selectTabletsWithFqdn, tabletsApi} from '../../store/reducers/tablets';
1514
import {ETabletState} from '../../types/api/tablet';
1615
import type {TTabletStateInfo} from '../../types/api/tablet';
1716
import type {TabletsApiRequestParams} from '../../types/store/tablets';
1817
import {cn} from '../../utils/cn';
1918
import {DEFAULT_TABLE_SETTINGS} from '../../utils/constants';
2019
import {calcUptime} from '../../utils/dataFormatters/dataFormatters';
21-
import {useTypedDispatch, useTypedSelector} from '../../utils/hooks';
20+
import {useAutoRefreshInterval, useTypedDispatch, useTypedSelector} from '../../utils/hooks';
2221
import {mapTabletStateToLabelTheme} from '../../utils/tablet';
2322
import {getDefaultNodePath} from '../Node/NodePages';
2423

@@ -146,7 +145,7 @@ interface TabletsProps {
146145
}
147146

148147
export function Tablets({nodeId, path, className}: TabletsProps) {
149-
const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval);
148+
const [autoRefreshInterval] = useAutoRefreshInterval();
150149

151150
let params: TabletsApiRequestParams = {};
152151
const node = nodeId === undefined ? undefined : String(nodeId);

src/containers/Tenant/Diagnostics/Autorefresh/AutorefreshControl.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ import {ArrowsRotateLeft} from '@gravity-ui/icons';
22
import {Button, Select} from '@gravity-ui/uikit';
33

44
import {api} from '../../../../store/reducers/api';
5-
import {
6-
selectAutoRefreshInterval,
7-
setAutoRefreshInterval,
8-
} from '../../../../store/reducers/autoRefreshControl';
95
import {cn} from '../../../../utils/cn';
10-
import {useTypedDispatch, useTypedSelector} from '../../../../utils/hooks';
6+
import {useAutoRefreshInterval, useTypedDispatch} from '../../../../utils/hooks';
117

128
import i18n from './i18n';
139

@@ -21,7 +17,7 @@ interface AutorefreshControlProps {
2117

2218
export function AutorefreshControl({className}: AutorefreshControlProps) {
2319
const dispatch = useTypedDispatch();
24-
const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval);
20+
const [autoRefreshInterval, setAutoRefreshInterval] = useAutoRefreshInterval();
2521
return (
2622
<div className={b(null, className)}>
2723
<Button
@@ -38,7 +34,7 @@ export function AutorefreshControl({className}: AutorefreshControlProps) {
3834
<Select
3935
value={[String(autoRefreshInterval)]}
4036
onUpdate={(v) => {
41-
dispatch(setAutoRefreshInterval(Number(v)));
37+
setAutoRefreshInterval(Number(v));
4238
}}
4339
width={85}
4440
>

src/containers/Tenant/Diagnostics/Consumers/Consumers.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {ResponseError} from '../../../../components/Errors/ResponseError';
66
import {Loader} from '../../../../components/Loader';
77
import {ResizeableDataTable} from '../../../../components/ResizeableDataTable/ResizeableDataTable';
88
import {Search} from '../../../../components/Search';
9-
import {selectAutoRefreshInterval} from '../../../../store/reducers/autoRefreshControl';
109
import {
1110
selectPreparedConsumersData,
1211
selectPreparedTopicStats,
@@ -15,7 +14,7 @@ import {
1514
import type {EPathType} from '../../../../types/api/schema';
1615
import {cn} from '../../../../utils/cn';
1716
import {DEFAULT_TABLE_SETTINGS} from '../../../../utils/constants';
18-
import {useTypedSelector} from '../../../../utils/hooks';
17+
import {useAutoRefreshInterval, useTypedSelector} from '../../../../utils/hooks';
1918
import {isCdcStreamEntityType} from '../../utils/schema';
2019

2120
import {ConsumersTopicStats} from './TopicStats';
@@ -36,7 +35,7 @@ export const Consumers = ({path, type}: ConsumersProps) => {
3635

3736
const [searchValue, setSearchValue] = React.useState('');
3837

39-
const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval);
38+
const [autoRefreshInterval] = useAutoRefreshInterval();
4039
const {currentData, isFetching, error} = topicApi.useGetTopicQuery(
4140
{path},
4241
{pollingInterval: autoRefreshInterval},

src/containers/Tenant/Diagnostics/Describe/Describe.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import {shallowEqual} from 'react-redux';
44

55
import {ResponseError} from '../../../../components/Errors/ResponseError';
66
import {Loader} from '../../../../components/Loader';
7-
import {selectAutoRefreshInterval} from '../../../../store/reducers/autoRefreshControl';
87
import {describeApi} from '../../../../store/reducers/describe';
98
import {selectSchemaMergedChildrenPaths} from '../../../../store/reducers/schema/schema';
109
import type {EPathType} from '../../../../types/api/schema';
1110
import {cn} from '../../../../utils/cn';
12-
import {useTypedSelector} from '../../../../utils/hooks';
11+
import {useAutoRefreshInterval, useTypedSelector} from '../../../../utils/hooks';
1312
import {isEntityWithMergedImplementation} from '../../utils/schema';
1413

1514
import './Describe.scss';
@@ -25,7 +24,7 @@ interface IDescribeProps {
2524
}
2625

2726
const Describe = ({path, type}: IDescribeProps) => {
28-
const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval);
27+
const [autoRefreshInterval] = useAutoRefreshInterval();
2928

3029
const isEntityWithMergedImpl = isEntityWithMergedImplementation(type);
3130

src/containers/Tenant/Diagnostics/Network/Network.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {Link} from 'react-router-dom';
66
import {ResponseError} from '../../../../components/Errors/ResponseError';
77
import {Illustration} from '../../../../components/Illustration';
88
import {ProblemFilter} from '../../../../components/ProblemFilter';
9-
import {selectAutoRefreshInterval} from '../../../../store/reducers/autoRefreshControl';
109
import {networkApi} from '../../../../store/reducers/network/network';
1110
import {
1211
ProblemFilterValues,
@@ -16,7 +15,7 @@ import {
1615
import {hideTooltip, showTooltip} from '../../../../store/reducers/tooltip';
1716
import type {TNetNodeInfo, TNetNodePeerInfo} from '../../../../types/api/netInfo';
1817
import {cn} from '../../../../utils/cn';
19-
import {useTypedDispatch, useTypedSelector} from '../../../../utils/hooks';
18+
import {useAutoRefreshInterval, useTypedDispatch, useTypedSelector} from '../../../../utils/hooks';
2019
import {getDefaultNodePath} from '../../../Node/NodePages';
2120

2221
import {NodeNetwork} from './NodeNetwork/NodeNetwork';
@@ -32,7 +31,7 @@ interface NetworkProps {
3231
tenantName: string;
3332
}
3433
export function Network({tenantName}: NetworkProps) {
35-
const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval);
34+
const [autoRefreshInterval] = useAutoRefreshInterval();
3635
const filter = useTypedSelector(selectProblemFilter);
3736
const dispatch = useTypedDispatch();
3837

src/containers/Tenant/Diagnostics/Overview/Overview.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import {shallowEqual} from 'react-redux';
66
import {ResponseError} from '../../../../components/Errors/ResponseError';
77
import {TableIndexInfo} from '../../../../components/InfoViewer/schemaInfo';
88
import {Loader} from '../../../../components/Loader';
9-
import {selectAutoRefreshInterval} from '../../../../store/reducers/autoRefreshControl';
109
import {olapApi} from '../../../../store/reducers/olapStats';
1110
import {overviewApi} from '../../../../store/reducers/overview/overview';
1211
import {schemaApi, selectSchemaMergedChildrenPaths} from '../../../../store/reducers/schema/schema';
1312
import {EPathType} from '../../../../types/api/schema';
14-
import {useTypedSelector} from '../../../../utils/hooks';
13+
import {useAutoRefreshInterval, useTypedSelector} from '../../../../utils/hooks';
1514
import {ExternalDataSourceInfo} from '../../Info/ExternalDataSource/ExternalDataSource';
1615
import {ExternalTableInfo} from '../../Info/ExternalTable/ExternalTable';
1716
import {ViewInfo} from '../../Info/View/View';
@@ -32,7 +31,7 @@ interface OverviewProps {
3231
}
3332

3433
function Overview({type, path}: OverviewProps) {
35-
const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval);
34+
const [autoRefreshInterval] = useAutoRefreshInterval();
3635

3736
const olapParams = isTableType(type) && isColumnEntityType(type) ? {path} : skipToken;
3837
const {currentData: olapData, isFetching: olapIsFetching} = olapApi.useGetOlapStatsQuery(

src/containers/Tenant/Diagnostics/Overview/TopicStats/TopicStats.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import {LabelWithPopover} from '../../../../../components/LabelWithPopover';
55
import {LagPopoverContent} from '../../../../../components/LagPopoverContent';
66
import {Loader} from '../../../../../components/Loader';
77
import {SpeedMultiMeter} from '../../../../../components/SpeedMultiMeter';
8-
import {selectAutoRefreshInterval} from '../../../../../store/reducers/autoRefreshControl';
98
import {selectPreparedTopicStats, topicApi} from '../../../../../store/reducers/topic';
109
import type {IPreparedTopicStats} from '../../../../../types/store/topic';
1110
import {cn} from '../../../../../utils/cn';
1211
import {formatBps, formatBytes} from '../../../../../utils/dataFormatters/dataFormatters';
13-
import {useTypedSelector} from '../../../../../utils/hooks';
12+
import {useAutoRefreshInterval, useTypedSelector} from '../../../../../utils/hooks';
1413
import {formatDurationToShortTimeFormat} from '../../../../../utils/timeParsers';
1514

1615
import i18n from './i18n';
@@ -71,7 +70,7 @@ const prepareBytesWrittenInfo = (data: IPreparedTopicStats): Array<InfoViewerIte
7170
};
7271

7372
export const TopicStats = ({path}: {path: string}) => {
74-
const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval);
73+
const [autoRefreshInterval] = useAutoRefreshInterval();
7574
const {currentData, isFetching, error} = topicApi.useGetTopicQuery(
7675
{path},
7776
{pollingInterval: autoRefreshInterval},

0 commit comments

Comments
 (0)