@@ -3,14 +3,13 @@ import * as ReactDOM from '@theia/core/shared/react-dom';
3
3
import { CommandRegistry } from '@theia/core/lib/common/command' ;
4
4
import { DisposableCollection } from '@theia/core/lib/common/disposable' ;
5
5
import { Port } from '../../common/protocol' ;
6
- import { BoardsConfig } from './ boards-config' ;
6
+ import { OpenBoardsConfig } from '../contributions/open- boards-config' ;
7
7
import {
8
8
BoardsServiceProvider ,
9
9
AvailableBoard ,
10
10
} from './boards-service-provider' ;
11
11
import { nls } from '@theia/core/lib/common' ;
12
12
import classNames from 'classnames' ;
13
- import { OpenBoardsConfig } from '../contributions/open-boards-config' ;
14
13
15
14
export interface BoardsDropDownListCoords {
16
15
readonly top : number ;
@@ -177,7 +176,7 @@ export class BoardsToolBarItem extends React.Component<
177
176
this . toDispose . dispose ( ) ;
178
177
}
179
178
180
- protected readonly show = ( event : React . MouseEvent < HTMLElement > ) => {
179
+ protected readonly show = ( event : React . MouseEvent < HTMLElement > ) : void => {
181
180
const { currentTarget : element } = event ;
182
181
if ( element instanceof HTMLElement ) {
183
182
if ( this . state . coords === 'hidden' ) {
@@ -200,23 +199,24 @@ export class BoardsToolBarItem extends React.Component<
200
199
201
200
override render ( ) : React . ReactNode {
202
201
const { coords, availableBoards } = this . state ;
203
- const boardsConfig = this . props . boardsServiceProvider . boardsConfig ;
204
- const title = BoardsConfig . Config . toString ( boardsConfig , {
205
- default : nls . localize (
206
- 'arduino/common/noBoardSelected' ,
207
- 'No board selected'
208
- ) ,
209
- } ) ;
210
- const decorator = ( ( ) => {
211
- const selectedBoard = availableBoards . find ( ( { selected } ) => selected ) ;
212
- if ( ! selectedBoard || ! selectedBoard . port ) {
213
- return 'fa fa-times notAttached' ;
214
- }
215
- if ( selectedBoard . state === AvailableBoard . State . guessed ) {
216
- return 'fa fa-exclamation-triangle guessed' ;
217
- }
218
- return '' ;
219
- } ) ( ) ;
202
+ const selectedBoard = availableBoards . find ( ( { selected } ) => selected ) ;
203
+
204
+ const boardLabel =
205
+ selectedBoard ?. name ||
206
+ nls . localize ( 'arduino/board/selectBoard' , 'Select Board' ) ;
207
+ const selectedPortLabel = portLabel ( selectedBoard ?. port ?. address ) ;
208
+
209
+ const isConnected = Boolean (
210
+ selectedBoard && AvailableBoard . hasPort ( selectedBoard )
211
+ ) ;
212
+ const protocolIcon = isConnected
213
+ ? iconNameFromProtocol ( selectedBoard ?. port ?. protocol || '' )
214
+ : null ;
215
+ const protocolIconClassNames = classNames (
216
+ 'arduino-boards-toolbar-item--protocol' ,
217
+ 'fa' ,
218
+ protocolIcon
219
+ ) ;
220
220
221
221
return (
222
222
< React . Fragment >
@@ -225,7 +225,7 @@ export class BoardsToolBarItem extends React.Component<
225
225
title = { selectedPortLabel }
226
226
onClick = { this . show }
227
227
>
228
- { protocolIcon && < div className = { procolIconClassNames } /> }
228
+ { protocolIcon && < div className = { protocolIconClassNames } /> }
229
229
< div
230
230
className = { classNames (
231
231
'arduino-boards-toolbar-item--label' ,
@@ -264,11 +264,10 @@ export class BoardsToolBarItem extends React.Component<
264
264
) ;
265
265
}
266
266
267
- protected openDialog = ( ) => {
267
+ protected openDialog = ( ) : void => {
268
268
this . props . commands . executeCommand (
269
269
OpenBoardsConfig . Commands . OPEN_DIALOG . id
270
270
) ;
271
- this . setState ( { coords : 'hidden' } ) ;
272
271
} ;
273
272
}
274
273
export namespace BoardsToolBarItem {
0 commit comments