Bug fix: make "phantom side panes" get properly cleared (#3878)

* Write a failing test

* Make `openPanes` get cleared of any hidden panes

* Grrr fmt
This commit is contained in:
Frank Noirot
2024-09-13 14:49:33 -04:00
committed by GitHub
parent 8c6266e94b
commit 3cd3e1af72
3 changed files with 148 additions and 29 deletions

View File

@ -15,6 +15,8 @@ import { DebugPane } from './DebugPane'
import { FileTreeInner, FileTreeMenu } from 'components/FileTree'
import { useKclContext } from 'lang/KclProvider'
import { editorManager } from 'lib/singletons'
import { ContextFrom } from 'xstate'
import { settingsMachine } from 'machines/settingsMachine'
export type SidebarType =
| 'code'
@ -36,6 +38,8 @@ export interface BadgeInfo {
*/
interface PaneCallbackProps {
kclContext: ReturnType<typeof useKclContext>
settings: ContextFrom<typeof settingsMachine>
platform: 'web' | 'desktop'
}
export type SidebarPane = {
@ -45,10 +49,21 @@ export type SidebarPane = {
keybinding: string
Content: ReactNode | React.FC
Menu?: ReactNode | React.FC
hideOnPlatform?: 'desktop' | 'web'
hide?: boolean | ((props: PaneCallbackProps) => boolean)
showBadge?: BadgeInfo
}
export type SidebarAction = {
id: string
title: string
icon: CustomIconName
iconClassName?: string // Just until we get rid of FontAwesome icons
keybinding: string
action: () => void
hide?: boolean | ((props: PaneCallbackProps) => boolean)
disable?: () => string | undefined
}
export const sidebarPanes: SidebarPane[] = [
{
id: 'code',
@ -74,7 +89,7 @@ export const sidebarPanes: SidebarPane[] = [
Content: FileTreeInner,
keybinding: 'Shift + F',
Menu: FileTreeMenu,
hideOnPlatform: 'web',
hide: ({ platform }) => platform === 'web',
},
{
id: 'variables',
@ -97,5 +112,6 @@ export const sidebarPanes: SidebarPane[] = [
icon: faBugSlash,
Content: DebugPane,
keybinding: 'Shift + D',
hide: ({ settings }) => !settings.modeling.showDebugPanel.current,
},
]