diff --git a/apps/remix-ide/src/app/components/hidden-panel.tsx b/apps/remix-ide/src/app/components/hidden-panel.tsx index bfdff5a11a..31c7a0cb0b 100644 --- a/apps/remix-ide/src/app/components/hidden-panel.tsx +++ b/apps/remix-ide/src/app/components/hidden-panel.tsx @@ -1,9 +1,9 @@ // eslint-disable-next-line no-use-before-define import React from 'react' -import ReactDOM from 'react-dom' // eslint-disable-line import { AbstractPanel } from './panel' import * as packageJson from '../../../../../package.json' import { RemixPluginPanel } from '@remix-ui/panel' +import { PluginViewWrapper } from '@remix-ui/helper' const profile = { name: 'hiddenPanel', @@ -15,6 +15,7 @@ const profile = { export class HiddenPanel extends AbstractPanel { el: HTMLElement + dispatch: React.Dispatch = () => {} constructor () { super(profile) this.el = document.createElement('div') @@ -27,11 +28,23 @@ export class HiddenPanel extends AbstractPanel { this.renderComponent() } - render () { - return this.el + updateComponent (state: any) { + return } plugins={state.plugins}/> + } + + setDispatch (dispatch: React.Dispatch) { + this.dispatch = dispatch + } + + render() { + return ( +
+ ); } renderComponent () { - ReactDOM.render(} plugins={this.plugins}/>, this.el) + this.dispatch({ + plugins: this.plugins, + }) } } diff --git a/apps/remix-ide/src/app/components/main-panel.tsx b/apps/remix-ide/src/app/components/main-panel.tsx index b9d180f194..615e03690d 100644 --- a/apps/remix-ide/src/app/components/main-panel.tsx +++ b/apps/remix-ide/src/app/components/main-panel.tsx @@ -1,8 +1,8 @@ import React from 'react' // eslint-disable-line import { AbstractPanel } from './panel' -import ReactDOM from 'react-dom' // eslint-disable-line import { RemixPluginPanel } from '@remix-ui/panel' import packageJson from '../../../../../package.json' +import { PluginViewWrapper } from '@remix-ui/helper' const profile = { name: 'mainPanel', @@ -14,6 +14,7 @@ const profile = { export class MainPanel extends AbstractPanel { element: HTMLDivElement + dispatch: React.Dispatch = () => {} constructor (config) { super(profile) this.element = document.createElement('div') @@ -22,6 +23,10 @@ export class MainPanel extends AbstractPanel { // this.config = config } + setDispatch (dispatch: React.Dispatch) { + this.dispatch = dispatch + } + onActivation () { this.renderComponent() } @@ -47,11 +52,17 @@ export class MainPanel extends AbstractPanel { this.renderComponent() } - render () { - return this.element + renderComponent () { + this.dispatch({ + plugins: this.plugins + }) + } + + render() { + return
} - renderComponent () { - ReactDOM.render(} plugins={this.plugins}/>, this.element) + updateComponent (state: any) { + return } plugins={state.plugins}/> } } diff --git a/apps/remix-ide/src/app/components/plugin-manager-component.js b/apps/remix-ide/src/app/components/plugin-manager-component.js index 72acd7cbf6..00013ee545 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -1,8 +1,8 @@ import { ViewPlugin } from '@remixproject/engine-web' import React from 'react' // eslint-disable-line -import ReactDOM from 'react-dom' import {RemixUiPluginManager} from '@remix-ui/plugin-manager' // eslint-disable-line import * as packageJson from '../../../../../package.json' +import { PluginViewWrapper } from '@remix-ui/helper' const _paq = window._paq = window._paq || [] const profile = { @@ -31,6 +31,7 @@ class PluginManagerComponent extends ViewPlugin { this.inactivePlugins = [] this.activeProfiles = this.appManager.actives this._paq = _paq + this.dispatch = null this.listenOnEvent() } @@ -40,7 +41,7 @@ class PluginManagerComponent extends ViewPlugin { * RemixAppManager * @param {string} name name of Plugin */ - isActive (name) { + isActive = (name) =>{ return this.appManager.actives.includes(name) } @@ -49,7 +50,7 @@ class PluginManagerComponent extends ViewPlugin { * RemixAppManager to enable plugin activation * @param {string} name name of Plugin */ - activateP (name) { + activateP = (name) => { this.appManager.activatePlugin(name) _paq.push(['trackEvent', 'manager', 'activate', name]) } @@ -60,7 +61,7 @@ class PluginManagerComponent extends ViewPlugin { * @param {Profile} pluginName * @returns {void} */ - async activateAndRegisterLocalPlugin (localPlugin) { + activateAndRegisterLocalPlugin = async (localPlugin) => { if (localPlugin) { this.engine.register(localPlugin) this.appManager.activatePlugin(localPlugin.profile.name) @@ -75,28 +76,33 @@ class PluginManagerComponent extends ViewPlugin { * of the plugin * @param {string} name name of Plugin */ - deactivateP (name) { + deactivateP = (name) => { this.call('manager', 'deactivatePlugin', name) _paq.push(['trackEvent', 'manager', 'deactivate', name]) } - onActivation () { + setDispatch (dispatch) { + this.dispatch = dispatch this.renderComponent() } + updateComponent(state){ + return + } + renderComponent () { - ReactDOM.render( - , - this.htmlElement) + if(this.dispatch) this.dispatch({...this, activePlugins: this.activePlugins, inactivePlugins: this.inactivePlugins}) } render () { - return this.htmlElement + return ( +
+ ); + } - getAndFilterPlugins (filter) { + getAndFilterPlugins = (filter) => { this.filter = typeof filter === 'string' ? filter.toLowerCase() : this.filter const isFiltered = (profile) => (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(this.filter) diff --git a/apps/remix-ide/src/app/components/side-panel.tsx b/apps/remix-ide/src/app/components/side-panel.tsx index b5e9dcd3df..bf82defe55 100644 --- a/apps/remix-ide/src/app/components/side-panel.tsx +++ b/apps/remix-ide/src/app/components/side-panel.tsx @@ -1,10 +1,10 @@ // eslint-disable-next-line no-use-before-define import React from 'react' -import ReactDOM from 'react-dom' import { AbstractPanel } from './panel' import { RemixPluginPanel } from '@remix-ui/panel' import packageJson from '../../../../../package.json' import RemixUIPanelHeader from 'libs/remix-ui/panel/src/lib/plugins/panel-header' +import { PluginViewWrapper } from '@remix-ui/helper' // const csjs = require('csjs-inject') const sidePanel = { @@ -17,6 +17,7 @@ const sidePanel = { export class SidePanel extends AbstractPanel { sideelement: any + dispatch: React.Dispatch = () => {} constructor() { super(sidePanel) this.sideelement = document.createElement('section') @@ -78,11 +79,23 @@ export class SidePanel extends AbstractPanel { this.renderComponent() } - render() { - return this.sideelement + setDispatch (dispatch: React.Dispatch) { + this.dispatch = dispatch + } + + render() { + return ( +
+ ); + } + + updateComponent(state: any) { + return } plugins={state.plugins} /> } renderComponent() { - ReactDOM.render(} plugins={this.plugins} />, this.sideelement) + this.dispatch({ + plugins: this.plugins + }) } } diff --git a/apps/remix-ide/src/app/components/vertical-icons.tsx b/apps/remix-ide/src/app/components/vertical-icons.tsx index eea114b637..bc70fd812c 100644 --- a/apps/remix-ide/src/app/components/vertical-icons.tsx +++ b/apps/remix-ide/src/app/components/vertical-icons.tsx @@ -1,11 +1,11 @@ // eslint-disable-next-line no-use-before-define import React from 'react' -import ReactDOM from 'react-dom' import packageJson from '../../../../../package.json' import { Plugin } from '@remixproject/engine' import { EventEmitter } from 'events' import { IconRecord, RemixUiVerticalIconsPanel } from '@remix-ui/vertical-icons-panel' import { Profile } from '@remixproject/plugin-utils' +import { PluginViewWrapper } from '@remix-ui/helper' const profile = { name: 'menuicons', @@ -20,6 +20,7 @@ export class VerticalIcons extends Plugin { events: EventEmitter htmlElement: HTMLDivElement icons: Record = {} + dispatch: React.Dispatch = () => {} constructor () { super(profile) this.events = new EventEmitter() @@ -46,12 +47,15 @@ export class VerticalIcons extends Plugin { ...divived.filter((value) => { return !value.isRequired }) ] - ReactDOM.render( - , - this.htmlElement) + this.dispatch({ + verticalIconsPlugin: this, + icons: sorted + }) + + } + + setDispatch (dispatch: React.Dispatch) { + this.dispatch = dispatch } onActivation () { @@ -107,7 +111,16 @@ export class VerticalIcons extends Plugin { this.events.emit('toggleContent', name) } - render () { - return this.htmlElement + updateComponent(state: any){ + return + } + + render() { + return ( +
+ ); } } diff --git a/apps/remix-ide/src/app/editor/editor.js b/apps/remix-ide/src/app/editor/editor.js index d15fe531a1..e7887df7e2 100644 --- a/apps/remix-ide/src/app/editor/editor.js +++ b/apps/remix-ide/src/app/editor/editor.js @@ -1,9 +1,9 @@ 'use strict' import React from 'react' // eslint-disable-line -import ReactDOM from 'react-dom' import { EditorUI } from '@remix-ui/editor' // eslint-disable-line import { Plugin } from '@remixproject/engine' import * as packageJson from '../../../../../package.json' +import { PluginViewWrapper } from '@remix-ui/helper' const EventManager = require('../../lib/events') @@ -61,10 +61,29 @@ class Editor extends Plugin { // to be implemented by the react component this.api = {} + this.dispatch = null + this.ref = null + } + + setDispatch (dispatch) { + this.dispatch = dispatch + } + + updateComponent(state) { + return } render () { - if (this.el) return this.el + +/* if (this.el) return this.el this.el = document.createElement('div') this.el.setAttribute('id', 'editorView') @@ -76,22 +95,34 @@ class Editor extends Plugin { } } this.el.gotoLine = (line, column) => this.gotoLine(line, column || 0) - this.el.getCursorPosition = () => this.getCursorPosition() - return this.el + this.el.getCursorPosition = () => this.getCursorPosition() */ + + return
{ + this.ref = element + this.ref.currentContent = () => this.currentContent() // used by e2e test + this.ref.setCurrentContent = (value) => { + if (this.sessions[this.currentFile]) { + this.sessions[this.currentFile].setValue(value) + this._onChange(this.currentFile) + } + } + this.ref.gotoLine = (line, column) => this.gotoLine(line, column || 0) + this.ref.getCursorPosition = () => this.getCursorPosition() + }} id='editorView'> + +
} renderComponent () { - ReactDOM.render( - - , this.el) + this.dispatch({ + api: this.api, + currentThemeType: this.currentThemeType, + currentFile: this.currentFile, + sourceAnnotationsPerFile: this.sourceAnnotationsPerFile, + markerPerFile: this.markerPerFile, + events: this.events, + plugin: this + }) } triggerEvent (name, params) { diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index 47e40a2f5f..6c5e4d0235 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -2,7 +2,6 @@ import { ViewPlugin } from '@remixproject/engine-web' import * as packageJson from '../../../../../package.json' import React from 'react' // eslint-disable-line -import ReactDOM from 'react-dom' import { FileSystemProvider } from '@remix-ui/workspace' // eslint-disable-line import Registry from '../state/registry' import { RemixdHandle } from '../plugins/remixd-handle' @@ -58,18 +57,8 @@ module.exports = class Filepanel extends ViewPlugin { this.currentWorkspaceMetadata = {} } - onActivation () { - this.renderComponent() - } - render () { - return this.el - } - - renderComponent () { - ReactDOM.render( - - , this.el) + return
} /** diff --git a/apps/remix-ide/src/app/panels/tab-proxy.js b/apps/remix-ide/src/app/panels/tab-proxy.js index a713b4bd02..1671648a36 100644 --- a/apps/remix-ide/src/app/panels/tab-proxy.js +++ b/apps/remix-ide/src/app/panels/tab-proxy.js @@ -1,8 +1,7 @@ import React from 'react' // eslint-disable-line -import ReactDOM from 'react-dom' import { Plugin } from '@remixproject/engine' import { TabsUI } from '@remix-ui/tabs' -import { getPathIcon } from '@remix-ui/helper' +import { PluginViewWrapper, getPathIcon } from '@remix-ui/helper' const EventEmitter = require('events') const profile = { @@ -11,7 +10,6 @@ const profile = { kind: 'other' } -// @todo(#650) Merge this with MainPanel into one plugin export class TabProxy extends Plugin { constructor (fileManager, editor) { super(profile) @@ -23,6 +21,7 @@ export class TabProxy extends Plugin { this._handlers = {} this.loadedTabs = [] this.el = document.createElement('div') + this.dispatch = null } onActivation () { @@ -286,6 +285,15 @@ export class TabProxy extends Plugin { this.handlers[type] = fn } + setDispatch (dispatch) { + this.dispatch = dispatch + this.renderComponent() + } + + updateComponent(state) { + return + } + renderComponent () { const onSelect = (index) => { if (this.loadedTabs[index]) { @@ -308,12 +316,17 @@ export class TabProxy extends Plugin { const onReady = (api) => { this.tabsApi = api } - ReactDOM.render( - - , this.el) + this.dispatch({ + loadedTabs: this.loadedTabs, + onSelect, + onClose, + onZoomIn, + onZoomOut, + onReady + }) } renderTabsbar () { - return this.el + return
} } diff --git a/apps/remix-ide/src/app/panels/terminal.js b/apps/remix-ide/src/app/panels/terminal.js index 0854f7586e..6eaa65f6e9 100644 --- a/apps/remix-ide/src/app/panels/terminal.js +++ b/apps/remix-ide/src/app/panels/terminal.js @@ -1,15 +1,16 @@ /* global Node, requestAnimationFrame */ // eslint-disable-line import React from 'react' // eslint-disable-line -import ReactDOM from 'react-dom' import { RemixUiTerminal } from '@remix-ui/terminal' // eslint-disable-line import { Plugin } from '@remixproject/engine' import * as packageJson from '../../../../../package.json' import Registry from '../state/registry' +import { PluginViewWrapper } from '@remix-ui/helper' const vm = require('vm') const EventManager = require('../../lib/events') import { CompilerImports } from '@remix-project/core-plugin' // eslint-disable-line + const KONSOLES = [] function register (api) { KONSOLES.push(api) } @@ -79,9 +80,12 @@ class Terminal extends Plugin { this.call('menuicons', 'select', 'debugger') this.call('debugger', 'debug', hash) }) + this.dispatch = null + } + - onActivation () { + onActivation() { this.renderComponent() } @@ -100,19 +104,27 @@ class Terminal extends Plugin { this.terminalApi.log(message) } + setDispatch(dispatch) { + this.dispatch = dispatch + } + render () { - return this.element + return
+ } + + updateComponent(state) { + return } renderComponent () { const onReady = (api) => { this.terminalApi = api } - ReactDOM.render( - , - this.element - ) + this.dispatch({ + plugin: this, + onReady: onReady + }) } scroll2bottom () { diff --git a/apps/remix-ide/src/app/tabs/analysis-tab.js b/apps/remix-ide/src/app/tabs/analysis-tab.js index dcd894d02c..f17b0da52b 100644 --- a/apps/remix-ide/src/app/tabs/analysis-tab.js +++ b/apps/remix-ide/src/app/tabs/analysis-tab.js @@ -1,10 +1,10 @@ import React from 'react' // eslint-disable-line import { ViewPlugin } from '@remixproject/engine-web' -import ReactDOM from 'react-dom' import { EventEmitter } from 'events' import {RemixUiStaticAnalyser} from '@remix-ui/static-analyser' // eslint-disable-line import * as packageJson from '../../../../../package.json' import Registry from '../state/registry' +import { PluginViewWrapper } from '@remix-ui/helper' var EventManager = require('../../lib/events') @@ -35,6 +35,7 @@ class AnalysisTab extends ViewPlugin { offsetToLineColumnConverter: this.registry.get( 'offsettolinecolumnconverter').api } + this.dispatch = null } async onActivation () { @@ -43,33 +44,40 @@ class AnalysisTab extends ViewPlugin { await this.call('manager', 'activatePlugin', 'solidity') } this.renderComponent() + 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' }) + } + }) + } + + setDispatch (dispatch) { + this.dispatch = dispatch } render () { - return this.element + return
+ } + + updateComponent(state) { + return } renderComponent () { - ReactDOM.render( - , - 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' }) - } - }) - } - ) + this.dispatch({ + registry: this.registry, + analysisModule: this, + event: this.event + }) } } diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 4718b4dee6..da85e7ea61 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -1,6 +1,5 @@ /* global */ import React from 'react' // eslint-disable-line -import ReactDOM from 'react-dom' import { SolidityCompiler } from '@remix-ui/solidity-compiler' // eslint-disable-line import { CompileTabLogic } from '@remix-ui/solidity-compiler' // eslint-disable-line import { CompilerApiMixin } from '@remixproject/solidity-compiler-plugin' // eslint-disable-line @@ -42,9 +41,7 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA } renderComponent () { - ReactDOM.render( - - , this.el) + // empty method, is a state update needed? } onCurrentFileChanged () { @@ -68,9 +65,7 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA } render () { - this.renderComponent() - - return this.el + return
} async compileWithParameters (compilationTargets, settings) { diff --git a/apps/remix-ide/src/app/tabs/debugger-tab.js b/apps/remix-ide/src/app/tabs/debugger-tab.js index 6ac7235c09..63debf4553 100644 --- a/apps/remix-ide/src/app/tabs/debugger-tab.js +++ b/apps/remix-ide/src/app/tabs/debugger-tab.js @@ -3,7 +3,6 @@ import { DebuggerApiMixin } from '@remixproject/debugger-plugin' // eslint-disab import { ViewPlugin } from '@remixproject/engine-web' import * as packageJson from '../../../../../package.json' import React from 'react' // eslint-disable-line -import ReactDOM from 'react-dom' import * as remixBleach from '../../lib/remixBleach' import { compilationFinishedToastMsg, compilingToastMsg, localCompilationToastMsg, notFoundToastMsg, sourceVerificationNotAvailableToastMsg } from '@remix-ui/helper' const css = require('./styles/debugger-tab-styles') @@ -51,9 +50,7 @@ export class DebuggerTab extends DebuggerApiMixin(ViewPlugin) { this.on('fetchAndCompile', 'sourceVerificationNotAvailable', () => { this.call('notification', 'toast', sourceVerificationNotAvailableToastMsg()) }) - - this.renderComponent() - return this.el + return
} showMessage (title, message) { @@ -68,9 +65,4 @@ export class DebuggerTab extends DebuggerApiMixin(ViewPlugin) { } } - renderComponent () { - ReactDOM.render( - - , this.el) - } } diff --git a/apps/remix-ide/src/app/tabs/settings-tab.js b/apps/remix-ide/src/app/tabs/settings-tab.tsx similarity index 62% rename from apps/remix-ide/src/app/tabs/settings-tab.js rename to apps/remix-ide/src/app/tabs/settings-tab.tsx index 133ae6ee5f..25ea5fb934 100644 --- a/apps/remix-ide/src/app/tabs/settings-tab.js +++ b/apps/remix-ide/src/app/tabs/settings-tab.tsx @@ -1,9 +1,9 @@ import React from 'react' // eslint-disable-line import { ViewPlugin } from '@remixproject/engine-web' -import ReactDOM from 'react-dom' import * as packageJson from '../../../../../package.json' import { RemixUiSettings } from '@remix-ui/settings' //eslint-disable-line import Registry from '../state/registry' +import { PluginViewWrapper } from '@remix-ui/helper' const profile = { name: 'settings', @@ -20,6 +20,15 @@ const profile = { } module.exports = class SettingsTab extends ViewPlugin { + config: any = {} + editor: any + private _deps: { + themeModule: any // eslint-disable-line + + } + element: HTMLDivElement + public useMatomoAnalytics: any + dispatch: React.Dispatch = () => {} constructor (config, editor) { super(profile) this.config = config @@ -32,24 +41,31 @@ module.exports = class SettingsTab extends ViewPlugin { this.useMatomoAnalytics = null } - onActivation () { + setDispatch (dispatch: React.Dispatch) { + this.dispatch = dispatch this.renderComponent() } - render () { - return this.element + render() { + return ( +
+ +
+ ); + } + + updateComponent(state: any){ + return } renderComponent () { - ReactDOM.render( - , - this.element - ) + this.dispatch(this) } get (key) { @@ -59,6 +75,8 @@ module.exports = class SettingsTab extends ViewPlugin { updateMatomoAnalyticsChoice (isChecked) { this.config.set('settings/matomo-analytics', isChecked) this.useMatomoAnalytics = isChecked - this.renderComponent() + this.dispatch({ + ...this + }) } -} +} \ No newline at end of file diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index a03d74a846..c2af5ce7a7 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -1,12 +1,12 @@ /* global */ import React from 'react' // eslint-disable-line -import ReactDOM from 'react-dom' import { SolidityUnitTesting } from '@remix-ui/solidity-unit-testing' // eslint-disable-line import { TestTabLogic } from '@remix-ui/solidity-unit-testing' // eslint-disable-line import { ViewPlugin } from '@remixproject/engine-web' import helper from '../../lib/helper' import { canUseWorker, urlFromVersion } from '@remix-project/remix-solidity' +import { PluginViewWrapper } from '@remix-ui/helper' var { UnitTestRunner, assertLibCode } = require('@remix-project/remix-tests') @@ -34,6 +34,7 @@ module.exports = class TestTab extends ViewPlugin { this.offsetToLineColumnConverter = offsetToLineColumnConverter this.allFilesInvolved = ['.deps/remix-tests/remix_tests.sol', '.deps/remix-tests/remix_accounts.sol'] this.element = document.createElement('div') + this.dispatch = null } onActivationInternal () { @@ -128,15 +129,25 @@ module.exports = class TestTab extends ViewPlugin { }) } + setDispatch (dispatch) { + this.dispatch = dispatch + this.renderComponent('tests') + } + render () { this.onActivationInternal() - this.renderComponent('tests') - return this.element + return
+ } + + updateComponent(state) { + return } renderComponent (testDirPath) { - ReactDOM.render( - - , this.element) + this.dispatch({ + testTab: this, + helper: this.helper, + testDirPath: testDirPath + }) } } diff --git a/apps/remix-ide/src/app/udapp/run-tab.js b/apps/remix-ide/src/app/udapp/run-tab.js index 5fe56053fa..05a015c4fc 100644 --- a/apps/remix-ide/src/app/udapp/run-tab.js +++ b/apps/remix-ide/src/app/udapp/run-tab.js @@ -1,5 +1,4 @@ import React from 'react' // eslint-disable-line -import ReactDOM from 'react-dom' import { RunTabUI } from '@remix-ui/run-tab' import { ViewPlugin } from '@remixproject/engine-web' import * as packageJson from '../../../../../package.json' @@ -40,9 +39,6 @@ export class RunTab extends ViewPlugin { this.el = document.createElement('div') } - onActivation () { - this.renderComponent() - } setupEvents () { this.blockchain.events.on('newTransaction', (tx, receipt) => { @@ -86,14 +82,9 @@ export class RunTab extends ViewPlugin { } render () { - return this.el + return
} - renderComponent () { - ReactDOM.render( - - , this.el) - } onReady (api) { this.REACT_API = api diff --git a/apps/remix-ide/src/app/ui/landing-page/landing-page.js b/apps/remix-ide/src/app/ui/landing-page/landing-page.js index b05271dc96..2f8819fc5f 100644 --- a/apps/remix-ide/src/app/ui/landing-page/landing-page.js +++ b/apps/remix-ide/src/app/ui/landing-page/landing-page.js @@ -1,6 +1,5 @@ /* global */ import React from 'react' // eslint-disable-line -import ReactDOM from 'react-dom' import * as packageJson from '../../../../../../package.json' import { ViewPlugin } from '@remixproject/engine-web' import { RemixUiHomeTab } from '@remix-ui/home-tab' // eslint-disable-line @@ -31,15 +30,9 @@ export class LandingPage extends ViewPlugin { } render () { - this.renderComponent() - return this.el + return
} - renderComponent () { - ReactDOM.render( - - , this.el) - } } diff --git a/apps/remix-ide/src/index.tsx b/apps/remix-ide/src/index.tsx index fde108b852..a418ecbd49 100644 --- a/apps/remix-ide/src/index.tsx +++ b/apps/remix-ide/src/index.tsx @@ -33,9 +33,9 @@ import ('./app').then((AppComponent) => { const appComponent = new AppComponent.default() appComponent.run().then(() => { render( - + <> - , + , document.getElementById('root') ) }) diff --git a/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx b/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx index 6845ce88b1..8d0aeec020 100644 --- a/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useRef, useState } from 'react' +import React, { useContext, useEffect, useRef, useState } from 'react' import './style/remix-app.css' import { RemixUIMainPanel } from '@remix-ui/panel' import MatomoDialog from './components/modals/matomo' @@ -8,6 +8,7 @@ import { AppProvider } from './context/provider' import AppDialogs from './components/modals/dialogs' import DialogViewPlugin from './components/modals/dialogViewPlugin' import { AppContext } from './context/context' +import { RemixUiVerticalIconsPanel } from '@remix-ui/vertical-icons-panel' interface IRemixAppUi { app: any @@ -17,31 +18,8 @@ const RemixApp = (props: IRemixAppUi) => { const [appReady, setAppReady] = useState(false) const [hideSidePanel, setHideSidePanel] = useState(false) const sidePanelRef = useRef(null) - const mainPanelRef = useRef(null) - const iconPanelRef = useRef(null) - const hiddenPanelRef = useRef(null) useEffect(() => { - if (sidePanelRef.current) { - if (props.app.sidePanel) { - sidePanelRef.current.appendChild(props.app.sidePanel.render()) - } - } - if (mainPanelRef.current) { - if (props.app.mainview) { - mainPanelRef.current.appendChild(props.app.mainview.render()) - } - } - if (iconPanelRef.current) { - if (props.app.menuicons) { - iconPanelRef.current.appendChild(props.app.menuicons.render()) - } - } - if (hiddenPanelRef.current) { - if (props.app.hiddenPanel) { - hiddenPanelRef.current.appendChild(props.app.hiddenPanel.render()) - } - } async function activateApp () { props.app.themeModule.initTheme(() => { setAppReady(true) @@ -72,13 +50,6 @@ const RemixApp = (props: IRemixAppUi) => { }) } - const components = { - iconPanel:
, - sidePanel:
, - mainPanel:
, - hiddenPanel:
- } - const value = { settings: props.app.settings, showMatamo: props.app.showMatamo, @@ -93,14 +64,14 @@ const RemixApp = (props: IRemixAppUi) => {
- {components.iconPanel} - {components.sidePanel} +
{props.app.menuicons.render()}
+
{props.app.sidePanel.render()}
- {components.hiddenPanel} +
{props.app.hiddenPanel.render()}
diff --git a/libs/remix-ui/helper/src/index.ts b/libs/remix-ui/helper/src/index.ts index 31c21f0564..36d73ef523 100644 --- a/libs/remix-ui/helper/src/index.ts +++ b/libs/remix-ui/helper/src/index.ts @@ -1,2 +1,3 @@ export * from './lib/remix-ui-helper' export * from './lib/helper-components' +export * from './lib/components/PluginViewWrapper' \ No newline at end of file diff --git a/libs/remix-ui/helper/src/lib/components/PluginViewWrapper.tsx b/libs/remix-ui/helper/src/lib/components/PluginViewWrapper.tsx new file mode 100644 index 0000000000..058fa3aee0 --- /dev/null +++ b/libs/remix-ui/helper/src/lib/components/PluginViewWrapper.tsx @@ -0,0 +1,24 @@ +import React from "react" +import { useEffect, useState } from "react" + +interface IPluginViewWrapperProps { + plugin: any + } + +export const PluginViewWrapper = (props: IPluginViewWrapperProps) => { + + const [state, setState] = useState(null) + + useEffect(() => { + if(props.plugin.setDispatch){ + props.plugin.setDispatch(setState) + } + }, []) + + return ( + <>{state? + <>{props.plugin.updateComponent(state)} + :<> + } + ) + } \ No newline at end of file diff --git a/libs/remix-ui/panel/src/lib/plugins/panel-plugin.tsx b/libs/remix-ui/panel/src/lib/plugins/panel-plugin.tsx index 9eb30391bc..35a82ea4a5 100644 --- a/libs/remix-ui/panel/src/lib/plugins/panel-plugin.tsx +++ b/libs/remix-ui/panel/src/lib/plugins/panel-plugin.tsx @@ -10,6 +10,7 @@ const RemixUIPanelPlugin = (props: panelPLuginProps, panelRef: any) => { const localRef = useRef(null) const [view, setView] = useState() useEffect(() => { + const ref:any = panelRef || localRef if (ref.current) { if (props.pluginRecord.view) { diff --git a/libs/remix-ui/panel/src/lib/plugins/panel.css b/libs/remix-ui/panel/src/lib/plugins/panel.css index d2b2133667..8356d6ef15 100644 --- a/libs/remix-ui/panel/src/lib/plugins/panel.css +++ b/libs/remix-ui/panel/src/lib/plugins/panel.css @@ -76,11 +76,6 @@ iframe { display: block; } -.pluginsContainer { - height: 100%; - overflow-y: hidden; -} - #editorView { height: 100%; width: 100%; diff --git a/package.json b/package.json index b37e2a9cb8..3585888453 100644 --- a/package.json +++ b/package.json @@ -149,13 +149,13 @@ "@ethereumjs/tx": "^3.3.2", "@ethereumjs/vm": "^5.5.3", "@monaco-editor/react": "^4.3.1", - "@remixproject/engine": "^0.3.26", - "@remixproject/engine-web": "^0.3.26", - "@remixproject/plugin": "^0.3.26", - "@remixproject/plugin-api": "^0.3.26", - "@remixproject/plugin-utils": "^0.3.26", - "@remixproject/plugin-webview": "^0.3.26", - "@remixproject/plugin-ws": "^0.3.26", + "@remixproject/engine": "^0.3.28", + "@remixproject/engine-web": "^0.3.28", + "@remixproject/plugin": "^0.3.28", + "@remixproject/plugin-api": "^0.3.28", + "@remixproject/plugin-utils": "^0.3.28", + "@remixproject/plugin-webview": "^0.3.28", + "@remixproject/plugin-ws": "^0.3.28", "ansi-gray": "^0.1.1", "async": "^2.6.2", "axios": ">=0.21.1",