@@ -4,9 +4,10 @@ import {
44 Database as DatabaseIcon ,
55 HardDrive as StorageNodeIcon ,
66} from '@gravity-ui/icons' ;
7+ import { isNil } from 'lodash' ;
78
89import { TabletIcon } from '../../components/TabletIcon/TabletIcon' ;
9- import routes , { getPDiskPagePath } from '../../routes' ;
10+ import routes , { getPDiskPagePath , getStorageGroupPath } from '../../routes' ;
1011import type {
1112 BreadcrumbsOptions ,
1213 ClusterBreadcrumbsOptions ,
@@ -38,7 +39,10 @@ export interface RawBreadcrumbItem {
3839}
3940
4041interface GetBreadcrumbs < T , U = AnyRecord > {
41- ( options : T & { singleClusterMode : boolean } , query ?: U ) : RawBreadcrumbItem [ ] ;
42+ (
43+ options : T & { singleClusterMode : boolean ; isViewerUser ?: boolean } ,
44+ query ?: U ,
45+ ) : RawBreadcrumbItem [ ] ;
4246}
4347
4448const getQueryForTenant = ( type : 'nodes' | 'tablets' ) => ( {
@@ -133,6 +137,9 @@ function getNodeIcon(nodeRole: 'Storage' | 'Compute' | undefined) {
133137}
134138
135139const getPDiskBreadcrumbs : GetBreadcrumbs < PDiskBreadcrumbsOptions > = ( options , query = { } ) => {
140+ if ( ! options . isViewerUser ) {
141+ return [ ] ;
142+ }
136143 const { nodeId, pDiskId, nodeRole} = options ;
137144
138145 const breadcrumbs = getNodeBreadcrumbs ( {
@@ -157,35 +164,42 @@ const getPDiskBreadcrumbs: GetBreadcrumbs<PDiskBreadcrumbsOptions> = (options, q
157164 return breadcrumbs ;
158165} ;
159166
160- const getVDiskBreadcrumbs : GetBreadcrumbs < VDiskBreadcrumbsOptions > = ( options , query = { } ) => {
161- const { vDiskSlotId} = options ;
167+ const getStorageGroupBreadcrumbs : GetBreadcrumbs < StorageGroupBreadcrumbsOptions > = (
168+ options ,
169+ query = { } ,
170+ ) => {
171+ const { groupId, isViewerUser, tenantName} = options ;
162172
163- const breadcrumbs = getPDiskBreadcrumbs ( options , query ) ;
173+ const breadcrumbs = isViewerUser
174+ ? getClusterBreadcrumbs ( options , query )
175+ : getTenantBreadcrumbs ( options , query ) ;
164176
165- let text = headerKeyset ( 'breadcrumbs.vDisk ' ) ;
166- if ( vDiskSlotId ) {
167- text += ` ${ vDiskSlotId } ` ;
177+ let text = headerKeyset ( 'breadcrumbs.storageGroup ' ) ;
178+ if ( groupId ) {
179+ text += ` ${ groupId } ` ;
168180 }
169181
170182 const lastItem = {
171183 text,
184+ link : groupId ? getStorageGroupPath ( groupId , { database : tenantName } ) : undefined ,
172185 } ;
173186 breadcrumbs . push ( lastItem ) ;
174187
175188 return breadcrumbs ;
176189} ;
177190
178- const getStorageGroupBreadcrumbs : GetBreadcrumbs < StorageGroupBreadcrumbsOptions > = (
179- options ,
180- query = { } ,
181- ) => {
182- const { groupId} = options ;
191+ const getVDiskBreadcrumbs : GetBreadcrumbs < VDiskBreadcrumbsOptions > = ( options , query = { } ) => {
192+ const { vDiskSlotId, groupId} = options ;
183193
184- const breadcrumbs = getClusterBreadcrumbs ( options , query ) ;
194+ let breadcrumbs = getPDiskBreadcrumbs ( options , query ) ;
185195
186- let text = headerKeyset ( 'breadcrumbs.storageGroup' ) ;
187- if ( groupId ) {
188- text += ` ${ groupId } ` ;
196+ if ( breadcrumbs . length === 0 && ! isNil ( groupId ) ) {
197+ breadcrumbs = getStorageGroupBreadcrumbs ( options , query ) ;
198+ }
199+
200+ let text = headerKeyset ( 'breadcrumbs.vDisk' ) ;
201+ if ( vDiskSlotId ) {
202+ text += ` ${ vDiskSlotId } ` ;
189203 }
190204
191205 const lastItem = {
@@ -226,7 +240,7 @@ const mapPageToGetter = {
226240
227241export const getBreadcrumbs = (
228242 page : Page ,
229- options : BreadcrumbsOptions & { singleClusterMode : boolean } ,
243+ options : BreadcrumbsOptions & { singleClusterMode : boolean ; isViewerUser ?: boolean } ,
230244 rawBreadcrumbs : RawBreadcrumbItem [ ] = [ ] ,
231245 query = { } ,
232246) => {
0 commit comments