11import * as CR from 'typings'
22import * as G from 'typings/graphql'
3- import client from '../../apollo'
4- import tutorialQuery from '../../apollo/queries/tutorial'
53import * as selectors from '../../selectors'
6- import onError from '../../../services/sentry/onError'
7-
8- interface TutorialData {
9- tutorial : G . Tutorial
10- }
11-
12- interface TutorialDataVariables {
13- tutorialId : string
14- // version: string
15- }
164
175export default ( editorSend : any ) => ( {
186 loadEnv ( ) : void {
@@ -27,40 +15,6 @@ export default (editorSend: any) => ({
2715 type : 'EDITOR_TUTORIAL_LOAD' ,
2816 } )
2917 } ,
30- initializeTutorial ( context : CR . MachineContext , event : CR . MachineEvent ) {
31- // setup test runner and git
32- if ( ! context . tutorial ) {
33- const error = new Error ( 'Tutorial not available to load' )
34- onError ( error )
35- throw error
36- }
37-
38- client
39- . query < TutorialData , TutorialDataVariables > ( {
40- query : tutorialQuery ,
41- variables : {
42- tutorialId : context . tutorial . id ,
43- // version: context.tutorial.version.version, // TODO: reimplement version
44- } ,
45- } )
46- . then ( result => {
47- if ( ! result || ! result . data || ! result . data . tutorial ) {
48- const message = 'No tutorial returned from tutorial config query'
49- onError ( new Error ( message ) )
50- return Promise . reject ( message )
51- }
52-
53- editorSend ( {
54- type : 'EDITOR_TUTORIAL_CONFIG' ,
55- payload : { tutorial : result . data . tutorial } ,
56- } )
57- } )
58- . catch ( ( error : Error ) => {
59- const message = `Failed to load tutorial config ${ error . message } `
60- onError ( new Error ( message ) )
61- return Promise . reject ( message )
62- } )
63- } ,
6418 continueConfig ( context : CR . MachineContext ) {
6519 editorSend ( {
6620 type : 'EDITOR_TUTORIAL_CONTINUE_CONFIG' ,
0 commit comments