Commit 465bd76f authored by aniket-engg's avatar aniket-engg Committed by Aniket

enable checkbox UI

parent 29b4eb7e
...@@ -90,6 +90,12 @@ class CompileTab extends ViewPlugin { ...@@ -90,6 +90,12 @@ class CompileTab extends ViewPlugin {
*/ */
listenToEvents () { listenToEvents () {
this.on('filePanel', 'setWorkspace', (workspace) => {
this.compileTabLogic.isHardhatProject().then((result) => {
if (result) this.compilerContainer.hardhatCompilation.style.display = 'flex'
})
})
this.data.eventHandlers.onContentChanged = () => { this.data.eventHandlers.onContentChanged = () => {
this.emit('statusChanged', { key: 'edited', title: 'the content has changed, needs recompilation', type: 'info' }) this.emit('statusChanged', { key: 'edited', title: 'the content has changed, needs recompilation', type: 'info' })
} }
......
...@@ -78,11 +78,16 @@ class CompileTab { ...@@ -78,11 +78,16 @@ class CompileTab {
}) })
} }
async isHardhatProject () {
if (this.fileManager.mode === 'localhost') {
return await this.fileManager.exists('hardhat.config.js')
} else return false
}
runCompiler () { runCompiler () {
try { try {
console.log('mode is - ', this.fileManager.mode) console.log('mode is - ', this.fileManager.mode)
if (this.fileManager.mode === 'localhost') { if (this.fileManager.mode === 'localhost') {
console.log('calling compilehardhat')
const { currentVersion, optimize, runs } = this.compiler.state const { currentVersion, optimize, runs } = this.compiler.state
const fileContent = `module.exports = { const fileContent = `module.exports = {
solidity: '${currentVersion.substring(0, currentVersion.indexOf('+commit'))}', solidity: '${currentVersion.substring(0, currentVersion.indexOf('+commit'))}',
......
...@@ -183,6 +183,10 @@ class CompilerContainer { ...@@ -183,6 +183,10 @@ class CompilerContainer {
} }
}) })
this.hardhatCompilation = yo`<div class="mt-2 ${css.compilerConfig} custom-control custom-checkbox" style="display:none">
<input class="${css.autocompile} custom-control-input" id="enableHardhat" type="checkbox" title="Enable Hardhat Compilation">
<label class="form-check-label custom-control-label" for="enableHardhat">Enable Hardhat Compilation</label>
</div>`
this._view.warnCompilationSlow = yo`<i title="Compilation Slow" style="visibility:hidden" class="${css.warnCompilationSlow} fas fa-exclamation-triangle" aria-hidden="true"></i>` this._view.warnCompilationSlow = yo`<i title="Compilation Slow" style="visibility:hidden" class="${css.warnCompilationSlow} fas fa-exclamation-triangle" aria-hidden="true"></i>`
this._view.compileIcon = yo`<i class="fas fa-sync ${css.icon}" aria-hidden="true"></i>` this._view.compileIcon = yo`<i class="fas fa-sync ${css.icon}" aria-hidden="true"></i>`
this._view.autoCompile = yo`<input class="${css.autocompile} custom-control-input" onchange=${() => this.updateAutoCompile()} data-id="compilerContainerAutoCompile" id="autoCompile" type="checkbox" title="Auto compile">` this._view.autoCompile = yo`<input class="${css.autocompile} custom-control-input" onchange=${() => this.updateAutoCompile()} data-id="compilerContainerAutoCompile" id="autoCompile" type="checkbox" title="Auto compile">`
...@@ -299,6 +303,7 @@ class CompilerContainer { ...@@ -299,6 +303,7 @@ class CompilerContainer {
<label class="form-check-label custom-control-label" for="hideWarningsBox">Hide warnings</label> <label class="form-check-label custom-control-label" for="hideWarningsBox">Hide warnings</label>
</div> </div>
</div> </div>
${this.hardhatCompilation}
${this._view.compilationButton} ${this._view.compilationButton}
</header> </header>
</article> </article>
......
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