1
1
import * as React from 'react' ;
2
2
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' ;
4
5
5
6
export class ConnectedBoards extends React . Component < ConnectedBoards . Props , ConnectedBoards . State > {
6
7
static TOOLBAR_ID : 'connected-boards-toolbar' ;
@@ -25,7 +26,9 @@ export class ConnectedBoards extends React.Component<ConnectedBoards.Props, Conn
25
26
}
26
27
27
28
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 } >
29
32
< optgroup label = "Attached boards" >
30
33
{ content }
31
34
</ optgroup >
@@ -57,7 +60,7 @@ export class ConnectedBoards extends React.Component<ConnectedBoards.Props, Conn
57
60
if ( selection === "select-other" || selection === "selected-other" ) {
58
61
let selectedBoard = this . state . otherBoard ;
59
62
if ( selection === "select-other" || ! selectedBoard ) {
60
- selectedBoard = await new SelectBoardDialog ( this . props . boardsService ) . open ( ) ;
63
+ selectedBoard = await this . selectedInstalledBoard ( ) ;
61
64
}
62
65
if ( ! selectedBoard ) {
63
66
return ;
@@ -76,12 +79,27 @@ export class ConnectedBoards extends React.Component<ConnectedBoards.Props, Conn
76
79
this . setState ( { selection} ) ;
77
80
}
78
81
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
+
79
96
}
80
97
81
98
export namespace ConnectedBoards {
82
99
83
100
export interface Props {
84
101
readonly boardsService : BoardsService ;
102
+ readonly quickPickService : QuickPickService ;
85
103
}
86
104
87
105
export interface State {
0 commit comments