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

Commit76420e5

Browse files
committed
render level with no steps
1 parent1b8f290 commit76420e5

File tree

2 files changed

+47
-27
lines changed

2 files changed

+47
-27
lines changed

‎web-app/src/containers/Tutorial/LevelPage/Level.tsx

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ interface Props {
8585
}
8686

8787
constLevel=({ level, onContinue, onLoadSolution, processes, testStatus}:Props)=>{
88-
if(!level.steps){
89-
thrownewError('No Stage steps found')
88+
//@ts-ignore
89+
letcurrentStep=level.steps.findIndex(s=>s.status==='ACTIVE')
90+
if(currentStep===-1){
91+
currentStep=level.steps.length
9092
}
9193

9294
constpageBottomRef=React.useRef(null)
@@ -95,11 +97,6 @@ const Level = ({ level, onContinue, onLoadSolution, processes, testStatus }: Pro
9597
//@ts-ignore
9698
pageBottomRef.current.scrollIntoView({behavior:'smooth'})
9799
}
98-
//@ts-ignore
99-
letcurrentStep=level.steps.findIndex(s=>s.status==='ACTIVE')
100-
if(currentStep===-1){
101-
currentStep=level.steps.length
102-
}
103100
React.useEffect(scrollToBottom,[currentStep])
104101

105102
return(
@@ -112,26 +109,28 @@ const Level = ({ level, onContinue, onLoadSolution, processes, testStatus }: Pro
112109
<Markdown>{level.content||''}</Markdown>
113110
</div>
114111

115-
<divcss={styles.tasks}>
116-
<divcss={styles.header}>Tasks</div>
117-
<divcss={styles.steps}>
118-
{level.steps.map((step:(G.Step&{status:T.ProgressStatus})|null,index:number)=>{
119-
if(!step){
120-
returnnull
121-
}
122-
return(
123-
<Step
124-
key={step.id}
125-
order={index+1}
126-
status={step.status}
127-
content={step.content}
128-
onLoadSolution={onLoadSolution}
129-
/>
130-
)
131-
})}
112+
{level.steps.length ?(
113+
<divcss={styles.tasks}>
114+
<divcss={styles.header}>Tasks</div>
115+
<divcss={styles.steps}>
116+
{level.steps.map((step:(G.Step&{status:T.ProgressStatus})|null,index:number)=>{
117+
if(!step){
118+
returnnull
119+
}
120+
return(
121+
<Step
122+
key={step.id}
123+
order={index+1}
124+
status={step.status}
125+
content={step.content}
126+
onLoadSolution={onLoadSolution}
127+
/>
128+
)
129+
})}
130+
</div>
132131
</div>
133-
<divref={pageBottomRef}/>
134-
</div>
132+
) :null}
133+
<divref={pageBottomRef}/>
135134

136135
{(testStatus||processes.length>0)&&(
137136
<divcss={styles.processes}>
@@ -149,7 +148,7 @@ const Level = ({ level, onContinue, onLoadSolution, processes, testStatus }: Pro
149148
{level.title}
150149
</span>
151150
<span>
152-
{level.status==='COMPLETE' ?(
151+
{level.status==='COMPLETE'||!level.steps.length?(
153152
<Buttontype="primary"onClick={onContinue}>
154153
Continue
155154
</Button>

‎web-app/stories/Level.stories.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,24 @@ storiesOf('Level', module)
289289
/>
290290
)
291291
})
292+
.add('No steps',()=>{
293+
constlevel={
294+
id:'L1',
295+
index:0,
296+
title:'A Title',
297+
description:'A summary of the level',
298+
content:'Some content here in markdown',
299+
setup:null,
300+
status:'ACTIVE',
301+
steps:[],
302+
}
303+
return(
304+
<Level
305+
level={level}
306+
onContinue={action('onContinue')}
307+
onLoadSolution={action('onLoadSolution')}
308+
processes={[]}
309+
testStatus={null}
310+
/>
311+
)
312+
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp