Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit c555bd7

Browse files
authored
Merge pull request #1592 from microsoft/dev/bemcmorr/warn-on-no-installed-boards
Show warning when no boards are installed
2 parents 35a3afc + 7c415dc commit c555bd7

File tree

4 files changed

+49
-14
lines changed

4 files changed

+49
-14
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
1010
### Added
1111

1212
- [Arduino CLI](https://arduino.github.io/arduino-cli/0.30/) version 0.30.0 is now bundled with the extension [#1584](https://github.com/microsoft/vscode-arduino/pull/1584). To use the bundled version of Arduino CLI, `arduino.useArduinoCli` should be `true`, and `arduino.path` and `arduino.commandPath` should be empty or unset. Additionally, prompts will appear to switch to the bundled version whenever the legacy Arduino IDE is used or manually specified Arduino tools cannot be found.
13+
- A warning will appear in the Board Configuration view when no boards are installed. This warning links to the Board Manager view to install boards. [#1592](https://github.com/microsoft/vscode-arduino/pull/1584)
1314

1415
### Changed
1516

src/arduino/arduinoContentProvider.ts

+16
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class ArduinoContentProvider implements vscode.TextDocumentContentProvide
4141
this.addHandlerWithLogger("load-configitems", "/api/configitems", async (req, res) => await this.getBoardConfig(req, res));
4242
this.addHandlerWithLogger("update-selectedboard", "/api/updateselectedboard", (req, res) => this.updateSelectedBoard(req, res), true);
4343
this.addHandlerWithLogger("update-config", "/api/updateconfig", async (req, res) => await this.updateConfig(req, res), true);
44+
this.addHandlerWithLogger("run-command", "/api/runcommand", (req, res) => this.runCommand(req, res), true);
4445

4546
// Arduino Examples TreeView
4647
this.addHandlerWithLogger("show-examplesview", "/examples", (req, res) => this.getHtmlView(req, res));
@@ -170,6 +171,21 @@ export class ArduinoContentProvider implements vscode.TextDocumentContentProvide
170171
}
171172
}
172173

174+
public async runCommand(req, res) {
175+
if (!req.body.command) {
176+
return res.status(400).send("BAD Request! Missing { command } parameter!");
177+
} else {
178+
try {
179+
await vscode.commands.executeCommand(req.body.command);
180+
return res.json({
181+
status: "OK",
182+
});
183+
} catch (error) {
184+
return res.status(500).send(`Cannot run command with error message "${error}"`);
185+
}
186+
}
187+
}
188+
173189
public async getLibraries(req, res) {
174190
await ArduinoContext.arduinoApp.libraryManager.loadLibraries(req.query.update === "true");
175191
return res.json({

src/views/app/actions/api.ts

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ export function openSettings(query) {
4343
}).then((response) => response.json());
4444
}
4545

46+
export function runCommand(command) {
47+
return postHTTP("/api/runcommand", {
48+
command,
49+
}).then((response) => response.json());
50+
}
51+
4652
export function getLibraries(update) {
4753
return window.fetch(`/api/libraries?update=${update}`).then((response) => response.json());
4854
}

src/views/app/components/BoardConfig.tsx

+26-14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as React from "react";
55
import { Grid, Row } from "react-bootstrap";
66
import { connect } from "react-redux";
77
import * as actions from "../actions";
8+
import * as API from "../actions/api";
89
import BoardConfigItemView from "./BoardConfigItemView";
910
import BoardSelector from "./BoardSelector";
1011

@@ -41,20 +42,31 @@ class BoardConfig extends React.Component<IBoardConfigProps, React.Props<any>> {
4142
}
4243

4344
public render() {
44-
return (<div className="boardConfig">
45-
<Grid fluid>
46-
<Row key="board-selector">
47-
<BoardSelector installedBoards={this.props.installedBoards} loadConfigItems={this.props.loadConfigItems} />
48-
</Row>
49-
{
50-
this.props.configitems.map((configitem, index) => {
51-
return (<Row key={configitem.id}>
52-
<BoardConfigItemView configitem={configitem} />
53-
</Row>);
54-
})
55-
}
56-
</Grid>
57-
</div>);
45+
let installWarning;
46+
if (this.props.installedBoards.length === 0) {
47+
installWarning = (<div className="theme-bgcolor arduinomanager-toolbar">
48+
No boards are installed. <a className="help-link"
49+
onClick={() => API.runCommand("arduino.showBoardManager")}>Install a board with the Boards Manager.</a>
50+
</div>);
51+
}
52+
return (
53+
<div>
54+
{installWarning}
55+
<div className="boardConfig">
56+
<Grid fluid>
57+
<Row key="board-selector">
58+
<BoardSelector installedBoards={this.props.installedBoards} loadConfigItems={this.props.loadConfigItems} />
59+
</Row>
60+
{
61+
this.props.configitems.map((configitem, index) => {
62+
return (<Row key={configitem.id}>
63+
<BoardConfigItemView configitem={configitem} />
64+
</Row>);
65+
})
66+
}
67+
</Grid>
68+
</div>
69+
</div>);
5870
}
5971
}
6072

0 commit comments

Comments
 (0)