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
8c5df6e3
Commit
8c5df6e3
authored
Feb 23, 2021
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix loading code sample
parent
33d95aa2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
25 deletions
+27
-25
app.js
apps/remix-ide/src/app.js
+0
-10
file-panel.js
apps/remix-ide/src/app/panels/file-panel.js
+27
-15
No files found.
apps/remix-ide/src/app.js
View file @
8c5df6e3
...
...
@@ -443,15 +443,5 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
migrateToWorkspace
(
fileManager
)
filePanel
.
initWorkspace
()
if
(
params
.
code
)
{
try
{
const
path
=
'browser/.code-sample/contract.sol'
await
fileManager
.
writeFile
(
path
,
atob
(
params
.
code
))
await
fileManager
.
openFile
(
path
)
}
catch
(
e
)
{
console
.
error
(
e
)
}
}
if
(
params
.
embed
)
framingService
.
embed
()
}
apps/remix-ide/src/app/panels/file-panel.js
View file @
8c5df6e3
...
...
@@ -5,6 +5,7 @@ import React from 'react' // eslint-disable-line
import
ReactDOM
from
'react-dom'
import
{
FileExplorer
}
from
'@remix-ui/file-explorer'
// eslint-disable-line
import
'./styles/file-panel-styles.css'
var
ethutil
=
require
(
'ethereumjs-util'
)
var
yo
=
require
(
'yo-yo'
)
var
EventManager
=
require
(
'../../lib/events'
)
var
{
RemixdHandle
}
=
require
(
'../files/remixd-handle.js'
)
...
...
@@ -104,27 +105,38 @@ module.exports = class Filepanel extends ViewPlugin {
this
.
renderComponent
()
}
initWorkspace
()
{
async
initWorkspace
()
{
const
workspacesPath
=
this
.
_deps
.
fileProviders
.
workspace
.
workspacesPath
const
queryParams
=
new
QueryParams
()
const
params
=
queryParams
.
get
()
// get the file from gist
const
gistHandler
=
new
GistHandler
()
const
loadedFromGist
=
gistHandler
.
loadFromGist
(
params
,
this
.
_deps
.
fileManager
)
if
(
!
loadedFromGist
)
{
// insert example contracts if there are no files to show
t
his
.
_deps
.
fileProviders
.
browser
.
resolveDirectory
(
'/'
,
async
(
error
,
filesList
)
=>
{
if
(
error
)
console
.
error
(
error
)
if
(
Object
.
keys
(
filesList
).
length
===
0
)
{
const
workspacesPath
=
this
.
_deps
.
fileProviders
.
workspace
.
workspacesPath
for
(
const
file
in
examples
)
{
await
this
.
_deps
.
fileManager
.
writeFile
(
'browser/'
+
workspacesPath
+
'/default_workspace/'
+
examples
[
file
].
name
,
examples
[
file
].
content
)
}
this
.
setWorkspace
(
'default_workspace'
)
}
}
)
}
else
{
this
.
setWorkspace
(
'gists'
)
if
(
loadedFromGist
)
return
if
(
params
.
code
)
{
t
ry
{
await
this
.
_deps
.
fileManager
.
createWorkspace
(
'code-sample'
)
var
hash
=
ethutil
.
bufferToHex
(
ethutil
.
keccak
(
params
.
code
))
const
fileName
=
'contract-'
+
hash
.
replace
(
'0x'
,
''
).
substring
(
0
,
10
)
+
'.sol'
const
path
=
'browser/'
+
workspacesPath
+
'/code-sample/'
+
fileName
await
this
.
_deps
.
fileManager
.
writeFile
(
path
,
atob
(
params
.
code
)
)
this
.
setWorkspace
(
'code-sample'
)
await
this
.
_deps
.
fileManager
.
openFile
(
path
)
}
catch
(
e
)
{
console
.
error
(
e
)
}
return
}
// insert example contracts if there are no files to show
this
.
_deps
.
fileProviders
.
browser
.
resolveDirectory
(
'/'
,
async
(
error
,
filesList
)
=>
{
if
(
error
)
console
.
error
(
error
)
if
(
Object
.
keys
(
filesList
).
length
===
0
)
{
for
(
const
file
in
examples
)
{
await
this
.
_deps
.
fileManager
.
writeFile
(
'browser/'
+
workspacesPath
+
'/default_workspace/'
+
examples
[
file
].
name
,
examples
[
file
].
content
)
}
this
.
setWorkspace
(
'default_workspace'
)
}
})
}
refreshWorkspacesList
()
{
...
...
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