@@ -10,6 +10,11 @@ const TabNavigation: React.FC = () => {
1010 const [ showRightIndicator , setShowRightIndicator ] = useState ( false ) ;
1111
1212 const handleTabClick = ( tab : 'code' | 'sca' | 'scanning' ) => {
13+ // Don't allow switching to scanning tab if it's disabled
14+ if ( tab === 'scanning' && ! state . ideScanningEnabled ) {
15+ return ;
16+ }
17+
1318 dispatch ( { type : 'SET_ACTIVE_TAB' , payload : tab } ) ;
1419
1520 // Scroll to active tab if it's not fully visible
@@ -88,28 +93,30 @@ const TabNavigation: React.FC = () => {
8893
8994 event . preventDefault ( ) ;
9095
91- const tabs = [ 'code' , 'sca' , 'scanning' ] as const ;
92- const currentIndex = tabs . indexOf ( state . activeTab ) ;
96+ // Filter available tabs based on IDE scanning config
97+ const allTabs = [ 'code' , 'sca' , 'scanning' ] as const ;
98+ const availableTabs = state . ideScanningEnabled ? allTabs : ( [ 'code' , 'sca' ] as const ) ;
99+ const currentIndex = availableTabs . indexOf ( state . activeTab as any ) ;
93100
94101 let newIndex = currentIndex ;
95102
96103 switch ( event . key ) {
97104 case 'ArrowLeft' :
98- newIndex = currentIndex > 0 ? currentIndex - 1 : tabs . length - 1 ;
105+ newIndex = currentIndex > 0 ? currentIndex - 1 : availableTabs . length - 1 ;
99106 break ;
100107 case 'ArrowRight' :
101- newIndex = currentIndex < tabs . length - 1 ? currentIndex + 1 : 0 ;
108+ newIndex = currentIndex < availableTabs . length - 1 ? currentIndex + 1 : 0 ;
102109 break ;
103110 case 'Home' :
104111 newIndex = 0 ;
105112 break ;
106113 case 'End' :
107- newIndex = tabs . length - 1 ;
114+ newIndex = availableTabs . length - 1 ;
108115 break ;
109116 }
110117
111118 if ( newIndex !== currentIndex ) {
112- handleTabClick ( tabs [ newIndex ] ) ;
119+ handleTabClick ( availableTabs [ newIndex ] ) ;
113120 }
114121 } ;
115122
@@ -145,6 +152,14 @@ const TabNavigation: React.FC = () => {
145152 setTimeout ( ( ) => updateScrollIndicators ( ) , 100 ) ;
146153 } , [ state . vulnerabilities . length , state . scaVulnerabilities . length , state . scanState . isScanning ] ) ;
147154
155+ // Handle tab switching when IDE scanning is disabled
156+ useEffect ( ( ) => {
157+ if ( ! state . ideScanningEnabled && state . activeTab === 'scanning' ) {
158+ // Switch to code tab if scanning tab is disabled and currently active
159+ dispatch ( { type : 'SET_ACTIVE_TAB' , payload : 'code' } ) ;
160+ }
161+ } , [ state . ideScanningEnabled , state . activeTab , dispatch ] ) ;
162+
148163 return (
149164 < div className = "tab-navigation-container" >
150165 < div className = "nav-tabs-wrapper" >
@@ -206,23 +221,25 @@ const TabNavigation: React.FC = () => {
206221 ) }
207222 </ button >
208223 </ li >
209- < li className = "nav-item" role = "presentation" >
210- < button
211- className = { `nav-link ${ state . activeTab === 'scanning' ? 'active' : '' } ` }
212- onClick = { ( ) => handleTabClick ( 'scanning' ) }
213- type = "button"
214- role = "tab"
215- aria-selected = { state . activeTab === 'scanning' }
216- >
217- < i className = "fas fa-search" > </ i >
218- Scanning
219- { state . scanState . isScanning && (
220- < span className = "count-badge scanning-indicator" >
221- < i className = "fas fa-spinner fa-spin" > </ i >
222- </ span >
223- ) }
224- </ button >
225- </ li >
224+ { state . ideScanningEnabled && (
225+ < li className = "nav-item" role = "presentation" >
226+ < button
227+ className = { `nav-link ${ state . activeTab === 'scanning' ? 'active' : '' } ` }
228+ onClick = { ( ) => handleTabClick ( 'scanning' ) }
229+ type = "button"
230+ role = "tab"
231+ aria-selected = { state . activeTab === 'scanning' }
232+ >
233+ < i className = "fas fa-search" > </ i >
234+ Scanning
235+ { state . scanState . isScanning && (
236+ < span className = "count-badge scanning-indicator" >
237+ < i className = "fas fa-spinner fa-spin" > </ i >
238+ </ span >
239+ ) }
240+ </ button >
241+ </ li >
242+ ) }
226243 </ ul >
227244 </ div >
228245 </ div >
0 commit comments