@@ -24,7 +24,8 @@ import {
2424 PodHealthIcon ,
2525 getUsrMsgKeyToDisplay ,
2626 getApplicationLinkURLFromNode ,
27- getManagedByURLFromNode
27+ getManagedByURLFromNode ,
28+ formatResourceInfo
2829} from '../utils' ;
2930import { NodeUpdateAnimation } from './node-update-animation' ;
3031import { PodGroup } from '../application-pod-view/pod-view' ;
@@ -543,11 +544,19 @@ function renderPodGroup(props: ApplicationResourceTreeProps, id: string, node: R
543544 < Tooltip
544545 content = {
545546 < >
546- { ( node . info || [ ] ) . map ( i => (
547- < div key = { i . name } >
548- { i . name } : { i . value }
549- </ div >
550- ) ) }
547+ { ( node . info || [ ] ) . map ( i => {
548+ // Use common formatting function for CPU and Memory
549+ if ( i . name === 'cpu' || i . name === 'memory' ) {
550+ const { tooltipValue} = formatResourceInfo ( i . name , `${ i . value } ` ) ;
551+ return < div key = { i . name } > { tooltipValue } </ div > ;
552+ } else {
553+ return (
554+ < div key = { i . name } >
555+ { i . name } : { i . value }
556+ </ div >
557+ ) ;
558+ }
559+ } ) }
551560 </ >
552561 }
553562 key = { node . uid } >
@@ -675,9 +684,9 @@ function expandCollapse(node: ResourceTreeNode, props: ApplicationResourceTreePr
675684
676685function NodeInfoDetails ( { tag : tag , kind : kind } : { tag : models . InfoItem ; kind : string } ) {
677686 if ( kind === 'Pod' ) {
678- const val = ` ${ tag . name } ` ;
687+ const val = tag . name ;
679688 if ( val === 'Status Reason' ) {
680- if ( ` ${ tag . value } ` !== 'ImagePullBackOff' )
689+ if ( String ( tag . value ) !== 'ImagePullBackOff' )
681690 return (
682691 < span className = 'application-resource-tree__node-label' title = { `Status: ${ tag . value } ` } >
683692 { tag . value }
@@ -693,10 +702,10 @@ function NodeInfoDetails({tag: tag, kind: kind}: {tag: models.InfoItem; kind: st
693702 ) ;
694703 }
695704 } else if ( val === 'Containers' ) {
696- const arr = ` ${ tag . value } ` . split ( '/' ) ;
705+ const arr = String ( tag . value ) . split ( '/' ) ;
697706 const title = `Number of containers in total: ${ arr [ 1 ] } \nNumber of ready containers: ${ arr [ 0 ] } ` ;
698707 return (
699- < span className = 'application-resource-tree__node-label' title = { ` ${ title } ` } >
708+ < span className = 'application-resource-tree__node-label' title = { title } >
700709 { tag . value }
701710 </ span >
702711 ) ;
@@ -712,6 +721,14 @@ function NodeInfoDetails({tag: tag, kind: kind}: {tag: models.InfoItem; kind: st
712721 { tag . value }
713722 </ span >
714723 ) ;
724+ } else if ( val === 'cpu' || val === 'memory' ) {
725+ // Use common formatting function for CPU and Memory
726+ const { displayValue, tooltipValue} = formatResourceInfo ( val , String ( tag . value ) ) ;
727+ return (
728+ < span className = 'application-resource-tree__node-label' title = { tooltipValue } >
729+ { displayValue }
730+ </ span >
731+ ) ;
715732 } else {
716733 return (
717734 < span className = 'application-resource-tree__node-label' title = { `${ tag . name } : ${ tag . value } ` } >
@@ -825,19 +842,27 @@ function renderResourceNode(props: ApplicationResourceTreeProps, id: string, nod
825842 ) : null }
826843 { ( node . info || [ ] )
827844 . filter ( tag => ! tag . name . includes ( 'Node' ) && tag . name !== 'managed-by-url' )
828- . slice ( 0 , 4 )
845+ . slice ( 0 , 2 )
829846 . map ( ( tag , i ) => {
830847 return < NodeInfoDetails tag = { tag } kind = { node . kind } key = { i } /> ;
831848 } ) }
832- { ( node . info || [ ] ) . length > 4 && (
849+ { ( node . info || [ ] ) . length > 3 && (
833850 < Tooltip
834851 content = {
835852 < >
836- { ( node . info || [ ] ) . map ( i => (
837- < div key = { i . name } >
838- { i . name } : { i . value }
839- </ div >
840- ) ) }
853+ { ( node . info || [ ] ) . map ( i => {
854+ // Use common formatting function for CPU and Memory
855+ if ( i . name === 'cpu' || i . name === 'memory' ) {
856+ const { tooltipValue} = formatResourceInfo ( i . name , `${ i . value } ` ) ;
857+ return < div key = { i . name } > { tooltipValue } </ div > ;
858+ } else {
859+ return (
860+ < div key = { i . name } >
861+ { i . name } : { i . value }
862+ </ div >
863+ ) ;
864+ }
865+ } ) }
841866 </ >
842867 }
843868 key = { node . uid } >
0 commit comments