pull/3321/head^2
Joseph Izang 2 years ago committed by Aniket
parent 04a6ff9834
commit cf2ea03674
  1. 2
      apps/remix-ide/src/app/panels/tab-proxy.js
  2. 13
      apps/remix-ide/src/app/plugins/solidity-umlgen.tsx
  3. 10
      libs/remix-ui/solidity-uml-gen/src/lib/solidity-uml-gen.tsx

@ -33,7 +33,7 @@ export class TabProxy extends Plugin {
this.on('fileManager', 'filesAllClosed', () => {
this.call('manager', 'activatePlugin', 'home')
this.tabsApi.activateTab('home')
this.focus('home')
})
this.on('fileManager', 'fileRemoved', (name) => {

@ -18,7 +18,7 @@ const profile = {
displayName: 'Solidity UML Generator',
description: 'Generate UML diagram in svg format from last compiled contract',
location: 'mainPanel',
methods: ['showUmlDiagram', 'generateUml', 'generateCustomAction', 'flattenAContract'],
methods: ['showUmlDiagram', 'generateUml', 'generateCustomAction'],
events: [],
}
@ -56,7 +56,6 @@ export class SolidityUmlGen extends ViewPlugin implements ISolidityUmlGen {
const umlClasses = convertAST2UmlClasses(ast, this.currentFile)
const umlDot = convertUmlClasses2Dot(umlClasses)
const payload = vizRenderStringSync(umlDot)
console.log({ umlClasses, umlDot, payload })
this.updatedSvg = payload
this.renderComponent()
} catch (error) {
@ -98,15 +97,6 @@ export class SolidityUmlGen extends ViewPlugin implements ISolidityUmlGen {
this.renderComponent()
}
async flattenAContract(action: customAction) {
const fileName = action.path[0]
this.call('solidity', 'compile', fileName)
this.on('solidity', 'compilationFinished', async (file, source, languageVersion, data, input, version) => {
await this.flattenContract(source, fileName, data)
})
this.off('solidity', 'compilationFinished')
}
/**
* Takes currently compiled contract that has a bunch of imports at the top
* and flattens them ready for UML creation. Takes the flattened result
@ -114,6 +104,7 @@ export class SolidityUmlGen extends ViewPlugin implements ISolidityUmlGen {
* @returns {Promise<string>}
*/
async flattenContract (source: any, filePath: string, data: any) {
const hold = { data, source, filePath }
const ast = data.sources
const dependencyGraph = getDependencyGraph(ast, filePath)
const sorted = dependencyGraph.isEmpty()

@ -83,7 +83,7 @@ export function RemixUiSolidityUmlGen ({ plugin, updatedSvg, loading, themeSelec
const invert = themeSelected === 'dark' ? 'invert(1)' : 'invert(0)'
return (
<div className="d-flex flex-column justify-content-center align-items-center">
<div id="umlImageHolder">
<div id="umlImageHolder" className="w-100 px-2 py-2">
{ validSvg && showViewer ? (
<TransformWrapper
initialScale={1}
@ -91,16 +91,10 @@ export function RemixUiSolidityUmlGen ({ plugin, updatedSvg, loading, themeSelec
{
({ zoomIn, zoomOut, resetTransform }) => (
<Fragment>
{/* <div className="position-relative">
<button className="btn position-absolute top-0 end-100 translate-middle btn-sm mr-1 rounded-circle btn-success" onClick={() => zoomIn()}>+</button>
<button className="btn position-absolute top-0 end-100 translate-middle btn-sm mr-1 rounded-circle btn-warning" onClick={() => zoomOut()}>-</button>
<button className="btn position-absolute top-0 end-100 translate-middle btn-sm mr-1 rounded-circle btn-danger" onClick={() => resetTransform()}>X</button>
<ActionButtons buttons={buttons}/>
</div> */}
<TransformComponent>
<img
src={`data:image/svg+xml;base64,${btoa(plugin.updatedSvg ?? svgPayload)}`}
width={950}
width={'100%'}
height={'auto'}
style={{ filter: invert }}
/>

Loading…
Cancel
Save