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
c953633b
Commit
c953633b
authored
May 01, 2018
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save the current gist instead of creating a new one over and over
parent
0ced992b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
17 deletions
+44
-17
app.js
src/app.js
+5
-2
file-panel.js
src/app/panels/file-panel.js
+39
-15
No files found.
src/app.js
View file @
c953633b
...
...
@@ -556,7 +556,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
})
// Add files received from remote instance (i.e. another remix-ide)
function
loadFiles
(
filesSet
,
fileProvider
)
{
function
loadFiles
(
filesSet
,
fileProvider
,
callback
)
{
if
(
!
fileProvider
)
fileProvider
=
'browser'
async
.
each
(
Object
.
keys
(
filesSet
),
(
file
,
callback
)
=>
{
...
...
@@ -573,6 +573,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
})
},
(
error
)
=>
{
if
(
!
error
)
fileManager
.
switchFile
()
if
(
callback
)
callback
(
error
)
})
}
...
...
@@ -597,7 +598,9 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
modalDialogCustom
.
alert
(
`Gist load error:
${
error
||
data
.
message
}
`
)
return
}
loadFiles
(
data
.
files
,
'gist'
)
loadFiles
(
data
.
files
,
'gist'
,
(
errorLoadingFile
)
=>
{
if
(
!
errorLoadingFile
)
filesProviders
[
'gist'
].
id
=
gistId
})
})
})
}
...
...
src/app/panels/file-panel.js
View file @
c953633b
...
...
@@ -8,6 +8,7 @@ var EventManager = remixLib.EventManager
var
FileExplorer
=
require
(
'../files/file-explorer'
)
var
modalDialog
=
require
(
'../ui/modaldialog'
)
var
modalDialogCustom
=
require
(
'../ui/modal-dialog-custom'
)
var
tooltip
=
require
(
'../ui/tooltip'
)
var
QueryParams
=
require
(
'../../lib/query-params'
)
var
queryParams
=
new
QueryParams
()
var
helper
=
require
(
'../../lib/helper'
)
...
...
@@ -80,10 +81,10 @@ function filepanel (appAPI, filesProvider) {
</label>
</span>
`
:
''
}
<span class="
${
css
.
gist
}
" title="Publish all [browser] explorer
open files to an anonymous
github gist" onclick=
${()
=>
publishToGist
(
'browser'
)}
>
<span class="
${
css
.
gist
}
" title="Publish all [browser] explorer
files to a
github gist" onclick=
${()
=>
publishToGist
(
'browser'
)}
>
<i class="fa fa-github"></i>
</span>
<span class="
${
css
.
gist
}
" title="
Publish all [gist] explorer open files to an anonymous github gist" onclick=
${()
=>
publishToGist
(
'gist'
)}
>
<span class="
${
css
.
gist
}
" title="
Update the current [gist] explorer" onclick=
${()
=>
updateGist
(
)}
>
<i class="fa fa-github"></i>
</span>
<span class="
${
css
.
copyFiles
}
" title="Copy all files to another instance of Remix IDE" onclick=
${
copyFiles
}
>
...
...
@@ -273,22 +274,22 @@ function filepanel (appAPI, filesProvider) {
// ------------------ gist publish --------------
function
publishToGist
(
fileProviderName
)
{
function
cb
(
error
,
data
)
{
if
(
error
)
{
modalDialogCustom
.
alert
(
'Failed to create gist: '
+
error
)
}
else
{
if
(
data
.
html_url
)
{
modalDialogCustom
.
confirm
(
null
,
`Created a gist at
${
data
.
html_url
}
. Would you like to open it in a new window?`
,
()
=>
{
window
.
open
(
data
.
html_url
,
'_blank'
)
})
function
updateGist
()
{
var
gistId
=
filesProvider
[
'gist'
].
id
if
(
!
gistId
)
{
tooltip
(
'no gist content is currently loaded.'
)
}
else
{
modalDialogCustom
.
alert
(
data
.
message
+
' '
+
data
.
documentation_url
+
' '
+
JSON
.
stringify
(
data
.
errors
,
null
,
'
\
t'
)
)
toGist
(
'gist'
,
gistId
)
}
}
function
publishToGist
(
fileProviderName
)
{
modalDialogCustom
.
confirm
(
null
,
'Are you very sure you want to publish all your files anonymously as a public gist on github.com?'
,
()
=>
{
toGist
(
fileProviderName
)
})
}
function
toGist
(
)
{
function
toGist
(
fileProviderName
,
id
)
{
packageFiles
(
filesProvider
[
fileProviderName
],
(
error
,
packaged
)
=>
{
if
(
error
)
{
console
.
log
(
error
)
...
...
@@ -302,6 +303,18 @@ function filepanel (appAPI, filesProvider) {
var
gists
=
new
Gists
({
token
:
tokenAccess
})
if
(
id
)
{
tooltip
(
'Saving gist ('
+
id
+
') ...'
)
gists
.
edit
({
description
:
description
,
public
:
true
,
files
:
packaged
,
id
:
id
},
(
error
,
result
)
=>
{
cb
(
error
,
result
)
})
}
else
{
tooltip
(
'Creating a new gist ...'
)
gists
.
create
({
description
:
description
,
public
:
true
,
...
...
@@ -311,11 +324,22 @@ function filepanel (appAPI, filesProvider) {
})
}
}
}
})
}
modalDialogCustom
.
confirm
(
null
,
'Are you very sure you want to publish all your files anonymously as a public gist on github.com?'
,
()
=>
{
toGist
()
function
cb
(
error
,
data
)
{
if
(
error
)
{
modalDialogCustom
.
alert
(
'Failed to manage gist: '
+
error
)
}
else
{
if
(
data
.
html_url
)
{
modalDialogCustom
.
confirm
(
null
,
`The gist is at
${
data
.
html_url
}
. Would you like to open it in a new window?`
,
()
=>
{
window
.
open
(
data
.
html_url
,
'_blank'
)
})
}
else
{
modalDialogCustom
.
alert
(
data
.
message
+
' '
+
data
.
documentation_url
+
' '
+
JSON
.
stringify
(
data
.
errors
,
null
,
'
\
t'
))
}
}
}
// ------------------ copy files --------------
...
...
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