From a57cf1e31343f21dd1d0473fd3aa516b24953443 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Tue, 27 Jul 2021 10:27:06 +0100 Subject: [PATCH] Disable button when loading compiler --- .../solidity-compiler/src/lib/actions/compiler.ts | 2 +- .../solidity-compiler/src/lib/compiler-container.tsx | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts b/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts index 5df99c1350..1cba2adff9 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts @@ -44,7 +44,7 @@ export const listenToEvents = (editor, compileTabLogic) => (dispatch: React.Disp }) compileTabLogic.compiler.event.register('loadingCompiler', () => { - dispatch(setCompilerMode('compilationDuration')) + dispatch(setCompilerMode('loadingCompiler')) }) compileTabLogic.compiler.event.register('compilerLoaded', () => { 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 91d645ea2c..1f1feef4ca 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -35,6 +35,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { language: '', evmVersion: '' }) + const [disableCompileButton, setDisableCompileButton] = useState(false) const compileIcon = useRef(null) const warningIcon = useRef(null) const promptMessageInput = useRef(null) @@ -83,6 +84,9 @@ export const CompilerContainer = (props: CompilerContainerProps) => { }, [compileTabLogic]) useEffect(() => { + const isDisabled = !compiledFileName || (compiledFileName && !isSolFileSelected(compiledFileName)) + + setDisableCompileButton(isDisabled) setState(prevState => { return { ...prevState, compiledFileName } }) @@ -266,6 +270,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { compileIcon.current.classList.add('remixui_spinningIcon') warningIcon.current.style.visibility = 'hidden' _updateLanguageSelector() + setDisableCompileButton(true) } const compilerLoaded = () => { @@ -273,6 +278,9 @@ export const CompilerContainer = (props: CompilerContainerProps) => { compileIcon.current.setAttribute('title', '') compileIcon.current.classList.remove('remixui_spinningIcon') if (state.autoCompile) compile() + const isDisabled = !compiledFileName || (compiledFileName && !isSolFileSelected(compiledFileName)) + + setDisableCompileButton(isDisabled) } const compilationFinished = () => { @@ -576,8 +584,8 @@ export const CompilerContainer = (props: CompilerContainerProps) => { } -