@@ -4,9 +4,12 @@ import {serverContext} from 'sentry-docs/serverContext';
44import { sortPages } from 'sentry-docs/utils' ;
55import { getUnversionedPath , VERSION_INDICATOR } from 'sentry-docs/versioning' ;
66
7- import { NavChevron } from './sidebar/navChevron' ;
8- import { SidebarLink } from './sidebarLink' ;
9- import { SmartLink } from './smartLink' ;
7+ import styles from './style.module.scss' ;
8+
9+ import { SidebarLink } from '../sidebarLink' ;
10+ import { SmartLink } from '../smartLink' ;
11+
12+ import { NavChevron } from './navChevron' ;
1013
1114type Node = {
1215 [ key : string ] : any ;
@@ -105,31 +108,19 @@ export function Children({tree, path, exclude = [], showDepth = 0}: ChildrenProp
105108}
106109
107110type Props = {
108- headerClassName : string ;
109111 root : string ;
110112 tree : EntityTree [ ] ;
111- collapse ?: boolean ;
113+ collapsible ?: boolean ;
112114 exclude ?: string [ ] ;
113- noHeadingLink ?: boolean ;
114- prependLinks ?: [ string , string ] [ ] ;
115- showDepth ?: number ;
116- suppressMissing ?: boolean ;
117115 title ?: string ;
118- withChevron ?: boolean ;
119116} ;
120117
121118export function DynamicNav ( {
122119 root,
123120 title,
124121 tree,
125- collapse = false ,
122+ collapsible = false ,
126123 exclude = [ ] ,
127- showDepth = 0 ,
128- prependLinks = [ ] ,
129- suppressMissing = false ,
130- noHeadingLink = false ,
131- headerClassName,
132- withChevron = false ,
133124} : Props ) {
134125 if ( root . startsWith ( '/' ) ) {
135126 root = root . substring ( 1 ) ;
@@ -141,10 +132,8 @@ export function DynamicNav({
141132 rootBits . forEach ( bit => {
142133 entity = currentTree . find ( n => n . name === bit ) ;
143134 if ( ! entity ) {
144- if ( ! suppressMissing ) {
145- // eslint-disable-next-line no-console
146- console . warn ( `Could not find entity at ${ root } (specifically at ${ bit } )` ) ;
147- }
135+ // eslint-disable-next-line no-console
136+ console . warn ( `Could not find entity at ${ root } (specifically at ${ bit } )` ) ;
148137 return ;
149138 }
150139 currentTree = entity . children ;
@@ -155,44 +144,39 @@ export function DynamicNav({
155144 if ( ! title && entity . node ) {
156145 title = entity . node . context . sidebar_title || entity . node . context . title || '' ;
157146 }
158- const parentNode = entity . children
159- ? entity . children . find ( ( n : EntityTree ) => n . name === '' )
160- : null ;
147+ const parentNode = entity . children ?. find ( ( n : EntityTree ) => n . name === '' ) ;
148+
149+ if ( ! parentNode ) {
150+ // eslint-disable-next-line no-console
151+ console . warn ( `Could not find parentNode at ${ root } ` ) ;
152+ return null ;
153+ }
161154
162155 const { path} = serverContext ( ) ;
163156 const isActive = path . join ( '/' ) . indexOf ( root ) === 0 ;
164157 const linkPath = `/${ path . join ( '/' ) } /` ;
165158
166- const header =
167- parentNode && ! noHeadingLink ? (
168- < SmartLink
169- to = { `/${ root } /` }
170- className = { `${ headerClassName } ${ getUnversionedPath ( path , false ) === root ? 'active' : '' } justify-between` }
171- activeClassName = "active"
172- data-sidebar-link
173- >
174- < strong > { title } </ strong >
175- { withChevron && < NavChevron direction = { isActive ? 'down' : 'right' } /> }
176- </ SmartLink >
177- ) : (
178- < div className = { headerClassName } data-sidebar-link >
179- < strong > { title } </ strong >
180- </ div >
181- ) ;
159+ const header = (
160+ < SmartLink
161+ to = { `/${ root } /` }
162+ className = { `${ styles [ 'sidebar-title' ] } flex items-center ${ getUnversionedPath ( path , false ) === root ? 'active' : '' } justify-between` }
163+ activeClassName = "active"
164+ data-sidebar-link
165+ >
166+ < strong > { title } </ strong >
167+ { collapsible && < NavChevron direction = { isActive ? 'down' : 'right' } /> }
168+ </ SmartLink >
169+ ) ;
182170
183171 return (
184172 < li className = "mb-3" data-sidebar-branch >
185173 { header }
186- { ( ! collapse || isActive ) && entity . children && (
174+ { ( ! collapsible || isActive ) && entity . children && (
187175 < ul data-sidebar-tree className = "pl-3" >
188- { prependLinks &&
189- prependLinks . map ( link => (
190- < SidebarLink to = { link [ 0 ] } key = { link [ 0 ] } title = { link [ 1 ] } path = { linkPath } />
191- ) ) }
192176 < Children
193177 tree = { entity . children }
194178 exclude = { exclude }
195- showDepth = { showDepth }
179+ showDepth = { 0 }
196180 path = { linkPath }
197181 />
198182 </ ul >
0 commit comments