Skip to content

Reset whole tutorial #513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reset tutorial to the Intro page
Signed-off-by: Shubham Shah <shubhamshahrising@gmail.com>
  • Loading branch information
SavvyShah committed Sep 28, 2021
commit 9f45628767e76e0feb2f949e0e0930a9dac419e6
20 changes: 17 additions & 3 deletions web-app/src/containers/Tutorial/containers/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import React, { useState } from 'react'
import { Theme } from '../../../styles/theme'
import Reset from '../components/Reset'

import * as T from 'typings'

const styles = {
flexColumn: {
display: 'flex' as 'flex',
Expand Down Expand Up @@ -43,11 +45,21 @@ const styles = {
},
}

interface Props {}
interface Props {
levels: T.LevelUI[]
onResetToPosition(position: T.Position): void
}

const SettingsPage = (props: Props) => {
const onReset = () => {
console.log('Trigger a reset event here')
const level: T.LevelUI | null = props.levels.length ? props.levels[0] : null
if (level) {
props.onResetToPosition({
levelId: level.id,
stepId: null,
complete: false,
})
}
}
return (
<div css={styles.container}>
Expand All @@ -61,7 +73,9 @@ const SettingsPage = (props: Props) => {
<div css={styles.menuItemHeader}>Reset Tutorial</div>
<div css={styles.menuItemContent}>
This will reset the whole tutorial and change the source files back to the first level and first task
checkpoint.
checkpoint. This will reset the whole tutorial and change the source files back to the first level and
first task checkpoint. This will reset the whole tutorial and change the source files back to the first
level and first task checkpoint.
</div>
</div>
<Reset style={styles.menuItemButton} warning onReset={onReset} />
Expand Down
4 changes: 2 additions & 2 deletions web-app/src/containers/Tutorial/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const TutorialPage = (props: PageProps) => {
levels: tutorial.levels,
testStatus,
})

console.log({ position })
const disableOptions = processes.length > 0 || props.state === 'Level.TestRunning'

return (
Expand All @@ -156,7 +156,7 @@ const TutorialPage = (props: PageProps) => {
)}
{page === 'review' && <ReviewPage levels={levels} onResetToPosition={onResetToPosition} />}

{page === 'settings' && <SettingsPage />}
{page === 'settings' && <SettingsPage levels={levels} onResetToPosition={onResetToPosition} />}
</div>

{props.state === 'Completed' ? (
Expand Down