added dummy functions to interface

pull/1/head
LianaHus 5 years ago
parent ed4b6e1f53
commit a936bd94f7
  1. 39
      src/app/files/NotPersistedExplorer.js
  2. 37
      src/app/files/fileProviderBase.js
  3. 94
      src/app/files/readonlyProvider.js
  4. 4
      src/app/tabs/compile-tab.js

@ -1,39 +0,0 @@
'use strict'
var ReadonlyProvider = require('./readonlyProvider')
var toolTip = require('../ui/tooltip')
class NotPersistedExplorer extends ReadonlyProvider {
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

@ -1,23 +1,34 @@
/* 'use strict'
this.exists = function (path, cb) {} import * as packageJson from '../../../package.json'
this.init = function (cb) {} class FileProvider {
constructor () {
super(profile)
}
this.get = function (path, cb) {}
this.set = function (path, content, cb) {} exists (path, cb) { throw new Error(this.name + ' function is not implemented for ' + this.constructor.name + ' class'); }
this.addReadOnly = function (path, content) {} init (cb) { throw new Error(this.name + ' function is not implemented for ' + this.constructor.name + ' class'); }
this.isReadOnly = function (path) {} get (path, cb) { throw new Error(this.name + ' function is not implemented for ' + this.constructor.name + ' class'); }
this.remove = function (path) {} set (path, content, cb) { throw new Error(this.name + ' function is not implemented for ' + this.constructor.name + ' class'); }
this.rename = function (oldPath, newPath, isFolder) {} addReadOnly (path, content) { throw new Error(this.name + ' function is not implemented for ' + this.constructor.name + ' class'); }
this.resolveDirectory = function (path, callback) {} isReadOnly (path) { throw new Error(this.name + ' function is not implemented for ' + this.constructor.name + ' class'); }
this.removePrefix = function (path) {} remove (path) { throw new Error(this.name + ' function is not implemented for ' + this.constructor.name + ' class'); }
updateRefs (path, type) {} rename (oldPath, newPath, isFolder) { throw new Error(this.name + ' function is not implemented for ' + this.constructor.name + ' class'); }
*/
resolveDirectory (path, callback) { throw new Error(this.name + ' function is not implemented for ' + this.constructor.name + ' class'); }
removePrefix (path) { throw new Error(this.name + ' function is not implemented for ' + this.constructor.name + ' class'); }
updateRefs (path, type) { throw new Error(this.name + ' function is not implemented for ' + this.constructor.name + ' class'); }
}
module.exports = FileProvider

@ -1,102 +1,20 @@
'use strict' 'use strict'
var EventManager = require('../../lib/events') var ReadonlyProvider = require('./basicFileProvider')
class ReadonlyProvider { class ReadonlyProvider extends BasicFileProvider {
constructor (type) { constructor (type) {
this.event = new EventManager() super(type)
this.files = {}
this.paths = {}
this.normalizedNames = {} // contains the raw url associated with the displayed path
this.paths[type] = {}
this.type = type
this.readonly = true
}
close (cb) {
this.files = {}
cb()
}
init (cb) {
this.files = {}
}
exists (path, cb) {
if (!this.files) return cb(null, false)
var unprefixedPath = this.removePrefix(path)
cb(null, this.files[unprefixedPath] !== undefined)
}
get (path, cb) {
if (this.normalizedNames[path]) path = this.normalizedNames[path] // ensure we actually use the normalized path from here
var unprefixedPath = this.removePrefix(path)
var content = this.files[unprefixedPath]
if (!content) {
content = this.files[this.type + '/' + this.normalizedNames[path]]
}
if (cb) {
cb(null, content)
}
return content
}
set (path, content, cb) {
this.addReadOnly(path, content)
if (cb) cb()
return true
}
addReadOnly (path, content, rawPath) {
path = this.removePrefix(path)
try { // lazy try to format JSON
content = JSON.stringify(JSON.parse(content), null, '\t')
} catch (e) {}
if (!rawPath) rawPath = path
// splitting off the path in a tree structure, the json tree is used in `resolveDirectory`
var split = path
var folder = false
while (split.lastIndexOf('/') !== -1) {
var subitem = split.substring(split.lastIndexOf('/'))
split = split.substring(0, split.lastIndexOf('/'))
if (!this.paths[this.type + '/' + split]) {
this.paths[this.type + '/' + split] = {}
}
this.paths[this.type + '/' + split][split + subitem] = { isDirectory: folder }
folder = true
}
this.paths[this.type][split] = { isDirectory: folder }
this.files[path] = content
this.normalizedNames[rawPath] = path
this.event.trigger('fileAdded', [this.type + '/' + path, true])
return true
}
isReadOnly (path) {
return true
} }
remove (path) { remove (path) {
return false
} }
rename (oldPath, newPath, isFolder) { rename (oldPath, newPath, isFolder) {
return true
}
list () {
return this.files
} }
resolveDirectory (path, callback) { isReadOnly (path) {
var self = this return true
if (path[0] === '/') path = path.substring(1)
if (!path) return callback(null, { [self.type]: { } })
// we just return the json tree populated by `addReadOnly`
callback(null, this.paths[path])
}
removePrefix (path) {
return path.indexOf(this.type + '/') === 0 ? path.replace(this.type + '/', '') : path
} }
}
module.exports = ReadonlyProvider module.exports = ReadonlyProvider

@ -232,17 +232,19 @@ class CompileTab extends ViewPlugin {
<label class="border-0 input-group-text" for="compiledContracts">Contract</label> <label class="border-0 input-group-text" for="compiledContracts">Contract</label>
${selectEl} ${selectEl}
</div> </div>
<article class="${css.compilerArticle}"> <article class="${css.compilerArticle}">
<<<<<<< HEAD <<<<<<< HEAD
<button class="btn btn-secondary btn-block" title="Publish on Swarm" onclick="${() => { this.publish('swarm') }}"> <button class="btn btn-secondary btn-block" title="Publish on Swarm" onclick="${() => { this.publish('swarm') }}">
======= =======
<button class="btn btn-secondary btn-block" title="Publish on Swarm" onclick="${() => { this.publish() }}"> <button class="btn btn-secondary btn-block" title="Publish on Swarm" onclick="${() => { this.publish() }}">
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
======= =======
<i class="${css.copyIcon} fas fa-upload" aria-hidden="true"></i> <i class="${css.copyIcon} fas fa-upload" aria-hidden="true"></i>
>>>>>>> c353b990... standard >>>>>>> c353b990... standard
>>>>>>> c049685c... standard >>>>>>> c049685c... standard
=======
>>>>>>> 1eeb61d4... added dummy functions to interface
<span>Publish on Swarm</span> <span>Publish on Swarm</span>
<img id="swarmLogo" class="${css.storageLogo} ml-2" src="${swarmImg}"> <img id="swarmLogo" class="${css.storageLogo} ml-2" src="${swarmImg}">
</button> </button>

Loading…
Cancel
Save