use granular control to handle warnings showing

pull/5370/head
Joseph Izang 1 year ago
parent 3ace6d5560
commit d2b3511f5a
  1. 128
      libs/remix-ui/static-analyser/src/lib/components/BasicTabBody.tsx

@ -6,78 +6,70 @@ type BasicTabBodyProps = {
hideWarnings: boolean hideWarnings: boolean
showLibsWarning: boolean showLibsWarning: boolean
warningState: any warningState: any
ssaWarnings: any[]
ssaWarningsNoLibs: any[]
startAnalysis: boolean startAnalysis: boolean
analysisModule: any analysisModule: any
} }
export function BasicTabBody({ state, hideWarnings, showLibsWarning, warningState, startAnalysis, analysisModule}: BasicTabBodyProps) { export function BasicTabBody({ state, hideWarnings, ssaWarnings, ssaWarningsNoLibs, showLibsWarning, warningState, startAnalysis, analysisModule}: BasicTabBodyProps) {
const test = ssaWarningsNoLibs.filter(x => x.options.isLibrary === false)
const test1 = ssaWarningsNoLibs.filter(x => x.options.isLibrary)
console.log({test, test1 })
return ( return (
<> <>
{Object.entries(warningState).length > 0 ? ( {ssaWarningsNoLibs.length > 0 ? (
<div id="staticanalysisresult"> <div id="staticanalysisresult">
<div className="mb-4 pt-2"> <div className="mb-4 pt-2">
{Object.entries(warningState).map((warning, index) => ( {
<div key={index}> (hideWarnings === false && showLibsWarning === false) && ssaWarningsNoLibs.length > 0
{ hideWarnings === false ? <span className="text-dark h6">{warning[0]}</span> : null} ? ssaWarningsNoLibs.filter(x => x.options.isLibrary === false).map((item, index) => (
{ hideWarnings === false ? warning[1]["map"]( <div
(x,i) => // eslint-disable-line dot-notation data-id={`staticAnalysisModule${item.warningModuleName}${index}`}
x.hasWarning id={`staticAnalysisModule${item.warningModuleName}${index}`}
? ( // eslint-disable-next-line dot-notation key={index}
<div >
data-id={`staticAnalysisModule${x.warningModuleName}${i}`} <ErrorRenderer
id={`staticAnalysisModule${x.warningModuleName}${i}`} name={`staticAnalysisModule${item.warningModuleName}${index}`}
key={i} message={item.msg}
> opt={item.options}
<ErrorRenderer warningErrors={item.warningErrors}
name={`staticAnalysisModule${x.warningModuleName}${i}`} editor={analysisModule}
message={x.msg} />
opt={x.options} </div>
warningErrors={x.warningErrors} ))
editor={analysisModule} : null
/> }
</div> {
) : null) : null} hideWarnings === false && showLibsWarning === true && ssaWarnings.length > 0
{ ? ssaWarnings.map((warning, index) => (
hideWarnings === false ? warning[1]["map"]((x,i) =>( <div
showLibsWarning === false ? ( data-id={`staticAnalysisModule${warning.warningModuleName}${index}`}
x.isLibrary ? ( id={`staticAnalysisModule${warning.warningModuleName}${index}`}
<div key={index}
data-id={`staticAnalysisModule${x.warningModuleName}${i}`} >
id={`staticAnalysisModule${x.warningModuleName}${i}`} <ErrorRenderer
key={i} name={`staticAnalysisModule${warning.warningModuleName}${index}`}
> message={warning.msg}
<ErrorRenderer opt={warning.options}
name={`staticAnalysisModule${x.warningModuleName}${i}`} warningErrors={warning.warningErrors}
message={x.msg} editor={analysisModule}
opt={x.options} />
warningErrors={x.warningErrors}
editor={analysisModule}
/>
</div>
) : null): null)) : null
}
{
hideWarnings === false ? warning[1]["map"]((x,i) =>(
<div
data-id={`staticAnalysisModule${x.warningModuleName}${i}`}
id={`staticAnalysisModule${x.warningModuleName}${i}`}
key={i}
>
<ErrorRenderer
name={`staticAnalysisModule${x.warningModuleName}${i}`}
message={x.msg}
opt={x.options}
warningErrors={x.warningErrors}
editor={analysisModule}
/>
</div>
)) : null
}
</div> </div>
))} )) : null
</div> }
</div> </div>
) : state.data && state.file.length > 0 && state.source && startAnalysis && Object.entries(warningState).length > 0 ? <span className="ml-4 spinner-grow-sm d-flex justify-content-center">Loading...</span> : <span className="display-6 text-center">Nothing to report</span>} </div>
</> ) : state.data &&
) state.file.length > 0 &&
state.source &&
startAnalysis &&
Object.entries(warningState).length > 0 ? (
<span className="ml-4 spinner-grow-sm d-flex justify-content-center">
Loading...
</span>
) : (
<span className="display-6 text-center">Nothing to report</span>
)}
</>
);
} }

Loading…
Cancel
Save