2024-09-16 17:12:54 -04:00
|
|
|
import { IconDefinition, faBugSlash } from '@fortawesome/free-solid-svg-icons'
|
2024-04-15 12:04:17 -04:00
|
|
|
import { KclEditorMenu } from 'components/ModelingSidebar/ModelingPanes/KclEditorMenu'
|
|
|
|
import { CustomIconName } from 'components/CustomIcon'
|
|
|
|
import { KclEditorPane } from 'components/ModelingSidebar/ModelingPanes/KclEditorPane'
|
2024-08-04 15:59:04 -07:00
|
|
|
import { MouseEventHandler, ReactNode } from 'react'
|
2024-05-17 16:40:20 -04:00
|
|
|
import { MemoryPane, MemoryPaneMenu } from './MemoryPane'
|
2024-08-01 19:40:16 -07:00
|
|
|
import { LogsPane } from './LoggingPanes'
|
2024-04-15 12:04:17 -04:00
|
|
|
import { DebugPane } from './DebugPane'
|
2024-10-28 14:29:47 -04:00
|
|
|
import { FileTreeInner, FileTreeMenu, FileTreeRoot } from 'components/FileTree'
|
2024-07-31 23:29:24 -04:00
|
|
|
import { useKclContext } from 'lang/KclProvider'
|
2024-08-04 15:59:04 -07:00
|
|
|
import { editorManager } from 'lib/singletons'
|
2024-09-13 14:49:33 -04:00
|
|
|
import { ContextFrom } from 'xstate'
|
|
|
|
import { settingsMachine } from 'machines/settingsMachine'
|
2024-04-15 12:04:17 -04:00
|
|
|
|
2024-04-25 09:56:55 -04:00
|
|
|
export type SidebarType =
|
|
|
|
| 'code'
|
|
|
|
| 'debug'
|
|
|
|
| 'export'
|
|
|
|
| 'files'
|
|
|
|
| 'logs'
|
|
|
|
| 'lspMessages'
|
|
|
|
| 'variables'
|
|
|
|
|
2024-08-04 15:59:04 -07:00
|
|
|
export interface BadgeInfo {
|
|
|
|
value: (props: PaneCallbackProps) => boolean | number
|
|
|
|
onClick?: MouseEventHandler<any>
|
|
|
|
}
|
|
|
|
|
2024-07-31 23:29:24 -04:00
|
|
|
/**
|
|
|
|
* This interface can be extended as more context is needed for the panes
|
|
|
|
* to determine if they should show their badges or not.
|
|
|
|
*/
|
|
|
|
interface PaneCallbackProps {
|
|
|
|
kclContext: ReturnType<typeof useKclContext>
|
2024-09-13 14:49:33 -04:00
|
|
|
settings: ContextFrom<typeof settingsMachine>
|
|
|
|
platform: 'web' | 'desktop'
|
2024-07-31 23:29:24 -04:00
|
|
|
}
|
|
|
|
|
2024-04-25 09:56:55 -04:00
|
|
|
export type SidebarPane = {
|
|
|
|
id: SidebarType
|
2024-10-28 14:29:47 -04:00
|
|
|
title: ReactNode
|
|
|
|
sidebarName?: string
|
2024-04-15 12:04:17 -04:00
|
|
|
icon: CustomIconName | IconDefinition
|
2024-04-25 09:56:55 -04:00
|
|
|
keybinding: string
|
2024-04-15 12:04:17 -04:00
|
|
|
Content: ReactNode | React.FC
|
|
|
|
Menu?: ReactNode | React.FC
|
2024-09-13 14:49:33 -04:00
|
|
|
hide?: boolean | ((props: PaneCallbackProps) => boolean)
|
2024-08-04 15:59:04 -07:00
|
|
|
showBadge?: BadgeInfo
|
2024-04-15 12:04:17 -04:00
|
|
|
}
|
|
|
|
|
2024-09-13 14:49:33 -04:00
|
|
|
export type SidebarAction = {
|
|
|
|
id: string
|
2024-10-28 14:29:47 -04:00
|
|
|
title: ReactNode
|
2024-09-13 14:49:33 -04:00
|
|
|
icon: CustomIconName
|
|
|
|
iconClassName?: string // Just until we get rid of FontAwesome icons
|
|
|
|
keybinding: string
|
|
|
|
action: () => void
|
|
|
|
hide?: boolean | ((props: PaneCallbackProps) => boolean)
|
|
|
|
disable?: () => string | undefined
|
|
|
|
}
|
|
|
|
|
2024-07-24 22:02:16 -04:00
|
|
|
export const sidebarPanes: SidebarPane[] = [
|
2024-04-15 12:04:17 -04:00
|
|
|
{
|
|
|
|
id: 'code',
|
|
|
|
title: 'KCL Code',
|
2024-09-16 17:12:54 -04:00
|
|
|
icon: 'code',
|
2024-04-15 12:04:17 -04:00
|
|
|
Content: KclEditorPane,
|
2024-07-24 22:02:16 -04:00
|
|
|
keybinding: 'Shift + C',
|
2024-04-15 12:04:17 -04:00
|
|
|
Menu: KclEditorMenu,
|
2024-08-04 15:59:04 -07:00
|
|
|
showBadge: {
|
|
|
|
value: ({ kclContext }) => {
|
|
|
|
return kclContext.errors.length
|
|
|
|
},
|
|
|
|
onClick: (e) => {
|
|
|
|
e.preventDefault()
|
2024-08-04 19:44:33 -07:00
|
|
|
editorManager.scrollToFirstErrorDiagnosticIfExists()
|
2024-08-04 15:59:04 -07:00
|
|
|
},
|
|
|
|
},
|
2024-04-15 12:04:17 -04:00
|
|
|
},
|
2024-04-25 09:56:55 -04:00
|
|
|
{
|
|
|
|
id: 'files',
|
2024-10-28 14:29:47 -04:00
|
|
|
title: <FileTreeRoot />,
|
|
|
|
sidebarName: 'Project Files',
|
2024-04-25 09:56:55 -04:00
|
|
|
icon: 'folder',
|
|
|
|
Content: FileTreeInner,
|
2024-07-24 22:02:16 -04:00
|
|
|
keybinding: 'Shift + F',
|
2024-04-25 09:56:55 -04:00
|
|
|
Menu: FileTreeMenu,
|
2024-09-13 14:49:33 -04:00
|
|
|
hide: ({ platform }) => platform === 'web',
|
2024-04-25 09:56:55 -04:00
|
|
|
},
|
2024-04-15 12:04:17 -04:00
|
|
|
{
|
|
|
|
id: 'variables',
|
|
|
|
title: 'Variables',
|
2024-09-16 17:12:54 -04:00
|
|
|
icon: 'make-variable',
|
2024-04-15 12:04:17 -04:00
|
|
|
Content: MemoryPane,
|
2024-05-17 16:40:20 -04:00
|
|
|
Menu: MemoryPaneMenu,
|
2024-07-24 22:02:16 -04:00
|
|
|
keybinding: 'Shift + V',
|
2024-04-15 12:04:17 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'logs',
|
|
|
|
title: 'Logs',
|
2024-09-16 17:12:54 -04:00
|
|
|
icon: 'logs',
|
2024-04-15 12:04:17 -04:00
|
|
|
Content: LogsPane,
|
2024-07-24 22:02:16 -04:00
|
|
|
keybinding: 'Shift + L',
|
2024-04-15 12:04:17 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'debug',
|
|
|
|
title: 'Debug',
|
|
|
|
icon: faBugSlash,
|
|
|
|
Content: DebugPane,
|
2024-07-24 22:02:16 -04:00
|
|
|
keybinding: 'Shift + D',
|
2024-09-13 14:49:33 -04:00
|
|
|
hide: ({ settings }) => !settings.modeling.showDebugPanel.current,
|
2024-04-15 12:04:17 -04:00
|
|
|
},
|
|
|
|
]
|