diff --git a/src/app/tabs/analysis-tab.js b/src/app/tabs/analysis-tab.js index 51f06c7fb0..e1cec92d26 100644 --- a/src/app/tabs/analysis-tab.js +++ b/src/app/tabs/analysis-tab.js @@ -42,7 +42,7 @@ class AnalysisTab extends ViewPlugin { }) this.registry.put({api: this.staticanalysis, name: 'staticanalysis'}) - return yo`
${this.staticanalysis.render()}
` + return yo`
${this.staticanalysis.render()}
` } } diff --git a/src/app/tabs/staticanalysis/staticAnalysisView.js b/src/app/tabs/staticanalysis/staticAnalysisView.js index eba2e65dd9..c14b0c8530 100644 --- a/src/app/tabs/staticanalysis/staticAnalysisView.js +++ b/src/app/tabs/staticanalysis/staticAnalysisView.js @@ -32,6 +32,7 @@ function staticAnalysisView (localRegistry, analysisModule) { $('#staticanalysisresult').empty() if (languageVersion.indexOf('soljson') !== 0) return self.lastCompilationResult = data + if (self.view) self.view.querySelector('#staticAnalysisCurrentFile').innerText = file self.lastCompilationSource = source if (self.view.querySelector('#autorunstaticanalysis').checked) { self.run() @@ -40,45 +41,50 @@ function staticAnalysisView (localRegistry, analysisModule) { } staticAnalysisView.prototype.render = function () { - var self = this - var view = yo` + this.runBtn = yo`` + const view = yo`
-
-
- -
- - -
-
- - -
-
+
+
+ For: No file compiled
-
- ${this.modulesView} +
+ ${this.runBtn} +
+ + +
+
+ + +
-
Results:
-
+
+
+ ${this.modulesView} +
+
Results:
+
` + if (!this.view) { this.view = view } + this.correctRunBtnDisabled() return view } @@ -86,7 +92,7 @@ staticAnalysisView.prototype.selectedModules = function () { if (!this.view) { return [] } - var selected = this.view.querySelectorAll('[name="staticanalysismodule"]:checked') + const selected = this.view.querySelectorAll('[name="staticanalysismodule"]:checked') var toRun = [] for (var i = 0; i < selected.length; i++) { toRun.push(selected[i].attributes['index'].value) @@ -98,16 +104,17 @@ staticAnalysisView.prototype.run = function () { if (!this.view) { return } - var selected = this.selectedModules() - var warningContainer = $('#staticanalysisresult') + const selected = this.selectedModules() + const warningContainer = $('#staticanalysisresult') warningContainer.empty() var self = this if (this.lastCompilationResult && selected.length) { - var warningCount = 0 + this.runBtn.removeAttribute('disabled') + let warningCount = 0 this.runner.run(this.lastCompilationResult, selected, function (results) { results.map(function (result, i) { result.report.map(function (item, i) { - var location = '' + let location = '' if (item.location) { var split = item.location.split(':') var file = split[2] @@ -122,79 +129,87 @@ staticAnalysisView.prototype.run = function () { location = Object.keys(self.lastCompilationResult.contracts)[file] + ':' + (location.start.line + 1) + ':' + (location.start.column + 1) + ':' } warningCount++ - var msg = yo`${location} ${item.warning} ${item.more ? yo`
more
` : yo``}
` + const msg = yo`${location} ${item.warning} ${item.more ? yo`
more
` : yo``}
` self._components.renderer.error(msg, warningContainer, {type: 'staticAnalysisWarning alert alert-warning', useSpan: true}) }) }) self.event.trigger('staticAnaysisWarning', [warningCount]) }) } else { + this.runBtn.setAttribute('disabled', 'disabled') if (selected.length) { warningContainer.html('No compiled AST available') } self.event.trigger('staticAnaysisWarning', [-1]) } } - staticAnalysisView.prototype.checkModule = function (event) { - let selected = this.view.querySelectorAll('[name="staticanalysismodule"]:checked') - let checkAll = this.view.querySelector('[id="checkAllEntries"]') + const selected = this.view.querySelectorAll('[name="staticanalysismodule"]:checked') + const checkAll = this.view.querySelector('[id="checkAllEntries"]') + this.correctRunBtnDisabled() if (event.target.checked) { checkAll.checked = true } else if (!selected.length) { checkAll.checked = false } } - +staticAnalysisView.prototype.correctRunBtnDisabled = function () { + const selected = this.view.querySelectorAll('[name="staticanalysismodule"]:checked') + if (this.lastCompilationResult && selected.length != 0) { + this.runBtn.removeAttribute('disabled') + } else { + this.runBtn.setAttribute('disabled', 'disabled') + } +} staticAnalysisView.prototype.checkAll = function (event) { if (!this.view) { return } // checks/unchecks all - var checkBoxes = this.view.querySelectorAll('[name="staticanalysismodule"]') + const checkBoxes = this.view.querySelectorAll('[name="staticanalysismodule"]') checkBoxes.forEach((checkbox) => { checkbox.checked = event.target.checked }) + this.correctRunBtnDisabled() } staticAnalysisView.prototype.renderModules = function () { - var self = this - var groupedModules = utils.groupBy(preProcessModules(self.runner.modules()), 'categoryId') + const groupedModules = utils.groupBy(preProcessModules(this.runner.modules()), 'categoryId') const moduleEntries = Object.keys(groupedModules).map((categoryId, i) => { - var category = groupedModules[categoryId] - var entriesDom = category.map((item, i) => { - return yo` -
- - -
- ` - }) + const category = groupedModules[categoryId] + const entriesDom = category.map((item, i) => { return yo` -
- - -
- ${entriesDom} -
- +
+ + +
` }) return yo` -
- ${moduleEntries} -
` +
+ + +
+ ${entriesDom} +
+ + ` + }) +return yo` +
+ ${moduleEntries} +
` } module.exports = staticAnalysisView diff --git a/src/app/tabs/staticanalysis/styles/staticAnalysisView-styles.js b/src/app/tabs/staticanalysis/styles/staticAnalysisView-styles.js index 2f676f9d67..c46d4ddd02 100644 --- a/src/app/tabs/staticanalysis/styles/staticAnalysisView-styles.js +++ b/src/app/tabs/staticanalysis/styles/staticAnalysisView-styles.js @@ -21,9 +21,6 @@ var css = csjs` align-items: center; justify-content: space-around; } - .buttonRun { - margin-right: 1%; - } .label { display: flex; align-items: center; diff --git a/src/app/tabs/styles/test-tab-styles.js b/src/app/tabs/styles/test-tab-styles.js index df15f2a441..e194533601 100644 --- a/src/app/tabs/styles/test-tab-styles.js +++ b/src/app/tabs/styles/test-tab-styles.js @@ -39,11 +39,6 @@ var css = csjs` } .testFailureSummary { } - .buttons { - margin: 5%; - display: flex; - align-items: center; - } .title { font-size: 1.1em; font-weight: bold;