Skip to content

revamp repo page #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions packages/web/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export const completeOnboarding = async (domain: string): Promise<{ success: boo
}
})
);

export const getSecrets = (domain: string): Promise<{ createdAt: Date; key: string; }[] | ServiceError> =>
withAuth((session) =>
withOrgMembership(session, domain, async ({ orgId }) => {
Expand Down Expand Up @@ -321,7 +321,11 @@ export const getRepos = async (domain: string, filter: { status?: RepoIndexingSt
} : {}),
},
include: {
connections: true,
connections: {
include: {
connection: true,
}
}
}
});

Expand All @@ -330,7 +334,10 @@ export const getRepos = async (domain: string, filter: { status?: RepoIndexingSt
repoId: repo.id,
repoName: repo.name,
repoCloneUrl: repo.cloneUrl,
linkedConnections: repo.connections.map((connection) => connection.connectionId),
linkedConnections: repo.connections.map(({ connection }) => ({
id: connection.id,
name: connection.name,
})),
imageUrl: repo.imageUrl ?? undefined,
indexedAt: repo.indexedAt ?? undefined,
repoIndexingStatus: repo.repoIndexingStatus,
Expand Down Expand Up @@ -883,7 +890,7 @@ export const createOnboardingSubscription = async (domain: string) =>
save_default_payment_method: 'on_subscription',
},
});

if (!subscription) {
return {
statusCode: StatusCodes.INTERNAL_SERVER_ERROR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function SharedConnectionCreationForm<T>({
return checkIfSecretExists(secretKey, domain);
}, { message: "Secret not found" }),
});
}, [schema, domain]);
}, [schema, domain, additionalConfigValidation]);

const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const ErrorNavIndicator = () => {
.slice(0, 10)
.map(repo => (
// Link to the first connection for the repo
<Link key={repo.repoId} href={`/${domain}/connections/${repo.linkedConnections[0]}`} onClick={() => captureEvent('wa_error_nav_job_pressed', {})}>
<Link key={repo.repoId} href={`/${domain}/connections/${repo.linkedConnections[0].id}`} onClick={() => captureEvent('wa_error_nav_job_pressed', {})}>
<div className="flex items-center justify-between px-3 py-2
bg-red-50 dark:bg-red-900/20 rounded-md
border border-red-200/50 dark:border-red-800/50
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const ProgressNavIndicator = () => {
<div className="flex flex-col gap-2 pl-4">
{inProgressRepos.slice(0, 10).map(item => (
// Link to the first connection for the repo
<Link key={item.repoId} href={`/${domain}/connections/${item.linkedConnections[0]}`} onClick={() => captureEvent('wa_progress_nav_job_pressed', {})}>
<Link key={item.repoId} href={`/${domain}/connections/${item.linkedConnections[0].id}`} onClick={() => captureEvent('wa_progress_nav_job_pressed', {})}>
<div className="flex items-center gap-2 px-3 py-2 bg-green-50 dark:bg-green-900/20
rounded-md text-sm text-green-700 dark:text-green-300
border border-green-200/50 dark:border-green-800/50
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,19 @@ export const RepoListItem = ({
className="flex flex-row items-center p-4 border rounded-lg bg-background justify-between"
>
<div className="flex flex-row items-center gap-2">
<Image
src={imageUrl ?? ""}
alt={name}
width={40}
height={40}
className="rounded-full"
/>
{imageUrl ? (
<Image
src={imageUrl}
alt={name}
width={32}
height={32}
className="object-cover"
/>
) : (
<div className="h-8 w-8 flex items-center justify-center bg-muted text-xs font-medium uppercase text-muted-foreground rounded-md">
{name.charAt(0)}
</div>
)}
<p className="font-medium">{name}</p>
</div>
<div className="flex flex-row items-center gap-4">
Expand Down
57 changes: 57 additions & 0 deletions packages/web/src/app/[domain]/repos/addRepoButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"use client"

import { Button } from "@/components/ui/button"
import { PlusCircle } from "lucide-react"
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
DialogDescription,
DialogClose,
DialogFooter,
} from "@/components/ui/dialog"
import { useState } from "react"
import { ConnectionList } from "../connections/components/connectionList"
import { useDomain } from "@/hooks/useDomain"
import Link from "next/link";

export function AddRepoButton() {
const [isOpen, setIsOpen] = useState(false)
const domain = useDomain()

return (
<>
<Button
onClick={() => setIsOpen(true)}
variant="ghost"
size="icon"
className="h-8 w-8 ml-2 text-muted-foreground hover:text-foreground transition-colors"
>
<PlusCircle className="h-4 w-4" />
</Button>

<Dialog open={isOpen} onOpenChange={setIsOpen}>
<DialogContent className="sm:max-w-[800px] max-h-[90vh] flex flex-col p-0 gap-0 overflow-hidden">
<DialogHeader className="px-6 py-4 border-b">
<DialogTitle className="text-xl font-semibold">Add a New Repository</DialogTitle>
<DialogDescription className="text-sm text-muted-foreground mt-1">
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.
</DialogDescription>
</DialogHeader>
<div className="flex-1 overflow-y-auto p-6">
<ConnectionList className="w-full" />
</div>
<DialogFooter className="flex justify-between items-center border-t p-4 px-6">
<Button asChild variant="default" className="bg-primary hover:bg-primary/90">
<Link href={`/${domain}/connections`}>Add new connection</Link>
</Button>
<DialogClose asChild>
<Button variant="outline">Close</Button>
</DialogClose>
</DialogFooter>
</DialogContent>
</Dialog>
</>
)
}
Loading