@@ -13,20 +13,22 @@ import {InfoViewerSkeleton} from '../../components/InfoViewerSkeleton/InfoViewer
1313import { PageMetaWithAutorefresh } from '../../components/PageMeta/PageMeta' ;
1414import { ResizeableDataTable } from '../../components/ResizeableDataTable/ResizeableDataTable' ;
1515import { VDiskInfo } from '../../components/VDiskInfo/VDiskInfo' ;
16+ import { api } from '../../store/reducers/api' ;
1617import { selectIsUserAllowedToMakeChanges } from '../../store/reducers/authentication/authentication' ;
1718import { setHeaderBreadcrumbs } from '../../store/reducers/header/header' ;
18- import type { PreparedStorageGroup } from '../../store/reducers/storage/types ' ;
19+ import { storageApi } from '../../store/reducers/storage/storage ' ;
1920import { vDiskApi } from '../../store/reducers/vdisk/vdisk' ;
2021import { valueIsDefined } from '../../utils' ;
2122import { cn } from '../../utils/cn' ;
2223import { DEFAULT_TABLE_SETTINGS } from '../../utils/constants' ;
2324import { stringifyVdiskId } from '../../utils/dataFormatters/dataFormatters' ;
24- import { getSeverityColor } from '../../utils/disks/helpers' ;
25+ import { getSeverityColor , getVDiskSlotBasedId } from '../../utils/disks/helpers' ;
2526import { useAutoRefreshInterval , useTypedDispatch , useTypedSelector } from '../../utils/hooks' ;
2627import { STORAGE_GROUPS_COLUMNS_WIDTH_LS_KEY } from '../Storage/StorageGroups/columns/getStorageGroupsColumns' ;
2728import { useGetDiskStorageColumns } from '../Storage/StorageGroups/columns/hooks' ;
2829
2930import { vDiskPageKeyset } from './i18n' ;
31+ import { prepareVDiskGroupResponse } from './utils' ;
3032
3133import './VDiskPage.scss' ;
3234
@@ -52,11 +54,14 @@ export function VDiskPage() {
5254 valueIsDefined ( nodeId ) && valueIsDefined ( pDiskId ) && valueIsDefined ( vDiskSlotId )
5355 ? { nodeId, pDiskId, vDiskSlotId}
5456 : skipToken ;
55- const { currentData, isFetching, refetch, error} = vDiskApi . useGetVDiskDataQuery ( params , {
57+ const {
58+ currentData : vDiskData = { } ,
59+ isFetching,
60+ error,
61+ } = vDiskApi . useGetVDiskDataQuery ( params , {
5662 pollingInterval : autoRefreshInterval ,
5763 } ) ;
58- const loading = isFetching && currentData === undefined ;
59- const { vDiskData = { } , groupData} = currentData || { } ;
64+ const loading = isFetching && vDiskData === undefined ;
6065 const { NodeHost, NodeId, NodeType, NodeDC, PDiskId, PDiskType, Severity, VDiskId} = vDiskData ;
6166 const { GroupID, GroupGeneration, Ring, Domain, VDisk} = VDiskId || { } ;
6267 const vDiskIdParamsDefined =
@@ -91,8 +96,16 @@ export function VDiskPage() {
9196 return undefined ;
9297 } ;
9398
94- const handleAfterEvictVDisk = async ( ) => {
95- return refetch ( ) ;
99+ const handleAfterEvictVDisk = ( ) => {
100+ dispatch (
101+ api . util . invalidateTags ( [
102+ {
103+ type : 'VDiskData' ,
104+ id : getVDiskSlotBasedId ( nodeId || 0 , pDiskId || 0 , vDiskSlotId || 0 ) ,
105+ } ,
106+ 'StorageData' ,
107+ ] ) ,
108+ ) ;
96109 } ;
97110
98111 const renderHelmet = ( ) => {
@@ -166,11 +179,11 @@ export function VDiskPage() {
166179 } ;
167180
168181 const renderGroupInfo = ( ) => {
169- if ( groupData ) {
182+ if ( valueIsDefined ( GroupID ) ) {
170183 return (
171184 < React . Fragment >
172185 < div className = { vDiskPageCn ( 'group-title' ) } > { vDiskPageKeyset ( 'group' ) } </ div >
173- < VDiskGroup data = { groupData } />
186+ < VDiskGroup groupId = { GroupID } />
174187 </ React . Fragment >
175188 ) ;
176189 }
@@ -203,13 +216,30 @@ export function VDiskPage() {
203216 ) ;
204217}
205218
206- export function VDiskGroup ( { data} : { data : PreparedStorageGroup } ) {
219+ export function VDiskGroup ( { groupId} : { groupId : string | number } ) {
220+ const [ autoRefreshInterval ] = useAutoRefreshInterval ( ) ;
221+
222+ const { currentData} = storageApi . useGetStorageGroupsInfoQuery (
223+ { groupId} ,
224+ { pollingInterval : autoRefreshInterval } ,
225+ ) ;
226+
227+ const preparedGroups = React . useMemo ( ( ) => {
228+ const group = prepareVDiskGroupResponse ( currentData , groupId ) ;
229+
230+ return group ? [ group ] : undefined ;
231+ } , [ currentData , groupId ] ) ;
232+
207233 const vDiskStorageColumns = useGetDiskStorageColumns ( ) ;
208234
235+ if ( ! preparedGroups ) {
236+ return null ;
237+ }
238+
209239 return (
210240 < ResizeableDataTable
211241 columnsWidthLSKey = { STORAGE_GROUPS_COLUMNS_WIDTH_LS_KEY }
212- data = { [ data ] }
242+ data = { preparedGroups }
213243 columns = { vDiskStorageColumns }
214244 settings = { DEFAULT_TABLE_SETTINGS }
215245 />
0 commit comments