This repository was archived by the owner on Dec 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Getting started page from command palette #258
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3d52299
Initialize a webview service
xnkevinnguyen f49c8e9
Add command for getting started
xnkevinnguyen c9bf221
Initialize html page for getting started
xnkevinnguyen 59a39db
Merge branch 'dev' into users/t-xunguy/getting-started
xnkevinnguyen e4cfd3c
Add placeholder content
xnkevinnguyen 86fc862
Complete tutorials for microbit
xnkevinnguyen 9f93e5e
Complete tutorial for cpx
xnkevinnguyen 412d3f2
Merge branch 'dev' into users/t-xunguy/getting-started
xnkevinnguyen 12746e5
Update webview service
xnkevinnguyen ccddc67
Merge branch 'users/t-xunguy/getting-started' of https://github.com/m…
xnkevinnguyen 688d698
Working webview service for getting started type
xnkevinnguyen 11d8119
Load entire getting started from react
xnkevinnguyen 2d9459f
Remove inconsistency cpx microbit getting started
xnkevinnguyen 74f0d54
Add tests for getting started
xnkevinnguyen 0195172
Merge branch 'dev' into users/t-xunguy/getting-started
xnkevinnguyen db00df7
Update with dev
xnkevinnguyen 56c4afd
Align left the getting started
xnkevinnguyen 3d9f2b2
Format files
xnkevinnguyen f028216
Update ui tests
xnkevinnguyen ac940ff
Remove deleted ressources import
xnkevinnguyen 3a20712
Update with dev
xnkevinnguyen 602ec9b
update tests
xnkevinnguyen 4ad66da
Feedback for additional copy instruction
xnkevinnguyen 61f0a11
Merge branch 'dev' into users/t-xunguy/getting-started
xnkevinnguyen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,21 @@ | ||
| { | ||
| "deviceSimulatorExpressExtension.commands.common.installDependencies": "Install Extension Dependencies", | ||
| "deviceSimulatorExpressExtension.commands.common.label": "Device Simulator Express", | ||
| "deviceSimulatorExpressExtension.commands.common.runSimulator": "Run Simulator", | ||
| "deviceSimulatorExpressExtension.commands.common.changeBaudRate": "Change Baud Rate", | ||
| "deviceSimulatorExpressExtension.commands.common.closeSerialMonitor": "Close Serial Monitor", | ||
| "deviceSimulatorExpressExtension.commands.common.openSerialMonitor": "Open Serial Monitor", | ||
| "deviceSimulatorExpressExtension.commands.common.selectSerialPort": "Select Serial Port", | ||
| "deviceSimulatorExpressExtension.commands.cpx.openSimulator": "[Circuit Playground Express] Open Simulator", | ||
| "deviceSimulatorExpressExtension.commands.cpx.newFile": "[Circuit Playground Express] New File", | ||
| "deviceSimulatorExpressExtension.commands.cpx.deployToDevice": "[Circuit Playground Express] Deploy to Device", | ||
| "deviceSimulatorExpressExtension.commands.microbit.deployToDevice": "[micro:bit] Deploy to Device", | ||
| "deviceSimulatorExpressExtension.commands.microbit.openSimulator": "[micro:bit] Open Simulator", | ||
| "deviceSimulatorExpressExtension.commands.microbit.newFile": "[micro:bit] New File", | ||
| "deviceSimulatorExpressExtension.configuration.title": "Device Simulator Express configuration", | ||
| "deviceSimulatorExpressExtension.configuration.properties.configEnvOnChange": "When you change the Python interpreter, the Device Simulator Express will automatically configure itself for the required dependencies.", | ||
| "deviceSimulatorExpressExtension.configuration.properties.debuggerPort": "The port the Server will listen on for communication with the debugger.", | ||
| "deviceSimulatorExpressExtension.configuration.properties.dependencyChecker": "Whether or not to ask if we can download dependencies. If unchecked, the extension will default to never download dependencies, except when automatically creating a virtual environment in the extension files." | ||
| "deviceSimulatorExpressExtension.commands.common.installDependencies": "Install Extension Dependencies", | ||
| "deviceSimulatorExpressExtension.commands.common.label": "Device Simulator Express", | ||
| "deviceSimulatorExpressExtension.commands.common.runSimulator": "Run Simulator", | ||
| "deviceSimulatorExpressExtension.commands.common.gettingStarted": "Getting Started", | ||
|
|
||
| "deviceSimulatorExpressExtension.commands.common.changeBaudRate": "Change Baud Rate", | ||
| "deviceSimulatorExpressExtension.commands.common.closeSerialMonitor": "Close Serial Monitor", | ||
| "deviceSimulatorExpressExtension.commands.common.openSerialMonitor": "Open Serial Monitor", | ||
| "deviceSimulatorExpressExtension.commands.common.selectSerialPort": "Select Serial Port", | ||
| "deviceSimulatorExpressExtension.commands.cpx.openSimulator": "[Circuit Playground Express] Open Simulator", | ||
| "deviceSimulatorExpressExtension.commands.cpx.newFile": "[Circuit Playground Express] New File", | ||
| "deviceSimulatorExpressExtension.commands.cpx.deployToDevice": "[Circuit Playground Express] Deploy to Device", | ||
| "deviceSimulatorExpressExtension.commands.microbit.deployToDevice": "[micro:bit] Deploy to Device", | ||
| "deviceSimulatorExpressExtension.commands.microbit.openSimulator": "[micro:bit] Open Simulator", | ||
| "deviceSimulatorExpressExtension.commands.microbit.newFile": "[micro:bit] New File", | ||
| "deviceSimulatorExpressExtension.configuration.title": "Device Simulator Express configuration", | ||
| "deviceSimulatorExpressExtension.configuration.properties.configEnvOnChange": "When you change the Python interpreter, the Device Simulator Express will automatically configure itself for the required dependencies.", | ||
| "deviceSimulatorExpressExtension.configuration.properties.debuggerPort": "The port the Server will listen on for communication with the debugger.", | ||
| "deviceSimulatorExpressExtension.configuration.properties.dependencyChecker": "Whether or not to ask if we can download dependencies. If unchecked, the extension will default to never download dependencies, except when automatically creating a virtual environment in the extension files." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,21 @@ | ||
| { | ||
| "deviceSimulatorExpressExtension.commands.common.installDependencies": "Install Extension Dependencies", | ||
| "deviceSimulatorExpressExtension.commands.common.label": "Device Simulator Express", | ||
| "deviceSimulatorExpressExtension.commands.common.runSimulator": "Run Simulator", | ||
| "deviceSimulatorExpressExtension.commands.common.changeBaudRate": "Change Baud Rate", | ||
| "deviceSimulatorExpressExtension.commands.common.closeSerialMonitor": "Close Serial Monitor", | ||
| "deviceSimulatorExpressExtension.commands.common.openSerialMonitor": "Open Serial Monitor", | ||
| "deviceSimulatorExpressExtension.commands.common.selectSerialPort": "Select Serial Port", | ||
| "deviceSimulatorExpressExtension.commands.cpx.openSimulator": "[Circuit Playground Express] Open Simulator", | ||
| "deviceSimulatorExpressExtension.commands.cpx.newFile": "[Circuit Playground Express] New File", | ||
| "deviceSimulatorExpressExtension.commands.cpx.deployToDevice": "[Circuit Playground Express] Deploy to Device", | ||
| "deviceSimulatorExpressExtension.commands.microbit.deployToDevice": "[micro:bit] Deploy to Device", | ||
| "deviceSimulatorExpressExtension.commands.microbit.openSimulator": "[micro:bit] Open Simulator", | ||
| "deviceSimulatorExpressExtension.commands.microbit.newFile": "[micro:bit] New File", | ||
| "deviceSimulatorExpressExtension.configuration.title": "Device Simulator Express configuration", | ||
| "deviceSimulatorExpressExtension.configuration.properties.configEnvOnChange": "When you change the Python interpreter, the Device Simulator Express will automatically configure itself for the required dependencies.", | ||
| "deviceSimulatorExpressExtension.configuration.properties.debuggerPort": "The port the Server will listen on for communication with the debugger.", | ||
| "deviceSimulatorExpressExtension.configuration.properties.dependencyChecker": "Whether or not to ask for dependency downloads. If unchecked, the extension will default to never download dependencies, except when automatically creating a virtual environment in the extension files." | ||
| "deviceSimulatorExpressExtension.commands.common.installDependencies": "Install Extension Dependencies", | ||
| "deviceSimulatorExpressExtension.commands.common.label": "Device Simulator Express", | ||
| "deviceSimulatorExpressExtension.commands.common.runSimulator": "Run Simulator", | ||
| "deviceSimulatorExpressExtension.commands.common.gettingStarted": "Getting Started", | ||
|
|
||
| "deviceSimulatorExpressExtension.commands.common.changeBaudRate": "Change Baud Rate", | ||
| "deviceSimulatorExpressExtension.commands.common.closeSerialMonitor": "Close Serial Monitor", | ||
| "deviceSimulatorExpressExtension.commands.common.openSerialMonitor": "Open Serial Monitor", | ||
| "deviceSimulatorExpressExtension.commands.common.selectSerialPort": "Select Serial Port", | ||
| "deviceSimulatorExpressExtension.commands.cpx.openSimulator": "[Circuit Playground Express] Open Simulator", | ||
| "deviceSimulatorExpressExtension.commands.cpx.newFile": "[Circuit Playground Express] New File", | ||
| "deviceSimulatorExpressExtension.commands.cpx.deployToDevice": "[Circuit Playground Express] Deploy to Device", | ||
| "deviceSimulatorExpressExtension.commands.microbit.deployToDevice": "[micro:bit] Deploy to Device", | ||
| "deviceSimulatorExpressExtension.commands.microbit.openSimulator": "[micro:bit] Open Simulator", | ||
| "deviceSimulatorExpressExtension.commands.microbit.newFile": "[micro:bit] New File", | ||
| "deviceSimulatorExpressExtension.configuration.title": "Device Simulator Express configuration", | ||
| "deviceSimulatorExpressExtension.configuration.properties.configEnvOnChange": "When you change the Python interpreter, the Device Simulator Express will automatically configure itself for the required dependencies.", | ||
| "deviceSimulatorExpressExtension.configuration.properties.debuggerPort": "The port the Server will listen on for communication with the debugger.", | ||
| "deviceSimulatorExpressExtension.configuration.properties.dependencyChecker": "Whether or not to ask for dependency downloads. If unchecked, the extension will default to never download dependencies, except when automatically creating a virtual environment in the extension files." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import * as path from "path"; | ||
| import * as vscode from "vscode"; | ||
| import CONSTANTS from "../constants"; | ||
| import { WEBVIEW_ATTRIBUTES_KEY, WEBVIEW_TYPES } from "../view/constants"; | ||
| import { DeviceSelectionService } from "./deviceSelectionService"; | ||
|
|
||
| // Manages different type of webview | ||
| export class WebviewService { | ||
| private tutorialPanel: vscode.WebviewPanel | undefined; | ||
| private context: vscode.ExtensionContext; | ||
| private deviceSelectionService: DeviceSelectionService; | ||
|
|
||
| constructor( | ||
| context: vscode.ExtensionContext, | ||
| deviceSelectionService: DeviceSelectionService | ||
| ) { | ||
| this.context = context; | ||
| this.deviceSelectionService = deviceSelectionService; | ||
| } | ||
|
|
||
| public openTutorialPanel() { | ||
| if (this.tutorialPanel) { | ||
| this.tutorialPanel.reveal(vscode.ViewColumn.Beside); | ||
| } else { | ||
| this.createTutorialPanel(); | ||
| } | ||
| } | ||
|
|
||
| public getWebviewContent(webviewType: string, hasDevice: boolean) { | ||
xnkevinnguyen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return `<!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
|
|
||
| <title>${CONSTANTS.NAME}</title> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script > | ||
| const vscode = acquireVsCodeApi(); | ||
| </script> | ||
| <script ></script> | ||
| ${this.loadScript( | ||
| this.context, | ||
| webviewType, | ||
| "out/vendor.js", | ||
| hasDevice | ||
| )} | ||
| ${this.loadScript( | ||
| this.context, | ||
| webviewType, | ||
| "out/simulator.js", | ||
| hasDevice | ||
| )} | ||
| </body> | ||
| </html>`; | ||
| } | ||
|
|
||
| private createTutorialPanel() { | ||
| this.tutorialPanel = vscode.window.createWebviewPanel( | ||
| CONSTANTS.WEBVIEW_TYPE.TUTORIAL, | ||
| CONSTANTS.LABEL.WEBVIEW_PANEL, | ||
| { preserveFocus: true, viewColumn: vscode.ViewColumn.One }, | ||
| { | ||
| enableScripts: true, | ||
| } | ||
| ); | ||
| this.tutorialPanel.webview.html = this.getWebviewContent( | ||
| WEBVIEW_TYPES.GETTING_STARTED, | ||
| false | ||
| ); | ||
| this.tutorialPanel.onDidDispose(() => { | ||
| this.disposeTutorialPanel(); | ||
| }); | ||
| } | ||
|
|
||
| private disposeTutorialPanel() { | ||
| this.tutorialPanel = undefined; | ||
| } | ||
|
|
||
| private loadScript( | ||
| context: vscode.ExtensionContext, | ||
| attributeValue: string, | ||
| scriptPath: string, | ||
| hasDevice: boolean | ||
| ) { | ||
| let attributeString: string; | ||
| if (hasDevice) { | ||
| attributeString = `${ | ||
| WEBVIEW_ATTRIBUTES_KEY.TYPE | ||
| }=${attributeValue} ${ | ||
| WEBVIEW_ATTRIBUTES_KEY.INITIAL_DEVICE | ||
| }=${this.deviceSelectionService.getCurrentActiveDevice()}`; | ||
| } else { | ||
| attributeString = `${WEBVIEW_ATTRIBUTES_KEY.TYPE}=${attributeValue} `; | ||
| } | ||
| return `<script ${attributeString} src="${vscode.Uri.file( | ||
| context.asAbsolutePath(scriptPath) | ||
| ) | ||
| .with({ scheme: "vscode-resource" }) | ||
| .toString()}"></script>`; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.