change gist explorer to be non read only && redeploy to gist

pull/1/head
yann300 7 years ago
parent ceeeea8d0d
commit d8975cf429
  1. 3
      src/app.js
  2. 39
      src/app/files/NotPersistedExplorer.js
  3. 1
      src/app/files/basicReadOnlyExplorer.js
  4. 11
      src/app/panels/file-panel.js

@ -40,6 +40,7 @@ var FileManager = require('./app/files/fileManager')
var ContextualListener = require('./app/editor/contextualListener')
var ContextView = require('./app/editor/contextView')
var BasicReadOnlyExplorer = require('./app/files/basicReadOnlyExplorer')
var NotPersistedExplorer = require('./app/files/NotPersistedExplorer')
var toolTip = require('./app/ui/tooltip')
var CommandInterpreter = require('./lib/cmdInterpreter')
@ -128,7 +129,7 @@ class App {
self._api.filesProviders['localhost'] = new SharedFolder(remixd)
self._api.filesProviders['swarm'] = new BasicReadOnlyExplorer('swarm')
self._api.filesProviders['github'] = new BasicReadOnlyExplorer('github')
self._api.filesProviders['gist'] = new BasicReadOnlyExplorer('gist')
self._api.filesProviders['gist'] = new NotPersistedExplorer('gist')
self._api.filesProviders['ipfs'] = new BasicReadOnlyExplorer('ipfs')
self._view = {}
self._components = {}

@ -0,0 +1,39 @@
'use strict'
var ReadOnlyExplorer = require('./basicReadOnlyExplorer')
var toolTip = require('../ui/tooltip')
class NotPersistedExplorer extends ReadOnlyExplorer {
constructor (type) {
super(type)
this.readonly = false
}
remove (path) {
var unprefixedPath = this.removePrefix(path)
var folderPath = path.substring(0, path.lastIndexOf('/'))
if (this.paths[folderPath]) {
delete this.paths[folderPath][unprefixedPath]
delete this.files[path]
}
this.event.trigger('fileRemoved', [this.type + '/' + unprefixedPath])
return true
}
rename (oldPath, newPath, isFolder) {
if (isFolder) { return toolTip('folder renaming is not handled by this explorer') }
var unprefixedoldPath = this.removePrefix(oldPath)
var unprefixednewPath = this.removePrefix(newPath)
this.get(oldPath, (error, content) => {
if (error) return console.log(error)
this.remove(oldPath)
this.set(newPath, content)
this.event.trigger('fileRenamed', [this.type + '/' + unprefixedoldPath, this.type + '/' + unprefixednewPath, isFolder])
})
}
isReadOnly (path) {
return false
}
}
module.exports = NotPersistedExplorer

@ -76,7 +76,6 @@ class BasicReadOnlyExplorer {
}
remove (path) {
delete this.files[path]
}
rename (oldPath, newPath, isFolder) {

@ -80,7 +80,10 @@ function filepanel (appAPI, filesProvider) {
</label>
</span>
` : ''}
<span class="${css.gist}" title="Publish all open files to an anonymous github gist" onclick=${() => publishToGist(appAPI)}>
<span class="${css.gist}" title="Publish all [browser] explorer open files to an anonymous 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')}>
<i class="fa fa-github"></i>
</span>
<span class="${css.copyFiles}" title="Copy all files to another instance of Remix IDE" onclick=${copyFiles}>
@ -270,7 +273,7 @@ function filepanel (appAPI, filesProvider) {
// ------------------ gist publish --------------
function publishToGist () {
function publishToGist (fileProviderName) {
function cb (data) {
if (data instanceof Error) {
console.log('fail', data.message)
@ -288,7 +291,7 @@ function filepanel (appAPI, filesProvider) {
}
function toGist () {
packageFiles(filesProvider['browser'], (error, packaged) => {
packageFiles(filesProvider[fileProviderName], (error, packaged) => {
if (error) {
console.log(error)
modalDialogCustom.alert('Failed to create gist: ' + error)
@ -338,7 +341,7 @@ function filepanel (appAPI, filesProvider) {
// return all the files, except the temporary/readonly ones..
function packageFiles (filesProvider, callback) {
var ret = {}
filesProvider.resolveDirectory('browser', (error, files) => {
filesProvider.resolveDirectory(filesProvider.type, (error, files) => {
if (error) callback(error)
else {
async.eachSeries(Object.keys(files), (path, cb) => {

Loading…
Cancel
Save