Skip to content

Commit f24aed6

Browse files
author
Akos Kitta
committed
feat: aligned board+port status bar with toolbar tooltip
1 parent 20d99f5 commit f24aed6

File tree

3 files changed

+37
-18
lines changed

3 files changed

+37
-18
lines changed

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

+13-8
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,18 @@ export class BoardsToolBarItem extends React.Component<
296296
const boardLabel =
297297
selectedBoard?.name ||
298298
nls.localize('arduino/board/selectBoard', 'Select Board');
299-
const selectedPortLabel = portLabel(selectedPort?.address);
299+
const boardFqbn = selectedBoard?.fqbn;
300+
const selectedItem: BoardListItem | undefined =
301+
boardList[boardList.selectedIndex];
302+
let tooltip = `${boardLabel}${boardFqbn ? ` (${boardFqbn})` : ''}${
303+
selectedPort ? `\n${selectedPort.address}` : ''
304+
}`;
305+
if (selectedPort && !selectedItem) {
306+
tooltip += ` ${nls.localize(
307+
'arduino/common/notConnected',
308+
'[not connected]'
309+
)}`;
310+
}
300311

301312
const isConnected = boardList.selectedIndex >= 0;
302313
const protocolIcon = isConnected
@@ -321,7 +332,7 @@ export class BoardsToolBarItem extends React.Component<
321332
<React.Fragment>
322333
<div
323334
className="arduino-boards-toolbar-item-container"
324-
title={selectedPortLabel}
335+
title={tooltip}
325336
onClick={this.show}
326337
>
327338
{protocolIcon && <div className={protocolIconClassNames} />}
@@ -373,9 +384,3 @@ function iconNameFromProtocol(protocol: string): string {
373384
return 'fa-arduino-technology-3dimensionscube';
374385
}
375386
}
376-
377-
function portLabel(portName?: string): string {
378-
return portName
379-
? nls.localize('arduino/board/portLabel', 'Port: {0}', portName)
380-
: nls.localize('arduino/board/disconnected', 'Disconnected');
381-
}

arduino-ide-extension/src/browser/contributions/selected-board.ts

+24-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import {
44
} from '@theia/core/lib/browser/status-bar/status-bar';
55
import { nls } from '@theia/core/lib/common/nls';
66
import { inject, injectable } from '@theia/core/shared/inversify';
7-
import type { BoardList } from '../../common/protocol/board-list';
7+
import type {
8+
BoardList,
9+
BoardListItem,
10+
} from '../../common/protocol/board-list';
811
import { BoardsServiceProvider } from '../boards/boards-service-provider';
912
import { Contribution } from './contribution';
1013

@@ -38,17 +41,30 @@ export class SelectedBoard extends Contribution {
3841
className: 'arduino-selected-board',
3942
});
4043
if (selectedBoard) {
44+
const notConnectedLabel = nls.localize(
45+
'arduino/common/notConnected',
46+
'[not connected]'
47+
);
48+
let portLabel = notConnectedLabel;
49+
if (selectedPort) {
50+
portLabel = nls.localize(
51+
'arduino/common/selectedOn',
52+
'on {0}',
53+
selectedPort.address
54+
);
55+
const selectedItem: BoardListItem | undefined =
56+
boardList[boardList.selectedIndex];
57+
if (!selectedItem) {
58+
portLabel += ` ${notConnectedLabel}`; // append ` [not connected]` when the port is selected but it's not detected by the CLI
59+
}
60+
}
4161
this.statusBar.setElement('arduino-selected-port', {
4262
alignment: StatusBarAlignment.RIGHT,
43-
text: selectedPort
44-
? nls.localize(
45-
'arduino/common/selectedOn',
46-
'on {0}',
47-
selectedPort.address
48-
)
49-
: nls.localize('arduino/common/notConnected', '[not connected]'),
63+
text: portLabel,
5064
className: 'arduino-selected-port',
5165
});
66+
} else {
67+
this.statusBar.removeElement('arduino-selected-port');
5268
}
5369
}
5470
}

i18n/en.json

-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"boards": "boards",
1818
"configDialog1": "Select both a Board and a Port if you want to upload a sketch.",
1919
"configDialog2": "If you only select a Board you will be able to compile, but not to upload your sketch.",
20-
"disconnected": "Disconnected",
2120
"editBoardsConfig": "Edit Board and Port...",
2221
"getBoardInfo": "Get Board Info",
2322
"inSketchbook": " (in Sketchbook)",
@@ -29,7 +28,6 @@
2928
"openBoardsConfig": "Select other board and port…",
3029
"pleasePickBoard": "Please pick a board connected to the port you have selected.",
3130
"port": "Port{0}",
32-
"portLabel": "Port: {0}",
3331
"ports": "ports",
3432
"programmer": "Programmer",
3533
"revertBoardsConfig": "Revert the selected '{0}' board to '{1}' detected on '{2}'",

0 commit comments

Comments
 (0)