Unverified Commit cb8d69c8 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #1669 from ethereum/runtab_refactor

Runtab refactor
parents 14e5c2cd 47309d8e
'use strict'
var $ = require('jquery')
var csjs = require('csjs-inject')
var yo = require('yo-yo')
var async = require('async')
......@@ -423,14 +424,53 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
let compileTab = new CompileTab(self._components.registry)
let tabs = {
compile: compileTab,
run: new RunTab(self._components.registry),
run: new RunTab(
registry.get('udapp').api,
registry.get('udappUI').api,
registry.get('config').api,
registry.get('filemanager').api,
registry.get('editor').api,
registry.get('logCallback').api,
registry.get('filepanel').api,
registry.get('pluginmanager').api,
registry.get('compilersartefacts').api
),
settings: new SettingsTab(self._components.registry),
analysis: new AnalysisTab(self._components.registry),
debug: new DebuggerTab(self._components.registry),
support: new SupportTab(self._components.registry),
analysis: new AnalysisTab(registry),
debug: new DebuggerTab(),
support: new SupportTab(),
test: new TestTab(self._components.registry, compileTab)
}
registry.get('app').api.event.register('tabChanged', (tabName) => {
if (tabName === 'Support') tabs.support.loadTab()
})
let transactionContextAPI = {
getAddress: (cb) => {
cb(null, $('#txorigin').val())
},
getValue: (cb) => {
try {
var number = document.querySelector('#value').value
var select = document.getElementById('unit')
var index = select.selectedIndex
var selectedUnit = select.querySelectorAll('option')[index].dataset.unit
var unit = 'ether' // default
if (['ether', 'finney', 'gwei', 'wei'].indexOf(selectedUnit) >= 0) {
unit = selectedUnit
}
cb(null, executionContext.web3().toWei(number, unit))
} catch (e) {
cb(e)
}
},
getGasLimit: (cb) => {
cb(null, $('#gasLimit').val())
}
}
udapp.resetAPI(transactionContextAPI)
// ---------------- Righthand-panel --------------------
self._components.righthandpanel = new RighthandPanel({ tabs, pluginManager })
self._view.rightpanel.appendChild(self._components.righthandpanel.render())
......
var yo = require('yo-yo')
var csjs = require('csjs-inject')
var StaticAnalysis = require('../staticanalysis/staticAnalysisView')
var globalRegistry = require('../../global/registry')
var EventManager = require('../../lib/events')
var css = require('./styles/analysis-tab-styles')
class AnalysisTab {
module.exports = class AnalysisTab {
constructor (localRegistry) {
const self = this
self.event = new EventManager()
self._view = { el: null }
self.data = {}
self._components = {}
self._components.registry = localRegistry || globalRegistry
self._deps = {}
constructor (registry) {
this.event = new EventManager()
this.registry = registry
}
render () {
const self = this
var staticanalysis = new StaticAnalysis()
staticanalysis.event.register('staticAnaysisWarning', (count) => {
if (count > 0) {
const msg = `Static Analysis raised ${count} warning(s) that requires your attention. Check Solidity Static Analysis Module for more information.`
const settings = { type: 'staticAnalysisWarning', useSpan: true }
self.event.trigger('newStaticAnaysisWarningMessage', [msg, settings])
}
})
self._components.registry.put({api: staticanalysis, name: 'staticanalysis'})
if (self._view.el) return self._view.el
self._view.el = yo`
<div class="${css.analysisTabView} "id="staticanalysisView">${staticanalysis.render()}</div>`
this.registry.put({api: staticanalysis, name: 'staticanalysis'})
return self._view.el
if (this.el) return this.el
this.el = yo`<div class="${css.analysisTabView} "id="staticanalysisView">${staticanalysis.render()}</div>`
return this.el
}
}
const css = csjs`
.analysisTabView {
padding: 2%;
padding-bottom: 3em;
display: flex;
flex-direction: column;
}
`
module.exports = AnalysisTab
var yo = require('yo-yo')
var csjs = require('csjs-inject')
var css = require('./styles/debugger-tab-styles')
var DebuggerUI = require('../debugger/debuggerUI')
var globalRegistry = require('../../global/registry')
var EventManager = require('../../lib/events')
var styles = require('../ui/styles-guide/theme-chooser').chooser()
const css = csjs`
.debuggerTabView {
padding: 2%;
}
.debugger {
margin-bottom: 1%;
${styles.rightPanel.debuggerTab.box_Debugger}
}
`
class DebuggerTab {
constructor (localRegistry) {
const self = this
self.event = new EventManager()
self._view = { el: null }
self.data = {}
self._components = {}
self._components.registry = localRegistry || globalRegistry
constructor () {
this.el = null
}
render () {
const self = this
if (self._view.el) return self._view.el
if (this.el) return this.el
self._view.el = yo`
this.el = yo`
<div class="${css.debuggerTabView}" id="debugView">
<div id="debugger" class="${css.debugger}"></div>
</div>`
this.debuggerUI = new DebuggerUI(self._view.el.querySelector('#debugger'))
// self._view.transactionDebugger = this.debuggerUI.view()
return self._view.el
this.debuggerUI = new DebuggerUI(this.el.querySelector('#debugger'))
return this.el
}
debugger () {
// return this._view.transactionDebugger
return this.debuggerUI
}
}
......
var yo = require('yo-yo')
var csjs = require('csjs-inject')
var css = require('./styles/plugin-tab-styles')
var globalRegistry = require('../../global/registry')
var EventManager = require('../../lib/events')
class PluginTab {
module.exports = class plugintab {
constructor (json, localRegistry) {
const self = this
self.event = new EventManager()
self._view = { el: null }
self.data = { json }
self._components = {}
self._components.registry = localRegistry || globalRegistry
constructor (json) {
this.el = null
this.data = { json }
}
render () {
const self = this
if (self._view.el) return self._view.el
self._view.el = yo`
if (this.el) return this.el
this.el = yo`
<div class="${css.pluginTabView}" id="pluginView">
<iframe class="${css.iframe}" src="${self.data.json.url}/index.html"></iframe>
<iframe class="${css.iframe}" src="${this.data.json.url}/index.html"></iframe>
</div>`
return self._view.el
return this.el
}
}
const css = csjs`
.pluginTabView {
height: 100%;
width: 100%;
}
.iframe {
height: 100%;
width: 100%;
border: 0;
}
`
module.exports = PluginTab
This diff is collapsed.
......@@ -9,10 +9,9 @@ var CompilerAbstract = require('../../../compiler/compiler-abstract')
var EventManager = remixLib.EventManager
class DropdownLogic {
constructor (fileManager, pluginManager, compilersArtefacts, compiler, config, editor, udapp, filePanel) {
constructor (fileManager, pluginManager, compilersArtefacts, config, editor, udapp, filePanel) {
this.pluginManager = pluginManager
this.compilersArtefacts = compilersArtefacts
this.compiler = compiler
this.config = config
this.editor = editor
this.udapp = udapp
......@@ -27,6 +26,7 @@ class DropdownLogic {
})
}
// TODO: can be moved up; the event in contractDropdown will have to refactored a method instead
listenToCompilationEvents () {
this.pluginManager.event.register('sendCompilationResult', (file, source, languageVersion, data) => {
// TODO check whether the tab is configured
......
......@@ -80,6 +80,13 @@ class Recorder {
this.data._createdContracts[address] = timestamp
this.data._createdContractsReverse[timestamp] = address
})
executionContext.event.register('contextChanged', this.clearAll.bind(this))
this.event.register('newTxRecorded', (count) => {
this.event.trigger('recorderCountChange', [count])
})
this.event.register('cleared', () => {
this.event.trigger('recorderCountChange', [0])
})
}
/**
......
var yo = require('yo-yo')
var remixLib = require('remix-lib')
var EventManager = remixLib.EventManager
var csjs = require('csjs-inject')
var css = require('../styles/run-tab-styles')
......@@ -8,10 +10,10 @@ var confirmDialog = require('../../execution/confirmDialog')
class RecorderUI {
constructor (recorder, parentSelf) {
constructor (recorder, logCallBack) {
this.recorder = recorder
this.parentSelf = parentSelf
this.logCallBack = this.parentSelf._deps.logCallback
this.logCallBack = logCallBack
this.event = new EventManager()
}
render () {
......@@ -67,10 +69,7 @@ class RecorderUI {
return modalDialogCustom.alert(error)
}
var noInstancesText = this.parentSelf._view.noInstancesText
if (noInstancesText.parentNode) { noInstancesText.parentNode.removeChild(noInstancesText) }
this.parentSelf._view.instanceContainer.appendChild(this.parentSelf._deps.udappUI.renderInstanceFromABI(abi, address, contractName))
this.event.trigger('newScenario', [abi, address, contractName])
})
}
......
var csjs = require('csjs-inject')
const css = csjs`
.analysisTabView {
padding: 2%;
padding-bottom: 3em;
display: flex;
flex-direction: column;
}
`
module.exports = css
var csjs = require('csjs-inject')
var styles = require('../../ui/styles-guide/theme-chooser').chooser()
const css = csjs`
.debuggerTabView {
padding: 2%;
}
.debugger {
margin-bottom: 1%;
${styles.rightPanel.debuggerTab.box_Debugger}
}
`
module.exports = css
var csjs = require('csjs-inject')
const css = csjs`
.pluginTabView {
height: 100%;
width: 100%;
}
.iframe {
height: 100%;
width: 100%;
border: 0;
}
`
module.exports = css
const csjs = require('csjs-inject')
const styles = require('../../ui/styles-guide/theme-chooser').chooser()
const css = csjs`
.supportTabView {
height: 100%;
padding: 2%;
padding-bottom: 3em;
display: flex;
flex-direction: column;
overflow: hidden;
overflow-y: auto;
}
.chat {
${styles.rightPanel.supportTab.box_IframeContainer}
display: flex;
flex-direction: column;
align-items: center;
height: 85%;
padding: 0;
}
.chatTitle {
height: 40px;
width: 90%;
display: flex;
align-items: center;
justify-content: center;
margin-top: 15px;
}
.chatTitle:hover {
cursor: pointer;
}
.icon {
height: 70%;
margin-right: 2%;
}
.chatTitleText {
font-size: 17px;
font-weight: bold;
}
.chatTitleText {
opacity: 0.8;
}
.chatIframe {
width: 100%;
height: 100%;
transform: scale(0.9);
padding: 0;
border: none;
}
.infoBox {
${styles.rightPanel.supportTab.box_SupportInfo}
}
.remixdinstallation {
padding: 3px;
border-radius: 2px;
margin-left: 5px;
}
.info {
${styles.rightPanel.settingsTab.box_SolidityVersionInfo};
margin-top: 1em;
word-break: break-word;
}
.title {
font-size: 1.1em;
font-weight: bold;
margin-bottom: 1em;
}
.crow {
display: flex;
overflow: auto;
clear: both;
padding: .2em;
}
.crow label {
cursor:pointer;
}
.crowNoFlex {
overflow: auto;
clear: both;
}
`
module.exports = css
const csjs = require('csjs-inject')
const styles = require('../../ui/styles-guide/theme-chooser').chooser()
const css = csjs`
.menu {
display: flex;
background-color: ${styles.rightPanel.BackgroundColor_Pre};
list-style: none;
margin: 0;
padding: 0;
}
.active {
background-color: ${styles.rightPanel.backgroundColor_Tab};
color: ${styles.appProperties.mainText_Color}
}
.options {
float: left;
padding-top: 0.7em;
min-width: 60px;
font-size: 0.9em;
cursor: pointer;
font-size: 1em;
text-align: center;
}
.optionViews {
background-color: ${styles.rightPanel.backgroundColor_Tab};
overflow: scroll;
height: 100%;
}
.optionViews > div {
display: none;
}
.optionViews .pre {
word-wrap: break-word;
background-color: ${styles.rightPanel.BackgroundColor_Pre};
border-radius: 3px;
display: inline-block;
padding: 0 0.6em;
}
`
module.exports = css
const yo = require('yo-yo')
const csjs = require('csjs-inject')
var css = require('./styles/support-tab-styles')
var globalRegistry = require('../../global/registry')
const styles = require('../ui/styles-guide/theme-chooser').chooser()
class SupportTab {
var EventManager = require('../../lib/events')
module.exports = class SupportTab {
constructor (localRegistry) {
const self = this
self.event = new EventManager()
self._view = { el: null, gitterIframe: '', config: {} }
self.data = { gitterIsLoaded: false }
self._components = {}
self._components.registry = localRegistry || globalRegistry
this.el = null
this.gitterIframe = ''
this.gitterIsLoaded = false
}
self._deps = {
app: self._components.registry.get('app').api
}
loadTab () {
if (this.gitterIsLoaded) return
self._deps.app.event.register('tabChanged', (tabName) => {
if (tabName !== 'Support' || self.data.gitterIsLoaded) return
const iframe = yo`<iframe class="${css.chatIframe}" src='https://gitter.im/ethereum/remix/~embed'>`
self._view.gitterIframe.parentNode.replaceChild(iframe, self._view.gitterIframe)
self._view.gitterIframe = iframe
self._view.el.style.display = 'block'
self.data.gitterIsLoaded = true
})
const iframe = yo`<iframe class="${css.chatIframe}" src='https://gitter.im/ethereum/remix/~embed'>`
this.gitterIframe.parentNode.replaceChild(iframe, this.gitterIframe)
this.gitterIframe = iframe
this.el.style.display = 'block'
this.gitterIsLoaded = true
}
render () {
const self = this
if (self._view.el) return self._view.el
self._view.gitterIframe = yo`<div></div>`
self._view.config.remixd = yo`
if (this.el) return this.el
this.gitterIframe = yo`<div></div>`
const remixd = yo`
<div class="${css.info}">
<div class=${css.title}>Accessing local files</div>
<div class="${css.crow}">
......@@ -44,7 +36,8 @@ module.exports = class SupportTab {
<div class="${css.crow}"><a target="_blank" href="https://remix.readthedocs.io/en/latest/tutorial_remixd_filesystem">http://remix.readthedocs.io/en/latest/tutorial_remixd_filesystem.html</a></div>
<div class="${css.crow}">Installation: <pre class=${css.remixdinstallation}>npm install remixd -g</pre></div>
</div>`
self._view.config.localremixd = yo`
const localremixd = yo`
<div class="${css.info}">
<div class=${css.title}>Running Remix locally</div>
<div class="${css.crow}">
......@@ -57,7 +50,8 @@ module.exports = class SupportTab {
</div>
<a target="_blank" href="https://github.com/horizon-games/remix-app">https://github.com/horizon-games/remix-app</a>
</div>`
self._view.el = yo`
this.el = yo`
<div class="${css.supportTabView}" id="supportView">
<div class="${css.infoBox}">
Have a question, found a bug or want to propose a feature? Have a look at the
......@@ -66,95 +60,18 @@ module.exports = class SupportTab {
<a target="_blank" href='https://solidity.readthedocs.io/en/latest/'> Solidity</a>.
</div>
<div class="${css.chat}">
<div class="${css.chatTitle}" onclick=${openLink} title='Click to open chat in Gitter'>
<div class="${css.chatTitle}" onclick=${() => { window.open('https://gitter.im/ethereum/remix') }} title='Click to open chat in Gitter'>
<div class="${css.chatTitleText}">ethereum/remix community chat</div>
</div>
${self._view.gitterIframe}
${this.gitterIframe}
</div>
${self._view.config.remixd}
${self._view.config.localremixd}
${remixd}
${localremixd}
</div>`
return self._view.el
function openLink () { window.open('https://gitter.im/ethereum/remix') }
return this.el
}
}
const css = csjs`
.supportTabView {
height: 100%;
padding: 2%;
padding-bottom: 3em;
display: flex;
flex-direction: column;
overflow: hidden;
overflow-y: auto;
}
.chat {
${styles.rightPanel.supportTab.box_IframeContainer}
display: flex;
flex-direction: column;
align-items: center;
height: 85%;
padding: 0;
}
.chatTitle {
height: 40px;
width: 90%;
display: flex;
align-items: center;
justify-content: center;
margin-top: 15px;
}
.chatTitle:hover {
cursor: pointer;
}
.icon {
height: 70%;
margin-right: 2%;
}
.chatTitleText {
font-size: 17px;
font-weight: bold;
}
.chatTitleText {
opacity: 0.8;
}
.chatIframe {
width: 100%;
height: 100%;
transform: scale(0.9);
padding: 0;
border: none;
}
.infoBox {
${styles.rightPanel.supportTab.box_SupportInfo}
}
.remixdinstallation {
padding: 3px;
border-radius: 2px;
margin-left: 5px;
}
.info {
${styles.rightPanel.settingsTab.box_SolidityVersionInfo};
margin-top: 1em;
word-break: break-word;
}
.title {
font-size: 1.1em;
font-weight: bold;
margin-bottom: 1em;
}
.crow {
display: flex;
overflow: auto;
clear: both;
padding: .2em;
}
.crow label {
cursor:pointer;
}
.crowNoFlex {
overflow: auto;
clear: both;
}
`
module.exports = SupportTab
var yo = require('yo-yo')
var csjs = require('csjs-inject')
var css = require('./styles/tabbed-menu-styles')
var globalRegistry = require('../../global/registry')
var helper = require('../../lib/helper')
var styles = require('../ui/styles-guide/theme-chooser').chooser()
var EventManager = require('../../lib/events')
module.exports = class TabbedMenu {
class TabbedMenu {
constructor (localRegistry) {
const self = this
self.event = new EventManager()
......@@ -91,40 +90,4 @@ module.exports = class TabbedMenu {
}
}
const css = csjs`
.menu {
display: flex;
background-color: ${styles.rightPanel.BackgroundColor_Pre};
list-style: none;
margin: 0;
padding: 0;
}
.active {
background-color: ${styles.rightPanel.backgroundColor_Tab};
color: ${styles.appProperties.mainText_Color}
}
.options {
float: left;
padding-top: 0.7em;
min-width: 60px;
font-size: 0.9em;
cursor: pointer;
font-size: 1em;
text-align: center;
}
.optionViews {
background-color: ${styles.rightPanel.backgroundColor_Tab};
overflow: scroll;
height: 100%;
}
.optionViews > div {
display: none;
}
.optionViews .pre {
word-wrap: break-word;
background-color: ${styles.rightPanel.BackgroundColor_Pre};
border-radius: 3px;
display: inline-block;
padding: 0 0.6em;
}
`
module.exports = TabbedMenu
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment