mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Merge pull request #23914 from overleaf/dp-history
Add existing history view into new editor GitOrigin-RevId: 0d35ba1f38dafd8a71087f231f2cddc1b0424401
This commit is contained in:
@@ -11,6 +11,7 @@ import { useLayoutContext } from '@/shared/context/layout-context'
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import EditorPanel from './editor-panel'
|
import EditorPanel from './editor-panel'
|
||||||
import { useRailContext } from '../contexts/rail-context'
|
import { useRailContext } from '../contexts/rail-context'
|
||||||
|
import HistoryContainer from '@/features/ide-react/components/history-container'
|
||||||
|
|
||||||
export default function MainLayout() {
|
export default function MainLayout() {
|
||||||
const [resizing, setResizing] = useState(false)
|
const [resizing, setResizing] = useState(false)
|
||||||
@@ -30,6 +31,7 @@ export default function MainLayout() {
|
|||||||
view === 'editor' || view === 'file' || pdfLayout === 'sideBySide'
|
view === 'editor' || view === 'file' || pdfLayout === 'sideBySide'
|
||||||
|
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ide-redesign-main">
|
<div className="ide-redesign-main">
|
||||||
<Toolbar />
|
<Toolbar />
|
||||||
@@ -42,49 +44,59 @@ export default function MainLayout() {
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<RailLayout />
|
<RailLayout />
|
||||||
<Panel
|
<Panel id="ide-redesign-editor-and-pdf-panel" order={2}>
|
||||||
id="ide-redesign-editor-panel"
|
<HistoryContainer />
|
||||||
order={1}
|
<PanelGroup
|
||||||
className={classNames({
|
autoSaveId="ide-redesign-editor-and-pdf-panel-group"
|
||||||
hidden: !editorIsOpen,
|
direction="horizontal"
|
||||||
})}
|
>
|
||||||
minSize={5}
|
<Panel
|
||||||
defaultSize={50}
|
id="ide-redesign-editor-panel"
|
||||||
>
|
order={1}
|
||||||
<div className="ide-redesign-editor-container">
|
className={classNames({
|
||||||
<EditorPanel />
|
hidden: !editorIsOpen || view === 'history',
|
||||||
</div>
|
})}
|
||||||
</Panel>
|
minSize={5}
|
||||||
<HorizontalResizeHandle
|
defaultSize={50}
|
||||||
resizable={pdfLayout === 'sideBySide'}
|
>
|
||||||
onDragging={setResizing}
|
<div className="ide-redesign-editor-container">
|
||||||
onDoubleClick={togglePdfPane}
|
<EditorPanel />
|
||||||
hitAreaMargins={{ coarse: 0, fine: 0 }}
|
</div>
|
||||||
className={classNames({
|
</Panel>
|
||||||
hidden: !editorIsOpen,
|
<HorizontalResizeHandle
|
||||||
})}
|
resizable={pdfLayout === 'sideBySide'}
|
||||||
>
|
onDragging={setResizing}
|
||||||
<HorizontalToggler
|
onDoubleClick={togglePdfPane}
|
||||||
id="ide-redesign-pdf-panel"
|
hitAreaMargins={{ coarse: 0, fine: 0 }}
|
||||||
togglerType="east"
|
className={classNames({
|
||||||
isOpen={isPdfOpen}
|
hidden: !editorIsOpen,
|
||||||
setIsOpen={setIsPdfOpen}
|
})}
|
||||||
tooltipWhenOpen={t('tooltip_hide_pdf')}
|
>
|
||||||
tooltipWhenClosed={t('tooltip_show_pdf')}
|
<HorizontalToggler
|
||||||
/>
|
id="ide-redesign-pdf-panel"
|
||||||
</HorizontalResizeHandle>
|
togglerType="east"
|
||||||
<Panel
|
isOpen={isPdfOpen}
|
||||||
collapsible
|
setIsOpen={setIsPdfOpen}
|
||||||
className="ide-redesign-pdf-container"
|
tooltipWhenOpen={t('tooltip_hide_pdf')}
|
||||||
id="ide-redesign-pdf-panel"
|
tooltipWhenClosed={t('tooltip_show_pdf')}
|
||||||
order={2}
|
/>
|
||||||
defaultSize={50}
|
</HorizontalResizeHandle>
|
||||||
minSize={5}
|
<Panel
|
||||||
ref={pdfPanelRef}
|
collapsible
|
||||||
onExpand={handlePdfPaneExpand}
|
className={classNames('ide-redesign-pdf-container', {
|
||||||
onCollapse={handlePdfPaneCollapse}
|
hidden: view === 'history',
|
||||||
>
|
})}
|
||||||
<PdfPreview />
|
id="ide-redesign-pdf-panel"
|
||||||
|
order={2}
|
||||||
|
defaultSize={50}
|
||||||
|
minSize={5}
|
||||||
|
ref={pdfPanelRef}
|
||||||
|
onExpand={handlePdfPaneExpand}
|
||||||
|
onCollapse={handlePdfPaneCollapse}
|
||||||
|
>
|
||||||
|
<PdfPreview />
|
||||||
|
</Panel>
|
||||||
|
</PanelGroup>
|
||||||
</Panel>
|
</Panel>
|
||||||
</PanelGroup>
|
</PanelGroup>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import {
|
|||||||
} from '@/features/ui/components/bootstrap-5/dropdown-menu'
|
} from '@/features/ui/components/bootstrap-5/dropdown-menu'
|
||||||
import { RailHelpShowHotkeysModal } from './help/keyboard-shortcuts'
|
import { RailHelpShowHotkeysModal } from './help/keyboard-shortcuts'
|
||||||
import { RailHelpContactUsModal } from './help/contact-us'
|
import { RailHelpContactUsModal } from './help/contact-us'
|
||||||
|
import { HistorySidebar } from '@/features/ide-react/components/history-sidebar'
|
||||||
|
|
||||||
type RailElement = {
|
type RailElement = {
|
||||||
icon: AvailableUnfilledIcon
|
icon: AvailableUnfilledIcon
|
||||||
@@ -109,7 +110,11 @@ export const RailLayout = () => {
|
|||||||
togglePane,
|
togglePane,
|
||||||
setResizing,
|
setResizing,
|
||||||
} = useRailContext()
|
} = useRailContext()
|
||||||
const { setLeftMenuShown } = useLayoutContext()
|
|
||||||
|
const { view, setLeftMenuShown } = useLayoutContext()
|
||||||
|
|
||||||
|
const isHistoryView = view === 'history'
|
||||||
|
|
||||||
const railActions: RailAction[] = useMemo(
|
const railActions: RailAction[] = useMemo(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
@@ -154,7 +159,7 @@ export const RailLayout = () => {
|
|||||||
onSelect={onTabSelect}
|
onSelect={onTabSelect}
|
||||||
id="ide-rail-tabs"
|
id="ide-rail-tabs"
|
||||||
>
|
>
|
||||||
<div className="ide-rail">
|
<div className={classNames('ide-rail', { hidden: isHistoryView })}>
|
||||||
<Nav activeKey={selectedTab} className="ide-rail-tabs-nav">
|
<Nav activeKey={selectedTab} className="ide-rail-tabs-nav">
|
||||||
{RAIL_TABS.filter(({ hide }) => !hide).map(
|
{RAIL_TABS.filter(({ hide }) => !hide).map(
|
||||||
({ icon, key, indicator }) => (
|
({ icon, key, indicator }) => (
|
||||||
@@ -184,7 +189,10 @@ export const RailLayout = () => {
|
|||||||
onCollapse={handlePaneCollapse}
|
onCollapse={handlePaneCollapse}
|
||||||
onExpand={handlePaneExpand}
|
onExpand={handlePaneExpand}
|
||||||
>
|
>
|
||||||
<div className="ide-rail-content">
|
{isHistoryView && <HistorySidebar />}
|
||||||
|
<div
|
||||||
|
className={classNames('ide-rail-content', { hidden: isHistoryView })}
|
||||||
|
>
|
||||||
<Tab.Content>
|
<Tab.Content>
|
||||||
{RAIL_TABS.filter(({ hide }) => !hide).map(({ key, component }) => (
|
{RAIL_TABS.filter(({ hide }) => !hide).map(({ key, component }) => (
|
||||||
<Tab.Pane eventKey={key} key={key}>
|
<Tab.Pane eventKey={key} key={key}>
|
||||||
|
|||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
import OLButton from '@/features/ui/components/ol/ol-button'
|
||||||
|
import MaterialIcon from '@/shared/components/material-icon'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import OLTooltip from '@/features/ui/components/ol/ol-tooltip'
|
||||||
|
import * as eventTracking from '../../../../infrastructure/event-tracking'
|
||||||
|
import { useLayoutContext } from '@/shared/context/layout-context'
|
||||||
|
import { useCallback } from 'react'
|
||||||
|
|
||||||
|
export default function ShowHistoryButton() {
|
||||||
|
const { t } = useTranslation()
|
||||||
|
const { view, setView } = useLayoutContext()
|
||||||
|
|
||||||
|
const toggleHistoryOpen = useCallback(() => {
|
||||||
|
const action = view === 'history' ? 'close' : 'open'
|
||||||
|
eventTracking.sendMB('navigation-clicked-history', { action })
|
||||||
|
|
||||||
|
setView(view === 'history' ? 'editor' : 'history')
|
||||||
|
}, [view, setView])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="ide-redesign-toolbar-button-container">
|
||||||
|
<OLTooltip
|
||||||
|
id="tooltip-open-history"
|
||||||
|
description={t('history')}
|
||||||
|
overlayProps={{ delay: 0, placement: 'bottom' }}
|
||||||
|
>
|
||||||
|
<OLButton
|
||||||
|
size="sm"
|
||||||
|
variant="ghost"
|
||||||
|
className="ide-redesign-toolbar-button-subdued"
|
||||||
|
leadingIcon={<MaterialIcon type="history" />}
|
||||||
|
onClick={toggleHistoryOpen}
|
||||||
|
/>
|
||||||
|
</OLTooltip>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import OLButton from '@/features/ui/components/ol/ol-button'
|
|
||||||
import MaterialIcon from '@/shared/components/material-icon'
|
import MaterialIcon from '@/shared/components/material-icon'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { ToolbarMenuBar } from './menu-bar'
|
import { ToolbarMenuBar } from './menu-bar'
|
||||||
@@ -7,8 +6,8 @@ import { OnlineUsers } from './online-users'
|
|||||||
import ShareProjectButton from './share-project-button'
|
import ShareProjectButton from './share-project-button'
|
||||||
import importOverleafModules from '../../../../../macros/import-overleaf-module.macro'
|
import importOverleafModules from '../../../../../macros/import-overleaf-module.macro'
|
||||||
import { useEditorContext } from '@/shared/context/editor-context'
|
import { useEditorContext } from '@/shared/context/editor-context'
|
||||||
import OLTooltip from '@/features/ui/components/ol/ol-tooltip'
|
|
||||||
import ChangeLayoutButton from './change-layout-button'
|
import ChangeLayoutButton from './change-layout-button'
|
||||||
|
import ShowHistoryButton from './show-history-button'
|
||||||
|
|
||||||
const [publishModalModules] = importOverleafModules('publishModal')
|
const [publishModalModules] = importOverleafModules('publishModal')
|
||||||
const SubmitProjectButton = publishModalModules?.import.NewPublishToolbarButton
|
const SubmitProjectButton = publishModalModules?.import.NewPublishToolbarButton
|
||||||
@@ -40,7 +39,6 @@ const ToolbarMenus = () => {
|
|||||||
|
|
||||||
const ToolbarButtons = () => {
|
const ToolbarButtons = () => {
|
||||||
const { permissionsLevel } = useEditorContext()
|
const { permissionsLevel } = useEditorContext()
|
||||||
const { t } = useTranslation()
|
|
||||||
|
|
||||||
const shouldDisplaySubmitButton =
|
const shouldDisplaySubmitButton =
|
||||||
(permissionsLevel === 'owner' || permissionsLevel === 'readAndWrite') &&
|
(permissionsLevel === 'owner' || permissionsLevel === 'readAndWrite') &&
|
||||||
@@ -49,20 +47,7 @@ const ToolbarButtons = () => {
|
|||||||
return (
|
return (
|
||||||
<div className="ide-redesign-toolbar-actions">
|
<div className="ide-redesign-toolbar-actions">
|
||||||
<OnlineUsers />
|
<OnlineUsers />
|
||||||
<div className="ide-redesign-toolbar-button-container">
|
<ShowHistoryButton />
|
||||||
<OLTooltip
|
|
||||||
id="tooltip-open-history"
|
|
||||||
description={t('history')}
|
|
||||||
overlayProps={{ delay: 0, placement: 'bottom' }}
|
|
||||||
>
|
|
||||||
<OLButton
|
|
||||||
size="sm"
|
|
||||||
variant="ghost"
|
|
||||||
className="ide-redesign-toolbar-button-subdued"
|
|
||||||
leadingIcon={<MaterialIcon type="history" />}
|
|
||||||
/>
|
|
||||||
</OLTooltip>
|
|
||||||
</div>
|
|
||||||
<ChangeLayoutButton />
|
<ChangeLayoutButton />
|
||||||
{shouldDisplaySubmitButton && <SubmitProjectButton />}
|
{shouldDisplaySubmitButton && <SubmitProjectButton />}
|
||||||
<ShareProjectButton />
|
<ShareProjectButton />
|
||||||
|
|||||||
Reference in New Issue
Block a user