compilerloaded

pull/2868/head
filip mertens 2 years ago
parent cfaad6a614
commit b66eed3948
  1. 5
      apps/remix-ide-e2e/src/commands/verifyLoad.ts
  2. 65
      libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx

@ -23,6 +23,11 @@ class VerifyLoad extends EventEmitter {
locateStrategy: 'xpath', locateStrategy: 'xpath',
timeout: 60000 timeout: 60000
}) })
.waitForElementPresent({
selector: "//span[@data-id='compilerloaded']",
locateStrategy: 'xpath',
timeout: 60000
})
.perform((done) => { .perform((done) => {
done() done()
this.emit('complete') this.emit('complete')

@ -227,7 +227,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
if (state.useFileConfiguration) if (state.useFileConfiguration)
if (state.createFileOnce) { if (state.createFileOnce) {
api.fileExists(defaultPath).then((exists) => { api.fileExists(defaultPath).then((exists) => {
if (!exists || state.useFileConfiguration ) createNewConfigFile() if (!exists || state.useFileConfiguration) createNewConfigFile()
}) })
setState(prevState => { setState(prevState => {
return { ...prevState, createFileOnce: false } return { ...prevState, createFileOnce: false }
@ -436,7 +436,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
compileIcon.current.setAttribute('title', 'compiler is loading, please wait a few moments.') compileIcon.current.setAttribute('title', 'compiler is loading, please wait a few moments.')
compileIcon.current.classList.add('remixui_spinningIcon') compileIcon.current.classList.add('remixui_spinningIcon')
setState(prevState => { setState(prevState => {
return { ...prevState, compilerLicense: 'Compiler is loading. License will be displayed once compiler is loaded'} return { ...prevState, compilerLicense: 'Compiler is loading. License will be displayed once compiler is loaded' }
}) })
_updateLanguageSelector() _updateLanguageSelector()
setDisableCompileButton(true) setDisableCompileButton(true)
@ -453,6 +453,13 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const isDisabled = !compiledFileName || (compiledFileName && !isSolFileSelected(compiledFileName)) const isDisabled = !compiledFileName || (compiledFileName && !isSolFileSelected(compiledFileName))
setDisableCompileButton(isDisabled) setDisableCompileButton(isDisabled)
// just for e2e
// eslint-disable-next-line no-case-declarations
const loadedElement = document.createElement('span')
loadedElement.setAttribute('data-id', 'compilerloaded')
loadedElement.setAttribute('data-version', state.selectedVersion)
document.body.appendChild(loadedElement)
} }
const compilationFinished = () => { const compilationFinished = () => {
@ -555,22 +562,22 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const _shouldBeAdded = (version) => { const _shouldBeAdded = (version) => {
return !version.includes('nightly') || return !version.includes('nightly') ||
(version.includes('nightly') && state.includeNightlies) (version.includes('nightly') && state.includeNightlies)
} }
const promptCompiler = () => { const promptCompiler = () => {
// custom url https://solidity-blog.s3.eu-central-1.amazonaws.com/data/08preview/soljson.js // custom url https://solidity-blog.s3.eu-central-1.amazonaws.com/data/08preview/soljson.js
modal('Add a custom compiler', promptMessage('URL'), 'OK', addCustomCompiler, 'Cancel', () => {}) modal('Add a custom compiler', promptMessage('URL'), 'OK', addCustomCompiler, 'Cancel', () => { })
} }
const showCompilerLicense = () => { const showCompilerLicense = () => {
modal('Compiler License', state.compilerLicense ? state.compilerLicense : 'License not available', 'OK', () => {}) modal('Compiler License', state.compilerLicense ? state.compilerLicense : 'License not available', 'OK', () => { })
} }
const promptMessage = (message) => { const promptMessage = (message) => {
return ( return (
<> <>
<span>{ message }</span> <span>{message}</span>
<input type="text" data-id="modalDialogCustomPromptCompiler" className="form-control" ref={promptMessageInput} /> <input type="text" data-id="modalDialogCustomPromptCompiler" className="form-control" ref={promptMessageInput} />
</> </>
) )
@ -709,7 +716,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
setToggleExpander(!toggleExpander) setToggleExpander(!toggleExpander)
} }
return ( return (
<section> <section>
<article> <article>
<div className='pt-0 remixui_compilerSection'> <div className='pt-0 remixui_compilerSection'>
@ -717,11 +724,11 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
<label className="remixui_compilerLabel form-check-label" htmlFor="versionSelector">Compiler</label> <label className="remixui_compilerLabel form-check-label" htmlFor="versionSelector">Compiler</label>
<span className="far fa-plus border-0 p-0 ml-3" onClick={() => promptCompiler()} title="Add a custom compiler with URL"></span> <span className="far fa-plus border-0 p-0 ml-3" onClick={() => promptCompiler()} title="Add a custom compiler with URL"></span>
<span className="fa fa-file-text-o border-0 p-0 ml-2" onClick={() => showCompilerLicense()} title="See compiler license"></span> <span className="fa fa-file-text-o border-0 p-0 ml-2" onClick={() => showCompilerLicense()} title="See compiler license"></span>
<select value={ state.selectedVersion || state.defaultVersion } onChange={(e) => handleLoadVersion(e.target.value) } className="custom-select" id="versionSelector" disabled={state.allversions.length <= 0}> <select value={state.selectedVersion || state.defaultVersion} onChange={(e) => handleLoadVersion(e.target.value)} className="custom-select" id="versionSelector" disabled={state.allversions.length <= 0}>
{ state.allversions.length <= 0 && <option disabled data-id={state.selectedVersion === state.defaultVersion ? 'selected' : ''}>{ state.defaultVersion }</option> } {state.allversions.length <= 0 && <option disabled data-id={state.selectedVersion === state.defaultVersion ? 'selected' : ''}>{state.defaultVersion}</option>}
{ state.allversions.length <= 0 && <option disabled data-id={state.selectedVersion === 'builtin' ? 'selected' : ''}>builtin</option> } {state.allversions.length <= 0 && <option disabled data-id={state.selectedVersion === 'builtin' ? 'selected' : ''}>builtin</option>}
{ state.customVersions.map((url, i) => <option key={i} data-id={state.selectedVersion === url ? 'selected' : ''} value={url}>custom</option>)} {state.customVersions.map((url, i) => <option key={i} data-id={state.selectedVersion === url ? 'selected' : ''} value={url}>custom</option>)}
{ state.allversions.map((build, i) => { {state.allversions.map((build, i) => {
return _shouldBeAdded(build.longVersion) return _shouldBeAdded(build.longVersion)
? <option key={i} value={build.path} data-id={state.selectedVersion === build.path ? 'selected' : ''}>{build.longVersion}</option> ? <option key={i} value={build.path} data-id={state.selectedVersion === build.path ? 'selected' : ''}>{build.longVersion}</option>
: null : null
@ -826,12 +833,12 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
<label className="form-check-label custom-control-label" htmlFor="scFileConfig" data-id="scFileConfiguration">Use configuration file</label> <label className="form-check-label custom-control-label" htmlFor="scFileConfig" data-id="scFileConfiguration">Use configuration file</label>
</div> </div>
<div className={`pt-2 ml-4 ml-2 align-items-start justify-content-between d-flex`}> <div className={`pt-2 ml-4 ml-2 align-items-start justify-content-between d-flex`}>
{ (!showFilePathInput && state.useFileConfiguration) && <span {(!showFilePathInput && state.useFileConfiguration) && <span
title="Click to open the config file" title="Click to open the config file"
onClick={configFilePath === '' ? () => {} : async()=>{ await openFile()}} onClick={configFilePath === '' ? () => { } : async () => { await openFile() }}
className="py-2 remixui_compilerConfigPath" className="py-2 remixui_compilerConfigPath"
>{configFilePath === '' ? 'No file selected.' : configFilePath}</span> } >{configFilePath === '' ? 'No file selected.' : configFilePath}</span>}
{ (!showFilePathInput && !state.useFileConfiguration) && <span className="py-2 text-secondary">{configFilePath}</span> } {(!showFilePathInput && !state.useFileConfiguration) && <span className="py-2 text-secondary">{configFilePath}</span>}
<input <input
ref={configFilePathInput} ref={configFilePathInput}
className={`py-0 my-0 form-control ${showFilePathInput ? "d-flex" : "d-none"}`} className={`py-0 my-0 form-control ${showFilePathInput ? "d-flex" : "d-none"}`}
@ -845,23 +852,23 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
} }
}} }}
/> />
{ !showFilePathInput && <button disabled={!state.useFileConfiguration} data-id="scConfigChangeFilePath" className="btn-secondary" onClick={() => {setShowFilePathInput(true)}}>Change</button> } {!showFilePathInput && <button disabled={!state.useFileConfiguration} data-id="scConfigChangeFilePath" className="btn-secondary" onClick={() => { setShowFilePathInput(true) }}>Change</button>}
</div> </div>
</div> </div>
<div className="px-4"> <div className="px-4">
<span id='compilerLoadedVersion' data-version={compilerLoadedVersion}></span> {compilerLoadedVersion ? <span data-id='compilerLoadedVersion' data-version={compilerLoadedVersion}></span> : ''}
<button id="compileBtn" data-id="compilerContainerCompileBtn" className="btn btn-primary btn-block d-block w-100 text-break remixui_disabled mb-1 mt-3" onClick={compile} disabled={(configFilePath === '' && state.useFileConfiguration) || disableCompileButton}> <button id="compileBtn" data-id="compilerContainerCompileBtn" className="btn btn-primary btn-block d-block w-100 text-break remixui_disabled mb-1 mt-3" onClick={compile} disabled={(configFilePath === '' && state.useFileConfiguration) || disableCompileButton}>
<OverlayTrigger overlay={ <OverlayTrigger overlay={
<Tooltip id="overlay-tooltip-compile"> <Tooltip id="overlay-tooltip-compile">
<div className="text-left"> <div className="text-left">
{ !(configFilePath === '' && state.useFileConfiguration) && <div><b>Ctrl+S</b> for compiling</div> } {!(configFilePath === '' && state.useFileConfiguration) && <div><b>Ctrl+S</b> for compiling</div>}
{ (configFilePath === '' && state.useFileConfiguration) && <div> No config file selected</div> } {(configFilePath === '' && state.useFileConfiguration) && <div> No config file selected</div>}
</div> </div>
</Tooltip> </Tooltip>
}> }>
<span> <span>
{ <i ref={compileIcon} className="fas fa-sync remixui_iconbtn" aria-hidden="true"></i> } {<i ref={compileIcon} className="fas fa-sync remixui_iconbtn" aria-hidden="true"></i>}
Compile { typeof state.compiledFileName === 'string' ? extractNameFromKey(state.compiledFileName) || '<no file selected>' : '<no file selected>' } Compile {typeof state.compiledFileName === 'string' ? extractNameFromKey(state.compiledFileName) || '<no file selected>' : '<no file selected>'}
</span> </span>
</OverlayTrigger> </OverlayTrigger>
</button> </button>
@ -876,8 +883,8 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
<OverlayTrigger overlay={ <OverlayTrigger overlay={
<Tooltip id="overlay-tooltip-compile-run"> <Tooltip id="overlay-tooltip-compile-run">
<div className="text-left"> <div className="text-left">
{ !(configFilePath === '' && state.useFileConfiguration) && <div><b>Ctrl+Shift+S</b> for compiling and script execution</div> } {!(configFilePath === '' && state.useFileConfiguration) && <div><b>Ctrl+Shift+S</b> for compiling and script execution</div>}
{ (configFilePath === '' && state.useFileConfiguration) && <div> No config file selected</div> } {(configFilePath === '' && state.useFileConfiguration) && <div> No config file selected</div>}
</div> </div>
</Tooltip> </Tooltip>
}> }>
@ -893,11 +900,11 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
<pre> <pre>
<code> <code>
/**<br /> /**<br />
* @title ContractName<br /> * @title ContractName<br />
* @dev ContractDescription<br /> * @dev ContractDescription<br />
* @custom:dev-run-script file_path<br /> * @custom:dev-run-script file_path<br />
*/<br /> */<br />
contract ContractName {'{}'}<br /> contract ContractName {'{}'}<br />
</code> </code>
</pre> </pre>
Click to know more Click to know more

Loading…
Cancel
Save