Skip to content

Fix/continue #63

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 4 commits into from
Dec 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/actions/tutorialConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const tutorialConfig = async (
})
})

// TODO: if remote not already set
// TODO if remote not already set
await git.setupRemote(config.repo.uri).catch(error => {
onError({ title: error.message, description: 'Remove your current Git project and restarting' })
})
Expand Down
2 changes: 1 addition & 1 deletion src/actions/utils/openFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const openFiles = async (files: string[]) => {
}
for (const filePath of files) {
try {
// TODO: figure out why this does not work
// TODO figure out why this does not work
// try {
// const absoluteFilePath = join(workspaceRoot.uri.path, filePath)
// const doc = await vscode.workspace.openTextDocument(absoluteFilePath)
Expand Down
9 changes: 3 additions & 6 deletions src/channel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,12 @@ class Channel implements Channel {
},
onError,
)
return
case 'EDITOR_SYNC_PROGRESS':
// sync client progress on server
this.context.position.set(action.payload.position)
this.context.progress.set(action.payload.progress)
// update the current stepId on startup
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload)
return
// load step actions (git commits, commands, open files)
case 'SETUP_ACTIONS':
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload)
await vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload)
setupActions(this.workspaceRoot, action.payload, this.send)
return
// load solution step actions (git commits, commands, open files)
Expand Down
5 changes: 3 additions & 2 deletions src/channel/state/Position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Position {
// calculate the current position based on the saved progress
public setPositionFromProgress = (tutorial: G.Tutorial, progress: CR.Progress): CR.Position => {
// tutorial already completed
// TODO: handle start again?
// TODO handle start again?
if (progress.complete) {
return this.value
}
Expand All @@ -36,7 +36,7 @@ class Position {
const { levels } = tutorial.version.data

const lastLevelIndex: number | undefined = levels.findIndex((l: G.Level) => !progress.levels[l.id])
// TODO: consider all levels complete as progress.complete
// TODO consider all levels complete as progress.complete
if (lastLevelIndex >= levels.length) {
throw new Error('Error setting progress level')
}
Expand All @@ -56,6 +56,7 @@ class Position {
levelId: currentLevel.id,
stepId: currentStep.id,
}

return this.value
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/channel/state/Progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class Progress {
public setStepComplete = (stepId: string): CR.Progress => {
const next = this.value
next.steps[stepId] = true

// TODO validate if progress is complete for a level or tutorial

return this.set(next)
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/channel/state/Tutorial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ import Storage from '../../services/storage'
// Tutorial
class Tutorial {
private storage: Storage<G.Tutorial | null>
private value: G.Tutorial | null
private value: G.Tutorial | null = null
constructor(workspaceState: vscode.Memento) {
this.storage = new Storage<G.Tutorial | null>({
key: 'coderoad:currentTutorial',
storage: workspaceState,
defaultValue: null,
})
this.value = null
// set value from storage
this.storage.get().then((value: G.Tutorial | null) => {
this.value = value
})
}
public get = () => this.value
public get = () => {
return this.value
}
public set = (value: G.Tutorial | null) => {
this.value = value
this.storage.set(value)
Expand Down
6 changes: 3 additions & 3 deletions src/editor/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const createCommands = ({ extensionPath, workspaceState, workspaceRoot }:
return {
// initialize
[COMMANDS.START]: async () => {
// TODO: replace with a prompt to open a workspace
// TODO replace with a prompt to open a workspace
// await isEmptyWorkspace()

let webviewState: 'INITIALIZING' | 'RESTARTING'
Expand Down Expand Up @@ -58,6 +58,7 @@ export const createCommands = ({ extensionPath, workspaceState, workspaceRoot }:
// send test pass message back to client
vscode.window.showInformationMessage('PASS')
webview.send({ type: 'TEST_PASS', payload })
// update local storage
},
onFail: (payload: Payload, message: string) => {
// send test fail message back to client
Expand All @@ -75,13 +76,12 @@ export const createCommands = ({ extensionPath, workspaceState, workspaceRoot }:
})
},
[COMMANDS.SET_CURRENT_STEP]: ({ stepId }: Payload) => {
// NOTE: as async, may sometimes be inaccurate
// set from last setup stepAction
currentStepId = stepId
},
[COMMANDS.RUN_TEST]: (current: Payload | undefined, onSuccess: () => void) => {
// use stepId from client, or last set stepId
const payload: Payload = { stepId: current ? current.stepId : currentStepId }
const payload: Payload = { stepId: current && current.stepId.length ? current.stepId : currentStepId }
testRunner(payload, onSuccess)
},
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/git/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export async function checkRemoteExists(): Promise<boolean> {
return false
}
// string match on remote output
// TODO: improve the specificity of this regex
// TODO improve the specificity of this regex
return !!stdout.match(gitOrigin)
} catch (error) {
return false
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
2 changes: 1 addition & 1 deletion src/webview/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface ReactWebViewProps {

const createReactWebView = ({ extensionPath, workspaceState, workspaceRoot }: ReactWebViewProps) => {
let loaded = false
// TODO: add disposables
// TODO add disposables
const disposables: vscode.Disposable[] = []

function createWebViewPanel(): vscode.WebviewPanel {
Expand Down
2 changes: 1 addition & 1 deletion typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ interface MessageState {
state: string
}

// todo: type each string param and payload
// TODO type each string param and payload
export type EditorDispatch = (type: string, payload?: MessageData | MessageState | any) => void

export interface ProcessEvent {
Expand Down
2 changes: 1 addition & 1 deletion web-app/src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { Route } = Router
const tempSend = (action: any) => console.log('sent')

const Routes = () => {
// TODO: refactor for typescript to understand send & context passed into React.cloneElement's
// TODO refactor for typescript to understand send & context passed into React.cloneElement's
return (
<Workspace>
<Router>
Expand Down
2 changes: 1 addition & 1 deletion web-app/src/components/Markdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const Markdown = (props: Props) => {
<p>${props.children}</p>
</div>`
}
// TODO: sanitize markdown or HTML
// TODO sanitize markdown or HTML
return <div dangerouslySetInnerHTML={{ __html: html }} />
}

Expand Down
2 changes: 1 addition & 1 deletion web-app/src/components/Markdown/prism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ import 'prismjs/components/prism-javascript'
import 'prismjs/components/prism-json'
import 'prismjs/components/prism-sql'
import 'prismjs/components/prism-typescript'
// TODO: import all - current list only supports js related
// TODO import all - current list only supports js related
2 changes: 1 addition & 1 deletion web-app/src/components/StepHelp/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface Props {
}

const StepHelp = (props: Props) => {
// TODO: extract or replace load solution
// TODO extract or replace load solution
const [loadedSolution, setLoadedSolution] = React.useState()
const onClickHandler = () => {
if (!loadedSolution) {
Expand Down
148 changes: 74 additions & 74 deletions web-app/src/containers/Overview/OverviewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,87 +5,87 @@ import * as G from 'typings/graphql'
import Markdown from '../../components/Markdown'

const styles = {
page: {
position: 'relative' as 'relative',
display: 'flex' as 'flex',
flexDirection: 'column' as 'column',
width: '100%',
},
summary: {
padding: '0rem 1rem 1rem 1rem',
},
title: {
fontWeight: 'bold' as 'bold',
},
description: {
fontSize: '1rem',
},
header: {
height: '36px',
backgroundColor: '#EBEBEB',
fontSize: '16px',
lineHeight: '16px',
padding: '10px 1rem',
},
levelList: {
padding: '0rem 1rem',
},
options: {
position: 'absolute' as 'absolute',
bottom: 0,
display: 'flex' as 'flex',
flexDirection: 'row' as 'row',
alignItems: 'center' as 'center',
justifyContent: 'flex-end' as 'flex-end',
height: '50px',
padding: '1rem',
paddingRight: '2rem',
backgroundColor: 'black',
width: '100%',
},
page: {
position: 'relative' as 'relative',
display: 'flex' as 'flex',
flexDirection: 'column' as 'column',
width: '100%',
},
summary: {
padding: '0rem 1rem 1rem 1rem',
},
title: {
fontWeight: 'bold' as 'bold',
},
description: {
fontSize: '1rem',
},
header: {
height: '36px',
backgroundColor: '#EBEBEB',
fontSize: '16px',
lineHeight: '16px',
padding: '10px 1rem',
},
levelList: {
padding: '0rem 1rem',
},
options: {
position: 'absolute' as 'absolute',
bottom: 0,
display: 'flex' as 'flex',
flexDirection: 'row' as 'row',
alignItems: 'center' as 'center',
justifyContent: 'flex-end' as 'flex-end',
height: '50px',
padding: '1rem',
paddingRight: '2rem',
backgroundColor: 'black',
width: '100%',
},
}

interface Props {
title: string
description: string
levels: G.Level[]
onNext(): void
title: string
description: string
levels: G.Level[]
onNext(): void
}

const Summary = ({ title, description, levels, onNext }: Props) => (
<div style={styles.page}>
<div>
<div style={styles.header}>
<span>CodeRoad</span>
</div>
<div style={styles.summary}>
<h2 style={styles.title}>{title}</h2>
<Markdown>{description}</Markdown>
</div>
<div>
<div style={styles.header}>
<span>Levels</span>
</div>
<div style={styles.levelList}>
{levels.map((level: G.Level, index: number) => (
<div key={index}>
<h4>
{index + 1}. {level.title}
</h4>
<div>{level.description}</div>
</div>
))}
</div>
</div>
</div>
<div style={styles.page}>
<div>
<div style={styles.header}>
<span>CodeRoad</span>
</div>
<div style={styles.summary}>
<h2 style={styles.title}>{title}</h2>
<Markdown>{description}</Markdown>
</div>
<div>
<div style={styles.header}>
<span>Levels</span>
</div>
<div style={styles.levelList}>
{levels.map((level: G.Level, index: number) => (
<div key={index}>
<h4>
{index + 1}. {level.title}
</h4>
<div>{level.description}</div>
</div>
))}
</div>
</div>
</div>

<div style={styles.options}>
{/* TODO: Add back button */}
<Button type="primary" onClick={() => onNext()}>
Start
</Button>
</div>
</div>
<div style={styles.options}>
{/* TODO Add back button */}
<Button type="primary" onClick={() => onNext()}>
Start
</Button>
</div>
</div>
)

export default Summary
2 changes: 1 addition & 1 deletion web-app/src/services/state/actions/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
.catch(console.error)

if (!result || !result.data) {
// TODO: handle failed authentication
// TODO handle failed authentication
console.error('ERROR: Authentication failed')
const error = {
title: 'Authentication Failed',
Expand Down
4 changes: 2 additions & 2 deletions web-app/src/services/state/actions/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default {
// @ts-ignore
updateStepPosition: assign({
position: (context: CR.MachineContext, event: CR.MachineEvent): CR.Position => {
// TODO: calculate from progress
// TODO calculate from progress

const { position } = context
// merge in the updated position
Expand Down Expand Up @@ -176,7 +176,7 @@ export default {
const level: G.Level = selectors.currentLevel(context)

const { steps } = level
// TODO: verify not -1
// TODO verify not -1
const stepIndex = steps.findIndex((s: G.Step) => s.id === position.stepId)
const finalStep = stepIndex === steps.length - 1
const stepComplete = progress.steps[position.stepId]
Expand Down
Loading