Skip to content

Feature/key bindings #391

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 6 commits into from
Jul 18, 2020
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
open continue on success
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
ShMcK committed Jul 18, 2020
commit ca2d77eda834a382d9139ca79451a82152dd7086
2 changes: 1 addition & 1 deletion web-app/src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Routes = () => {
<LoadingPage text="Loading Level..." processes={context.processes} />
</Route>
<Route paths={{ Tutorial: { Level: true } }}>
<TutorialPage send={send} context={context} />
<TutorialPage send={send} context={context} state={route.replace('Tutorial.Level.', '')} />
</Route>
{/* Completed */}
<Route paths={{ Tutorial: { Completed: true } }}>
Expand Down
3 changes: 2 additions & 1 deletion web-app/src/containers/Tutorial/components/Continue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ interface Props {
title: string
current: number // level index
max: number // level count
defaultOpen: boolean
onContinue(): void
}

const Continue = (props: Props) => {
const [modalState, setModalState] = React.useState<'closed' | 'open'>('closed')
const [modalState, setModalState] = React.useState<'closed' | 'open'>(props.defaultOpen ? 'open' : 'closed')

const onClose = () => {
setModalState('closed')
Expand Down
21 changes: 17 additions & 4 deletions web-app/src/containers/Tutorial/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import TestMessage from '../../components/TestMessage'
import StepProgress from './components/StepProgress'
import { DISPLAY_RUN_TEST_BUTTON } from '../../environment'
import formatLevels from './formatLevels'
// import SettingsPage from './containers/Settings'
import Reset from './components/Reset'
import Continue from './components/Continue'

Expand Down Expand Up @@ -69,6 +68,7 @@ const styles = {
interface PageProps {
context: T.MachineContext
send(action: T.Action): void
state: string // 'Normal' | 'TestRunning' | 'TestFail' | 'TestPass' | 'LevelComplete'
}

/**
Expand Down Expand Up @@ -111,6 +111,8 @@ const TutorialPage = (props: PageProps) => {
testStatus,
})

const disableOptions = processes.length > 0 && props.state === 'TestRunning'

return (
<div>
<div>
Expand Down Expand Up @@ -141,26 +143,37 @@ const TutorialPage = (props: PageProps) => {
{/* Left */}
<div css={{ flex: 1 }}>
{DISPLAY_RUN_TEST_BUTTON && level.status !== 'COMPLETE' ? (
<Button style={{ marginLeft: '1rem' }} type="primary" onClick={onRunTest} disabled={processes.length > 0}>
<Button style={{ marginLeft: '1rem' }} type="primary" onClick={onRunTest} disabled={disableOptions}>
Run
</Button>
) : null}
</div>

{/* Center */}
<div css={{ flex: 1, display: 'flex', justifyContent: 'center' }}>
<Reset onReset={onReset} disabled={processes.length > 0} />
<Reset onReset={onReset} disabled={disableOptions} />
</div>

{/* Right */}
<div css={{ flex: 1, display: 'flex', justifyContent: 'flex-end' }}>
{level.status === 'COMPLETE' || !level.steps.length ? (
{!level.steps.length ? (
<div css={{ marginRight: '0.5rem' }}>
<Continue
onContinue={onContinue}
current={levelIndex + 1}
max={levels.length}
title={tutorial.summary.title}
defaultOpen={false}
/>
</div>
) : props.state === 'LevelComplete' ? (
<div css={{ marginRight: '0.5rem' }}>
<Continue
onContinue={onContinue}
current={levelIndex + 1}
max={levels.length}
title={tutorial.summary.title}
defaultOpen={true}
/>
</div>
) : level.steps.length > 1 ? (
Expand Down