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
499467ca
Unverified
Commit
499467ca
authored
Oct 02, 2019
by
yann300
Committed by
GitHub
Oct 02, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2379 from ethereum/folderCreation
Folder creation
parents
73658927
b3a77508
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
9 deletions
+35
-9
file-explorer.js
src/app/files/file-explorer.js
+30
-8
fileManager.js
src/app/files/fileManager.js
+5
-1
No files found.
src/app/files/file-explorer.js
View file @
499467ca
...
@@ -28,7 +28,7 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -28,7 +28,7 @@ function fileExplorer (localRegistry, files, menuItems) {
let
allItems
=
let
allItems
=
[
[
{
action
:
'createNewFile'
,
{
action
:
'createNewFile'
,
title
:
'Create New File
in the Browser Storage Explorer
'
,
title
:
'Create New File'
,
icon
:
'fas fa-plus-circle'
icon
:
'fas fa-plus-circle'
},
},
{
action
:
'publishToGist'
,
{
action
:
'publishToGist'
,
...
@@ -230,6 +230,9 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -230,6 +230,9 @@ function fileExplorer (localRegistry, files, menuItems) {
)
)
}
}
}
}
actions
[
'Create File'
]
=
()
=>
self
.
createNewFile
(
key
)
actions
[
'Create Folder'
]
=
()
=>
self
.
createNewFolder
(
key
)
actions
[
'Rename'
]
=
()
=>
{
actions
[
'Rename'
]
=
()
=>
{
if
(
self
.
files
.
isReadOnly
(
key
))
{
return
tooltip
(
'cannot rename folder. '
+
self
.
files
.
type
+
' is a read only explorer'
)
}
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
+
'"]'
)
var
name
=
label
.
querySelector
(
'span[data-path="'
+
key
+
'"]'
)
...
@@ -238,7 +241,10 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -238,7 +241,10 @@ function fileExplorer (localRegistry, files, menuItems) {
}
}
actions
[
'Delete'
]
=
()
=>
{
actions
[
'Delete'
]
=
()
=>
{
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'
)
}
modalDialogCustom
.
confirm
(
'Confirm to delete a folder'
,
'Are you sure you want to delete this folder?'
,
()
=>
{
files
.
remove
(
key
)
},
()
=>
{})
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
)
})
})
...
@@ -249,6 +255,7 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -249,6 +255,7 @@ function fileExplorer (localRegistry, files, menuItems) {
let
actions
=
{}
let
actions
=
{}
const
provider
=
self
.
_deps
.
fileManager
.
fileProviderOf
(
key
)
const
provider
=
self
.
_deps
.
fileManager
.
fileProviderOf
(
key
)
if
(
!
provider
.
isExternalFolder
(
key
))
{
if
(
!
provider
.
isExternalFolder
(
key
))
{
actions
[
'Create Folder'
]
=
()
=>
self
.
createNewFolder
(
self
.
_deps
.
fileManager
.
extractPathOf
(
key
))
actions
[
'Rename'
]
=
()
=>
{
actions
[
'Rename'
]
=
()
=>
{
if
(
self
.
files
.
isReadOnly
(
key
))
{
return
tooltip
(
'cannot rename file. '
+
self
.
files
.
type
+
' is a read only explorer'
)
}
if
(
self
.
files
.
isReadOnly
(
key
))
{
return
tooltip
(
'cannot rename file. '
+
self
.
files
.
type
+
' is a read only explorer'
)
}
var
name
=
label
.
querySelector
(
'span[data-path="'
+
key
+
'"]'
)
var
name
=
label
.
querySelector
(
'span[data-path="'
+
key
+
'"]'
)
...
@@ -572,24 +579,39 @@ fileExplorer.prototype.copyFiles = function () {
...
@@ -572,24 +579,39 @@ fileExplorer.prototype.copyFiles = function () {
}
}
}
}
fileExplorer
.
prototype
.
createNewFile
=
function
()
{
fileExplorer
.
prototype
.
createNewFile
=
function
(
parentFolder
)
{
let
self
=
this
let
self
=
this
modalDialogCustom
.
prompt
(
'Create new file'
,
'File
Path (Untitled.sol, Folder1/
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
)
=>
{
helper
.
createNonClashingName
(
input
,
self
.
files
,
(
error
,
newName
)
=>
{
if
(
error
)
return
modalDialogCustom
.
alert
(
'Failed to create file '
+
newName
+
' '
+
error
)
if
(
error
)
return
modalDialogCustom
.
alert
(
'Failed to create file '
+
newName
+
' '
+
error
)
const
currentPath
=
!
parentFolder
?
self
.
_deps
.
fileManager
.
currentPath
()
:
parentFolder
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
)
modalDialogCustom
.
alert
(
'Failed to create file '
+
newName
)
}
else
{
}
else
{
var
file
=
self
.
files
.
type
+
'/'
+
newName
self
.
_deps
.
fileManager
.
switchFile
(
newName
)
self
.
_deps
.
fileManager
.
switchFile
(
file
)
if
(
newName
.
includes
(
'_test.sol'
))
{
if
(
file
.
includes
(
'_test.sol'
))
{
self
.
event
.
trigger
(
'newTestFileCreated'
,
[
newName
])
self
.
event
.
trigger
(
'newTestFileCreated'
,
[
file
])
}
}
}
}
})
})
},
null
,
true
)
},
null
,
true
)
}
}
fileExplorer
.
prototype
.
createNewFolder
=
function
(
parentFolder
)
{
let
self
=
this
modalDialogCustom
.
prompt
(
'Create new folder'
,
''
,
''
,
(
input
)
=>
{
const
currentPath
=
!
parentFolder
?
self
.
_deps
.
fileManager
.
currentPath
()
:
parentFolder
let
newName
=
currentPath
?
currentPath
+
'/'
+
input
:
self
.
files
.
type
+
'/'
+
input
newName
=
newName
+
'/'
if
(
!
self
.
files
.
set
(
newName
,
''
))
{
modalDialogCustom
.
alert
(
'Failed to create folder '
+
newName
)
}
},
null
,
true
)
}
fileExplorer
.
prototype
.
renderMenuItems
=
function
()
{
fileExplorer
.
prototype
.
renderMenuItems
=
function
()
{
let
items
=
''
let
items
=
''
if
(
this
.
menuItems
)
{
if
(
this
.
menuItems
)
{
...
...
src/app/files/fileManager.js
View file @
499467ca
...
@@ -119,8 +119,12 @@ class FileManager extends Plugin {
...
@@ -119,8 +119,12 @@ class FileManager extends Plugin {
currentPath
()
{
currentPath
()
{
var
currentFile
=
this
.
_deps
.
config
.
get
(
'currentFile'
)
var
currentFile
=
this
.
_deps
.
config
.
get
(
'currentFile'
)
return
this
.
extractPathOf
(
currentFile
)
}
extractPathOf
(
file
)
{
var
reg
=
/
(
.*
)(\/)
.*/
var
reg
=
/
(
.*
)(\/)
.*/
var
path
=
reg
.
exec
(
currentF
ile
)
var
path
=
reg
.
exec
(
f
ile
)
return
path
?
path
[
1
]
:
null
return
path
?
path
[
1
]
:
null
}
}
...
...
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