@@ -13,8 +13,6 @@ import { boardIdentifierLabel, Port } from '../../common/protocol';
13
13
import {
14
14
BoardListItem ,
15
15
BoardListItemUI ,
16
- InferredBoardListItem ,
17
- isInferredBoardListItem ,
18
16
} from '../../common/protocol/board-list' ;
19
17
import { assertUnreachable } from '../../common/utils' ;
20
18
import { BoardListUI , BoardsServiceProvider } from './boards-service-provider' ;
@@ -108,7 +106,7 @@ export class BoardListDropDown extends React.Component<
108
106
109
107
private readonly onDefaultAction = ( item : BoardListItemUI ) : unknown => {
110
108
const { boardList } = this . props ;
111
- const { type, params } = boardList . defaultAction ( item ) ;
109
+ const { type, params } = item . defaultAction ;
112
110
switch ( type ) {
113
111
case 'select-boards-config' : {
114
112
return boardList . onSelect ( params ) ;
@@ -162,61 +160,63 @@ export class BoardListDropDown extends React.Component<
162
160
{ portLabel }
163
161
</ div >
164
162
</ div >
165
- { isInferredBoardListItem ( item ) && this . renderActions ( item ) }
163
+ { this . renderActions ( item ) }
166
164
</ div >
167
165
) ;
168
166
}
169
167
170
- private renderActions ( inferredItem : InferredBoardListItem ) : React . ReactNode {
171
- const { port } = inferredItem ;
172
- const edit = (
173
- < div
174
- id = "edit"
175
- className = { codicon ( 'pencil' , true ) }
176
- title = { nls . localize (
177
- 'arduino/board/editBoardsConfig' ,
178
- 'Edit Board and Port...'
179
- ) }
180
- onClick = { ( event ) => {
181
- event . preventDefault ( ) ;
182
- event . stopPropagation ( ) ;
183
- this . props . boardList . onEdit ( {
184
- query : inferredItem . inferredBoard . name ,
185
- boardToSelect : inferredItem . inferredBoard ,
186
- portToSelect : port ,
187
- } ) ;
188
- } }
189
- />
190
- ) ;
191
- const revert =
192
- inferredItem . type === 'board-overridden' ? (
193
- < div
194
- id = "revert"
195
- className = { codicon ( 'discard' , true ) }
196
- title = { nls . localize (
197
- 'arduino/board/revertBoardsConfig' ,
198
- "Use '{0}' discovered on '{1}'" ,
199
- boardIdentifierLabel ( inferredItem . inferredBoard ) ,
200
- port . address
201
- ) }
202
- onClick = { ( event ) => {
203
- event . preventDefault ( ) ;
204
- event . stopPropagation ( ) ;
205
- this . props . boardList . onSelect ( {
206
- selectedBoard : inferredItem . board ,
207
- selectedPort : port ,
208
- } ) ;
209
- } }
210
- />
211
- ) : undefined ;
168
+ private renderActions ( item : BoardListItemUI ) : React . ReactNode {
169
+ const { boardList } = this . props ;
170
+ const { revert, edit } = item . otherActions ;
171
+ if ( ! edit && ! revert ) {
172
+ return undefined ;
173
+ }
212
174
return (
213
175
< div className = { TabBarToolbar . Styles . TAB_BAR_TOOLBAR } >
214
- < div className = { `${ TabBarToolbar . Styles . TAB_BAR_TOOLBAR_ITEM } enabled` } >
215
- { edit }
216
- </ div >
217
- < div className = { `${ TabBarToolbar . Styles . TAB_BAR_TOOLBAR_ITEM } enabled` } >
218
- { revert }
219
- </ div >
176
+ { edit && (
177
+ < div
178
+ className = { `${ TabBarToolbar . Styles . TAB_BAR_TOOLBAR_ITEM } enabled` }
179
+ >
180
+ {
181
+ < div
182
+ id = "edit"
183
+ className = { codicon ( 'pencil' , true ) }
184
+ title = { nls . localize (
185
+ 'arduino/board/editBoardsConfig' ,
186
+ 'Edit Board and Port...'
187
+ ) }
188
+ onClick = { ( event ) => {
189
+ event . preventDefault ( ) ;
190
+ event . stopPropagation ( ) ;
191
+ boardList . onEdit ( edit . params ) ;
192
+ } }
193
+ />
194
+ }
195
+ </ div >
196
+ ) }
197
+ { revert && (
198
+ < div
199
+ className = { `${ TabBarToolbar . Styles . TAB_BAR_TOOLBAR_ITEM } enabled` }
200
+ >
201
+ {
202
+ < div
203
+ id = "revert"
204
+ className = { codicon ( 'discard' , true ) }
205
+ title = { nls . localize (
206
+ 'arduino/board/revertBoardsConfig' ,
207
+ "Use '{0}' discovered on '{1}'" ,
208
+ boardIdentifierLabel ( revert . params . selectedBoard ) ,
209
+ item . labels . portLabel
210
+ ) }
211
+ onClick = { ( event ) => {
212
+ event . preventDefault ( ) ;
213
+ event . stopPropagation ( ) ;
214
+ boardList . onSelect ( revert . params ) ;
215
+ } }
216
+ />
217
+ }
218
+ </ div >
219
+ ) }
220
220
</ div >
221
221
) ;
222
222
}
0 commit comments