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
3a075e1d
Unverified
Commit
3a075e1d
authored
Apr 01, 2020
by
yann300
Committed by
GitHub
Apr 01, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2689 from ethereum/renameFolder
issue with rename of folder
parents
f6ce8384
da9b3a20
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
12 deletions
+27
-12
file-explorer.js
src/app/files/file-explorer.js
+21
-8
fileManager.js
src/app/files/fileManager.js
+2
-2
tab-proxy.js
src/app/panels/tab-proxy.js
+4
-2
No files found.
src/app/files/file-explorer.js
View file @
3a075e1d
...
@@ -173,12 +173,13 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -173,12 +173,13 @@ function fileExplorer (localRegistry, files, menuItems) {
}
}
},
},
formatSelf
:
function
formatSelf
(
key
,
data
,
li
)
{
formatSelf
:
function
formatSelf
(
key
,
data
,
li
)
{
var
isRoot
=
data
.
path
===
self
.
files
.
type
const
isRoot
=
data
.
path
===
self
.
files
.
type
const
isFolder
=
!!
data
.
children
return
yo
`
return
yo
`
<div class="
${
css
.
items
}
">
<div class="
${
css
.
items
}
">
<span
<span
title="
${
data
.
path
}
"
title="
${
data
.
path
}
"
class="
${
css
.
label
}
${
!
isRoot
?
css
.
leaf
:
''
}
"
class="
${
css
.
label
}
${
!
isRoot
?
!
isFolder
?
css
.
leaf
:
css
.
folder
:
''
}
"
data-path="
${
data
.
path
}
"
data-path="
${
data
.
path
}
"
style="
${
isRoot
?
'font-weight:bold;'
:
''
}
"
style="
${
isRoot
?
'font-weight:bold;'
:
''
}
"
onkeydown=
${
editModeOff
}
onkeydown=
${
editModeOff
}
...
@@ -232,7 +233,7 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -232,7 +233,7 @@ function fileExplorer (localRegistry, files, menuItems) {
if
(
self
.
files
.
isReadOnly
(
key
))
{
return
tooltip
(
'cannot delete folder. '
+
self
.
files
.
type
+
' is a read only explorer'
)
}
if
(
self
.
files
.
isReadOnly
(
key
))
{
return
tooltip
(
'cannot delete folder. '
+
self
.
files
.
type
+
' is a read only explorer'
)
}
const
currentFoldername
=
extractNameFromKey
(
key
)
const
currentFoldername
=
extractNameFromKey
(
key
)
modalDialogCustom
.
confirm
(
`Confirm to delete
${
currentFoldername
}
folder`
,
`Are you sure you want to delete
${
currentFoldername
}
folder?`
,
modalDialogCustom
.
confirm
(
`Confirm to delete folder`
,
`Are you sure you want to delete
${
currentFoldername
}
folder?`
,
()
=>
{
()
=>
{
if
(
!
files
.
remove
(
key
))
{
if
(
!
files
.
remove
(
key
))
{
tooltip
(
`failed to remove
${
key
}
. Make sure the directory is empty before removing it.`
)
tooltip
(
`failed to remove
${
key
}
. Make sure the directory is empty before removing it.`
)
...
@@ -273,7 +274,7 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -273,7 +274,7 @@ function fileExplorer (localRegistry, files, menuItems) {
const
currentFilename
=
extractNameFromKey
(
key
)
const
currentFilename
=
extractNameFromKey
(
key
)
modalDialogCustom
.
confirm
(
modalDialogCustom
.
confirm
(
`Delete
${
currentFilename
}
file`
,
`Are you sure you want to delete
${
currentFilename
}
file?`
,
`Delete file`
,
`Are you sure you want to delete
${
currentFilename
}
file?`
,
()
=>
{
()
=>
{
files
.
remove
(
key
)
files
.
remove
(
key
)
self
.
updatePath
(
'browser'
)
self
.
updatePath
(
'browser'
)
...
@@ -339,7 +340,9 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -339,7 +340,9 @@ function fileExplorer (localRegistry, files, menuItems) {
}
}
function
editModeOff
(
event
)
{
function
editModeOff
(
event
)
{
var
label
=
this
let
label
=
this
const
isFolder
=
label
.
className
.
indexOf
(
'folder'
)
!==
-
1
function
rename
()
{
function
rename
()
{
var
newPath
=
label
.
dataset
.
path
var
newPath
=
label
.
dataset
.
path
newPath
=
newPath
.
split
(
'/'
)
newPath
=
newPath
.
split
(
'/'
)
...
@@ -366,10 +369,14 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -366,10 +369,14 @@ function fileExplorer (localRegistry, files, menuItems) {
if
(
event
.
which
===
13
)
event
.
preventDefault
()
if
(
event
.
which
===
13
)
event
.
preventDefault
()
if
((
event
.
type
===
'blur'
||
event
.
which
===
13
)
&&
label
.
getAttribute
(
'contenteditable'
))
{
if
((
event
.
type
===
'blur'
||
event
.
which
===
13
)
&&
label
.
getAttribute
(
'contenteditable'
))
{
var
isFolder
=
label
.
className
.
indexOf
(
'folder'
)
!==
-
1
var
save
=
textUnderEdit
!==
label
.
innerText
var
save
=
textUnderEdit
!==
label
.
innerText
if
(
save
)
{
if
(
save
)
{
modalDialogCustom
.
confirm
(
'Confirm to rename a file'
,
'Are you sure you want to rename this file?'
,
()
=>
{
rename
()
},
()
=>
{
label
.
innerText
=
textUnderEdit
})
modalDialogCustom
.
confirm
(
'Confirm to rename a '
+
(
isFolder
?
'folder'
:
'file'
),
'Are you sure you want to rename '
+
textUnderEdit
+
'?'
,
()
=>
{
rename
()
},
()
=>
{
label
.
innerText
=
textUnderEdit
}
)
}
}
label
.
removeAttribute
(
'contenteditable'
)
label
.
removeAttribute
(
'contenteditable'
)
label
.
classList
.
remove
(
'bg-light'
)
label
.
classList
.
remove
(
'bg-light'
)
...
@@ -619,7 +626,13 @@ fileExplorer.prototype.renderMenuItems = function () {
...
@@ -619,7 +626,13 @@ fileExplorer.prototype.renderMenuItems = function () {
`
`
} else {
} else {
return yo`
return yo`
<
span
id
=
$
{
action
}
data-id="fileExplorerNewFile
${
action
}
" onclick=
${(
event
)
=>
{
event
.
stopPropagation
();
this
[
action
]()
}}
class
=
"newFile ${icon} ${css.newFile}"
title
=
$
{
title
}
></span>
<
span
id
=
$
{
action
}
data-id="fileExplorerNewFile
${
action
}
"
onclick=
${(
event
)
=>
{
event
.
stopPropagation
();
this
[
action
]()
}}
class
=
"newFile ${icon} ${css.newFile}"
title
=
$
{
title
}
>
</span>
`
`
}
}
})
})
...
...
src/app/files/fileManager.js
View file @
3a075e1d
...
@@ -89,8 +89,8 @@ class FileManager extends Plugin {
...
@@ -89,8 +89,8 @@ class FileManager extends Plugin {
}
}
}
}
// TODO: Only keep `this.emit` (issue#2210)
// TODO: Only keep `this.emit` (issue#2210)
this
.
emit
(
'fileRenamed'
,
oldName
,
newName
)
this
.
emit
(
'fileRenamed'
,
oldName
,
newName
,
isFolder
)
this
.
events
.
emit
(
'fileRenamed'
,
oldName
,
newName
)
this
.
events
.
emit
(
'fileRenamed'
,
oldName
,
newName
,
isFolder
)
}
}
currentFileProvider
()
{
currentFileProvider
()
{
...
...
src/app/panels/tab-proxy.js
View file @
3a075e1d
...
@@ -43,8 +43,9 @@ export class TabProxy {
...
@@ -43,8 +43,9 @@ export class TabProxy {
})
})
})
})
fileManager
.
events
.
on
(
'fileRenamed'
,
(
oldName
,
newName
)
=>
{
fileManager
.
events
.
on
(
'fileRenamed'
,
(
oldName
,
newName
,
isFolder
)
=>
{
this
.
removeTab
(
oldName
)
if
(
isFolder
)
return
// should change the tab title too
this
.
addTab
(
newName
,
''
,
()
=>
{
this
.
addTab
(
newName
,
''
,
()
=>
{
this
.
fileManager
.
switchFile
(
newName
)
this
.
fileManager
.
switchFile
(
newName
)
this
.
event
.
emit
(
'switchFile'
,
newName
)
this
.
event
.
emit
(
'switchFile'
,
newName
)
...
@@ -53,6 +54,7 @@ export class TabProxy {
...
@@ -53,6 +54,7 @@ export class TabProxy {
this
.
fileManager
.
closeFile
(
newName
)
this
.
fileManager
.
closeFile
(
newName
)
this
.
event
.
emit
(
'closeFile'
,
newName
)
this
.
event
.
emit
(
'closeFile'
,
newName
)
})
})
this
.
removeTab
(
oldName
)
})
})
appManager
.
event
.
on
(
'activate'
,
({
name
,
location
,
displayName
,
icon
})
=>
{
appManager
.
event
.
on
(
'activate'
,
({
name
,
location
,
displayName
,
icon
})
=>
{
...
...
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