Skip to content

Commit c405101

Browse files
committed
cleanup select tutorial config
1 parent a73d0fb commit c405101

File tree

8 files changed

+80
-269
lines changed

8 files changed

+80
-269
lines changed

typings/index.d.ts

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -42,63 +42,6 @@ export interface ErrorMessage {
4242
description?: string
4343
}
4444

45-
export interface MachineContext {
46-
env: Environment
47-
error: ErrorMessage | null
48-
tutorial: G.Tutorial | null
49-
}
50-
51-
export interface PlayMachineContext extends MachineContext {
52-
position: Position
53-
progress: Progress
54-
processes: ProcessEvent[]
55-
}
56-
57-
export interface MachineEvent {
58-
type: string
59-
payload?: any
60-
data?: any
61-
}
62-
63-
export interface SelectTutorialMachineStateSchema {
64-
states: {
65-
Startup: {}
66-
Authenticate: {}
67-
NewOrContinue: {}
68-
SelectTutorial: {}
69-
Summary: {}
70-
Configure: {}
71-
Launch: {}
72-
ContinueTutorial: {}
73-
}
74-
}
75-
76-
export interface PlayTutorialMachineStateSchema {
77-
states: {
78-
LoadNext: {}
79-
Level: {
80-
states: {
81-
Loading: {}
82-
Normal: {}
83-
TestRunning: {}
84-
TestPass: {}
85-
TestFail: {}
86-
TestError: {}
87-
StepNext: {}
88-
LevelComplete: {}
89-
}
90-
}
91-
Completed: {}
92-
}
93-
}
94-
95-
export interface MachineStateSchema {
96-
states: {
97-
SelectTutorial: {}
98-
PlayTutorial: {}
99-
}
100-
}
101-
10245
export interface StateMachine {
10346
activate(): void
10447
deactivate(): void

web-app/src/containers/New/TutorialList/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface Props {
1010
const TutorialList = (props: Props) => {
1111
const onSelect = (tutorial: G.Tutorial) => {
1212
channel.machineSend({
13-
type: 'TUTORIAL_START',
13+
type: 'SELECT_NEW_TUTORIAL',
1414
payload: {
1515
tutorial,
1616
},

web-app/src/containers/Overview/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import * as G from 'typings/graphql'
55
import ErrorView from '../../components/Error'
66
import queryTutorial from '../../services/apollo/queries/tutorial'
77
import OverviewPage from './OverviewPage'
8+
import { MachineContext } from '../../services/state/selectTutorial'
89

910
interface PageProps {
10-
context: CR.MachineContext
11+
context: MachineContext
1112
send(action: CR.Action): void
1213
}
1314

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import * as CR from 'typings'
21
import * as G from 'typings/graphql'
3-
import client from '../../../apollo'
4-
import tutorialQuery from '../../../apollo/queries/tutorial'
5-
import channel from '../../../channel'
6-
import * as selectors from '../../../selectors'
7-
import onError from '../../../../services/sentry/onError'
2+
import { ActionFunctionMap } from 'xstate'
3+
import client from '../../apollo'
4+
import tutorialQuery from '../../apollo/queries/tutorial'
5+
import channel from '../../channel'
6+
import onError from '../../../services/sentry/onError'
7+
import { MachineContext, MachineEvent } from './index'
88

99
interface TutorialData {
1010
tutorial: G.Tutorial
@@ -15,7 +15,7 @@ interface TutorialDataVariables {
1515
// version: string
1616
}
1717

18-
export default {
18+
const actionMap: ActionFunctionMap<MachineContext, MachineEvent> = {
1919
loadEnv(): void {
2020
channel.editorSend({
2121
type: 'ENV_GET',
@@ -28,7 +28,7 @@ export default {
2828
type: 'EDITOR_TUTORIAL_LOAD',
2929
})
3030
},
31-
initializeTutorial(context: CR.PlayMachineContext, event: CR.MachineEvent) {
31+
initializeTutorial(context: MachineContext, event: MachineEvent) {
3232
// setup test runner and git
3333
if (!context.tutorial) {
3434
const error = new Error('Tutorial not available to load')
@@ -62,50 +62,21 @@ export default {
6262
return Promise.reject(message)
6363
})
6464
},
65-
continueConfig(context: CR.PlayMachineContext) {
66-
channel.editorSend({
67-
type: 'EDITOR_TUTORIAL_CONTINUE_CONFIG',
68-
payload: {
69-
// pass position because current stepId or first stepId will be empty
70-
stepId: context.position.stepId,
71-
},
72-
})
73-
},
74-
loadLevel(context: CR.PlayMachineContext): void {
75-
const level: G.Level = selectors.currentLevel(context)
76-
if (level.setup) {
77-
// load step actions
78-
channel.editorSend({
79-
type: 'SETUP_ACTIONS',
80-
payload: level.setup,
81-
})
82-
}
83-
},
84-
loadStep(context: CR.PlayMachineContext): void {
85-
const step: G.Step = selectors.currentStep(context)
86-
if (step.setup) {
87-
// load step actions
88-
channel.editorSend({
89-
type: 'SETUP_ACTIONS',
90-
payload: {
91-
stepId: step.id,
92-
...step.setup,
93-
},
94-
})
95-
}
96-
},
97-
editorLoadSolution(context: CR.PlayMachineContext): void {
98-
const step: G.Step = selectors.currentStep(context)
99-
// tell editor to load solution commit
100-
channel.editorSend({
101-
type: 'SOLUTION_ACTIONS',
102-
payload: {
103-
stepId: step.id,
104-
...step.solution,
105-
},
106-
})
107-
},
65+
// continueConfig(context: CR.MachineContext) {
66+
// channel.editorSend({
67+
// type: 'EDITOR_TUTORIAL_CONTINUE_CONFIG',
68+
// payload: {
69+
// // pass position because current stepId or first stepId will be empty
70+
// stepId: context.position.stepId,
71+
// },
72+
// })
73+
// },
10874
clearStorage(): void {
10975
channel.editorSend({ type: 'TUTORIAL_CLEAR' })
11076
},
77+
userTutorialComplete(context: MachineContext) {
78+
console.log('should update user tutorial as complete')
79+
},
11180
}
81+
82+
export default actionMap

web-app/src/services/state/selectTutorial/actions/api.ts

Lines changed: 0 additions & 68 deletions
This file was deleted.

web-app/src/services/state/selectTutorial/actions/context.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

web-app/src/services/state/selectTutorial/actions/index.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)