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
0cd50b5f
Commit
0cd50b5f
authored
Sep 26, 2019
by
LianaHus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added Discard changes for external folder. removed readonly.
parent
472cabb0
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
90 additions
and
42 deletions
+90
-42
compiler-imports.js
src/app/compiler/compiler-imports.js
+9
-1
file-explorer.js
src/app/files/file-explorer.js
+18
-15
fileManager.js
src/app/files/fileManager.js
+5
-1
fileProvider.js
src/app/files/fileProvider.js
+54
-21
compile-tab.js
src/app/tabs/compile-tab.js
+2
-2
compileTab.js
src/app/tabs/compileTab/compileTab.js
+1
-1
landing-page.js
src/app/ui/landing-page/landing-page.js
+1
-1
No files found.
src/app/compiler/compiler-imports.js
View file @
0cd50b5f
...
@@ -110,10 +110,18 @@ module.exports = class CompilerImports extends Plugin {
...
@@ -110,10 +110,18 @@ module.exports = class CompilerImports extends Plugin {
})
})
}
}
import
(
url
,
loadingCb
,
cb
)
{
import
(
url
,
force
,
loadingCb
,
cb
)
{
if
(
typeof
force
!==
'boolean'
)
{
let
temp
=
loadingCb
loadingCb
=
force
cb
=
temp
force
=
false
}
if
(
!
loadingCb
)
loadingCb
=
()
=>
{}
if
(
!
loadingCb
)
loadingCb
=
()
=>
{}
if
(
!
cb
)
cb
=
()
=>
{}
var
self
=
this
var
self
=
this
if
(
force
)
delete
this
.
previouslyHandled
[
url
]
var
imported
=
this
.
previouslyHandled
[
url
]
var
imported
=
this
.
previouslyHandled
[
url
]
if
(
imported
)
{
if
(
imported
)
{
return
cb
(
null
,
imported
.
content
,
imported
.
cleanUrl
,
imported
.
type
,
url
)
return
cb
(
null
,
imported
.
content
,
imported
.
cleanUrl
,
imported
.
type
,
url
)
...
...
src/app/files/file-explorer.js
View file @
0cd50b5f
...
@@ -194,17 +194,29 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -194,17 +194,29 @@ function fileExplorer (localRegistry, files, menuItems) {
if
(
self
.
files
.
readonly
)
return
if
(
self
.
files
.
readonly
)
return
if
(
key
===
self
.
files
.
type
)
return
if
(
key
===
self
.
files
.
type
)
return
MENU_HANDLE
&&
MENU_HANDLE
.
hide
(
null
,
true
)
MENU_HANDLE
&&
MENU_HANDLE
.
hide
(
null
,
true
)
MENU_HANDLE
=
contextMenu
(
event
,
{
let
actions
=
{}
'Rename'
:
()
=>
{
const
provider
=
self
.
_deps
.
fileManager
.
fileProviderOf
(
key
)
if
(
provider
.
isExternalFolder
(
key
))
{
actions
[
'Discard changes'
]
=
()
=>
{
modalDialogCustom
.
confirm
(
'Discard changes'
,
'Are you sure you want to discard all your changes?'
,
()
=>
{
files
.
discardChanges
(
key
)
},
()
=>
{}
)
}
}
else
{
actions
[
'Rename'
]
=
()
=>
{
if
(
self
.
files
.
readonly
)
{
return
tooltip
(
'cannot rename folder. '
+
self
.
files
.
type
+
' is a read only explorer'
)
}
if
(
self
.
files
.
readonly
)
{
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
+
'"]'
)
if
(
name
)
editModeOn
(
name
)
if
(
name
)
editModeOn
(
name
)
},
}
'Delete'
:
()
=>
{
}
actions
[
'Delete'
]
=
()
=>
{
if
(
self
.
files
.
readonly
)
{
return
tooltip
(
'cannot delete folder. '
+
self
.
files
.
type
+
' is a read only explorer'
)
}
if
(
self
.
files
.
readonly
)
{
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?'
,
()
=>
{
files
.
remove
(
key
)
},
()
=>
{})
}
}
}
)
MENU_HANDLE
=
contextMenu
(
event
,
actions
)
})
})
self
.
treeView
.
event
.
register
(
'leafRightClick'
,
function
(
key
,
data
,
label
,
event
)
{
self
.
treeView
.
event
.
register
(
'leafRightClick'
,
function
(
key
,
data
,
label
,
event
)
{
...
@@ -212,7 +224,7 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -212,7 +224,7 @@ 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
)
if
(
!
provider
.
is
ReadOnly
(
key
))
{
if
(
!
provider
.
is
ExternalFolder
(
key
))
{
actions
[
'Rename'
]
=
()
=>
{
actions
[
'Rename'
]
=
()
=>
{
if
(
self
.
files
.
readonly
)
{
return
tooltip
(
'cannot rename file. '
+
self
.
files
.
type
+
' is a read only explorer'
)
}
if
(
self
.
files
.
readonly
)
{
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
+
'"]'
)
...
@@ -226,15 +238,6 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -226,15 +238,6 @@ function fileExplorer (localRegistry, files, menuItems) {
()
=>
{}
()
=>
{}
)
)
}
}
}
else
{
actions
[
'Delete from remix'
]
=
()
=>
{
modalDialogCustom
.
confirm
(
'Delete from remix'
,
'Are you sure you want to delete this file from remix?'
,
()
=>
{
files
.
remove
(
key
)
},
()
=>
{}
)
}
}
}
MENU_HANDLE
=
contextMenu
(
event
,
actions
)
MENU_HANDLE
=
contextMenu
(
event
,
actions
)
})
})
...
...
src/app/files/fileManager.js
View file @
0cd50b5f
...
@@ -49,7 +49,7 @@ class FileManager extends Plugin {
...
@@ -49,7 +49,7 @@ class FileManager extends Plugin {
localhostExplorer
:
this
.
_components
.
registry
.
get
(
'fileproviders/localhost'
).
api
,
localhostExplorer
:
this
.
_components
.
registry
.
get
(
'fileproviders/localhost'
).
api
,
filesProviders
:
this
.
_components
.
registry
.
get
(
'fileproviders'
).
api
filesProviders
:
this
.
_components
.
registry
.
get
(
'fileproviders'
).
api
}
}
this
.
_deps
.
browserExplorer
.
event
.
register
(
'fileChanged'
,
(
path
)
=>
{
this
.
fileChangedEvent
(
path
)
})
this
.
_deps
.
browserExplorer
.
event
.
register
(
'fileRenamed'
,
(
oldName
,
newName
,
isFolder
)
=>
{
this
.
fileRenamedEvent
(
oldName
,
newName
,
isFolder
)
})
this
.
_deps
.
browserExplorer
.
event
.
register
(
'fileRenamed'
,
(
oldName
,
newName
,
isFolder
)
=>
{
this
.
fileRenamedEvent
(
oldName
,
newName
,
isFolder
)
})
this
.
_deps
.
localhostExplorer
.
event
.
register
(
'fileRenamed'
,
(
oldName
,
newName
,
isFolder
)
=>
{
this
.
fileRenamedEvent
(
oldName
,
newName
,
isFolder
)
})
this
.
_deps
.
localhostExplorer
.
event
.
register
(
'fileRenamed'
,
(
oldName
,
newName
,
isFolder
)
=>
{
this
.
fileRenamedEvent
(
oldName
,
newName
,
isFolder
)
})
this
.
_deps
.
browserExplorer
.
event
.
register
(
'fileRemoved'
,
(
path
)
=>
{
this
.
fileRemovedEvent
(
path
)
})
this
.
_deps
.
browserExplorer
.
event
.
register
(
'fileRemoved'
,
(
path
)
=>
{
this
.
fileRemovedEvent
(
path
)
})
...
@@ -58,6 +58,10 @@ class FileManager extends Plugin {
...
@@ -58,6 +58,10 @@ class FileManager extends Plugin {
this
.
_deps
.
localhostExplorer
.
event
.
register
(
'closed'
,
(
event
)
=>
{
this
.
removeTabsOf
(
this
.
_deps
.
localhostExplorer
)
})
this
.
_deps
.
localhostExplorer
.
event
.
register
(
'closed'
,
(
event
)
=>
{
this
.
removeTabsOf
(
this
.
_deps
.
localhostExplorer
)
})
}
}
fileChangedEvent
(
path
)
{
this
.
syncEditor
(
path
)
}
fileRenamedEvent
(
oldName
,
newName
,
isFolder
)
{
fileRenamedEvent
(
oldName
,
newName
,
isFolder
)
{
if
(
!
isFolder
)
{
if
(
!
isFolder
)
{
this
.
_deps
.
config
.
set
(
'currentFile'
,
''
)
this
.
_deps
.
config
.
set
(
'currentFile'
,
''
)
...
...
src/app/files/fileProvider.js
View file @
0cd50b5f
'use strict'
'use strict'
var
EventManager
=
require
(
'../../lib/events'
)
const
CompilerImport
=
require
(
'../compiler/compiler-imports'
)
const
EventManager
=
require
(
'../../lib/events'
)
const
modalDialogCustom
=
require
(
'../ui/modal-dialog-custom'
)
const
tooltip
=
require
(
'../ui/tooltip'
)
const
remixLib
=
require
(
'remix-lib'
)
const
Storage
=
remixLib
.
Storage
class
FileProvider
{
class
FileProvider
{
constructor
(
name
)
{
constructor
(
name
)
{
this
.
event
=
new
EventManager
()
this
.
event
=
new
EventManager
()
this
.
type
=
name
this
.
type
=
name
this
.
normalizedNames
=
{}
// contains the raw url associated with the displayed path
this
.
providerExternalsStorage
=
new
Storage
(
'providerExternals:'
)
this
.
readonlyItems
=
[
'browser'
]
this
.
externalFolders
=
[
this
.
type
+
'/swarm'
,
this
.
type
+
'/ipfs'
,
this
.
type
+
'/github'
,
this
.
type
+
'/gist'
,
this
.
type
+
'/https'
]
}
addNormalizedName
(
path
,
url
)
{
this
.
providerExternalsStorage
.
set
(
this
.
type
+
'/'
+
path
,
url
)
}
removeNormalizedName
(
path
)
{
this
.
providerExternalsStorage
.
remove
(
path
)
}
normalizedNameExists
(
path
)
{
return
this
.
providerExternalsStorage
.
exists
(
path
)
}
getNormalizedName
(
path
)
{
return
this
.
providerExternalsStorage
.
get
(
path
)
}
isExternalFolder
(
path
)
{
return
this
.
externalFolders
.
includes
(
path
)
}
discardChanges
(
path
)
{
this
.
remove
(
path
)
const
compilerImport
=
new
CompilerImport
()
this
.
providerExternalsStorage
.
keys
().
map
(
value
=>
{
if
(
value
.
indexOf
(
path
)
===
0
)
{
compilerImport
.
import
(
this
.
getNormalizedName
(
value
),
true
,
(
loadingMsg
)
=>
{
tooltip
(
loadingMsg
)
},
(
error
,
content
,
cleanUrl
,
type
,
url
)
=>
{
if
(
error
)
{
modalDialogCustom
.
alert
(
error
)
}
else
{
this
.
addExternal
(
type
+
'/'
+
cleanUrl
,
content
,
url
)
}
}
)
}
})
}
}
exists
(
path
,
cb
)
{
exists
(
path
,
cb
)
{
...
@@ -25,7 +71,7 @@ class FileProvider {
...
@@ -25,7 +71,7 @@ class FileProvider {
get
(
path
,
cb
)
{
get
(
path
,
cb
)
{
cb
=
cb
||
function
()
{}
cb
=
cb
||
function
()
{}
if
(
this
.
normalizedName
s
[
path
])
path
=
this
.
normalizedNames
[
path
]
// ensure we actually use the normalized path from here
if
(
this
.
normalizedName
Exists
[
path
])
path
=
this
.
getNormalizedName
(
path
)
// ensure we actually use the normalized path from here
var
unprefixedpath
=
this
.
removePrefix
(
path
)
var
unprefixedpath
=
this
.
removePrefix
(
path
)
var
exists
=
window
.
remixFileSystem
.
existsSync
(
unprefixedpath
)
var
exists
=
window
.
remixFileSystem
.
existsSync
(
unprefixedpath
)
if
(
!
exists
)
return
cb
(
null
,
null
)
if
(
!
exists
)
return
cb
(
null
,
null
)
...
@@ -36,10 +82,6 @@ class FileProvider {
...
@@ -36,10 +82,6 @@ class FileProvider {
set
(
path
,
content
,
cb
)
{
set
(
path
,
content
,
cb
)
{
cb
=
cb
||
function
()
{}
cb
=
cb
||
function
()
{}
if
(
this
.
isReadOnly
(
path
))
{
cb
(
new
Error
(
'It is not possible to modify a readonly item'
))
return
false
}
var
unprefixedpath
=
this
.
removePrefix
(
path
)
var
unprefixedpath
=
this
.
removePrefix
(
path
)
var
exists
=
window
.
remixFileSystem
.
existsSync
(
unprefixedpath
)
var
exists
=
window
.
remixFileSystem
.
existsSync
(
unprefixedpath
)
if
(
!
exists
&&
unprefixedpath
.
indexOf
(
'/'
)
!==
-
1
)
{
if
(
!
exists
&&
unprefixedpath
.
indexOf
(
'/'
)
!==
-
1
)
{
...
@@ -70,26 +112,17 @@ class FileProvider {
...
@@ -70,26 +112,17 @@ class FileProvider {
return
true
return
true
}
}
addReadOnly
(
path
,
content
,
url
)
{
// this will not add a folder as readonly but keep the original url to be able to restore it later
this
.
readonlyItems
.
push
(
this
.
type
+
'/'
+
path
)
addExternal
(
path
,
content
,
url
)
{
if
(
!
url
)
this
.
normalizedNames
[
url
]
=
path
if
(
url
)
this
.
addNormalizedName
(
path
,
url
)
return
this
.
set
(
path
,
content
)
return
this
.
set
(
path
,
content
)
}
}
isReadOnly
(
path
)
{
isReadOnly
(
path
)
{
return
this
.
readonlyItems
.
includes
(
path
)
return
false
}
_removeFromReadonlyList
(
path
)
{
const
indexToRemove
=
this
.
readonlyItems
.
indexOf
(
path
)
if
(
indexToRemove
!==
-
1
)
{
this
.
readonlyItems
.
splice
(
indexToRemove
,
1
)
}
}
}
remove
(
path
)
{
remove
(
path
)
{
this
.
_removeFromReadonlyList
(
path
)
var
unprefixedpath
=
this
.
removePrefix
(
path
)
var
unprefixedpath
=
this
.
removePrefix
(
path
)
if
(
!
this
.
_exists
(
unprefixedpath
))
{
if
(
!
this
.
_exists
(
unprefixedpath
))
{
return
false
return
false
...
...
src/app/tabs/compile-tab.js
View file @
0cd50b5f
...
@@ -313,7 +313,7 @@ class CompileTab extends ViewPlugin {
...
@@ -313,7 +313,7 @@ class CompileTab extends ViewPlugin {
modalDialogCustom
.
alert
(
yo
`<span>Metadata published successfully.<br> <pre>
${
result
}
</pre> </span>`
)
modalDialogCustom
.
alert
(
yo
`<span>Metadata published successfully.<br> <pre>
${
result
}
</pre> </span>`
)
}
}
},
(
item
)
=>
{
// triggered each time there's a new verified publish (means hash correspond)
},
(
item
)
=>
{
// triggered each time there's a new verified publish (means hash correspond)
this
.
fileProvider
.
add
ReadOnly
(
'swarm/'
+
item
.
hash
,
item
.
content
)
this
.
fileProvider
.
add
External
(
'swarm/'
+
item
.
hash
,
item
.
content
)
})
})
}
else
{
}
else
{
publishOnIpfs
(
contract
,
this
.
fileManager
,
function
(
err
,
uploaded
)
{
publishOnIpfs
(
contract
,
this
.
fileManager
,
function
(
err
,
uploaded
)
{
...
@@ -330,7 +330,7 @@ class CompileTab extends ViewPlugin {
...
@@ -330,7 +330,7 @@ class CompileTab extends ViewPlugin {
modalDialogCustom
.
alert
(
yo
`<span>Metadata published successfully.<br> <pre>
${
result
}
</pre> </span>`
)
modalDialogCustom
.
alert
(
yo
`<span>Metadata published successfully.<br> <pre>
${
result
}
</pre> </span>`
)
}
}
},
(
item
)
=>
{
// triggered each time there's a new verified publish (means hash correspond)
},
(
item
)
=>
{
// triggered each time there's a new verified publish (means hash correspond)
this
.
fileProvider
.
add
ReadOnly
(
'ipfs/'
+
item
.
hash
,
item
.
content
)
this
.
fileProvider
.
add
External
(
'ipfs/'
+
item
.
hash
,
item
.
content
)
})
})
}
}
}
}
...
...
src/app/tabs/compileTab/compileTab.js
View file @
0cd50b5f
...
@@ -93,7 +93,7 @@ class CompileTab {
...
@@ -93,7 +93,7 @@ class CompileTab {
if
(
error
)
return
cb
(
error
)
if
(
error
)
return
cb
(
error
)
if
(
this
.
fileProvider
)
{
if
(
this
.
fileProvider
)
{
this
.
fileProvider
.
add
ReadOnly
(
cleanUrl
,
content
,
url
)
this
.
fileProvider
.
add
External
(
cleanUrl
,
content
,
url
)
}
}
cb
(
null
,
content
)
cb
(
null
,
content
)
})
})
...
...
src/app/ui/landing-page/landing-page.js
View file @
0cd50b5f
...
@@ -106,7 +106,7 @@ export class LandingPage extends ViewPlugin {
...
@@ -106,7 +106,7 @@ export class LandingPage extends ViewPlugin {
if
(
error
)
{
if
(
error
)
{
modalDialogCustom
.
alert
(
error
)
modalDialogCustom
.
alert
(
error
)
}
else
{
}
else
{
fileProviders
[
'browser'
].
add
ReadOnly
(
type
+
'/'
+
cleanUrl
,
content
,
url
)
fileProviders
[
'browser'
].
add
External
(
type
+
'/'
+
cleanUrl
,
content
,
url
)
this
.
verticalIcons
.
select
(
'fileExplorers'
)
this
.
verticalIcons
.
select
(
'fileExplorers'
)
}
}
}
}
...
...
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