- Notifications
You must be signed in to change notification settings - Fork39
Feature/tutorial setup#4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
12 commits Select commitHold shift + click to select a range
481807c
run test action
ShMcKd00a485
progress refactoring webview, editor, machine
ShMcK3261c33
refactor order of launches
ShMcK6d8b993
further editor refactoring
ShMcK0a3e395
cleanup component structure
ShMcKec2e0e0
absolute path typings
ShMcKb50e2c0
support passing of messages to view
ShMcK9c530c9
update state in client
ShMcK864a26e
setup cond rendering route
ShMcK08b28af
run received actions through state machine
ShMcK3cdce4d
setup state/data
ShMcK99372b4
move components into containers
ShMcKFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
116 changes: 58 additions & 58 deletionssrc/editor/views/createWebview.ts → src/editor/ReactWebView.ts
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
104 changes: 76 additions & 28 deletionssrc/editor/commands/index.ts
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,36 +1,84 @@ | ||
import * as vscode from 'vscode' | ||
import { join } from 'path' | ||
import { setStorage } from '../storage' | ||
import ReactWebView from '../ReactWebView' | ||
import * as CR from 'typings' | ||
const COMMANDS = { | ||
START: 'coderoad.start', | ||
NEW_OR_CONTINUE: 'coderoad.new_or_continue', | ||
OPEN_WEBVIEW: 'coderoad.open_webview', | ||
SEND_STATE: 'coderoad.send_state', | ||
SEND_DATA: 'coderoad.send_data', | ||
RECEIVE_ACTION: 'coderoad.receive_action', | ||
OPEN_FILE: 'coderoad.open_file', | ||
RUN_TEST: 'coderoad.test_run', | ||
} | ||
interface CreateCommandProps { | ||
context: vscode.ExtensionContext, | ||
machine: CR.StateMachine, | ||
storage: any, | ||
git: any | ||
} | ||
// React panel webview | ||
let webview: any; | ||
export const createCommands = ({ context, machine, storage, git }: CreateCommandProps) => ({ | ||
// initialize | ||
[COMMANDS.START]: () => { | ||
// set local storage workspace | ||
setStorage(context.workspaceState) | ||
// activate machine | ||
webview = new ReactWebView(context.extensionPath) | ||
console.log('webview', webview.panel.webview.postMessage) | ||
machine.activate() | ||
}, | ||
[COMMANDS.NEW_OR_CONTINUE]: async () => { | ||
// verify that the user has a tutorial & progress | ||
// verify git is setup with a coderoad remote | ||
const [tutorial, progress, hasGit, hasGitRemote] = await Promise.all([ | ||
storage.getTutorial(), | ||
storage.getProgress(), | ||
git.gitVersion(), | ||
git.gitCheckRemoteExists(), | ||
]) | ||
const canContinue = !!(tutorial && progress && hasGit && hasGitRemote) | ||
console.log('canContinue', canContinue) | ||
// if a tutorial exists, 'CONTINUE' | ||
// otherwise start from 'NEW' | ||
machine.send(canContinue ? 'CONTINUE' : 'NEW') | ||
}, | ||
// open React webview | ||
[COMMANDS.OPEN_WEBVIEW]: (column: number = vscode.ViewColumn.One) => { | ||
webview.createOrShow(column); | ||
}, | ||
// open a file | ||
[COMMANDS.OPEN_FILE]: async (relativeFilePath: string) => { | ||
console.log(`OPEN_FILE ${JSON.stringify(relativeFilePath)}`) | ||
try { | ||
const workspaceRoot = vscode.workspace.rootPath | ||
if (!workspaceRoot) { | ||
throw new Error('No workspace root path') | ||
} | ||
const absoluteFilePath = join(workspaceRoot, relativeFilePath) | ||
const doc = await vscode.workspace.openTextDocument(absoluteFilePath) | ||
await vscode.window.showTextDocument(doc, vscode.ViewColumn.One) | ||
} catch (error) { | ||
console.log(`Failed to open file ${relativeFilePath}`, error) | ||
} | ||
}, | ||
// send messages to webview | ||
[COMMANDS.SEND_STATE]: (payload: { data: any, state: any }) => { | ||
webview.postMessage({ type: 'SET_STATE', payload }) | ||
}, | ||
[COMMANDS.SEND_DATA]: (payload: { data: any }) => { | ||
webview.postMessage({ type: 'SET_DATA', payload }) | ||
}, | ||
[COMMANDS.RECEIVE_ACTION]: (action: string | CR.Action) => { | ||
console.log('onReceiveAction', action) | ||
machine.onReceive(action) | ||
} | ||
}) |
5 changes: 0 additions & 5 deletionssrc/editor/commands/quit.ts
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
45 changes: 0 additions & 45 deletionssrc/editor/commands/start.ts
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.