Skip to content

Commit c1f6132

Browse files
Add connection table
1 parent 2f6f2ac commit c1f6132

File tree

17 files changed

+1036
-142
lines changed

17 files changed

+1036
-142
lines changed

packages/web/src/app/[domain]/chat/components/demoCards.tsx

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Badge } from "@/components/ui/badge";
77
import { Card } from "@/components/ui/card";
88
import { CardContent } from "@/components/ui/card";
99
import { DemoExamples, DemoSearchExample, DemoSearchScope } from "@/types";
10-
import { cn, getCodeHostIcon } from "@/lib/utils";
10+
import { cn, CodeHostType, getCodeHostIcon } from "@/lib/utils";
1111
import useCaptureEvent from "@/hooks/useCaptureEvent";
1212
import { SearchScopeInfoCard } from "@/features/chat/components/chatBox/searchScopeInfoCard";
1313

@@ -41,25 +41,23 @@ export const DemoCards = ({
4141
}
4242

4343
if (searchScope.codeHostType) {
44-
const codeHostIcon = getCodeHostIcon(searchScope.codeHostType);
45-
if (codeHostIcon) {
46-
// When selected, icons need to match the inverted badge colors
47-
// In light mode selected: light icon on dark bg (invert)
48-
// In dark mode selected: dark icon on light bg (no invert, override dark:invert)
49-
const selectedIconClass = isSelected
50-
? "invert dark:invert-0"
51-
: codeHostIcon.className;
44+
const codeHostIcon = getCodeHostIcon(searchScope.codeHostType as CodeHostType);
45+
// When selected, icons need to match the inverted badge colors
46+
// In light mode selected: light icon on dark bg (invert)
47+
// In dark mode selected: dark icon on light bg (no invert, override dark:invert)
48+
const selectedIconClass = isSelected
49+
? "invert dark:invert-0"
50+
: codeHostIcon.className;
5251

53-
return (
54-
<Image
55-
src={codeHostIcon.src}
56-
alt={`${searchScope.codeHostType} icon`}
57-
width={size}
58-
height={size}
59-
className={cn(sizeClass, selectedIconClass)}
60-
/>
61-
);
62-
}
52+
return (
53+
<Image
54+
src={codeHostIcon.src}
55+
alt={`${searchScope.codeHostType} icon`}
56+
width={size}
57+
height={size}
58+
className={cn(sizeClass, selectedIconClass)}
59+
/>
60+
);
6361
}
6462

6563
return <Code className={cn(sizeClass, colorClass)} />;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { cn } from "@/lib/utils";
2+
import { ArrowLeft } from "lucide-react"
3+
import Link from "next/link"
4+
5+
interface BackButtonProps {
6+
href: string;
7+
name: string;
8+
className?: string;
9+
}
10+
11+
export function BackButton({ href, name, className }: BackButtonProps) {
12+
return (
13+
<Link href={href} className={cn("inline-flex items-center text-link transition-colors group", className)}>
14+
<span className="inline-flex items-center gap-1.5 border-b border-transparent group-hover:border-link pb-0.5">
15+
<ArrowLeft className="h-4 w-4" />
16+
<span>{name}</span>
17+
</span>
18+
</Link>
19+
)
20+
}

packages/web/src/app/[domain]/repos/[id]/page.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ import { Button } from "@/components/ui/button"
44
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
55
import { Skeleton } from "@/components/ui/skeleton"
66
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"
7+
import { env } from "@/env.mjs"
78
import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants"
89
import { ServiceErrorException } from "@/lib/serviceError"
910
import { cn, getCodeHostInfoForRepo, isServiceError } from "@/lib/utils"
1011
import { withOptionalAuthV2 } from "@/withAuthV2"
11-
import { ChevronLeft, ExternalLink, Info } from "lucide-react"
12+
import { getConfigSettings, repoMetadataSchema } from "@sourcebot/shared"
13+
import { ExternalLink, Info } from "lucide-react"
1214
import Image from "next/image"
1315
import Link from "next/link"
1416
import { notFound } from "next/navigation"
1517
import { Suspense } from "react"
16-
import { RepoJobsTable } from "../components/repoJobsTable"
17-
import { getConfigSettings } from "@sourcebot/shared"
18-
import { env } from "@/env.mjs"
18+
import { BackButton } from "../../components/backButton"
1919
import { DisplayDate } from "../../components/DisplayDate"
2020
import { RepoBranchesTable } from "../components/repoBranchesTable"
21-
import { repoMetadataSchema } from "@sourcebot/shared"
21+
import { RepoJobsTable } from "../components/repoJobsTable"
2222

2323
export default async function RepoDetailPage({ params }: { params: Promise<{ id: string }> }) {
2424
const { id } = await params
@@ -52,14 +52,13 @@ export default async function RepoDetailPage({ params }: { params: Promise<{ id:
5252
const repoMetadata = repoMetadataSchema.parse(repo.metadata);
5353

5454
return (
55-
<div className="container mx-auto">
55+
<>
5656
<div className="mb-6">
57-
<Button variant="ghost" asChild className="mb-4">
58-
<Link href={`/${SINGLE_TENANT_ORG_DOMAIN}/repos`}>
59-
<ChevronLeft className="mr-2 h-4 w-4" />
60-
Back to repositories
61-
</Link>
62-
</Button>
57+
<BackButton
58+
href={`/${SINGLE_TENANT_ORG_DOMAIN}/repos`}
59+
name="Back to repositories"
60+
className="mb-2"
61+
/>
6362

6463
<div className="flex items-start justify-between">
6564
<div>
@@ -168,7 +167,7 @@ export default async function RepoDetailPage({ params }: { params: Promise<{ id:
168167

169168
<Card>
170169
<CardHeader>
171-
<CardTitle>Indexing Jobs</CardTitle>
170+
<CardTitle>Indexing History</CardTitle>
172171
<CardDescription>History of all indexing and cleanup jobs for this repository.</CardDescription>
173172
</CardHeader>
174173
<CardContent>
@@ -177,16 +176,17 @@ export default async function RepoDetailPage({ params }: { params: Promise<{ id:
177176
</Suspense>
178177
</CardContent>
179178
</Card>
180-
</div>
179+
</>
181180
)
182181
}
183182

184183
const getRepoWithJobs = async (repoId: number) => sew(() =>
185-
withOptionalAuthV2(async ({ prisma }) => {
184+
withOptionalAuthV2(async ({ prisma, org }) => {
186185

187186
const repo = await prisma.repo.findUnique({
188187
where: {
189188
id: repoId,
189+
orgId: org.id,
190190
},
191191
include: {
192192
jobs: {

packages/web/src/app/[domain]/repos/components/reposTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ export const ReposTable = ({ data }: { data: Repo[] }) => {
331331
</Button>
332332
</div>
333333
<div className="rounded-md border">
334-
<Table style={{ tableLayout: 'fixed', width: '100%' }}>
334+
<Table style={{ width: '100%' }}>
335335
<TableHeader>
336336
{table.getHeaderGroups().map((headerGroup) => (
337337
<TableRow key={headerGroup.id}>

packages/web/src/app/[domain]/repos/layout.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ export default async function Layout(
1616
<div className="min-h-screen flex flex-col">
1717
<NavigationMenu domain={domain} />
1818
<main className="flex-grow flex justify-center p-4 bg-backgroundSecondary relative">
19-
<div className="w-full max-w-6xl rounded-lg p-6">{children}</div>
19+
<div className="w-full max-w-6xl rounded-lg p-6">
20+
<div className="container mx-auto">
21+
{children}
22+
</div>
23+
</div>
2024
</main>
2125
</div>
2226
)

packages/web/src/app/[domain]/repos/page.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default async function ReposPage() {
1212
}
1313

1414
return (
15-
<div className="container mx-auto">
15+
<>
1616
<div className="mb-6">
1717
<h1 className="text-3xl font-semibold">Repositories</h1>
1818
<p className="text-muted-foreground mt-2">View and manage your code repositories and their indexing status.</p>
@@ -31,12 +31,12 @@ export default async function ReposPage() {
3131
codeHostType: repo.external_codeHostType,
3232
indexedCommitHash: repo.indexedCommitHash,
3333
}))} />
34-
</div>
34+
</>
3535
)
3636
}
3737

3838
const getReposWithLatestJob = async () => sew(() =>
39-
withOptionalAuthV2(async ({ prisma }) => {
39+
withOptionalAuthV2(async ({ prisma, org }) => {
4040
const repos = await prisma.repo.findMany({
4141
include: {
4242
jobs: {
@@ -48,6 +48,9 @@ const getReposWithLatestJob = async () => sew(() =>
4848
},
4949
orderBy: {
5050
name: 'asc'
51+
},
52+
where: {
53+
orgId: org.id,
5154
}
5255
});
5356
return repos;

packages/web/src/app/[domain]/settings/components/header.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

packages/web/src/app/[domain]/settings/components/sidebar-nav.tsx

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,46 @@ import { usePathname } from "next/navigation"
66
import { cn } from "@/lib/utils"
77
import { buttonVariants } from "@/components/ui/button"
88

9-
interface SidebarNavProps extends React.HTMLAttributes<HTMLElement> {
10-
items: {
9+
export type SidebarNavItem = {
1110
href: string
11+
hrefRegex?: string
1212
title: React.ReactNode
13-
}[]
13+
}
14+
15+
interface SidebarNavProps extends React.HTMLAttributes<HTMLElement> {
16+
items: SidebarNavItem[]
1417
}
1518

1619
export function SidebarNav({ className, items, ...props }: SidebarNavProps) {
17-
const pathname = usePathname()
20+
const pathname = usePathname()
1821

19-
return (
20-
<nav
21-
className={cn(
22-
"flex flex-col space-x-2 lg:space-x-0 lg:space-y-1",
23-
className
24-
)}
25-
{...props}
26-
>
27-
{items.map((item) => (
28-
<Link
29-
key={item.href}
30-
href={item.href}
31-
className={cn(
32-
buttonVariants({ variant: "ghost" }),
33-
pathname === item.href
34-
? "bg-muted hover:bg-muted"
35-
: "hover:bg-transparent hover:underline",
36-
"justify-start"
37-
)}
22+
return (
23+
<nav
24+
className={cn(
25+
"flex flex-col space-x-2 lg:space-x-0 lg:space-y-1",
26+
className
27+
)}
28+
{...props}
3829
>
39-
{item.title}
40-
</Link>
41-
))}
42-
</nav>
43-
)
30+
{items.map((item) => {
31+
const isActive = item.hrefRegex ? new RegExp(item.hrefRegex).test(pathname) : pathname === item.href;
32+
33+
return (
34+
<Link
35+
key={item.href}
36+
href={item.href}
37+
className={cn(
38+
buttonVariants({ variant: "ghost" }),
39+
isActive
40+
? "bg-muted hover:bg-muted"
41+
: "hover:bg-transparent hover:underline",
42+
"justify-start"
43+
)}
44+
>
45+
{item.title}
46+
</Link>
47+
)
48+
})}
49+
</nav>
50+
)
4451
}

0 commit comments

Comments
 (0)