Add functionality for plugin calls to maximise and reset pinned panel size

pull/5370/head
ioedeveloper 9 months ago
parent 8350f09ee8
commit c5df8c8629
  1. 1
      apps/remix-ide/src/app/components/pinned-panel.tsx
  2. 24
      apps/remix-ide/src/app/panels/layout.ts
  3. 2
      apps/remix-ide/src/app/tabs/locales/en/panel.json
  4. 19
      libs/remix-ui/app/src/lib/remix-app/components/dragbar/dragbar.tsx
  5. 11
      libs/remix-ui/app/src/lib/remix-app/remix-app.tsx
  6. 16
      libs/remix-ui/debugger-ui/src/lib/api/debugger-api.ts

@ -15,7 +15,6 @@ const pinnedPanel = {
} }
export class PinnedPanel extends AbstractPanel { export class PinnedPanel extends AbstractPanel {
sideelement: any
dispatch: React.Dispatch<any> = () => {} dispatch: React.Dispatch<any> = () => {}
loggedState: any loggedState: any

@ -6,7 +6,7 @@ import { QueryParams } from '@remix-project/remix-lib'
const profile: Profile = { const profile: Profile = {
name: 'layout', name: 'layout',
description: 'layout', description: 'layout',
methods: ['minimize', 'maximiseSidePanel', 'resetSidePanel', 'maximizeTerminal'] methods: ['minimize', 'maximiseSidePanel', 'resetSidePanel', 'maximizeTerminal', 'maximisePinnedPanel', 'resetPinnedPanel']
} }
interface panelState { interface panelState {
@ -74,6 +74,16 @@ export class Layout extends Plugin {
this.event.emit('resetsidepanel') this.event.emit('resetsidepanel')
} }
}) })
this.on('pinnedPanel', 'pinnedPlugin', async (name) => {
const current = await this.call('pinnedPanel', 'currentFocus')
if (this.maximised[current]) {
this.event.emit('maximisepinnedpanel')
} else {
this.event.emit('resetpinnedpanel')
}
})
document.addEventListener('keypress', e => { document.addEventListener('keypress', e => {
if (e.shiftKey && e.ctrlKey) { if (e.shiftKey && e.ctrlKey) {
if (e.code === 'KeyF') { if (e.code === 'KeyF') {
@ -110,6 +120,12 @@ export class Layout extends Plugin {
this.maximised[current] = true this.maximised[current] = true
} }
async maximisePinnedPanel () {
this.event.emit('maximisepinnedpanel')
const current = await this.call('pinnedPanel', 'currentFocus')
this.maximised[current] = true
}
async maximizeTerminal() { async maximizeTerminal() {
this.panels.terminal.minimized = false this.panels.terminal.minimized = false
this.event.emit('change', this.panels) this.event.emit('change', this.panels)
@ -121,4 +137,10 @@ export class Layout extends Plugin {
const current = await this.call('sidePanel', 'currentFocus') const current = await this.call('sidePanel', 'currentFocus')
this.maximised[current] = false this.maximised[current] = false
} }
async resetPinnedPanel () {
this.event.emit('resetpinnedpanel')
const current = await this.call('pinnedPanel', 'currentFocus')
this.maximised[current] = false
}
} }

@ -4,7 +4,7 @@
"panel.documentation": "Documentation", "panel.documentation": "Documentation",
"panel.description": "Description", "panel.description": "Description",
"panel.maintainedByRemix": "Maintained by Remix", "panel.maintainedByRemix": "Maintained by Remix",
"panel.pinnedMsg": "Click to return plugin to the right side panel", "panel.pinnedMsg": "Click to move plugin to the right side panel",
"panel.unPinnedMsg": "Click to return plugin to the left side panel", "panel.unPinnedMsg": "Click to return plugin to the left side panel",
"panel.maintainedExternally": "Not maintained by Remix", "panel.maintainedExternally": "Not maintained by Remix",
"panel.pluginInfo": "Plugin info", "panel.pluginInfo": "Plugin info",

@ -32,22 +32,41 @@ const DragBar = (props: IRemixDragBarUi) => {
useEffect(() => { useEffect(() => {
initialWidth.current = props.refObject.current.clientWidth initialWidth.current = props.refObject.current.clientWidth
if (props.maximiseTrigger > 0) { if (props.maximiseTrigger > 0) {
if (props.layoutPosition === 'left') {
const width = 0.4 * window.innerWidth const width = 0.4 * window.innerWidth
if (width > props.refObject.current.offsetWidth) { if (width > props.refObject.current.offsetWidth) {
props.refObject.current.style.width = width + 'px' props.refObject.current.style.width = width + 'px'
setTimeout(() => { setTimeout(() => {
setDragBarPosX(offset + width) setDragBarPosX(offset + width)
}, 300) }, 300)
} }
} else if (props.layoutPosition === 'right') {
const width = 0.4 * window.innerWidth
if (width > props.refObject.current.offsetWidth) {
props.refObject.current.style.width = width + 'px'
setTimeout(() => {
setDragBarPosX(window.innerWidth - width)
}, 300)
}
}
} }
}, [props.maximiseTrigger]) }, [props.maximiseTrigger])
useEffect(() => { useEffect(() => {
if (props.maximiseTrigger > 0) { if (props.maximiseTrigger > 0) {
if (props.layoutPosition === 'left') {
props.refObject.current.style.width = initialWidth.current + 'px' props.refObject.current.style.width = initialWidth.current + 'px'
setTimeout(() => { setTimeout(() => {
setDragBarPosX(offset + initialWidth.current) setDragBarPosX(offset + initialWidth.current)
}, 300) }, 300)
} else if (props.layoutPosition === 'right') {
props.refObject.current.style.width = props.minWidth + 'px'
setTimeout(() => {
setDragBarPosX(window.innerWidth - props.minWidth)
}, 300)
}
} }
}, [props.resetTrigger]) }, [props.resetTrigger])

@ -96,12 +96,6 @@ const RemixApp = (props: IRemixAppUi) => {
}) })
}) })
props.app.layout.event.on('minimizepinnedpanel', () => {
setTimeout(() => {
setHidePinnedPanel(true)
}, 1000)
})
props.app.layout.event.on('maximisepinnedpanel', () => { props.app.layout.event.on('maximisepinnedpanel', () => {
setMaximiseRightTrigger((prev) => { setMaximiseRightTrigger((prev) => {
return prev + 1 return prev + 1
@ -211,15 +205,18 @@ const RemixApp = (props: IRemixAppUi) => {
<div id="pinned-panel" ref={pinnedPanelRef} data-id="remixIdePinnedPanel" className={`flex-row-reverse pinnedpanel border-right border-left ${hidePinnedPanel ? 'd-none' : 'd-flex'}`}> <div id="pinned-panel" ref={pinnedPanelRef} data-id="remixIdePinnedPanel" className={`flex-row-reverse pinnedpanel border-right border-left ${hidePinnedPanel ? 'd-none' : 'd-flex'}`}>
{props.app.pinnedPanel.render()} {props.app.pinnedPanel.render()}
</div> </div>
{
!hidePinnedPanel &&
<DragBar <DragBar
resetTrigger={resetRightTrigger} resetTrigger={resetRightTrigger}
maximiseTrigger={maximiseRightTrigger} maximiseTrigger={maximiseRightTrigger}
minWidth={285} minWidth={331}
refObject={pinnedPanelRef} refObject={pinnedPanelRef}
hidden={hidePinnedPanel} hidden={hidePinnedPanel}
setHideStatus={setHidePinnedPanel} setHideStatus={setHidePinnedPanel}
layoutPosition='right' layoutPosition='right'
></DragBar> ></DragBar>
}
</div> </div>
<div>{props.app.hiddenPanel.render()}</div> <div>{props.app.hiddenPanel.render()}</div>
<AppDialogs></AppDialogs> <AppDialogs></AppDialogs>

@ -183,14 +183,26 @@ export const DebuggerApiMixin = (Base) => class extends Base {
showMessage (title: string, message: string) {} showMessage (title: string, message: string) {}
onStartDebugging (debuggerBackend: any) { async onStartDebugging (debuggerBackend: any) {
const pinnedPlugin = await this.call('pinnedPanel', 'currentFocus')
if (pinnedPlugin === 'debugger') {
this.call('layout', 'maximisePinnedPanel')
} else {
this.call('layout', 'maximiseSidePanel') this.call('layout', 'maximiseSidePanel')
}
this.emit('startDebugging') this.emit('startDebugging')
this.debuggerBackend = debuggerBackend this.debuggerBackend = debuggerBackend
} }
onStopDebugging () { async onStopDebugging () {
const pinnedPlugin = await this.call('pinnedPanel', 'currentFocus')
if (pinnedPlugin === 'debugger') {
this.call('layout', 'resetPinnedPanel')
} else {
this.call('layout', 'resetSidePanel') this.call('layout', 'resetSidePanel')
}
this.emit('stopDebugging') this.emit('stopDebugging')
this.debuggerBackend = null this.debuggerBackend = null
} }

Loading…
Cancel
Save