From 6337827fc8001511114b06055e0adbf582a088f3 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Sun, 5 May 2024 12:55:34 -0500 Subject: [PATCH] Load plugin state for side-panel after unpin --- apps/remix-ide/src/app/components/pinned-panel.tsx | 9 ++++++--- apps/remix-ide/src/app/components/side-panel.tsx | 10 ++++++---- libs/remix-ui/panel/src/lib/plugins/panel-header.tsx | 4 ++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/apps/remix-ide/src/app/components/pinned-panel.tsx b/apps/remix-ide/src/app/components/pinned-panel.tsx index 0526ddf04f..db8bcba590 100644 --- a/apps/remix-ide/src/app/components/pinned-panel.tsx +++ b/apps/remix-ide/src/app/components/pinned-panel.tsx @@ -31,7 +31,10 @@ export class PinnedPanel extends AbstractPanel { const activePlugin = this.currentFocus() if (activePlugin === profile.name) throw new Error(`Plugin ${profile.name} already pinned`) - if (activePlugin) this.remove(activePlugin) + if (activePlugin) { + await this.call('sidePanel', 'unPinView', this.plugins[activePlugin].profile, this.plugins[activePlugin].view) + this.remove(activePlugin) + } this.loggedState = await this.call('pluginStateLogger', 'getPluginState', profile.name) this.addView(profile, view) this.plugins[profile.name].pinned = true @@ -40,11 +43,11 @@ export class PinnedPanel extends AbstractPanel { this.events.emit('pinnedPlugin', profile.name) } - unPinView (profile) { + async unPinView (profile) { const activePlugin = this.currentFocus() if (activePlugin !== profile.name) throw new Error(`Plugin ${profile.name} already pinned`) - this.call('sidePanel', 'unPinView', profile, this.plugins[profile.name].view) + await this.call('sidePanel', 'unPinView', profile, this.plugins[profile.name].view) super.remove(profile.name) this.renderComponent() this.events.emit('unPinnedPlugin', profile.name) diff --git a/apps/remix-ide/src/app/components/side-panel.tsx b/apps/remix-ide/src/app/components/side-panel.tsx index 11642fce57..81d19791fe 100644 --- a/apps/remix-ide/src/app/components/side-panel.tsx +++ b/apps/remix-ide/src/app/components/side-panel.tsx @@ -72,15 +72,17 @@ export class SidePanel extends AbstractPanel { this.renderComponent() } - pinView (profile) { - this.call('pinnedPanel', 'pinView', profile, this.plugins[profile.name].view) + async pinView (profile, view) { + await this.call('pinnedPanel', 'pinView', profile, view) this.removeView(profile) } async unPinView (profile, view) { - this.addView(profile, view) const activePlugin = this.currentFocus() + if (activePlugin === profile.name) throw new Error(`Plugin ${profile.name} already unpinned`) + this.loggedState = await this.call('pluginStateLogger', 'getPluginState', profile.name) + super.addView(profile, view) this.plugins[activePlugin].active = false this.plugins[profile.name].active = true await this.call('menuicons', 'linkContent', profile) @@ -111,7 +113,7 @@ export class SidePanel extends AbstractPanel { } updateComponent(state: any) { - return } plugins={state.plugins} pluginState={state.loggedState} /> + return } plugins={state.plugins} pluginState={state.pluginState} /> } renderComponent() { diff --git a/libs/remix-ui/panel/src/lib/plugins/panel-header.tsx b/libs/remix-ui/panel/src/lib/plugins/panel-header.tsx index 687d2cfd50..9d86ff6eec 100644 --- a/libs/remix-ui/panel/src/lib/plugins/panel-header.tsx +++ b/libs/remix-ui/panel/src/lib/plugins/panel-header.tsx @@ -7,7 +7,7 @@ import {CustomTooltip, RenderIf, RenderIfNot} from '@remix-ui/helper' export interface RemixPanelProps { plugins: Record, pinView?: (profile: PluginRecord['profile'], view: PluginRecord['view']) => void, - unPinView?: (profile: PluginRecord['profile']) => void + unPinView?: (profile: PluginRecord['profile'], view: PluginRecord['view']) => void } const RemixUIPanelHeader = (props: RemixPanelProps) => { const [plugin, setPlugin] = useState() @@ -32,7 +32,7 @@ const RemixUIPanelHeader = (props: RemixPanelProps) => { } const unPinPlugin = () => { - props.unPinView && props.unPinView(plugin.profile) + props.unPinView && props.unPinView(plugin.profile, plugin.view) } const tooltipChild =