mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-08 03:46:33 +00:00
feat: show in tooltip if core is from sketchbook
Closes #2270 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
parent
2dae4c8258
commit
64ce35edbb
@ -48,16 +48,17 @@ namespace BoardsConfigComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export abstract class Item<T> extends React.Component<{
|
class Item<T> extends React.Component<{
|
||||||
item: T;
|
item: T;
|
||||||
label: string;
|
label: string;
|
||||||
selected: boolean;
|
selected: boolean;
|
||||||
onClick: (item: T) => void;
|
onClick: (item: T) => void;
|
||||||
missing?: boolean;
|
missing?: boolean;
|
||||||
details?: string;
|
details?: string;
|
||||||
|
title?: string | ((item: T) => string);
|
||||||
}> {
|
}> {
|
||||||
override render(): React.ReactNode {
|
override render(): React.ReactNode {
|
||||||
const { selected, label, missing, details } = this.props;
|
const { selected, label, missing, details, item } = this.props;
|
||||||
const classNames = ['item'];
|
const classNames = ['item'];
|
||||||
if (selected) {
|
if (selected) {
|
||||||
classNames.push('selected');
|
classNames.push('selected');
|
||||||
@ -65,11 +66,15 @@ export abstract class Item<T> extends React.Component<{
|
|||||||
if (missing === true) {
|
if (missing === true) {
|
||||||
classNames.push('missing');
|
classNames.push('missing');
|
||||||
}
|
}
|
||||||
|
let title = this.props.title ?? `${label}${!details ? '' : details}`;
|
||||||
|
if (typeof title === 'function') {
|
||||||
|
title = title(item);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
onClick={this.onClick}
|
onClick={this.onClick}
|
||||||
className={classNames.join(' ')}
|
className={classNames.join(' ')}
|
||||||
title={`${label}${!details ? '' : details}`}
|
title={title}
|
||||||
>
|
>
|
||||||
<div className="label">{label}</div>
|
<div className="label">{label}</div>
|
||||||
{!details ? '' : <div className="details">{details}</div>}
|
{!details ? '' : <div className="details">{details}</div>}
|
||||||
@ -234,9 +239,20 @@ export class BoardsConfigComponent extends React.Component<
|
|||||||
distinctBoards.set(key, board);
|
distinctBoards.set(key, board);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const title = (board: Board.Detailed): string => {
|
||||||
|
const { details, manuallyInstalled } = board;
|
||||||
|
let label = board.name;
|
||||||
|
if (details) {
|
||||||
|
label += details;
|
||||||
|
}
|
||||||
|
if (manuallyInstalled) {
|
||||||
|
label += nls.localize('arduino/board/inSketchbook', ' (in Sketchbook)');
|
||||||
|
}
|
||||||
|
return label;
|
||||||
|
};
|
||||||
|
|
||||||
const boardsList = Array.from(distinctBoards.values()).map((board) => (
|
const boardsList = Array.from(distinctBoards.values()).map((board) => (
|
||||||
<Item<BoardWithPackage>
|
<Item<Board.Detailed>
|
||||||
key={toKey(board)}
|
key={toKey(board)}
|
||||||
item={board}
|
item={board}
|
||||||
label={board.name}
|
label={board.name}
|
||||||
@ -244,6 +260,7 @@ export class BoardsConfigComponent extends React.Component<
|
|||||||
selected={board.selected}
|
selected={board.selected}
|
||||||
onClick={this.selectBoard}
|
onClick={this.selectBoard}
|
||||||
missing={board.missing}
|
missing={board.missing}
|
||||||
|
title={title}
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user