From b9524f167ed1f1d48d296f4e2529ea29d986c74a Mon Sep 17 00:00:00 2001 From: LianaHus Date: Mon, 2 Sep 2019 18:04:31 +0200 Subject: [PATCH] Renamed - browser-files-tree.js to filePovider.js, - browser-files.js to localStorageProvider.js, - basicReadOnlyExplorer.js to readonlyProvider.js, - shared-folder.js to remixdProvider.js --- src/app.js | 20 +++++++-------- src/app/files/NotPersistedExplorer.js | 2 +- src/app/files/fileManager.js | 8 +++--- .../{browser-files-tree.js => filePovider.js} | 4 +-- src/app/files/fileProviderBase.js | 25 +++++++++++++++++++ ...owser-files.js => localStorageProvider.js} | 4 +-- ...eadOnlyExplorer.js => readonlyProvider.js} | 4 +-- src/app/files/remixd-handle.js | 2 +- .../{shared-folder.js => remixdProvider.js} | 2 +- 9 files changed, 48 insertions(+), 23 deletions(-) rename src/app/files/{browser-files-tree.js => filePovider.js} (98%) create mode 100644 src/app/files/fileProviderBase.js rename src/app/files/{browser-files.js => localStorageProvider.js} (98%) rename src/app/files/{basicReadOnlyExplorer.js => readonlyProvider.js} (97%) rename src/app/files/{shared-folder.js => remixdProvider.js} (99%) diff --git a/src/app.js b/src/app.js index 67eaf965fd..305a565206 100644 --- a/src/app.js +++ b/src/app.js @@ -12,14 +12,14 @@ var { OffsetToLineColumnConverter } = require('./lib/offsetToLineColumnConverter var QueryParams = require('./lib/query-params') var GistHandler = require('./lib/gist-handler') var Storage = remixLib.Storage -var Browserfiles = require('./app/files/browser-files') -var SharedFolder = require('./app/files/shared-folder') +var LocalStorageProvider = require('./app/files/localStorageProvider') +var RemixdProvider = require('./app/files/remixdProvider') var Config = require('./config') var Renderer = require('./app/ui/renderer') var examples = require('./app/editor/example-contracts') var modalDialogCustom = require('./app/ui/modal-dialog-custom') var FileManager = require('./app/files/fileManager') -var BasicReadOnlyExplorer = require('./app/files/basicReadOnlyExplorer') +var ReadonlyProvider = require('./app/files/readonlyProvider') var NotPersistedExplorer = require('./app/files/NotPersistedExplorer') var toolTip = require('./app/ui/tooltip') var CompilerMetadata = require('./app/files/compiler-metadata') @@ -113,7 +113,7 @@ class App { // load file system self._components.filesProviders = {} - self._components.filesProviders['browser'] = new Browserfiles(fileStorage) + self._components.filesProviders['browser'] = new LocalStorageProvider(fileStorage) registry.put({api: self._components.filesProviders['browser'], name: 'fileproviders/browser'}) var remixd = new Remixd(65520) @@ -122,13 +122,13 @@ class App { if (message.error) toolTip(message.error) }) - self._components.filesProviders['localhost'] = new SharedFolder(remixd) - self._components.filesProviders['swarm'] = new BasicReadOnlyExplorer('swarm') - self._components.filesProviders['github'] = new BasicReadOnlyExplorer('github') + self._components.filesProviders['localhost'] = new RemixdProvider(remixd) + self._components.filesProviders['swarm'] = new ReadonlyProvider('swarm') + self._components.filesProviders['github'] = new ReadonlyProvider('github') self._components.filesProviders['gist'] = new NotPersistedExplorer('gist') - self._components.filesProviders['ipfs'] = new BasicReadOnlyExplorer('ipfs') - self._components.filesProviders['https'] = new BasicReadOnlyExplorer('https') - self._components.filesProviders['http'] = new BasicReadOnlyExplorer('http') + self._components.filesProviders['ipfs'] = new ReadonlyProvider('ipfs') + self._components.filesProviders['https'] = new ReadonlyProvider('https') + self._components.filesProviders['http'] = new ReadonlyProvider('http') registry.put({api: self._components.filesProviders['localhost'], name: 'fileproviders/localhost'}) registry.put({api: self._components.filesProviders['swarm'], name: 'fileproviders/swarm'}) registry.put({api: self._components.filesProviders['github'], name: 'fileproviders/github'}) diff --git a/src/app/files/NotPersistedExplorer.js b/src/app/files/NotPersistedExplorer.js index 2ab8b1d938..6bf1ff1f3a 100644 --- a/src/app/files/NotPersistedExplorer.js +++ b/src/app/files/NotPersistedExplorer.js @@ -1,5 +1,5 @@ 'use strict' -var ReadOnlyExplorer = require('./basicReadOnlyExplorer') +var ReadOnlyExplorer = require('./readonlyProvider') var toolTip = require('../ui/tooltip') class NotPersistedExplorer extends ReadOnlyExplorer { diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index bdfa2bb99d..8108b5bc7f 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -277,9 +277,9 @@ class FileManager extends Plugin { if (file) return _switchFile(file) else { var browserProvider = this._deps.filesProviders['browser'] - browserProvider.resolveDirectory('browser', (error, filesTree) => { + browserProvider.resolveDirectory('browser', (error, filesProvider) => { if (error) console.error(error) - var fileList = Object.keys(filesTree) + var fileList = Object.keys(filesProvider) if (fileList.length) { _switchFile(browserProvider.type + '/' + fileList[0]) } else { @@ -296,9 +296,9 @@ class FileManager extends Plugin { return new Promise((resolve, reject) => { const provider = this.fileProviderOf(path) if (!provider) return reject(`provider for path ${path} not found`) - provider.resolveDirectory(path, (error, filesTree) => { + provider.resolveDirectory(path, (error, filesProvider) => { if (error) reject(error) - resolve(filesTree) + resolve(filesProvider) }) }) } diff --git a/src/app/files/browser-files-tree.js b/src/app/files/filePovider.js similarity index 98% rename from src/app/files/browser-files-tree.js rename to src/app/files/filePovider.js index 6747ff32c5..a0c245bd56 100644 --- a/src/app/files/browser-files-tree.js +++ b/src/app/files/filePovider.js @@ -2,7 +2,7 @@ var EventManager = require('../../lib/events') -class FilesTree { +class FileProvider { constructor (name, storage) { this.event = new EventManager() this.storage = storage @@ -136,4 +136,4 @@ class FilesTree { } } -module.exports = FilesTree +module.exports = FileProvider diff --git a/src/app/files/fileProviderBase.js b/src/app/files/fileProviderBase.js new file mode 100644 index 0000000000..acd59fefa4 --- /dev/null +++ b/src/app/files/fileProviderBase.js @@ -0,0 +1,25 @@ +/* +this.exists = function (path, cb) {} + +this.init = function (cb) {} + +this.get = function (path, cb) {} + +this.set = function (path, content, cb) {} + +this.addReadOnly = function (path, content) {} + + +this.isReadOnly = function (path) {} + +this.remove = function (path) {} + +this.rename = function (oldPath, newPath, isFolder) {} + +this.resolveDirectory = function (path, callback) {} + +this.removePrefix = function (path) {} + + +updateRefs (path, type) {} +*/ \ No newline at end of file diff --git a/src/app/files/browser-files.js b/src/app/files/localStorageProvider.js similarity index 98% rename from src/app/files/browser-files.js rename to src/app/files/localStorageProvider.js index de84eb664f..2422f8dc5c 100644 --- a/src/app/files/browser-files.js +++ b/src/app/files/localStorageProvider.js @@ -2,7 +2,7 @@ var EventManager = require('../../lib/events') -function Files (storage) { +function LocalStorageProvider (storage) { var event = new EventManager() this.event = event var readonly = {} @@ -145,4 +145,4 @@ function Files (storage) { } } -module.exports = Files +module.exports = LocalStorageProvider diff --git a/src/app/files/basicReadOnlyExplorer.js b/src/app/files/readonlyProvider.js similarity index 97% rename from src/app/files/basicReadOnlyExplorer.js rename to src/app/files/readonlyProvider.js index 67a1a1f874..b6536d5a47 100644 --- a/src/app/files/basicReadOnlyExplorer.js +++ b/src/app/files/readonlyProvider.js @@ -1,7 +1,7 @@ 'use strict' var EventManager = require('../../lib/events') -class BasicReadOnlyExplorer { +class ReadonlyProvider { constructor (type) { this.event = new EventManager() this.files = {} @@ -99,4 +99,4 @@ class BasicReadOnlyExplorer { } } -module.exports = BasicReadOnlyExplorer +module.exports = ReadonlyProvider diff --git a/src/app/files/remixd-handle.js b/src/app/files/remixd-handle.js index 028a7540e0..b64799c6ed 100644 --- a/src/app/files/remixd-handle.js +++ b/src/app/files/remixd-handle.js @@ -21,7 +21,7 @@ const profile = { name: 'remixd', methods: [], events: [], - description: 'using Remixd daemon, allow to access file system', + description: 'Using Remixd daemon, allow to access file system', kind: 'other', version: packageJson.version } diff --git a/src/app/files/shared-folder.js b/src/app/files/remixdProvider.js similarity index 99% rename from src/app/files/shared-folder.js rename to src/app/files/remixdProvider.js index 0b712e8c78..bc484aeeb7 100644 --- a/src/app/files/shared-folder.js +++ b/src/app/files/remixdProvider.js @@ -2,7 +2,7 @@ var EventManager = require('../../lib/events') var pathtool = require('path') -module.exports = class SharedFolder { +module.exports = class RemixdProvider { constructor (remixd) { this.event = new EventManager() this._remixd = remixd