showing compilation details in main tab

pull/4153/head
Joseph Izang 1 year ago
parent 6c6889ef8b
commit f75d89943e
  1. 24
      apps/remix-ide/src/app/plugins/compile-details.tsx
  2. 59
      libs/remix-ui/solidity-compile-details/src/lib/solidity-compile-details.tsx
  3. 11
      libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
  4. 18
      libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx
  5. 5
      libs/remix-ui/solidity-compiler/src/lib/css/style.css
  6. 2
      libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx

@ -19,16 +19,25 @@ export class CompilationDetailsPlugin extends ViewPlugin {
dispatch: React.Dispatch<any> = () => {} dispatch: React.Dispatch<any> = () => {}
appManager: RemixAppManager appManager: RemixAppManager
element: HTMLDivElement element: HTMLDivElement
payload: any
constructor(appManager: RemixAppManager) { constructor(appManager: RemixAppManager) {
super(profile) super(profile)
this.appManager = appManager this.appManager = appManager
this.element = document.createElement('div') this.element = document.createElement('div')
this.element.setAttribute('id', 'compileDetails') this.element.setAttribute('id', 'compileDetails')
this.payload = {
contractProperties: {} as any,
intl: {} as any,
selectedContract: '',
help: {} as any,
insertValue: {} as any,
saveAs: {} as any,
}
} }
async onActivation() { async onActivation() {
await this.call('tabs', 'focus', 'compilationdetails')
this.renderComponent() this.renderComponent()
// await this.call('tabs', 'focus', 'compilationdetails')
_paq.push(['trackEvent', 'plugin', 'activated', 'compilationDetails']) _paq.push(['trackEvent', 'plugin', 'activated', 'compilationDetails'])
} }
@ -36,8 +45,9 @@ export class CompilationDetailsPlugin extends ViewPlugin {
} }
async showDetails() { async showDetails(sentPayload: any) {
await this.call('tabs', 'focus', 'compilationdetails') await this.call('tabs', 'focus', 'compilationdetails')
this.payload = sentPayload
this.renderComponent() this.renderComponent()
} }
@ -54,8 +64,8 @@ export class CompilationDetailsPlugin extends ViewPlugin {
renderComponent() { renderComponent() {
this.dispatch({ this.dispatch({
...this ...this,
...this.payload
}) })
} }
@ -63,6 +73,12 @@ export class CompilationDetailsPlugin extends ViewPlugin {
return ( return (
<RemixUiCompileDetails <RemixUiCompileDetails
plugin={this} plugin={this}
contractProperties={state.contractProperties}
intl={state.intl}
selectedContract={state.selectedContract}
saveAs={state.saveAs}
help={state.help}
insertValue={state.insertValue}
/> />
) )
} }

@ -1,14 +1,67 @@
import { CopyToClipboard } from '@remix-ui/clipboard'
import { TreeView, TreeViewItem } from '@remix-ui/tree-view'
import React from 'react' import React from 'react'
export interface RemixUiCompileDetailsProps { export interface RemixUiCompileDetailsProps {
plugin: any plugin: any
contractProperties: any
intl: any
selectedContract: string
help: any
insertValue: any
saveAs: any
} }
export function RemixUiCompileDetails({ plugin }: RemixUiCompileDetailsProps) { const _paq = (window._paq = window._paq || [])
export function RemixUiCompileDetails({ plugin, contractProperties, intl, selectedContract, saveAs, help, insertValue }: RemixUiCompileDetailsProps) {
const downloadFn = () => {
_paq.push(['trackEvent', 'compiler', 'compilerDetails', 'download'])
saveAs(new Blob([JSON.stringify(contractProperties, null, '\t')]), `${selectedContract}_compData.json`)
}
return ( return (
<> <>
<h1>Compile Details!!!</h1> <div>
<h3>Every thing works fine.</h3> <span>{selectedContract}</span><span>Download Compile details</span>
</div>
<div className="remixui_detailsJSON">
<TreeView>
{Object.keys(contractProperties).map((propertyName, index) => {
const copyDetails = (
<span className="remixui_copyDetails">
<CopyToClipboard tip={intl.formatMessage({id: 'solidity.copy'})} content={contractProperties[propertyName]} direction="top" />
</span>
)
const questionMark = (
<span className="remixui_questionMark">
<i
title={intl.formatMessage({
id: `solidity.${propertyName}`,
defaultMessage: help[propertyName]
})}
className="fas fa-question-circle"
aria-hidden="true"
></i>
</span>
)
return (
<div className="remixui_log" key={index}>
<TreeViewItem
label={
<div data-id={`remixui_treeviewitem_${propertyName}`} className="remixui_key">
{propertyName} {copyDetails} {questionMark}
</div>
}
>
{insertValue(contractProperties, propertyName)}
</TreeViewItem>
</div>
)
})}
</TreeView>
</div>
</> </>
) )
} }

@ -41,7 +41,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
//@ts-ignore //@ts-ignore
pluginProps pluginProps
} = props // eslint-disable-line } = props // eslint-disable-line
console.log({ props })
const [state, setState] = useState({ const [state, setState] = useState({
hideWarnings: false, hideWarnings: false,
autoCompile: false, autoCompile: false,
@ -1182,15 +1182,6 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
</CopyToClipboard> </CopyToClipboard>
</div> </div>
</div> </div>
<button className="btn btn-primary btn-block" onClick={async () => {
// console.log('activatePlugin')
(pluginProps.api as any).call('compilationDetails', 'showDetails')
}}>
<span>
Show Details
</span>
</button>
</article> </article>
</section> </section>
) )

@ -156,6 +156,15 @@ export const ContractSelection = (props: ContractSelectionProps) => {
return <pre className="remixui_value">{node || ''}</pre> return <pre className="remixui_value">{node || ''}</pre>
} }
const payload = {
saveAs: saveAs,
intl: intl,
contractProperties: {},
selectedContract: '',
help: {},
insertValue: insertValue
}
const details = () => { const details = () => {
_paq.push(['trackEvent', 'compiler', 'compilerDetails', 'display']) _paq.push(['trackEvent', 'compiler', 'compilerDetails', 'display'])
if (!selectedContract) throw new Error('No contract compiled yet') if (!selectedContract) throw new Error('No contract compiled yet')
@ -182,6 +191,10 @@ export const ContractSelection = (props: ContractSelectionProps) => {
// Make 'compilerInput' first field to display it as first item in 'Compilation Details' modal // Make 'compilerInput' first field to display it as first item in 'Compilation Details' modal
if (compilerInput) contractProperties.compilerInput = compilerInput if (compilerInput) contractProperties.compilerInput = compilerInput
contractProperties = Object.assign(contractProperties, contractsDetails[selectedContract]) contractProperties = Object.assign(contractProperties, contractsDetails[selectedContract])
payload.contractProperties = contractProperties
payload.selectedContract = selectedContract
payload.help = help
payload.insertValue = insertValue
const log = ( const log = (
<div className="remixui_detailsJSON"> <div className="remixui_detailsJSON">
<TreeView> <TreeView>
@ -225,7 +238,7 @@ export const ContractSelection = (props: ContractSelectionProps) => {
_paq.push(['trackEvent', 'compiler', 'compilerDetails', 'download']) _paq.push(['trackEvent', 'compiler', 'compilerDetails', 'download'])
saveAs(new Blob([JSON.stringify(contractProperties, null, '\t')]), `${selectedContract}_compData.json`) saveAs(new Blob([JSON.stringify(contractProperties, null, '\t')]), `${selectedContract}_compData.json`)
} }
modal(selectedContract, log, intl.formatMessage({id: 'solidity.download'}), downloadFn, true, intl.formatMessage({id: 'solidity.close'}), null) // modal(selectedContract, log, intl.formatMessage({id: 'solidity.download'}), downloadFn, true, intl.formatMessage({id: 'solidity.close'}), null)
} }
const copyBytecode = () => { const copyBytecode = () => {
@ -301,8 +314,9 @@ export const ContractSelection = (props: ContractSelectionProps) => {
<button <button
data-id="compilation-details" data-id="compilation-details"
className="btn btn-secondary btn-block" className="btn btn-secondary btn-block"
onClick={() => { onClick={async () => {
details() details()
await (api as any).call('compilationDetails', 'showDetails', payload)
}} }}
> >
<CustomTooltip <CustomTooltip

@ -245,3 +245,8 @@
70% { top: -0.3em; } 70% { top: -0.3em; }
100% { top: 0; } 100% { top: 0; }
} }
#compileDetails {
margin: 15px;
padding: 15px;
}

@ -13,7 +13,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
api, api,
api: {currentFile, compileTabLogic, configurationSettings} api: {currentFile, compileTabLogic, configurationSettings}
} = props } = props
console.log({ props })
const [state, setState] = useState({ const [state, setState] = useState({
isHardhatProject: false, isHardhatProject: false,
isTruffleProject: false, isTruffleProject: false,

Loading…
Cancel
Save