@@ -42,34 +42,36 @@ export class BoardsDataMenuUpdater implements FrontendApplicationContribution {
42
42
const { fqbn } = selectedBoard ;
43
43
if ( fqbn ) {
44
44
const { configOptions, programmers, selectedProgrammer } = await this . boardsDataStore . getData ( fqbn ) ;
45
- const boardsConfigMenuPath = [ ...ArduinoMenus . TOOLS , 'z01_boardsConfig' ] ; // `z_` is for ordering.
46
- for ( const { label, option, values } of configOptions . sort ( ConfigOption . LABEL_COMPARATOR ) ) {
47
- const menuPath = [ ...boardsConfigMenuPath , `${ option } ` ] ;
48
- const commands = new Map < string , Disposable & { label : string } > ( )
49
- for ( const value of values ) {
50
- const id = `${ fqbn } -${ option } --${ value . value } ` ;
51
- const command = { id } ;
52
- const selectedValue = value . value ;
53
- const handler = {
54
- execute : ( ) => this . boardsDataStore . selectConfigOption ( { fqbn, option, selectedValue } ) ,
55
- isToggled : ( ) => value . selected
56
- } ;
57
- commands . set ( id , Object . assign ( this . commandRegistry . registerCommand ( command , handler ) , { label : value . label } ) ) ;
45
+ if ( configOptions . length ) {
46
+ const boardsConfigMenuPath = [ ...ArduinoMenus . TOOLS , 'z01_boardsConfig' ] ; // `z_` is for ordering.
47
+ for ( const { label, option, values } of configOptions . sort ( ConfigOption . LABEL_COMPARATOR ) ) {
48
+ const menuPath = [ ...boardsConfigMenuPath , `${ option } ` ] ;
49
+ const commands = new Map < string , Disposable & { label : string } > ( )
50
+ for ( const value of values ) {
51
+ const id = `${ fqbn } -${ option } --${ value . value } ` ;
52
+ const command = { id } ;
53
+ const selectedValue = value . value ;
54
+ const handler = {
55
+ execute : ( ) => this . boardsDataStore . selectConfigOption ( { fqbn, option, selectedValue } ) ,
56
+ isToggled : ( ) => value . selected
57
+ } ;
58
+ commands . set ( id , Object . assign ( this . commandRegistry . registerCommand ( command , handler ) , { label : value . label } ) ) ;
59
+ }
60
+ this . menuRegistry . registerSubmenu ( menuPath , label ) ;
61
+ this . toDisposeOnBoardChange . pushAll ( [
62
+ ...commands . values ( ) ,
63
+ Disposable . create ( ( ) => this . unregisterSubmenu ( menuPath ) ) , // We cannot dispose submenu entries: https://github.com/eclipse-theia/theia/issues/7299
64
+ ...Array . from ( commands . keys ( ) ) . map ( ( commandId , i ) => {
65
+ const { label } = commands . get ( commandId ) ! ;
66
+ this . menuRegistry . registerMenuAction ( menuPath , { commandId, order : `${ i } ` , label } ) ;
67
+ return Disposable . create ( ( ) => this . menuRegistry . unregisterMenuAction ( commandId ) ) ;
68
+ } )
69
+ ] ) ;
58
70
}
59
- this . menuRegistry . registerSubmenu ( menuPath , label ) ;
60
- this . toDisposeOnBoardChange . pushAll ( [
61
- ...commands . values ( ) ,
62
- Disposable . create ( ( ) => this . unregisterSubmenu ( menuPath ) ) , // We cannot dispose submenu entries: https://github.com/eclipse-theia/theia/issues/7299
63
- ...Array . from ( commands . keys ( ) ) . map ( ( commandId , i ) => {
64
- const { label } = commands . get ( commandId ) ! ;
65
- this . menuRegistry . registerMenuAction ( menuPath , { commandId, order : `${ i } ` , label } ) ;
66
- return Disposable . create ( ( ) => this . menuRegistry . unregisterMenuAction ( commandId ) ) ;
67
- } )
68
- ] ) ;
69
71
}
70
72
if ( programmers . length ) {
71
73
const programmersMenuPath = [ ...ArduinoMenus . TOOLS , 'z02_programmers' ] ;
72
- const label = selectedProgrammer ? `Programmer: ${ selectedProgrammer . name } ` : 'Programmer'
74
+ const label = selectedProgrammer ? `Programmer: " ${ selectedProgrammer . name } " ` : 'Programmer'
73
75
this . menuRegistry . registerSubmenu ( programmersMenuPath , label ) ;
74
76
for ( const programmer of programmers ) {
75
77
const { id, name } = programmer ;
0 commit comments