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'
2
2
export { default as onTutorialConfig } from './onTutorialConfig'
3
3
export { default as onTutorialContinueConfig } from './onTutorialContinueConfig'
4
4
export { default as onValidateSetup } from './onValidateSetup'
5
- export { default as onRunLatestReset } from './onRunLatestReset '
5
+ export { default as onRunReset } from './onRunReset '
6
6
export { default as onErrorPage } from './onErrorPage'
7
7
export { onRunTest, onTestPass } from './onTest'
8
8
export { onSetupActions, onSolutionActions } from './onActions'
Original file line number Diff line number Diff line change @@ -3,16 +3,21 @@ import * as TT from 'typings/tutorial'
3
3
import Context from '../services/context/context'
4
4
import { exec } from '../services/node'
5
5
import 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
+ }
7
12
8
13
// reset to the start of the last test
9
- const onRunLatestReset = async (context: Context) => {
14
+ const onRunReset = async (action: ResetAction, context: Context) => {
10
15
// reset to timeline
11
16
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()
13
18
14
19
// get last pass commit
15
- const hash = getLastCommitHash (position, tutorial?.levels || [])
20
+ const hash: string = getCommitHashByPosition (position, tutorial?.levels || [])
16
21
17
22
const branch = tutorial?.config.repo.branch
18
23
@@ -30,4 +35,4 @@ const onRunLatestReset = async (context: Context) => {
30
35
}
31
36
}
32
37
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 {
79
79
case 'EDITOR_RUN_TEST':
80
80
actions.onRunTest(action)
81
81
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)
84
87
return
85
88
default:
86
89
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) => ({
119
119
},
120
120
runReset() {
121
121
editorSend({
122
- type: 'EDITOR_RUN_RESET ',
122
+ type: 'EDITOR_RUN_RESET_LATEST ',
123
123
})
124
124
},
125
125
})
You can’t perform that action at this time.
0 commit comments