fixed upload gist

pull/5370/head
LianaHus 5 years ago
parent ae415141bb
commit d399b366bb
  1. 23
      src/app/files/file-explorer.js

@ -218,12 +218,12 @@ function fileExplorer (localRegistry, files, menuItems) {
} else { } else {
const folderPath = extractExternalFolder(key) const folderPath = extractExternalFolder(key)
if (folderPath === 'browser/gists') { if (folderPath === 'browser/gists') {
const id = key.substr(key.lastIndexOf('/'), key.length - 1)
actions['Push changes to gist'] = () => { actions['Push changes to gist'] = () => {
const id = key.substr(key.lastIndexOf('/') + 1, key.length - 1)
modalDialogCustom.confirm( modalDialogCustom.confirm(
'Push back to Gist', 'Push back to Gist',
'Are you sure you want to push all your changes back to Gist?', 'Are you sure you want to push all your changes back to Gist?',
() => { this.toGist(id) }, () => { self.toGist(id) },
() => {} () => {}
) )
} }
@ -430,6 +430,7 @@ fileExplorer.prototype.toGist = function (id) {
let proccedResult = function (error, data) { let proccedResult = function (error, data) {
if (error) { if (error) {
modalDialogCustom.alert('Failed to manage gist: ' + error) modalDialogCustom.alert('Failed to manage gist: ' + error)
console.log('Failed to manage gist: ' + error)
} else { } else {
if (data.html_url) { if (data.html_url) {
modalDialogCustom.confirm('Gist is ready', `The gist is at ${data.html_url}. Would you like to open it in a new window?`, () => { modalDialogCustom.confirm('Gist is ready', `The gist is at ${data.html_url}. Would you like to open it in a new window?`, () => {
@ -513,14 +514,14 @@ fileExplorer.prototype.packageFiles = function (filesProvider, callback) {
else { else {
async.eachSeries(Object.keys(files), (path, cb) => { async.eachSeries(Object.keys(files), (path, cb) => {
filesProvider.get(path, (error, content) => { filesProvider.get(path, (error, content) => {
if (/^\s+$/.test(content) || !content.length) {
content = '// this line is added to create a gist. Empty file is not allowed.'
}
if (error) cb(error) if (error) cb(error)
else { else if (/^\s+$/.test(content) || !content.length) {
content = '// this line is added to create a gist. Empty file is not allowed.'
if (!error) {
ret[path] = { content } ret[path] = { content }
cb() cb()
} }
}
}) })
}, (error) => { }, (error) => {
callback(error, ret) callback(error, ret)
@ -559,16 +560,6 @@ fileExplorer.prototype.copyFiles = function () {
} }
} }
// ------------------ gist publish --------------
fileExplorer.prototype.updateGist = function () {
const gistId = this.files.id
if (!gistId) {
tooltip('no gist content is currently loaded.')
} else {
this.toGist(gistId)
}
}
fileExplorer.prototype.createNewFile = function () { fileExplorer.prototype.createNewFile = function () {
let self = this let self = this
modalDialogCustom.prompt('Create new file', 'File Path (Untitled.sol, Folder1/Untitled.sol)', 'Untitled.sol', (input) => { modalDialogCustom.prompt('Create new file', 'File Path (Untitled.sol, Folder1/Untitled.sol)', 'Untitled.sol', (input) => {

Loading…
Cancel
Save