mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-15 05:45:20 +00:00
remove connections settings page
This commit is contained in:
parent
ac8751ef55
commit
101f29b967
1 changed files with 32 additions and 75 deletions
|
|
@ -7,104 +7,61 @@ import {
|
||||||
BreadcrumbPage,
|
BreadcrumbPage,
|
||||||
BreadcrumbSeparator,
|
BreadcrumbSeparator,
|
||||||
} from "@/components/ui/breadcrumb"
|
} from "@/components/ui/breadcrumb"
|
||||||
import { TabSwitcher } from "@/components/ui/tab-switcher"
|
|
||||||
import { Tabs, TabsContent } from "@/components/ui/tabs"
|
|
||||||
import { ConnectionIcon } from "../components/connectionIcon"
|
import { ConnectionIcon } from "../components/connectionIcon"
|
||||||
import { Header } from "../../components/header"
|
import { Header } from "../../components/header"
|
||||||
import { ConfigSetting } from "./components/configSetting"
|
|
||||||
import { DeleteConnectionSetting } from "./components/deleteConnectionSetting"
|
|
||||||
import { DisplayNameSetting } from "./components/displayNameSetting"
|
|
||||||
import { RepoList } from "./components/repoList"
|
import { RepoList } from "./components/repoList"
|
||||||
import { getConnectionByDomain } from "@/data/connection"
|
import { getConnectionByDomain } from "@/data/connection"
|
||||||
import { Overview } from "./components/overview"
|
import { Overview } from "./components/overview"
|
||||||
import { getOrgMembership } from "@/actions"
|
|
||||||
import { isServiceError } from "@/lib/utils"
|
|
||||||
import { notFound } from "next/navigation"
|
|
||||||
import { OrgRole } from "@sourcebot/db"
|
|
||||||
import { CodeHostType } from "@/lib/utils"
|
|
||||||
import { env } from "@/env.mjs"
|
|
||||||
|
|
||||||
interface ConnectionManagementPageProps {
|
interface ConnectionManagementPageProps {
|
||||||
params: Promise<{
|
params: Promise<{
|
||||||
domain: string
|
domain: string
|
||||||
id: string
|
id: string
|
||||||
}>,
|
}>,
|
||||||
searchParams: Promise<{
|
|
||||||
tab: string
|
|
||||||
}>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function ConnectionManagementPage(props: ConnectionManagementPageProps) {
|
export default async function ConnectionManagementPage(props: ConnectionManagementPageProps) {
|
||||||
const searchParams = await props.searchParams;
|
|
||||||
const params = await props.params;
|
const params = await props.params;
|
||||||
const connection = await getConnectionByDomain(Number(params.id), params.domain);
|
const connection = await getConnectionByDomain(Number(params.id), params.domain);
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
return <NotFound className="flex w-full h-full items-center justify-center" message="Connection not found" />
|
return <NotFound className="flex w-full h-full items-center justify-center" message="Connection not found" />
|
||||||
}
|
}
|
||||||
|
|
||||||
const membership = await getOrgMembership(params.domain);
|
|
||||||
if (isServiceError(membership)) {
|
|
||||||
return notFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
const isOwner = membership.role === OrgRole.OWNER;
|
|
||||||
const isDisabled = !isOwner || env.CONFIG_PATH !== undefined;
|
|
||||||
const currentTab = searchParams.tab || "overview";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tabs value={currentTab} className="w-full">
|
<div className="min-h-screen bg-background">
|
||||||
<Header className="mb-6" withTopMargin={false}>
|
<div className="max-w-7xl mx-auto px-6 py-8">
|
||||||
<Breadcrumb>
|
<div className="mb-8">
|
||||||
<BreadcrumbList>
|
<Breadcrumb className="mb-6">
|
||||||
<BreadcrumbItem>
|
<BreadcrumbList>
|
||||||
<BreadcrumbLink href={`/${params.domain}/connections`}>Connections</BreadcrumbLink>
|
<BreadcrumbItem>
|
||||||
</BreadcrumbItem>
|
<BreadcrumbLink href={`/${params.domain}/connections`}>Connections</BreadcrumbLink>
|
||||||
<BreadcrumbSeparator />
|
</BreadcrumbItem>
|
||||||
<BreadcrumbItem>
|
<BreadcrumbSeparator />
|
||||||
<BreadcrumbPage>{connection.name}</BreadcrumbPage>
|
<BreadcrumbItem>
|
||||||
</BreadcrumbItem>
|
<BreadcrumbPage>{connection.name}</BreadcrumbPage>
|
||||||
</BreadcrumbList>
|
</BreadcrumbItem>
|
||||||
</Breadcrumb>
|
</BreadcrumbList>
|
||||||
<div className="mt-6 flex flex-row items-center gap-4 w-full">
|
</Breadcrumb>
|
||||||
<ConnectionIcon type={connection.connectionType} />
|
<div className="flex items-center gap-3">
|
||||||
<h1 className="text-lg font-semibold">{connection.name}</h1>
|
<ConnectionIcon type={connection.connectionType} />
|
||||||
</div>
|
<h1 className="text-2xl font-semibold text-foreground">{connection.name}</h1>
|
||||||
<TabSwitcher
|
</div>
|
||||||
className="h-auto p-0 bg-transparent border-b border-border mt-6"
|
|
||||||
tabs={[
|
|
||||||
{ label: "Overview", value: "overview" },
|
|
||||||
{ label: "Settings", value: "settings" },
|
|
||||||
]}
|
|
||||||
currentTab={currentTab}
|
|
||||||
/>
|
|
||||||
</Header>
|
|
||||||
<TabsContent
|
|
||||||
value="overview"
|
|
||||||
className="space-y-8"
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
<h1 className="font-semibold text-lg mb-4">Overview</h1>
|
|
||||||
<Overview connectionId={connection.id} />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="border-t border-border/40 pt-8">
|
||||||
|
<div className="space-y-12">
|
||||||
|
<div>
|
||||||
|
<h2 className="text-lg font-medium text-foreground mb-6">Overview</h2>
|
||||||
|
<Overview connectionId={connection.id} />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h1 className="font-semibold text-lg mb-4">Linked Repositories</h1>
|
<h2 className="text-lg font-medium text-foreground mb-6">Linked Repositories</h2>
|
||||||
<RepoList connectionId={connection.id} />
|
<RepoList connectionId={connection.id} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</TabsContent>
|
</div>
|
||||||
<TabsContent
|
</div>
|
||||||
value="settings"
|
|
||||||
className="flex flex-col gap-6"
|
|
||||||
>
|
|
||||||
<DisplayNameSetting connectionId={connection.id} name={connection.name} disabled={isDisabled} />
|
|
||||||
<ConfigSetting
|
|
||||||
connectionId={connection.id}
|
|
||||||
type={connection.connectionType as CodeHostType}
|
|
||||||
config={JSON.stringify(connection.config, null, 2)}
|
|
||||||
disabled={isDisabled}
|
|
||||||
/>
|
|
||||||
<DeleteConnectionSetting connectionId={connection.id} disabled={isDisabled} />
|
|
||||||
</TabsContent>
|
|
||||||
</Tabs>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue