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

Show warning when no boards are installed #1592

Merged
merged 1 commit into from
Feb 15, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
### Added

- [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.
- 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)

### Changed

Expand Down
16 changes: 16 additions & 0 deletions src/arduino/arduinoContentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class ArduinoContentProvider implements vscode.TextDocumentContentProvide
this.addHandlerWithLogger("load-configitems", "/api/configitems", async (req, res) => await this.getBoardConfig(req, res));
this.addHandlerWithLogger("update-selectedboard", "/api/updateselectedboard", (req, res) => this.updateSelectedBoard(req, res), true);
this.addHandlerWithLogger("update-config", "/api/updateconfig", async (req, res) => await this.updateConfig(req, res), true);
this.addHandlerWithLogger("run-command", "/api/runcommand", (req, res) => this.runCommand(req, res), true);

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

public async runCommand(req, res) {
if (!req.body.command) {
return res.status(400).send("BAD Request! Missing { command } parameter!");
} else {
try {
await vscode.commands.executeCommand(req.body.command);
return res.json({
status: "OK",
});
} catch (error) {
return res.status(500).send(`Cannot run command with error message "${error}"`);
}
}
}

public async getLibraries(req, res) {
await ArduinoContext.arduinoApp.libraryManager.loadLibraries(req.query.update === "true");
return res.json({
Expand Down
6 changes: 6 additions & 0 deletions src/views/app/actions/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export function openSettings(query) {
}).then((response) => response.json());
}

export function runCommand(command) {
return postHTTP("/api/runcommand", {
command,
}).then((response) => response.json());
}

export function getLibraries(update) {
return window.fetch(`/api/libraries?update=${update}`).then((response) => response.json());
}
Expand Down
40 changes: 26 additions & 14 deletions src/views/app/components/BoardConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as React from "react";
import { Grid, Row } from "react-bootstrap";
import { connect } from "react-redux";
import * as actions from "../actions";
import * as API from "../actions/api";
import BoardConfigItemView from "./BoardConfigItemView";
import BoardSelector from "./BoardSelector";

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

public render() {
return (<div className="boardConfig">
<Grid fluid>
<Row key="board-selector">
<BoardSelector installedBoards={this.props.installedBoards} loadConfigItems={this.props.loadConfigItems} />
</Row>
{
this.props.configitems.map((configitem, index) => {
return (<Row key={configitem.id}>
<BoardConfigItemView configitem={configitem} />
</Row>);
})
}
</Grid>
</div>);
let installWarning;
if (this.props.installedBoards.length === 0) {
installWarning = (<div className="theme-bgcolor arduinomanager-toolbar">
No boards are installed. <a className="help-link"
onClick={() => API.runCommand("arduino.showBoardManager")}>Install a board with the Boards Manager.</a>
</div>);
}
return (
<div>
{installWarning}
<div className="boardConfig">
<Grid fluid>
<Row key="board-selector">
<BoardSelector installedBoards={this.props.installedBoards} loadConfigItems={this.props.loadConfigItems} />
</Row>
{
this.props.configitems.map((configitem, index) => {
return (<Row key={configitem.id}>
<BoardConfigItemView configitem={configitem} />
</Row>);
})
}
</Grid>
</div>
</div>);
}
}

Expand Down