Skip to content

Commit 43ab17f

Browse files
author
Christian Weichel
committed
Incorporated review feedback and moved to QuickPickService
1 parent be20365 commit 43ab17f

File tree

8 files changed

+30
-118
lines changed

8 files changed

+30
-118
lines changed
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

arduino-ide-extension/src/browser/arduino-commands.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { Command } from '@theia/core/lib/common/command';
33
export namespace ArduinoCommands {
44

55
export const VERIFY: Command = {
6-
id: 'arduino-verify'
6+
id: 'arduino-verify',
7+
label: 'Verify Sketch'
78
}
89

910
export const UPLOAD: Command = {
10-
id: 'arduino-upload'
11+
id: 'arduino-upload',
12+
label: 'Upload Sketch'
1113
}
1214

1315
}

arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { CoreService } from '../common/protocol/core-service';
1313
import { WorkspaceServiceExt } from './workspace-service-ext';
1414
import { ToolOutputServiceClient } from '../common/protocol/tool-output-service';
1515
import { ConfirmDialog } from '@theia/core/lib/browser';
16+
import { QuickPickService } from '@theia/core/lib/common/quick-pick-service';
1617

1718

1819
@injectable()
@@ -33,6 +34,9 @@ export class ArduinoFrontendContribution extends DefaultFrontendApplicationContr
3334
@inject(ToolOutputServiceClient)
3435
protected readonly toolOutputServiceClient: ToolOutputServiceClient;
3536

37+
@inject(QuickPickService)
38+
protected readonly quickPickService: QuickPickService;
39+
3640
@postConstruct()
3741
protected async init(): Promise<void> {
3842
// This is a hack. Otherwise, the backend services won't bind.
@@ -56,7 +60,7 @@ export class ArduinoFrontendContribution extends DefaultFrontendApplicationContr
5660
});
5761
registry.registerItem({
5862
id: ConnectedBoards.TOOLBAR_ID,
59-
render: () => <ConnectedBoards boardsService={this.boardService}/>,
63+
render: () => <ConnectedBoards boardsService={this.boardService} quickPickService={this.quickPickService} />,
6064
isVisible: widget => this.isArduinoEditor(widget)
6165
})
6266
}

arduino-ide-extension/src/browser/components/connected-boards.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react';
22
import { BoardsService, Board } from '../../common/protocol/boards-service';
3-
import { SelectBoardDialog } from './select-board-dialog';
3+
// import { SelectBoardDialog } from './select-board-dialog';
4+
import { QuickPickService } from '@theia/core/lib/common/quick-pick-service';
45

56
export class ConnectedBoards extends React.Component<ConnectedBoards.Props, ConnectedBoards.State> {
67
static TOOLBAR_ID: 'connected-boards-toolbar';
@@ -25,7 +26,9 @@ export class ConnectedBoards extends React.Component<ConnectedBoards.Props, Conn
2526
}
2627

2728
return <div className={ConnectedBoards.Styles.CONNECTED_BOARDS_CLASS}>
28-
<select disabled={!this.state.boards} onChange={this.onBoardSelect.bind(this)} value={this.state.selection}>
29+
<select disabled={!this.state.boards}
30+
onChange={this.onBoardSelect.bind(this)}
31+
value={this.state.selection}>
2932
<optgroup label="Attached boards">
3033
{ content }
3134
</optgroup>
@@ -57,7 +60,7 @@ export class ConnectedBoards extends React.Component<ConnectedBoards.Props, Conn
5760
if (selection === "select-other" || selection === "selected-other") {
5861
let selectedBoard = this.state.otherBoard;
5962
if (selection === "select-other" || !selectedBoard) {
60-
selectedBoard = await new SelectBoardDialog(this.props.boardsService).open();
63+
selectedBoard = await this.selectedInstalledBoard();
6164
}
6265
if (!selectedBoard) {
6366
return;
@@ -76,12 +79,27 @@ export class ConnectedBoards extends React.Component<ConnectedBoards.Props, Conn
7679
this.setState({selection});
7780
}
7881

82+
protected async selectedInstalledBoard(): Promise<Board | undefined> {
83+
const {items} = await this.props.boardsService.search({});
84+
85+
const idx = new Map<string, Board>();
86+
items.filter(pkg => !!pkg.installedVersion).forEach(pkg => pkg.boards.forEach(brd => idx.set(`${brd.name}`, brd) ));
87+
88+
const selection = await this.props.quickPickService.show(Array.from(idx.keys()));
89+
if (!selection) {
90+
return;
91+
}
92+
93+
return idx.get(selection);
94+
}
95+
7996
}
8097

8198
export namespace ConnectedBoards {
8299

83100
export interface Props {
84101
readonly boardsService: BoardsService;
102+
readonly quickPickService: QuickPickService;
85103
}
86104

87105
export interface State {

arduino-ide-extension/src/browser/components/select-board-dialog.tsx

Lines changed: 0 additions & 103 deletions
This file was deleted.

arduino-ide-extension/src/node/library-service-impl.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@ export class LibraryServiceImpl implements LibraryService {
2424
const installedLibsIdx = new Map<string, InstalledLibrary>();
2525
installedLibs.forEach(l => installedLibsIdx.set(l.getName(), l));
2626

27-
if (!options.query || options.query.length < 2) {
28-
const items: Library[] = Array.from(installedLibsIdx.values()).map(lib => toLibrary({
29-
name: lib.getName(),
30-
installable: false,
31-
installedVersion: lib.getInstalled()!.getVersion(),
32-
}, lib.getInstalled()!));
33-
return { items };
34-
}
35-
3627
const req = new LibrarySearchReq();
3728
req.setQuery(options.query || '');
3829
req.setInstance(instance);

0 commit comments

Comments
 (0)