Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit50a3b76

Browse files
authored
Merge pull requestcoderoad#326 from coderoad/feature/run-save-configs
Feature/run save configs
2 parentsa33089a +f53a941 commit50a3b76

File tree

8 files changed

+52
-18
lines changed

8 files changed

+52
-18
lines changed

‎src/actions/tutorialConfig.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as TT from 'typings/tutorial'
33
import*asvscodefrom'vscode'
44
import{COMMANDS}from'../editor/commands'
55
import*asgitfrom'../services/git'
6+
import{DISABLE_RUN_ON_SAVE}from'../environment'
67

78
interfaceTutorialConfigParams{
89
config:TT.TutorialConfig
@@ -53,21 +54,23 @@ const tutorialConfig = async ({ config, alreadyConfigured }: TutorialConfigParam
5354

5455
awaitvscode.commands.executeCommand(COMMANDS.CONFIG_TEST_RUNNER,config.testRunner)
5556

56-
// verify if file test should run based on document saved
57-
constshouldRunTest=(document:vscode.TextDocument):boolean=>{
58-
// must be a file
59-
if(document.uri.scheme!=='file'){
60-
returnfalse
57+
if(!DISABLE_RUN_ON_SAVE){
58+
// verify if file test should run based on document saved
59+
constshouldRunTest=(document:vscode.TextDocument):boolean=>{
60+
// must be a file
61+
if(document.uri.scheme!=='file'){
62+
returnfalse
63+
}
64+
returntrue
6165
}
62-
returntrue
63-
}
6466

65-
// setup onSave hook
66-
vscode.workspace.onDidSaveTextDocument((document:vscode.TextDocument)=>{
67-
if(shouldRunTest(document)){
68-
vscode.commands.executeCommand(COMMANDS.RUN_TEST)
69-
}
70-
})
67+
// setup onSave hook
68+
vscode.workspace.onDidSaveTextDocument((document:vscode.TextDocument)=>{
69+
if(shouldRunTest(document)){
70+
vscode.commands.executeCommand(COMMANDS.RUN_TEST)
71+
}
72+
})
73+
}
7174
}
7275

7376
exportdefaulttutorialConfig

‎src/channel/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,17 @@ class Channel implements Channel {
309309
// run test following solution to update position
310310
vscode.commands.executeCommand(COMMANDS.RUN_TEST)
311311
return
312-
313312
case'EDITOR_SYNC_PROGRESS':
314313
// update progress when a level is deemed complete in the client
315314
awaitthis.context.progress.syncProgress(action.payload.progress)
316315
return
317316
case'EDITOR_OPEN_LOGS':
318317
constchannel=action.payload.channel
319318
awaitshowOutput(channel)
319+
return
320+
case'EDITOR_RUN_TEST':
321+
vscode.commands.executeCommand(COMMANDS.RUN_TEST)
322+
return
320323
default:
321324
logger(`No match for action type:${actionType}`)
322325
return

‎src/environment.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ if (!supportedOS.includes(OS_PLATFORM)) {
3535
}
3636

3737
exportconstTUTORIAL_URL:string|null=process.env.CODEROAD_TUTORIAL_URL||null
38+
39+
exportconstDISABLE_RUN_ON_SAVE=(process.env.CODEROAD_DISABLE_RUN_ON_SAVE||'').toLowerCase()==='true'

‎web-app/src/containers/Tutorial/components/Level.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Markdown from '../../../components/Markdown'
99
importProcessMessagesfrom'../../../components/ProcessMessages'
1010
importNuxTutorialfrom'../../../components/NewUserExperience/NuxTutorial'
1111
importStepfrom'./Step'
12+
import{DISPLAY_RUN_TEST_BUTTON}from'../../../environment'
1213

1314
conststyles={
1415
page:{
@@ -95,6 +96,7 @@ interface Props {
9596
processes:T.ProcessEvent[]
9697
testStatus:T.TestStatus|null
9798
onContinue():void
99+
onRunTest():void
98100
onLoadSolution():void
99101
onOpenLogs(channel:string):void
100102
}
@@ -107,6 +109,7 @@ const Level = ({
107109
index,
108110
status,
109111
onContinue,
112+
onRunTest,
110113
onLoadSolution,
111114
onOpenLogs,
112115
processes,
@@ -181,10 +184,16 @@ const Level = ({
181184
</div>
182185

183186
<divcss={styles.footer}>
184-
<span>
185-
{typeofindex==='number' ?`${index+1}. ` :''}
186-
{title}
187-
</span>
187+
{DISPLAY_RUN_TEST_BUTTON&&status!=='COMPLETE' ?(
188+
<Buttontype="primary"onClick={onRunTest}disabled={processes.length>0}>
189+
Run
190+
</Button>
191+
) :(
192+
<span>
193+
{typeofindex==='number' ?`${index+1}. ` :''}
194+
{title}
195+
</span>
196+
)}
188197
<span>
189198
{status==='COMPLETE'||!steps.length ?(
190199
<Buttontype="primary"onClick={onContinue}>

‎web-app/src/containers/Tutorial/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ const TutorialPage = (props: PageProps) => {
3232
props.send({type:'STEP_SOLUTION_LOAD'})
3333
}
3434

35+
constonRunTest=():void=>{
36+
props.send({type:'RUN_TEST'})
37+
}
38+
3539
constonOpenLogs=(channel:string):void=>{
3640
props.send({type:'OPEN_LOGS',payload:{ channel}})
3741
}
@@ -64,6 +68,7 @@ const TutorialPage = (props: PageProps) => {
6468
steps={steps}
6569
status={progress.levels[position.levelId] ?'COMPLETE' :'ACTIVE'}
6670
onContinue={onContinue}
71+
onRunTest={onRunTest}
6772
onLoadSolution={onLoadSolution}
6873
onOpenLogs={onOpenLogs}
6974
processes={processes}

‎web-app/src/environment.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ export const NODE_ENV: string = process.env.NODE_ENV || 'development'
1212
exportconstLOG:boolean=(process.env.REACT_APP_LOG||'').toLowerCase()==='true'
1313
exportconstTUTORIAL_LIST_URL:string=process.env.REACT_APP_TUTORIAL_LIST_URL||''
1414
exportconstSENTRY_DSN:string|null=process.env.REACT_APP_SENTRY_DSN||null
15+
16+
// config variables
17+
exportconstDISPLAY_RUN_TEST_BUTTON=(process.env.CODEROAD_DISPLAY_RUN_TEST_BUTTON||'').toLowerCase()==='true'

‎web-app/src/services/state/actions/editor.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,10 @@ export default (editorSend: any) => ({
101101
payload:{channel:event.payload.channel},
102102
})
103103
},
104+
runTest(context:T.MachineContext){
105+
editorSend({
106+
type:'EDITOR_RUN_TEST',
107+
payload:{position:context.position},
108+
})
109+
},
104110
})

‎web-app/src/services/state/machine.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ export const createMachine = (options: any) => {
177177
OPEN_LOGS:{
178178
actions:['editorOpenLogs'],
179179
},
180+
RUN_TEST:{
181+
actions:['runTest'],
182+
},
180183
},
181184
},
182185
TestRunning:{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp