Skip to content

Commit 0d734ea

Browse files
author
Akos Kitta
committed
fix: refine with vendor
if multiple boards are discovered on the same port Signed-off-by: Akos Kitta <[email protected]>
1 parent 48499ec commit 0d734ea

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

arduino-ide-extension/src/browser/boards/boards-toolbar-item.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export class BoardListDropDown extends React.Component<BoardsDropDown.Props> {
123123
const board = getInferredBoardOrBoard(item);
124124
const boardLabel = board?.name ?? unknownBoard;
125125
const boardFqbn = board?.fqbn;
126+
const vendor = item.metadata?.vendor;
126127
const onDefaultAction = () => {
127128
if (board) {
128129
onSelect({ selectedBoard: board, selectedPort: port });
@@ -161,10 +162,11 @@ export class BoardListDropDown extends React.Component<BoardsDropDown.Props> {
161162
port.address
162163
}`}
163164
>
164-
<div className="arduino-boards-dropdown-item--board-name">
165+
<div className="arduino-boards-dropdown-item--board-header">
165166
<div className="arduino-boards-dropdown-item--board-label noWrapInfo noselect">
166167
{boardLabel}
167168
</div>
169+
{vendor && <div className="vendor">{vendor}</div>}
168170
</div>
169171
<div className="arduino-boards-dropdown-item--port-label noWrapInfo noselect">
170172
{port.addressLabel}

arduino-ide-extension/src/browser/style/boards-config-dialog.css

+16-4
Original file line numberDiff line numberDiff line change
@@ -172,20 +172,19 @@ div#select-board-dialog .selectBoardContainer .list .item.selected i {
172172
width: 210px;
173173
}
174174

175-
.arduino-boards-toolbar-item--protocol,
175+
.arduino-boards-toolbar-item--protocol,
176176
.arduino-boards-dropdown-item--protocol {
177177
align-items: center;
178178
display: flex;
179179
font-size: 16px;
180180
}
181181

182-
.arduino-boards-toolbar-item--protocol ,
182+
.arduino-boards-toolbar-item--protocol,
183183
.arduino-boards-dropdown-item--protocol {
184184
color: var(--theia-arduino-toolbar-dropdown-label);
185185
}
186186

187-
.arduino-boards-toolbar-item-container
188-
.arduino-boards-toolbar-item {
187+
.arduino-boards-toolbar-item-container .arduino-boards-toolbar-item {
189188
display: flex;
190189
align-items: baseline;
191190
width: 100%;
@@ -241,11 +240,24 @@ div#select-board-dialog .selectBoardContainer .list .item.selected i {
241240
padding: 10px;
242241
}
243242

243+
.arduino-boards-dropdown-item--board-header {
244+
display: flex;
245+
align-items: center;
246+
}
247+
244248
.arduino-boards-dropdown-item--label {
245249
overflow: hidden;
246250
flex: 1;
247251
}
248252

253+
.arduino-boards-dropdown-item--board-header .vendor {
254+
color: var(--theia-button-background);
255+
background-color: var(--theia-arduino-toolbar-dropdown-option-backgroundHover);
256+
font-size: 10px;
257+
border-radius: 4px;
258+
margin-left: 2px;
259+
}
260+
249261
/* Redefine default codicon size https://github.com/microsoft/vscode/commit/38cd0a377b7abef34fb07fe770fc633e68819ba6 */
250262
.arduino-boards-dropdown-item .codicon[class*='codicon-'] {
251263
font-size: 14px;

arduino-ide-extension/src/common/protocol/board-list.ts

+25-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ import {
1515
portProtocolComparator,
1616
} from './boards-service';
1717

18+
export interface BoardListItemMetadata {
19+
readonly vendor?: string;
20+
}
21+
1822
export interface BoardListItem {
1923
readonly port: Port;
2024
readonly board?: BoardIdentifier;
25+
readonly metadata?: BoardListItemMetadata;
2126
}
2227

2328
export function isBoardListItem(arg: unknown): arg is BoardListItem {
@@ -248,7 +253,26 @@ export function createBoardList(
248253
};
249254
items.push(inferredItem);
250255
} else {
251-
items.push({ port, board: { fqbn, name } });
256+
// If multiple matching boards are discovered for a detected port, attach the vendor ID of the FQBN as an extra metadata to the item.
257+
// This is to distinguish between boards with the same name but different FQBNs.
258+
// There is not need to apply this, when the board has been overridden.
259+
let vendor: string | undefined = undefined;
260+
if (
261+
board.fqbn &&
262+
boards.some(
263+
(otherDetectedBoardOnPort) =>
264+
otherDetectedBoardOnPort.name === board.name &&
265+
otherDetectedBoardOnPort.fqbn !== board.fqbn
266+
)
267+
) {
268+
[vendor] = board.fqbn.split(':');
269+
}
270+
const item = { port, board: { fqbn, name } };
271+
if (vendor) {
272+
const metadata: BoardListItemMetadata = { vendor };
273+
Object.assign(item, { metadata });
274+
}
275+
items.push(item);
252276
}
253277
}
254278
}

0 commit comments

Comments
 (0)