mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Merge pull request #29033 from overleaf/dp-histroy-current-version
Hide restore version option for current history version GitOrigin-RevId: 1eecaced2d7423bf8e28ab97e27288691ab0b002
This commit is contained in:
+5
-1
@@ -5,6 +5,7 @@ import { useCallback } from 'react'
|
||||
import { ActiveDropdown } from '../../../hooks/use-dropdown-active-item'
|
||||
import RestoreProject from './menu-item/restore-project'
|
||||
import { usePermissionsContext } from '@/features/ide-react/context/permissions-context'
|
||||
import { useHistoryContext } from '@/features/history/context/history-context'
|
||||
|
||||
type VersionDropdownContentProps = {
|
||||
projectId: string
|
||||
@@ -19,6 +20,9 @@ function HistoryDropdownContent({
|
||||
closeDropdownForItem,
|
||||
endTimestamp,
|
||||
}: VersionDropdownContentProps) {
|
||||
const { updatesInfo } = useHistoryContext()
|
||||
const isCurrentVersion = version === updatesInfo.updates[0].toV
|
||||
|
||||
const closeDropdown = useCallback(() => {
|
||||
closeDropdownForItem(version, 'moreOptions')
|
||||
}, [closeDropdownForItem, version])
|
||||
@@ -35,7 +39,7 @@ function HistoryDropdownContent({
|
||||
version={version}
|
||||
closeDropdown={closeDropdown}
|
||||
/>
|
||||
{permissions.write && (
|
||||
{permissions.write && !isCurrentVersion && (
|
||||
<RestoreProject
|
||||
projectId={projectId}
|
||||
version={version}
|
||||
|
||||
@@ -10,12 +10,16 @@ import useAsync from '../../../../shared/hooks/use-async'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
function DiffView() {
|
||||
const { selection, projectId, loadingFileDiffs } = useHistoryContext()
|
||||
const { selection, projectId, loadingFileDiffs, updatesInfo } =
|
||||
useHistoryContext()
|
||||
const { isLoading, data, runAsync } = useAsync<DocDiffResponse>()
|
||||
const { t } = useTranslation()
|
||||
const { updateRange, selectedFile } = selection
|
||||
const { showBoundary } = useErrorBoundary()
|
||||
|
||||
const isCurrentVersion =
|
||||
!!updateRange && updatesInfo.updates[0].toV === updateRange.toV
|
||||
|
||||
useEffect(() => {
|
||||
if (!updateRange || !selectedFile?.pathname || loadingFileDiffs) {
|
||||
return
|
||||
@@ -73,7 +77,11 @@ function DiffView() {
|
||||
return (
|
||||
<div className="doc-panel">
|
||||
<div className="history-header toolbar-container">
|
||||
<Toolbar diff={diff} selection={selection} />
|
||||
<Toolbar
|
||||
diff={diff}
|
||||
selection={selection}
|
||||
isCurrentVersion={isCurrentVersion}
|
||||
/>
|
||||
</div>
|
||||
<div className="doc-container">
|
||||
<Main diff={diff} isLoading={isLoading || loadingFileDiffs} />
|
||||
|
||||
@@ -13,14 +13,22 @@ import { usePermissionsContext } from '@/features/ide-react/context/permissions-
|
||||
type ToolbarProps = {
|
||||
diff: Nullable<Diff>
|
||||
selection: HistoryContextValue['selection']
|
||||
isCurrentVersion: boolean
|
||||
}
|
||||
|
||||
export default function Toolbar({ diff, selection }: ToolbarProps) {
|
||||
export default function Toolbar({
|
||||
diff,
|
||||
selection,
|
||||
isCurrentVersion,
|
||||
}: ToolbarProps) {
|
||||
const { write } = usePermissionsContext()
|
||||
const hasRestoreFileToVersion = useFeatureFlag('revert-file')
|
||||
|
||||
const showRestoreFileToVersionButton =
|
||||
hasRestoreFileToVersion && selection.selectedFile && write
|
||||
hasRestoreFileToVersion &&
|
||||
selection.selectedFile &&
|
||||
write &&
|
||||
!isCurrentVersion
|
||||
|
||||
const showRestoreFileButton =
|
||||
selection.selectedFile &&
|
||||
|
||||
@@ -16,7 +16,7 @@ const TestContainerWithoutErrorBoundary: FC<{
|
||||
<EditorProviders layoutContext={layoutContext}>
|
||||
<HistoryProvider>
|
||||
<div className="history-react">
|
||||
<Toolbar diff={diff} selection={selection} />
|
||||
<Toolbar diff={diff} selection={selection} isCurrentVersion={false} />
|
||||
</div>
|
||||
</HistoryProvider>
|
||||
</EditorProviders>
|
||||
|
||||
Reference in New Issue
Block a user