@@ -13,6 +13,7 @@ import {
1313 formatStorageValuesToGb ,
1414} from '../../utils/dataFormatters/dataFormatters' ;
1515import { getUsageSeverity } from '../../utils/generateEvaluator' ;
16+ import { getNodeMemory } from '../../utils/memory' ;
1617import type { Column } from '../../utils/tableUtils/types' ;
1718import { formatToMs , parseUsToMs } from '../../utils/timeParsers' ;
1819import { bytesToSpeed , isNumeric } from '../../utils/utils' ;
@@ -169,22 +170,26 @@ export function getUptimeColumn<
169170 } ;
170171}
171172
172- export function getRAMColumn < T extends { MemoryUsed ?: string ; MemoryLimit ?: string } > ( ) : Column < T > {
173+ export function getRAMColumn <
174+ T extends { MemoryStats ?: TMemoryStats ; MemoryUsed ?: string ; MemoryLimit ?: string } ,
175+ > ( ) : Column < T > {
173176 return {
174177 name : NODES_COLUMNS_IDS . RAM ,
175178 header : NODES_COLUMNS_TITLES . RAM ,
176- sortAccessor : ( { MemoryUsed = 0 } ) => Number ( MemoryUsed ) ,
179+ sortAccessor : ( row ) => getNodeMemory ( row ) . memoryUsed ?? 0 ,
177180 defaultOrder : DataTable . DESCENDING ,
178181 render : ( { row} ) => {
182+ const { memoryUsed : used , memoryLimit : limit } = getNodeMemory ( row ) ;
179183 const [ memoryUsed , memoryLimit ] = formatStorageValues (
180- isNumeric ( row . MemoryUsed ) ? Number ( row . MemoryUsed ) : undefined ,
181- isNumeric ( row . MemoryLimit ) ? Number ( row . MemoryLimit ) : undefined ,
184+ used ,
185+ limit ,
182186 'gb' ,
183187 undefined ,
184188 true ,
185189 ) ;
186190
187191 const hasData = memoryUsed || memoryLimit ;
192+ const memoryContent = used === undefined ? EMPTY_DATA_PLACEHOLDER : memoryUsed ;
188193
189194 return (
190195 < CellWithPopover
@@ -206,10 +211,10 @@ export function getRAMColumn<T extends {MemoryUsed?: string; MemoryLimit?: strin
206211 </ DefinitionList >
207212 }
208213 >
209- { isNumeric ( row . MemoryUsed ) ? (
214+ { used !== undefined && limit !== undefined ? (
210215 < ProgressViewer
211- value = { row . MemoryUsed }
212- capacity = { row . MemoryLimit }
216+ value = { used }
217+ capacity = { limit }
213218 formatValues = { ( value , total ) =>
214219 formatStorageValues ( value , total , 'gb' , undefined , true )
215220 }
@@ -218,7 +223,7 @@ export function getRAMColumn<T extends {MemoryUsed?: string; MemoryLimit?: strin
218223 hideCapacity
219224 />
220225 ) : (
221- EMPTY_DATA_PLACEHOLDER
226+ memoryContent
222227 ) }
223228 </ CellWithPopover >
224229 ) ;
@@ -238,18 +243,27 @@ export function getMemoryColumn<
238243 render : ( { row} ) => {
239244 if ( row . MemoryStats ) {
240245 return (
241- < MemoryViewer formatValues = { formatStorageValuesToGb } stats = { row . MemoryStats } />
246+ < MemoryViewer
247+ formatValues = { formatStorageValuesToGb }
248+ stats = { row . MemoryStats }
249+ memoryUsed = { row . MemoryUsed }
250+ memoryLimit = { row . MemoryLimit }
251+ />
242252 ) ;
243253 }
244254
245- if ( ! isNumeric ( row . MemoryUsed ) ) {
255+ const { memoryUsed, memoryLimit} = getNodeMemory ( row ) ;
256+ if ( memoryUsed === undefined ) {
246257 return EMPTY_DATA_PLACEHOLDER ;
247258 }
259+ if ( memoryLimit === undefined ) {
260+ return formatStorageValuesToGb ( memoryUsed ) [ 0 ] ;
261+ }
248262
249263 return (
250264 < ProgressViewer
251- value = { row . MemoryUsed }
252- capacity = { row . MemoryLimit }
265+ value = { memoryUsed }
266+ capacity = { memoryLimit }
253267 formatValues = { formatStorageValuesToGb }
254268 colorizeProgress = { true }
255269 />
0 commit comments