-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: fixes evaluations filtering in documentuuid view (#163)
Also reorders routes to make place for the evaluation detail view
- Loading branch information
Showing
18 changed files
with
215 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
...jectId]/versions/[commitUuid]/documents/[documentUuid]/evaluations/_components/Layout.tsx
This file was deleted.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
...uid]/documents/[documentUuid]/evaluations/dashboard/_components/BatchEvaluationsTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { EvaluationDto } from '@latitude-data/core/browser' | ||
import { | ||
Icon, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableHeader, | ||
TableRow, | ||
Text, | ||
useCurrentCommit, | ||
useCurrentDocument, | ||
useCurrentProject, | ||
} from '@latitude-data/web-ui' | ||
import { useNavigate } from '$/hooks/useNavigate' | ||
import { ROUTES } from '$/services/routes' | ||
import Link from 'next/link' | ||
|
||
export default function BatchEvaluationsTable({ | ||
evaluations, | ||
}: { | ||
evaluations: EvaluationDto[] | ||
}) { | ||
const navigate = useNavigate() | ||
const { project } = useCurrentProject() | ||
const { commit } = useCurrentCommit() | ||
const document = useCurrentDocument() | ||
return ( | ||
<Table className='table-auto'> | ||
<TableHeader className='sticky top-0 z-10'> | ||
<TableRow> | ||
<TableHead>Name</TableHead> | ||
<TableHead>Description</TableHead> | ||
<TableHead>Actions</TableHead> | ||
</TableRow> | ||
</TableHeader> | ||
<TableBody className='max-h-full overflow-y-auto'> | ||
{evaluations.map((evaluation) => ( | ||
<TableRow | ||
key={evaluation.id} | ||
className='cursor-pointer border-b-[0.5px] h-12 max-h-12 border-border' | ||
onClick={() => | ||
navigate.push( | ||
ROUTES.projects | ||
.detail({ id: project.id }) | ||
.commits.detail({ uuid: commit.uuid }) | ||
.documents.detail({ uuid: document.documentUuid }) | ||
.evaluations.detail(evaluation.uuid).dashboard.root, | ||
) | ||
} | ||
> | ||
<TableCell> | ||
<Text.H4 noWrap>{evaluation.name}</Text.H4> | ||
</TableCell> | ||
<TableCell> | ||
<Text.H4>{evaluation.description}</Text.H4> | ||
</TableCell> | ||
<TableCell onClick={(e) => e.stopPropagation()}> | ||
<Link | ||
href={ | ||
ROUTES.projects | ||
.detail({ id: project.id }) | ||
.commits.detail({ uuid: commit.uuid }) | ||
.documents.detail({ uuid: document.documentUuid }) | ||
.evaluations.detail(evaluation.uuid).dashboard.destroy | ||
} | ||
> | ||
<Icon name='trash' /> | ||
</Link> | ||
</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
) | ||
} |
54 changes: 54 additions & 0 deletions
54
...rsions/[commitUuid]/documents/[documentUuid]/evaluations/dashboard/_components/Layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
'use client' | ||
|
||
import { EvaluationDto } from '@latitude-data/core/browser' | ||
import { | ||
TableBlankSlate, | ||
useCurrentCommit, | ||
useCurrentDocument, | ||
useCurrentProject, | ||
} from '@latitude-data/web-ui' | ||
import { ROUTES } from '$/services/routes' | ||
import useEvaluations from '$/stores/evaluations' | ||
import Link from 'next/link' | ||
|
||
import BatchEvaluationsTable from './BatchEvaluationsTable' | ||
|
||
export default function EvaluationsLayoutClient({ | ||
evaluations: fallbackData, | ||
}: { | ||
evaluations: EvaluationDto[] | ||
}) { | ||
const { project } = useCurrentProject() | ||
const { commit } = useCurrentCommit() | ||
const document = useCurrentDocument() | ||
const { data: evaluations } = useEvaluations({ | ||
fallbackData, | ||
params: { documentUuid: document.documentUuid }, | ||
}) | ||
|
||
const href = ROUTES.projects | ||
.detail({ id: project.id }) | ||
.commits.detail({ uuid: commit.uuid }) | ||
.documents.detail({ uuid: document.documentUuid }).evaluations.dashboard | ||
.connect.root | ||
|
||
return ( | ||
<> | ||
{evaluations.length > 0 && ( | ||
<BatchEvaluationsTable evaluations={evaluations} /> | ||
)} | ||
{evaluations.length === 0 && ( | ||
<TableBlankSlate | ||
description='There are no evaluations connected to this prompt yet. Connect one to start evaluating the prompt.' | ||
link={ | ||
<Link href={href}> | ||
<TableBlankSlate.Button> | ||
Connect your first evaluation | ||
</TableBlankSlate.Button> | ||
</Link> | ||
} | ||
/> | ||
)} | ||
</> | ||
) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...[projectId]/versions/[commitUuid]/documents/[documentUuid]/evaluations/dashboard/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function EvaluationsDashboardPage() { | ||
return null // --> layout.tsx | ||
} |
16 changes: 14 additions & 2 deletions
16
.../projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/evaluations/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
export default function EvaluationsPage() { | ||
return null // --> layout.tsx | ||
import { ROUTES } from '$/services/routes' | ||
import { redirect } from 'next/navigation' | ||
|
||
export default function EvaluationsPage({ | ||
params: { projectId, documentUuid, commitUuid }, | ||
}: { | ||
params: { projectId: string; documentUuid: string; commitUuid: string } | ||
}) { | ||
redirect( | ||
ROUTES.projects | ||
.detail({ id: Number(projectId) }) | ||
.commits.detail({ uuid: commitUuid }) | ||
.documents.detail({ uuid: documentUuid }).evaluations.dashboard.root, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use client' | ||
|
||
import { createContext, ReactNode, useContext } from 'react' | ||
|
||
import { DocumentVersion } from '@latitude-data/core/browser' | ||
|
||
const DocumentContext = createContext<DocumentVersion | undefined>(undefined) | ||
|
||
const DocumentVersionProvider = ({ | ||
children, | ||
document, | ||
}: { | ||
children: ReactNode | ||
document: DocumentVersion | ||
}) => { | ||
return ( | ||
<DocumentContext.Provider value={document}> | ||
{children} | ||
</DocumentContext.Provider> | ||
) | ||
} | ||
|
||
const useCurrentDocument = () => { | ||
const context = useContext(DocumentContext) | ||
if (!context) { | ||
throw new Error( | ||
'useCurrentDocument must be used within a DocumentVersionProvider', | ||
) | ||
} | ||
return context | ||
} | ||
|
||
export { DocumentVersionProvider, useCurrentDocument } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './CommitProvider' | ||
export * from './ProjectProvider' | ||
export * from './SessionProvider' | ||
export * from './DocumentProvider' |