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

Commit3a172c5

Browse files
committed
setup load solution from client to server
1 parentf9660fd commit3a172c5

File tree

6 files changed

+33
-15
lines changed

6 files changed

+33
-15
lines changed

‎typings/graphql.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export type Stage = {
136136
step?:Maybe<Step>,
137137
steps:Array<Step>,
138138
setup?:Maybe<StepActions>,
139-
status:string
139+
status:'ACTIVE'|'COMPLETE'|'INCOMPLETE'
140140
};
141141

142142

@@ -151,8 +151,8 @@ export type Step = {
151151
text:Scalars['String'],
152152
setup:StepActions,
153153
solution:StepActions,
154-
status:string
155-
};
154+
status:'ACTIVE'|'COMPLETE'|'INCOMPLETE'
155+
}
156156

157157
exporttypeStepActions={
158158
__typename?:'StepActions',

‎web-app/src/containers/Tutorial/StagePage/Stage/StepDescription/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import*asReactfrom'react'
22
importMarkdownfrom'../../../../../components/Markdown'
3+
import{Button}from'@alifd/next'
34

45
conststyles={
56
// active: {
@@ -12,16 +13,18 @@ const styles = {
1213

1314
interfaceProps{
1415
text?:string|null
15-
hide:boolean
16+
mode:'INCOMPLETE'|'ACTIVE'|'COMPLETE'
17+
onLoadSolution():void
1618
}
1719

18-
constStepDescription=({ text,hide}:Props)=>{
19-
if(hide){
20+
constStepDescription=({ text,mode, onLoadSolution}:Props)=>{
21+
if(mode==='INCOMPLETE'){
2022
returnnull
2123
}
2224
return(
2325
<divstyle={styles.card}>
2426
<Markdown>{text||''}</Markdown>
27+
{mode==='ACTIVE'&&<ButtononClick={onLoadSolution}>Load Solution</Button>}
2528
</div>
2629
)
2730
}

‎web-app/src/containers/Tutorial/StagePage/Stage/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ const styles = {
2424

2525
interfaceProps{
2626
stage:T.Stage
27-
onContinue():void
28-
onSave():void
27+
onContinue():void
28+
onSave():void
29+
onLoadSolution():void
2930
}
3031

31-
constStage=({ stage, onContinue, onSave}:Props)=>{
32+
constStage=({ stage, onContinue, onSave, onLoadSolution}:Props)=>{
3233
if(!stage.steps){
3334
thrownewError('No Stage steps found')
3435
}
@@ -50,12 +51,11 @@ const Stage = ({ stage, onContinue, onSave }: Props) => {
5051
if(!step){
5152
returnnull
5253
}
53-
consthide=step.status==='INCOMPLETE'
5454
return(
5555
<Step.Item
5656
key={step.id}
5757
title={step.title||`Step${index+1}`}
58-
content={<StepDescriptiontext={step.text}hide={hide}/>}
58+
content={<StepDescriptiontext={step.text}mode={step.status}onLoadSolution={onLoadSolution}/>}
5959
/>
6060
)
6161
})}
@@ -67,10 +67,10 @@ const Stage = ({ stage, onContinue, onSave }: Props) => {
6767
<ButtononClick={onContinue}>Continue</Button>
6868
</div>
6969
) :(
70-
<divstyle={styles.options}>
70+
<divstyle={styles.options}>
7171
<ButtononClick={onSave}>Save</Button>
7272
</div>
73-
)}
73+
)}
7474
</div>
7575
)
7676
}

‎web-app/src/containers/Tutorial/StagePage/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ const StageSummaryPageContainer = (props: PageProps) => {
3333
})
3434
}
3535

36+
constonLoadSolution=():void=>{
37+
props.send({type:'STEP_SOLUTION_LOAD'})
38+
}
39+
3640
stage.steps.forEach((step:G.Step)=>{
3741
if(progress.steps[step.id]){
3842
step.status='COMPLETE'
@@ -44,7 +48,7 @@ const StageSummaryPageContainer = (props: PageProps) => {
4448
})
4549
stage.status=progress.stages[position.stageId] ?'COMPLETE' :'ACTIVE'
4650

47-
return<Stagestage={stage}onContinue={onContinue}onSave={onSave}/>
51+
return<Stagestage={stage}onContinue={onContinue}onSave={onSave}onLoadSolution={onLoadSolution}/>
4852
}
4953

5054
exportdefaultStageSummaryPageContainer

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,17 @@ export default {
9797
})
9898
}
9999
},
100+
editorLoadSolution(context:CR.MachineContext):void{
101+
conststep:G.Step=selectors.currentStep(context)
102+
// tell editor to load solution commit
103+
channel.editorSend({
104+
type:'SOLUTION_ACTIONS',
105+
payload:{
106+
stepId:step.id,
107+
...step.solution,
108+
}
109+
})
110+
},
100111
clearStorage():void{
101112
channel.editorSend({type:'TUTORIAL_CLEAR'})
102113
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
113113
on:{
114114
TEST_RUN:'TestRunning',
115115
STEP_SOLUTION_LOAD:{
116-
actions:['callSolution'],
116+
actions:['editorLoadSolution'],
117117
},
118118
},
119119
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp