From 26dc1a84bb411ffcd531e3654e8d2f2823e8bddc Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 17 Jan 2019 18:16:56 +0100 Subject: [PATCH] add mainPanelComponent --- package.json | 2 +- src/app.js | 17 ++++++++++--- src/app/components/swap-panel-api.js | 1 + src/app/components/swap-panel-component.js | 1 - src/app/panels/editor-panel.js | 10 ++++++++ src/remixAppManager.js | 28 ++++++++++++++++++---- 6 files changed, 50 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index efa0d1924c..ac3330bda3 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "remix-analyzer": "0.3.1", "remix-debug": "0.3.1", "remix-lib": "0.4.1", - "remix-plugin": "0.0.1-alpha.7", + "remix-plugin": "0.0.1-alpha.8", "remix-solidity": "0.3.1", "remix-tests": "0.1.1", "remixd": "0.1.8-alpha.6", diff --git a/src/app.js b/src/app.js index be343c9de5..91dd856105 100644 --- a/src/app.js +++ b/src/app.js @@ -411,12 +411,14 @@ Please make a backup of your contracts and start using http://remix.ethereum.org const pluginManagerComponent = new PluginManagerComponent() const swapPanelComponent = new SwapPanelComponent() + const mainPanelComponent = new SwapPanelComponent() const verticalIconComponent = new VerticalIconsComponent() const swapPanelApi = new SwapPanelApi(swapPanelComponent, verticalIconComponent) // eslint-disable-line + const mainPanelApi = new SwapPanelApi(mainPanelComponent, verticalIconComponent) // eslint-disable-line const verticalIconsApi = new VerticalIconsApi(verticalIconComponent) // eslint-disable-line let appStore = new EntityStore('module', { actives: [], ids: [], entities: {} }) - const appManager = new RemixAppManager(appStore, swapPanelApi, verticalIconsApi) + const appManager = new RemixAppManager(appStore, swapPanelApi, mainPanelApi, verticalIconsApi) registry.put({api: appManager.proxy(), name: 'pluginmanager'}) pluginManagerComponent.setApp(appManager) @@ -425,7 +427,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org self._components.editorpanel.init() self._components.fileManager.init() - self._view.mainpanel.appendChild(self._components.editorpanel.render()) + self._view.mainpanel.appendChild(mainPanelComponent.render()) self._view.iconpanel.appendChild(verticalIconComponent.render()) self._view.swappanel.appendChild(swapPanelComponent.render()) @@ -458,6 +460,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org { profile: sourceHighlighters.profile(), api: sourceHighlighters }, { profile: configProvider.profile(), api: configProvider }, { profile: txListenerModuleProxy.profile(), api: txListenerModuleProxy }, + { profile: self._components.editorpanel.profile(), api: self._components.editorpanel }, { profile: filePanel.profile(), api: filePanel }, { profile: support.profile(), api: support }, { profile: settings.profile(), api: settings }, @@ -481,9 +484,17 @@ Please make a backup of your contracts and start using http://remix.ethereum.org // warn the content that it is being displayed. TODO should probably be done in each view if (current && current.api.__showing) current.api.__showing() }) + mainPanelApi.event.on('showing', (moduleName) => { + if (moduleName === 'code editor') { + verticalIconComponent.select('file explorers') + this._components.resizeFeature.maximise() + return + } + this._components.resizeFeature.minimize() + }) verticalIconComponent.select('file explorers') - + verticalIconComponent.select('code editor') // The event listener needs to be registered as early as possible, because the // parent will send the message upon the "load" event. var filesToLoad = null diff --git a/src/app/components/swap-panel-api.js b/src/app/components/swap-panel-api.js index 939f8a51d9..28cb4e7ec9 100644 --- a/src/app/components/swap-panel-api.js +++ b/src/app/components/swap-panel-api.js @@ -6,6 +6,7 @@ class SwapPanelApi { this.component = swapPanelComponent this.currentContent verticalIconsComponent.event.on('showContent', (moduleName) => { + if (!swapPanelComponent.contents[moduleName]) return if (this.currentContent === moduleName) { this.event.emit('toggle') return diff --git a/src/app/components/swap-panel-component.js b/src/app/components/swap-panel-component.js index 080ff40559..c6db7d221f 100644 --- a/src/app/components/swap-panel-component.js +++ b/src/app/components/swap-panel-component.js @@ -23,7 +23,6 @@ class SwapPanelComponent { this.currentNode = moduleName return } - console.log(`${moduleName} not found`) } add (moduleName, content) { diff --git a/src/app/panels/editor-panel.js b/src/app/panels/editor-panel.js index 14c3d04733..b4dcda5420 100644 --- a/src/app/panels/editor-panel.js +++ b/src/app/panels/editor-panel.js @@ -22,6 +22,16 @@ class EditorPanel { self._components.editor = new Editor({}) self._components.registry.put({api: self._components.editor, name: 'editor'}) } + profile () { + return { + name: 'code editor', + methods: [], + events: [], + icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xNjk2IDM4NHE0MCAwIDY4IDI4dDI4IDY4djEyMTZxMCA0MC0yOCA2OHQtNjggMjhoLTk2MHEtNDAgMC02OC0yOHQtMjgtNjh2LTI4OGgtNTQ0cS00MCAwLTY4LTI4dC0yOC02OHYtNjcycTAtNDAgMjAtODh0NDgtNzZsNDA4LTQwOHEyOC0yOCA3Ni00OHQ4OC0yMGg0MTZxNDAgMCA2OCAyOHQyOCA2OHYzMjhxNjgtNDAgMTI4LTQwaDQxNnptLTU0NCAyMTNsLTI5OSAyOTloMjk5di0yOTl6bS02NDAtMzg0bC0yOTkgMjk5aDI5OXYtMjk5em0xOTYgNjQ3bDMxNi0zMTZ2LTQxNmgtMzg0djQxNnEwIDQwLTI4IDY4dC02OCAyOGgtNDE2djY0MGg1MTJ2LTI1NnEwLTQwIDIwLTg4dDQ4LTc2em05NTYgODA0di0xMTUyaC0zODR2NDE2cTAgNDAtMjggNjh0LTY4IDI4aC00MTZ2NjQwaDg5NnoiLz48L3N2Zz4=', + description: ' - ', + prefferedLocation: 'mainPanel' + } + } init () { var self = this self._deps = { diff --git a/src/remixAppManager.js b/src/remixAppManager.js index 4d2ba220ba..763832fc64 100644 --- a/src/remixAppManager.js +++ b/src/remixAppManager.js @@ -4,8 +4,13 @@ import PluginManagerProxy from './app/components/plugin-manager-proxy' export class RemixAppManager extends AppManagerApi { - constructor (store, swapPanelApi, verticalIconsApi) { + constructor (store, swapPanelApi, mainPanelApi, verticalIconsApi) { super(null) + this.location = { + 'default': swapPanelApi, + 'swapPanel': swapPanelApi, + 'mainPanel': mainPanelApi + } this.store = store this.verticalIconsApi = verticalIconsApi this.swapPanelApi = swapPanelApi @@ -51,7 +56,11 @@ export class RemixAppManager extends AppManagerApi { // if there's an icon, we add to the swap panel // if not we suppose it just need to be put to DOM (that would be) if (profile.icon) { - this.swapPanelApi.add(profile, domEl) + var panel = this.location[profile.prefferedLocation] ? this.location[profile.prefferedLocation] : this.location['default'] + domEl.style.height = '100%' + domEl.style.width = '100%' + domEl.style.border = '0' + panel.add(profile, domEl) this.verticalIconsApi.addIcon(profile) return } @@ -77,9 +86,20 @@ export class RemixAppManager extends AppManagerApi { notifications: { 'solCompiler': ['getCompilationFinished'] }, - url: 'https://ipfs.io/ipfs/Qmdu56TjQLMQmwitM6GRZXwvTWh8LBoNCWmoZbSzykPycJ/', + url: 'https://ipfs.io/ipfs/QmbxaFhAzSYbQ4TNQhCQqBgW3dFMt7Zj1D2achHHYvJhkz/', description: 'generate solidity documentation' } - return [{ profile: ethDoc, api: new Plugin(ethDoc, { resolveLocaton: (iframe) => { return this.resolveLocation(ethDoc, iframe) } }) }] + var pipeline = { + name: 'pipeline', + events: [], + methods: [], + notifications: {}, + url: 'https://pipeline.pipeos.one', + description: ' - ', + icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDUwIDUwIiBoZWlnaHQ9IjUwcHgiIGlkPSJMYXllcl8xIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCA1MCA1MCIgd2lkdGg9IjUwcHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxyZWN0IGZpbGw9Im5vbmUiIGhlaWdodD0iNTAiIHdpZHRoPSI1MCIvPjxwb2x5Z29uIGZpbGw9Im5vbmUiIHBvaW50cz0iNDksMTQgMzYsMjEgMzYsMjkgICA0OSwzNiAiIHN0cm9rZT0iIzAwMDAwMCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIHN0cm9rZS13aWR0aD0iMiIvPjxwYXRoIGQ9Ik0zNiwzNmMwLDIuMjA5LTEuNzkxLDQtNCw0ICBINWMtMi4yMDksMC00LTEuNzkxLTQtNFYxNGMwLTIuMjA5LDEuNzkxLTQsNC00aDI3YzIuMjA5LDAsNCwxLjc5MSw0LDRWMzZ6IiBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLW1pdGVybGltaXQ9IjEwIiBzdHJva2Utd2lkdGg9IjIiLz48L3N2Zz4=', + prefferedLocation: 'mainPanel' + } + return [{ profile: ethDoc, api: new Plugin(ethDoc, { resolveLocaton: (iframe) => { return this.resolveLocation(ethDoc, iframe) } }) }, + { profile: pipeline, api: new Plugin(pipeline, { resolveLocaton: (iframe) => { return this.resolveLocation(pipeline, iframe) } }) }] } }