CompileTab: refactor element errorContainer

pull/1/head
serapath 7 years ago
parent 396be94ef2
commit 62b6dde8a0
  1. 17
      src/app/tabs/compile-tab.js

@ -23,7 +23,8 @@ module.exports = class CompileTab {
compileButton: null, compileButton: null,
warnCompilationSlow: null, warnCompilationSlow: null,
compileIcon: null, compileIcon: null,
compileContainer: null compileContainer: null,
errorContainer: null
} }
self.data = { self.data = {
autoCompile: self._opts.config.get('autoCompile'), autoCompile: self._opts.config.get('autoCompile'),
@ -64,7 +65,7 @@ module.exports = class CompileTab {
}) })
self._events.compiler.register('compilationStarted', function start () { self._events.compiler.register('compilationStarted', function start () {
if (!self._view.compileIcon) return if (!self._view.compileIcon) return
errorContainer.innerHTML = '' self._view.errorContainer.innerHTML = ''
self._view.compileIcon.classList.remove(`${css.bouncingIcon}`) self._view.compileIcon.classList.remove(`${css.bouncingIcon}`)
self._view.compileIcon.classList.add(`${css.spinningIcon}`) self._view.compileIcon.classList.add(`${css.spinningIcon}`)
self._view.compileIcon.setAttribute('title', 'compiling...') self._view.compileIcon.setAttribute('title', 'compiling...')
@ -97,25 +98,25 @@ module.exports = class CompileTab {
var error = false var error = false
if (data['error']) { if (data['error']) {
error = true error = true
self._opts.renderer.error(data['error'].formattedMessage, errorContainer, {type: data['error'].severity}) self._opts.renderer.error(data['error'].formattedMessage, self._view.errorContainer, {type: data['error'].severity})
} }
if (data['errors']) { if (data['errors']) {
if (data['errors'].length) error = true if (data['errors'].length) error = true
data['errors'].forEach(function (err) { data['errors'].forEach(function (err) {
self._opts.renderer.error(err.formattedMessage, errorContainer, {type: err.severity}) self._opts.renderer.error(err.formattedMessage, self._view.errorContainer, {type: err.severity})
}) })
} }
if (!error) { if (!error) {
if (data.contracts) { if (data.contracts) {
self._opts.compiler.visitContracts((contract) => { self._opts.compiler.visitContracts((contract) => {
self._opts.renderer.error(contract.name, errorContainer, {type: 'success'}) self._opts.renderer.error(contract.name, self._view.errorContainer, {type: 'success'})
}) })
} }
} }
}) })
self._events.staticAnalysis.register('staticAnaysisWarning', (count) => { self._events.staticAnalysis.register('staticAnaysisWarning', (count) => {
if (count) { if (count) {
self._opts.renderer.error(`Static Analysis raised ${count} warning(s) that requires your attention.`, errorContainer, { self._opts.renderer.error(`Static Analysis raised ${count} warning(s) that requires your attention.`, self._view.errorContainer, {
type: 'warning', type: 'warning',
click: () => self._api.switchTab('staticanalysisView') click: () => self._api.switchTab('staticanalysisView')
}) })
@ -139,7 +140,7 @@ module.exports = class CompileTab {
${self._view.warnCompilationSlow} ${self._view.warnCompilationSlow}
</div> </div>
</div>` </div>`
var errorContainer = yo`<div class='error'></div>` self._view.errorContainer = yo`<div class='error'></div>`
var contractNames = yo`<select class="${css.contractNames}" disabled></select>` var contractNames = yo`<select class="${css.contractNames}" disabled></select>`
var contractEl = yo` var contractEl = yo`
<div class="${css.container}"> <div class="${css.container}">
@ -153,7 +154,7 @@ module.exports = class CompileTab {
<div class="${css.compileTabView}" id="compileTabView"> <div class="${css.compileTabView}" id="compileTabView">
${self._view.compileContainer} ${self._view.compileContainer}
${contractEl} ${contractEl}
${errorContainer} ${self._view.errorContainer}
</div>` </div>`
function updateAutoCompile (event) { self._opts.config.set('autoCompile', self._view.autoCompile.checked) } function updateAutoCompile (event) { self._opts.config.set('autoCompile', self._view.autoCompile.checked) }
function compile (event) { self._api.runCompiler() } function compile (event) { self._api.runCompiler() }

Loading…
Cancel
Save