Skip to content

Fix/update to api #43

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 12 commits into from
Oct 15, 2019
Prev Previous commit
Next Next commit
resolve startup issues
  • Loading branch information
ShMcK committed Oct 15, 2019
commit 6d2263ae6481f318d600155bdd15be072b57bc78
6 changes: 3 additions & 3 deletions src/actions/tutorialConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ const tutorialConfig = async ({tutorial, alreadyConfigured, onComplete}: Tutoria
if (onComplete) {onComplete()}
}

// TODO: allow multiple coding languages in a tutorial
const languages: G.CodingLanguage[] = tutorial.version.data.config.codingLanguages
// allow multiple coding languages in a tutorial
const languages: string[] = tutorial.version.data.config.codingLanguages.map(lang => lang.toLowerCase())

// setup onSave hook
vscode.workspace.onDidSaveTextDocument((document: vscode.TextDocument) => {
// @ts-ignore // issue with GQL enums in TS
if (document.uri.scheme === 'file' && languages.includes(document.languageId.toUpperCase())) {
if (document.uri.scheme === 'file' && languages.includes(document.languageId)) {
vscode.commands.executeCommand('coderoad.run_test')
}
})
Expand Down
4 changes: 4 additions & 0 deletions src/channel/state/Position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class Position {
return this.value
}

if (!tutorial || !tutorial.version || !tutorial.version.data || !tutorial.version.data.levels) {
throw new Error('Error setting position from progress')
}

const {levels} = tutorial.version.data

const lastLevelIndex: number | undefined = levels.findIndex((l: G.Level) => !progress.levels[l.id])
Expand Down
2 changes: 0 additions & 2 deletions src/editor/ReactWebView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ class ReactWebView {

// // // prevents moving coderoad panel on top of left panel
// vscode.window.onDidChangeVisibleTextEditors((textEditors: vscode.TextEditor[]) => {
// console.log('onDidChangeVisibleTextEditors')
// console.log(textEditors)
// // updateWindows()
// })

Expand Down
8 changes: 4 additions & 4 deletions src/services/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class Storage<T> {
this.defaultValue = defaultValue
}
public get = async (): Promise<T> => {
const value: string | undefined = await this.storage.get(this.key)
if (value) {
return JSON.parse(value)
}
// const value: string | undefined = await this.storage.get(this.key)
// if (value) {
// return JSON.parse(value)
// }
return this.defaultValue
}
public set = (value: T): void => {
Expand Down
1 change: 0 additions & 1 deletion src/test/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as path from 'path'
import {runTests} from 'vscode-test'

async function main() {
console.log('__dirname', __dirname)
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath: string = path.resolve(__dirname, '../../')
Expand Down
1 change: 0 additions & 1 deletion src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ suite('Extension tests', () => {
await vscode.commands.executeCommand('coderoad.start')
await setTimeout(() => Promise.resolve(), 5000)
// const webview = vscode.window.activeTextEditor
// console.log(webview)
assert.equal(2, 2)
})

Expand Down
2 changes: 1 addition & 1 deletion web-app/src/services/apollo/mutations/authenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default gql`
mutation Authenticate(
$machineId: String!,
$sessionId: String!,
$editor: EditorEnum!
$editor: Editor!
) {
editorLogin(input: {
machineId: $machineId,
Expand Down
1 change: 1 addition & 0 deletions web-app/src/services/apollo/queries/tutorial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default gql`
data {
config {
testRunner
codingLanguages
repo {
uri
}
Expand Down
20 changes: 17 additions & 3 deletions web-app/src/services/state/actions/api.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
import * as CR from 'typings'
import * as G from 'typings/graphql'
import client from '../../apollo'
import authenticateMutation from '../../apollo/mutations/authenticate'
import {setAuthToken} from '../../apollo/auth'
import channel from '../../../services/channel'

interface AuthenticateData {
editorLogin: {
token: string
user: G.User
}
}

interface AuthenticateVariables {
machineId: string
sessionId: string
editor: 'VSCODE'
}

export default {
authenticate: (async (context: CR.MachineContext): Promise<void> => {

const result = await client.mutate({
const result = await client.mutate<AuthenticateData, AuthenticateVariables>({
mutation: authenticateMutation,
variables: {
machineId: context.env.machineId,
sessionId: context.env.sessionId,
editor: 'VSCODE',
}
})

}).catch(console.error)

if (!result || !result.data) {
// TODO: handle failed authentication
console.error('ERROR: Authentication failed')
return
}
const {token} = result.data.editorLogin
// add token to headers
Expand Down