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
036afc31
Commit
036afc31
authored
Oct 27, 2021
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement renameWorkspace and deleteWorkspace API
parent
b38ca31a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
25 deletions
+51
-25
file-panel.js
apps/remix-ide/src/app/panels/file-panel.js
+23
-5
events.ts
libs/remix-ui/workspace/src/lib/actions/events.ts
+7
-3
index.ts
libs/remix-ui/workspace/src/lib/actions/index.ts
+1
-15
workspace.ts
libs/remix-ui/workspace/src/lib/actions/workspace.ts
+20
-2
No files found.
apps/remix-ide/src/app/panels/file-panel.js
View file @
036afc31
...
...
@@ -29,8 +29,8 @@ const globalRegistry = require('../../global/registry')
const
profile
=
{
name
:
'filePanel'
,
displayName
:
'File explorers'
,
methods
:
[
'createNewFile'
,
'uploadFile'
,
'getCurrentWorkspace'
,
'getWorkspaces'
,
'createWorkspace'
,
'setWorkspace'
,
'registerContextMenuItem'
,
'renameWorkspace'
],
events
:
[
'setWorkspace'
,
'workspaceRenamed'
,
'
deleteWorkspace'
,
'createWorkspace
'
],
methods
:
[
'createNewFile'
,
'uploadFile'
,
'getCurrentWorkspace'
,
'getWorkspaces'
,
'createWorkspace'
,
'setWorkspace'
,
'registerContextMenuItem'
,
'renameWorkspace'
,
'deleteWorkspace'
],
events
:
[
'setWorkspace'
,
'workspaceRenamed'
,
'
workspaceDeleted'
,
'workspaceCreated
'
],
icon
:
'assets/img/fileManager.webp'
,
description
:
' - '
,
kind
:
'fileexplorer'
,
...
...
@@ -139,7 +139,21 @@ module.exports = class Filepanel extends ViewPlugin {
}
renameWorkspace
(
oldName
,
workspaceName
)
{
this
.
emit
(
'renameWorkspace'
,
oldName
,
workspaceName
)
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
emit
(
'renameWorkspaceReducerEvent'
,
oldName
,
workspaceName
,
(
err
,
data
)
=>
{
if
(
err
)
reject
(
err
)
else
resolve
(
data
||
true
)
})
})
}
deleteWorkspace
(
workspaceName
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
emit
(
'deleteWorkspaceReducerEvent'
,
workspaceName
,
(
err
,
data
)
=>
{
if
(
err
)
reject
(
err
)
else
resolve
(
data
||
true
)
})
})
}
setWorkspace
(
workspace
)
{
...
...
@@ -149,12 +163,16 @@ module.exports = class Filepanel extends ViewPlugin {
this
.
emit
(
'setWorkspace'
,
workspace
)
}
workspaceRenamed
(
oldName
,
workspaceName
)
{
this
.
emit
(
'workspaceRenamed'
,
oldName
,
workspaceName
)
}
workspaceDeleted
(
workspace
)
{
this
.
emit
(
'
deleteWorkspace
'
,
workspace
)
this
.
emit
(
'
workspaceDeleted
'
,
workspace
)
}
workspaceCreated
(
workspace
)
{
this
.
emit
(
'
createWorkspace
'
,
workspace
)
this
.
emit
(
'
workspaceCreated
'
,
workspace
)
}
/** end section */
}
libs/remix-ui/workspace/src/lib/actions/events.ts
View file @
036afc31
...
...
@@ -2,7 +2,7 @@ import { extractParentFromKey } from '@remix-ui/helper'
import
React
from
'react'
import
{
action
}
from
'../types'
import
{
displayNotification
,
displayPopUp
,
fileAddedSuccess
,
fileRemovedSuccess
,
fileRenamedSuccess
,
folderAddedSuccess
,
loadLocalhostError
,
loadLocalhostRequest
,
loadLocalhostSuccess
,
removeContextMenuItem
,
rootFolderChangedSuccess
,
setContextMenuItem
,
setMode
,
setReadOnlyMode
}
from
'./payload'
import
{
addInputField
,
createWorkspace
,
fetchWorkspaceDirectory
,
renameWorkspace
,
switchToWorkspace
,
uploadFile
}
from
'./workspace'
import
{
addInputField
,
createWorkspace
,
deleteWorkspace
,
fetchWorkspaceDirectory
,
renameWorkspace
,
switchToWorkspace
,
uploadFile
}
from
'./workspace'
const
LOCALHOST
=
' - connect to localhost - '
let
plugin
,
dispatch
:
React
.
Dispatch
<
any
>
...
...
@@ -14,8 +14,12 @@ export const listenOnPluginEvents = (filePanelPlugin) => {
createWorkspace
(
name
,
isEmpty
,
cb
)
})
plugin
.
on
(
'filePanel'
,
'renameWorkspace'
,
(
oldName
:
string
,
workspaceName
:
string
)
=>
{
renameWorkspace
(
oldName
,
workspaceName
)
plugin
.
on
(
'filePanel'
,
'renameWorkspaceReducerEvent'
,
(
oldName
:
string
,
workspaceName
:
string
,
cb
:
(
err
:
Error
,
result
?:
string
|
number
|
boolean
|
Record
<
string
,
any
>
)
=>
void
)
=>
{
renameWorkspace
(
oldName
,
workspaceName
,
cb
)
})
plugin
.
on
(
'filePanel'
,
'deleteWorkspaceReducerEvent'
,
(
workspaceName
:
string
,
cb
:
(
err
:
Error
,
result
?:
string
|
number
|
boolean
|
Record
<
string
,
any
>
)
=>
void
)
=>
{
deleteWorkspace
(
workspaceName
,
cb
)
})
plugin
.
on
(
'filePanel'
,
'registerContextMenuItemReducerEvent'
,
(
item
:
action
,
cb
:
(
err
:
Error
,
result
?:
string
|
number
|
boolean
|
Record
<
string
,
any
>
)
=>
void
)
=>
{
...
...
libs/remix-ui/workspace/src/lib/actions/index.ts
View file @
036afc31
...
...
@@ -2,7 +2,7 @@ import React from 'react'
import
{
extractNameFromKey
,
createNonClashingNameAsync
}
from
'@remix-ui/helper'
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
,
set
DeleteWorkspace
,
set
ExpandPath
,
setMode
,
setWorkspaces
}
from
'./payload'
import
{
displayNotification
,
displayPopUp
,
fetchDirectoryError
,
fetchDirectoryRequest
,
fetchDirectorySuccess
,
focusElement
,
hidePopUp
,
removeInputFieldSuccess
,
setCurrentWorkspace
,
setExpandPath
,
setMode
,
setWorkspaces
}
from
'./payload'
import
{
listenOnPluginEvents
,
listenOnProviderEvents
}
from
'./events'
import
{
createWorkspaceTemplate
,
getWorkspaces
,
loadWorkspacePreset
,
setPlugin
}
from
'./workspace'
...
...
@@ -82,11 +82,6 @@ export const removeInputField = async (path: string) => {
dispatch
(
removeInputFieldSuccess
(
path
))
}
export
const
deleteWorkspace
=
async
(
workspaceName
:
string
)
=>
{
await
deleteWorkspaceFromProvider
(
workspaceName
)
await
dispatch
(
setDeleteWorkspace
(
workspaceName
))
}
export
const
publishToGist
=
async
(
path
?:
string
,
type
?:
string
)
=>
{
// If 'id' is not defined, it is not a gist update but a creation so we have to take the files from the browser explorer.
const
folder
=
path
||
'/'
...
...
@@ -258,15 +253,6 @@ export const handleExpandPath = (paths: string[]) => {
dispatch
(
setExpandPath
(
paths
))
}
const
deleteWorkspaceFromProvider
=
async
(
workspaceName
:
string
)
=>
{
const
workspacesPath
=
plugin
.
fileProviders
.
workspace
.
workspacesPath
await
plugin
.
fileManager
.
closeAllFiles
()
plugin
.
fileProviders
.
browser
.
remove
(
workspacesPath
+
'/'
+
workspaceName
)
plugin
.
emit
(
'deleteWorkspace'
,
{
name
:
workspaceName
})
plugin
.
setWorkspaces
(
await
getWorkspaces
())
}
const
packageGistFiles
=
(
directory
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
workspaceProvider
=
plugin
.
fileProviders
.
workspace
...
...
libs/remix-ui/workspace/src/lib/actions/workspace.ts
View file @
036afc31
import
React
from
'react'
import
{
bufferToHex
,
keccakFromString
}
from
'ethereumjs-util'
import
axios
,
{
AxiosResponse
}
from
'axios'
import
{
addInputFieldSuccess
,
createWorkspaceError
,
createWorkspaceRequest
,
createWorkspaceSuccess
,
displayNotification
,
fetchWorkspaceDirectoryError
,
fetchWorkspaceDirectoryRequest
,
fetchWorkspaceDirectorySuccess
,
hideNotification
,
setCurrentWorkspace
,
setMode
,
setReadOnlyMode
,
setRenameWorkspace
}
from
'./payload'
import
{
addInputFieldSuccess
,
createWorkspaceError
,
createWorkspaceRequest
,
createWorkspaceSuccess
,
displayNotification
,
fetchWorkspaceDirectoryError
,
fetchWorkspaceDirectoryRequest
,
fetchWorkspaceDirectorySuccess
,
hideNotification
,
setCurrentWorkspace
,
set
DeleteWorkspace
,
set
Mode
,
setReadOnlyMode
,
setRenameWorkspace
}
from
'./payload'
import
{
checkSlash
,
checkSpecialChars
}
from
'@remix-ui/helper'
const
examples
=
require
(
'../../../../../../apps/remix-ide/src/app/editor/examples'
)
...
...
@@ -48,6 +48,7 @@ export const createWorkspace = async (workspaceName: string, isEmpty = false, cb
dispatch
(
createWorkspaceSuccess
(
workspaceName
))
plugin
.
setWorkspace
({
name
:
workspaceName
,
isLocalhost
:
false
})
plugin
.
setWorkspaces
(
await
getWorkspaces
())
plugin
.
workspaceCreated
(
workspaceName
)
if
(
!
isEmpty
)
await
loadWorkspacePreset
(
'default-template'
)
cb
&&
cb
(
null
,
workspaceName
)
}).
catch
((
error
)
=>
{
...
...
@@ -172,10 +173,12 @@ export const fetchWorkspaceDirectory = async (path: string) => {
return
promise
}
export
const
renameWorkspace
=
async
(
oldName
:
string
,
workspaceName
:
string
)
=>
{
export
const
renameWorkspace
=
async
(
oldName
:
string
,
workspaceName
:
string
,
cb
?:
(
err
:
Error
,
result
?:
string
|
number
|
boolean
|
Record
<
string
,
any
>
)
=>
void
)
=>
{
await
renameWorkspaceFromProvider
(
oldName
,
workspaceName
)
await
dispatch
(
setRenameWorkspace
(
oldName
,
workspaceName
))
plugin
.
setWorkspace
({
name
:
workspaceName
,
isLocalhost
:
false
})
plugin
.
workspaceRenamed
(
oldName
,
workspaceName
)
cb
&&
cb
(
null
,
workspaceName
)
}
export
const
renameWorkspaceFromProvider
=
async
(
oldName
:
string
,
workspaceName
:
string
)
=>
{
...
...
@@ -190,6 +193,21 @@ export const renameWorkspaceFromProvider = async (oldName: string, workspaceName
plugin
.
setWorkspaces
(
await
getWorkspaces
())
}
export
const
deleteWorkspace
=
async
(
workspaceName
:
string
,
cb
?:
(
err
:
Error
,
result
?:
string
|
number
|
boolean
|
Record
<
string
,
any
>
)
=>
void
)
=>
{
await
deleteWorkspaceFromProvider
(
workspaceName
)
await
dispatch
(
setDeleteWorkspace
(
workspaceName
))
plugin
.
workspaceDeleted
(
workspaceName
)
cb
&&
cb
(
null
,
workspaceName
)
}
const
deleteWorkspaceFromProvider
=
async
(
workspaceName
:
string
)
=>
{
const
workspacesPath
=
plugin
.
fileProviders
.
workspace
.
workspacesPath
await
plugin
.
fileManager
.
closeAllFiles
()
plugin
.
fileProviders
.
browser
.
remove
(
workspacesPath
+
'/'
+
workspaceName
)
plugin
.
setWorkspaces
(
await
getWorkspaces
())
}
export
const
switchToWorkspace
=
async
(
name
:
string
)
=>
{
await
plugin
.
fileManager
.
closeAllFiles
()
if
(
name
===
LOCALHOST
)
{
...
...
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