Skip to content

Commit

Permalink
feat: show in tooltip if core is from sketchbook
Browse files Browse the repository at this point in the history
Closes #2270

Signed-off-by: Akos Kitta <[email protected]>
  • Loading branch information
Akos Kitta authored and kittaakos committed Dec 13, 2023
1 parent 2dae4c8 commit 64ce35e
Showing 1 changed file with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,33 @@ namespace BoardsConfigComponent {
}
}

export abstract class Item<T> extends React.Component<{
class Item<T> extends React.Component<{
item: T;
label: string;
selected: boolean;
onClick: (item: T) => void;
missing?: boolean;
details?: string;
title?: string | ((item: T) => string);
}> {
override render(): React.ReactNode {
const { selected, label, missing, details } = this.props;
const { selected, label, missing, details, item } = this.props;
const classNames = ['item'];
if (selected) {
classNames.push('selected');
}
if (missing === true) {
classNames.push('missing');
}
let title = this.props.title ?? `${label}${!details ? '' : details}`;
if (typeof title === 'function') {
title = title(item);
}
return (
<div
onClick={this.onClick}
className={classNames.join(' ')}
title={`${label}${!details ? '' : details}`}
title={title}
>
<div className="label">{label}</div>
{!details ? '' : <div className="details">{details}</div>}
Expand Down Expand Up @@ -234,16 +239,28 @@ export class BoardsConfigComponent extends React.Component<
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) => (
<Item<BoardWithPackage>
<Item<Board.Detailed>
key={toKey(board)}
item={board}
label={board.name}
details={board.details}
selected={board.selected}
onClick={this.selectBoard}
missing={board.missing}
title={title}
/>
));

Expand Down

0 comments on commit 64ce35e

Please sign in to comment.