From 40ddf173168d3cc586030633ee8f251ebf9121c9 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 28 Jun 2023 12:39:57 +0100 Subject: [PATCH] Analyze button is enabled if none of Remix and Solhint are selected - fixed --- .../src/lib/reducers/staticAnalysisReducer.ts | 10 ++++++++++ .../src/lib/remix-ui-static-analyser.tsx | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libs/remix-ui/static-analyser/src/lib/reducers/staticAnalysisReducer.ts b/libs/remix-ui/static-analyser/src/lib/reducers/staticAnalysisReducer.ts index 1e12b09f03..001d9cc80a 100644 --- a/libs/remix-ui/static-analyser/src/lib/reducers/staticAnalysisReducer.ts +++ b/libs/remix-ui/static-analyser/src/lib/reducers/staticAnalysisReducer.ts @@ -1,3 +1,4 @@ +import { CompilationResult, SourceWithTarget } from "@remixproject/plugin-api" import { RemixUiStaticAnalyserReducerActionType, RemixUiStaticAnalyserState } from "../../staticanalyser" export const initialState: RemixUiStaticAnalyserState = { @@ -26,3 +27,12 @@ export const analysisReducer = (state: RemixUiStaticAnalyserState, return initialState } } + +type someReducerState = { + solhintEnabled?: boolean + basicEnabled?: boolean + slitherEnabled?: boolean + isSupportedVersion?: boolean + compiledState?: { data: CompilationResult, langVersion: string, fileName: string, source: SourceWithTarget, input: string } +} + diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index ee76d9b9fb..406f52321b 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -82,6 +82,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const [slitherWarnings, setSlitherWarnings] = useState([]) const [ssaWarnings, setSsaWarnings] = useState([]) + const warningContainer = useRef(null) const allWarnings = useRef({}) const [state, dispatch] = useReducer(analysisReducer, initialState) @@ -694,6 +695,7 @@ useEffect(() => { }).flat().every(el => categoryIndex.includes(el))} label="Remix" onClick={() => { + handleBasicEnabled() handleCheckAllModules(groupedModules) }} onChange={() => {}} @@ -738,7 +740,7 @@ useEffect(() => { classList="btn btn-sm btn-primary btn-block" onClick={async () => await run(state.data, state.source, state.file, state , props, isSupportedVersion, showSlither, categoryIndex, groupedModules, runner,_paq, message, showWarnings, allWarnings, warningContainer, calculateWarningStateEntries, warningState, setHints, hints, setSlitherWarnings, setSsaWarnings, slitherEnabled, setStartAnalysis, solhintEnabled, basicEnabled)} - disabled={(state.data === null || !isSupportedVersion) || (!solhintEnabled && !basicEnabled) } + disabled={(state.data === null || !isSupportedVersion) || (!solhintEnabled && !basicEnabled) } />} {state && state.data !== null && state.source !== null && state.file.length > 0 ? (
{slitherWarnings.length > 0 || hints.length > 0 || Object.entries(warningState).length > 0 ? (