finish conditional display of flattener button

pull/3321/head^2
Joseph Izang 2 years ago committed by Aniket
parent c4adffb706
commit e0fe97cb88
  1. 3
      libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
  2. 20
      libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx

@ -17,6 +17,7 @@ import axios, { AxiosResponse } from 'axios'
import './css/style.css'
const defaultPath = "compiler_config.json"
declare global {
@ -26,6 +27,8 @@ declare global {
}
}
type AstNode = { id: number, literals: string[], nodeType: string, src: string }
const _paq = window._paq = window._paq || [] //eslint-disable-line

@ -34,6 +34,7 @@ export const ContractSelection = (props: ContractSelectionProps) => {
}
}, [contractList])
const resetStorage = () => {
setStorage('')
}
@ -199,11 +200,6 @@ export const ContractSelection = (props: ContractSelectionProps) => {
return copyContractProperty('bytecode')
}
/**
* Local property to hold flattend contract result
*/
// let content4AST: string
/**
* Take AST and generates a UML diagram of compiled contract as svg
* @returns void
@ -235,8 +231,13 @@ export const ContractSelection = (props: ContractSelectionProps) => {
const sources = api.getCompilationResult().source.sources
setContent4AST(concatSourceFiles(sorted, sources))
}
const showFlattener = () => {
const confirmNodeType = api.getCompilationResult().data.sources[api.currentFile].ast.nodes.some(x => x.nodeType === 'ImportDirective')
const currentFile = api.currentFile.split('/')[1]
const contractListConfirm = contractList.some(x => x.file === currentFile)
return confirmNodeType && contractListConfirm
}
return (
// define swarm logo
<>
@ -250,16 +251,17 @@ export const ContractSelection = (props: ContractSelectionProps) => {
</select>
</div>
<article className="mt-2 pb-0">
<CustomTooltip
{showFlattener() && <CustomTooltip
placement="right-start"
tooltipId="flattenContractTooltip"
tooltipClasses="text-nowrap"
tooltipText={`${intl.formatMessage({ id: 'solidity.flattenLabel' })}`}
>
<button id="contractFlattener" onClick={flattenContract} className="btn btn-secondary btn-block mt-2">
<FormattedMessage id='solidity.flattenLabel' />{api.currentFile}
<FormattedMessage id='solidity.flattenLabel' /> {api.currentFile}
</button>
</CustomTooltip>
}
<CustomTooltip
placement="right-start"
tooltipId="generateUMLTooltip"

Loading…
Cancel
Save