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
c5057116
Commit
c5057116
authored
Oct 16, 2021
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update plugin with workspaces and current selected workspace
parent
2adda600
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
35 deletions
+43
-35
file-panel.js
apps/remix-ide/src/app/panels/file-panel.js
+1
-0
index.ts
libs/remix-ui/workspace/src/lib/actions/index.ts
+7
-28
payload.ts
libs/remix-ui/workspace/src/lib/actions/payload.ts
+6
-3
workspace.ts
libs/remix-ui/workspace/src/lib/actions/workspace.ts
+29
-4
No files found.
apps/remix-ide/src/app/panels/file-panel.js
View file @
c5057116
...
...
@@ -143,6 +143,7 @@ module.exports = class Filepanel extends ViewPlugin {
}
setWorkspace
(
workspace
)
{
console
.
log
(
'workspace: '
,
workspace
)
const
workspaceProvider
=
this
.
fileProviders
.
workspace
this
.
currentWorkspaceMetadata
=
{
name
:
workspace
.
name
,
isLocalhost
:
workspace
.
isLocalhost
,
absolutePath
:
`
${
workspaceProvider
.
workspacesPath
}
/
${
workspace
.
name
}
`
}
...
...
libs/remix-ui/workspace/src/lib/actions/index.ts
View file @
c5057116
...
...
@@ -4,7 +4,7 @@ import Gists from 'gists'
import
{
customAction
}
from
'@remixproject/plugin-api/lib/file-system/file-panel/type'
import
{
displayNotification
,
displayPopUp
,
fetchDirectoryError
,
fetchDirectoryRequest
,
fetchDirectorySuccess
,
focusElement
,
hidePopUp
,
removeInputFieldSuccess
,
setCurrentWorkspace
,
setDeleteWorkspace
,
setExpandPath
,
setMode
,
setWorkspaces
}
from
'./payload'
import
{
listenOnPluginEvents
,
listenOnProviderEvents
}
from
'./events'
import
{
createWorkspaceTemplate
,
loadWorkspacePreset
,
setPlugin
}
from
'./workspace'
import
{
createWorkspaceTemplate
,
getWorkspaces
,
loadWorkspacePreset
,
setPlugin
}
from
'./workspace'
export
*
from
'./events'
export
*
from
'./workspace'
...
...
@@ -28,20 +28,20 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
if
(
params
.
gist
)
{
await
createWorkspaceTemplate
(
'gist-sample'
,
'gist-template'
)
await
loadWorkspacePreset
(
'gist-template'
)
dispatch
(
setCurrentWorkspace
(
'gist-sample'
))
dispatch
(
setCurrentWorkspace
(
'gist-sample'
,
plugin
))
}
else
if
(
params
.
code
||
params
.
url
)
{
await
createWorkspaceTemplate
(
'code-sample'
,
'code-template'
)
await
loadWorkspacePreset
(
'code-template'
)
dispatch
(
setCurrentWorkspace
(
'code-sample'
))
dispatch
(
setCurrentWorkspace
(
'code-sample'
,
plugin
))
}
else
{
if
(
workspaces
.
length
===
0
)
{
await
createWorkspaceTemplate
(
'default_workspace'
,
'default-template'
)
await
loadWorkspacePreset
(
'default-template'
)
dispatch
(
setCurrentWorkspace
(
'default_workspace'
))
dispatch
(
setCurrentWorkspace
(
'default_workspace'
,
plugin
))
}
else
{
if
(
workspaces
.
length
>
0
)
{
workspaceProvider
.
setWorkspace
(
workspaces
[
workspaces
.
length
-
1
])
dispatch
(
setCurrentWorkspace
(
workspaces
[
workspaces
.
length
-
1
]))
dispatch
(
setCurrentWorkspace
(
workspaces
[
workspaces
.
length
-
1
]
,
plugin
))
}
}
}
...
...
@@ -50,6 +50,7 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
listenOnProviderEvents
(
workspaceProvider
)(
dispatch
)
listenOnProviderEvents
(
localhostProvider
)(
dispatch
)
dispatch
(
setMode
(
'browser'
))
plugin
.
setWorkspaces
(
await
getWorkspaces
())
plugin
.
emit
(
'workspaceInitializationCompleted'
)
}
}
...
...
@@ -259,29 +260,7 @@ const deleteWorkspaceFromProvider = async (workspaceName: string) => {
await
plugin
.
fileManager
.
closeAllFiles
()
plugin
.
fileProviders
.
browser
.
remove
(
workspacesPath
+
'/'
+
workspaceName
)
plugin
.
emit
(
'deleteWorkspace'
,
{
name
:
workspaceName
})
}
const
getWorkspaces
=
async
():
Promise
<
string
[]
>
|
undefined
=>
{
try
{
const
workspaces
:
string
[]
=
await
new
Promise
((
resolve
,
reject
)
=>
{
const
workspacesPath
=
plugin
.
fileProviders
.
workspace
.
workspacesPath
plugin
.
fileProviders
.
browser
.
resolveDirectory
(
'/'
+
workspacesPath
,
(
error
,
items
)
=>
{
if
(
error
)
{
console
.
error
(
error
)
return
reject
(
error
)
}
resolve
(
Object
.
keys
(
items
)
.
filter
((
item
)
=>
items
[
item
].
isDirectory
)
.
map
((
folder
)
=>
folder
.
replace
(
workspacesPath
+
'/'
,
''
)))
})
})
plugin
.
setWorkspaces
(
workspaces
)
return
workspaces
}
catch
(
e
)
{
console
.
log
(
e
)
}
plugin
.
setWorkspaces
(
await
getWorkspaces
())
}
const
packageGistFiles
=
(
directory
)
=>
{
...
...
libs/remix-ui/workspace/src/lib/actions/payload.ts
View file @
c5057116
import
{
action
}
from
'../types'
export
const
setCurrentWorkspace
=
(
workspace
:
string
)
=>
{
export
const
setCurrentWorkspace
=
(
workspace
:
string
,
plugin
?)
=>
{
plugin
&&
plugin
.
setWorkspace
(
workspace
)
return
{
type
:
'SET_CURRENT_WORKSPACE'
,
payload
:
workspace
...
...
@@ -125,7 +126,8 @@ export const createWorkspaceRequest = (promise: Promise<any>) => {
}
}
export
const
createWorkspaceSuccess
=
(
workspaceName
:
string
)
=>
{
export
const
createWorkspaceSuccess
=
(
workspaceName
:
string
,
plugin
?)
=>
{
plugin
&&
plugin
.
setWorkspace
(
workspaceName
)
return
{
type
:
'CREATE_WORKSPACE_SUCCESS'
,
payload
:
workspaceName
...
...
@@ -153,7 +155,8 @@ export const fetchWorkspaceDirectorySuccess = (path: string, fileTree) => {
}
}
export
const
setRenameWorkspace
=
(
oldName
:
string
,
workspaceName
:
string
)
=>
{
export
const
setRenameWorkspace
=
(
oldName
:
string
,
workspaceName
:
string
,
plugin
?)
=>
{
plugin
&&
plugin
.
setWorkspace
(
workspaceName
)
return
{
type
:
'RENAME_WORKSPACE'
,
payload
:
{
oldName
,
workspaceName
}
...
...
libs/remix-ui/workspace/src/lib/actions/workspace.ts
View file @
c5057116
...
...
@@ -45,9 +45,10 @@ export const createWorkspace = async (workspaceName: string, isEmpty = false, cb
dispatch
(
createWorkspaceRequest
(
promise
))
promise
.
then
(
async
()
=>
{
dispatch
(
createWorkspaceSuccess
(
workspaceName
))
dispatch
(
createWorkspaceSuccess
(
workspaceName
,
plugin
))
if
(
!
isEmpty
)
await
loadWorkspacePreset
(
'default-template'
)
plugin
.
emit
(
'setWorkspace'
,
{
name
:
workspaceName
,
isLocalhost
:
false
})
plugin
.
setWorkspaces
(
await
getWorkspaces
())
cb
&&
cb
(
null
,
workspaceName
)
}).
catch
((
error
)
=>
{
dispatch
(
createWorkspaceError
({
error
}))
...
...
@@ -172,7 +173,7 @@ export const fetchWorkspaceDirectory = async (path: string) => {
export
const
renameWorkspace
=
async
(
oldName
:
string
,
workspaceName
:
string
)
=>
{
await
renameWorkspaceFromProvider
(
oldName
,
workspaceName
)
await
dispatch
(
setRenameWorkspace
(
oldName
,
workspaceName
))
await
dispatch
(
setRenameWorkspace
(
oldName
,
workspaceName
,
plugin
))
}
export
const
renameWorkspaceFromProvider
=
async
(
oldName
:
string
,
workspaceName
:
string
)
=>
{
...
...
@@ -185,6 +186,7 @@ export const renameWorkspaceFromProvider = async (oldName: string, workspaceName
browserProvider
.
rename
(
'browser/'
+
workspacesPath
+
'/'
+
oldName
,
'browser/'
+
workspacesPath
+
'/'
+
workspaceName
,
true
)
workspaceProvider
.
setWorkspace
(
workspaceName
)
plugin
.
emit
(
'renameWorkspace'
,
{
name
:
workspaceName
})
plugin
.
setWorkspaces
(
await
getWorkspaces
())
}
export
const
switchToWorkspace
=
async
(
name
:
string
)
=>
{
...
...
@@ -197,14 +199,14 @@ export const switchToWorkspace = async (name: string) => {
plugin
.
emit
(
'setWorkspace'
,
{
name
:
LOCALHOST
,
isLocalhost
:
true
})
}
else
if
(
name
===
NO_WORKSPACE
)
{
plugin
.
fileProviders
.
workspace
.
clearWorkspace
()
dispatch
(
setCurrentWorkspace
(
null
))
dispatch
(
setCurrentWorkspace
(
null
,
plugin
))
}
else
{
const
isActive
=
await
plugin
.
call
(
'manager'
,
'isActive'
,
'remixd'
)
if
(
isActive
)
plugin
.
call
(
'manager'
,
'deactivatePlugin'
,
'remixd'
)
await
plugin
.
fileProviders
.
workspace
.
setWorkspace
(
name
)
dispatch
(
setMode
(
'browser'
))
dispatch
(
setCurrentWorkspace
(
name
))
dispatch
(
setCurrentWorkspace
(
name
,
plugin
))
dispatch
(
setReadOnlyMode
(
false
))
plugin
.
emit
(
'setWorkspace'
,
{
name
,
isLocalhost
:
false
})
}
...
...
@@ -255,3 +257,26 @@ export const uploadFile = async (target, targetFolder: string, cb?: (err: Error,
})
})
}
export
const
getWorkspaces
=
async
():
Promise
<
string
[]
>
|
undefined
=>
{
try
{
const
workspaces
:
string
[]
=
await
new
Promise
((
resolve
,
reject
)
=>
{
const
workspacesPath
=
plugin
.
fileProviders
.
workspace
.
workspacesPath
plugin
.
fileProviders
.
browser
.
resolveDirectory
(
'/'
+
workspacesPath
,
(
error
,
items
)
=>
{
if
(
error
)
{
console
.
error
(
error
)
return
reject
(
error
)
}
resolve
(
Object
.
keys
(
items
)
.
filter
((
item
)
=>
items
[
item
].
isDirectory
)
.
map
((
folder
)
=>
folder
.
replace
(
workspacesPath
+
'/'
,
''
)))
})
})
plugin
.
setWorkspaces
(
workspaces
)
return
workspaces
}
catch
(
e
)
{
console
.
log
(
e
)
}
}
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