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
0c180e65
Unverified
Commit
0c180e65
authored
Nov 12, 2019
by
Liana Husikyan
Committed by
GitHub
Nov 12, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2427 from ethereum/deleteDir
Fixing bugs of FE #2386
parents
01b764d4
02bee701
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
38 deletions
+73
-38
file-explorer.js
src/app/files/file-explorer.js
+40
-27
fileProvider.js
src/app/files/fileProvider.js
+31
-10
tab-proxy.js
src/app/panels/tab-proxy.js
+1
-1
helper.js
src/lib/helper.js
+1
-0
No files found.
src/app/files/file-explorer.js
View file @
0c180e65
...
@@ -158,7 +158,6 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -158,7 +158,6 @@ function fileExplorer (localRegistry, files, menuItems) {
var
isFile
=
false
var
isFile
=
false
Object
.
keys
(
value
).
filter
(
function
keep
(
x
)
{
Object
.
keys
(
value
).
filter
(
function
keep
(
x
)
{
if
(
x
===
'/content'
)
isFile
=
true
if
(
x
===
'/content'
)
isFile
=
true
// if (x === '/readOnly') isReadOnly = true
if
(
x
[
0
]
!==
'/'
)
return
true
if
(
x
[
0
]
!==
'/'
)
return
true
}).
forEach
(
function
(
x
)
{
newValue
[
x
]
=
value
[
x
]
})
}).
forEach
(
function
(
x
)
{
newValue
[
x
]
=
value
[
x
]
})
return
{
return
{
...
@@ -208,17 +207,35 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -208,17 +207,35 @@ function fileExplorer (localRegistry, files, menuItems) {
MENU_HANDLE
&&
MENU_HANDLE
.
hide
(
null
,
true
)
MENU_HANDLE
&&
MENU_HANDLE
.
hide
(
null
,
true
)
let
actions
=
{}
let
actions
=
{}
const
provider
=
self
.
_deps
.
fileManager
.
fileProviderOf
(
key
)
const
provider
=
self
.
_deps
.
fileManager
.
fileProviderOf
(
key
)
actions
[
'Create File'
]
=
()
=>
self
.
createNewFile
(
key
)
actions
[
'Create Folder'
]
=
()
=>
self
.
createNewFolder
(
key
)
if
(
provider
.
isExternalFolder
(
key
))
{
if
(
provider
.
isExternalFolder
(
key
))
{
actions
[
'Discard changes'
]
=
()
=>
{
actions
[
'Discard changes'
]
=
()
=>
{
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
)
},
()
=>
{}
()
=>
{}
)
)
}
}
}
else
{
}
else
{
const
folderPath
=
extractExternalFolder
(
key
)
const
folderPath
=
extractExternalFolder
(
key
)
actions
[
'Rename'
]
=
()
=>
{
if
(
self
.
files
.
isReadOnly
(
key
))
{
return
tooltip
(
'cannot rename folder. '
+
self
.
files
.
type
+
' is a read only explorer'
)
}
var
name
=
label
.
querySelector
(
'span[data-path="'
+
key
+
'"]'
)
if
(
name
)
editModeOn
(
name
)
}
actions
[
'Delete'
]
=
()
=>
{
if
(
self
.
files
.
isReadOnly
(
key
))
{
return
tooltip
(
'cannot delete folder. '
+
self
.
files
.
type
+
' is a read only explorer'
)
}
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.`
)
}
else
{
self
.
updatePath
(
'browser'
)
}
},
()
=>
{})
}
if
(
folderPath
===
'browser/gists'
)
{
if
(
folderPath
===
'browser/gists'
)
{
actions
[
'Push changes to gist'
]
=
()
=>
{
actions
[
'Push changes to gist'
]
=
()
=>
{
const
id
=
key
.
substr
(
key
.
lastIndexOf
(
'/'
)
+
1
,
key
.
length
-
1
)
const
id
=
key
.
substr
(
key
.
lastIndexOf
(
'/'
)
+
1
,
key
.
length
-
1
)
...
@@ -230,21 +247,6 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -230,21 +247,6 @@ function fileExplorer (localRegistry, files, menuItems) {
)
)
}
}
}
}
actions
[
'Create File'
]
=
()
=>
self
.
createNewFile
(
key
)
actions
[
'Create Folder'
]
=
()
=>
self
.
createNewFolder
(
key
)
actions
[
'Rename'
]
=
()
=>
{
if
(
self
.
files
.
isReadOnly
(
key
))
{
return
tooltip
(
'cannot rename folder. '
+
self
.
files
.
type
+
' is a read only explorer'
)
}
var
name
=
label
.
querySelector
(
'span[data-path="'
+
key
+
'"]'
)
if
(
name
)
editModeOn
(
name
)
}
}
actions
[
'Delete'
]
=
()
=>
{
if
(
self
.
files
.
isReadOnly
(
key
))
{
return
tooltip
(
'cannot delete folder. '
+
self
.
files
.
type
+
' is a read only explorer'
)
}
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.`
)
},
()
=>
{})
}
}
MENU_HANDLE
=
contextMenu
(
event
,
actions
)
MENU_HANDLE
=
contextMenu
(
event
,
actions
)
})
})
...
@@ -265,7 +267,10 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -265,7 +267,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'
)
},
()
=>
{}
()
=>
{}
)
)
}
}
...
@@ -579,16 +584,15 @@ fileExplorer.prototype.copyFiles = function () {
...
@@ -579,16 +584,15 @@ fileExplorer.prototype.copyFiles = function () {
}
}
}
}
fileExplorer
.
prototype
.
createNewFile
=
function
(
parentFolder
)
{
fileExplorer
.
prototype
.
createNewFile
=
function
(
parentFolder
=
'browser'
)
{
let
self
=
this
let
self
=
this
modalDialogCustom
.
prompt
(
'Create new file'
,
'File Name (e.g Untitled.sol)'
,
'Untitled.sol'
,
(
input
)
=>
{
modalDialogCustom
.
prompt
(
'Create new file'
,
'File Name (e.g Untitled.sol)'
,
'Untitled.sol'
,
(
input
)
=>
{
helper
.
createNonClashingName
(
input
,
self
.
files
,
(
error
,
newName
)
=>
{
if
(
!
input
)
input
=
'New file'
if
(
error
)
return
modalDialogCustom
.
alert
(
'Failed to create file '
+
newName
+
' '
+
error
)
helper
.
createNonClashingName
(
parentFolder
+
'/'
+
input
,
self
.
files
,
(
error
,
newName
)
=>
{
const
currentPath
=
!
parentFolder
?
self
.
_deps
.
fileManager
.
currentPath
()
:
parentFolder
if
(
error
)
return
tooltip
(
'Failed to create file '
+
newName
+
' '
+
error
)
newName
=
currentPath
?
currentPath
+
'/'
+
newName
:
self
.
files
.
type
+
'/'
+
newName
if
(
!
self
.
files
.
set
(
newName
,
''
))
{
if
(
!
self
.
files
.
set
(
newName
,
''
))
{
modalDialogCustom
.
alert
(
'Failed to create file '
+
newName
)
tooltip
(
'Failed to create file '
+
newName
)
}
else
{
}
else
{
self
.
_deps
.
fileManager
.
switchFile
(
newName
)
self
.
_deps
.
fileManager
.
switchFile
(
newName
)
if
(
newName
.
includes
(
'_test.sol'
))
{
if
(
newName
.
includes
(
'_test.sol'
))
{
...
@@ -601,14 +605,23 @@ fileExplorer.prototype.createNewFile = function (parentFolder) {
...
@@ -601,14 +605,23 @@ fileExplorer.prototype.createNewFile = function (parentFolder) {
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
)
{
return
tooltip
(
'Failed to create folder. The name can not be empty'
)
}
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
tooltip
(
'Unexpected error while creating folder: '
+
error
)
if
(
!
exist
)
{
self
.
files
.
set
(
newName
,
''
)
}
else
{
tooltip
(
'Folder already exists.'
,
()
=>
{})
}
}
})
},
null
,
true
)
},
null
,
true
)
}
}
...
...
src/app/files/fileProvider.js
View file @
0c180e65
...
@@ -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
))
}
}
...
@@ -131,25 +133,44 @@ class FileProvider {
...
@@ -131,25 +133,44 @@ class FileProvider {
return
false
return
false
}
}
/**
* Removes the folder recursively
* @param {*} path is the folder to be removed
*/
remove
(
path
)
{
remove
(
path
)
{
var
unprefixedpath
=
this
.
removePrefix
(
path
)
path
=
this
.
removePrefix
(
path
)
if
(
!
this
.
_exists
(
unprefixedpath
))
{
if
(
window
.
remixFileSystem
.
existsSync
(
path
))
{
return
false
const
stat
=
window
.
remixFileSystem
.
statSync
(
path
)
}
const
stat
=
window
.
remixFileSystem
.
statSync
(
unprefixedpath
)
try
{
try
{
if
(
stat
.
isDirectory
())
{
if
(
!
stat
.
isDirectory
())
{
window
.
remixFileSystem
.
rmdirSync
(
unprefixedpath
,
console
.
log
)
window
.
remixFileSystem
.
unlinkSync
(
path
,
console
.
log
)
this
.
event
.
trigger
(
'fileRemoved'
,
[
this
.
_normalizePath
(
path
)])
return
true
}
else
{
}
else
{
window
.
remixFileSystem
.
unlinkSync
(
unprefixedpath
,
console
.
log
)
const
items
=
window
.
remixFileSystem
.
readdirSync
(
path
)
if
(
items
.
length
!==
0
)
{
items
.
forEach
((
item
,
index
)
=>
{
const
curPath
=
`
${
path
}
/
${
item
}
`
if
(
window
.
remixFileSystem
.
statSync
(
curPath
).
isDirectory
())
{
// delete folder
this
.
remove
(
curPath
)
}
else
{
// delete file
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
)
}
}
}
this
.
event
.
trigger
(
'fileRemoved'
,
[
this
.
_normalizePath
(
unprefixedpath
)])
return
true
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
e
)
console
.
log
(
e
)
return
false
return
false
}
}
}
}
return
true
}
rename
(
oldPath
,
newPath
,
isFolder
)
{
rename
(
oldPath
,
newPath
,
isFolder
)
{
var
unprefixedoldPath
=
this
.
removePrefix
(
oldPath
)
var
unprefixedoldPath
=
this
.
removePrefix
(
oldPath
)
...
...
src/app/panels/tab-proxy.js
View file @
0c180e65
...
@@ -132,7 +132,7 @@ export class TabProxy {
...
@@ -132,7 +132,7 @@ export class TabProxy {
id
:
name
,
id
:
name
,
title
,
title
,
icon
,
icon
,
tooltip
:
titl
e
tooltip
:
nam
e
})
})
this
.
_handlers
[
name
]
=
{
switchTo
,
close
}
this
.
_handlers
[
name
]
=
{
switchTo
,
close
}
}
}
...
...
src/lib/helper.js
View file @
0c180e65
...
@@ -12,6 +12,7 @@ module.exports = {
...
@@ -12,6 +12,7 @@ module.exports = {
return
data
.
slice
(
0
,
5
)
+
'...'
+
data
.
slice
(
len
-
5
,
len
)
return
data
.
slice
(
0
,
5
)
+
'...'
+
data
.
slice
(
len
-
5
,
len
)
},
},
createNonClashingNameWithPrefix
(
name
,
fileProvider
,
prefix
,
cb
)
{
createNonClashingNameWithPrefix
(
name
,
fileProvider
,
prefix
,
cb
)
{
if
(
!
name
)
name
=
'Undefined'
var
counter
=
''
var
counter
=
''
var
ext
=
'sol'
var
ext
=
'sol'
var
reg
=
/
(
.*
)\.([^
.
]
+
)
/g
var
reg
=
/
(
.*
)\.([^
.
]
+
)
/g
...
...
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