From c39a566fe31f9b203cf7c435f27ec3a43a1e0c07 Mon Sep 17 00:00:00 2001 From: ilkin-overleaf <100852799+ilkin-overleaf@users.noreply.github.com> Date: Fri, 27 Oct 2023 13:50:57 +0300 Subject: [PATCH] Merge pull request #15221 from overleaf/ii-ide-page-prototype-file-tree-history FileTree for history React IDE page GitOrigin-RevId: 56fadced9f507297ba16dc54715811f36dcfd5b5 --- .../components/editor-and-sidebar.tsx | 24 ++++++++--- .../ide-react/components/editor-sidebar.tsx | 42 ++++++++++++------- .../ide-react/components/editor/editor.tsx | 6 +-- .../features/ide-react/components/history.tsx | 23 ++++++++++ .../ide-react/components/layout/ide-page.tsx | 12 +----- .../placeholder/placeholder-history.tsx | 2 +- 6 files changed, 75 insertions(+), 34 deletions(-) create mode 100644 services/web/frontend/js/features/ide-react/components/history.tsx diff --git a/services/web/frontend/js/features/ide-react/components/editor-and-sidebar.tsx b/services/web/frontend/js/features/ide-react/components/editor-and-sidebar.tsx index 103aae86b5..53cb7a05a3 100644 --- a/services/web/frontend/js/features/ide-react/components/editor-and-sidebar.tsx +++ b/services/web/frontend/js/features/ide-react/components/editor-and-sidebar.tsx @@ -3,7 +3,10 @@ import TwoColumnMainContent from '@/features/ide-react/components/layout/two-col import Editor from '@/features/ide-react/components/editor/editor' import EditorSidebar from '@/features/ide-react/components/editor-sidebar' import customLocalStorage from '@/infrastructure/local-storage' +import History from '@/features/ide-react/components/history' +import { HistoryProvider } from '@/features/history/context/history-context' import { useProjectContext } from '@/shared/context/project-context' +import { useLayoutContext } from '@/shared/context/layout-context' import { FileTreeFindResult } from '@/features/ide-react/types/file-tree' type EditorAndSidebarProps = { @@ -19,6 +22,8 @@ export function EditorAndSidebar({ }: EditorAndSidebarProps) { const [leftColumnIsOpen, setLeftColumnIsOpen] = useState(true) const { rootDocId, _id: projectId } = useProjectContext() + const { view } = useLayoutContext() + const historyIsOpen = view === 'history' const [openDocId, setOpenDocId] = useState( () => customLocalStorage.getItem(`doc.open_id.${projectId}`) || rootDocId @@ -46,12 +51,21 @@ export function EditorAndSidebar({ onFileTreeSelect={handleFileTreeSelect} /> ) + const rightColumnContent = ( - + <> + {/* Recreate the history context when the history view is toggled */} + {historyIsOpen && ( + + + + )} + + ) return ( diff --git a/services/web/frontend/js/features/ide-react/components/editor-sidebar.tsx b/services/web/frontend/js/features/ide-react/components/editor-sidebar.tsx index 3dd9d81109..eaf88fcab2 100644 --- a/services/web/frontend/js/features/ide-react/components/editor-sidebar.tsx +++ b/services/web/frontend/js/features/ide-react/components/editor-sidebar.tsx @@ -2,6 +2,8 @@ import React from 'react' import { Panel, PanelGroup } from 'react-resizable-panels' import { VerticalResizeHandle } from '@/features/ide-react/components/resize/vertical-resize-handle' import { FileTree } from '@/features/ide-react/components/file-tree' +import { useLayoutContext } from '@/shared/context/layout-context' +import classnames from 'classnames' import { FileTreeSelectHandler } from '@/features/ide-react/types/file-tree' type EditorSidebarProps = { @@ -15,22 +17,32 @@ export default function EditorSidebar({ onFileTreeInit, onFileTreeSelect, }: EditorSidebarProps) { + const { view } = useLayoutContext() + const historyIsOpen = view === 'history' + return ( - +