File tree Expand file tree Collapse file tree 4 files changed +36
-4
lines changed Expand file tree Collapse file tree 4 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import AdminContext from '../../../services/admin/context'
99
1010interface Props {
1111 levels : T . LevelUI [ ]
12+ onResetToPosition ( position : T . Position ) : void
1213}
1314
1415const styles = {
@@ -67,7 +68,16 @@ const ReviewPage = (props: Props) => {
6768 < div key = { level . id } >
6869 { adminMode && (
6970 < div css = { styles . adminNav } >
70- < Button type = "normal" warning >
71+ < Button
72+ type = "normal"
73+ warning
74+ onClick = { ( ) =>
75+ props . onResetToPosition ( {
76+ levelId : level . id ,
77+ stepId : level . steps . length ? level . steps [ 0 ] . id : null ,
78+ } )
79+ }
80+ >
7181 { level . id }
7282 < Icon type = "refresh" />
7383 </ Button >
@@ -84,7 +94,11 @@ const ReviewPage = (props: Props) => {
8494 < div key = { step . id } >
8595 { adminMode && (
8696 < div css = { styles . adminNav } >
87- < Button type = "normal" warning >
97+ < Button
98+ type = "normal"
99+ warning
100+ onClick = { ( ) => props . onResetToPosition ( { levelId : level . id , stepId : step . id } ) }
101+ >
88102 { step . id }
89103 < Icon type = "refresh" />
90104 </ Button >
Original file line number Diff line number Diff line change @@ -119,6 +119,10 @@ const TutorialPage = (props: PageProps) => {
119119 props . send ( { type : 'RUN_RESET' } )
120120 }
121121
122+ const onResetToPosition = ( position : T . Position ) : void => {
123+ props . send ( { type : 'RUN_RESET_TO_POSITION' , payload : { position } } )
124+ }
125+
122126 const [ menuVisible , setMenuVisible ] = React . useState ( false )
123127
124128 const [ page , setPage ] = React . useState < 'about' | 'level' | 'review' | 'settings' > ( 'level' )
@@ -150,7 +154,7 @@ const TutorialPage = (props: PageProps) => {
150154 < Level level = { level } />
151155 </ ScrollContent >
152156 ) }
153- { page === 'review' && < ReviewPage levels = { levels } /> }
157+ { page === 'review' && < ReviewPage levels = { levels } onResetToPosition = { onResetToPosition } /> }
154158
155159 { /* {page === 'settings' && <SettingsPage />} */ }
156160 </ div >
Original file line number Diff line number Diff line change 11import * as T from 'typings'
22import * as TT from 'typings/tutorial'
3+ import { assign } from 'xstate'
34import * as selectors from '../../selectors'
45
56export default ( editorSend : any ) => ( {
@@ -117,9 +118,19 @@ export default (editorSend: any) => ({
117118 payload : { position : context . position } ,
118119 } )
119120 } ,
120- runReset ( ) {
121+ runReset ( ) : void {
121122 editorSend ( {
122123 type : 'EDITOR_RUN_RESET_LATEST' ,
123124 } )
124125 } ,
126+ // @ts -ignore
127+ runResetToPosition : assign ( {
128+ position : ( context : T . MachineContext , event : T . MachineEvent ) => {
129+ editorSend ( {
130+ type : 'EDITOR_RUN_RESET_POSITION' ,
131+ payload : event . payload ,
132+ } )
133+ return event . payload . position
134+ } ,
135+ } ) ,
125136} )
Original file line number Diff line number Diff line change @@ -171,6 +171,9 @@ export const createMachine = (options: any) => {
171171 RUN_RESET : {
172172 actions : [ 'runReset' ] ,
173173 } ,
174+ RUN_RESET_TO_POSITION : {
175+ actions : [ 'runResetToPosition' ] ,
176+ } ,
174177 KEY_PRESS_ENTER : {
175178 actions : [ 'runTest' ] ,
176179 } ,
You can’t perform that action at this time.
0 commit comments