Skip to content

Commit 64ce35e

Browse files
Akos Kittakittaakos
authored andcommitted
feat: show in tooltip if core is from sketchbook
Closes #2270 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 2dae4c8 commit 64ce35e

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

arduino-ide-extension/src/browser/boards/boards-config-component.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,33 @@ namespace BoardsConfigComponent {
4848
}
4949
}
5050

51-
export abstract class Item<T> extends React.Component<{
51+
class Item<T> extends React.Component<{
5252
item: T;
5353
label: string;
5454
selected: boolean;
5555
onClick: (item: T) => void;
5656
missing?: boolean;
5757
details?: string;
58+
title?: string | ((item: T) => string);
5859
}> {
5960
override render(): React.ReactNode {
60-
const { selected, label, missing, details } = this.props;
61+
const { selected, label, missing, details, item } = this.props;
6162
const classNames = ['item'];
6263
if (selected) {
6364
classNames.push('selected');
6465
}
6566
if (missing === true) {
6667
classNames.push('missing');
6768
}
69+
let title = this.props.title ?? `${label}${!details ? '' : details}`;
70+
if (typeof title === 'function') {
71+
title = title(item);
72+
}
6873
return (
6974
<div
7075
onClick={this.onClick}
7176
className={classNames.join(' ')}
72-
title={`${label}${!details ? '' : details}`}
77+
title={title}
7378
>
7479
<div className="label">{label}</div>
7580
{!details ? '' : <div className="details">{details}</div>}
@@ -234,16 +239,28 @@ export class BoardsConfigComponent extends React.Component<
234239
distinctBoards.set(key, board);
235240
}
236241
}
242+
const title = (board: Board.Detailed): string => {
243+
const { details, manuallyInstalled } = board;
244+
let label = board.name;
245+
if (details) {
246+
label += details;
247+
}
248+
if (manuallyInstalled) {
249+
label += nls.localize('arduino/board/inSketchbook', ' (in Sketchbook)');
250+
}
251+
return label;
252+
};
237253

238254
const boardsList = Array.from(distinctBoards.values()).map((board) => (
239-
<Item<BoardWithPackage>
255+
<Item<Board.Detailed>
240256
key={toKey(board)}
241257
item={board}
242258
label={board.name}
243259
details={board.details}
244260
selected={board.selected}
245261
onClick={this.selectBoard}
246262
missing={board.missing}
263+
title={title}
247264
/>
248265
));
249266

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy