From bad15fcd57d8517f11f60c21a01451ee97933b91 Mon Sep 17 00:00:00 2001 From: Valerii Sidorenko Date: Tue, 25 Jun 2024 13:23:32 +0200 Subject: [PATCH 1/2] feat(autoRefresh): move auto refresh to separate reducer --- src/containers/Heatmap/Heatmap.tsx | 5 +-- src/containers/Nodes/Nodes.tsx | 3 +- src/containers/Storage/Storage.tsx | 3 +- src/containers/Tablets/Tablets.tsx | 5 +-- .../Autorefresh/AutorefreshControl.tsx | 11 ++++--- .../Diagnostics/Consumers/Consumers.tsx | 5 +-- .../Tenant/Diagnostics/Describe/Describe.tsx | 6 ++-- .../Tenant/Diagnostics/Network/Network.tsx | 5 +-- .../Tenant/Diagnostics/Overview/Overview.tsx | 8 +++-- .../Overview/TopicStats/TopicStats.tsx | 6 ++-- .../Diagnostics/Partitions/Partitions.tsx | 5 +-- .../Healthcheck/HealthcheckDetails.tsx | 7 +++-- .../Healthcheck/HealthcheckPreview.tsx | 5 +-- .../TenantCpu/TopNodesByCpu.tsx | 5 +-- .../TenantCpu/TopNodesByLoad.tsx | 5 +-- .../TenantOverview/TenantCpu/TopQueries.tsx | 5 +-- .../TenantOverview/TenantCpu/TopShards.tsx | 6 ++-- .../TenantDashboard/TenantDashboard.tsx | 5 +-- .../TenantMemory/TopNodesByMemory.tsx | 5 +-- .../TenantOverview/TenantOverview.tsx | 5 +-- .../TenantStorage/TopGroups.tsx | 5 +-- .../TenantStorage/TopTables.tsx | 5 +-- .../Diagnostics/TopQueries/TopQueries.tsx | 5 +-- .../Diagnostics/TopShards/TopShards.tsx | 6 ++-- .../Tenant/Query/Preview/Preview.tsx | 6 ++-- src/store/reducers/autoRefreshControl.ts | 31 +++++++++++++++++++ src/store/reducers/index.ts | 2 ++ src/store/reducers/schema/schema.ts | 24 ++------------ src/store/reducers/schema/types.ts | 3 -- 29 files changed, 121 insertions(+), 76 deletions(-) create mode 100644 src/store/reducers/autoRefreshControl.ts diff --git a/src/containers/Heatmap/Heatmap.tsx b/src/containers/Heatmap/Heatmap.tsx index 671ffed8d2..30b182bbbb 100644 --- a/src/containers/Heatmap/Heatmap.tsx +++ b/src/containers/Heatmap/Heatmap.tsx @@ -4,6 +4,7 @@ import {Checkbox, Select} from '@gravity-ui/uikit'; import {ResponseError} from '../../components/Errors/ResponseError'; import {Loader} from '../../components/Loader'; +import {selectAutoRefreshInterval} from '../../store/reducers/autoRefreshControl'; import {heatmapApi, setHeatmapOptions} from '../../store/reducers/heatmap'; import {hideTooltip, showTooltip} from '../../store/reducers/tooltip'; import type {IHeatmapMetricValue} from '../../types/store/heatmap'; @@ -29,11 +30,11 @@ export const Heatmap = ({path}: HeatmapProps) => { const itemsContainer = React.createRef(); - const {autorefresh} = useTypedSelector((state) => state.schema); + const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval); const {currentData, isFetching, error} = heatmapApi.useGetHeatmapTabletsInfoQuery( {path}, - {pollingInterval: autorefresh}, + {pollingInterval: autoRefreshInterval}, ); const loading = isFetching && currentData === undefined; diff --git a/src/containers/Nodes/Nodes.tsx b/src/containers/Nodes/Nodes.tsx index 5f99b7737b..cadeb8845f 100644 --- a/src/containers/Nodes/Nodes.tsx +++ b/src/containers/Nodes/Nodes.tsx @@ -13,6 +13,7 @@ import {ResizeableDataTable} from '../../components/ResizeableDataTable/Resizeab import {Search} from '../../components/Search'; import {TableWithControlsLayout} from '../../components/TableWithControlsLayout/TableWithControlsLayout'; import {UptimeFilter} from '../../components/UptimeFIlter'; +import {selectAutoRefreshInterval} from '../../store/reducers/autoRefreshControl'; import {nodesApi} from '../../store/reducers/nodes/nodes'; import {filterNodes} from '../../store/reducers/nodes/selectors'; import type {NodesSortParams} from '../../store/reducers/nodes/types'; @@ -58,7 +59,7 @@ export const Nodes = ({path, additionalNodesProps = {}}: NodesProps) => { const isClusterNodes = !path; const problemFilter = useTypedSelector((state) => state.settings.problemFilter); - const {autorefresh} = useTypedSelector((state) => state.schema); + const autorefresh = useTypedSelector(selectAutoRefreshInterval); const [useNodesEndpoint] = useSetting(USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY); diff --git a/src/containers/Storage/Storage.tsx b/src/containers/Storage/Storage.tsx index 4e55b3c498..debbc249ca 100644 --- a/src/containers/Storage/Storage.tsx +++ b/src/containers/Storage/Storage.tsx @@ -5,6 +5,7 @@ import {ArrayParam, StringParam, useQueryParams, withDefault} from 'use-query-pa import {AccessDenied} from '../../components/Errors/403'; import {ResponseError} from '../../components/Errors/ResponseError'; import {TableWithControlsLayout} from '../../components/TableWithControlsLayout/TableWithControlsLayout'; +import {selectAutoRefreshInterval} from '../../store/reducers/autoRefreshControl'; import type {NodesSortParams} from '../../store/reducers/nodes/types'; import {selectNodesMap} from '../../store/reducers/nodesList'; import {STORAGE_TYPES, VISIBLE_ENTITIES} from '../../store/reducers/storage/constants'; @@ -62,7 +63,7 @@ interface StorageProps { } export const Storage = ({additionalNodesProps, tenant, nodeId}: StorageProps) => { - const {autorefresh} = useTypedSelector((state) => state.schema); + const autorefresh = useTypedSelector(selectAutoRefreshInterval); const [queryParams, setQueryParams] = useQueryParams({ type: StringParam, visible: StringParam, diff --git a/src/containers/Tablets/Tablets.tsx b/src/containers/Tablets/Tablets.tsx index 1eb9bf4c42..d6c0ebf841 100644 --- a/src/containers/Tablets/Tablets.tsx +++ b/src/containers/Tablets/Tablets.tsx @@ -10,6 +10,7 @@ import {InternalLink} from '../../components/InternalLink'; import {ResizeableDataTable} from '../../components/ResizeableDataTable/ResizeableDataTable'; import {TableSkeleton} from '../../components/TableSkeleton/TableSkeleton'; import routes, {createHref} from '../../routes'; +import {selectAutoRefreshInterval} from '../../store/reducers/autoRefreshControl'; import {selectTabletsWithFqdn, tabletsApi} from '../../store/reducers/tablets'; import {ETabletState} from '../../types/api/tablet'; import type {TTabletStateInfo} from '../../types/api/tablet'; @@ -145,7 +146,7 @@ interface TabletsProps { } export function Tablets({nodeId, path, className}: TabletsProps) { - const {autorefresh} = useTypedSelector((state) => state.schema); + const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval); let params: TabletsApiRequestParams = {}; const node = nodeId === undefined ? undefined : String(nodeId); @@ -157,7 +158,7 @@ export function Tablets({nodeId, path, className}: TabletsProps) { const {currentData, isFetching, error} = tabletsApi.useGetTabletsInfoQuery( Object.keys(params).length === 0 ? skipToken : params, { - pollingInterval: autorefresh, + pollingInterval: autoRefreshInterval, }, ); diff --git a/src/containers/Tenant/Diagnostics/Autorefresh/AutorefreshControl.tsx b/src/containers/Tenant/Diagnostics/Autorefresh/AutorefreshControl.tsx index c46a40a899..40c75436b3 100644 --- a/src/containers/Tenant/Diagnostics/Autorefresh/AutorefreshControl.tsx +++ b/src/containers/Tenant/Diagnostics/Autorefresh/AutorefreshControl.tsx @@ -2,7 +2,10 @@ import {ArrowsRotateLeft} from '@gravity-ui/icons'; import {Button, Select} from '@gravity-ui/uikit'; import {api} from '../../../../store/reducers/api'; -import {setAutorefreshInterval} from '../../../../store/reducers/schema/schema'; +import { + selectAutoRefreshInterval, + setAutoRefreshInterval, +} from '../../../../store/reducers/autoRefreshControl'; import {cn} from '../../../../utils/cn'; import {useTypedDispatch, useTypedSelector} from '../../../../utils/hooks'; @@ -18,7 +21,7 @@ interface AutorefreshControlProps { export function AutorefreshControl({className}: AutorefreshControlProps) { const dispatch = useTypedDispatch(); - const autorefresh = useTypedSelector((state) => state.schema.autorefresh); + const autoRefreshInterval = useTypedSelector(selectAutoRefreshInterval); return (