Merge pull request #3005 from ethereum/custom-tooltips-ssa

Custom tooltips for Static Analysis
pull/5370/head
Joseph Izang 2 years ago committed by GitHub
commit 28e1839b76
  1. 46
      libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.tsx
  2. 18
      libs/remix-ui/static-analyser/src/lib/Button/StaticAnalyserButton.tsx
  3. 6
      libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx

@ -1,5 +1,8 @@
import React, { CSSProperties } from 'react' //eslint-disable-line import React, { CSSProperties } from 'react' //eslint-disable-line
import { OverlayProps, OverlayTrigger, OverlayTriggerProps, Tooltip } from 'react-bootstrap'// eslint-disable-line
import './remix-ui-checkbox.css' import './remix-ui-checkbox.css'
type Placement = import('react-overlays/usePopper').Placement;
/* eslint-disable-next-line */ /* eslint-disable-next-line */
export interface RemixUiCheckboxProps { export interface RemixUiCheckboxProps {
@ -15,6 +18,7 @@ export interface RemixUiCheckboxProps {
title?: string title?: string
visibility?: string visibility?: string
display?: string display?: string
tooltipPlacement?: Placement
} }
export const RemixUiCheckbox = ({ export const RemixUiCheckbox = ({
@ -29,24 +33,34 @@ export const RemixUiCheckbox = ({
categoryId, categoryId,
title, title,
visibility, visibility,
display = 'flex' display = 'flex',
tooltipPlacement = 'right-start'
}: RemixUiCheckboxProps) => { }: RemixUiCheckboxProps) => {
return ( return (
<div className="listenOnNetwork_2A0YE0 custom-control custom-checkbox" title={title} style={{ display: display, alignItems: 'center', visibility: visibility } as CSSProperties } onClick={onClick}> <OverlayTrigger
<input placement={tooltipPlacement}
id={id} overlay={
type={inputType} <Tooltip id={`${name}Tooltip`}>
onChange={onChange} <span>{title}</span>
style={{ verticalAlign: 'bottom' }} </Tooltip>
name={name} }
className="custom-control-input" >
checked={checked} <div className="listenOnNetwork_2A0YE0 custom-control custom-checkbox" style={{ display: display, alignItems: 'center', visibility: visibility } as CSSProperties } onClick={onClick}>
/> <input
<label className="form-check-label custom-control-label" id={`heading${categoryId}`} style={{ paddingTop: '0.15rem' }}> id={id}
{name ? <div className="font-weight-bold">{itemName}</div> : ''} type={inputType}
{label} onChange={onChange}
</label> style={{ verticalAlign: 'bottom' }}
</div> name={name}
className="custom-control-input"
checked={checked}
/>
<label className="form-check-label custom-control-label" id={`heading${categoryId}`} style={{ paddingTop: '0.15rem' }}>
{name ? <div className="font-weight-bold">{itemName}</div> : ''}
{label}
</label>
</div>
</OverlayTrigger>
) )
} }

@ -1,4 +1,5 @@
import React from 'react' //eslint-disable-line import React from 'react' //eslint-disable-line
import { OverlayTrigger, Tooltip } from 'react-bootstrap'
interface StaticAnalyserButtonProps { interface StaticAnalyserButtonProps {
onClick: (event) => void onClick: (event) => void
@ -14,10 +15,21 @@ const StaticAnalyserButton = ({
title title
}: StaticAnalyserButtonProps) => { }: StaticAnalyserButtonProps) => {
let classList = "btn btn-sm w-25 btn-primary" let classList = "btn btn-sm w-25 btn-primary"
classList += disabled ? " disabled" : "" classList += disabled ? " disabled" : ""
return ( return (
<button className={classList} disabled={disabled} title={title} onClick={onClick}> <button className={classList} disabled={disabled} onClick={onClick}>
{buttonText} <OverlayTrigger
placement="bottom-start"
overlay={
<Tooltip id="ssaRunButtonTooltip" className="text-nowrap">
<span>{title}</span>
</Tooltip>
}
>
<span>
{buttonText}
</span>
</OverlayTrigger>
</button> </button>
) )
} }

@ -255,7 +255,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
if(fileName !== currentFile) { if(fileName !== currentFile) {
const {file, provider} = await props.analysisModule.call('fileManager', 'getPathFromUrl', fileName) const {file, provider} = await props.analysisModule.call('fileManager', 'getPathFromUrl', fileName)
if (file.startsWith('.deps') || (provider.type === 'localhost' && file.startsWith('localhost/node_modules'))) isLibrary = true if (file.startsWith('.deps') || (provider.type === 'localhost' && file.startsWith('localhost/node_modules'))) isLibrary = true
} }
const msg = message(result.name, item.warning, item.more, fileName, locationString) const msg = message(result.name, item.warning, item.more, fileName, locationString)
const options = { const options = {
type: 'warning', type: 'warning',
@ -321,7 +321,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
if(fileName !== currentFile) { if(fileName !== currentFile) {
const {file, provider} = await props.analysisModule.call('fileManager', 'getPathFromUrl', fileName) const {file, provider} = await props.analysisModule.call('fileManager', 'getPathFromUrl', fileName)
if (file.startsWith('.deps') || (provider.type === 'localhost' && file.startsWith('localhost/node_modules'))) isLibrary = true if (file.startsWith('.deps') || (provider.type === 'localhost' && file.startsWith('localhost/node_modules'))) isLibrary = true
} }
const msg = message(item.title, item.description, item.more, fileName, locationString) const msg = message(item.title, item.description, item.more, fileName, locationString)
const options = { const options = {
type: 'warning', type: 'warning',
@ -490,6 +490,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
label="Select all" label="Select all"
onClick={() => handleCheckAllModules(groupedModules)} onClick={() => handleCheckAllModules(groupedModules)}
onChange={() => {}} onChange={() => {}}
tooltipPlacement={'top-start'}
/> />
<RemixUiCheckbox <RemixUiCheckbox
id="autorunstaticanalysis" id="autorunstaticanalysis"
@ -499,6 +500,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
checked={autoRun} checked={autoRun}
label="Autorun" label="Autorun"
onChange={() => {}} onChange={() => {}}
tooltipPlacement={'bottom-start'}
/> />
<Button <Button
buttonText="Run" buttonText="Run"

Loading…
Cancel
Save