Skip to content

Fix/continue #34

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 our terms of service and privacy statement. We��ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
setup editor config on continue
  • Loading branch information
ShMcK committed Sep 23, 2019
commit 98498c54ab24085187ca8f3937f79440428f3f4c
16 changes: 12 additions & 4 deletions src/actions/tutorialConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ import * as G from 'typings/graphql'
import * as vscode from 'vscode'
import * as git from '../services/git'

const tutorialConfig = async (tutorial: G.Tutorial) => {
interface TutorialConfigParams {
tutorial: G.Tutorial,
alreadyConfigured?: boolean
}

const tutorialConfig = async ({tutorial, alreadyConfigured}: TutorialConfigParams) => {
if (!alreadyConfigured) {
// setup git, add remote
await git.initIfNotExists()

// setup git, add remote
await git.initIfNotExists()
await git.setupRemote(tutorial.repo.uri)
// TODO: if remote not already set
await git.setupRemote(tutorial.repo.uri)
}

// TODO: allow multiple coding languages in a tutorial
const language = tutorial.codingLanguage.toLowerCase()
Expand Down
14 changes: 13 additions & 1 deletion src/channel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,19 @@ class Channel implements Channel {
case 'EDITOR_TUTORIAL_CONFIG':
const tutorialData = action.payload.tutorial
this.context.setTutorial(this.workspaceState, tutorialData)
tutorialConfig(tutorialData)
tutorialConfig({
tutorial: tutorialData
})
return
case 'EDITOR_TUTORIAL_CONTINUE_CONFIG':
const tutorialContinue: G.Tutorial | null = this.context.tutorial.get()
if (!tutorialContinue) {
throw new Error('Invalid tutorial to continue')
}
tutorialConfig({
tutorial: tutorialContinue,
alreadyConfigured: true
})
return
case 'EDITOR_SYNC_PROGRESS':
// sync client progress on server
Expand Down
7 changes: 7 additions & 0 deletions web-app/src/services/state/actions/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default {
type: 'EDITOR_TUTORIAL_LOAD',
})
},
// TODO: syncProgress unused
syncProgress(context: CR.MachineContext) {
// sync progress in editor local storage for persistence
channel.editorSend({
Expand All @@ -23,6 +24,7 @@ export default {
initializeTutorial(context: CR.MachineContext, event: CR.MachineEvent) {
// setup test runner and git
const {tutorial} = event.data.payload

if (!tutorial) {
throw new Error('Invalid tutorial for tutorial config')
}
Expand All @@ -32,6 +34,11 @@ export default {
payload: {tutorial},
})
},
continueConfig() {
channel.editorSend({
type: 'EDITOR_TUTORIAL_CONTINUE_CONFIG',
})
},
testStart(context: CR.MachineContext, event: CR.MachineEvent) {
console.log('EDITOR: TEST_RUN')
const {stepId} = event.payload
Expand Down
6 changes: 5 additions & 1 deletion web-app/src/services/state/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
},
ContinueTutorial: {
on: {
TUTORIAL_START: '#tutorial-stage',
TUTORIAL_START: {
target: '#tutorial-stage',
actions: ['continueConfig'],
},
TUTORIAL_SELECT: 'SelectTutorial'
},
},
Expand All @@ -60,6 +63,7 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
id: 'tutorial',
initial: 'Initialize',
states: {
// TODO: move Initialize into New Tutorial setup
Initialize: {
invoke: {
id: 'loadTutorial',
Expand Down