Skip to content

Commit

Permalink
Cleaner header breadcrumb
Browse files Browse the repository at this point in the history
  • Loading branch information
csansoon committed Oct 21, 2024
1 parent 569b5ce commit 0275a59
Show file tree
Hide file tree
Showing 35 changed files with 573 additions and 449 deletions.
77 changes: 30 additions & 47 deletions apps/web/src/app/(private)/dashboard/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@ import {
Container,
TableBlankSlate,
TableWithHeader,
Text,
} from '@latitude-data/web-ui'
import { AppTabs } from '$/app/(private)/AppTabs'
import { AppLayout } from '$/components/layouts'
import { getCurrentUser } from '$/services/auth/getCurrentUser'
import { getSession } from '$/services/auth/getSession'
import { ROUTES } from '$/services/routes'
import Link from 'next/link'
import { redirect } from 'next/navigation'

import { getActiveProjectsCached } from '../_data-access'
import { NAV_LINKS } from '../_lib/constants'
import { ProjectsTable } from './_components/ProjectsTable'

export default async function DashboardLayout({
Expand All @@ -26,52 +23,38 @@ export default async function DashboardLayout({
const data = await getSession()
if (!data.session) return redirect(ROUTES.auth.login)

const { workspace, user } = await getCurrentUser()
const { workspace } = await getCurrentUser()
const projects = await getActiveProjectsCached({ workspaceId: workspace.id })
const breadcrumbs = [
{
name: workspace.name,
},
{
name: <Text.H5M>Projects</Text.H5M>,
},
]

return (
<AppLayout
navigationLinks={NAV_LINKS}
currentUser={user}
breadcrumbs={breadcrumbs}
>
<Container>
<AppTabs />
{children}
<TableWithHeader
title='Projects'
actions={
<Link href={ROUTES.dashboard.projects.new.root}>
<TableWithHeader.Button>Add project</TableWithHeader.Button>
</Link>
}
table={
<>
{projects.length > 0 && <ProjectsTable projects={projects} />}
{projects.length === 0 && (
<TableBlankSlate
description='There are no projects yet. Create one to start adding your prompts.'
link={
<Link href={ROUTES.dashboard.projects.new.root}>
<TableBlankSlate.Button>
Create your first project
</TableBlankSlate.Button>
</Link>
}
/>
)}
</>
}
/>
</Container>
</AppLayout>
<Container>
<AppTabs />
{children}
<TableWithHeader
title='Projects'
actions={
<Link href={ROUTES.dashboard.projects.new.root}>
<TableWithHeader.Button>Add project</TableWithHeader.Button>
</Link>
}
table={
<>
{projects.length > 0 && <ProjectsTable projects={projects} />}
{projects.length === 0 && (
<TableBlankSlate
description='There are no projects yet. Create one to start adding your prompts.'
link={
<Link href={ROUTES.dashboard.projects.new.root}>
<TableBlankSlate.Button>
Create your first project
</TableBlankSlate.Button>
</Link>
}
/>
)}
</>
}
/>
</Container>
)
}
58 changes: 20 additions & 38 deletions apps/web/src/app/(private)/datasets/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,57 +1,39 @@
import { ReactNode } from 'react'

import { DatasetsRepository } from '@latitude-data/core/repositories'
import { Container, TableWithHeader, Text } from '@latitude-data/web-ui'
import { Container, TableWithHeader } from '@latitude-data/web-ui'
import { AppTabs } from '$/app/(private)/AppTabs'
import { DatasetsTable } from '$/app/(private)/datasets/_components/DatasetsTable'
import { AppLayout } from '$/components/layouts'
import { getCurrentUser } from '$/services/auth/getCurrentUser'
import { ROUTES } from '$/services/routes'
import Link from 'next/link'

import { NAV_LINKS } from '../_lib/constants'

export default async function DatasetsList({
children,
}: Readonly<{
children: ReactNode
}>) {
const { workspace, user } = await getCurrentUser()
const { workspace } = await getCurrentUser()
const scope = new DatasetsRepository(workspace.id)
const datasets = await scope.findAll().then((r) => r.unwrap())
return (
<AppLayout
navigationLinks={NAV_LINKS}
currentUser={user}
breadcrumbs={[
{
name: workspace.name,
},
{
name: <Text.H5M>Datasets</Text.H5M>,
},
]}
>
<Container>
<AppTabs />
{children}
<TableWithHeader
title='Datasets'
actions={
<div className='flex flex-row items-center gap-2'>
<Link href={ROUTES.datasets.generate.root}>
<TableWithHeader.Button>
Generate dataset
</TableWithHeader.Button>
</Link>
<Link href={ROUTES.datasets.new.root}>
<TableWithHeader.Button>Upload dataset</TableWithHeader.Button>
</Link>
</div>
}
table={<DatasetsTable datasets={datasets} />}
/>
</Container>
</AppLayout>
<Container>
<AppTabs />
{children}
<TableWithHeader
title='Datasets'
actions={
<div className='flex flex-row items-center gap-2'>
<Link href={ROUTES.datasets.generate.root}>
<TableWithHeader.Button>Generate dataset</TableWithHeader.Button>
</Link>
<Link href={ROUTES.datasets.new.root}>
<TableWithHeader.Button>Upload dataset</TableWithHeader.Button>
</Link>
</div>
}
table={<DatasetsTable datasets={datasets} />}
/>
</Container>
)
}
21 changes: 4 additions & 17 deletions apps/web/src/app/(private)/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { useEffect } from 'react'

import { ErrorComponent, useSession } from '@latitude-data/web-ui/browser'
import * as Sentry from '@sentry/nextjs'
import { NAV_LINKS } from '$/app/(private)/_lib/constants'
import { AppLayout } from '$/components/layouts'

export default function Error({
error,
Expand All @@ -20,20 +18,9 @@ export default function Error({
}, [error])

return (
<AppLayout
currentUser={session.currentUser}
breadcrumbs={[
{
name: session.workspace.name,
},
{ name: 'Error' },
]}
navigationLinks={NAV_LINKS}
>
<ErrorComponent
type='red'
message='Something went wrong. Please, try again and if the error persists contact us.'
/>
</AppLayout>
<ErrorComponent
type='red'
message='Something went wrong. Please, try again and if the error persists contact us.'
/>
)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { ReactNode } from 'react'

import { getFreeRuns } from '@latitude-data/core/services/freeRunsManager/index'
import { Text } from '@latitude-data/web-ui'
import {
getEvaluationByUuidCached,
getProviderApiKeysCached,
} from '$/app/(private)/_data-access'
import { NAV_LINKS } from '$/app/(private)/_lib/constants'
import BreadcrumbLink from '$/components/BreadcrumbLink'
import { AppLayout } from '$/components/layouts'
import providerApiKeyPresenter from '$/presenters/providerApiKeyPresenter'
import { getCurrentUser } from '$/services/auth/getCurrentUser'
import { ROUTES } from '$/services/routes'

import EvaluationEditorLayout from './_components/EvaluationEditorLayout'

Expand All @@ -25,37 +20,17 @@ export default async function DocumentPage({
const { workspace } = await getCurrentUser()
const evaluationUuid = params.evaluationUuid
const evaluation = await getEvaluationByUuidCached(evaluationUuid)
const session = await getCurrentUser()
const providerApiKeys = await getProviderApiKeysCached()
const freeRunsCount = await getFreeRuns(workspace.id)

return (
<AppLayout
scrollable={false}
navigationLinks={NAV_LINKS}
currentUser={session.user}
breadcrumbs={[
{
name: session.workspace.name,
},
{
name: (
<BreadcrumbLink href={ROUTES.evaluations.root} name='Evaluations' />
),
},
{
name: <Text.H5M>{evaluation.name}</Text.H5M>,
},
]}
<EvaluationEditorLayout
evaluation={evaluation}
providerApiKeys={providerApiKeys.map(providerApiKeyPresenter)}
evaluationUuid={evaluationUuid}
freeRunsCount={freeRunsCount ? Number(freeRunsCount) : undefined}
>
<EvaluationEditorLayout
evaluation={evaluation}
providerApiKeys={providerApiKeys.map(providerApiKeyPresenter)}
evaluationUuid={evaluationUuid}
freeRunsCount={freeRunsCount ? Number(freeRunsCount) : undefined}
>
{children}
</EvaluationEditorLayout>
</AppLayout>
{children}
</EvaluationEditorLayout>
)
}
21 changes: 2 additions & 19 deletions apps/web/src/app/(private)/evaluations/(root)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,19 @@
import { ReactNode } from 'react'

import { Text } from '@latitude-data/web-ui'
import { getEvaluationTemplatesCached } from '$/app/(private)/_data-access'
import Evaluations from '$/app/(private)/evaluations/_components/Evaluations'
import { AppLayout } from '$/components/layouts'
import { getCurrentUser } from '$/services/auth/getCurrentUser'

import { NAV_LINKS } from '../../_lib/constants'

export default async function EvaluationsLayout({
children,
}: {
children: ReactNode
}) {
const session = await getCurrentUser()
const evaluationTemplates = await getEvaluationTemplatesCached()

return (
<AppLayout
navigationLinks={NAV_LINKS}
currentUser={session.user}
breadcrumbs={[
{
name: session.workspace.name,
},
{
name: <Text.H5M>Evaluations</Text.H5M>,
},
]}
>
<>
<Evaluations evaluationTemplates={evaluationTemplates} />
{children}
</AppLayout>
</>
)
}
6 changes: 5 additions & 1 deletion apps/web/src/app/(private)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ReactNode } from 'react'
import { SessionProvider } from '@latitude-data/web-ui/browser'
import { createSupportUserIdentity } from '$/app/(private)/_lib/createSupportUserIdentity'
import { SupportChat } from '$/components/IntercomSupportChat'
import { AppLayout } from '$/components/layouts'
import {
LatitudeWebsocketsProvider,
SocketIOProvider,
Expand All @@ -14,6 +15,7 @@ import { ROUTES } from '$/services/routes'
import { redirect } from 'next/navigation'

import { CSPostHogProvider, IdentifyUser } from '../providers'
import { NAV_LINKS } from './_lib/constants'

export default async function PrivateLayout({
children,
Expand All @@ -33,7 +35,9 @@ export default async function PrivateLayout({
<SocketIOProvider>
<SessionProvider currentUser={user} workspace={workspace}>
<LatitudeWebsocketsProvider socketServer={env.WEBSOCKETS_SERVER}>
{children}
<AppLayout currentUser={user} navigationLinks={NAV_LINKS}>
{children}
</AppLayout>
</LatitudeWebsocketsProvider>
</SessionProvider>
</SocketIOProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
DocumentVersion,
} from '@latitude-data/core/browser'
import { Text } from '@latitude-data/web-ui'
import useCommits from '$/stores/commitsStore'
import { useCommits } from '$/stores/commitsStore'

import { CommitItem, CommitItemSkeleton, SimpleUser } from './CommitItem'
import { CommitItemsWrapper } from './CommitItemsWrapper'
Expand Down
Loading

0 comments on commit 0275a59

Please sign in to comment.