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
2c03f8ba
Commit
2c03f8ba
authored
Apr 24, 2017
by
chriseth
Committed by
GitHub
Apr 24, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #525 from ethereum/fileExplorerCleanup1
Fix readonly files in file explorer and sync to tabs.
parents
7a64989b
2c3591a7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
43 deletions
+22
-43
app.js
src/app.js
+12
-26
file-explorer.js
src/app/file-explorer.js
+3
-7
files.js
src/app/files.js
+3
-6
storage.js
src/app/storage.js
+4
-4
No files found.
src/app.js
View file @
2c03f8ba
...
@@ -161,21 +161,6 @@ var run = function () {
...
@@ -161,21 +161,6 @@ var run = function () {
var
editor
=
new
Editor
(
document
.
getElementById
(
'input'
))
var
editor
=
new
Editor
(
document
.
getElementById
(
'input'
))
// ---------------- FilePanel --------------------
// ---------------- FilePanel --------------------
/****************************************************************************
var sources = {
'test/client/credit.sol': '',
'src/voting.sol': '',
'src/leasing.sol': '',
'src/gmbh/contract.sol': false,
'src/gmbh/test.sol': false,
'src/gmbh/company.sol': false,
'src/gmbh/node_modules/ballot.sol': false,
'src/ug/finance.sol': false,
'app/solidity/mode.sol': true,
'app/ethereum/constitution.sol': true
}
Object.keys(sources).forEach(function (key) { files.set(key, sources[key]) })
/****************************************************************************/
var
css
=
csjs
`
var
css
=
csjs
`
.filepanel {
.filepanel {
display : flex;
display : flex;
...
@@ -187,7 +172,7 @@ var run = function () {
...
@@ -187,7 +172,7 @@ var run = function () {
var
FilePanelAPI
=
{
var
FilePanelAPI
=
{
createName
:
createNonClashingName
,
createName
:
createNonClashingName
,
switchToFile
:
switchToFile
,
switchToFile
:
switchToFile
,
ui
:
ui
.
event
event
:
this
.
event
}
}
var
el
=
new
FilePanel
(
FilePanelAPI
,
files
)
var
el
=
new
FilePanel
(
FilePanelAPI
,
files
)
filepanel
.
appendChild
(
el
)
filepanel
.
appendChild
(
el
)
...
@@ -215,7 +200,7 @@ var run = function () {
...
@@ -215,7 +200,7 @@ var run = function () {
})
})
api
.
register
(
'focus'
,
function
(
path
)
{
api
.
register
(
'focus'
,
function
(
path
)
{
[...
window
.
files
.
querySelectorAll
(
'.file .name'
)].
forEach
(
function
(
span
)
{
[...
window
.
files
.
querySelectorAll
(
'.file .name'
)].
forEach
(
function
(
span
)
{
if
(
span
.
innerText
===
path
)
switchToFile
(
path
)
// @TODO: scroll into view
if
(
span
.
innerText
===
path
)
switchToFile
(
path
)
})
})
})
})
files
.
event
.
register
(
'fileRenamed'
,
function
(
oldName
,
newName
)
{
files
.
event
.
register
(
'fileRenamed'
,
function
(
oldName
,
newName
)
{
...
@@ -224,7 +209,15 @@ var run = function () {
...
@@ -224,7 +209,15 @@ var run = function () {
})
})
})
})
files
.
event
.
register
(
'fileRemoved'
,
function
(
path
)
{
files
.
event
.
register
(
'fileRemoved'
,
function
(
path
)
{
if
(
path
===
ui
.
get
(
'currentFile'
))
ui
.
set
(
'currentFile'
,
''
)
if
(
path
===
ui
.
get
(
'currentFile'
))
{
ui
.
set
(
'currentFile'
,
''
)
switchToNextFile
()
}
editor
.
discard
(
path
)
refreshTabs
()
})
files
.
event
.
register
(
'fileAdded'
,
function
(
path
)
{
refreshTabs
()
})
})
// ------------------ gist publish --------------
// ------------------ gist publish --------------
...
@@ -342,10 +335,6 @@ var run = function () {
...
@@ -342,10 +335,6 @@ var run = function () {
if
(
confirm
(
'Are you sure you want to remove: '
+
name
+
' from local storage?'
))
{
if
(
confirm
(
'Are you sure you want to remove: '
+
name
+
' from local storage?'
))
{
if
(
!
files
.
remove
(
name
))
{
if
(
!
files
.
remove
(
name
))
{
alert
(
'Error while removing file'
)
alert
(
'Error while removing file'
)
}
else
{
ui
.
set
(
'currentFile'
,
''
)
switchToNextFile
()
editor
.
discard
(
name
)
}
}
}
}
return
false
return
false
...
@@ -363,6 +352,7 @@ var run = function () {
...
@@ -363,6 +352,7 @@ var run = function () {
}
else
{
}
else
{
editor
.
open
(
file
,
files
.
get
(
file
))
editor
.
open
(
file
,
files
.
get
(
file
))
}
}
self
.
event
.
trigger
(
'currentFileChanged'
,
[
file
])
}
}
function
switchToNextFile
()
{
function
switchToNextFile
()
{
...
@@ -394,10 +384,6 @@ var run = function () {
...
@@ -394,10 +384,6 @@ var run = function () {
}
}
$
(
'#input'
).
toggle
(
currentFileOpen
)
$
(
'#input'
).
toggle
(
currentFileOpen
)
$
(
'#output'
).
toggle
(
currentFileOpen
)
$
(
'#output'
).
toggle
(
currentFileOpen
)
$filesEl
.
animate
({
left
:
Math
.
max
((
0
-
activeFilePos
()
+
(
FILE_SCROLL_DELTA
/
2
)),
0
)
+
'px'
},
'slow'
,
function
()
{
reAdjust
()
})
}
}
var
$scrollerRight
=
$
(
'.scroller-right'
)
var
$scrollerRight
=
$
(
'.scroller-right'
)
...
...
src/app/file-explorer.js
View file @
2c03f8ba
...
@@ -37,7 +37,6 @@ module.exports = fileExplorer
...
@@ -37,7 +37,6 @@ module.exports = fileExplorer
function
fileExplorer
(
appAPI
,
files
)
{
function
fileExplorer
(
appAPI
,
files
)
{
var
fileEvents
=
files
.
event
var
fileEvents
=
files
.
event
var
appUI
=
appAPI
.
ui
var
tv
=
new
Treeview
({
var
tv
=
new
Treeview
({
extractData
:
function
(
value
,
tree
,
key
)
{
extractData
:
function
(
value
,
tree
,
key
)
{
var
newValue
=
{}
var
newValue
=
{}
...
@@ -76,11 +75,12 @@ function fileExplorer (appAPI, files) {
...
@@ -76,11 +75,12 @@ function fileExplorer (appAPI, files) {
</span>
</span>
`
`
appUI
.
register
(
'currentFile'
,
fileFocus
)
appAPI
.
event
.
register
(
'currentFileChanged'
,
(
newFile
)
=>
{
fileFocus
(
newFile
)
})
fileEvents
.
register
(
'fileRemoved'
,
fileRemoved
)
fileEvents
.
register
(
'fileRemoved'
,
fileRemoved
)
fileEvents
.
register
(
'fileRenamed'
,
fileRenamed
)
fileEvents
.
register
(
'fileRenamed'
,
fileRenamed
)
fileEvents
.
register
(
'fileAdded'
,
fileAdded
)
fileEvents
.
register
(
'fileAdded'
,
fileAdded
)
fileEvents
.
register
(
'fileChanged'
,
fileChanged
)
var
filepath
=
null
var
filepath
=
null
var
focusElement
=
null
var
focusElement
=
null
...
@@ -216,8 +216,6 @@ function fileExplorer (appAPI, files) {
...
@@ -216,8 +216,6 @@ function fileExplorer (appAPI, files) {
})
})
}
}
function
fileChanged
(
filepath
)
{
}
function
fileFocus
(
path
)
{
function
fileFocus
(
path
)
{
if
(
filepath
===
path
)
return
if
(
filepath
===
path
)
return
filepath
=
path
filepath
=
path
...
@@ -253,8 +251,6 @@ function fileExplorer (appAPI, files) {
...
@@ -253,8 +251,6 @@ function fileExplorer (appAPI, files) {
el
.
className
=
css
.
fileexplorer
el
.
className
=
css
.
fileexplorer
element
.
parentElement
.
replaceChild
(
el
,
element
)
element
.
parentElement
.
replaceChild
(
el
,
element
)
element
=
el
element
=
el
fileFocus
(
filepath
)
appAPI
.
switchToFile
(
filepath
)
}
}
element
.
api
=
api
element
.
api
=
api
...
...
src/app/files.js
View file @
2c03f8ba
...
@@ -138,12 +138,9 @@ function Files (storage) {
...
@@ -138,12 +138,9 @@ function Files (storage) {
var
tree
=
{}
var
tree
=
{}
var
self
=
this
var
self
=
this
storage
.
keys
().
forEach
(
function
(
path
)
{
// This does not include '.remix.config', because it is filtered
// NOTE: as a temporary measure do not show the config file
// inside list().
if
(
path
===
'.remix.config'
)
{
Object
.
keys
(
this
.
list
()).
forEach
(
function
(
path
)
{
return
}
hashmapize
(
tree
,
path
,
{
hashmapize
(
tree
,
path
,
{
'/readonly'
:
self
.
isReadOnly
(
path
),
'/readonly'
:
self
.
isReadOnly
(
path
),
'/content'
:
self
.
get
(
path
)
'/content'
:
self
.
get
(
path
)
...
...
src/app/storage.js
View file @
2c03f8ba
...
@@ -39,17 +39,17 @@ function Storage (prefix) {
...
@@ -39,17 +39,17 @@ function Storage (prefix) {
this
.
keys
=
function
()
{
this
.
keys
=
function
()
{
return
safeKeys
()
return
safeKeys
()
// filter any names not including
sol:
// filter any names not including
the prefix
.
filter
(
function
(
item
)
{
return
item
.
indexOf
(
prefix
,
0
)
===
0
})
.
filter
(
function
(
item
)
{
return
item
.
indexOf
(
prefix
,
0
)
===
0
})
// remove
sol:
from filename
// remove
prefix
from filename
.
map
(
function
(
item
)
{
return
item
.
replace
(
/^sol:/
,
''
)
})
.
map
(
function
(
item
)
{
return
item
.
substr
(
prefix
.
length
)
})
}
}
// on startup, upgrade the old storage layout
// on startup, upgrade the old storage layout
safeKeys
().
forEach
(
function
(
name
)
{
safeKeys
().
forEach
(
function
(
name
)
{
if
(
name
.
indexOf
(
'sol-cache-file-'
,
0
)
===
0
)
{
if
(
name
.
indexOf
(
'sol-cache-file-'
,
0
)
===
0
)
{
var
content
=
window
.
localStorage
.
getItem
(
name
)
var
content
=
window
.
localStorage
.
getItem
(
name
)
window
.
localStorage
.
setItem
(
name
.
replace
(
/^sol-cache-file-/
,
prefix
),
content
)
window
.
localStorage
.
setItem
(
name
.
replace
(
/^sol-cache-file-/
,
'sol:'
),
content
)
window
.
localStorage
.
removeItem
(
name
)
window
.
localStorage
.
removeItem
(
name
)
}
}
})
})
...
...
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