11// Copyright (c) Microsoft Corporation. All rights reserved.
22// Licensed under the MIT license.
33
4- import * as _ from "lodash" ;
54import { useState , useRef } from "react" ;
65import { reportTabSwitch , WEBVIEW_ID } from "../utils" ;
76import { encodeCommandUriWithTelemetry } from "../../../utils/webview" ;
@@ -48,15 +47,20 @@ export default function NavigationPanel({ isAwtDisabled }: NavigationPanelProps)
4847 const [ activeTab , setActiveTab ] = useState ( groups [ 0 ] . name ) ;
4948 const prevTabRef = useRef ( groups [ 0 ] . name ) ;
5049
51- const studentSection = _ . find ( groups , { name : "Student" } ) ;
52- if ( studentSection ) {
53- for ( const action of studentSection . actions ) {
54- if ( action . command === "java.toggleAwtDevelopment" ) {
55- action . name = `${ isAwtDisabled ? "Enable" : "Disable" } AWT Development` ;
56- action . args = [ isAwtDisabled ] ;
57- }
58- }
59- }
50+ const resolvedGroups = groups . map ( group => {
51+ if ( group . name !== "Student" ) return group ;
52+ return {
53+ ...group ,
54+ actions : group . actions . map ( action => {
55+ if ( action . command !== "java.toggleAwtDevelopment" ) return action ;
56+ return {
57+ ...action ,
58+ name : `${ isAwtDisabled ? "Enable" : "Disable" } AWT Development` ,
59+ args : [ isAwtDisabled ] ,
60+ } ;
61+ } ) ,
62+ } ;
63+ } ) ;
6064
6165 const onSwitchTab = ( newTab : string ) => {
6266 reportTabSwitch ( prevTabRef . current , newTab ) ;
@@ -67,7 +71,7 @@ export default function NavigationPanel({ isAwtDisabled }: NavigationPanelProps)
6771 return (
6872 < div id = "navigationPanel" >
6973 < ul className = "nav-tabs" role = "tablist" >
70- { groups . map ( group => (
74+ { resolvedGroups . map ( group => (
7175 < li key = { group . name } className = "navigation-tab" >
7276 < button
7377 role = "tab"
@@ -82,7 +86,7 @@ export default function NavigationPanel({ isAwtDisabled }: NavigationPanelProps)
8286 </ li >
8387 ) ) }
8488 </ ul >
85- { groups . map ( group => (
89+ { resolvedGroups . map ( group => (
8690 activeTab === group . name && (
8791 < div key = { group . name } className = "navigation-tabcontent" role = "tabpanel" >
8892 < div className = "list-group" >
0 commit comments