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
c34ce4b4
Commit
c34ce4b4
authored
Apr 13, 2021
by
lianahus
Committed by
Liana Husikyan
Apr 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
createing default workspace
parent
d0b7b58d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
5 deletions
+31
-5
fileManager.js
apps/remix-ide/src/app/files/fileManager.js
+0
-1
workspaceFileProvider.js
apps/remix-ide/src/app/files/workspaceFileProvider.js
+10
-3
remix-ui-workspace.tsx
libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
+21
-1
No files found.
apps/remix-ide/src/app/files/fileManager.js
View file @
c34ce4b4
...
...
@@ -564,7 +564,6 @@ class FileManager extends Plugin {
return
this
.
_deps
.
filesProviders
.
browser
}
const
provider
=
this
.
_deps
.
filesProviders
.
workspace
if
(
!
provider
.
isReady
())
throw
createError
({
code
:
'ECONNRESET'
,
message
:
'No workspace has been opened.'
})
return
this
.
_deps
.
filesProviders
.
workspace
}
...
...
apps/remix-ide/src/app/files/workspaceFileProvider.js
View file @
c34ce4b4
'use strict'
const
EventManager
=
require
(
'../../lib/events'
)
const
FileProvider
=
require
(
'./fileProvider'
)
const
pathModule
=
require
(
'path'
)
...
...
@@ -8,6 +9,7 @@ class WorkspaceFileProvider extends FileProvider {
super
(
''
)
this
.
workspacesPath
=
'.workspaces'
this
.
workspace
=
null
this
.
event
=
new
EventManager
()
}
setWorkspace
(
workspace
)
{
...
...
@@ -28,7 +30,7 @@ class WorkspaceFileProvider extends FileProvider {
}
removePrefix
(
path
)
{
if
(
!
this
.
workspace
)
th
row
new
Error
(
'No workspace has been opened.'
)
if
(
!
this
.
workspace
)
th
is
.
createDefaultWorkspace
(
)
path
=
path
.
replace
(
/^
\/
|
\/
$/g
,
''
)
// remove first and last slash
if
(
path
.
startsWith
(
this
.
workspacesPath
+
'/'
+
this
.
workspace
))
return
path
if
(
path
.
startsWith
(
this
.
workspace
))
return
this
.
workspacesPath
+
'/'
+
this
.
workspace
...
...
@@ -49,7 +51,7 @@ class WorkspaceFileProvider extends FileProvider {
}
resolveDirectory
(
path
,
callback
)
{
if
(
!
this
.
workspace
)
th
row
new
Error
(
'No workspace has been opened.'
)
if
(
!
this
.
workspace
)
th
is
.
createDefaultWorkspace
(
)
super
.
resolveDirectory
(
path
,
(
error
,
files
)
=>
{
if
(
error
)
return
callback
(
error
)
const
unscoped
=
{}
...
...
@@ -74,9 +76,14 @@ class WorkspaceFileProvider extends FileProvider {
}
_normalizePath
(
path
)
{
if
(
!
this
.
workspace
)
th
row
new
Error
(
'No workspace has been opened.'
)
if
(
!
this
.
workspace
)
th
is
.
createDefaultWorkspace
(
)
return
path
.
replace
(
this
.
workspacesPath
+
'/'
+
this
.
workspace
+
'/'
,
''
)
}
createDefaultWorkspace
()
{
this
.
workspace
=
'workspace_default'
this
.
event
.
trigger
(
'create_workspace_default'
,
[
this
.
workspace
])
}
}
module
.
exports
=
WorkspaceFileProvider
libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
View file @
c34ce4b4
...
...
@@ -2,6 +2,7 @@ import React, { useState, useEffect, useRef } from 'react' // eslint-disable-lin
import
{
FileExplorer
}
from
'@remix-ui/file-explorer'
// eslint-disable-line
import
'./remix-ui-workspace.css'
import
{
ModalDialog
}
from
'@remix-ui/modal-dialog'
// eslint-disable-line
import
{
Toaster
}
from
'@remix-ui/toaster'
/* eslint-disable-next-line */
export
interface
WorkspaceProps
{
...
...
@@ -101,6 +102,17 @@ export const Workspace = (props: WorkspaceProps) => {
remixdExplorer
.
loading
()
})
props
.
workspace
.
event
.
register
(
'create_workspace_default'
,
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
)
}
})
if
(
props
.
initialWorkspace
)
{
props
.
workspace
.
setWorkspace
(
props
.
initialWorkspace
)
setState
(
prevState
=>
{
...
...
@@ -131,9 +143,16 @@ export const Workspace = (props: WorkspaceProps) => {
},
handleHide
:
null
},
loadingLocalhost
:
false
loadingLocalhost
:
false
,
toasterMsg
:
''
,
})
const
toast
=
(
message
:
string
)
=>
{
setState
(
prevState
=>
{
return
{
...
prevState
,
toasterMsg
:
message
}
})
}
/* workspace creation, renaming and deletion */
const
renameCurrentWorkspace
=
()
=>
{
...
...
@@ -312,6 +331,7 @@ export const Workspace = (props: WorkspaceProps) => {
handleHide=
{
handleHideModal
}
>
{
(
typeof
state
.
modal
.
message
!==
'string'
)
&&
state
.
modal
.
message
}
</
ModalDialog
>
<
Toaster
message=
{
state
.
toasterMsg
}
/>
<
div
className=
'remixui_fileexplorer'
onClick=
{
()
=>
resetFocus
(
true
)
}
>
<
div
>
<
header
>
...
...
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