-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor: projects blankslate and some other minor improvements (#130)
Fixes env boolean value coercion. Fixes minor stuff from the dashboard projects table.
- Loading branch information
Showing
18 changed files
with
216 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use server' | ||
|
||
import { ProjectsRepository } from '@latitude-data/core/repositories' | ||
import { updateProject } from '@latitude-data/core/services/projects/update' | ||
import { z } from 'zod' | ||
|
||
import { authProcedure } from '../procedures' | ||
|
||
export const updateProjectAction = authProcedure | ||
.createServerAction() | ||
.input(z.object({ id: z.number(), name: z.string() })) | ||
.handler(async ({ input, ctx }) => { | ||
const workspace = ctx.workspace | ||
const scope = new ProjectsRepository(workspace.id) | ||
const project = await scope.find(input.id).then((r) => r.unwrap()) | ||
const result = await updateProject(project, { name: input.name }) | ||
|
||
return result.unwrap() | ||
}) |
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
33 changes: 33 additions & 0 deletions
33
...ate)/projects/[projectId]/versions/[commitUuid]/documents/_components/BreadcrumpInput.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,33 @@ | ||
'use client' | ||
|
||
import React from 'react' | ||
|
||
import { Text } from '@latitude-data/web-ui' | ||
import useProjects from '$/stores/projects' | ||
import { EditableText } from 'node_modules/@latitude-data/web-ui/src/ds/molecules/EditableText' | ||
import { useDebouncedCallback } from 'use-debounce' | ||
|
||
export default function BreadcrumpInput({ projectId }: { projectId: number }) { | ||
const { data, update } = useProjects() | ||
const project = data.find((p) => p.id === projectId) | ||
const handleChange = useDebouncedCallback( | ||
(value?: string) => { | ||
if (!value) return | ||
if (!project) return | ||
|
||
update({ id: project.id, name: value }) | ||
}, | ||
250, | ||
{ trailing: true }, | ||
) | ||
|
||
if (!project) return null | ||
|
||
return ( | ||
<EditableText | ||
value={project.name} | ||
handleChange={handleChange} | ||
fallback={(value) => <Text.H5M>{value}</Text.H5M>} | ||
/> | ||
) | ||
} |
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
42 changes: 6 additions & 36 deletions
42
apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/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,44 +1,14 @@ | ||
import { DocumentDetailWrapper } from '@latitude-data/web-ui' | ||
import { | ||
getResizablePanelGroupData, | ||
MIN_SIDEBAR_WIDTH_PX, | ||
ResizableGroups, | ||
} from '$/app/_lib/getResizablePanelGroupData' | ||
import { | ||
findCommitCached, | ||
findProjectCached, | ||
} from '$/app/(private)/_data-access' | ||
import { getCurrentUser } from '$/services/auth/getCurrentUser' | ||
|
||
import Sidebar from './_components/Sidebar' | ||
|
||
export const dynamic = 'force-dynamic' | ||
import { ROUTES } from '$/services/routes' | ||
import { redirect } from 'next/navigation' | ||
|
||
export default async function CommitRoot({ | ||
params, | ||
}: { | ||
params: { projectId: string; commitUuid: string } | ||
}) { | ||
const session = await getCurrentUser() | ||
const project = await findProjectCached({ | ||
projectId: Number(params.projectId), | ||
workspaceId: session.workspace.id, | ||
}) | ||
const commit = await findCommitCached({ | ||
project, | ||
uuid: params.commitUuid, | ||
}) | ||
const resizableId = ResizableGroups.DocumentSidebar | ||
const sidebarWidth = | ||
getResizablePanelGroupData({ group: resizableId }) ?? MIN_SIDEBAR_WIDTH_PX | ||
return ( | ||
<DocumentDetailWrapper | ||
resizableId={resizableId} | ||
sidebarWidth={sidebarWidth} | ||
minSidebarWidth={MIN_SIDEBAR_WIDTH_PX} | ||
sidebar={<Sidebar project={project} commit={commit} />} | ||
> | ||
<div className='p-32'>Main content. Remove Tailwind Styles from here</div> | ||
</DocumentDetailWrapper> | ||
redirect( | ||
ROUTES.projects | ||
.detail({ id: Number(params.projectId) }) | ||
.commits.detail({ uuid: params.commitUuid }).documents.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
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './create' | ||
export * from './destroy' | ||
export * from './update' |
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,22 @@ | ||
import { eq } from 'drizzle-orm' | ||
|
||
import { Project } from '../../browser' | ||
import { database } from '../../client' | ||
import { Result, Transaction } from '../../lib' | ||
import { projects } from '../../schema' | ||
|
||
export async function updateProject( | ||
project: Project, | ||
values: Partial<Project>, | ||
db = database, | ||
) { | ||
return Transaction.call<Project>(async (tx) => { | ||
const updates = await tx | ||
.update(projects) | ||
.set(values) | ||
.where(eq(projects.id, project.id)) | ||
.returning() | ||
|
||
return Result.ok(updates[0]!) | ||
}, db) | ||
} |
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
Oops, something went wrong.