From f3036e59798879a4a6a46e40e19cf0c546803269 Mon Sep 17 00:00:00 2001 From: David <33458145+davidmcpowell@users.noreply.github.com> Date: Tue, 21 Oct 2025 10:07:35 +0100 Subject: [PATCH] Merge pull request #29033 from overleaf/dp-histroy-current-version Hide restore version option for current history version GitOrigin-RevId: 1eecaced2d7423bf8e28ab97e27288691ab0b002 --- .../dropdown/history-dropdown-content.tsx | 6 +++++- .../history/components/diff-view/diff-view.tsx | 12 ++++++++++-- .../history/components/diff-view/toolbar/toolbar.tsx | 12 ++++++++++-- .../features/history/components/toolbar.spec.tsx | 2 +- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/services/web/frontend/js/features/history/components/change-list/dropdown/history-dropdown-content.tsx b/services/web/frontend/js/features/history/components/change-list/dropdown/history-dropdown-content.tsx index 43858f7eb3..1090f04ae6 100644 --- a/services/web/frontend/js/features/history/components/change-list/dropdown/history-dropdown-content.tsx +++ b/services/web/frontend/js/features/history/components/change-list/dropdown/history-dropdown-content.tsx @@ -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 && ( () 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 (
- +
diff --git a/services/web/frontend/js/features/history/components/diff-view/toolbar/toolbar.tsx b/services/web/frontend/js/features/history/components/diff-view/toolbar/toolbar.tsx index 8e9fb2a4ab..1430ee7dfc 100644 --- a/services/web/frontend/js/features/history/components/diff-view/toolbar/toolbar.tsx +++ b/services/web/frontend/js/features/history/components/diff-view/toolbar/toolbar.tsx @@ -13,14 +13,22 @@ import { usePermissionsContext } from '@/features/ide-react/context/permissions- type ToolbarProps = { diff: Nullable 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 && diff --git a/services/web/test/frontend/features/history/components/toolbar.spec.tsx b/services/web/test/frontend/features/history/components/toolbar.spec.tsx index bc2b518eae..7a43c0151d 100644 --- a/services/web/test/frontend/features/history/components/toolbar.spec.tsx +++ b/services/web/test/frontend/features/history/components/toolbar.spec.tsx @@ -16,7 +16,7 @@ const TestContainerWithoutErrorBoundary: FC<{
- +