diff --git a/apps/remix-ide-e2e/src/tests/pinned_plugin.test.ts b/apps/remix-ide-e2e/src/tests/pinned_plugin.test.ts index e8e0af546c8..153ef9650c8 100644 --- a/apps/remix-ide-e2e/src/tests/pinned_plugin.test.ts +++ b/apps/remix-ide-e2e/src/tests/pinned_plugin.test.ts @@ -35,6 +35,17 @@ module.exports = { .click('*[data-id="restoreClosedPlugin"]') .waitForElementVisible('*[data-pinnedplugin="movePluginToLeft-solidity"]') }, + 'Close Solidity Compiler Plugin, reload IDE, it should be closed and restore it #group1': function (browser: NightwatchBrowser) { + browser + .waitForElementVisible('*[data-id="closePinnedPlugin"]') + .click('*[data-id="closePinnedPlugin"]') + .waitForElementNotVisible('*[data-pinnedplugin="movePluginToLeft-solidity"]') + .waitForElementVisible('*[data-id="restoreClosedPlugin"') + .refresh() + .waitForElementVisible('*[data-id="restoreClosedPlugin"') + .click('*[data-id="restoreClosedPlugin"]') + .waitForElementVisible('*[data-pinnedplugin="movePluginToLeft-solidity"]') + }, 'Swap pinned Solidity Compiler Plugin with RemixAI Assistant when pinned plugin is closed #group1': function (browser: NightwatchBrowser) { browser .refreshPage() diff --git a/apps/remix-ide/src/app/components/pinned-panel.tsx b/apps/remix-ide/src/app/components/pinned-panel.tsx index 47c9255dbda..a92de36208c 100644 --- a/apps/remix-ide/src/app/components/pinned-panel.tsx +++ b/apps/remix-ide/src/app/components/pinned-panel.tsx @@ -20,6 +20,7 @@ const pinnedPanel = { export class PinnedPanel extends AbstractPanel { dispatch: React.Dispatch = () => {} loggedState: Record + pinnedPanelState: Record // pluginProfile, isClosed highlightStamp: number closedPlugin: any @@ -36,6 +37,9 @@ export class PinnedPanel extends AbstractPanel { super.remove(name) } }) + + const pinnedPanelState = window.localStorage.getItem('pinnedPanelState') + if (!pinnedPanelState) window.localStorage.setItem('pinnedPanelState', JSON.stringify({})) } async pinView (profile, view) { @@ -53,9 +57,18 @@ export class PinnedPanel extends AbstractPanel { this.addView(profile, view) this.plugins[profile.name].pinned = true this.plugins[profile.name].active = true + let pinnedPanelState = window.localStorage.getItem('pinnedPanelState') + let isClosed = false + if (pinnedPanelState) { + pinnedPanelState = JSON.parse(pinnedPanelState) + if (pinnedPanelState['isClosed']) { + isClosed = true + await this.closePlugin(profile) + } + } this.renderComponent() - this.events.emit('pinnedPlugin', profile) - this.emit('pinnedPlugin', profile) + this.events.emit('pinnedPlugin', profile, isClosed) + this.emit('pinnedPlugin', profile, isClosed) } async unPinView (profile) { @@ -77,6 +90,7 @@ export class PinnedPanel extends AbstractPanel { const pinnedPanel = document.querySelector('#pinned-panel') pinnedPanel.classList.add('d-none') this.closedPlugin = profile + window.localStorage.setItem('pinnedPanelState', JSON.stringify({ pluginProfile: profile, isClosed: true })) this.events.emit('pluginClosed', profile) this.emit('pluginClosed', profile) } @@ -85,6 +99,7 @@ export class PinnedPanel extends AbstractPanel { const pinnedPanel = document.querySelector('#pinned-panel') pinnedPanel.classList.remove('d-none') this.closedPlugin = null + window.localStorage.setItem('pinnedPanelState', JSON.stringify({ pluginProfile: profile, isClosed: false })) this.events.emit('pluginMaximized', profile) this.emit('pluginMaximized', profile) } 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 47416e46e6e..c99c6d37c7c 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 @@ -125,8 +125,8 @@ const RemixApp = (props: IRemixAppUi) => { setLocale(nextLocale) }) - props.app.pinnedPanel.events.on('pinnedPlugin', () => { - setHidePinnedPanel(false) + props.app.pinnedPanel.events.on('pinnedPlugin', (profile, isClosed) => { + if (!isClosed) setHidePinnedPanel(false) }) props.app.pinnedPanel.events.on('unPinnedPlugin', () => {