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

Commit8bafa1f

Browse files
committed
setup for state machine initial
1 parente062d66 commit8bafa1f

File tree

14 files changed

+282
-322
lines changed

14 files changed

+282
-322
lines changed

‎web-app/src/App.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import client from './services/apollo'
66
importcurrentTutorialfrom'./services/current'
77
importDebuggerfrom'./components/Debugger'
88
importRoutesfrom'./Routes'
9-
import{send}from'./utils/vscode'
109

1110
interfaceReceivedEvent{
1211
data:CR.Action
@@ -55,9 +54,9 @@ const App = () => {
5554
},[])
5655

5756
// trigger progress when webview loaded
58-
React.useEffect(()=>{
59-
send('WEBVIEW_LOADED')
60-
},[])
57+
//React.useEffect(() => {
58+
// editorDispatch('WEBVIEW_LOADED')
59+
//}, [])
6160

6261
// TODO: refactor cond to user <Router><Route> and accept first route as if/else if
6362
return(

‎web-app/src/Routes.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import*asReactfrom'react'
2-
import{send}from'./utils/vscode'
2+
import{editorDispatch}from'./utils/vscode'
33

44
importRouterfrom'./components/Router'
55
importLoadingPagefrom'./containers/LoadingPage'
@@ -65,13 +65,13 @@ const Routes = ({ state }: Props) => {
6565
<LoadingPagetext="Loading..."/>
6666
</Route>
6767
<Routepath="Tutorial.Summary">
68-
<SummaryPagesend={send}/>
68+
<SummaryPagesend={editorDispatch}/>
6969
</Route>
7070
<Routepath="Tutorial.Level">
71-
<LevelSummaryPagesend={send}/>
71+
<LevelSummaryPagesend={editorDispatch}/>
7272
</Route>
7373
<Routepath="Tutorial.Stage">
74-
<StageSummaryPagesend={send}/>
74+
<StageSummaryPagesend={editorDispatch}/>
7575
</Route>
7676
<Routepath="Tutorial.Completed">
7777
<CompletedPage/>

‎web-app/src/containers/Continue/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Button, Card } from '@alifd/next'
44
import*asTfrom'typings/graphql'
55

66
importcurrentTutorialfrom'../../services/current'
7-
import{send}from'../../utils/vscode'
7+
//import {editorDispatch } from '../../utils/vscode'
88
importLoadingPagefrom'../LoadingPage'
99
importqueryTutorialfrom'./queryTutorial'
1010
importErrorViewfrom'../../components/Error'
@@ -51,7 +51,7 @@ const ContinuePageContainer = () => {
5151
<ContinuePage
5252
tutorial={data.tutorial}
5353
onContinue={()=>{
54-
send('TUTORIAL_START')
54+
console.log('TUTORIAL_START')
5555
}}
5656
/>
5757
)

‎web-app/src/containers/New/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as T from 'typings/graphql'
44
import*asCRfrom'typings'
55

66
importqueryTutorialsfrom'./queryTutorials'
7-
import{send}from'../../utils/vscode'
7+
import{editorDispatch}from'../../utils/vscode'
88
importLoadingPagefrom'../LoadingPage'
99
importErrorViewfrom'../../components/Error'
1010
importTutorialListfrom'./TutorialList'
@@ -35,7 +35,7 @@ const NewPageContainer = () => {
3535

3636
return(
3737
<React.Suspensefallback={Loading}>
38-
<NewPageonNew={send}tutorialList={data.tutorials}/>
38+
<NewPageonNew={editorDispatch}tutorialList={data.tutorials}/>
3939
</React.Suspense>
4040
)
4141
}

‎web-app/src/services/apollo/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
importApolloClient,{InMemoryCache}from'apollo-boost'
22

3+
exportconstcache=newInMemoryCache()
4+
35
constclient=newApolloClient({
46
uri:process.env.REACT_APP_GQL_URI,
57
headers:{
68
Authorization:process.env.REACT_APP_GQL_AUTH_TOKEN,
79
},
8-
cache:newInMemoryCache(),
10+
cache,
911
})
1012

1113
exportdefaultclient
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import{gql}from'apollo-boost'
2+
3+
constgetTutorialConfig=gql`
4+
query getTutorialConfig($tutorialId: ID!) {
5+
tutorial(id: $tutorialId) {
6+
id
7+
testRunner
8+
codingLanguage
9+
}
10+
}
11+
`
12+
13+
exportdefaultgetTutorialConfig
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import{gql}from'apollo-boost'
2+
3+
constgetTutorialRepo=gql`
4+
query getTutorialRepo($tutorialId: ID!) {
5+
tutorial(id: $tutorialId) {
6+
id
7+
repo {
8+
uri
9+
name
10+
branch
11+
}
12+
}
13+
}
14+
`
15+
16+
exportdefaultgetTutorialRepo

‎web-app/src/state/State.png

-501 KB
Binary file not shown.

‎web-app/src/state/actions/index.ts

Lines changed: 60 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,60 @@
1-
import{machine}from'../../extension'
2-
import{TutorialModel}from'../../services/tutorial'
3-
import*asCRfrom'typings'
4-
import*asGfrom'typings/graphql'
5-
6-
7-
exportdefault(tutorialModel:TutorialModel,editorDispatch:CR.EditorDispatch)=>({
8-
createWebview(){
9-
editorDispatch('coderoad.open_webview')
10-
},
11-
asyncnewOrContinue(){
12-
// verify that the user has an existing tutorial to continue
13-
consthasExistingTutorial:boolean=awaittutorialModel.hasExisting()
14-
machine.send(hasExistingTutorial ?'CONTINUE' :'NEW')
15-
},
16-
testRunnerSetup(){
17-
constcodingLanguage:G.EnumCodingLanguage=tutorialModel.config.codingLanguage
18-
editorDispatch('coderoad.test_runner_setup',codingLanguage)
19-
},
20-
initializeNewTutorial:()=>{
21-
console.log('initializeNewTutorial')
22-
},
23-
tutorialContinue(){
24-
console.log('tutorial continue')
25-
},
26-
// tutorialContinue: assign({
27-
// // load initial data, progress & position
28-
// data(): CR.TutorialData {
29-
// console.log('ACTION: tutorialLoad.data')
30-
// if (!currentTutorial) {
31-
// throw new Error('No Tutorial loaded')
32-
// }
33-
// return currentTutorial.data
34-
// },
35-
// progress(): CR.Progress {
36-
// console.log('ACTION: tutorialLoad.progress')
37-
// return currentProgress
38-
// },
39-
// position(context: any): CR.Position {
40-
// console.log('ACTION: tutorialLoad.position')
41-
// if (!currentTutorial) {
42-
// throw new Error('No Tutorial loaded')
43-
// }
44-
// const {data} = currentTutorial
45-
// const position = calculatePosition({data, progress: currentProgress})
46-
47-
// console.log('position', position)
48-
// return position
49-
// },
50-
// }),
51-
testStart(){
52-
editorDispatch('coderoad.run_test')
53-
},
54-
testPass():void{
55-
editorDispatch('coderoad.test_pass')
56-
// git.gitSaveCommit(tutorialModel.position)
57-
},
58-
testFail(){
59-
editorDispatch('coderoad.test_fail')
60-
},
61-
//@ts-ignore
62-
progressUpdate(){
63-
tutorialModel.updateProgress()
64-
tutorialModel.nextPosition()
65-
},
66-
67-
// assign({
68-
// progress: (): CR.Progress => {
69-
70-
// console.log('progress update')
71-
// const {progress, position, data} = context
72-
// const nextProgress = progress
73-
74-
// nextProgress.steps[position.stepId] = true
75-
// const {stepList} = data.stages[position.stageId]
76-
// const stageComplete = stepList[stepList.length - 1] === position.stepId
77-
// if (stageComplete) {
78-
// nextProgress.stages[position.stageId] = true
79-
// const {stageList} = data.levels[position.levelId]
80-
// const levelComplete = stageList[stageList.length - 1] === position.stageId
81-
// if (levelComplete) {
82-
// nextProgress.levels[position.levelId] = true
83-
// const {levelList} = data.summary
84-
// const tutorialComplete = levelList[levelList.length - 1] === position.levelId
85-
// if (tutorialComplete) {
86-
// nextProgress.complete = true
87-
// }
88-
// }
89-
// }
90-
// console.log('progress update', nextProgress)
91-
// storage.setProgress(nextProgress)
92-
// return nextProgress
93-
// },
94-
// }),
95-
// stepLoadNext: assign({
96-
// position: (context: any): CR.Position => {
97-
// const {data, position} = context
98-
// const {stepList} = data.stages[position.stageId]
99-
// const currentStepIndex = stepList.indexOf(position.stepId)
100-
101-
// const nextStepId = currentStepIndex < stepList.length ? stepList[currentStepIndex + 1] : position.stepId
102-
103-
// const nextPosition = {
104-
// ...context.position,
105-
// stepId: nextStepId,
106-
// }
107-
108-
// return nextPosition
109-
// },
110-
// }),
111-
loadLevel():void{
112-
tutorialModel.triggerCurrent('LEVEL')
113-
},
114-
stageLoadNext(){
115-
console.log('stageLoadNext')
116-
tutorialModel.nextPosition()
117-
},
118-
loadStage():void{
119-
tutorialModel.triggerCurrent('STAGE')
120-
},
121-
//@ts-ignore
122-
// updatePosition: assign({
123-
// position: () => calculatePosition({
124-
// data: context.data,
125-
// progress: context.progress,
126-
// }),
127-
// }),
128-
stepLoadCommits():void{
129-
tutorialModel.triggerCurrent('STEP')
130-
},
131-
})
1+
// import {machine} from '../../extension'
2+
// import {cache} from '../../services/apollo'
3+
// import {editorDispatch} from '../../utils/vscode'
4+
// import * as CR from 'typings'
5+
// import * as G from 'typings/graphql'
6+
// import tutorialConfig from '../../services/apollo/queries/tutorialConfig'
7+
8+
9+
exportdefault{}
10+
11+
// export default {
12+
// createWebview() {
13+
// editorDispatch('coderoad.open_webview')
14+
// },
15+
// async newOrContinue() {
16+
// // verify that the user has an existing tutorial to continue
17+
// // const hasExistingTutorial: boolean = await tutorialModel.hasExisting()
18+
// // machine.send(hasExistingTutorial ? 'CONTINUE' : 'NEW')
19+
// },
20+
// testRunnerSetup() {
21+
// const result = cache.readQuery({query: tutorialConfig})
22+
// console.log('result', result)
23+
// // const codingLanguage: G.EnumCodingLanguage = result.data.codingLanguage
24+
// // editorDispatch('coderoad.test_runner_setup', codingLanguage)
25+
// },
26+
// initializeNewTutorial: () => {
27+
// console.log('initializeNewTutorial')
28+
// },
29+
// tutorialContinue() {
30+
// console.log('tutorial continue')
31+
// },
32+
// testStart() {
33+
// editorDispatch('coderoad.run_test')
34+
// },
35+
// testPass(): void {
36+
// editorDispatch('coderoad.test_pass')
37+
// // git.gitSaveCommit(tutorialModel.position)
38+
// },
39+
// testFail() {
40+
// editorDispatch('coderoad.test_fail')
41+
// },
42+
// //@ts-ignore
43+
// progressUpdate() {
44+
// // tutorialModel.updateProgress()
45+
// // tutorialModel.nextPosition()
46+
// },
47+
// loadLevel(): void {
48+
// // tutorialModel.triggerCurrent('LEVEL')
49+
// },
50+
// stageLoadNext() {
51+
// console.log('stageLoadNext')
52+
// // tutorialModel.nextPosition()
53+
// },
54+
// loadStage(): void {
55+
// // tutorialModel.triggerCurrent('STAGE')
56+
// },
57+
// stepLoadCommits(): void {
58+
// // tutorialModel.triggerCurrent('STEP')
59+
// },
60+
// }

‎web-app/src/state/guards/index.ts

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
1-
import*asCRfrom'typings'
2-
import{TutorialModel}from'../../services/tutorial'
1+
//import * as CR from 'typings'
2+
//import {TutorialModel} from '../../services/tutorial'
33

44

5-
// TODO: refactor into a single calculation
6-
exportdefault(tutorialModel:TutorialModel)=>({
7-
hasNextStep:():boolean=>{
5+
exportdefault{}
86

9-
constnextPosition:CR.Position=tutorialModel.nextPosition()
7+
// // TODO: refactor into a single calculation
8+
// export default (tutorialModel: TutorialModel) => ({
9+
// hasNextStep: (): boolean => {
1010

11-
constsameStage=nextPosition.stageId===tutorialModel.position.stageId
12-
constsameStep=nextPosition.stepId===tutorialModel.position.stepId
11+
// const nextPosition: CR.Position = tutorialModel.nextPosition()
1312

14-
consthasNext:boolean=sameStage&&sameStep
13+
// const sameStage = nextPosition.stageId === tutorialModel.position.stageId
14+
// const sameStep = nextPosition.stepId === tutorialModel.position.stepId
1515

16-
console.log('GUARD: hasNextStep',hasNext)
17-
returnhasNext
18-
},
19-
hasNextStage:():boolean=>{
20-
constnextPosition:CR.Position=tutorialModel.nextPosition()
16+
// const hasNext: boolean = sameStage && sameStep
2117

22-
constsameLevel=nextPosition.levelId===tutorialModel.position.levelId
23-
constsameStage=nextPosition.stageId===tutorialModel.position.stageId
18+
// console.log('GUARD: hasNextStep', hasNext)
19+
// return hasNext
20+
// },
21+
// hasNextStage: (): boolean => {
22+
// const nextPosition: CR.Position = tutorialModel.nextPosition()
2423

25-
consthasNext:boolean=sameLevel&&sameStage
24+
// const sameLevel = nextPosition.levelId === tutorialModel.position.levelId
25+
// const sameStage = nextPosition.stageId === tutorialModel.position.stageId
2626

27-
console.log('GUARD: hasNextStage',hasNext)
28-
returnhasNext
29-
},
30-
hasNextLevel:():boolean=>{
31-
constnextPosition:CR.Position=tutorialModel.nextPosition()
27+
// const hasNext: boolean = sameLevel && sameStage
3228

33-
constsameLevel=nextPosition.levelId===tutorialModel.position.levelId
29+
// console.log('GUARD: hasNextStage', hasNext)
30+
// return hasNext
31+
// },
32+
// hasNextLevel: (): boolean => {
33+
// const nextPosition: CR.Position = tutorialModel.nextPosition()
3434

35-
consthasNext:boolean=sameLevel
35+
//constsameLevel = nextPosition.levelId === tutorialModel.position.levelId
3636

37-
// TODO: ensure this accounts for end
38-
console.log('GUARD: hasNextLevel',hasNext)
39-
returnhasNext
40-
},
41-
})
37+
// const hasNext: boolean = sameLevel
38+
39+
// // TODO: ensure this accounts for end
40+
// console.log('GUARD: hasNextLevel', hasNext)
41+
// return hasNext
42+
// },
43+
// })

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp