toggele analysis checkbox

pull/5370/head
aniket-engg 3 years ago committed by Aniket
parent fad31e3113
commit 1074ec489d
  1. 12
      libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx

@ -64,6 +64,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
const warningContainer = React.useRef(null)
const [warningState, setWarningState] = useState({})
const [allWarnings, setAllWarnings] = useState({})
const [state, dispatch] = useReducer(analysisReducer, initialState)
useEffect(() => {
@ -72,6 +73,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
useEffect(() => {
setWarningState({})
setAllWarnings({})
if (autoRun) {
if (state.data !== null) {
run(state.data, state.source, state.file)
@ -126,14 +128,17 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
}
const groupedCategory = groupBy(resultArray, groupByKey)
setAllWarnings(groupedCategory)
setWarningState(groupedCategory)
}
const showWarningsByModule = (showOnlyModule: string) => {
if(showOnlyModule && warningState[showOnlyModule]) {
if(allWarnings[showOnlyModule]) {
const newWarningState = {}
newWarningState[showOnlyModule] = warningState[showOnlyModule]
setWarningState({[showOnlyModule]: warningState[showOnlyModule]})
newWarningState[showOnlyModule] = allWarnings[showOnlyModule]
setWarningState({[showOnlyModule]: allWarnings[showOnlyModule]})
} else if (showOnlyModule === 'all') {
setWarningState(allWarnings)
}
}
@ -312,6 +317,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
const handleShowSlitherResultEnabled = () => {
if (slitherResultEnabled) {
setSlitherResultEnabled(false)
showWarningsByModule('all')
} else {
setSlitherResultEnabled(true)
showWarningsByModule('Slither Analysis')

Loading…
Cancel
Save