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
c2c3f787
Commit
c2c3f787
authored
Apr 13, 2021
by
lianahus
Committed by
Liana Husikyan
Apr 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed
parent
a9a96b7e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
25 deletions
+32
-25
workspaceFileProvider.js
apps/remix-ide/src/app/files/workspaceFileProvider.js
+6
-6
file-panel.js
apps/remix-ide/src/app/panels/file-panel.js
+11
-10
remix-ui-workspace.tsx
libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
+15
-9
No files found.
apps/remix-ide/src/app/files/workspaceFileProvider.js
View file @
c2c3f787
...
@@ -30,7 +30,7 @@ class WorkspaceFileProvider extends FileProvider {
...
@@ -30,7 +30,7 @@ class WorkspaceFileProvider extends FileProvider {
}
}
removePrefix
(
path
)
{
removePrefix
(
path
)
{
if
(
!
this
.
workspace
)
this
.
create
Default
Workspace
()
if
(
!
this
.
workspace
)
this
.
createWorkspace
()
path
=
path
.
replace
(
/^
\/
|
\/
$/g
,
''
)
// remove first and last slash
path
=
path
.
replace
(
/^
\/
|
\/
$/g
,
''
)
// remove first and last slash
if
(
path
.
startsWith
(
this
.
workspacesPath
+
'/'
+
this
.
workspace
))
return
path
if
(
path
.
startsWith
(
this
.
workspacesPath
+
'/'
+
this
.
workspace
))
return
path
if
(
path
.
startsWith
(
this
.
workspace
))
return
this
.
workspacesPath
+
'/'
+
this
.
workspace
if
(
path
.
startsWith
(
this
.
workspace
))
return
this
.
workspacesPath
+
'/'
+
this
.
workspace
...
@@ -51,7 +51,7 @@ class WorkspaceFileProvider extends FileProvider {
...
@@ -51,7 +51,7 @@ class WorkspaceFileProvider extends FileProvider {
}
}
resolveDirectory
(
path
,
callback
)
{
resolveDirectory
(
path
,
callback
)
{
if
(
!
this
.
workspace
)
this
.
create
Default
Workspace
()
if
(
!
this
.
workspace
)
this
.
createWorkspace
()
super
.
resolveDirectory
(
path
,
(
error
,
files
)
=>
{
super
.
resolveDirectory
(
path
,
(
error
,
files
)
=>
{
if
(
error
)
return
callback
(
error
)
if
(
error
)
return
callback
(
error
)
const
unscoped
=
{}
const
unscoped
=
{}
...
@@ -76,13 +76,13 @@ class WorkspaceFileProvider extends FileProvider {
...
@@ -76,13 +76,13 @@ class WorkspaceFileProvider extends FileProvider {
}
}
_normalizePath
(
path
)
{
_normalizePath
(
path
)
{
if
(
!
this
.
workspace
)
this
.
create
Default
Workspace
()
if
(
!
this
.
workspace
)
this
.
createWorkspace
()
return
path
.
replace
(
this
.
workspacesPath
+
'/'
+
this
.
workspace
+
'/'
,
''
)
return
path
.
replace
(
this
.
workspacesPath
+
'/'
+
this
.
workspace
+
'/'
,
''
)
}
}
create
DefaultWorkspace
(
)
{
create
Workspace
(
name
)
{
this
.
workspace
=
'generated
_workspace'
if
(
!
name
)
name
=
'default
_workspace'
this
.
event
.
trigger
(
'create_workspace
_default'
,
[
this
.
workspac
e
])
this
.
event
.
trigger
(
'create_workspace
'
,
[
nam
e
])
}
}
}
}
...
...
apps/remix-ide/src/app/panels/file-panel.js
View file @
c2c3f787
...
@@ -175,12 +175,10 @@ module.exports = class Filepanel extends ViewPlugin {
...
@@ -175,12 +175,10 @@ module.exports = class Filepanel extends ViewPlugin {
}
}
async
createNewFile
()
{
async
createNewFile
()
{
if
(
!
this
.
workspaceExists
())
this
.
createWorkspace
(
'default_workspace'
)
return
await
this
.
request
.
createNewFile
()
return
await
this
.
request
.
createNewFile
()
}
}
async
uploadFile
(
event
)
{
async
uploadFile
(
event
)
{
if
(
!
this
.
workspaceExists
())
this
.
createWorkspace
(
'default_workspace'
)
return
await
this
.
request
.
uploadFile
(
event
)
return
await
this
.
request
.
uploadFile
(
event
)
}
}
...
@@ -204,14 +202,17 @@ module.exports = class Filepanel extends ViewPlugin {
...
@@ -204,14 +202,17 @@ module.exports = class Filepanel extends ViewPlugin {
if
(
!
workspaceName
)
throw
new
Error
(
'name cannot be empty'
)
if
(
!
workspaceName
)
throw
new
Error
(
'name cannot be empty'
)
if
(
checkSpecialChars
(
workspaceName
)
||
checkSlash
(
workspaceName
))
throw
new
Error
(
'special characters are not allowed'
)
if
(
checkSpecialChars
(
workspaceName
)
||
checkSlash
(
workspaceName
))
throw
new
Error
(
'special characters are not allowed'
)
if
(
await
this
.
workspaceExists
(
workspaceName
))
throw
new
Error
(
'workspace already exists'
)
if
(
await
this
.
workspaceExists
(
workspaceName
))
throw
new
Error
(
'workspace already exists'
)
const
browserProvider
=
this
.
_deps
.
fileProviders
.
browser
else
{
const
workspacesPath
=
this
.
_deps
.
fileProviders
.
workspace
.
workspacesPath
this
.
_deps
.
fileProviders
.
workspace
.
setWorkspace
(
workspaceName
)
await
this
.
processCreateWorkspace
(
workspaceName
)
const
browserProvider
=
this
.
_deps
.
fileProviders
.
browser
for
(
const
file
in
examples
)
{
const
workspacesPath
=
this
.
_deps
.
fileProviders
.
workspace
.
workspacesPath
try
{
await
this
.
processCreateWorkspace
(
workspaceName
)
await
browserProvider
.
set
(
'browser/'
+
workspacesPath
+
'/'
+
workspaceName
+
'/'
+
examples
[
file
].
name
,
examples
[
file
].
content
)
for
(
const
file
in
examples
)
{
}
catch
(
error
)
{
try
{
console
.
error
(
error
)
await
browserProvider
.
set
(
'browser/'
+
workspacesPath
+
'/'
+
workspaceName
+
'/'
+
examples
[
file
].
name
,
examples
[
file
].
content
)
}
catch
(
error
)
{
console
.
error
(
error
)
}
}
}
}
}
}
}
...
...
libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
View file @
c2c3f787
...
@@ -50,10 +50,13 @@ export const Workspace = (props: WorkspaceProps) => {
...
@@ -50,10 +50,13 @@ export const Workspace = (props: WorkspaceProps) => {
}
}
props
.
request
.
createNewFile
=
()
=>
{
props
.
request
.
createNewFile
=
()
=>
{
if
(
!
state
.
workspaces
.
length
)
createNewWorkspace
(
'default_workspace'
)
props
.
plugin
.
resetNewFile
()
props
.
plugin
.
resetNewFile
()
}
}
props
.
request
.
uploadFile
=
(
target
)
=>
{
props
.
request
.
uploadFile
=
(
target
)
=>
{
if
(
!
state
.
workspaces
.
length
)
createNewWorkspace
(
'default_workspace'
)
setState
(
prevState
=>
{
setState
(
prevState
=>
{
return
{
...
prevState
,
uploadFileEvent
:
target
}
return
{
...
prevState
,
uploadFileEvent
:
target
}
})
})
...
@@ -102,15 +105,8 @@ export const Workspace = (props: WorkspaceProps) => {
...
@@ -102,15 +105,8 @@ export const Workspace = (props: WorkspaceProps) => {
remixdExplorer
.
loading
()
remixdExplorer
.
loading
()
})
})
props
.
workspace
.
event
.
register
(
'create_workspace_default'
,
async
(
workspaceName
)
=>
{
props
.
workspace
.
event
.
register
(
'create_workspace'
,
(
name
)
=>
{
try
{
createNewWorkspace
(
name
)
await
props
.
createWorkspace
(
workspaceName
)
await
setWorkspace
(
workspaceName
)
toast
(
'New default workspace has been created.'
)
}
catch
(
e
)
{
modalMessage
(
'Create Default Workspace'
,
e
.
message
)
console
.
error
(
e
)
}
})
})
if
(
props
.
initialWorkspace
)
{
if
(
props
.
initialWorkspace
)
{
...
@@ -121,6 +117,16 @@ export const Workspace = (props: WorkspaceProps) => {
...
@@ -121,6 +117,16 @@ export const Workspace = (props: WorkspaceProps) => {
}
}
},
[])
},
[])
const
createNewWorkspace
=
async
(
workspaceName
)
=>
{
try
{
await
props
.
createWorkspace
(
workspaceName
)
await
setWorkspace
(
workspaceName
)
toast
(
'New default workspace has been created.'
)
}
catch
(
e
)
{
modalMessage
(
'Create Default Workspace'
,
e
.
message
)
console
.
error
(
e
)
}
}
const
[
state
,
setState
]
=
useState
({
const
[
state
,
setState
]
=
useState
({
workspaces
:
[],
workspaces
:
[],
reset
:
false
,
reset
:
false
,
...
...
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