From 529420e74e52c3674ee15aea0504bf450d7fa802 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Fri, 15 Mar 2019 15:01:57 +0100 Subject: [PATCH] cleanup --- src/app/files/file-explorer.js | 6 +-- src/app/panels/file-panel.js | 23 ++++++++-- src/app/ui/landing-page/landing-page.js | 61 ++++++++++++++----------- 3 files changed, 57 insertions(+), 33 deletions(-) diff --git a/src/app/files/file-explorer.js b/src/app/files/file-explorer.js index 5a60d36ca6..98bc103966 100644 --- a/src/app/files/file-explorer.js +++ b/src/app/files/file-explorer.js @@ -63,8 +63,6 @@ function fileExplorer (localRegistry, files, menuItems) { fileManager: self._components.registry.get('filemanager').api } - self._components.registry.put(`fileexplorer${files.type}`, this) - // warn if file changed outside of Remix function remixdDialog () { return yo`
This file has been changed outside of Remix IDE.
` @@ -316,11 +314,11 @@ fileExplorer.prototype.init = function () { return this.container } -fileExplorer.prototype.publishToGist = function (fileProviderName) { +fileExplorer.prototype.publishToGist = function () { modalDialogCustom.confirm( null, 'Are you sure you want to publish all your files anonymously as a public gist on github.com?', - () => { this.toGist(fileProviderName) } + () => { this.toGist() } ) } diff --git a/src/app/panels/file-panel.js b/src/app/panels/file-panel.js index b820a4e00d..d63ecdacec 100644 --- a/src/app/panels/file-panel.js +++ b/src/app/panels/file-panel.js @@ -8,6 +8,8 @@ var css = require('./styles/file-panel-styles') import { ApiFactory } from 'remix-plugin' +var canUpload = window.File || window.FileReader || window.FileList || window.Blob + /* Overview of APIs: * fileManager: @args fileProviders (browser, shared-folder, swarm, github, etc ...) & config & editor @@ -38,16 +40,19 @@ module.exports = class Filepanel extends ApiFactory { config: self._components.registry.get('config').api, pluginManager: self._components.registry.get('pluginmanager').api } - var fileExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['browser']) + var fileExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['browser'], + ['createNewFile', 'publishToGist', 'copyFiles', canUpload ? 'uploadFile' : ''] + ) var fileSystemExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['localhost']) var swarmExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['swarm']) var githubExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['github']) - var gistExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['gist']) + var gistExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['gist'], ['updateGist']) var configExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['config']) var httpExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['http']) var httpsExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['https']) - self.remixdHandle = new RemixdHandle(fileSystemExplorer, self._deps.fileProviders['localhost']) + self.remixdHandle = new RemixdHandle(fileSystemExplorer, self._deps.fileProviders['localhost'], + self._deps.fileProviders['localhost'].isReadOnly ? ['createNewFile'] : []) // ----------------- editor panel ---------------------- self._compilerMetadata = new CompilerMetadata( @@ -134,5 +139,17 @@ module.exports = class Filepanel extends ApiFactory { self.render = function render () { return element } } + + get profile () { + return { + name: 'fileExplorers', + displayName: 'file explorers', + methods: [], + events: [], + icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xNjk2IDM4NHE0MCAwIDY4IDI4dDI4IDY4djEyMTZxMCA0MC0yOCA2OHQtNjggMjhoLTk2MHEtNDAgMC02OC0yOHQtMjgtNjh2LTI4OGgtNTQ0cS00MCAwLTY4LTI4dC0yOC02OHYtNjcycTAtNDAgMjAtODh0NDgtNzZsNDA4LTQwOHEyOC0yOCA3Ni00OHQ4OC0yMGg0MTZxNDAgMCA2OCAyOHQyOCA2OHYzMjhxNjgtNDAgMTI4LTQwaDQxNnptLTU0NCAyMTNsLTI5OSAyOTloMjk5di0yOTl6bS02NDAtMzg0bC0yOTkgMjk5aDI5OXYtMjk5em0xOTYgNjQ3bDMxNi0zMTZ2LTQxNmgtMzg0djQxNnEwIDQwLTI4IDY4dC02OCAyOGgtNDE2djY0MGg1MTJ2LTI1NnEwLTQwIDIwLTg4dDQ4LTc2em05NTYgODA0di0xMTUyaC0zODR2NDE2cTAgNDAtMjggNjh0LTY4IDI4aC00MTZ2NjQwaDg5NnoiLz48L3N2Zz4=', + description: ' - ', + kind: 'fileexplorer' + } + } } diff --git a/src/app/ui/landing-page/landing-page.js b/src/app/ui/landing-page/landing-page.js index 8735efea78..c2db4c43ad 100644 --- a/src/app/ui/landing-page/landing-page.js +++ b/src/app/ui/landing-page/landing-page.js @@ -48,31 +48,33 @@ export class LandingPage extends ApiFactory { constructor (appManager, appStore) { super() - /* - var actions1 = [ - {label: 'new file', type: `callback`, payload: () => { alert(`-new file created-`) }}, - {label: 'import from GitHub', type: `callback`, payload: () => { alert(`-imported from GitHub-`) }}, - {label: 'import from gist', type: `callback`, payload: () => { alert(`-imported from gist-`) }} - ] - - var actions2 = [ - {label: '...', type: `callback`, payload: () => { alert(`-...-`) }} - ] + this.sections = [] + /* var actions1 = [ + { label: 'New file', + type: 'callback', + payload: () => { + let fileManager = globalRegistry.get('fileexplorerbrowser').api + fileManager.creatNewFile() + } + }, + {label: 'Import from GitHub', type: `callback`, payload: () => { this.alert(`-imported from GitHub-`) }}, + {label: 'Import from gist', type: `callback`, payload: () => { this.alert(`-imported from gist-`) }} + ] */ var actions3 = [ {label: 'Remix documentation', type: `link`, payload: `https://remix.readthedocs.io/en/latest/#`}, {label: 'GitHub repository', type: `link`, payload: `https://github.com/ethereum/remix-ide`}, - {label: 'acces local file system (remixd)', type: `link`, payload: `https://remix.readthedocs.io/en/latest/tutorial_remixd_filesystem.html`}, + {label: 'Access local file system with remixd', type: `link`, payload: `https://remix.readthedocs.io/en/latest/tutorial_remixd_filesystem.html`}, {label: 'npm module for remixd', type: `link`, payload: `https://www.npmjs.com/package/remixd`}, - {label: 'medium posts', type: `link`, payload: `https://medium.com/remix-ide`}, - {label: 'tutorials', type: `link`, payload: `https://github.com/ethereum/remix-workshops`} + {label: 'Medium posts', type: `link`, payload: `https://medium.com/remix-ide`}, + {label: 'Tutorials', type: `link`, payload: `https://github.com/ethereum/remix-workshops`} ] var actions4 = [ {label: 'Remix plugins & modules', type: `link`, payload: `https://github.com/ethereum/remix-plugin/blob/master/readme.md`}, - {label: 'repository on GitHub', type: `link`, payload: `https://github.com/ethereum/remix-plugin`}, - {label: 'examples', type: `link`, payload: `https://github.com/ethereum/remix-plugin/tree/master/examples`}, - {label: 'build plugin for Remix', type: `link`, payload: `https://medium.com/remix-ide/build-a-plugin-for-remix-90d43b209c5a`} + {label: 'Repository on GitHub', type: `link`, payload: `https://github.com/ethereum/remix-plugin`}, + {label: 'Examples', type: `link`, payload: `https://github.com/ethereum/remix-plugin/tree/master/examples`}, + {label: 'Build a plugin for Remix', type: `link`, payload: `https://medium.com/remix-ide/build-a-plugin-for-remix-90d43b209c5a`} ] var actions5 = [ @@ -81,13 +83,12 @@ export class LandingPage extends ApiFactory { {label: 'Reddit', type: `link`, payload: `https://www.reddit.com/r/ethdev/search?q=remix&restrict_sr=1`} ] - var section1 = new Section('Start', actions1) - var section2 = new Section('Recent', actions2) - var section3 = new Section('Learn', actions3) - var section4 = new Section('Plugins', actions4) - var section5 = new Section('Help', actions5) - */ - const sectionsWorkspaces = [] + // var sectionStart = new Section('Start', actions1) + var sectionLearn = new Section('Learn', actions3) + var sectionPlugins = new Section('Plugins', actions4) + var sectionHelp = new Section('Help', actions5) + + var sectionsWorkspaces = [] sectionsWorkspaces.push({ label: 'Close All Modules', type: 'callback', @@ -97,10 +98,18 @@ export class LandingPage extends ApiFactory { .forEach((profile) => { appManager.deactivateOne(profile.name) }) }}) defaultWorkspaces(appManager).forEach((workspace) => { - sectionsWorkspaces.push({label: workspace.title, type: 'callback', payload: () => { workspace.activate() }}) + sectionsWorkspaces.push({ + label: workspace.title, + type: 'callback', + payload: () => { workspace.activate() } + }) }) - const sectionWorkspace = new Section('Workspaces', sectionsWorkspaces) - this.sections = sectionWorkspace + var sectionWorkspace = new Section('Workspaces', sectionsWorkspaces) + + this.sections.push(sectionWorkspace) + this.sections.push(sectionLearn) + this.sections.push(sectionPlugins) + this.sections.push(sectionHelp) } get profile () {