Skip to content

Commit

Permalink
Chore/minor improvements from user feedback (#252)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
geclos authored Sep 23, 2024
1 parent 6164587 commit a42d900
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -31,18 +30,16 @@ 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
.detail({ id: project.id })
.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 } =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
SelectTrigger,
SelectValueWithIcon,
Text,
useCurrentCommit,
useCurrentProject,
} from '@latitude-data/web-ui'
import { useNavigate } from '$/hooks/useNavigate'
Expand Down Expand Up @@ -118,6 +119,7 @@ function CommitItem({
onCommitDelete: ReactStateDispatch<number | null>
}) {
const { project } = useCurrentProject()
const { commit: currentCommit } = useCurrentCommit()
const router = useNavigate()
const selectedSegment = useSelectedLayoutSegment()
if (!commit) return null
Expand Down Expand Up @@ -156,9 +158,11 @@ function CommitItem({
</Text.H6>
</div>
<div className='flex gap-x-4'>
<Button variant='link' size='none' onClick={navigateToCommit}>
View
</Button>
{currentCommit.uuid !== commit.uuid && (
<Button variant='link' size='none' onClick={navigateToCommit}>
View
</Button>
)}
{isDraft ? (
<>
<Button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { TableBlankSlate, TableWithHeader } from '@latitude-data/web-ui'
import {
findCommitCached,
getDocumentLogsWithMetadataCached,
} from '$/app/(private)/_data-access'

import { Header } from '../_components/DocumentEditor/Editor/Header'
import { DocumentLogs } from './_components/DocumentLogs'

export default async function DocumentPage({
Expand All @@ -21,8 +21,17 @@ export default async function DocumentPage({

return (
<div className='flex flex-col w-full h-full overflow-hidden p-6 gap-2 min-w-0'>
<Header title='Logs' />
<DocumentLogs documentLogs={logs} />
<TableWithHeader
title='Logs'
table={
<>
{!logs.length && (
<TableBlankSlate description='There are no logs for this prompt yet. Logs will appear here when you run the prompt for the first time.' />
)}
{logs.length > 0 && <DocumentLogs documentLogs={logs} />}
</>
}
/>
</div>
)
}

0 comments on commit a42d900

Please sign in to comment.