Skip to content

WIP - Feature/admin mode #412

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 8 commits into from
Jul 27, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

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 to position
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
ShMcK committed Jul 27, 2020
commit c30e11d8b2f5c51514f954fe5475cc631ecbf244
2 changes: 1 addition & 1 deletion src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ export { default as onStartup } from './onStartup'
export { default as onTutorialConfig } from './onTutorialConfig'
export { default as onTutorialContinueConfig } from './onTutorialContinueConfig'
export { default as onValidateSetup } from './onValidateSetup'
export { default as onRunLatestReset } from './onRunLatestReset'
export { default as onRunReset } from './onRunReset'
export { default as onErrorPage } from './onErrorPage'
export { onRunTest, onTestPass } from './onTest'
export { onSetupActions, onSolutionActions } from './onActions'
15 changes: 10 additions & 5 deletions src/actions/onRunLatestReset.ts → src/actions/onRunReset.ts
Original file line number Diff line number Diff line change
@@ -3,16 +3,21 @@ import * as TT from 'typings/tutorial'
import Context from '../services/context/context'
import { exec } from '../services/node'
import reset from '../services/reset'
import getLastCommitHash from '../services/reset/lastHash'
import getCommitHashByPosition from '../services/reset/lastHash'

type ResetAction = {
type: 'LATEST' | 'POSITION'
position?: T.Position
}

// reset to the start of the last test
const onRunLatestReset = async (context: Context) => {
const onRunReset = async (action: ResetAction, context: Context) => {
// reset to timeline
const tutorial: TT.Tutorial | null = context.tutorial.get()
const position: T.Position = context.position.get()
const position: T.Position = action.position ? action.position : context.position.get()

// get last pass commit
const hash = getLastCommitHash(position, tutorial?.levels || [])
const hash: string = getCommitHashByPosition(position, tutorial?.levels || [])

const branch = tutorial?.config.repo.branch

@@ -30,4 +35,4 @@ const onRunLatestReset = async (context: Context) => {
}
}

export default onRunLatestReset
export default onRunReset
7 changes: 5 additions & 2 deletions src/channel.ts
Original file line number Diff line number Diff line change
@@ -79,8 +79,11 @@ class Channel implements Channel {
case 'EDITOR_RUN_TEST':
actions.onRunTest(action)
return
case 'EDITOR_RUN_RESET':
actions.onRunLatestReset(this.context)
case 'EDITOR_RUN_RESET_LATEST':
actions.onRunReset({ type: 'LATEST' }, this.context)
return
case 'EDITOR_RUN_RESET_POSITION':
actions.onRunReset({ type: 'POSITION', position: action.payload.position }, this.context)
return
default:
logger(`No match for action type: ${actionType}`)
2 changes: 1 addition & 1 deletion web-app/src/services/state/actions/editor.ts
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ export default (editorSend: any) => ({
},
runReset() {
editorSend({
type: 'EDITOR_RUN_RESET',
type: 'EDITOR_RUN_RESET_LATEST',
})
},
})