From a42d900468bb2ccc688be323141cfa9171e4335c Mon Sep 17 00:00:00 2001 From: Gerard Date: Mon, 23 Sep 2024 10:42:40 +0200 Subject: [PATCH] Chore/minor improvements from user feedback (#252) * chore: hide view button in commit selector if it is the currently selected commit * chore: add blank slate in logs section * chore: if user is in subsection within a document and they select another document, do not keep the subsection selected and get them to the editor page instead --- .../_components/Sidebar/ClientFilesTree/index.tsx | 9 +++------ .../_components/Sidebar/CommitSelector/index.tsx | 10 +++++++--- .../documents/[documentUuid]/logs/page.tsx | 15 ++++++++++++--- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/_components/Sidebar/ClientFilesTree/index.tsx b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/_components/Sidebar/ClientFilesTree/index.tsx index 9244d8cf0..0695552d7 100644 --- a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/_components/Sidebar/ClientFilesTree/index.tsx +++ b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/_components/Sidebar/ClientFilesTree/index.tsx @@ -10,9 +10,8 @@ import { type SidebarDocument, } from '@latitude-data/web-ui' import { useNavigate } from '$/hooks/useNavigate' -import { DocumentRoutes, ROUTES } from '$/services/routes' +import { ROUTES } from '$/services/routes' import useDocumentVersions from '$/stores/documentVersions' -import { useSelectedLayoutSegment } from 'next/navigation' import CreateDraftCommitModal from '../CreateDraftCommitModal' import MergedCommitWarningModal from '../MergedCommitWarningModal' @@ -31,7 +30,6 @@ export default function ClientFilesTree({ const isMerged = !!commit.mergedAt const { project } = useCurrentProject() const documentPath = currentDocument?.path - const selectedSegment = useSelectedLayoutSegment() as DocumentRoutes | null const navigateToDocument = useCallback( (documentUuid: string) => { const documentDetails = ROUTES.projects @@ -39,10 +37,9 @@ export default function ClientFilesTree({ .commits.detail({ uuid: isHead ? HEAD_COMMIT : commit.uuid }) .documents.detail({ uuid: documentUuid }) - if (!selectedSegment) return router.push(documentDetails.root) - router.push(documentDetails[selectedSegment].root) + return router.push(documentDetails.root) }, - [selectedSegment, project.id, commit.uuid, isHead], + [project.id, commit.uuid, isHead], ) const { createFile, destroyFile, destroyFolder, isDestroying, data } = diff --git a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/_components/Sidebar/CommitSelector/index.tsx b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/_components/Sidebar/CommitSelector/index.tsx index ce0f6e4a4..c4d6404b0 100644 --- a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/_components/Sidebar/CommitSelector/index.tsx +++ b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/_components/Sidebar/CommitSelector/index.tsx @@ -25,6 +25,7 @@ import { SelectTrigger, SelectValueWithIcon, Text, + useCurrentCommit, useCurrentProject, } from '@latitude-data/web-ui' import { useNavigate } from '$/hooks/useNavigate' @@ -118,6 +119,7 @@ function CommitItem({ onCommitDelete: ReactStateDispatch }) { const { project } = useCurrentProject() + const { commit: currentCommit } = useCurrentCommit() const router = useNavigate() const selectedSegment = useSelectedLayoutSegment() if (!commit) return null @@ -156,9 +158,11 @@ function CommitItem({
- + {currentCommit.uuid !== commit.uuid && ( + + )} {isDraft ? ( <>
) }