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
34c2b0c0
Commit
34c2b0c0
authored
Sep 13, 2021
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete workspaces
parent
a23514ee
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
17 deletions
+34
-17
workspaceFileProvider.js
apps/remix-ide/src/app/files/workspaceFileProvider.js
+3
-2
workspace.ts
libs/remix-ui/workspace/src/lib/actions/workspace.ts
+1
-1
index.ts
libs/remix-ui/workspace/src/lib/contexts/index.ts
+4
-4
workspace.ts
libs/remix-ui/workspace/src/lib/reducers/workspace.ts
+7
-7
remix-ui-workspace.tsx
libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
+19
-3
No files found.
apps/remix-ide/src/app/files/workspaceFileProvider.js
View file @
34c2b0c0
...
...
@@ -13,6 +13,7 @@ class WorkspaceFileProvider extends FileProvider {
}
setWorkspace
(
workspace
)
{
if
(
!
workspace
)
return
workspace
=
workspace
.
replace
(
/^
\/
|
\/
$/g
,
''
)
// remove first and last slash
this
.
workspace
=
workspace
}
...
...
@@ -30,7 +31,7 @@ class WorkspaceFileProvider extends FileProvider {
}
removePrefix
(
path
)
{
if
(
!
this
.
workspace
)
this
.
createWorkspace
()
//
if (!this.workspace) this.createWorkspace()
path
=
path
.
replace
(
/^
\/
|
\/
$/g
,
''
)
// remove first and last slash
if
(
path
.
startsWith
(
this
.
workspacesPath
+
'/'
+
this
.
workspace
))
return
path
if
(
path
.
startsWith
(
this
.
workspace
))
return
path
.
replace
(
this
.
workspace
,
this
.
workspacesPath
+
'/'
+
this
.
workspace
)
...
...
@@ -76,7 +77,7 @@ class WorkspaceFileProvider extends FileProvider {
}
_normalizePath
(
path
)
{
if
(
!
this
.
workspace
)
this
.
createWorkspace
()
//
if (!this.workspace) this.createWorkspace()
return
path
.
replace
(
this
.
workspacesPath
+
'/'
+
this
.
workspace
+
'/'
,
''
)
}
...
...
libs/remix-ui/workspace/src/lib/actions/workspace.ts
View file @
34c2b0c0
...
...
@@ -290,7 +290,6 @@ const deleteWorkspaceFromProvider = async (workspaceName: string) => {
await
plugin
.
fileManager
.
closeAllFiles
()
plugin
.
fileProviders
.
browser
.
remove
(
workspacesPath
+
'/'
+
workspaceName
)
// switchToWorkspace(NO_WORKSPACE)
plugin
.
emit
(
'deleteWorkspace'
,
{
name
:
workspaceName
})
}
...
...
@@ -523,6 +522,7 @@ export const switchToWorkspace = (name: string) => async (dispatch: React.Dispat
plugin
.
emit
(
'setWorkspace'
,
{
name
:
LOCALHOST
,
isLocalhost
:
true
})
}
else
if
(
name
===
NO_WORKSPACE
)
{
plugin
.
fileProviders
.
workspace
.
clearWorkspace
()
dispatch
(
setCurrentWorkspace
(
null
))
}
else
{
plugin
.
fileManager
.
setMode
(
'browser'
)
const
isActive
=
await
plugin
.
call
(
'manager'
,
'isActive'
,
'remixd'
)
...
...
libs/remix-ui/workspace/src/lib/contexts/index.ts
View file @
34c2b0c0
...
...
@@ -10,8 +10,8 @@ export const FileSystemContext = createContext<{
dispatchRemoveInputField
:(
path
:
string
)
=>
Promise
<
void
>
,
dispatchCreateWorkspace
:
(
workspaceName
:
string
)
=>
Promise
<
void
>
,
toast
:
(
toasterMsg
:
string
)
=>
void
,
dispatchFetchWorkspaceDirectory
:
(
path
:
string
)
=>
void
,
dispatchSwitchToWorkspace
:
(
name
:
string
)
=>
void
,
dispatchRenameWorkspace
:
(
oldName
:
string
,
workspaceName
:
string
)
=>
void
,
dispatchDeleteWorkspace
:
(
workspaceName
:
string
)
=>
void
dispatchFetchWorkspaceDirectory
:
(
path
:
string
)
=>
Promise
<
void
>
,
dispatchSwitchToWorkspace
:
(
name
:
string
)
=>
Promise
<
void
>
,
dispatchRenameWorkspace
:
(
oldName
:
string
,
workspaceName
:
string
)
=>
Promise
<
void
>
,
dispatchDeleteWorkspace
:
(
workspaceName
:
string
)
=>
Promise
<
void
>
}
>
(
null
)
libs/remix-ui/workspace/src/lib/reducers/workspace.ts
View file @
34c2b0c0
...
...
@@ -68,13 +68,14 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
switch
(
action
.
type
)
{
case
'SET_CURRENT_WORKSPACE'
:
{
const
payload
=
action
.
payload
as
string
const
workspaces
=
state
.
browser
.
workspaces
.
includes
(
payload
)
?
state
.
browser
.
workspaces
:
[...
state
.
browser
.
workspaces
,
action
.
payload
]
return
{
...
state
,
browser
:
{
...
state
.
browser
,
currentWorkspace
:
payload
,
workspaces
:
state
.
browser
.
workspaces
.
includes
(
payload
)
?
state
.
browser
.
workspaces
:
[...
state
.
browser
.
workspaces
,
action
.
payload
]
workspaces
:
workspaces
.
filter
(
workspace
=>
workspace
)
}
}
}
...
...
@@ -86,7 +87,7 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
...
state
,
browser
:
{
...
state
.
browser
,
workspaces
:
payload
workspaces
:
payload
.
filter
(
workspace
=>
workspace
)
}
}
}
...
...
@@ -376,13 +377,14 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
case
'CREATE_WORKSPACE_SUCCESS'
:
{
const
payload
=
action
.
payload
as
string
const
workspaces
=
state
.
browser
.
workspaces
.
includes
(
payload
)
?
state
.
browser
.
workspaces
:
[...
state
.
browser
.
workspaces
,
action
.
payload
]
return
{
...
state
,
browser
:
{
...
state
.
browser
,
currentWorkspace
:
payload
,
workspaces
:
state
.
browser
.
workspaces
.
includes
(
payload
)
?
state
.
browser
.
workspaces
:
[...
state
.
browser
.
workspaces
,
action
.
payload
]
,
workspaces
:
workspaces
.
filter
(
workspace
=>
workspace
)
,
isRequesting
:
false
,
isSuccessful
:
true
,
error
:
null
...
...
@@ -404,7 +406,7 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
case
'RENAME_WORKSPACE'
:
{
const
payload
=
action
.
payload
as
{
oldName
:
string
,
workspaceName
:
string
}
const
workspaces
=
state
.
browser
.
workspaces
.
filter
(
name
=>
name
!==
payload
.
oldName
)
const
workspaces
=
state
.
browser
.
workspaces
.
filter
(
name
=>
name
&&
(
name
!==
payload
.
oldName
)
)
return
{
...
state
,
...
...
@@ -418,14 +420,12 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
case
'DELETE_WORKSPACE'
:
{
const
payload
=
action
.
payload
as
string
const
workspaces
=
state
.
browser
.
workspaces
.
filter
(
name
=>
name
!==
payload
)
const
currentWorkspace
=
state
.
browser
.
currentWorkspace
===
payload
?
workspaces
.
length
>
0
?
workspaces
[
0
]
:
''
:
state
.
browser
.
currentWorkspace
const
workspaces
=
state
.
browser
.
workspaces
.
filter
(
name
=>
name
&&
(
name
!==
payload
))
return
{
...
state
,
browser
:
{
...
state
.
browser
,
currentWorkspace
:
currentWorkspace
,
workspaces
:
workspaces
}
}
...
...
libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
View file @
34c2b0c0
...
...
@@ -26,7 +26,8 @@ export function Workspace (props: WorkspaceProps) {
useEffect
(()
=>
{
if
(
global
.
fs
.
mode
===
'browser'
)
{
setCurrentWorkspace
(
global
.
fs
.
browser
.
currentWorkspace
)
if
(
global
.
fs
.
browser
.
currentWorkspace
)
setCurrentWorkspace
(
global
.
fs
.
browser
.
currentWorkspace
)
else
setCurrentWorkspace
(
NO_WORKSPACE
)
global
.
dispatchFetchWorkspaceDirectory
(
global
.
fs
.
browser
.
currentWorkspace
)
}
else
if
(
global
.
fs
.
mode
===
'localhost'
)
{
// global.dispatchFetchWorkspaceDirectory('/')
...
...
@@ -34,6 +35,16 @@ export function Workspace (props: WorkspaceProps) {
}
},
[
global
.
fs
.
browser
.
currentWorkspace
,
global
.
fs
.
localhost
.
sharedFolder
,
global
.
fs
.
mode
])
useEffect
(()
=>
{
if
(
global
.
fs
.
browser
.
currentWorkspace
&&
!
global
.
fs
.
browser
.
workspaces
.
includes
(
global
.
fs
.
browser
.
currentWorkspace
))
{
if
(
global
.
fs
.
browser
.
workspaces
.
length
>
0
)
{
switchWorkspace
(
global
.
fs
.
browser
.
workspaces
[
global
.
fs
.
browser
.
workspaces
.
length
-
1
])
}
else
{
switchWorkspace
(
NO_WORKSPACE
)
}
}
},
[
global
.
fs
.
browser
.
workspaces
])
props
.
plugin
.
resetNewFile
=
()
=>
{
setState
(
prevState
=>
{
return
{
...
prevState
,
displayNewFile
:
!
state
.
displayNewFile
}
...
...
@@ -134,7 +145,12 @@ export function Workspace (props: WorkspaceProps) {
}
const
switchWorkspace
=
async
(
name
:
string
)
=>
{
global
.
dispatchSwitchToWorkspace
(
name
)
try
{
await
global
.
dispatchSwitchToWorkspace
(
name
)
}
catch
(
e
)
{
global
.
modal
(
'Switch To Workspace'
,
e
.
message
,
'OK'
,
()
=>
{},
''
)
console
.
error
(
e
)
}
}
const
createModalMessage
=
()
=>
{
...
...
@@ -212,7 +228,7 @@ export function Workspace (props: WorkspaceProps) {
<
div
className=
'remixui_fileExplorerTree'
>
<
div
>
<
div
className=
'pl-2 remixui_treeview'
data
-
id=
'filePanelFileExplorerTree'
>
{
global
.
fs
.
mode
===
'browser'
&&
{
(
global
.
fs
.
mode
===
'browser'
)
&&
(
currentWorkspace
!==
NO_WORKSPACE
)
&&
<
FileExplorer
name=
{
currentWorkspace
}
registry=
{
props
.
plugin
.
registry
}
...
...
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