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
974efc51
Commit
974efc51
authored
Nov 11, 2019
by
LianaHus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed
- same name - empty name - remove empty folder - close deleted file tab issues
parent
5e667faf
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
11 deletions
+43
-11
file-explorer.js
src/app/files/file-explorer.js
+21
-5
fileProvider.js
src/app/files/fileProvider.js
+22
-6
No files found.
src/app/files/file-explorer.js
View file @
974efc51
...
@@ -213,7 +213,7 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -213,7 +213,7 @@ function fileExplorer (localRegistry, files, menuItems) {
modalDialogCustom
.
confirm
(
modalDialogCustom
.
confirm
(
'Discard changes'
,
'Discard changes'
,
'Are you sure you want to discard all your changes?'
,
'Are you sure you want to discard all your changes?'
,
()
=>
{
files
.
discardChanges
(
key
)
},
()
=>
{
self
.
files
.
discardChanges
(
key
)
},
()
=>
{}
()
=>
{}
)
)
}
}
...
@@ -244,6 +244,9 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -244,6 +244,9 @@ function fileExplorer (localRegistry, files, menuItems) {
modalDialogCustom
.
confirm
(
'Confirm to delete a folder'
,
'Are you sure you want to delete this folder?'
,
modalDialogCustom
.
confirm
(
'Confirm to delete a folder'
,
'Are you sure you want to delete this folder?'
,
()
=>
{
()
=>
{
if
(
!
files
.
remove
(
key
))
tooltip
(
`failed to remove
${
key
}
. Make sure the directory is empty before removing it.`
)
if
(
!
files
.
remove
(
key
))
tooltip
(
`failed to remove
${
key
}
. Make sure the directory is empty before removing it.`
)
else
{
self
.
updatePath
(
'browser'
)
}
},
()
=>
{})
},
()
=>
{})
}
}
MENU_HANDLE
=
contextMenu
(
event
,
actions
)
MENU_HANDLE
=
contextMenu
(
event
,
actions
)
...
@@ -265,7 +268,10 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -265,7 +268,10 @@ function fileExplorer (localRegistry, files, menuItems) {
if
(
self
.
files
.
isReadOnly
(
key
))
{
return
tooltip
(
'cannot delete file. '
+
self
.
files
.
type
+
' is a read only explorer'
)
}
if
(
self
.
files
.
isReadOnly
(
key
))
{
return
tooltip
(
'cannot delete file. '
+
self
.
files
.
type
+
' is a read only explorer'
)
}
modalDialogCustom
.
confirm
(
modalDialogCustom
.
confirm
(
'Delete a file'
,
'Are you sure you want to delete this file?'
,
'Delete a file'
,
'Are you sure you want to delete this file?'
,
()
=>
{
files
.
remove
(
key
)
},
()
=>
{
files
.
remove
(
key
)
self
.
updatePath
(
'browser'
)
},
()
=>
{}
()
=>
{}
)
)
}
}
...
@@ -599,14 +605,24 @@ fileExplorer.prototype.createNewFile = function (parentFolder = 'browser') {
...
@@ -599,14 +605,24 @@ fileExplorer.prototype.createNewFile = function (parentFolder = 'browser') {
fileExplorer
.
prototype
.
createNewFolder
=
function
(
parentFolder
)
{
fileExplorer
.
prototype
.
createNewFolder
=
function
(
parentFolder
)
{
let
self
=
this
let
self
=
this
modalDialogCustom
.
prompt
(
'Create new folder'
,
''
,
''
,
(
input
)
=>
{
modalDialogCustom
.
prompt
(
'Create new folder'
,
''
,
'New folder'
,
(
input
)
=>
{
if
(
input
===
''
)
{
modalDialogCustom
.
alert
(
'Failed to create folder. The name can not be empty'
)
return
false
}
const
currentPath
=
!
parentFolder
?
self
.
_deps
.
fileManager
.
currentPath
()
:
parentFolder
const
currentPath
=
!
parentFolder
?
self
.
_deps
.
fileManager
.
currentPath
()
:
parentFolder
let
newName
=
currentPath
?
currentPath
+
'/'
+
input
:
self
.
files
.
type
+
'/'
+
input
let
newName
=
currentPath
?
currentPath
+
'/'
+
input
:
self
.
files
.
type
+
'/'
+
input
newName
=
newName
+
'/'
newName
=
newName
+
'/'
if
(
!
self
.
files
.
set
(
newName
,
''
))
{
self
.
files
.
exists
(
newName
,
(
error
,
exist
)
=>
{
modalDialogCustom
.
alert
(
'Failed to create folder '
+
newName
)
if
(
error
)
return
modalDialogCustom
.
alert
(
'Unexpected error while creating folder: '
+
error
)
if
(
!
exist
)
{
self
.
files
.
set
(
newName
,
''
)
}
else
{
modalDialogCustom
.
alert
(
'Folder already exists.'
,
()
=>
{})
}
}
})
},
null
,
true
)
},
null
,
true
)
}
}
...
...
src/app/files/fileProvider.js
View file @
974efc51
...
@@ -64,6 +64,8 @@ class FileProvider {
...
@@ -64,6 +64,8 @@ class FileProvider {
}
}
exists
(
path
,
cb
)
{
exists
(
path
,
cb
)
{
// todo check the type (directory/file) as well #2386
// currently it is not possible to have a file and folder with same path
cb
(
null
,
this
.
_exists
(
path
))
cb
(
null
,
this
.
_exists
(
path
))
}
}
...
@@ -138,22 +140,36 @@ class FileProvider {
...
@@ -138,22 +140,36 @@ class FileProvider {
remove
(
path
)
{
remove
(
path
)
{
path
=
this
.
removePrefix
(
path
)
path
=
this
.
removePrefix
(
path
)
if
(
window
.
remixFileSystem
.
existsSync
(
path
))
{
if
(
window
.
remixFileSystem
.
existsSync
(
path
))
{
window
.
remixFileSystem
.
readdirSync
(
path
).
forEach
((
file
,
index
)
=>
{
const
stat
=
window
.
remixFileSystem
.
statSync
(
path
)
let
curPath
=
path
+
'/'
+
file
let
stat
=
window
.
remixFileSystem
.
statSync
(
curPath
)
try
{
try
{
if
(
stat
.
isDirectory
())
{
if
(
!
stat
.
isDirectory
())
{
window
.
remixFileSystem
.
unlinkSync
(
path
,
console
.
log
)
this
.
event
.
trigger
(
'fileRemoved'
,
[
this
.
_normalizePath
(
path
)])
return
true
}
else
{
let
items
=
window
.
remixFileSystem
.
readdirSync
(
path
)
if
(
items
.
length
!==
0
)
{
items
.
forEach
((
item
,
index
)
=>
{
let
curPath
=
path
+
'/'
+
item
if
(
window
.
remixFileSystem
.
statSync
(
curPath
).
isDirectory
())
{
// delete folder
this
.
remove
(
curPath
)
this
.
remove
(
curPath
)
window
.
remixFileSystem
.
rmdirSync
(
curPath
,
console
.
log
)
}
else
{
// delete file
}
else
{
// delete file
window
.
remixFileSystem
.
unlinkSync
(
curPath
,
console
.
log
)
window
.
remixFileSystem
.
unlinkSync
(
curPath
,
console
.
log
)
this
.
event
.
trigger
(
'fileRemoved'
,
[
this
.
_normalizePath
(
path
)])
}
})
if
(
window
.
remixFileSystem
.
readdirSync
(
path
).
length
===
0
)
window
.
remixFileSystem
.
rmdirSync
(
path
,
console
.
log
)
}
else
{
// folder is empty
window
.
remixFileSystem
.
rmdirSync
(
path
,
console
.
log
)
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
e
)
console
.
log
(
e
)
return
false
return
false
}
}
})
}
}
return
true
}
}
rename
(
oldPath
,
newPath
,
isFolder
)
{
rename
(
oldPath
,
newPath
,
isFolder
)
{
...
...
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