@@ -5,6 +5,7 @@ import {cn} from '../../utils/cn';
55import { formatStorageValuesToGb } from '../../utils/dataFormatters/dataFormatters' ;
66import { createPDiskDeveloperUILink } from '../../utils/developerUI/developerUI' ;
77import type { PreparedPDisk } from '../../utils/disks/types' ;
8+ import { useTypedSelector } from '../../utils/hooks' ;
89import { EntityStatus } from '../EntityStatus/EntityStatus' ;
910import type { InfoViewerItem } from '../InfoViewer' ;
1011import { InfoViewer } from '../InfoViewer/InfoViewer' ;
@@ -21,12 +22,15 @@ interface GetPDiskInfoOptions<T extends PreparedPDisk> {
2122 pDisk ?: T ;
2223 nodeId ?: number | string | null ;
2324 isPDiskPage ?: boolean ;
25+ isUserAllowedToMakeChanges ?: boolean ;
2426}
2527
28+ // eslint-disable-next-line complexity
2629function getPDiskInfo < T extends PreparedPDisk > ( {
2730 pDisk,
2831 nodeId,
2932 isPDiskPage = false ,
33+ isUserAllowedToMakeChanges,
3034} : GetPDiskInfoOptions < T > ) {
3135 const {
3236 PDiskId,
@@ -142,7 +146,12 @@ function getPDiskInfo<T extends PreparedPDisk>({
142146
143147 const additionalInfo : InfoViewerItem [ ] = [ ] ;
144148
145- if ( valueIsDefined ( PDiskId ) && valueIsDefined ( nodeId ) ) {
149+ const shouldDisplayLinks =
150+ ( ! isPDiskPage || isUserAllowedToMakeChanges ) &&
151+ valueIsDefined ( PDiskId ) &&
152+ valueIsDefined ( nodeId ) ;
153+
154+ if ( shouldDisplayLinks ) {
146155 const pDiskPagePath = getPDiskPagePath ( PDiskId , nodeId ) ;
147156 const pDiskInternalViewerPath = createPDiskDeveloperUILink ( {
148157 nodeId,
@@ -160,10 +169,12 @@ function getPDiskInfo<T extends PreparedPDisk>({
160169 external = { false }
161170 />
162171 ) }
163- < LinkWithIcon
164- title = { pDiskInfoKeyset ( 'developer-ui' ) }
165- url = { pDiskInternalViewerPath }
166- />
172+ { isUserAllowedToMakeChanges && (
173+ < LinkWithIcon
174+ title = { pDiskInfoKeyset ( 'developer-ui' ) }
175+ url = { pDiskInternalViewerPath }
176+ />
177+ ) }
167178 </ span >
168179 ) ,
169180 } ) ;
@@ -182,21 +193,24 @@ export function PDiskInfo<T extends PreparedPDisk>({
182193 isPDiskPage = false ,
183194 className,
184195} : PDiskInfoProps < T > ) {
196+ const { isUserAllowedToMakeChanges} = useTypedSelector ( ( state ) => state . authentication ) ;
197+
185198 const [ generalInfo , statusInfo , spaceInfo , additionalInfo ] = getPDiskInfo ( {
186199 pDisk,
187200 nodeId,
188201 isPDiskPage,
202+ isUserAllowedToMakeChanges,
189203 } ) ;
190204
191205 return (
192206 < div className = { b ( 'wrapper' , className ) } >
193207 < div className = { b ( 'col' ) } >
194- < InfoViewer info = { generalInfo } />
195- < InfoViewer info = { spaceInfo } />
208+ < InfoViewer info = { generalInfo } renderEmptyState = { ( ) => null } />
209+ < InfoViewer info = { spaceInfo } renderEmptyState = { ( ) => null } />
196210 </ div >
197211 < div className = { b ( 'col' ) } >
198- < InfoViewer info = { statusInfo } />
199- < InfoViewer info = { additionalInfo } />
212+ < InfoViewer info = { statusInfo } renderEmptyState = { ( ) => null } />
213+ < InfoViewer info = { additionalInfo } renderEmptyState = { ( ) => null } />
200214 </ div >
201215 </ div >
202216 ) ;
0 commit comments