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
08c1347b
Commit
08c1347b
authored
Mar 03, 2021
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix workspace rename
parent
ad47b45d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
9 deletions
+19
-9
file-panel.js
apps/remix-ide/src/app/panels/file-panel.js
+10
-0
remix-ui-workspace.tsx
libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
+9
-9
No files found.
apps/remix-ide/src/app/panels/file-panel.js
View file @
08c1347b
...
...
@@ -75,6 +75,7 @@ module.exports = class Filepanel extends ViewPlugin {
ReactDOM
.
render
(
<
Workspace
createWorkspace
=
{
this
.
createWorkspace
.
bind
(
this
)}
renameWorkspace
=
{
this
.
renameWorkspace
.
bind
(
this
)}
setWorkspace
=
{
this
.
setWorkspace
.
bind
(
this
)}
workspaceRenamed
=
{
this
.
workspaceRenamed
.
bind
(
this
)}
workspaceDeleted
=
{
this
.
workspaceDeleted
.
bind
(
this
)}
...
...
@@ -202,6 +203,15 @@ module.exports = class Filepanel extends ViewPlugin {
}
}
async
renameWorkspace
(
oldName
,
workspaceName
)
{
if
(
!
workspaceName
)
throw
new
Error
(
'name cannot be empty'
)
if
(
checkSpecialChars
(
workspaceName
)
||
checkSlash
(
workspaceName
))
throw
new
Error
(
'special characters are not allowed'
)
if
(
await
this
.
workspaceExists
(
workspaceName
))
throw
new
Error
(
'workspace already exists'
)
const
browserProvider
=
this
.
_deps
.
fileProviders
.
browser
const
workspacesPath
=
this
.
_deps
.
fileProviders
.
workspace
.
workspacesPath
browserProvider
.
rename
(
'browser/'
+
workspacesPath
+
'/'
+
oldName
,
'browser/'
+
workspacesPath
+
'/'
+
workspaceName
,
true
)
}
/** these are called by the react component, action is already finished whent it's called */
async
setWorkspace
(
workspace
)
{
this
.
_deps
.
fileManager
.
removeTabsOf
(
this
.
_deps
.
fileProviders
.
workspace
)
...
...
libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
View file @
08c1347b
...
...
@@ -7,6 +7,7 @@ import { ModalDialog } from '@remix-ui/modal-dialog' // eslint-disable-line
export
interface
WorkspaceProps
{
setWorkspace
:
({
name
:
string
,
isLocalhost
:
boolean
})
=>
void
,
createWorkspace
:
(
name
:
string
)
=>
void
,
renameWorkspace
:
(
oldName
:
string
,
newName
:
string
)
=>
void
workspaceRenamed
:
({
name
:
string
})
=>
void
,
workspaceCreated
:
({
name
:
string
})
=>
void
,
workspaceDeleted
:
({
name
:
string
})
=>
void
,
...
...
@@ -22,10 +23,6 @@ export interface WorkspaceProps {
initialWorkspace
:
string
}
const
hasSpecialChar
=
(
value
)
=>
{
return
value
.
match
(
/
[
:*?"<>
\\
'|
]
/
)
!=
null
||
value
.
match
(
/
\/
/
)
!=
null
}
var
canUpload
=
window
.
File
||
window
.
FileReader
||
window
.
FileList
||
window
.
Blob
export
const
Workspace
=
(
props
:
WorkspaceProps
)
=>
{
const
LOCALHOST
=
' - connect to localhost - '
...
...
@@ -171,12 +168,15 @@ export const Workspace = (props: WorkspaceProps) => {
if
(
workspaceRenameInput
.
current
===
undefined
)
return
// @ts-ignore: Object is possibly 'null'.
const
workspaceName
=
workspaceRenameInput
.
current
.
value
if
(
hasSpecialChar
(
workspaceName
))
return
modalMessage
(
'Workspace Rename'
,
'special characters are not allowed'
)
const
workspacesPath
=
props
.
workspace
.
workspacesPath
await
props
.
fileManager
.
rename
(
'browser/'
+
workspacesPath
+
'/'
+
state
.
currentWorkspace
,
'browser/'
+
workspacesPath
+
'/'
+
workspaceName
)
setWorkspace
(
workspaceName
)
props
.
workspaceRenamed
({
name
:
state
.
currentWorkspace
})
try
{
await
props
.
renameWorkspace
(
state
.
currentWorkspace
,
workspaceName
)
setWorkspace
(
workspaceName
)
props
.
workspaceRenamed
({
name
:
workspaceName
})
}
catch
(
e
)
{
modalMessage
(
'Workspace Rename'
,
e
.
message
)
console
.
error
(
e
)
}
}
const
onFinishCreateWorkspace
=
async
()
=>
{
...
...
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