Fixed solidity import test

pull/1339/head
ioedeveloper 3 years ago
parent 7fc5e893c3
commit 2b39ec1760
  1. 37
      libs/remix-ui/renderer/src/lib/renderer.tsx
  2. 6
      libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx

@ -4,14 +4,17 @@ interface RendererProps {
message: any;
opt?: any,
plugin: any,
config: any
editor: any,
config: any,
fileManager: any
}
export const Renderer = ({ message, opt = {}, plugin, config }: RendererProps) => {
export const Renderer = ({ message, opt = {}, editor, config, fileManager, plugin }: RendererProps) => {
const [messageText, setMessageText] = useState(null)
const [editorOptions, setEditorOptions] = useState({
useSpan: false,
type: ''
type: '',
errFile: ''
})
const [classList] = useState(opt.type === 'error' ? 'alert alert-danger' : 'alert alert-warning')
const [close, setClose] = useState(false)
@ -79,20 +82,40 @@ export const Renderer = ({ message, opt = {}, plugin, config }: RendererProps) =
}
}
const handlePointToErrorOnClick = (location, fileName) => {
plugin.call('editor', 'discardHighlight')
plugin.call('editor', 'highlight', location, fileName)
const handleErrorClick = (opt) => {
if (opt.click) {
opt.click(message)
} else if (opt.errFile !== undefined && opt.errLine !== undefined && opt.errCol !== undefined) {
_errorClick(opt.errFile, opt.errLine, opt.errCol)
}
}
const handleClose = () => {
setClose(true)
}
const _errorClick = (errFile, errLine, errCol) => {
if (errFile !== config.get('currentFile')) {
// TODO: refactor with this._components.contextView.jumpTo
const provider = fileManager.fileProviderOf(errFile)
if (provider) {
provider.exists(errFile).then(() => {
fileManager.open(errFile)
editor.gotoLine(errLine, errCol)
}).catch(error => {
if (error) return console.log(error)
})
}
} else {
editor.gotoLine(errLine, errCol)
}
}
return (
<>
{
messageText && !close && (
<div className={`sol ${editorOptions.type} ${classList}`} data-id={opt.errFile} onClick={() => handlePointToErrorOnClick(opt.location, opt.fileName)}>
<div className={`sol ${editorOptions.type} ${classList}`} data-id={editorOptions.errFile} onClick={() => handleErrorClick(editorOptions)}>
{ editorOptions.useSpan ? <span> { messageText } </span> : <pre><span>{ messageText }</span></pre> }
<div className="close" data-id="renderer" onClick={handleClose}>
<i className="fas fa-times"></i>

@ -86,15 +86,15 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
<ContractSelection contractMap={contractMap} fileProvider={fileProvider} fileManager={fileManager} contractsDetails={contractsDetails} modal={modal} />
<div className="remixui_errorBlobs p-4" data-id="compiledErrors">
<span data-id={`compilationFinishedWith_${currentVersion}`}></span>
{ compileErrors.error && <Renderer message={compileErrors.error.formattedMessage || compileErrors.error} plugin={plugin} opt={{ type: compileErrors.error.severity || 'error', errorType: compileErrors.error.type }} config={config} /> }
{ compileErrors.error && <Renderer message={compileErrors.error.formattedMessage || compileErrors.error} plugin={plugin} opt={{ type: compileErrors.error.severity || 'error', errorType: compileErrors.error.type }} config={config} editor={editor} fileManager={fileManager} /> }
{ compileErrors.error && (compileErrors.error.mode === 'panic') && modal('Error', panicMessage(compileErrors.error.formattedMessage), 'Close', null) }
{ compileErrors.errors && compileErrors.errors.length && compileErrors.errors.map((err, index) => {
if (config.get('hideWarnings')) {
if (err.severity !== 'warning') {
return <Renderer key={index} message={err.formattedMessage} plugin={plugin} opt={{ type: err.severity, errorType: err.type }} config={config} />
return <Renderer key={index} message={err.formattedMessage} plugin={plugin} opt={{ type: err.severity, errorType: err.type }} config={config} editor={editor} fileManager={fileManager} />
}
} else {
return <Renderer key={index} message={err.formattedMessage} plugin={plugin} opt={{ type: err.severity, errorType: err.type }} config={config} />
return <Renderer key={index} message={err.formattedMessage} plugin={plugin} opt={{ type: err.severity, errorType: err.type }} config={config} editor={editor} fileManager={fileManager} />
}
}) }
</div>

Loading…
Cancel
Save