diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index a7323d03f2..c0dba990bb 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -67,6 +67,7 @@ class CompileTab extends ViewPlugin { this.compiler = this.compileTabLogic.compiler this.compileTabLogic.init() this.contractMap = {} + this.isHardHatProject = false this.el = document.createElement('div') this.el.setAttribute('id', 'compileTabView') @@ -84,13 +85,6 @@ class CompileTab extends ViewPlugin { */ listenToEvents () { - this.on('filePanel', 'setWorkspace', (workspace) => { - this.compileTabLogic.isHardhatProject().then((result) => { - if (result && workspace.isLocalhost) this.compilerContainer.hardhatCompilation.style.display = 'flex' - else this.compilerContainer.hardhatCompilation.style.display = 'none' - }) - }) - this.data.eventHandlers.onContentChanged = () => { this.emit('statusChanged', { key: 'edited', title: 'the content has changed, needs recompilation', type: 'info' }) } @@ -116,7 +110,14 @@ class CompileTab extends ViewPlugin { this.call('editor', 'clearAnnotations') } - this.on('filePanel', 'setWorkspace', () => this.resetResults()) + this.on('filePanel', 'setWorkspace', (workspace) => { + this.compileTabLogic.isHardhatProject().then((result) => { + if (result && workspace.isLocalhost) this.isHardHatProject = true + else this.isHardHatProject = false + this.renderComponent() + }) + this.resetResults() + }) this.compileTabLogic.event.on('startingCompilation', this.data.eventHandlers.onStartingCompilation) this.compileTabLogic.event.on('removeAnnotations', this.data.eventHandlers.onRemoveAnnotations) @@ -284,9 +285,10 @@ class CompileTab extends ViewPlugin { compileTabLogic={this.compileTabLogic} compiledFileName={this.currentFile} contractsDetails={this.contractsDetails} - setHardHatCompilation={this.setHardHatCompilation} + setHardHatCompilation={this.setHardHatCompilation.bind(this)} contractMap={this.contractMap} compileErrors={this.compileErrors || {}} + isHardHatProject={this.isHardHatProject} /> , this.el) } diff --git a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx index a87cf1b993..5792dd2bec 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -7,7 +7,7 @@ import { canUseWorker, baseURLBin, baseURLWasm, urlFromVersion, pathToURL, promi import './css/style.css' export const CompilerContainer = (props: CompilerContainerProps) => { - const { editor, config, queryParams, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion } = props // eslint-disable-line + const { editor, config, queryParams, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion, isHardHatProject } = props // eslint-disable-line const [state, setState] = useState({ hideWarnings: false, autoCompile: false, @@ -53,8 +53,6 @@ export const CompilerContainer = (props: CompilerContainerProps) => { useEffect(() => { if (compileTabLogic && compileTabLogic.compiler) { compileTabLogic.compiler.event.register('compilerLoaded', compilerLoaded) - - console.log(`${config.get('autoCompile') || false}`) setState(prevState => { return { ...prevState, @@ -513,10 +511,12 @@ export const CompilerContainer = (props: CompilerContainerProps) => { -
- - -
+ { + isHardHatProject &&
+ + +
+ }