From a3a661d5b0ad68863b731806dba6c77c49720d2f Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Sat, 27 Apr 2024 14:35:47 +0100 Subject: [PATCH] Default to file-explorer --- apps/remix-ide/src/app/components/panel.ts | 6 ++- .../src/app/components/pinned-panel.tsx | 34 ++++++++-------- .../src/app/components/side-panel.tsx | 21 ++++++++-- .../app/src/lib/remix-app/remix-app.tsx | 18 ++++++--- .../panel/src/lib/plugins/panel-header.tsx | 39 +++++++++++-------- 5 files changed, 75 insertions(+), 43 deletions(-) diff --git a/apps/remix-ide/src/app/components/panel.ts b/apps/remix-ide/src/app/components/panel.ts index 2fa3c9b0e9..bf80f3614d 100644 --- a/apps/remix-ide/src/app/components/panel.ts +++ b/apps/remix-ide/src/app/components/panel.ts @@ -15,9 +15,11 @@ export class AbstractPanel extends HostPlugin { } currentFocus (): string { - return Object.values(this.plugins).find(plugin => { + const activePlugin = Object.values(this.plugins).find(plugin => { return plugin.active - }).profile.name + }) + + return activePlugin ? activePlugin.profile.name : null } addView (profile, view) { diff --git a/apps/remix-ide/src/app/components/pinned-panel.tsx b/apps/remix-ide/src/app/components/pinned-panel.tsx index 9bf681191c..70b39672a0 100644 --- a/apps/remix-ide/src/app/components/pinned-panel.tsx +++ b/apps/remix-ide/src/app/components/pinned-panel.tsx @@ -1,7 +1,7 @@ // eslint-disable-next-line no-use-before-define import React from 'react' import { AbstractPanel } from './panel' -import { RemixPluginPanel } from '@remix-ui/panel' +import { PluginRecord, RemixPluginPanel } from '@remix-ui/panel' import packageJson from '../../../../../package.json' import { RemixUIPanelHeader } from '@remix-ui/panel' import { PluginViewWrapper } from '@remix-ui/helper' @@ -11,7 +11,7 @@ const pinnedPanel = { displayName: 'Pinned Panel', description: 'Remix IDE pinned panel', version: packageJson.version, - methods: ['addView', 'removeView', 'currentFocus'] + methods: ['addView', 'removeView', 'currentFocus', 'pinView', 'unPinView'] } export class PinnedPanel extends AbstractPanel { @@ -26,24 +26,26 @@ export class PinnedPanel extends AbstractPanel { this.renderComponent() } - currentFocus (): string { - return Object.values(this.plugins).find(plugin => { - return plugin.pinned - }).profile.name - } + pinView (profile, view) { + const activePlugin = this.currentFocus() - removeView(profile) { - this.remove(profile.name) - this.emit('unpinnedPlugin', profile.name) + if (activePlugin === profile.name) throw new Error(`Plugin ${profile.name} already pinned`) + if (activePlugin) this.remove(activePlugin) + this.addView(profile, view) + this.plugins[profile.name].pinned = true + this.plugins[profile.name].active = true this.renderComponent() + this.events.emit('pinnedPlugin', profile.name) } - addView(profile, view) { - super.addView(profile, view) - this.plugins[profile.name].pinned = true - super.showContent(profile.name) - this.emit('pinnedPlugin', profile.name) + unPinView (profile) { + const activePlugin = this.currentFocus() + + if (activePlugin !== profile.name) throw new Error(`Plugin ${profile.name} already pinned`) + super.remove(profile.name) + this.call('sidePanel', 'unPinView', profile) this.renderComponent() + this.events.emit('unPinnedPlugin', profile.name) } setDispatch (dispatch: React.Dispatch) { @@ -57,7 +59,7 @@ export class PinnedPanel extends AbstractPanel { } updateComponent(state: any) { - return } plugins={state.plugins} /> + return } plugins={state.plugins} /> } renderComponent() { diff --git a/apps/remix-ide/src/app/components/side-panel.tsx b/apps/remix-ide/src/app/components/side-panel.tsx index 8735c296b7..3e32827183 100644 --- a/apps/remix-ide/src/app/components/side-panel.tsx +++ b/apps/remix-ide/src/app/components/side-panel.tsx @@ -12,7 +12,7 @@ const sidePanel = { displayName: 'Side Panel', description: 'Remix IDE side panel', version: packageJson.version, - methods: ['addView', 'removeView', 'currentFocus'] + methods: ['addView', 'removeView', 'currentFocus', 'pinView', 'unPinView'] } export class SidePanel extends AbstractPanel { @@ -65,22 +65,35 @@ export class SidePanel extends AbstractPanel { } addView(profile, view) { + console.log(profile.name) super.addView(profile, view) this.call('menuicons', 'linkContent', profile) this.renderComponent() } + hideView(profile) { + this.plugins[profile.name].active = false + this.plugins['filePanel'].active = true + this.call('menuicons', 'unlinkContent', profile) + this.renderComponent() + } + + showView(profile) { + this.call('menuicons', 'linkContent', profile) + this.renderComponent() + } + pinView (profile, view) { if (this.plugins[profile.name].pinned) return this.plugins[profile.name].pinned = true - this.call('pinnedPanel', 'addView', profile, view) - // this.removeView(profile) + this.call('pinnedPanel', 'pinView', profile, view) + this.hideView(profile) } unPinView (profile) { if (!this.plugins[profile.name].pinned) return this.plugins[profile.name].pinned = false - this.call('pinnedPanel', 'removeView', profile) + this.showView(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 3c79abba69..39684fc1fa 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 @@ -27,7 +27,7 @@ const RemixApp = (props: IRemixAppUi) => { const [appReady, setAppReady] = useState(false) const [showEnterDialog, setShowEnterDialog] = useState(false) const [hideSidePanel, setHideSidePanel] = useState(false) - const [hidePinnedPanel, setHidePinnedPanel] = useState(false) + const [hidePinnedPanel, setHidePinnedPanel] = useState(true) const [maximiseLeftTrigger, setMaximiseLeftTrigger] = useState(0) const [resetLeftTrigger, setResetLeftTrigger] = useState(0) const [maximiseRightTrigger, setMaximiseRightTrigger] = useState(0) @@ -118,6 +118,14 @@ const RemixApp = (props: IRemixAppUi) => { setLocale(nextLocale) }) + props.app.pinnedPanel.events.on('pinnedPlugin', () => { + setHidePinnedPanel(false) + }) + + props.app.pinnedPanel.events.on('unPinnedPlugin', () => { + setHidePinnedPanel(true) + }) + setInterval(() => { setOnline(window.navigator.onLine) }, 1000) @@ -199,9 +207,9 @@ const RemixApp = (props: IRemixAppUi) => { >
- }> -
-
+ {/* }> +
+
*/}
{ setHideStatus={setHideSidePanel} layoutPosition='right' > -
+
{props.app.pinnedPanel.render()}
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 ff4f327efc..cf5c63003f 100644 --- a/libs/remix-ui/panel/src/lib/plugins/panel-header.tsx +++ b/libs/remix-ui/panel/src/lib/plugins/panel-header.tsx @@ -2,7 +2,7 @@ import React, {useEffect, useState} from 'react' // eslint-disable-line import {FormattedMessage} from 'react-intl' import {PluginRecord} from '../types' import './panel.css' -import { CustomTooltip } from '@remix-ui/helper' +import {CustomTooltip, RenderIf, RenderIfNot} from '@remix-ui/helper' export interface RemixPanelProps { plugins: Record, @@ -47,32 +47,39 @@ const RemixUIPanelHeader = (props: RemixPanelProps) => {
{plugin?.profile?.maintainedBy?.toLowerCase() === 'remix' ? ( - }> + }> ) - : (}> + : (}> ) }
- } tooltipId="pluginInfoTooltip" tooltipClasses="text-nowrap"> + } tooltipId="pluginInfoTooltip" tooltipClasses="text-nowrap"> {tooltipChild}
{ - !plugin?.pinned ? ( -
- }> - - -
- ) : ( -
- }> - - -
+ plugin && plugin.profile.name !== 'filePanel' && ( + + <> + +
+ }> + + +
+
+ +
+ }> + + +
+
+ +
) }