|
|
@ -1,9 +1,11 @@ |
|
|
|
import React from 'react' // eslint-disable-line
|
|
|
|
import React from 'react' // eslint-disable-line
|
|
|
|
import { AbstractPanel } from './panel' |
|
|
|
import { AbstractPanel } from './panel' |
|
|
|
import { RemixPluginPanel } from '@remix-ui/panel' |
|
|
|
import { PluginRecord, RemixPluginPanel } from '@remix-ui/panel' |
|
|
|
import packageJson from '../../../../../package.json' |
|
|
|
import packageJson from '../../../../../package.json' |
|
|
|
import { PluginViewWrapper } from '@remix-ui/helper' |
|
|
|
import { PluginViewWrapper } from '@remix-ui/helper' |
|
|
|
import { EventEmitter } from 'events' |
|
|
|
import { EventEmitter } from 'events' |
|
|
|
|
|
|
|
import { AppState } from 'libs/remix-ui/app/src/lib/remix-app/interface' |
|
|
|
|
|
|
|
import { AppAction, appActionTypes } from '@remix-ui/app' |
|
|
|
|
|
|
|
|
|
|
|
const profile = { |
|
|
|
const profile = { |
|
|
|
name: 'popupPanel', |
|
|
|
name: 'popupPanel', |
|
|
@ -13,22 +15,28 @@ const profile = { |
|
|
|
events: ['popupPanelShown'], |
|
|
|
events: ['popupPanelShown'], |
|
|
|
methods: ['addView', 'removeView', 'showContent', 'showPopupPanel'] |
|
|
|
methods: ['addView', 'removeView', 'showContent', 'showPopupPanel'] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
type popupPanelState = { |
|
|
|
|
|
|
|
plugins: Record<string, PluginRecord> |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export class PopupPanel extends AbstractPanel { |
|
|
|
export class PopupPanel extends AbstractPanel { |
|
|
|
element: HTMLDivElement |
|
|
|
element: HTMLDivElement |
|
|
|
dispatch: React.Dispatch<any> = () => { } |
|
|
|
dispatch: React.Dispatch<any> = () => { } |
|
|
|
showPanel: boolean |
|
|
|
appStateDispatch: React.Dispatch<AppAction> = () => { } |
|
|
|
|
|
|
|
|
|
|
|
constructor(config) { |
|
|
|
constructor(config) { |
|
|
|
super(profile) |
|
|
|
super(profile) |
|
|
|
this.event = new EventEmitter() |
|
|
|
this.event = new EventEmitter() |
|
|
|
this.showPanel = true |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setDispatch(dispatch: React.Dispatch<any>) { |
|
|
|
setDispatch(dispatch: React.Dispatch<any>) { |
|
|
|
this.dispatch = dispatch |
|
|
|
this.dispatch = dispatch |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setAppStateDispatch(appStateDispatch: React.Dispatch<AppAction>) { |
|
|
|
|
|
|
|
this.appStateDispatch = appStateDispatch |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onActivation() { |
|
|
|
onActivation() { |
|
|
|
this.renderComponent() |
|
|
|
this.renderComponent() |
|
|
|
} |
|
|
|
} |
|
|
@ -56,23 +64,31 @@ export class PopupPanel extends AbstractPanel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async showPopupPanel(show) { |
|
|
|
async showPopupPanel(show) { |
|
|
|
console.log("hide in popup-panel =", show) |
|
|
|
|
|
|
|
this.showPanel = show |
|
|
|
this.appStateDispatch({ |
|
|
|
this.event.emit('popupPanelShown', show) |
|
|
|
type: appActionTypes.setShowPopupPanel, |
|
|
|
|
|
|
|
payload: show |
|
|
|
|
|
|
|
}) |
|
|
|
this.renderComponent() |
|
|
|
this.renderComponent() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
renderComponent() { |
|
|
|
renderComponent() { |
|
|
|
this.dispatch({ |
|
|
|
this.dispatch({ |
|
|
|
plugins: this.plugins, |
|
|
|
plugins: this.plugins |
|
|
|
showPpPanel: this.showPanel |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
render() { |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<PluginViewWrapper plugin={this} /> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateComponent(state: popupPanelState & Partial<AppState>) { |
|
|
|
|
|
|
|
console.log("state in updateComponent =", state) |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div |
|
|
|
<div |
|
|
|
className={'px-0 bg-light border-info ' + (!this.showPanel ? 'd-none' : 'd-flex')} |
|
|
|
className={'px-0 bg-light border-info ' + (!state.showPopupPanel ? 'd-none' : 'd-flex')} |
|
|
|
style={{ |
|
|
|
style={{ |
|
|
|
maxHeight: '40rem', |
|
|
|
maxHeight: '40rem', |
|
|
|
maxWidth: '25rem', |
|
|
|
maxWidth: '25rem', |
|
|
@ -86,14 +102,6 @@ export class PopupPanel extends AbstractPanel { |
|
|
|
}} |
|
|
|
}} |
|
|
|
data-id="popupPanelPluginsContainer" |
|
|
|
data-id="popupPanelPluginsContainer" |
|
|
|
> |
|
|
|
> |
|
|
|
{this.showPanel && <PluginViewWrapper plugin={this} />} |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateComponent(state: any) { |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<div className={!state.showPpPanel ? 'd-none' : 'd-flex'}> |
|
|
|
|
|
|
|
<RemixPluginPanel |
|
|
|
<RemixPluginPanel |
|
|
|
header={ |
|
|
|
header={ |
|
|
|
<span id='menubarAIChat' className='pb-2 d-flex flex-row'> |
|
|
|
<span id='menubarAIChat' className='pb-2 d-flex flex-row'> |
|
|
@ -108,6 +116,7 @@ export class PopupPanel extends AbstractPanel { |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
} |
|
|
|
} |
|
|
|
plugins={state.plugins} /> |
|
|
|
plugins={state.plugins} /> |
|
|
|
</div>) |
|
|
|
</div> |
|
|
|
|
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|