Skip to content

Commit a391e94

Browse files
authored
feat(autoRefresh): move auto refresh to separate reducer (#943)
1 parent 59d41f2 commit a391e94

File tree

29 files changed

+121
-76
lines changed

29 files changed

+121
-76
lines changed

src/containers/Heatmap/Heatmap.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ 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';
78
import {heatmapApi, setHeatmapOptions} from '../../store/reducers/heatmap';
89
import {hideTooltip, showTooltip} from '../../store/reducers/tooltip';
910
import type {IHeatmapMetricValue} from '../../types/store/heatmap';
@@ -29,11 +30,11 @@ export const Heatmap = ({path}: HeatmapProps) => {
2930

3031
const itemsContainer = React.createRef<HTMLDivElement>();
3132

32-
const {autorefresh} = useTypedSelector((state) => state.schema);
33+
const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval);
3334

3435
const {currentData, isFetching, error} = heatmapApi.useGetHeatmapTabletsInfoQuery(
3536
{path},
36-
{pollingInterval: autorefresh},
37+
{pollingInterval: autoRefreshInterval},
3738
);
3839

3940
const loading = isFetching && currentData === undefined;

src/containers/Nodes/Nodes.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ 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';
1617
import {nodesApi} from '../../store/reducers/nodes/nodes';
1718
import {filterNodes} from '../../store/reducers/nodes/selectors';
1819
import type {NodesSortParams} from '../../store/reducers/nodes/types';
@@ -58,7 +59,7 @@ export const Nodes = ({path, additionalNodesProps = {}}: NodesProps) => {
5859
const isClusterNodes = !path;
5960

6061
const problemFilter = useTypedSelector((state) => state.settings.problemFilter);
61-
const {autorefresh} = useTypedSelector((state) => state.schema);
62+
const autorefresh = useTypedSelector(selectAutoRefreshInterval);
6263

6364
const [useNodesEndpoint] = useSetting(USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY);
6465

src/containers/Storage/Storage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ 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';
89
import type {NodesSortParams} from '../../store/reducers/nodes/types';
910
import {selectNodesMap} from '../../store/reducers/nodesList';
1011
import {STORAGE_TYPES, VISIBLE_ENTITIES} from '../../store/reducers/storage/constants';
@@ -62,7 +63,7 @@ interface StorageProps {
6263
}
6364

6465
export const Storage = ({additionalNodesProps, tenant, nodeId}: StorageProps) => {
65-
const {autorefresh} = useTypedSelector((state) => state.schema);
66+
const autorefresh = useTypedSelector(selectAutoRefreshInterval);
6667
const [queryParams, setQueryParams] = useQueryParams({
6768
type: StringParam,
6869
visible: StringParam,

src/containers/Tablets/Tablets.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ 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';
1314
import {selectTabletsWithFqdn, tabletsApi} from '../../store/reducers/tablets';
1415
import {ETabletState} from '../../types/api/tablet';
1516
import type {TTabletStateInfo} from '../../types/api/tablet';
@@ -145,7 +146,7 @@ interface TabletsProps {
145146
}
146147

147148
export function Tablets({nodeId, path, className}: TabletsProps) {
148-
const {autorefresh} = useTypedSelector((state) => state.schema);
149+
const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval);
149150

150151
let params: TabletsApiRequestParams = {};
151152
const node = nodeId === undefined ? undefined : String(nodeId);
@@ -157,7 +158,7 @@ export function Tablets({nodeId, path, className}: TabletsProps) {
157158
const {currentData, isFetching, error} = tabletsApi.useGetTabletsInfoQuery(
158159
Object.keys(params).length === 0 ? skipToken : params,
159160
{
160-
pollingInterval: autorefresh,
161+
pollingInterval: autoRefreshInterval,
161162
},
162163
);
163164

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

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

44
import {api} from '../../../../store/reducers/api';
5-
import {setAutorefreshInterval} from '../../../../store/reducers/schema/schema';
5+
import {
6+
selectAutoRefreshInterval,
7+
setAutoRefreshInterval,
8+
} from '../../../../store/reducers/autoRefreshControl';
69
import {cn} from '../../../../utils/cn';
710
import {useTypedDispatch, useTypedSelector} from '../../../../utils/hooks';
811

@@ -18,7 +21,7 @@ interface AutorefreshControlProps {
1821

1922
export function AutorefreshControl({className}: AutorefreshControlProps) {
2023
const dispatch = useTypedDispatch();
21-
const autorefresh = useTypedSelector((state) => state.schema.autorefresh);
24+
const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval);
2225
return (
2326
<div className={b(null, className)}>
2427
<Button
@@ -33,9 +36,9 @@ export function AutorefreshControl({className}: AutorefreshControlProps) {
3336
</Button.Icon>
3437
</Button>
3538
<Select
36-
value={[String(autorefresh)]}
39+
value={[String(autoRefreshInterval)]}
3740
onUpdate={(v) => {
38-
dispatch(setAutorefreshInterval(Number(v)));
41+
dispatch(setAutoRefreshInterval(Number(v)));
3942
}}
4043
width={85}
4144
>

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ 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';
910
import {
1011
selectPreparedConsumersData,
1112
selectPreparedTopicStats,
@@ -35,10 +36,10 @@ export const Consumers = ({path, type}: ConsumersProps) => {
3536

3637
const [searchValue, setSearchValue] = React.useState('');
3738

38-
const {autorefresh} = useTypedSelector((state) => state.schema);
39+
const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval);
3940
const {currentData, isFetching, error} = topicApi.useGetTopicQuery(
4041
{path},
41-
{pollingInterval: autorefresh},
42+
{pollingInterval: autoRefreshInterval},
4243
);
4344
const loading = isFetching && currentData === undefined;
4445
const consumers = useTypedSelector((state) => selectPreparedConsumersData(state, path));

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ 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';
78
import {describeApi} from '../../../../store/reducers/describe';
89
import {selectSchemaMergedChildrenPaths} from '../../../../store/reducers/schema/schema';
910
import type {EPathType} from '../../../../types/api/schema';
@@ -24,7 +25,8 @@ interface IDescribeProps {
2425
}
2526

2627
const Describe = ({tenant, type}: IDescribeProps) => {
27-
const {autorefresh, currentSchemaPath} = useTypedSelector((state) => state.schema);
28+
const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval);
29+
const {currentSchemaPath} = useTypedSelector((state) => state.schema);
2830

2931
const isEntityWithMergedImpl = isEntityWithMergedImplementation(type);
3032

@@ -41,7 +43,7 @@ const Describe = ({tenant, type}: IDescribeProps) => {
4143
paths = [path, ...mergedChildrenPaths];
4244
}
4345
const {currentData, isFetching, error} = describeApi.useGetDescribeQuery(paths, {
44-
pollingInterval: autorefresh,
46+
pollingInterval: autoRefreshInterval,
4547
});
4648
const loading = isFetching && currentData === undefined;
4749
const currentDescribe = currentData;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ 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';
910
import {networkApi} from '../../../../store/reducers/network/network';
1011
import {
1112
ProblemFilterValues,
@@ -31,7 +32,7 @@ interface NetworkProps {
3132
path: string;
3233
}
3334
export function Network({path}: NetworkProps) {
34-
const {autorefresh} = useTypedSelector((state) => state.schema);
35+
const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval);
3536
const filter = useTypedSelector(selectProblemFilter);
3637
const dispatch = useTypedDispatch();
3738

@@ -40,7 +41,7 @@ export function Network({path}: NetworkProps) {
4041
const [showRacks, setShowRacks] = React.useState(false);
4142

4243
const {currentData, isFetching, error} = networkApi.useGetNetworkInfoQuery(path, {
43-
pollingInterval: autorefresh,
44+
pollingInterval: autoRefreshInterval,
4445
});
4546
const loading = isFetching && currentData === undefined;
4647

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ 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';
910
import {olapApi} from '../../../../store/reducers/olapStats';
1011
import {overviewApi} from '../../../../store/reducers/overview/overview';
1112
import {selectSchemaMergedChildrenPaths} from '../../../../store/reducers/schema/schema';
@@ -31,14 +32,15 @@ interface OverviewProps {
3132
}
3233

3334
function Overview({type, tenantName}: OverviewProps) {
34-
const {autorefresh, currentSchemaPath} = useTypedSelector((state) => state.schema);
35+
const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval);
36+
const {currentSchemaPath} = useTypedSelector((state) => state.schema);
3537

3638
const schemaPath = currentSchemaPath || tenantName;
3739
const olapParams =
3840
isTableType(type) && isColumnEntityType(type) ? {path: schemaPath} : skipToken;
3941
const {currentData: olapData, isFetching: olapIsFetching} = olapApi.useGetOlapStatsQuery(
4042
olapParams,
41-
{pollingInterval: autorefresh},
43+
{pollingInterval: autoRefreshInterval},
4244
);
4345
const olapStatsLoading = olapIsFetching && olapData === undefined;
4446
const {result: olapStats} = olapData || {result: undefined};
@@ -65,7 +67,7 @@ function Overview({type, tenantName}: OverviewProps) {
6567
isFetching,
6668
error: overviewError,
6769
} = overviewApi.useGetOverviewQuery(paths, {
68-
pollingInterval: autorefresh,
70+
pollingInterval: autoRefreshInterval,
6971
});
7072
const overviewLoading = isFetching && currentData === undefined;
7173
const {data: rawData, additionalData} = currentData || {};

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ 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';
89
import {selectPreparedTopicStats, topicApi} from '../../../../../store/reducers/topic';
910
import type {IPreparedTopicStats} from '../../../../../types/store/topic';
1011
import {cn} from '../../../../../utils/cn';
@@ -70,10 +71,11 @@ const prepareBytesWrittenInfo = (data: IPreparedTopicStats): Array<InfoViewerIte
7071
};
7172

7273
export const TopicStats = () => {
73-
const {autorefresh, currentSchemaPath} = useTypedSelector((state) => state.schema);
74+
const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval);
75+
const {currentSchemaPath} = useTypedSelector((state) => state.schema);
7476
const {currentData, isFetching, error} = topicApi.useGetTopicQuery(
7577
{path: currentSchemaPath},
76-
{pollingInterval: autorefresh},
78+
{pollingInterval: autoRefreshInterval},
7779
);
7880
const loading = isFetching && currentData === undefined;
7981
const data = useTypedSelector((state) => selectPreparedTopicStats(state, currentSchemaPath));

0 commit comments

Comments
 (0)