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

Add warning and link for no installed examples #1594

Merged
merged 4 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ 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)
- 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/1592)
- A warning will appear in the Arduino Examples view when no examples are installed. [#1594](https://github.com/microsoft/vscode-arduino/pull/1594)

### Changed

Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@
}
]
},
"viewsWelcome": [
{
"view": "arduinoExampleExplorer",
"contents": "No examples are installed. [Find additional examples online.](https://go.microsoft.com/fwlink/?linkid=2225276)"
}
],
"debuggers": [
{
"type": "arduino",
Expand Down
8 changes: 8 additions & 0 deletions src/arduino/exampleProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,18 @@ export class ExampleProvider implements vscode.TreeDataProvider<ExampleItem> {
this._exmaples = null;
this._exampleManager.loadExamples().then((examples) => {
this._exmaples = examples;
if (!this.hasAnyExamples(this._exmaples)) {
// Reset the examples list to get the welcome message (defined in package.json) to appear.
this._exmaples = [];
}
this._onDidChangeTreeData.fire(null);
});
}

private hasAnyExamples(nodes?: IExampleNode[]): boolean {
return nodes && (nodes.find((node) => node.isLeaf || this.hasAnyExamples(node.children)) !== undefined);
}

private createExampleItemList(examples: IExampleNode[]): ExampleItem[] {
const result = [];
if (examples && examples.length) {
Expand Down
3 changes: 3 additions & 0 deletions src/views/app/components/ExampleTreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { connect } from "react-redux";
import * as actions from "../actions";
import * as API from "../actions/api";

// TODO: I'm pretty sure this entire view is unused and can be removed.
// See exampleProvider.ts which instead uses the built-in VS Code Tree View API.

interface IExampleViewProps extends React.Props<any> {
examples: any[];
loadExamples: () => void;
Expand Down