Skip to content

Commit bdab90b

Browse files
authored
revamp repo page (#220)
* wip repo table * new repo page * add indicator for when feedback is applied in repo page * add repo button * fetch connection data in one query * fix styling
1 parent 7685d9c commit bdab90b

File tree

11 files changed

+430
-166
lines changed

11 files changed

+430
-166
lines changed

packages/web/src/actions.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export const completeOnboarding = async (domain: string): Promise<{ success: boo
147147
}
148148
})
149149
);
150-
150+
151151
export const getSecrets = (domain: string): Promise<{ createdAt: Date; key: string; }[] | ServiceError> =>
152152
withAuth((session) =>
153153
withOrgMembership(session, domain, async ({ orgId }) => {
@@ -321,7 +321,11 @@ export const getRepos = async (domain: string, filter: { status?: RepoIndexingSt
321321
} : {}),
322322
},
323323
include: {
324-
connections: true,
324+
connections: {
325+
include: {
326+
connection: true,
327+
}
328+
}
325329
}
326330
});
327331

@@ -330,7 +334,10 @@ export const getRepos = async (domain: string, filter: { status?: RepoIndexingSt
330334
repoId: repo.id,
331335
repoName: repo.name,
332336
repoCloneUrl: repo.cloneUrl,
333-
linkedConnections: repo.connections.map((connection) => connection.connectionId),
337+
linkedConnections: repo.connections.map(({ connection }) => ({
338+
id: connection.id,
339+
name: connection.name,
340+
})),
334341
imageUrl: repo.imageUrl ?? undefined,
335342
indexedAt: repo.indexedAt ?? undefined,
336343
repoIndexingStatus: repo.repoIndexingStatus,
@@ -883,7 +890,7 @@ export const createOnboardingSubscription = async (domain: string) =>
883890
save_default_payment_method: 'on_subscription',
884891
},
885892
});
886-
893+
887894
if (!subscription) {
888895
return {
889896
statusCode: StatusCodes.INTERNAL_SERVER_ERROR,

packages/web/src/app/[domain]/components/connectionCreationForms/sharedConnectionCreationForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default function SharedConnectionCreationForm<T>({
6767
return checkIfSecretExists(secretKey, domain);
6868
}, { message: "Secret not found" }),
6969
});
70-
}, [schema, domain]);
70+
}, [schema, domain, additionalConfigValidation]);
7171

7272
const form = useForm<z.infer<typeof formSchema>>({
7373
resolver: zodResolver(formSchema),

packages/web/src/app/[domain]/components/errorNavIndicator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const ErrorNavIndicator = () => {
9797
.slice(0, 10)
9898
.map(repo => (
9999
// Link to the first connection for the repo
100-
<Link key={repo.repoId} href={`/${domain}/connections/${repo.linkedConnections[0]}`} onClick={() => captureEvent('wa_error_nav_job_pressed', {})}>
100+
<Link key={repo.repoId} href={`/${domain}/connections/${repo.linkedConnections[0].id}`} onClick={() => captureEvent('wa_error_nav_job_pressed', {})}>
101101
<div className="flex items-center justify-between px-3 py-2
102102
bg-red-50 dark:bg-red-900/20 rounded-md
103103
border border-red-200/50 dark:border-red-800/50

packages/web/src/app/[domain]/components/progressNavIndicator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const ProgressNavIndicator = () => {
5050
<div className="flex flex-col gap-2 pl-4">
5151
{inProgressRepos.slice(0, 10).map(item => (
5252
// Link to the first connection for the repo
53-
<Link key={item.repoId} href={`/${domain}/connections/${item.linkedConnections[0]}`} onClick={() => captureEvent('wa_progress_nav_job_pressed', {})}>
53+
<Link key={item.repoId} href={`/${domain}/connections/${item.linkedConnections[0].id}`} onClick={() => captureEvent('wa_progress_nav_job_pressed', {})}>
5454
<div className="flex items-center gap-2 px-3 py-2 bg-green-50 dark:bg-green-900/20
5555
rounded-md text-sm text-green-700 dark:text-green-300
5656
border border-green-200/50 dark:border-green-800/50

packages/web/src/app/[domain]/connections/[id]/components/repoListItem.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,19 @@ export const RepoListItem = ({
4949
className="flex flex-row items-center p-4 border rounded-lg bg-background justify-between"
5050
>
5151
<div className="flex flex-row items-center gap-2">
52-
<Image
53-
src={imageUrl ?? ""}
54-
alt={name}
55-
width={40}
56-
height={40}
57-
className="rounded-full"
58-
/>
52+
{imageUrl ? (
53+
<Image
54+
src={imageUrl}
55+
alt={name}
56+
width={32}
57+
height={32}
58+
className="object-cover"
59+
/>
60+
) : (
61+
<div className="h-8 w-8 flex items-center justify-center bg-muted text-xs font-medium uppercase text-muted-foreground rounded-md">
62+
{name.charAt(0)}
63+
</div>
64+
)}
5965
<p className="font-medium">{name}</p>
6066
</div>
6167
<div className="flex flex-row items-center gap-4">
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"use client"
2+
3+
import { Button } from "@/components/ui/button"
4+
import { PlusCircle } from "lucide-react"
5+
import {
6+
Dialog,
7+
DialogContent,
8+
DialogHeader,
9+
DialogTitle,
10+
DialogDescription,
11+
DialogClose,
12+
DialogFooter,
13+
} from "@/components/ui/dialog"
14+
import { useState } from "react"
15+
import { ConnectionList } from "../connections/components/connectionList"
16+
import { useDomain } from "@/hooks/useDomain"
17+
import Link from "next/link";
18+
19+
export function AddRepoButton() {
20+
const [isOpen, setIsOpen] = useState(false)
21+
const domain = useDomain()
22+
23+
return (
24+
<>
25+
<Button
26+
onClick={() => setIsOpen(true)}
27+
variant="ghost"
28+
size="icon"
29+
className="h-8 w-8 ml-2 text-muted-foreground hover:text-foreground transition-colors"
30+
>
31+
<PlusCircle className="h-4 w-4" />
32+
</Button>
33+
34+
<Dialog open={isOpen} onOpenChange={setIsOpen}>
35+
<DialogContent className="sm:max-w-[800px] max-h-[90vh] flex flex-col p-0 gap-0 overflow-hidden">
36+
<DialogHeader className="px-6 py-4 border-b">
37+
<DialogTitle className="text-xl font-semibold">Add a New Repository</DialogTitle>
38+
<DialogDescription className="text-sm text-muted-foreground mt-1">
39+
Repositories are added to Sourcebot using <span className="text-primary">connections</span>. To add a new repo, add it to an existing connection or create a new one.
40+
</DialogDescription>
41+
</DialogHeader>
42+
<div className="flex-1 overflow-y-auto p-6">
43+
<ConnectionList className="w-full" />
44+
</div>
45+
<DialogFooter className="flex justify-between items-center border-t p-4 px-6">
46+
<Button asChild variant="default" className="bg-primary hover:bg-primary/90">
47+
<Link href={`/${domain}/connections`}>Add new connection</Link>
48+
</Button>
49+
<DialogClose asChild>
50+
<Button variant="outline">Close</Button>
51+
</DialogClose>
52+
</DialogFooter>
53+
</DialogContent>
54+
</Dialog>
55+
</>
56+
)
57+
}

0 commit comments

Comments
 (0)