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
b3a77508
Commit
b3a77508
authored
Sep 30, 2019
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add create New folder action
parent
e530595e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
8 deletions
+31
-8
file-explorer.js
src/app/files/file-explorer.js
+26
-7
fileManager.js
src/app/files/fileManager.js
+5
-1
No files found.
src/app/files/file-explorer.js
View file @
b3a77508
...
@@ -27,7 +27,7 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -27,7 +27,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'
,
...
@@ -229,6 +229,9 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -229,6 +229,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
+
'"]'
)
...
@@ -251,6 +254,7 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -251,6 +254,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
+
'"]'
)
...
@@ -562,24 +566,39 @@ fileExplorer.prototype.copyFiles = function () {
...
@@ -562,24 +566,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 @
b3a77508
...
@@ -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