pull/5371/head
bunsenstraat 2 weeks ago committed by bunsenstraat
parent 9734f542d6
commit d244c909be
  1. 6
      apps/remix-ide/src/app/components/popup-panel.tsx
  2. 37
      libs/remix-ui/helper/src/lib/components/PluginViewWrapper.tsx

@ -80,14 +80,14 @@ export class PopupPanel extends AbstractPanel {
render() {
return (
<PluginViewWrapper plugin={this} />
<PluginViewWrapper useAppContext={true} plugin={this} />
)
}
updateComponent(state: popupPanelState & Partial<AppState>) {
updateComponent(state: popupPanelState, appState: Partial<AppState>) {
return (
<div
className={'px-0 bg-light border-info ' + (!state.showPopupPanel ? 'd-none' : 'd-flex')}
className={`px-0 bg-light border-info ${appState?.showPopupPanel ? 'd-flex' : 'd-none'}`}
style={{
maxHeight: '40rem',
maxWidth: '25rem',

@ -1,28 +1,35 @@
import { AppContext } from '@remix-ui/app'
import React, { useContext } from 'react'
import { useEffect, useState } from 'react'
import React, { useContext, useEffect, useState } from 'react'
interface IPluginViewWrapperProps {
plugin: any
useAppContext?: boolean // Optional flag to decide whether to use AppContext
}
export const PluginViewWrapper = (props: IPluginViewWrapperProps) => {
export const PluginViewWrapper = ({ plugin, useAppContext = false }: IPluginViewWrapperProps) => {
const [state, setState] = useState<any>(null)
const appContext = useContext(AppContext)
const appContext = useAppContext ? useContext(AppContext) : null
useEffect(() => {
if (props.plugin.setDispatch) {
props.plugin.setDispatch(setState)
if (plugin.setDispatch) {
plugin.setDispatch(setState)
}
if (props.plugin.setAppStateDispatch) {
props.plugin.setAppStateDispatch(appContext.appStateDispatch)
if (useAppContext && appContext.appStateDispatch && plugin.setAppStateDispatch) {
plugin.setAppStateDispatch(appContext.appStateDispatch)
}
}, [])
}, [plugin])
return <>{state ? <>{props.plugin.updateComponent(
{
...state,
...appContext['appState']
})}
</> : <></>}</>
if (useAppContext && appContext && appContext.appState) {
return (
<>
{state ? <>{plugin.updateComponent(state, appContext.appState)}</> : <></>}
</>
)
}
return (
<>
{state ? <>{plugin.updateComponent(state)}</> : <></>}
</>
)
}

Loading…
Cancel
Save