change view plugin

pull/2074/head
filip mertens 3 years ago
parent 30e59ee03d
commit fb019e8100
  1. 27
      apps/remix-ide/src/app/plugins/viewReactPlugin.ts
  2. 3
      apps/remix-ide/src/app/tabs/settings-tab.tsx
  3. 5
      apps/remix-ide/src/app/ui/landing-page/landing-page.js
  4. 4
      libs/remix-ui/panel/src/lib/plugins/panel-plugin.tsx

@ -0,0 +1,27 @@
import type { Profile, LocationProfile } from '@remixproject/plugin-utils'
import { Plugin } from '@remixproject/engine'
export function isView<P extends Profile>(profile: Profile): profile is (ViewProfile & P) {
return !!profile['location']
}
export type ViewProfile = Profile & LocationProfile
export abstract class ViewReactPlugin extends Plugin {
abstract render(): any
constructor(public profile: ViewProfile) {
super(profile)
}
async activate() {
await this.call(this.profile.location, 'addView', this.profile, this.render())
super.activate()
}
deactivate() {
this.call(this.profile.location, 'removeView', this.profile)
super.deactivate()
}
}

@ -4,6 +4,7 @@ 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 { ViewReactPlugin } from '../plugins/viewReactPlugin'
const profile = {
name: 'settings',
@ -19,7 +20,7 @@ const profile = {
permission: true
}
module.exports = class SettingsTab extends ViewPlugin {
module.exports = class SettingsTab extends ViewReactPlugin {
config: any = {}
editor: any
private _deps: {

@ -4,6 +4,7 @@ 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
import { ViewReactPlugin } from '../../plugins/viewReactPlugin'
const profile = {
name: 'home',
@ -15,7 +16,7 @@ const profile = {
location: 'mainPanel',
version: packageJson.version
}
export class LandingPage extends ViewPlugin {
export class LandingPage extends ViewReactPlugin {
constructor (appManager, verticalIcons, fileManager, filePanel, contentImport) {
super(profile)
this.profile = profile
@ -35,5 +36,5 @@ export class LandingPage extends ViewPlugin {
plugin={this}
/></div>
}
}

@ -14,9 +14,9 @@ const RemixUIPanelPlugin = (props: panelPLuginProps, panelRef: any) => {
const ref:any = panelRef || localRef
if (ref.current) {
if(React.isValidElement(props.pluginRecord.view)) {
console.log('is REACT element', props.pluginRecord.profile.name)
// console.log('is REACT element', props.pluginRecord.profile.name)
}else{
console.log('is HTML element', props.pluginRecord.profile.name)
console.info('is HTML element', props.pluginRecord.profile.name)
}
if (props.pluginRecord.view) {
if (React.isValidElement(props.pluginRecord.view)) {

Loading…
Cancel
Save