File tree Expand file tree Collapse file tree 4 files changed +17
-9
lines changed
web-app/src/services/state/actions Expand file tree Collapse file tree 4 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ export { default as onStartup } from './onStartup'
22export { default as onTutorialConfig } from './onTutorialConfig'
33export { default as onTutorialContinueConfig } from './onTutorialContinueConfig'
44export { default as onValidateSetup } from './onValidateSetup'
5- export { default as onRunLatestReset } from './onRunLatestReset '
5+ export { default as onRunReset } from './onRunReset '
66export { default as onErrorPage } from './onErrorPage'
77export { onRunTest , onTestPass } from './onTest'
88export { onSetupActions , onSolutionActions } from './onActions'
Original file line number Diff line number Diff line change @@ -3,16 +3,21 @@ import * as TT from 'typings/tutorial'
33import Context from '../services/context/context'
44import { exec } from '../services/node'
55import reset from '../services/reset'
6- import getLastCommitHash from '../services/reset/lastHash'
6+ import getCommitHashByPosition from '../services/reset/lastHash'
7+
8+ type ResetAction = {
9+ type : 'LATEST' | 'POSITION'
10+ position ?: T . Position
11+ }
712
813// reset to the start of the last test
9- const onRunLatestReset = async ( context : Context ) => {
14+ const onRunReset = async ( action : ResetAction , context : Context ) => {
1015 // reset to timeline
1116 const tutorial : TT . Tutorial | null = context . tutorial . get ( )
12- const position : T . Position = context . position . get ( )
17+ const position : T . Position = action . position ? action . position : context . position . get ( )
1318
1419 // get last pass commit
15- const hash = getLastCommitHash ( position , tutorial ?. levels || [ ] )
20+ const hash : string = getCommitHashByPosition ( position , tutorial ?. levels || [ ] )
1621
1722 const branch = tutorial ?. config . repo . branch
1823
@@ -30,4 +35,4 @@ const onRunLatestReset = async (context: Context) => {
3035 }
3136}
3237
33- export default onRunLatestReset
38+ export default onRunReset
Original file line number Diff line number Diff line change @@ -79,8 +79,11 @@ class Channel implements Channel {
7979 case 'EDITOR_RUN_TEST' :
8080 actions . onRunTest ( action )
8181 return
82- case 'EDITOR_RUN_RESET' :
83- actions . onRunLatestReset ( this . context )
82+ case 'EDITOR_RUN_RESET_LATEST' :
83+ actions . onRunReset ( { type : 'LATEST' } , this . context )
84+ return
85+ case 'EDITOR_RUN_RESET_POSITION' :
86+ actions . onRunReset ( { type : 'POSITION' , position : action . payload . position } , this . context )
8487 return
8588 default :
8689 logger ( `No match for action type: ${ actionType } ` )
Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ export default (editorSend: any) => ({
119119 } ,
120120 runReset ( ) {
121121 editorSend ( {
122- type : 'EDITOR_RUN_RESET ' ,
122+ type : 'EDITOR_RUN_RESET_LATEST ' ,
123123 } )
124124 } ,
125125} )
You can’t perform that action at this time.
0 commit comments