feat: show the selected board config value on menu

closes #343

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta 2022-12-07 16:13:41 +01:00 committed by Akos Kitta
parent d3a863911c
commit af468a73bc

View File

@ -80,16 +80,16 @@ export class BoardsDataMenuUpdater implements FrontendApplicationContribution {
string, string,
Disposable & { label: string } Disposable & { label: string }
>(); >();
let selectedValue = '';
for (const value of values) { for (const value of values) {
const id = `${fqbn}-${option}--${value.value}`; const id = `${fqbn}-${option}--${value.value}`;
const command = { id }; const command = { id };
const selectedValue = value.value;
const handler = { const handler = {
execute: () => execute: () =>
this.boardsDataStore.selectConfigOption({ this.boardsDataStore.selectConfigOption({
fqbn, fqbn,
option, option,
selectedValue, selectedValue: value.value,
}), }),
isToggled: () => value.selected, isToggled: () => value.selected,
}; };
@ -100,8 +100,14 @@ export class BoardsDataMenuUpdater implements FrontendApplicationContribution {
{ label: value.label } { label: value.label }
) )
); );
if (value.selected) {
selectedValue = value.label;
}
} }
this.menuRegistry.registerSubmenu(menuPath, label); this.menuRegistry.registerSubmenu(
menuPath,
`${label}${selectedValue ? `: "${selectedValue}"` : ''}`
);
this.toDisposeOnBoardChange.pushAll([ this.toDisposeOnBoardChange.pushAll([
...commands.values(), ...commands.values(),
Disposable.create(() => Disposable.create(() =>