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
25dc9104
Commit
25dc9104
authored
Jan 31, 2018
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove expandPathTo
parent
419b4aa6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
95 deletions
+15
-95
browser-files.js
src/app/files/browser-files.js
+2
-5
file-explorer.js
src/app/files/file-explorer.js
+13
-90
No files found.
src/app/files/browser-files.js
View file @
25dc9104
...
@@ -118,9 +118,8 @@ function Files (storage) {
...
@@ -118,9 +118,8 @@ function Files (storage) {
this
.
resolveDirectory
=
function
(
path
,
callback
)
{
this
.
resolveDirectory
=
function
(
path
,
callback
)
{
var
self
=
this
var
self
=
this
if
(
path
[
0
]
===
'/'
)
path
=
path
.
substring
(
1
)
if
(
path
[
0
]
===
'/'
)
path
=
path
.
substring
(
1
)
if
(
path
[
0
]
===
'.'
&&
path
[
1
]
===
'/'
)
path
=
path
.
substring
(
2
)
if
(
!
path
)
return
callback
(
null
,
{
[
self
.
type
]:
{
}
})
if
(
!
path
)
return
callback
(
null
,
{
[
self
.
type
]:
{
}
})
path
=
self
.
removePrefix
(
''
+
(
path
||
''
)
)
path
=
self
.
removePrefix
(
path
)
var
filesList
=
{}
var
filesList
=
{}
var
tree
=
{}
var
tree
=
{}
// add r/w filesList to the list
// add r/w filesList to the list
...
@@ -157,9 +156,7 @@ function Files (storage) {
...
@@ -157,9 +156,7 @@ function Files (storage) {
}
}
this
.
removePrefix
=
function
(
path
)
{
this
.
removePrefix
=
function
(
path
)
{
path
=
path
.
indexOf
(
this
.
type
)
===
0
?
path
.
replace
(
this
.
type
,
''
)
:
path
return
path
.
indexOf
(
this
.
type
+
'/'
)
===
0
?
path
.
replace
(
this
.
type
+
'/'
,
''
)
:
path
if
(
path
[
0
]
===
'/'
)
return
path
.
substring
(
1
)
return
path
}
}
// rename .browser-solidity.json to .remix.config
// rename .browser-solidity.json to .remix.config
...
...
src/app/files/file-explorer.js
View file @
25dc9104
...
@@ -57,6 +57,7 @@ var focusElement = null
...
@@ -57,6 +57,7 @@ var focusElement = null
function
fileExplorer
(
appAPI
,
files
)
{
function
fileExplorer
(
appAPI
,
files
)
{
var
self
=
this
var
self
=
this
this
.
events
=
new
EventManager
()
this
.
files
=
files
this
.
files
=
files
function
remixdDialog
()
{
function
remixdDialog
()
{
...
@@ -95,11 +96,11 @@ function fileExplorer (appAPI, files) {
...
@@ -95,11 +96,11 @@ function fileExplorer (appAPI, files) {
return
{
return
{
path
:
(
tree
||
{}).
path
?
tree
.
path
+
'/'
+
key
:
key
,
path
:
(
tree
||
{}).
path
?
tree
.
path
+
'/'
+
key
:
key
,
children
:
isFile
?
undefined
children
:
isFile
?
undefined
:
value
instanceof
Array
?
value
.
map
((
item
,
index
)
=>
({
:
value
instanceof
Array
?
value
.
map
((
item
,
index
)
=>
({
key
:
index
,
value
:
item
key
:
index
,
value
:
item
}))
:
value
instanceof
Object
?
Object
.
keys
(
value
).
map
(
subkey
=>
({
}))
:
value
instanceof
Object
?
Object
.
keys
(
value
).
map
(
subkey
=>
({
key
:
subkey
,
value
:
value
[
subkey
]
key
:
subkey
,
value
:
value
[
subkey
]
}))
:
undefined
}))
:
undefined
}
}
},
},
formatSelf
:
function
formatSelf
(
key
,
data
,
li
)
{
formatSelf
:
function
formatSelf
(
key
,
data
,
li
)
{
...
@@ -162,7 +163,6 @@ function fileExplorer (appAPI, files) {
...
@@ -162,7 +163,6 @@ function fileExplorer (appAPI, files) {
var
textUnderEdit
=
null
var
textUnderEdit
=
null
var
textInRename
=
false
var
textInRename
=
false
self
.
events
=
new
EventManager
()
self
.
api
=
{}
self
.
api
=
{}
self
.
api
.
addFile
=
function
addFile
(
file
)
{
self
.
api
.
addFile
=
function
addFile
(
file
)
{
function
loadFile
()
{
function
loadFile
()
{
...
@@ -292,82 +292,16 @@ function fileExplorer (appAPI, files) {
...
@@ -292,82 +292,16 @@ function fileExplorer (appAPI, files) {
}
}
}
}
function
renameSubtree
(
label
,
dontcheck
)
{
var
oldPath
=
label
.
dataset
.
path
var
newPath
=
oldPath
newPath
=
newPath
.
split
(
'/'
)
newPath
[
newPath
.
length
-
1
]
=
label
.
innerText
newPath
=
newPath
.
join
(
'/'
)
if
(
!
dontcheck
)
{
var
allPaths
=
Object
.
keys
(
files
.
list
())
for
(
var
i
=
0
,
len
=
allPaths
.
length
,
path
,
err
;
i
<
len
;
i
++
)
{
path
=
allPaths
[
i
]
if
(
files
.
isReadOnly
(
path
))
{
err
=
'path contains readonly elements'
break
}
else
if
(
path
.
indexOf
(
newPath
)
===
0
)
{
err
=
'new path is conflicting with another existing path'
break
}
}
}
if
(
err
)
{
modalDialogCustom
.
alert
(
`could not rename -
${
err
}
`
)
label
.
innerText
=
textUnderEdit
}
else
{
textUnderEdit
=
label
.
innerText
updateAllLabels
([
getElement
(
oldPath
)],
oldPath
,
newPath
)
}
}
function
updateAllLabels
(
lis
,
oldPath
,
newPath
)
{
lis
.
forEach
(
function
(
li
)
{
var
label
=
getLabelFrom
(
li
)
var
path
=
label
.
dataset
.
path
var
newName
=
path
.
replace
(
oldPath
,
newPath
)
label
.
dataset
.
path
=
newName
var
ul
=
li
.
lastChild
if
(
ul
.
tagName
===
'UL'
)
{
updateAllLabels
([...
ul
.
children
],
oldPath
,
newPath
)
}
})
}
function
expandPathTo
(
filePath
,
cb
)
{
var
label
=
self
.
element
.
querySelector
(
`label[data-path="
${
filePath
}
"]`
)
if
(
label
)
cb
()
var
arr
=
filePath
.
split
(
'/'
)
var
filename
=
arr
.
pop
()
var
path
=
arr
.
shift
()
var
fullpath
=
path
expand
(
fullpath
,
path
,
function
next
()
{
path
=
arr
.
shift
()
if
(
path
)
{
fullpath
+=
'/'
+
path
expand
(
fullpath
,
path
,
next
)
}
else
{
var
label
=
self
.
element
.
querySelector
(
`label[data-path$="
${
filename
}
"]`
)
focus
.
call
(
getLiFrom
(
label
),
{})
cb
()
}
})
function
expand
(
path
,
step
,
next
)
{
label
=
self
.
element
.
querySelector
(
`label[data-path="
${
step
}
"]`
)
||
self
.
element
.
querySelector
(
`label[data-path="
${
path
}
"]`
)
if
(
label
)
var
li
=
label
.
parentElement
.
parentElement
.
parentElement
if
(
!
label
||
path
===
step
&&
!
li
.
children
[
1
].
children
.
length
)
{
var
currentTree
=
self
.
treeView
.
nodeAt
(
path
)
var
caret
=
currentTree
.
parentElement
.
firstElementChild
.
firstElementChild
caret
.
click
()
next
()
}
else
next
()
}
}
function
fileFocus
(
path
)
{
function
fileFocus
(
path
)
{
var
filepath
=
appAPI
.
config
.
get
(
'currentFile'
)
var
filepath
=
appAPI
.
config
.
get
(
'currentFile'
)
if
(
filepath
===
path
)
return
if
(
filepath
===
path
)
return
expandPathTo
(
path
,
function
()
{
appAPI
.
config
.
set
(
'currentFile'
,
path
)
})
var
label
=
document
.
querySelector
(
`label[data-path="
${
path
}
"]`
)
if
(
label
)
{
appAPI
.
config
.
set
(
'currentFile'
,
path
)
}
}
}
function
fileRemoved
(
filepath
)
{
function
fileRemoved
(
filepath
)
{
...
@@ -377,19 +311,8 @@ function fileExplorer (appAPI, files) {
...
@@ -377,19 +311,8 @@ function fileExplorer (appAPI, files) {
function
fileRenamed
(
oldName
,
newName
,
isFolder
)
{
function
fileRenamed
(
oldName
,
newName
,
isFolder
)
{
var
li
=
getElement
(
oldName
)
var
li
=
getElement
(
oldName
)
if
(
li
)
{
if
(
li
)
li
.
parentElement
.
removeChild
(
li
)
oldName
=
oldName
.
split
(
'/'
)
fileFocus
(
newName
)
newName
=
newName
.
split
(
'/'
)
var
index
=
oldName
.
reduce
(
function
(
idx
,
key
,
i
)
{
return
oldName
[
i
]
!==
newName
[
i
]
?
i
:
idx
},
undefined
)
var
newKey
=
newName
[
index
]
var
oldPath
=
oldName
.
slice
(
0
,
index
+
1
).
join
(
'/'
)
li
=
getElement
(
oldPath
)
var
label
=
getLabelFrom
(
li
)
label
.
innerText
=
newKey
renameSubtree
(
label
,
true
)
}
}
}
function
fileRenamedError
(
error
)
{
function
fileRenamedError
(
error
)
{
...
...
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