@@ -2,6 +2,7 @@ import { useState, useRef, useEffect, useCallback } from 'react'
22import { Layout } from '@ui/components/editor/settings/Layout'
33import { NavigationItem } from '@ui/components/editor/settings/NavigationItem'
44import { ModelProvidersSection } from './sections/ModelProvidersSection'
5+ import { NavigationDivider } from '@ui/components/editor/settings/NavigationDivider'
56import { Item } from '@ui/components/editor/settings/Item'
67import { ApiToolConfigurationSection } from './sections/ApiToolConfigurationSection'
78import { dictionary } from '@shared/constants/dictionary'
@@ -21,19 +22,26 @@ type NavItem =
2122 | 'intelligent-update'
2223 | 'commit-messages'
2324
24- const NAV_ITEMS_CONFIG : { id : NavItem ; label : string } [ ] = [
25+ type NavConfigItem =
26+ | { type : 'item' ; id : NavItem ; label : string }
27+ | { type : 'divider' ; text ?: string }
28+
29+ const NAV_ITEMS_CONFIG : NavConfigItem [ ] = [
2530 {
31+ type : 'item' ,
2632 id : 'general' ,
2733 label : 'General'
2834 } ,
2935 {
36+ type : 'item' ,
3037 id : 'model-providers' ,
3138 label : dictionary . settings . MODEL_PROVIDERS_LABEL
3239 } ,
33- { id : 'edit-context' , label : 'Edit Context' } ,
34- { id : 'code-completions' , label : 'Code Completions' } ,
35- { id : 'intelligent-update' , label : 'Intelligent Update' } ,
36- { id : 'commit-messages' , label : 'Commit Messages' }
40+ { type : 'divider' , text : 'API Tools' } ,
41+ { type : 'item' , id : 'edit-context' , label : 'Edit Context' } ,
42+ { type : 'item' , id : 'code-completions' , label : 'Code Completions' } ,
43+ { type : 'item' , id : 'intelligent-update' , label : 'Intelligent Update' } ,
44+ { type : 'item' , id : 'commit-messages' , label : 'Commit Messages' }
3745]
3846
3947type Props = {
@@ -124,7 +132,10 @@ export const Home: React.FC<Props> = (props) => {
124132 [ handle_stuck_change ]
125133 )
126134
127- const nav_item_ids = NAV_ITEMS_CONFIG . map ( ( item ) => item . id )
135+ const nav_item_ids = NAV_ITEMS_CONFIG . filter (
136+ ( item ) : item is Extract < NavConfigItem , { type : 'item' } > =>
137+ item . type === 'item'
138+ ) . map ( ( item ) => item . id )
128139 const active_nav_item_id =
129140 nav_item_ids . filter ( ( id ) => stuck_sections . has ( id ) ) . pop ( ) || nav_item_ids [ 0 ]
130141
@@ -185,19 +196,21 @@ export const Home: React.FC<Props> = (props) => {
185196 < Layout
186197 ref = { scroll_container_ref }
187198 title = { dictionary . settings . SETTINGS_TITLE }
188- sidebar = {
189- < >
190- { NAV_ITEMS_CONFIG . map ( ( { id, label } ) => (
191- < NavigationItem
192- key = { id }
193- href = { `#${ id } ` }
194- label = { label }
195- is_active = { id === active_nav_item_id }
196- on_click = { ( e ) => handle_nav_click ( e , id ) }
197- />
198- ) ) }
199- </ >
200- }
199+ sidebar = { NAV_ITEMS_CONFIG . map ( ( item , i ) => {
200+ if ( item . type == 'divider' ) {
201+ return < NavigationDivider key = { i } text = { item . text } />
202+ }
203+
204+ return (
205+ < NavigationItem
206+ key = { i }
207+ href = { `#${ item . id } ` }
208+ label = { item . label }
209+ is_active = { item . id === active_nav_item_id }
210+ on_click = { ( e ) => handle_nav_click ( e , item . id ) }
211+ />
212+ )
213+ } ) }
201214 >
202215 < Section
203216 ref = { ( el ) => ( section_refs . current [ 'general' ] = el ) }
0 commit comments