@@ -35,8 +35,8 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
3535 language : '' ,
3636 evmVersion : ''
3737 } )
38+ const [ disableCompileButton , setDisableCompileButton ] = useState < boolean > ( false )
3839 const compileIcon = useRef ( null )
39- const warningIcon = useRef ( null )
4040 const promptMessageInput = useRef ( null )
4141 const [ hhCompilation , sethhCompilation ] = useState ( false )
4242 const [ compilerContainer , dispatch ] = useReducer ( compilerReducer , compilerInitialState )
@@ -83,6 +83,9 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
8383 } , [ compileTabLogic ] )
8484
8585 useEffect ( ( ) => {
86+ const isDisabled = ! compiledFileName || ( compiledFileName && ! isSolFileSelected ( compiledFileName ) )
87+
88+ setDisableCompileButton ( isDisabled )
8689 setState ( prevState => {
8790 return { ...prevState , compiledFileName }
8891 } )
@@ -243,14 +246,8 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
243246 }
244247
245248 const compilationDuration = ( speed : number ) => {
246- if ( ! warningIcon . current ) return
247249 if ( speed > 1000 ) {
248- const msg = `Last compilation took ${ speed } ms. We suggest to turn off autocompilation.`
249-
250- warningIcon . current . setAttribute ( 'title' , msg )
251- warningIcon . current . style . visibility = 'visible'
252- } else {
253- warningIcon . current . style . visibility = 'hidden'
250+ console . log ( `Last compilation took ${ speed } ms. We suggest to turn off autocompilation.` )
254251 }
255252 }
256253
@@ -264,15 +261,18 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
264261 if ( ! compileIcon . current ) return
265262 compileIcon . current . setAttribute ( 'title' , 'compiler is loading, please wait a few moments.' )
266263 compileIcon . current . classList . add ( 'remixui_spinningIcon' )
267- warningIcon . current . style . visibility = 'hidden'
268264 _updateLanguageSelector ( )
265+ setDisableCompileButton ( true )
269266 }
270267
271268 const compilerLoaded = ( ) => {
272269 if ( ! compileIcon . current ) return
273270 compileIcon . current . setAttribute ( 'title' , '' )
274271 compileIcon . current . classList . remove ( 'remixui_spinningIcon' )
275272 if ( state . autoCompile ) compile ( )
273+ const isDisabled = ! compiledFileName || ( compiledFileName && ! isSolFileSelected ( compiledFileName ) )
274+
275+ setDisableCompileButton ( isDisabled )
276276 }
277277
278278 const compilationFinished = ( ) => {
@@ -531,6 +531,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
531531 < label className = "remixui_compilerLabel form-check-label" htmlFor = "evmVersionSelector" > EVM Version</ label >
532532 < select value = { state . evmVersion } onChange = { ( e ) => handleEvmVersionChange ( e . target . value ) } className = "custom-select" id = "evmVersionSelector" >
533533 < option data-id = { state . evmVersion === 'default' ? 'selected' : '' } value = "default" > compiler default</ option >
534+ < option data-id = { state . evmVersion === 'berlin' ? 'selected' : '' } value = "berlin" > berlin</ option >
534535 < option data-id = { state . evmVersion === 'muirGlacier' ? 'selected' : '' } value = "muirGlacier" > muirGlacier</ option >
535536 < option data-id = { state . evmVersion === 'istanbul' ? 'selected' : '' } value = "istanbul" > istanbul</ option >
536537 < option data-id = { state . evmVersion === 'petersburg' ? 'selected' : '' } value = "petersburg" > petersburg</ option >
@@ -575,11 +576,10 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
575576 < label className = "form-check-label custom-control-label" htmlFor = "enableHardhat" > Enable Hardhat Compilation</ label >
576577 </ div >
577578 }
578- < button id = "compileBtn" data-id = "compilerContainerCompileBtn" className = "btn btn-primary btn-block remixui_disabled mt-3" title = "Compile" onClick = { compile } disabled = { ! state . compiledFileName || ( state . compiledFileName && ! isSolFileSelected ( state . compiledFileName ) ) } >
579- < span className = "text-break" >
580- < i ref = { warningIcon } title = "Compilation Slow" style = { { visibility : 'hidden' } } className = "remixui_warnCompilationSlow fas fa-exclamation-triangle" aria-hidden = "true" > </ i >
581- { warningIcon . current && warningIcon . current . style . visibility === 'hidden' && < i ref = { compileIcon } className = "fas fa-sync remixui_icon" aria-hidden = "true" > </ i > }
582- Compile { state . compiledFileName || '<no file selected>' }
579+ < button id = "compileBtn" data-id = "compilerContainerCompileBtn" className = "btn btn-primary btn-block remixui_disabled mt-3" title = "Compile" onClick = { compile } disabled = { disableCompileButton } >
580+ < span >
581+ { < i ref = { compileIcon } className = "fas fa-sync remixui_icon" aria-hidden = "true" > </ i > }
582+ Compile { typeof state . compiledFileName === 'string' ? helper . extractNameFromKey ( state . compiledFileName ) || '<no file selected>' : '<no file selected>' }
583583 </ span >
584584 </ button >
585585 </ header >
0 commit comments