refactored warning message

pull/1104/head
tizah 4 years ago
parent 40cb362c64
commit af075393f3
  1. 25
      libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx

@ -105,6 +105,20 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
return () => { } return () => { }
}, [autoRun, categoryIndex]) }, [autoRun, categoryIndex])
const message = (name, warning, more, fileName, locationString) : string => {
return (`
<span className='d-flex flex-column'>
<span className='h6 font-weight-bold'>${name}</span>
${warning}
${more
? (<span><a href={more} target='_blank'>more</a></span>)
: (<span> </span>)
}
<span className="" title={Position in ${fileName}}>Pos: ${locationString}</span>
</span>`
)
}
const run = (lastCompilationResult, lastCompilationSource, currentFile) => { const run = (lastCompilationResult, lastCompilationSource, currentFile) => {
if (autoRun) { if (autoRun) {
setResult({ lastCompilationResult, lastCompilationSource, currentFile }) setResult({ lastCompilationResult, lastCompilationSource, currentFile })
@ -150,16 +164,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
fileName = Object.keys(lastCompilationResult.contracts)[file] fileName = Object.keys(lastCompilationResult.contracts)[file]
} }
warningCount++ warningCount++
const msg = ` const msg = message(item.name, item.warning, item.more, fileName, locationString)
<span class='d-flex flex-column'>
<span class='h6 font-weight-bold'>${result.name}</span>
${item.warning}
${item.more
? `<span><a href=${item.more} target='_blank'>more</a></span>`
: '<span> </span>'
}
<span class="" title="Position in ${fileName}">Pos: ${locationString}</span>
</span>`
const options = { const options = {
type: 'warning', type: 'warning',
useSpan: true, useSpan: true,

Loading…
Cancel
Save