Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
for (let i = 0; !hasChanged && i < availableBoards.length; i++) {
const [left, right] = [availableBoards[i], currentAvailableBoards[i]];
hasChanged =
left.fqbn !== right.fqbn ||
!!AvailableBoard.compare(left, right) ||
left.selected !== right.selected;
}
Expand Down
36 changes: 24 additions & 12 deletions arduino-ide-extension/src/browser/boards/boards-toolbar-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from './boards-service-provider';
import { nls } from '@theia/core/lib/common';
import classNames from 'classnames';
import { BoardsConfig } from './boards-config';

export interface BoardsDropDownListCoords {
readonly top: number;
Expand Down Expand Up @@ -199,18 +200,17 @@ export class BoardsToolBarItem extends React.Component<

override render(): React.ReactNode {
const { coords, availableBoards } = this.state;
const selectedBoard = availableBoards.find(({ selected }) => selected);
const { selectedBoard, selectedPort } =
this.props.boardsServiceProvider.boardsConfig;

const boardLabel =
selectedBoard?.name ||
nls.localize('arduino/board/selectBoard', 'Select Board');
const selectedPortLabel = portLabel(selectedBoard?.port?.address);
const selectedPortLabel = portLabel(selectedPort?.address);

const isConnected = Boolean(
selectedBoard && AvailableBoard.hasPort(selectedBoard)
);
const isConnected = Boolean(selectedBoard && selectedPort);
const protocolIcon = isConnected
? iconNameFromProtocol(selectedBoard?.port?.protocol || '')
? iconNameFromProtocol(selectedPort?.protocol || '')
: null;
const protocolIconClassNames = classNames(
'arduino-boards-toolbar-item--protocol',
Expand Down Expand Up @@ -244,11 +244,13 @@ export class BoardsToolBarItem extends React.Component<
.map((board) => ({
...board,
onClick: () => {
if (board.state === AvailableBoard.State.incomplete) {
if (!board.fqbn) {
const previousBoardConfig =
this.props.boardsServiceProvider.boardsConfig;
this.props.boardsServiceProvider.boardsConfig = {
selectedPort: board.port,
};
this.openDialog();
this.openDialog(previousBoardConfig);
} else {
this.props.boardsServiceProvider.boardsConfig = {
selectedBoard: board,
Expand All @@ -264,10 +266,20 @@ export class BoardsToolBarItem extends React.Component<
);
}

protected openDialog = (): void => {
this.props.commands.executeCommand(
OpenBoardsConfig.Commands.OPEN_DIALOG.id
);
protected openDialog = async (
previousBoardConfig?: BoardsConfig.Config
): Promise<void> => {
const selectedBoardConfig =
await this.props.commands.executeCommand<BoardsConfig.Config>(
OpenBoardsConfig.Commands.OPEN_DIALOG.id
);
if (
previousBoardConfig &&
(!selectedBoardConfig?.selectedPort ||
!selectedBoardConfig?.selectedBoard)
) {
this.props.boardsServiceProvider.boardsConfig = previousBoardConfig;
}
};
}
export namespace BoardsToolBarItem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class OpenBoardsConfig extends Contribution {
execute: async (query?: string | undefined) => {
const boardsConfig = await this.boardsConfigDialog.open(query);
if (boardsConfig) {
this.boardsServiceProvider.boardsConfig = boardsConfig;
return (this.boardsServiceProvider.boardsConfig = boardsConfig);
}
},
});
Expand Down