show only checkbox removed

pull/5370/head
Aniket-Engg 3 years ago committed by Aniket
parent f2f68471c7
commit 13c45f3d42
  1. 51
      libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx

@ -57,14 +57,10 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
const [autoRun, setAutoRun] = useState(true)
const [slitherEnabled, setSlitherEnabled] = useState(false)
const [showSlither, setShowSlither] = useState('hidden')
// Show checkbox to select to display only Slither Analysis
const [showSlitherResult, setShowSlitherResult] = useState('none')
const [slitherResultEnabled, setSlitherResultEnabled] = useState(false)
const [categoryIndex, setCategoryIndex] = useState(groupedModuleIndex(groupedModules))
const warningContainer = React.useRef(null)
const [warningState, setWarningState] = useState({})
const [allWarnings, setAllWarnings] = useState({})
const [state, dispatch] = useReducer(analysisReducer, initialState)
useEffect(() => {
@ -73,7 +69,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
useEffect(() => {
setWarningState({})
setAllWarnings({})
if (autoRun) {
if (state.data !== null) {
run(state.data, state.source, state.file)
@ -128,24 +123,9 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
}
const groupedCategory = groupBy(resultArray, groupByKey)
setAllWarnings(groupedCategory)
setWarningState(groupedCategory)
}
const showWarningsByModule = (showOnlyModule: string) => {
let count = 0
if (allWarnings[showOnlyModule]) {
const newWarningState = {}
newWarningState[showOnlyModule] = allWarnings[showOnlyModule]
setWarningState({ [showOnlyModule]: allWarnings[showOnlyModule] })
count = allWarnings[showOnlyModule].length
} else if (showOnlyModule === 'all') {
setWarningState(allWarnings)
for (const e in allWarnings) count += allWarnings[e].length
}
props.event.trigger('staticAnaysisWarning', [count])
}
const run = (lastCompilationResult, lastCompilationSource, currentFile) => {
if (state.data !== null) {
if (lastCompilationResult && categoryIndex.length > 0) {
@ -257,11 +237,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
})
showWarnings(warningMessage, 'warningModuleName')
props.event.trigger('staticAnaysisWarning', [warningCount])
if (showSlitherResult === 'none') {
setShowSlitherResult('block')
} else if (showSlitherResult === 'block' && slitherResultEnabled) {
showWarningsByModule('Slither Analysis')
}
}
}).catch((error) => {
console.log('Error found:', error) // This should be removed once testing done
@ -269,11 +244,8 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
})
})
} else {
setShowSlitherResult('none')
showWarnings(warningMessage, 'warningModuleName')
if (categoryIndex.length > 0) {
props.event.trigger('staticAnaysisWarning', [warningCount])
}
props.event.trigger('staticAnaysisWarning', [warningCount])
}
})
} else {
@ -319,16 +291,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
}
}
const handleShowSlitherResultEnabled = () => {
if (slitherResultEnabled) {
setSlitherResultEnabled(false)
showWarningsByModule('all')
} else {
setSlitherResultEnabled(true)
showWarningsByModule('Slither Analysis')
}
}
const handleAutoRun = () => {
if (autoRun) {
setAutoRun(false)
@ -458,17 +420,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
{state.file}
</span>
</div>
<div className="d-flex" id="onlySlitherResult">
<RemixUiCheckbox
id="showOnlySlitherResult"
inputType="checkbox"
onClick={handleShowSlitherResultEnabled}
checked={slitherResultEnabled}
label="Show Only Slither Analysis"
onChange={() => {}}
display = {showSlitherResult}
/>
</div>
<br/>
{Object.entries(warningState).length > 0 &&
<div id='staticanalysisresult' >

Loading…
Cancel
Save