From 2ccc0beffb5ccbac1ca5b38cd13b77d9a63bfdbf Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 27 Feb 2019 14:31:53 +0100 Subject: [PATCH] swap_it_workspaces --- src/app.js | 2 +- src/app/tabs/analysis-tab.js | 3 +- src/app/tabs/run-tab.js | 3 +- src/app/tabs/test-tab.js | 3 +- src/app/ui/landing-page/generate.js | 14 ++++++-- src/app/ui/landing-page/workspace.js | 50 ++++++++++++++++++++++++++++ src/remixAppManager.js | 4 +++ 7 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 src/app/ui/landing-page/workspace.js diff --git a/src/app.js b/src/app.js index 69373f7a29..b98e337623 100644 --- a/src/app.js +++ b/src/app.js @@ -459,7 +459,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org let configProvider = self._components.filesProviders['config'] appManager.init([ - { profile: homepageProfile(), api: generateHomePage() }, + { profile: homepageProfile(), api: generateHomePage(appManager, appStore) }, { profile: this.profile(), api: this }, { profile: udapp.profile(), api: udapp }, { profile: fileManager.profile(), api: fileManager }, diff --git a/src/app/tabs/analysis-tab.js b/src/app/tabs/analysis-tab.js index cd653bb7f0..17356068ad 100644 --- a/src/app/tabs/analysis-tab.js +++ b/src/app/tabs/analysis-tab.js @@ -11,7 +11,8 @@ class AnalysisTab { } profile () { return { - name: 'solidity static analysis', + name: 'solidityStaticAnalysis', + displayName: 'solidity static analysis', methods: [], events: [], icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMjA0OCIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMjA0OCAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0yMDQ4IDE1MzZ2MTI4aC0yMDQ4di0xNTM2aDEyOHYxNDA4aDE5MjB6bS0xMjgtMTI0OHY0MzVxMCAyMS0xOS41IDI5LjV0LTM1LjUtNy41bC0xMjEtMTIxLTYzMyA2MzNxLTEwIDEwLTIzIDEwdC0yMy0xMGwtMjMzLTIzMy00MTYgNDE2LTE5Mi0xOTIgNTg1LTU4NXExMC0xMCAyMy0xMHQyMyAxMGwyMzMgMjMzIDQ2NC00NjQtMTIxLTEyMXEtMTYtMTYtNy41LTM1LjV0MjkuNS0xOS41aDQzNXExNCAwIDIzIDl0OSAyM3oiLz48L3N2Zz4=', diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index 5d0cc73f8a..d7a8303388 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -149,7 +149,8 @@ class RunTab { profile () { return { - name: 'run transactions', + name: 'run', + displayName: 'run transactions', methods: [], events: [], icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xNTc2IDkyN2wtMTMyOCA3MzhxLTIzIDEzLTM5LjUgM3QtMTYuNS0zNnYtMTQ3MnEwLTI2IDE2LjUtMzZ0MzkuNSAzbDEzMjggNzM4cTIzIDEzIDIzIDMxdC0yMyAzMXoiLz48L3N2Zz4=', diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index ea39a4531a..b42dbf4476 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -25,7 +25,8 @@ module.exports = class TestTab { } profile () { return { - name: 'solidity unit testing', + name: 'solidityUnitTesting', + displayName: 'solidity unit testing', methods: [], events: [], icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMjMwNCIgaGVpZ2h0PSIxNzky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MC0xMSAzNS04MXQ5Mi0xNzQuNSAxMDctMTk1LjUgMTAyLTE4NCA1Ni0xMDBxMTgtMzMgNTYtMzN0NTYgMzNxNCA3IDU2IDEwMHQxMDIgMTg0IDEwNyAxOTUuNSA5MiAxNzQuNSAzNSA4MXoiLz48L3N2Zz4=', diff --git a/src/app/ui/landing-page/generate.js b/src/app/ui/landing-page/generate.js index 134be631a8..fc14675708 100644 --- a/src/app/ui/landing-page/generate.js +++ b/src/app/ui/landing-page/generate.js @@ -1,6 +1,7 @@ -/* global alert */ +/* global */ import LandingPage from './landing-page' import Section from './section' +import { defaultWorkspaces } from './workspace' export function homepageProfile () { return { @@ -13,7 +14,8 @@ export function homepageProfile () { } } -export function generateHomePage () { +export function generateHomePage (appManager) { + /* var actions1 = [ {label: 'new file', type: `callback`, payload: () => { alert(`-new file created-`) }}, {label: 'import from GitHub', type: `callback`, payload: () => { alert(`-imported from GitHub-`) }}, @@ -51,6 +53,12 @@ export function generateHomePage () { var section3 = new Section('Learn', actions3) var section4 = new Section('Plugins', actions4) var section5 = new Section('Help', actions5) + */ - return new LandingPage([section1, section2, section3, section4, section5]) + var sectionsWorkspaces = [] + defaultWorkspaces(appManager).forEach((workspace) => { + sectionsWorkspaces.push({label: workspace.title, type: 'callback', payload: () => { workspace.activate() }}) + }) + var sectionWorkspace = new Section('Workspaces', sectionsWorkspaces) + return new LandingPage([sectionWorkspace]) } diff --git a/src/app/ui/landing-page/workspace.js b/src/app/ui/landing-page/workspace.js new file mode 100644 index 0000000000..2f8399bfe3 --- /dev/null +++ b/src/app/ui/landing-page/workspace.js @@ -0,0 +1,50 @@ +export class Workspace { + constructor (title, description, activate, deactivate) { + this.title = title + this.description = description + this.activate = activate + this.deactivate = deactivate + } +} + +export const defaultWorkspaces = (appManager, appStore) => { + return [ + new Workspace('Close All Modules', '', () => { + appStore.getActives() + .filter(({profile}) => !profile.required) + .forEach((profile) => { appManager.deactivateOne(profile.name) }) + }, () => {}), + new Workspace('Solidity Basic', '', () => { + appManager.ensureActivated('solidity') + }, () => {}), + new Workspace('Solidity Unit testing', '', () => { + appManager.ensureActivated('solidity') + appManager.ensureActivated('solidityUnitTesting') + }, () => {}), + new Workspace('Solidity Full Environement', '', () => { + appManager.ensureActivated('solidity') + appManager.ensureActivated('run') + appManager.ensureActivated('solidityStaticAnalysis') + appManager.ensureActivated('solidityUnitTesting') + }, () => {}), + new Workspace('Vyper Basic', '', () => { + appManager.ensureActivated('vyper') + }, () => {}), + new Workspace('Pipeline', '', () => { + appManager.ensureActivated('solidity') + appManager.ensureActivated('run') + appManager.ensureActivated('pipeline') + }, () => {}), + new Workspace('Deploy and Run Solidity', '', () => { + appManager.ensureActivated('solidity') + appManager.ensureActivated('run') + }, () => {}), + new Workspace('Deploy and Run Vyper', '', () => { + appManager.ensureActivated('vyper') + appManager.ensureActivated('run') + }, () => {}), + new Workspace('Debugger', '', () => { + appManager.ensureActivated('debugger') + }, () => {}) + ] +} diff --git a/src/remixAppManager.js b/src/remixAppManager.js index 6bca9c35b5..744e0e2964 100644 --- a/src/remixAppManager.js +++ b/src/remixAppManager.js @@ -14,6 +14,10 @@ export class RemixAppManager extends AppManagerApi { } } + ensureActivated (module) { + if (!this.store.isActive(module)) this.activateOne(module) + } + proxy () { // that's temporary. should be removed when we can have proper notification registration return this.data.proxy