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

Commit828ed43

Browse files
authored
Merge pull request#150 from ShMcK/feature/workspace-empty
Feature/workspace empty
2 parents4992b32 +981f702 commit828ed43

File tree

9 files changed

+118
-4
lines changed

9 files changed

+118
-4
lines changed

‎src/channel/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import tutorialConfig from '../actions/tutorialConfig'
88
import{COMMANDS}from'../editor/commands'
99
importloggerfrom'../services/logger'
1010
importContextfrom'./context'
11+
import{openWorkspace,checkWorkspaceEmpty}from'../services/workspace'
1112

1213
interfaceChannel{
1314
receive(action:T.Action):Promise<void>
@@ -108,6 +109,18 @@ class Channel implements Channel {
108109
// update the current stepId on startup
109110
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP,action.payload)
110111
return
112+
case'EDITOR_CHECK_WORKSPACE':
113+
constisEmptyWorkspace=awaitcheckWorkspaceEmpty(this.workspaceRoot.uri.path)
114+
if(isEmptyWorkspace){
115+
this.send({type:'IS_EMPTY_WORKSPACE'})
116+
}else{
117+
this.send({type:'NOT_EMPTY_WORKSPACE'})
118+
}
119+
return
120+
case'EDITOR_REQUEST_WORKSPACE':
121+
console.log('request workspace')
122+
openWorkspace()
123+
return
111124
// load step actions (git commits, commands, open files)
112125
case'SETUP_ACTIONS':
113126
awaitvscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP,action.payload)

‎src/services/testRunner/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
importnodefrom'../../services/node'
2-
importloggerfrom'../../services/logger'
1+
importnodefrom'../node'
2+
importloggerfrom'../logger'
33
importparserfrom'./parser'
44
import{debounce,throttle}from'./throttle'
55
importonErrorfrom'../sentry/onError'

‎src/services/workspace/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import*asvscodefrom'vscode'
2+
import*asfsfrom'fs'
3+
4+
exportconstopenWorkspace=()=>{
5+
constopenInNewWindow=false
6+
vscode.commands.executeCommand('vscode.openFolder',undefined,openInNewWindow)
7+
}
8+
9+
exportconstcheckWorkspaceEmpty=async(dirname:string)=>{
10+
letfiles
11+
try{
12+
files=awaitfs.promises.readdir(dirname)
13+
}catch(error){
14+
thrownewError('Failed to check workspace')
15+
}
16+
returnfiles.length===0
17+
}

‎typings/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export interface MachineStateSchema {
7373
Error:{}
7474
LoadStoredTutorial:{}
7575
Start:{}
76+
CheckEmptyWorkspace:{}
77+
NonEmptyWorkspace:{}
7678
SelectTutorial:{}
7779
LoadTutorialSummary:{}
7880
Summary:{}

‎web-app/src/Routes.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import SelectTutorialPage from './containers/SelectTutorial'
77
importOverviewPagefrom'./containers/Overview'
88
importCompletedPagefrom'./containers/Tutorial/CompletedPage'
99
importLevelSummaryPagefrom'./containers/Tutorial/LevelPage'
10+
importSelectEmptyWorkspacefrom'./containers/Check/SelectWorkspace'
1011

1112
constRoutes=()=>{
1213
const{ context, send, Router, Route}=useRouter()
1314
return(
1415
<Workspace>
1516
<Router>
1617
{/* Setup */}
17-
<Routepath={['Setup.Startup','Setup.Authenticate','Setup.LoadStoredTutorial']}>
18+
<Routepath={['Setup.Startup','Setup.Authenticate','Setup.LoadStoredTutorial','Setup.CheckEmptyWorkspace']}>
1819
<LoadingPagetext="Launching..."context={context}/>
1920
</Route>
2021
<Routepath="Setup.Start">
@@ -23,6 +24,9 @@ const Routes = () => {
2324
<Routepath={['Setup.LoadTutorialSummary','Setup.LoadTutorialData','Setup.SetupNewTutorial']}>
2425
<LoadingPagetext="Loading Tutorial..."context={context}/>
2526
</Route>
27+
<Routepath={['Setup.NonEmptyWorkspace','Setup.RequestEmptyWorkspace']}>
28+
<SelectEmptyWorkspacesend={send}/>
29+
</Route>
2630
<Routepath="Setup.Error">
2731
<LoadingPagetext="Error"context={context}/>
2832
</Route>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import*asReactfrom'react'
2+
import*asTfrom'typings'
3+
import{css,jsx}from'@emotion/core'
4+
importButtonfrom'../../components/Button'
5+
6+
conststyles={
7+
container:{
8+
padding:'1rem',
9+
},
10+
}
11+
12+
typeProps={
13+
send:(action:T.Action)=>void
14+
}
15+
16+
constSelectWorkspace=(props:Props)=>{
17+
constonOpenWorkspace=()=>props.send({type:'REQUEST_WORKSPACE'})
18+
return(
19+
<divcss={styles.container}>
20+
<h3>Select An Empty VSCode Workspace</h3>
21+
<p>Start a project in an empty folder.</p>
22+
<p>Once selected, the extension will close and need to be re-started.</p>
23+
<br/>
24+
<Buttontype="secondary"onClick={onOpenWorkspace}>
25+
Open a Workspace
26+
</Button>
27+
</div>
28+
)
29+
}
30+
31+
exportdefaultSelectWorkspace

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,14 @@ export default (editorSend: any) => ({
7070
clearStorage():void{
7171
editorSend({type:'TUTORIAL_CLEAR'})
7272
},
73+
checkEmptyWorkspace(){
74+
editorSend({
75+
type:'EDITOR_CHECK_WORKSPACE',
76+
})
77+
},
78+
requestWorkspaceSelect(){
79+
editorSend({
80+
type:'EDITOR_REQUEST_WORKSPACE',
81+
})
82+
},
7383
})

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,29 @@ export const createMachine = (options: any) => {
6868
},
6969
Start:{
7070
on:{
71-
NEW_TUTORIAL:'SelectTutorial',
71+
NEW_TUTORIAL:'CheckEmptyWorkspace',
7272
CONTINUE_TUTORIAL:{
7373
target:'#tutorial-level',
7474
actions:['continueConfig'],
7575
},
7676
},
7777
},
78+
CheckEmptyWorkspace:{
79+
onEntry:['checkEmptyWorkspace'],
80+
on:{
81+
IS_EMPTY_WORKSPACE:'SelectTutorial',
82+
NOT_EMPTY_WORKSPACE:'NonEmptyWorkspace',
83+
},
84+
},
85+
NonEmptyWorkspace:{
86+
on:{
87+
REQUEST_WORKSPACE:{
88+
target:'NonEmptyWorkspace',
89+
actions:'requestWorkspaceSelect',
90+
},
91+
WORKSPACE_LOADED:'CheckEmptyWorkspace',
92+
},
93+
},
7894
SelectTutorial:{
7995
onEntry:['clearStorage'],
8096
id:'select-new-tutorial',

‎web-app/stories/Check.stories.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import{storiesOf}from'@storybook/react'
2+
import{action}from'@storybook/addon-actions'
3+
importReactfrom'react'
4+
import{css,jsx}from'@emotion/core'
5+
importSelectWorkspacefrom'../src/containers/Check/SelectWorkspace'
6+
importSideBarDecoratorfrom'./utils/SideBarDecorator'
7+
8+
conststyles={
9+
container:{
10+
display:'flex'as'flex',
11+
flexDirection:'column'as'column',
12+
},
13+
}
14+
15+
storiesOf('Check',module)
16+
.addDecorator(SideBarDecorator)
17+
.add('Select Workspace',()=>(
18+
<divcss={styles.container}>
19+
<SelectWorkspacesend={action('send')}/>
20+
</div>
21+
))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp