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

Commit5cad8e1

Browse files
committed
working load tutorials from GH
1 parent6ca0fbb commit5cad8e1

File tree

9 files changed

+24
-171
lines changed

9 files changed

+24
-171
lines changed

‎typings/index.d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,12 @@ export interface MachineStateSchema {
6969
Setup:{
7070
states:{
7171
Startup:{}
72-
// Authenticate: {}
7372
Error:{}
7473
LoadStoredTutorial:{}
7574
Start:{}
7675
CheckEmptyWorkspace:{}
7776
NonEmptyWorkspace:{}
7877
SelectTutorial:{}
79-
LoadTutorialSummary:{}
80-
Summary:{}
81-
LoadTutorialData:{}
8278
SetupNewTutorial:{}
8379
}
8480
}

‎web-app/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@
2727
"dependencies": {
2828
"@alifd/next":"^1.19.19",
2929
"@alifd/theme-4":"^0.2.3",
30-
"@apollo/react-hooks":"^3.1.3",
3130
"@emotion/core":"^10.0.28",
3231
"@sentry/browser":"^5.15.4",
33-
"apollo-boost":"^0.4.7",
3432
"graphql":"^14.6.0",
3533
"markdown-it":"^10.0.0",
3634
"markdown-it-emoji":"^1.4.0",

‎web-app/src/components/TutorialOverview/index.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,10 @@ const styles = {
7070

7171
interfaceProps{
7272
tutorial:TT.Tutorial
73-
send:any
73+
onNext:()=>void
7474
}
7575

7676
constSummary=(props:Props)=>{
77-
constonNext=()=>
78-
props.send({
79-
type:'TUTORIAL_START',
80-
// TODO: change tutorial on parent
81-
// payload: {
82-
// tutorial: data.tutorial,
83-
// },
84-
})
85-
86-
// const onBack = () => props.send({ type: 'BACK' })
8777
return(
8878
<divcss={styles.page}>
8979
<divcss={styles.content}>
@@ -123,7 +113,7 @@ const Summary = (props: Props) => {
123113

124114
<divcss={styles.footer}>
125115
{/* TODO Add back button */}
126-
<Buttontype="primary"onClick={onNext}>
116+
<Buttontype="primary"onClick={props.onNext}>
127117
Start
128118
</Button>
129119
</div>

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ interface GitHubFetchProps {
2929
send:any
3030
}
3131

32-
constGitHubFetch=({ url, send}:GitHubFetchProps)=>{
33-
const{ data, error, loading}=useFetch<TT.Tutorial>(url)
32+
constGitHubFetch=(props:GitHubFetchProps)=>{
33+
const{ data, error, loading}=useFetch<TT.Tutorial>(props.url)
3434
if(loading){
3535
return<div>Loading...</div>
3636
}
@@ -40,7 +40,16 @@ const GitHubFetch = ({ url, send }: GitHubFetchProps) => {
4040
if(!data){
4141
return<div>No data returned</div>
4242
}
43-
return<TutorialOverviewsend={send}tutorial={data}/>
43+
constonNext=()=>{
44+
console.log('called tutorial start')
45+
props.send({
46+
type:'TUTORIAL_START',
47+
payload:{
48+
tutorial:data,
49+
},
50+
})
51+
}
52+
return<TutorialOverviewonNext={onNext}tutorial={data}/>
4453
}
4554

4655
consttutorials=[
@@ -61,7 +70,7 @@ interface Props {
6170
context:any
6271
}
6372

64-
constSelectTutorialPage=({ send}:Props)=>{
73+
constSelectTutorialPage=(props:Props)=>{
6574
const[url,setUrl]=React.useState<string|null>(null)
6675
consthandleUrlChange=(value:string)=>{
6776
setUrl(value)
@@ -81,7 +90,7 @@ const SelectTutorialPage = ({ send }: Props) => {
8190
</FormItem>
8291
</Form>
8392
</div>
84-
{url&&<GitHubFetchurl={url}send={send}/>}
93+
{url&&<GitHubFetchurl={url}send={props.send}/>}
8594
</div>
8695
)
8796
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ const contextActions: ActionFunctionMap<T.MachineContext, T.MachineEvent> = {
2727
},
2828
}),
2929
//@ts-ignore
30-
selectTutorialById:assign({
31-
tutorial:(context:T.MachineContext,event:T.MachineEvent):any=>{
32-
returnevent.payload.tutorial
33-
},
34-
}),
35-
//@ts-ignore
3630
startNewTutorial:assign({
3731
position:(context:T.MachineContext,event:T.MachineEvent):any=>{
3832
constposition:T.Position=selectors.initialPosition(context)
@@ -232,6 +226,12 @@ const contextActions: ActionFunctionMap<T.MachineContext, T.MachineEvent> = {
232226
type:context.position.stepId===null ?'START_COMPLETED_LEVEL' :'START_LEVEL',
233227
}
234228
}),
229+
//@ts-ignore
230+
setTutorialContext:assign({
231+
tutorial:(context:T.MachineContext,event:T.MachineEvent):any=>{
232+
returnevent.payload.tutorial
233+
},
234+
}),
235235
}
236236

237237
exportdefaultcontextActions

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

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import*asCRfrom'typings'
22
import{assign,Machine,MachineOptions}from'xstate'
33
importcreateActionsfrom'./actions'
4-
import*asservicesfrom'./services'
54

65
constcreateOptions=({ editorSend}:any):MachineOptions<CR.MachineContext,CR.MachineEvent>=>({
76
activities:{},
@@ -43,18 +42,6 @@ export const createMachine = (options: any) => {
4342
},
4443
},
4544
},
46-
// Authenticate: {
47-
// invoke: {
48-
// src: services.authenticate,
49-
// onDone: 'LoadStoredTutorial',
50-
// onError: {
51-
// target: 'Error',
52-
// actions: assign({
53-
// error: (context, event) => event.data,
54-
// }),
55-
// },
56-
// },
57-
// },
5845
Error:{},
5946
LoadStoredTutorial:{
6047
onEntry:['loadStoredTutorial'],
@@ -95,50 +82,9 @@ export const createMachine = (options: any) => {
9582
onEntry:['clearStorage'],
9683
id:'select-new-tutorial',
9784
on:{
98-
SELECT_TUTORIAL:{
99-
target:'LoadTutorialSummary',
100-
actions:['selectTutorialById'],
101-
},
102-
},
103-
},
104-
// TODO move Initialize into New Tutorial setup
105-
LoadTutorialSummary:{
106-
invoke:{
107-
src:services.loadTutorialSummary,
108-
onDone:{
109-
target:'Summary',
110-
actions:assign({
111-
tutorial:(context,event)=>event.data,
112-
}),
113-
},
114-
onError:{
115-
target:'Error',
116-
actions:assign({
117-
error:(context,event)=>event.data,
118-
}),
119-
},
120-
},
121-
},
122-
Summary:{
123-
on:{
124-
BACK:'SelectTutorial',
125-
TUTORIAL_START:'LoadTutorialData',
126-
},
127-
},
128-
LoadTutorialData:{
129-
invoke:{
130-
src:services.loadTutorialData,
131-
onDone:{
85+
TUTORIAL_START:{
13286
target:'SetupNewTutorial',
133-
actions:assign({
134-
tutorial:(context,event)=>event.data,
135-
}),
136-
},
137-
onError:{
138-
target:'Error',
139-
actions:assign({
140-
error:(context,event)=>event.data,
141-
}),
87+
actions:['setTutorialContext'],
14288
},
14389
},
14490
},

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

Lines changed: 0 additions & 2 deletions
This file was deleted.

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

Lines changed: 0 additions & 42 deletions
This file was deleted.

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

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp