Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
67146f1f
Commit
67146f1f
authored
Mar 01, 2021
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move createWorkspace to filePanel.js
parent
22ee1cf6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
18 deletions
+35
-18
fileManager.js
apps/remix-ide/src/app/files/fileManager.js
+6
-0
file-panel.js
apps/remix-ide/src/app/panels/file-panel.js
+13
-9
remix-ui-workspace.tsx
libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
+16
-9
No files found.
apps/remix-ide/src/app/files/fileManager.js
View file @
67146f1f
...
@@ -589,6 +589,12 @@ class FileManager extends Plugin {
...
@@ -589,6 +589,12 @@ class FileManager extends Plugin {
if
(
!
this
.
exists
(
workspaceRootPath
))
await
this
.
mkdir
(
workspaceRootPath
)
if
(
!
this
.
exists
(
workspaceRootPath
))
await
this
.
mkdir
(
workspaceRootPath
)
if
(
!
this
.
exists
(
workspacePath
))
await
this
.
mkdir
(
workspacePath
)
if
(
!
this
.
exists
(
workspacePath
))
await
this
.
mkdir
(
workspacePath
)
}
}
async
workspaceExists
(
name
)
{
const
workspaceProvider
=
this
.
_deps
.
filesProviders
.
workspace
const
workspacePath
=
'browser/'
+
workspaceProvider
.
workspacesPath
+
'/'
+
name
return
this
.
exists
(
workspacePath
)
}
}
}
module
.
exports
=
FileManager
module
.
exports
=
FileManager
apps/remix-ide/src/app/panels/file-panel.js
View file @
67146f1f
...
@@ -72,6 +72,7 @@ module.exports = class Filepanel extends ViewPlugin {
...
@@ -72,6 +72,7 @@ module.exports = class Filepanel extends ViewPlugin {
renderComponent
()
{
renderComponent
()
{
ReactDOM
.
render
(
ReactDOM
.
render
(
<
Workspace
<
Workspace
createWorkspace
=
{
this
.
createWorkspace
.
bind
(
this
)}
setWorkspace
=
{
this
.
setWorkspace
.
bind
(
this
)}
setWorkspace
=
{
this
.
setWorkspace
.
bind
(
this
)}
workspaceRenamed
=
{
this
.
workspaceRenamed
.
bind
(
this
)}
workspaceRenamed
=
{
this
.
workspaceRenamed
.
bind
(
this
)}
workspaceDeleted
=
{
this
.
workspaceDeleted
.
bind
(
this
)}
workspaceDeleted
=
{
this
.
workspaceDeleted
.
bind
(
this
)}
...
@@ -153,13 +154,7 @@ module.exports = class Filepanel extends ViewPlugin {
...
@@ -153,13 +154,7 @@ module.exports = class Filepanel extends ViewPlugin {
this
.
_deps
.
fileProviders
.
browser
.
resolveDirectory
(
'/'
,
async
(
error
,
filesList
)
=>
{
this
.
_deps
.
fileProviders
.
browser
.
resolveDirectory
(
'/'
,
async
(
error
,
filesList
)
=>
{
if
(
error
)
console
.
error
(
error
)
if
(
error
)
console
.
error
(
error
)
if
(
Object
.
keys
(
filesList
).
length
===
0
)
{
if
(
Object
.
keys
(
filesList
).
length
===
0
)
{
for
(
const
file
in
examples
)
{
await
this
.
createWorkspace
(
'default_workspace'
)
try
{
await
this
.
_deps
.
fileManager
.
writeFile
(
'browser/'
+
workspacesPath
+
'/default_workspace/'
+
examples
[
file
].
name
,
examples
[
file
].
content
)
}
catch
(
error
)
{
console
.
error
(
error
)
}
}
}
}
this
.
getWorkspaces
()
this
.
getWorkspaces
()
})
})
...
@@ -173,8 +168,17 @@ module.exports = class Filepanel extends ViewPlugin {
...
@@ -173,8 +168,17 @@ module.exports = class Filepanel extends ViewPlugin {
return
await
this
.
request
.
uploadFile
()
return
await
this
.
request
.
uploadFile
()
}
}
async
createWorkspace
()
{
async
createWorkspace
(
workspaceName
)
{
return
await
this
.
request
.
createWorkspace
()
if
(
await
this
.
_deps
.
fileManager
.
workspaceExists
(
workspaceName
))
throw
new
Error
(
'workspace already exists'
)
const
workspacesPath
=
this
.
_deps
.
fileProviders
.
workspace
.
workspacesPath
await
this
.
_deps
.
fileManager
.
createWorkspace
(
workspaceName
)
for
(
const
file
in
examples
)
{
try
{
await
this
.
_deps
.
fileManager
.
writeFile
(
'browser/'
+
workspacesPath
+
'/'
+
workspaceName
+
'/'
+
examples
[
file
].
name
,
examples
[
file
].
content
)
}
catch
(
error
)
{
console
.
error
(
error
)
}
}
}
}
/** these are called by the react component, action is already finished whent it's called */
/** these are called by the react component, action is already finished whent it's called */
...
...
libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
View file @
67146f1f
...
@@ -9,6 +9,7 @@ type CodeExamples = {
...
@@ -9,6 +9,7 @@ type CodeExamples = {
/* eslint-disable-next-line */
/* eslint-disable-next-line */
export
interface
WorkspaceProps
{
export
interface
WorkspaceProps
{
setWorkspace
:
({
name
:
string
,
isLocalhost
:
boolean
})
=>
void
,
setWorkspace
:
({
name
:
string
,
isLocalhost
:
boolean
})
=>
void
,
createWorkspace
:
(
name
:
string
)
=>
void
,
workspaceRenamed
:
({
name
:
string
})
=>
void
,
workspaceRenamed
:
({
name
:
string
})
=>
void
,
workspaceCreated
:
({
name
:
string
})
=>
void
,
workspaceCreated
:
({
name
:
string
})
=>
void
,
workspaceDeleted
:
({
name
:
string
})
=>
void
,
workspaceDeleted
:
({
name
:
string
})
=>
void
,
...
@@ -136,6 +137,16 @@ export const Workspace = (props: WorkspaceProps) => {
...
@@ -136,6 +137,16 @@ export const Workspace = (props: WorkspaceProps) => {
})
})
}
}
const
modalMessage
=
(
title
:
string
,
body
:
string
)
=>
{
modal
(
title
,
body
,
{
label
:
'OK'
,
fn
:
()
=>
{}
},
{
label
:
null
,
fn
:
null
})
}
const
workspaceRenameInput
=
useRef
()
const
workspaceRenameInput
=
useRef
()
const
workspaceCreateInput
=
useRef
()
const
workspaceCreateInput
=
useRef
()
...
@@ -153,18 +164,14 @@ export const Workspace = (props: WorkspaceProps) => {
...
@@ -153,18 +164,14 @@ export const Workspace = (props: WorkspaceProps) => {
if
(
workspaceCreateInput
.
current
===
undefined
)
return
if
(
workspaceCreateInput
.
current
===
undefined
)
return
// @ts-ignore: Object is possibly 'null'.
// @ts-ignore: Object is possibly 'null'.
const
workspaceName
=
workspaceCreateInput
.
current
.
value
const
workspaceName
=
workspaceCreateInput
.
current
.
value
const
workspacesPath
=
props
.
workspace
.
workspacesPath
props
.
browser
.
createDir
(
workspacesPath
+
'/'
+
workspaceName
,
async
()
=>
{
await
setWorkspace
(
workspaceName
)
for
(
const
file
in
props
.
examples
)
{
try
{
try
{
await
props
.
fileManager
.
writeFile
(
props
.
examples
[
file
].
name
,
props
.
examples
[
file
].
content
)
await
props
.
createWorkspace
(
workspaceName
)
}
catch
(
error
)
{
}
catch
(
e
)
{
console
.
error
(
error
)
modalMessage
(
'Workspace Creation'
,
e
.
message
)
}
console
.
error
(
e
)
}
}
}
)
await
setWorkspace
(
workspaceName
)
}
}
const
onFinishDeleteWorkspace
=
async
()
=>
{
const
onFinishDeleteWorkspace
=
async
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment