-
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.
Create first project when setup is done + app layout header
- Loading branch information
1 parent
393a84f
commit b510b7c
Showing
64 changed files
with
1,426 additions
and
241 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
41 changes: 41 additions & 0 deletions
41
apps/web/src/app/(private)/_components/CommitDetailPage/BreadcrumpBadge/index.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,41 @@ | ||
'use client' | ||
|
||
import { useCallback } from 'react' | ||
|
||
import { HEAD_COMMIT } from '@latitude-data/core/browser' | ||
import { Badge, Icons, Text, Tooltip } from '@latitude-data/web-ui' | ||
|
||
export default function BreadcrumpCommit({ | ||
uuid: fullUuid, | ||
title, | ||
isLatest, | ||
}: { | ||
uuid: string | ||
title?: string | null | ||
isLatest: boolean | ||
}) { | ||
const [uuid] = isLatest ? [HEAD_COMMIT] : fullUuid.split('-') | ||
const onCopy = useCallback(() => { | ||
navigator.clipboard.writeText(fullUuid) | ||
}, [fullUuid]) | ||
return ( | ||
<div className='flex flex-row items-center space-x-2'> | ||
<Text.H5M>{title ?? 'Untitled'}</Text.H5M> | ||
<Tooltip | ||
side='right' | ||
align='center' | ||
trigger={ | ||
<div | ||
onClick={onCopy} | ||
className='cursor-pointer flex flex-row items-center gap-x-1' | ||
> | ||
<Badge variant={isLatest ? 'accent' : 'secondary'}>{uuid}</Badge> | ||
<Icons.clipboard className='w-4 h-4 text-muted-foreground' /> | ||
</div> | ||
} | ||
> | ||
<Text.H6 color='white'>Click to copy: {fullUuid}</Text.H6> | ||
</Tooltip> | ||
</div> | ||
) | ||
} |
21 changes: 21 additions & 0 deletions
21
apps/web/src/app/(private)/_components/CommitDetailPage/ClientPushNavigation/index.ts
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,21 @@ | ||
'use client' | ||
|
||
import { useEffect } from 'react' | ||
|
||
export default function ClientPushNavigation({ | ||
url, | ||
}: { | ||
url: string | undefined | ||
}) { | ||
useEffect(() => { | ||
if (!url) return | ||
|
||
window.history.replaceState( | ||
{ ...window.history.state, as: url, url }, | ||
'', | ||
url, | ||
) | ||
}, [url]) | ||
|
||
return null | ||
} |
46 changes: 46 additions & 0 deletions
46
apps/web/src/app/(private)/_components/CommitDetailPage/index.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,46 @@ | ||
import { type Commit, type Project } from '@latitude-data/core' | ||
import { CommitDetail } from '@latitude-data/web-ui' | ||
import BreadcrumpCommit from '$/app/(private)/_components/CommitDetailPage/BreadcrumpBadge' | ||
import ClientPushNavigation from '$/app/(private)/_components/CommitDetailPage/ClientPushNavigation' | ||
import { NAV_LINKS } from '$/app/(private)/_lib/constants' | ||
import { SessionData } from '$/services/auth/getCurrentUser' | ||
|
||
type Props = { | ||
session: SessionData | ||
project: Project | ||
commit: Commit | ||
isLatest?: boolean | ||
url?: string | ||
} | ||
export default function CommitDetailPage({ | ||
session, | ||
project, | ||
commit, | ||
url, | ||
isLatest = true, | ||
}: Props) { | ||
return ( | ||
<> | ||
<ClientPushNavigation url={url} /> | ||
<CommitDetail | ||
appLayout={{ | ||
navigationLinks: NAV_LINKS, | ||
currentUser: session.user, | ||
breadcrumbs: [ | ||
{ name: session.workspace.name }, | ||
{ name: project.name }, | ||
{ | ||
name: ( | ||
<BreadcrumpCommit | ||
uuid={commit.uuid} | ||
title={commit.title} | ||
isLatest={isLatest} | ||
/> | ||
), | ||
}, | ||
], | ||
}} | ||
/> | ||
</> | ||
) | ||
} |
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,36 @@ | ||
import { cache } from 'react' | ||
|
||
import { | ||
findCommit as originalfindCommit, | ||
findProject as originalFindProject, | ||
getFirstProject as originalGetFirstProject, | ||
type FindCommitProps, | ||
type FindProjectProps, | ||
} from '@latitude-data/core' | ||
|
||
export const getFirstProject = cache( | ||
async ({ workspaceId }: { workspaceId: number }) => { | ||
const result = await originalGetFirstProject({ workspaceId }) | ||
const project = result.unwrap() | ||
|
||
return project | ||
}, | ||
) | ||
|
||
export const findProject = cache( | ||
async ({ projectId, workspaceId }: FindProjectProps) => { | ||
const result = await originalFindProject({ projectId, workspaceId }) | ||
const project = result.unwrap() | ||
|
||
return project | ||
}, | ||
) | ||
|
||
export const findCommit = cache( | ||
async ({ isLatest, uuid, projectId }: FindCommitProps) => { | ||
const result = await originalfindCommit({ isLatest, uuid, projectId }) | ||
const commit = result.unwrap() | ||
|
||
return commit | ||
}, | ||
) |
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,12 @@ | ||
import { | ||
LATITUDE_CHANGELOG_URL, | ||
LATITUDE_DOCS_URL, | ||
LATITUDE_HELP_URL, | ||
} from '@latitude-data/core/browser' | ||
|
||
export const NAV_LINKS = [ | ||
{ label: 'Feedback', href: '' }, | ||
{ label: 'Docs', href: LATITUDE_DOCS_URL }, | ||
{ label: 'Help', href: LATITUDE_HELP_URL }, | ||
{ label: 'Changelog', href: LATITUDE_CHANGELOG_URL }, | ||
] |
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,34 @@ | ||
'use client' | ||
|
||
import { useEffect } from 'react' | ||
|
||
import { | ||
AppLayout, | ||
ErrorComponent, | ||
useSession, | ||
} from '@latitude-data/web-ui/browser' | ||
import { NAV_LINKS } from '$/app/(private)/_lib/constants' | ||
|
||
export default function Error({ | ||
error, | ||
}: { | ||
error: Error & { digest?: string } | ||
reset: () => void // Re-render of page | ||
}) { | ||
const session = useSession() | ||
useEffect(() => { | ||
console.error(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> | ||
) | ||
} |
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,25 +1,15 @@ | ||
import { ReactNode } from 'react' | ||
|
||
import Sidebar from '$/components/Sidebar' | ||
import { getSession } from '$/services/auth/getSession' | ||
import { ROUTES } from '$/services/routes' | ||
import { redirect } from 'next/navigation' | ||
import { SessionProvider } from '@latitude-data/web-ui/browser' | ||
import { getCurrentUser } from '$/services/auth/getCurrentUser' | ||
|
||
export default async function PrivateLayout({ | ||
children, | ||
}: { | ||
children: ReactNode | ||
}) { | ||
const data = await getSession() | ||
if (!data.session) { | ||
return redirect(ROUTES.auth.login) | ||
} | ||
}: Readonly<{ children: ReactNode }>) { | ||
const session = await getCurrentUser() | ||
return ( | ||
<main className='flex flex-row w-full'> | ||
<div className='w-[280px]'> | ||
<Sidebar /> | ||
</div> | ||
<div className='flex-1'>{children}</div> | ||
</main> | ||
<SessionProvider currentUser={session.user} workspace={session.workspace}> | ||
{children} | ||
</SessionProvider> | ||
) | ||
} |
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,21 +1,38 @@ | ||
import { FocusHeader, FocusLayout } from '@latitude-data/web-ui' | ||
import DummyLogoutButton from '$/app/(private)/_components/DummyLogoutButton' | ||
import { Commit, NotFoundError, Project } from '@latitude-data/core' | ||
import CommitDetailPage from '$/app/(private)/_components/CommitDetailPage' | ||
import { findCommit, getFirstProject } from '$/app/(private)/_data-access' | ||
import { getCurrentUser, SessionData } from '$/services/auth/getCurrentUser' | ||
import { ROUTES } from '$/services/routes' | ||
import { notFound } from 'next/navigation' | ||
|
||
export const dynamic = 'force-dynamic' | ||
const PROJECT_ROUTE = ROUTES.projects.detail | ||
|
||
export default async function AppRoot() { | ||
let session: SessionData | ||
let project: Project | ||
let commit: Commit | ||
let url | ||
|
||
try { | ||
session = await getCurrentUser() | ||
project = await getFirstProject({ workspaceId: session.workspace.id }) | ||
commit = await findCommit({ isLatest: true, projectId: project.id }) | ||
url = PROJECT_ROUTE({ id: project.id }).commits.latest | ||
} catch (error) { | ||
if (error instanceof NotFoundError) { | ||
return notFound() | ||
} | ||
|
||
throw error | ||
} | ||
|
||
export default async function Home() { | ||
return ( | ||
<FocusLayout | ||
header={ | ||
<FocusHeader | ||
title='Inside the APP 💪' | ||
description="Your're in let's kick those random AI's butts!" | ||
/> | ||
} | ||
> | ||
<div className='flex items-center justify-center'> | ||
<DummyLogoutButton /> | ||
</div> | ||
</FocusLayout> | ||
<CommitDetailPage | ||
session={session} | ||
project={project} | ||
commit={commit} | ||
url={url} | ||
/> | ||
) | ||
} |
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,43 @@ | ||
import { Commit, NotFoundError, Project } from '@latitude-data/core' | ||
import CommitDetailPage from '$/app/(private)/_components/CommitDetailPage' | ||
import { findCommit, findProject } from '$/app/(private)/_data-access' | ||
import { getCurrentUser, SessionData } from '$/services/auth/getCurrentUser' | ||
import { ROUTES } from '$/services/routes' | ||
import { notFound } from 'next/navigation' | ||
|
||
export const dynamic = 'force-dynamic' | ||
const PROJECT_ROUTE = ROUTES.projects.detail | ||
|
||
export type ProjectPageParams = { | ||
params: { id: string } | ||
} | ||
export default async function ProjectPage({ params }: ProjectPageParams) { | ||
let session: SessionData | ||
let project: Project | ||
let commit: Commit | ||
let url | ||
|
||
try { | ||
session = await getCurrentUser() | ||
project = await findProject({ | ||
projectId: params.id, | ||
workspaceId: session.workspace.id, | ||
}) | ||
commit = await findCommit({ isLatest: true, projectId: project.id }) | ||
url = PROJECT_ROUTE({ id: +project.id }).commits.latest | ||
} catch (error) { | ||
if (error instanceof NotFoundError) { | ||
return notFound() | ||
} | ||
throw error | ||
} | ||
|
||
return ( | ||
<CommitDetailPage | ||
session={session} | ||
project={project} | ||
commit={commit} | ||
url={url} | ||
/> | ||
) | ||
} |
49 changes: 49 additions & 0 deletions
49
apps/web/src/app/(private)/projects/[id]/versions/[uuid]/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,49 @@ | ||
import { | ||
Commit, | ||
HEAD_COMMIT, | ||
NotFoundError, | ||
Project, | ||
} from '@latitude-data/core' | ||
import CommitDetailPage from '$/app/(private)/_components/CommitDetailPage' | ||
import { findCommit, findProject } from '$/app/(private)/_data-access' | ||
import { ProjectPageParams } from '$/app/(private)/projects/[id]/page' | ||
import { getCurrentUser, SessionData } from '$/services/auth/getCurrentUser' | ||
import { notFound } from 'next/navigation' | ||
|
||
export const dynamic = 'force-dynamic' | ||
|
||
export type CommitPageParams = { | ||
params: ProjectPageParams['params'] & { uuid: string } | ||
} | ||
export default async function CommitRoot({ params }: CommitPageParams) { | ||
const isLatest = params.uuid === HEAD_COMMIT | ||
let session: SessionData | ||
let project: Project | ||
let commit: Commit | ||
try { | ||
session = await getCurrentUser() | ||
project = await findProject({ | ||
projectId: params.id, | ||
workspaceId: session.workspace.id, | ||
}) | ||
commit = await findCommit({ | ||
isLatest, | ||
uuid: params.uuid, | ||
projectId: project.id, | ||
}) | ||
} catch (error) { | ||
if (error instanceof NotFoundError) { | ||
return notFound() | ||
} | ||
throw error | ||
} | ||
|
||
return ( | ||
<CommitDetailPage | ||
isLatest={isLatest} | ||
session={session} | ||
project={project} | ||
commit={commit} | ||
/> | ||
) | ||
} |
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,5 @@ | ||
import ProjectPage from '$/app/(private)/projects/[id]/page' | ||
|
||
export const dynamic = 'force-dynamic' | ||
|
||
export default ProjectPage |
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,5 @@ | ||
import AppRoot from '$/app/(private)/page' | ||
|
||
export const dynamic = 'force-dynamic' | ||
|
||
export default AppRoot |
Oops, something went wrong.