Skip to content

Commit 06e89d2

Browse files
authored
Merge pull request #63 from ShMcK/fix/continue
Fix/continue
2 parents 3029687 + eb3628e commit 06e89d2

File tree

20 files changed

+114
-119
lines changed

20 files changed

+114
-119
lines changed

src/actions/tutorialConfig.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const tutorialConfig = async (
2626
})
2727
})
2828

29-
// TODO: if remote not already set
29+
// TODO if remote not already set
3030
await git.setupRemote(config.repo.uri).catch(error => {
3131
onError({ title: error.message, description: 'Remove your current Git project and restarting' })
3232
})

src/actions/utils/openFiles.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const openFiles = async (files: string[]) => {
88
}
99
for (const filePath of files) {
1010
try {
11-
// TODO: figure out why this does not work
11+
// TODO figure out why this does not work
1212
// try {
1313
// const absoluteFilePath = join(workspaceRoot.uri.path, filePath)
1414
// const doc = await vscode.workspace.openTextDocument(absoluteFilePath)

src/channel/index.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,12 @@ class Channel implements Channel {
113113
},
114114
onError,
115115
)
116-
return
117-
case 'EDITOR_SYNC_PROGRESS':
118-
// sync client progress on server
119-
this.context.position.set(action.payload.position)
120-
this.context.progress.set(action.payload.progress)
116+
// update the current stepId on startup
117+
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload)
121118
return
122119
// load step actions (git commits, commands, open files)
123120
case 'SETUP_ACTIONS':
124-
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload)
121+
await vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP, action.payload)
125122
setupActions(this.workspaceRoot, action.payload, this.send)
126123
return
127124
// load solution step actions (git commits, commands, open files)

src/channel/state/Position.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Position {
2424
// calculate the current position based on the saved progress
2525
public setPositionFromProgress = (tutorial: G.Tutorial, progress: CR.Progress): CR.Position => {
2626
// tutorial already completed
27-
// TODO: handle start again?
27+
// TODO handle start again?
2828
if (progress.complete) {
2929
return this.value
3030
}
@@ -36,7 +36,7 @@ class Position {
3636
const { levels } = tutorial.version.data
3737

3838
const lastLevelIndex: number | undefined = levels.findIndex((l: G.Level) => !progress.levels[l.id])
39-
// TODO: consider all levels complete as progress.complete
39+
// TODO consider all levels complete as progress.complete
4040
if (lastLevelIndex >= levels.length) {
4141
throw new Error('Error setting progress level')
4242
}
@@ -56,6 +56,7 @@ class Position {
5656
levelId: currentLevel.id,
5757
stepId: currentStep.id,
5858
}
59+
5960
return this.value
6061
}
6162
}

src/channel/state/Progress.ts

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class Progress {
4343
public setStepComplete = (stepId: string): CR.Progress => {
4444
const next = this.value
4545
next.steps[stepId] = true
46+
47+
// TODO validate if progress is complete for a level or tutorial
48+
4649
return this.set(next)
4750
}
4851
}

src/channel/state/Tutorial.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,21 @@ import Storage from '../../services/storage'
66
// Tutorial
77
class Tutorial {
88
private storage: Storage<G.Tutorial | null>
9-
private value: G.Tutorial | null
9+
private value: G.Tutorial | null = null
1010
constructor(workspaceState: vscode.Memento) {
1111
this.storage = new Storage<G.Tutorial | null>({
1212
key: 'coderoad:currentTutorial',
1313
storage: workspaceState,
1414
defaultValue: null,
1515
})
16-
this.value = null
1716
// set value from storage
1817
this.storage.get().then((value: G.Tutorial | null) => {
1918
this.value = value
2019
})
2120
}
22-
public get = () => this.value
21+
public get = () => {
22+
return this.value
23+
}
2324
public set = (value: G.Tutorial | null) => {
2425
this.value = value
2526
this.storage.set(value)

src/editor/commands.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const createCommands = ({ extensionPath, workspaceState, workspaceRoot }:
2626
return {
2727
// initialize
2828
[COMMANDS.START]: async () => {
29-
// TODO: replace with a prompt to open a workspace
29+
// TODO replace with a prompt to open a workspace
3030
// await isEmptyWorkspace()
3131

3232
let webviewState: 'INITIALIZING' | 'RESTARTING'
@@ -58,6 +58,7 @@ export const createCommands = ({ extensionPath, workspaceState, workspaceRoot }:
5858
// send test pass message back to client
5959
vscode.window.showInformationMessage('PASS')
6060
webview.send({ type: 'TEST_PASS', payload })
61+
// update local storage
6162
},
6263
onFail: (payload: Payload, message: string) => {
6364
// send test fail message back to client
@@ -75,13 +76,12 @@ export const createCommands = ({ extensionPath, workspaceState, workspaceRoot }:
7576
})
7677
},
7778
[COMMANDS.SET_CURRENT_STEP]: ({ stepId }: Payload) => {
78-
// NOTE: as async, may sometimes be inaccurate
7979
// set from last setup stepAction
8080
currentStepId = stepId
8181
},
8282
[COMMANDS.RUN_TEST]: (current: Payload | undefined, onSuccess: () => void) => {
8383
// use stepId from client, or last set stepId
84-
const payload: Payload = { stepId: current ? current.stepId : currentStepId }
84+
const payload: Payload = { stepId: current && current.stepId.length ? current.stepId : currentStepId }
8585
testRunner(payload, onSuccess)
8686
},
8787
}

src/services/git/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export async function checkRemoteExists(): Promise<boolean> {
119119
return false
120120
}
121121
// string match on remote output
122-
// TODO: improve the specificity of this regex
122+
// TODO improve the specificity of this regex
123123
return !!stdout.match(gitOrigin)
124124
} catch (error) {
125125
return false

src/services/storage/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ class Storage<T> {
1616
this.defaultValue = defaultValue
1717
}
1818
public get = async (): Promise<T> => {
19-
// const value: string | undefined = await this.storage.get(this.key)
20-
// if (value) {
21-
// return JSON.parse(value)
22-
// }
19+
const value: string | undefined = await this.storage.get(this.key)
20+
if (value) {
21+
return JSON.parse(value)
22+
}
2323
return this.defaultValue
2424
}
2525
public set = (value: T): void => {

src/webview/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface ReactWebViewProps {
1212

1313
const createReactWebView = ({ extensionPath, workspaceState, workspaceRoot }: ReactWebViewProps) => {
1414
let loaded = false
15-
// TODO: add disposables
15+
// TODO add disposables
1616
const disposables: vscode.Disposable[] = []
1717

1818
function createWebViewPanel(): vscode.WebviewPanel {

typings/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ interface MessageState {
108108
state: string
109109
}
110110

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

114114
export interface ProcessEvent {

web-app/src/Routes.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const { Route } = Router
1515
const tempSend = (action: any) => console.log('sent')
1616

1717
const Routes = () => {
18-
// TODO: refactor for typescript to understand send & context passed into React.cloneElement's
18+
// TODO refactor for typescript to understand send & context passed into React.cloneElement's
1919
return (
2020
<Workspace>
2121
<Router>

web-app/src/components/Markdown/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const Markdown = (props: Props) => {
3636
<p>${props.children}</p>
3737
</div>`
3838
}
39-
// TODO: sanitize markdown or HTML
39+
// TODO sanitize markdown or HTML
4040
return <div dangerouslySetInnerHTML={{ __html: html }} />
4141
}
4242

web-app/src/components/Markdown/prism.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ import 'prismjs/components/prism-javascript'
1010
import 'prismjs/components/prism-json'
1111
import 'prismjs/components/prism-sql'
1212
import 'prismjs/components/prism-typescript'
13-
// TODO: import all - current list only supports js related
13+
// TODO import all - current list only supports js related

web-app/src/components/StepHelp/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface Props {
2727
}
2828

2929
const StepHelp = (props: Props) => {
30-
// TODO: extract or replace load solution
30+
// TODO extract or replace load solution
3131
const [loadedSolution, setLoadedSolution] = React.useState()
3232
const onClickHandler = () => {
3333
if (!loadedSolution) {

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

+74-74
Original file line numberDiff line numberDiff line change
@@ -5,87 +5,87 @@ import * as G from 'typings/graphql'
55
import Markdown from '../../components/Markdown'
66

77
const styles = {
8-
page: {
9-
position: 'relative' as 'relative',
10-
display: 'flex' as 'flex',
11-
flexDirection: 'column' as 'column',
12-
width: '100%',
13-
},
14-
summary: {
15-
padding: '0rem 1rem 1rem 1rem',
16-
},
17-
title: {
18-
fontWeight: 'bold' as 'bold',
19-
},
20-
description: {
21-
fontSize: '1rem',
22-
},
23-
header: {
24-
height: '36px',
25-
backgroundColor: '#EBEBEB',
26-
fontSize: '16px',
27-
lineHeight: '16px',
28-
padding: '10px 1rem',
29-
},
30-
levelList: {
31-
padding: '0rem 1rem',
32-
},
33-
options: {
34-
position: 'absolute' as 'absolute',
35-
bottom: 0,
36-
display: 'flex' as 'flex',
37-
flexDirection: 'row' as 'row',
38-
alignItems: 'center' as 'center',
39-
justifyContent: 'flex-end' as 'flex-end',
40-
height: '50px',
41-
padding: '1rem',
42-
paddingRight: '2rem',
43-
backgroundColor: 'black',
44-
width: '100%',
45-
},
8+
page: {
9+
position: 'relative' as 'relative',
10+
display: 'flex' as 'flex',
11+
flexDirection: 'column' as 'column',
12+
width: '100%',
13+
},
14+
summary: {
15+
padding: '0rem 1rem 1rem 1rem',
16+
},
17+
title: {
18+
fontWeight: 'bold' as 'bold',
19+
},
20+
description: {
21+
fontSize: '1rem',
22+
},
23+
header: {
24+
height: '36px',
25+
backgroundColor: '#EBEBEB',
26+
fontSize: '16px',
27+
lineHeight: '16px',
28+
padding: '10px 1rem',
29+
},
30+
levelList: {
31+
padding: '0rem 1rem',
32+
},
33+
options: {
34+
position: 'absolute' as 'absolute',
35+
bottom: 0,
36+
display: 'flex' as 'flex',
37+
flexDirection: 'row' as 'row',
38+
alignItems: 'center' as 'center',
39+
justifyContent: 'flex-end' as 'flex-end',
40+
height: '50px',
41+
padding: '1rem',
42+
paddingRight: '2rem',
43+
backgroundColor: 'black',
44+
width: '100%',
45+
},
4646
}
4747

4848
interface Props {
49-
title: string
50-
description: string
51-
levels: G.Level[]
52-
onNext(): void
49+
title: string
50+
description: string
51+
levels: G.Level[]
52+
onNext(): void
5353
}
5454

5555
const Summary = ({ title, description, levels, onNext }: Props) => (
56-
<div style={styles.page}>
57-
<div>
58-
<div style={styles.header}>
59-
<span>CodeRoad</span>
60-
</div>
61-
<div style={styles.summary}>
62-
<h2 style={styles.title}>{title}</h2>
63-
<Markdown>{description}</Markdown>
64-
</div>
65-
<div>
66-
<div style={styles.header}>
67-
<span>Levels</span>
68-
</div>
69-
<div style={styles.levelList}>
70-
{levels.map((level: G.Level, index: number) => (
71-
<div key={index}>
72-
<h4>
73-
{index + 1}. {level.title}
74-
</h4>
75-
<div>{level.description}</div>
76-
</div>
77-
))}
78-
</div>
79-
</div>
80-
</div>
56+
<div style={styles.page}>
57+
<div>
58+
<div style={styles.header}>
59+
<span>CodeRoad</span>
60+
</div>
61+
<div style={styles.summary}>
62+
<h2 style={styles.title}>{title}</h2>
63+
<Markdown>{description}</Markdown>
64+
</div>
65+
<div>
66+
<div style={styles.header}>
67+
<span>Levels</span>
68+
</div>
69+
<div style={styles.levelList}>
70+
{levels.map((level: G.Level, index: number) => (
71+
<div key={index}>
72+
<h4>
73+
{index + 1}. {level.title}
74+
</h4>
75+
<div>{level.description}</div>
76+
</div>
77+
))}
78+
</div>
79+
</div>
80+
</div>
8181

82-
<div style={styles.options}>
83-
{/* TODO: Add back button */}
84-
<Button type="primary" onClick={() => onNext()}>
85-
Start
86-
</Button>
87-
</div>
88-
</div>
82+
<div style={styles.options}>
83+
{/* TODO Add back button */}
84+
<Button type="primary" onClick={() => onNext()}>
85+
Start
86+
</Button>
87+
</div>
88+
</div>
8989
)
9090

9191
export default Summary

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default {
3232
.catch(console.error)
3333

3434
if (!result || !result.data) {
35-
// TODO: handle failed authentication
35+
// TODO handle failed authentication
3636
console.error('ERROR: Authentication failed')
3737
const error = {
3838
title: 'Authentication Failed',

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default {
4747
// @ts-ignore
4848
updateStepPosition: assign({
4949
position: (context: CR.MachineContext, event: CR.MachineEvent): CR.Position => {
50-
// TODO: calculate from progress
50+
// TODO calculate from progress
5151

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

178178
const { steps } = level
179-
// TODO: verify not -1
179+
// TODO verify not -1
180180
const stepIndex = steps.findIndex((s: G.Step) => s.id === position.stepId)
181181
const finalStep = stepIndex === steps.length - 1
182182
const stepComplete = progress.steps[position.stepId]

0 commit comments

Comments
 (0)