2023-10-02 05:35:02 -04:00
|
|
|
import { Panel, PanelGroup } from 'react-resizable-panels'
|
2023-12-05 05:19:00 -05:00
|
|
|
import { FC } from 'react'
|
2023-10-02 05:35:02 -04:00
|
|
|
import { HorizontalResizeHandle } from '../resize/horizontal-resize-handle'
|
2023-11-15 06:55:05 -05:00
|
|
|
import classNames from 'classnames'
|
2023-12-05 04:34:21 -05:00
|
|
|
import { useLayoutContext } from '@/shared/context/layout-context'
|
|
|
|
import EditorNavigationToolbar from '@/features/ide-react/components/editor-navigation-toolbar'
|
|
|
|
import ChatPane from '@/features/chat/components/chat-pane'
|
2023-12-05 05:19:00 -05:00
|
|
|
import { HorizontalToggler } from '@/features/ide-react/components/resize/horizontal-toggler'
|
|
|
|
import { HistorySidebar } from '@/features/ide-react/components/history-sidebar'
|
|
|
|
import EditorSidebar from '@/features/ide-react/components/editor-sidebar'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { useSidebarPane } from '@/features/ide-react/hooks/use-sidebar-pane'
|
|
|
|
import { useChatPane } from '@/features/ide-react/hooks/use-chat-pane'
|
|
|
|
import { EditorAndPdf } from '@/features/ide-react/components/editor-and-pdf'
|
2024-02-27 05:30:37 -05:00
|
|
|
import HistoryContainer from '@/features/ide-react/components/history-container'
|
2024-10-09 05:17:12 -04:00
|
|
|
import getMeta from '@/utils/meta'
|
2023-10-02 05:35:02 -04:00
|
|
|
|
2023-12-05 05:19:00 -05:00
|
|
|
export const MainLayout: FC = () => {
|
|
|
|
const { view } = useLayoutContext()
|
2023-10-02 05:35:02 -04:00
|
|
|
|
2023-12-05 05:19:00 -05:00
|
|
|
const {
|
|
|
|
isOpen: sidebarIsOpen,
|
|
|
|
setIsOpen: setSidebarIsOpen,
|
2023-12-20 06:48:24 -05:00
|
|
|
panelRef: sidebarPanelRef,
|
2023-12-05 05:19:00 -05:00
|
|
|
togglePane: toggleSidebar,
|
|
|
|
handlePaneExpand: handleSidebarExpand,
|
|
|
|
handlePaneCollapse: handleSidebarCollapse,
|
|
|
|
resizing: sidebarResizing,
|
|
|
|
setResizing: setSidebarResizing,
|
|
|
|
} = useSidebarPane()
|
2023-12-05 04:34:21 -05:00
|
|
|
|
2023-12-05 05:19:00 -05:00
|
|
|
const {
|
|
|
|
isOpen: chatIsOpen,
|
2023-12-20 06:48:24 -05:00
|
|
|
panelRef: chatPanelRef,
|
2023-12-08 04:37:05 -05:00
|
|
|
togglePane: toggleChat,
|
2023-12-05 05:19:00 -05:00
|
|
|
resizing: chatResizing,
|
|
|
|
setResizing: setChatResizing,
|
2023-12-08 04:37:05 -05:00
|
|
|
handlePaneCollapse: handleChatCollapse,
|
|
|
|
handlePaneExpand: handleChatExpand,
|
2023-12-05 05:19:00 -05:00
|
|
|
} = useChatPane()
|
|
|
|
|
2024-10-09 05:17:12 -04:00
|
|
|
const chatEnabled = getMeta('ol-chatEnabled')
|
|
|
|
|
2023-12-05 05:19:00 -05:00
|
|
|
const { t } = useTranslation()
|
2023-10-02 05:35:02 -04:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="ide-react-main">
|
2023-12-05 04:34:21 -05:00
|
|
|
<EditorNavigationToolbar />
|
2023-10-02 05:35:02 -04:00
|
|
|
<div className="ide-react-body">
|
|
|
|
<PanelGroup
|
2023-12-05 05:19:00 -05:00
|
|
|
autoSaveId="ide-outer-layout"
|
2023-10-02 05:35:02 -04:00
|
|
|
direction="horizontal"
|
2023-11-15 06:55:05 -05:00
|
|
|
className={classNames({
|
2023-12-05 05:19:00 -05:00
|
|
|
'ide-panel-group-resizing': sidebarResizing || chatResizing,
|
2023-11-15 06:55:05 -05:00
|
|
|
})}
|
2023-10-02 05:35:02 -04:00
|
|
|
>
|
2023-12-05 05:19:00 -05:00
|
|
|
{/* sidebar */}
|
|
|
|
<Panel
|
|
|
|
ref={sidebarPanelRef}
|
|
|
|
id="panel-sidebar"
|
|
|
|
order={1}
|
2024-01-03 06:13:21 -05:00
|
|
|
defaultSize={15}
|
2023-12-20 07:18:12 -05:00
|
|
|
minSize={5}
|
2024-01-18 07:53:10 -05:00
|
|
|
maxSize={80}
|
2023-12-05 05:19:00 -05:00
|
|
|
collapsible
|
|
|
|
onCollapse={handleSidebarCollapse}
|
|
|
|
onExpand={handleSidebarExpand}
|
|
|
|
>
|
2023-12-15 04:19:42 -05:00
|
|
|
<EditorSidebar />
|
2023-12-05 05:19:00 -05:00
|
|
|
{view === 'history' && <HistorySidebar />}
|
2023-10-02 05:35:02 -04:00
|
|
|
</Panel>
|
2023-12-05 05:19:00 -05:00
|
|
|
|
|
|
|
<HorizontalResizeHandle
|
|
|
|
onDoubleClick={toggleSidebar}
|
|
|
|
resizable={sidebarIsOpen}
|
|
|
|
onDragging={setSidebarResizing}
|
2024-09-05 07:10:51 -04:00
|
|
|
hitAreaMargins={{ coarse: 0, fine: 0 }}
|
2023-12-05 05:19:00 -05:00
|
|
|
>
|
|
|
|
<HorizontalToggler
|
|
|
|
id="panel-sidebar"
|
|
|
|
togglerType="west"
|
|
|
|
isOpen={sidebarIsOpen}
|
|
|
|
setIsOpen={setSidebarIsOpen}
|
|
|
|
tooltipWhenOpen={t('tooltip_hide_filetree')}
|
|
|
|
tooltipWhenClosed={t('tooltip_show_filetree')}
|
|
|
|
/>
|
|
|
|
</HorizontalResizeHandle>
|
|
|
|
|
|
|
|
<Panel id="panel-outer-main" order={2}>
|
2023-12-20 06:54:02 -05:00
|
|
|
<PanelGroup autoSaveId="ide-inner-layout" direction="horizontal">
|
2023-12-05 05:19:00 -05:00
|
|
|
<Panel className="ide-react-panel" id="panel-main" order={1}>
|
2024-02-27 05:30:37 -05:00
|
|
|
<HistoryContainer />
|
2024-02-22 08:20:37 -05:00
|
|
|
<EditorAndPdf />
|
2023-10-02 05:35:02 -04:00
|
|
|
</Panel>
|
2023-12-05 05:19:00 -05:00
|
|
|
|
2024-10-09 05:17:12 -04:00
|
|
|
{chatEnabled && (
|
|
|
|
<>
|
|
|
|
<HorizontalResizeHandle
|
|
|
|
onDoubleClick={toggleChat}
|
|
|
|
resizable={chatIsOpen}
|
|
|
|
onDragging={setChatResizing}
|
|
|
|
hitAreaMargins={{ coarse: 0, fine: 0 }}
|
|
|
|
/>
|
2023-12-05 05:19:00 -05:00
|
|
|
|
2024-10-09 05:17:12 -04:00
|
|
|
{/* chat */}
|
|
|
|
<Panel
|
|
|
|
ref={chatPanelRef}
|
|
|
|
id="panel-chat"
|
|
|
|
order={2}
|
|
|
|
defaultSize={20}
|
|
|
|
minSize={5}
|
|
|
|
maxSize={30}
|
|
|
|
collapsible
|
|
|
|
onCollapse={handleChatCollapse}
|
|
|
|
onExpand={handleChatExpand}
|
|
|
|
>
|
|
|
|
<ChatPane />
|
|
|
|
</Panel>
|
|
|
|
</>
|
|
|
|
)}
|
2023-12-05 05:19:00 -05:00
|
|
|
</PanelGroup>
|
|
|
|
</Panel>
|
2023-10-02 05:35:02 -04:00
|
|
|
</PanelGroup>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|