From 9b3eda8e7fbbd321b52106b86652fbc8e5d50be1 Mon Sep 17 00:00:00 2001 From: tizah Date: Mon, 12 Apr 2021 12:51:49 +0100 Subject: [PATCH] added warning sign when analysis has runned --- apps/remix-ide/src/app/tabs/analysis-tab.js | 15 +++++++++++++-- .../src/lib/remix-ui-static-analyser.tsx | 19 +++++++++---------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/analysis-tab.js b/apps/remix-ide/src/app/tabs/analysis-tab.js index ad3c2fce54..b3bba2705c 100644 --- a/apps/remix-ide/src/app/tabs/analysis-tab.js +++ b/apps/remix-ide/src/app/tabs/analysis-tab.js @@ -56,10 +56,21 @@ class AnalysisTab extends ViewPlugin { analysisModule={this} event={this.event} />, - this.element + this.element, + () => { + this.event.register('staticAnaysisWarning', (count) => { + if (count > 0) { + this.emit('statusChanged', { key: count, title: `${count} warning${count === 1 ? '' : 's'}`, type: 'warning' }) + } else if (count === 0) { + this.emit('statusChanged', { key: 'succeed', title: 'no warning', type: 'success' }) + } else { + // count ==-1 no compilation result + this.emit('statusChanged', { key: 'none' }) + } + }) + } ) } - } module.exports = AnalysisTab 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 1674d66d84..81d4e29e15 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 @@ -1,4 +1,5 @@ import React, { useEffect, useState } from 'react' +import ReactDOM from 'react-dom' //eslint-disable-line import CheckBox from './Checkbox/StaticAnalyserCheckedBox' // eslint-disable-line import Button from './Button/StaticAnalyserButton' // eslint-disable-line import remixLib from '@remix-project/remix-lib' @@ -18,7 +19,8 @@ export interface RemixUiStaticAnalyserProps { registry: any, event: any, analysisModule: any - _deps: any + _deps: any, + emit: any } export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { @@ -63,7 +65,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const warningContainer = React.useRef(null) const [runButtonState, setRunButtonState] = useState(true) - const [autoRun, setAutoRun] = useState(true) + const [autoRun, setAutoRun] = useState(false) const [result, setResult] = useState({ lastCompilationResult: null, lastCompilationSource: null, @@ -96,7 +98,10 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } ) } + } else { + setAutoRun(true) } + return () => { } }, [autoRun]) @@ -105,6 +110,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { // await props.analysisModule.call('editor', 'discardHighlight') // await props.analysisModule.call('editor', 'highlight', location, fileName) // } + console.log({ autoRun }, ' auto run in run function') setResult({ lastCompilationResult, lastCompilationSource, currentFile }) if (lastCompilationResult && categoryIndex.length) { setRunButtonState(false) @@ -193,6 +199,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const groupedCategory = groupBy(resultArray, 'warningModuleName') setWarningState(groupedCategory) }) + props.event.trigger('staticAnaysisWarning', [warningCount]) } else { setRunButtonState(true) @@ -203,14 +210,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } } - // const correctRunBtnDisabled = () => { - // if (props.lastCompilationResult && selectedCategoryIndex.length !== 0) { - // setRunButtonState(false) - // } else { - // setRunButtonState(true) - // } - // } - const handleCheckAllModules = (groupedModules) => { const index = groupedModuleIndex(groupedModules) if (index.every(el => categoryIndex.includes(el))) {