Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 3 commits intomasterfromfix/continue
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes fromall 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
16 changes: 12 additions & 4 deletionssrc/actions/tutorialConfig.ts
View file
Open in desktop
Original file line numberDiff line numberDiff 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, addremote
await git.initIfNotExists()
await git.setupRemote(tutorial.repo.uri)
//TODO: ifremote not already set
await git.setupRemote(tutorial.repo.uri)
}

// TODO: allow multiple coding languages in a tutorial
const language = tutorial.codingLanguage.toLowerCase()
Expand Down
5 changes: 5 additions & 0 deletionssrc/channel/context.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,6 +23,11 @@ class Context {
const position: CR.Position = this.position.setPositionFromProgress(tutorial, progress)
return {progress, position}
}
public reset = () => {
this.tutorial.reset()
this.progress.reset()
this.position.reset()
}
}

export default Context
16 changes: 14 additions & 2 deletionssrc/channel/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -64,13 +64,25 @@ class Channel implements Channel {
// clear tutorial local storage
case 'TUTORIAL_CLEAR':
// clear current progress/position/tutorial
this.context = new Context(this.workspaceState)
this.context.reset()
return
// configure test runner, language, git
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
15 changes: 10 additions & 5 deletionssrc/channel/state/Position.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
import * as CR from 'typings'
import * as G from 'typings/graphql'

const defaultValue: CR.Position = {
levelId: '',
stageId: '',
stepId: '',
}

// position
class Position {
private value: CR.Position
constructor() {
this.value = {
levelId: '',
stageId: '',
stepId: '',
}
this.value = defaultValue
}
public get = () => {
return this.value
}
public set = (value: CR.Position) => {
this.value = value
}
public reset = () => {
this.value = defaultValue
}
// calculate the current position based on the saved progress
public setPositionFromProgress = (tutorial: G.Tutorial, progress: CR.Progress): CR.Position => {

Expand Down
8 changes: 6 additions & 2 deletionssrc/channel/state/Progress.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,11 +32,15 @@ class Progress {
}
public set = (value: CR.Progress) => {
this.value = value
if (this.storage) {
this.storage.set(value)
if (!this.storage) {
throw new Error('Tutorial storage not found')
}
this.storage.set(value)
return this.value
}
public reset = () => {
this.set(defaultValue)
}
public setStepComplete = (stepId: string): CR.Progress => {
const next = this.value
next.steps[stepId] = true
Expand Down
10 changes: 6 additions & 4 deletionssrc/channel/state/Tutorial.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,11 +19,13 @@ class Tutorial {
this.value = value
})
}
public get = () => {
return this.value
}
public set = (value: G.Tutorial) => {
public get = () => this.value
public set = (value: G.Tutorial | null) => {
this.value = value
this.storage.set(value)
}
public reset = () => {
this.set(null)
}
}

Expand Down
3 changes: 1 addition & 2 deletionssrc/editor/ReactWebView.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,7 +31,6 @@ class ReactWebView {
private channel: Channel

public constructor({extensionPath, workspaceState}: ReactWebViewProps) {
console.log(`extPath ${extensionPath}`)
this.extensionPath = extensionPath

// Create and show a new webview panel
Expand DownExpand Up@@ -73,7 +72,7 @@ class ReactWebView {
this.channel = new Channel({
workspaceState,
postMessage: (action: Action): Thenable<boolean> => {
console.log(`postMessage ${JSON.stringify(action)}`)
//console.log(`postMessage ${JSON.stringify(action)}`)
return this.panel.webview.postMessage(action)
}
})
Expand Down
9 changes: 8 additions & 1 deletionweb-app/src/services/state/actions/editor.ts
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand Up@@ -75,7 +82,7 @@ export default {
})
}
},
clearStorage() {
clearStorage(): void {
channel.editorSend({type: 'TUTORIAL_CLEAR'})
}
}
11 changes: 8 additions & 3 deletionsweb-app/src/services/state/machine.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,11 +35,11 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
},
NEW_TUTORIAL: {
target: 'SelectTutorial',
actions: ['clearStorage']
}
},
},
SelectTutorial: {
onEntry: ['clearStorage'],
id: 'start-new-tutorial',
on: {
TUTORIAL_START: {
Expand All@@ -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 DownExpand Up@@ -155,6 +159,7 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
}
},
StageComplete: {
onEntry: ['syncProgress'],
on: {
STAGE_NEXT: '#tutorial-load-next',
},
Expand All@@ -163,7 +168,7 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
},
Completed: {
id: 'completed-tutorial',
onEntry: ['userTutorialComplete'],
onEntry: ['syncProgress', 'userTutorialComplete'],
on: {
SELECT_TUTORIAL: {
target: '#start-new-tutorial',
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp