cleanup of conditional render of tabs

pull/3642/head
Joseph Izang 2 years ago
parent 5bd0ab11c8
commit e638cc7db5
  1. 2
      libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts
  2. 42
      libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx

@ -1,6 +1,6 @@
import { CompilationResult, SourceWithTarget } from '@remixproject/plugin-api' import { CompilationResult, SourceWithTarget } from '@remixproject/plugin-api'
import React from 'react' //eslint-disable-line import React from 'react' //eslint-disable-line
import { AnalysisTab, RemixUiStaticAnalyserReducerActionType, SolHintReport } from '../../staticanalyser' import { AnalysisTab, RemixUiStaticAnalyserReducerActionType } from '../../staticanalyser'
/** /**
* *

@ -255,11 +255,14 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
} }
} }
const handleSlitherEnabled = () => { const handleSlitherEnabled = async () => {
if (slitherEnabled) { const slitherStatus = await props.analysisModule.call('manager', 'isActive', 'remixd')
if (slitherEnabled && slitherStatus) {
setSlitherEnabled(false) setSlitherEnabled(false)
setShowSlither(false)
} else { } else {
setSlitherEnabled(true) setSlitherEnabled(true)
setShowSlither(true)
} }
} }
@ -356,7 +359,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
} }
const handleHideWarnings = () => { const handleHideWarnings = () => {
setHideWarnings(!hideWarnings)
} }
const tabKeys = [ const tabKeys = [
@ -436,6 +439,14 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
} }
] ]
const checkBasicStatus = () => {
return Object.values(groupedModules).map((value: any) => {
return (value.map(x => {
return x._index.toString()
}))
}).flat().every(el => categoryIndex.includes(el))
}
return ( return (
<div className="analysis_3ECCBV px-3 pb-1"> <div className="analysis_3ECCBV px-3 pb-1">
<div className="my-2 d-flex flex-column align-items-left"> <div className="my-2 d-flex flex-column align-items-left">
@ -462,7 +473,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
}).flat().every(el => categoryIndex.includes(el))} }).flat().every(el => categoryIndex.includes(el))}
label="Basic" label="Basic"
onClick={() => { onClick={() => {
handleBasicEnabled()
handleCheckAllModules(groupedModules) handleCheckAllModules(groupedModules)
}} }}
onChange={() => {}} onChange={() => {}}
@ -474,7 +484,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
onClick={handleSlitherEnabled} onClick={handleSlitherEnabled}
checked={slitherEnabled} checked={slitherEnabled}
label="Slither" label="Slither"
disabled={showSlither}
onChange={() => {}} onChange={() => {}}
/> />
</div> </div>
@ -522,7 +531,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
<Tabs defaultActiveKey={tabKeys[0].tabKey}> <Tabs defaultActiveKey={tabKeys[0].tabKey}>
{solhintEnabled ? <Tab {solhintEnabled ? <Tab
key={tabKeys[0].tabKey} key={tabKeys[0].tabKey}
disabled={solhintEnabled}
title={tabKeys[0].title} title={tabKeys[0].title}
eventKey={tabKeys[0].tabKey} eventKey={tabKeys[0].tabKey}
tabClassName="text-decoration-none font-weight-bold" tabClassName="text-decoration-none font-weight-bold"
@ -530,19 +538,19 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
{tabKeys[0].child} {tabKeys[0].child}
</Tab> : null} </Tab> : null}
{basicEnabled ? <Tab {
key={tabKeys[1].tabKey} checkBasicStatus() ? <Tab
disabled={basicEnabled} key={tabKeys[1].tabKey}
title={tabKeys[1].title} title={tabKeys[1].title}
eventKey={tabKeys[1].tabKey} eventKey={tabKeys[1].tabKey}
tabClassName="text-decoration-none font-weight-bold" tabClassName="text-decoration-none font-weight-bold"
> >
{tabKeys[1].child} {tabKeys[1].child}
</Tab> : null} </Tab> : null
}
{ slitherEnabled ? <Tab { showSlither ? <Tab
key={tabKeys[2].tabKey} key={tabKeys[2].tabKey}
disabled={slitherEnabled}
title={tabKeys[2].title} title={tabKeys[2].title}
eventKey={tabKeys[2].tabKey} eventKey={tabKeys[2].tabKey}
tabClassName="text-decoration-none font-weight-bold" tabClassName="text-decoration-none font-weight-bold"

Loading…
Cancel
Save