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

Commit69190ec

Browse files
committed
invoke initialize tutorial
1 parentdec9354 commit69190ec

File tree

5 files changed

+61
-57
lines changed

5 files changed

+61
-57
lines changed

‎web-app/src/services/state/actions/editor.ts

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
import*asCRfrom'typings'
22
import*asGfrom'typings/graphql'
3-
importclientfrom'../../apollo'
4-
importtutorialQueryfrom'../../apollo/queries/tutorial'
53
import*asselectorsfrom'../../selectors'
6-
importonErrorfrom'../../../services/sentry/onError'
7-
8-
interfaceTutorialData{
9-
tutorial:G.Tutorial
10-
}
11-
12-
interfaceTutorialDataVariables{
13-
tutorialId:string
14-
// version: string
15-
}
164

175
exportdefault(editorSend:any)=>({
186
loadEnv():void{
@@ -27,40 +15,6 @@ export default (editorSend: any) => ({
2715
type:'EDITOR_TUTORIAL_LOAD',
2816
})
2917
},
30-
initializeTutorial(context:CR.MachineContext,event:CR.MachineEvent){
31-
// setup test runner and git
32-
if(!context.tutorial){
33-
consterror=newError('Tutorial not available to load')
34-
onError(error)
35-
throwerror
36-
}
37-
38-
client
39-
.query<TutorialData,TutorialDataVariables>({
40-
query:tutorialQuery,
41-
variables:{
42-
tutorialId:context.tutorial.id,
43-
// version: context.tutorial.version.version, // TODO: reimplement version
44-
},
45-
})
46-
.then(result=>{
47-
if(!result||!result.data||!result.data.tutorial){
48-
constmessage='No tutorial returned from tutorial config query'
49-
onError(newError(message))
50-
returnPromise.reject(message)
51-
}
52-
53-
editorSend({
54-
type:'EDITOR_TUTORIAL_CONFIG',
55-
payload:{tutorial:result.data.tutorial},
56-
})
57-
})
58-
.catch((error:Error)=>{
59-
constmessage=`Failed to load tutorial config${error.message}`
60-
onError(newError(message))
61-
returnPromise.reject(message)
62-
})
63-
},
6418
continueConfig(context:CR.MachineContext){
6519
editorSend({
6620
type:'EDITOR_TUTORIAL_CONTINUE_CONFIG',

‎web-app/src/services/state/machine.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ export const createMachine = (options: any) => {
5454
onError:{
5555
target:'Error',
5656
actions:assign({
57-
error:(context,event)=>{
58-
console.log('ERROR')
59-
console.log(JSON.stringify(event))
60-
returnevent.data
61-
},
57+
error:(context,event)=>event.data,
6258
}),
6359
},
6460
},
@@ -118,10 +114,20 @@ export const createMachine = (options: any) => {
118114
states:{
119115
// TODO move Initialize into New Tutorial setup
120116
Initialize:{
121-
onEntry:['initializeTutorial'],
122-
on:{
123-
TUTORIAL_CONFIGURED:'Summary',
124-
// TUTORIAL_CONFIG_ERROR: 'Start' // TODO should handle error
117+
invoke:{
118+
src:services.initialize,
119+
onDone:{
120+
target:'Summary',
121+
actions:assign({
122+
tutorial:(context,event)=>event.data,
123+
}),
124+
},
125+
onError:{
126+
target:'Summary',
127+
actions:assign({
128+
error:(context,event)=>event.data,
129+
}),
130+
},
125131
},
126132
},
127133
Summary:{

‎web-app/src/services/state/services/authenticate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function authenticate(context: CR.MachineContext): Promise<any> {
2929
},
3030
})
3131
.catch(error=>{
32-
//onError(error)
32+
onError(error)
3333
console.log('ERROR: Authentication failed')
3434
console.log(error.message)
3535
// let message
@@ -53,7 +53,7 @@ export async function authenticate(context: CR.MachineContext): Promise<any> {
5353
if(!result||!result.data){
5454
consterror=newError('Authentication request responded with no data')
5555
console.log(error)
56-
//onError(error)
56+
onError(error)
5757
return
5858
}
5959
const{ token}=result.data.editorLogin
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export{authenticate}from'./authenticate'
2+
export{initialize}from'./initialize'
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import*asCRfrom'typings'
2+
import*asGfrom'typings/graphql'
3+
importclientfrom'../../apollo'
4+
importtutorialQueryfrom'../../apollo/queries/tutorial'
5+
importonErrorfrom'../../../services/sentry/onError'
6+
7+
interfaceTutorialData{
8+
tutorial:G.Tutorial
9+
}
10+
11+
interfaceTutorialDataVariables{
12+
tutorialId:string
13+
// version: string
14+
}
15+
16+
exportasyncfunctioninitialize(context:CR.MachineContext):Promise<any>{
17+
// setup test runner and git
18+
if(!context.tutorial){
19+
consterror=newError('Tutorial not available to load')
20+
onError(error)
21+
throwerror
22+
}
23+
24+
try{
25+
constresult=awaitclient.query<TutorialData,TutorialDataVariables>({
26+
query:tutorialQuery,
27+
variables:{
28+
tutorialId:context.tutorial.id,
29+
// version: context.tutorial.version.version, // TODO: reimplement version
30+
},
31+
})
32+
if(!result||!result.data||!result.data.tutorial){
33+
constmessage='No tutorial returned from tutorial config query'
34+
onError(newError(message))
35+
returnPromise.reject(message)
36+
}
37+
returnPromise.resolve(result.data.tutorial)
38+
}catch(error){
39+
constmessage:CR.ErrorMessage={title:'Failed to load tutorial config',description:error.message}
40+
onError(error)
41+
returnPromise.reject(message)
42+
}
43+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp