From ece69c52f45ee3b755b15ba68d87d7fcc32498ef Mon Sep 17 00:00:00 2001 From: yann300 Date: Sat, 9 Dec 2017 11:34:56 +0100 Subject: [PATCH] add clear button --- src/app/tabs/run-tab.js | 25 ++++++++++++++++--------- src/recorder.js | 3 +++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index cc377ee5c6..5e3743704e 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -9,6 +9,7 @@ var modalDialogCustom = require('../ui/modal-dialog-custom') var executionContext = require('../../execution-context') var copyToClipboard = require('../ui/copy-to-clipboard') var Recorder = require('../../recorder') +var EventManager = require('remix-lib').EventManager // -------------- styling ---------------------- var csjs = require('csjs-inject') @@ -172,6 +173,7 @@ var noInstancesText = yo`
0 contract Instance var pendingTxsText = yo`
` function runTab (container, appAPI, appEvents, opts) { + var events = new EventManager() var pendingTxsContainer = yo`
${pendingTxsText} @@ -180,7 +182,7 @@ function runTab (container, appAPI, appEvents, opts) { var el = yo`
${settings(appAPI, appEvents)} - ${contractDropdown(appAPI, appEvents, instanceContainer)} + ${contractDropdown(events, appAPI, appEvents, instanceContainer)} ${pendingTxsContainer} ${instanceContainer}
@@ -200,11 +202,8 @@ function runTab (container, appAPI, appEvents, opts) { // set the final context. Cause it is possible that this is not the one we've originaly selected selectExEnv.value = executionContext.getProvider() fillAccountsList(appAPI, el) + clearInstance() }) - - instanceContainer.innerHTML = '' // clear the instances list - noInstancesText.style.display = 'block' - instanceContainer.appendChild(noInstancesText) }) selectExEnv.value = executionContext.getProvider() fillAccountsList(appAPI, el) @@ -212,6 +211,13 @@ function runTab (container, appAPI, appEvents, opts) { updateAccountBalances(container, appAPI) updatePendingTxs(container, appAPI) }, 500) + + var clearInstance = function () { + instanceContainer.innerHTML = '' // clear the instances list + noInstancesText.style.display = 'block' + instanceContainer.appendChild(noInstancesText) + events.trigger('clearInstance', []) + } } function fillAccountsList (appAPI, container) { @@ -244,11 +250,12 @@ function updateAccountBalances (container, appAPI) { /* ------------------------------------------------ RECORDER ------------------------------------------------ */ -function makeRecorder (appAPI, appEvents) { +function makeRecorder (events, appAPI, appEvents) { var recorder = new Recorder({ events: { udapp: appEvents.udapp, - executioncontext: executionContext.event + executioncontext: executionContext.event, + runtab: events }, api: appAPI }) @@ -323,7 +330,7 @@ function makeRecorder (appAPI, appEvents) { section CONTRACT DROPDOWN and BUTTONS ------------------------------------------------ */ -function contractDropdown (appAPI, appEvents, instanceContainer) { +function contractDropdown (events, appAPI, appEvents, instanceContainer) { instanceContainer.appendChild(noInstancesText) var compFails = yo`` appEvents.compiler.register('compilationFinished', function (success, data, source) { @@ -364,7 +371,7 @@ function contractDropdown (appAPI, appEvents, instanceContainer) { ${atAddressButtonInput}
At Address
-
${makeRecorder(appAPI, appEvents)}
+
${makeRecorder(events, appAPI, appEvents)}
` diff --git a/src/recorder.js b/src/recorder.js index 3247021107..a8fe1b7aef 100644 --- a/src/recorder.js +++ b/src/recorder.js @@ -21,6 +21,9 @@ class Recorder { opts.events.executioncontext.register('contextChanged', () => { self.clearAll() }) + opts.events.runtab.register('clearInstances', () => { + self.clearAll() + }) opts.events.udapp.register('initiatingTransaction', (timestamp, tx, payLoad) => { if (tx.useCall) return