Skip to content

Commit

Permalink
fix: Remove git config file stuff (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
adityachoudhari26 authored Oct 15, 2024
1 parent 391a262 commit a6faaf3
Show file tree
Hide file tree
Showing 15 changed files with 3,647 additions and 564 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ export const GithubConnectedOrgs: React.FC<GithubConnectedOrgsProps> = async ({
Connected Github organizations
</CardTitle>
<CardDescription>
You can configure job agents and sync config files for these
organizations
You can configure job agents for these organizations
</CardDescription>
</div>
{githubUser != null ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
"use client";

import type {
Deployment,
GithubConfigFile,
GithubOrganization,
} from "@ctrlplane/db/schema";
import type * as schema from "@ctrlplane/db/schema";
import { useRouter } from "next/navigation";

import {
Expand All @@ -18,21 +14,12 @@ import {
AlertDialogTitle,
AlertDialogTrigger,
} from "@ctrlplane/ui/alert-dialog";
import { Badge } from "@ctrlplane/ui/badge";
import { buttonVariants } from "@ctrlplane/ui/button";

import { api } from "~/trpc/react";

type GithubConfigFileWithDeployments = GithubConfigFile & {
deployments: Deployment[];
};

export type GithubOrganizationWithConfigFiles = GithubOrganization & {
configFiles: GithubConfigFileWithDeployments[];
};

type GithubRemoveOrgDialogProps = {
githubOrganization: GithubOrganizationWithConfigFiles;
githubOrganization: schema.GithubOrganization;
children: React.ReactNode;
};

Expand All @@ -43,70 +30,34 @@ export const GithubRemoveOrgDialog: React.FC<GithubRemoveOrgDialogProps> = ({
const router = useRouter();
const githubOrgDelete = api.github.organizations.delete.useMutation();

const handleDelete = (deleteResources: boolean) => {
const { id, workspaceId } = githubOrganization;
const handleDelete = () =>
githubOrgDelete
.mutateAsync({
id: githubOrganization.id,
workspaceId: githubOrganization.workspaceId,
deleteDeployments: deleteResources,
})
.mutateAsync({ id, workspaceId })
.then(() => router.refresh());
};

return (
<AlertDialog>
<AlertDialogTrigger asChild>{children}</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Are you sure?</AlertDialogTitle>
{githubOrganization.configFiles.length > 0 ? (
<AlertDialogDescription>
<p className="mb-2">You have two options for deletion:</p>
<ol className="list-decimal space-y-2 pl-5">
<li>
<strong>Disconnect only the organization:</strong> Any
resources generated from a{" "}
<Badge variant="secondary">
<code>ctrlplane.yaml</code>
</Badge>{" "}
config file associated with this organization will remain, but
will no longer be synced with changes to the source file.
</li>
<li>
<strong>Disconnect and delete all resources:</strong> This
action is irreversible and will permanently remove the
organization along with all associated resources. This
includes all resources generated from a{" "}
<Badge variant="secondary">
<code>ctrlplane.yaml</code>
</Badge>{" "}
config file in a repo within your Github organization.
</li>
</ol>
</AlertDialogDescription>
) : (
<AlertDialogDescription>
Disconnecting the organization will remove the connection between
Ctrlplane and your Github organization for this workspace.
</AlertDialogDescription>
)}
<AlertDialogTitle>
Are you sure you want to disconnect this Github organization?
</AlertDialogTitle>

<AlertDialogDescription>
Disconnecting the organization will remove the connection between
Ctrlplane and your Github organization for this workspace.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
className={buttonVariants({ variant: "destructive" })}
onClick={() => handleDelete(false)}
onClick={handleDelete}
>
Disconnect {githubOrganization.configFiles.length > 0 && "only"}
Disconnect
</AlertDialogAction>
{githubOrganization.configFiles.length > 0 && (
<AlertDialogAction
className={buttonVariants({ variant: "destructive" })}
onClick={() => handleDelete(true)}
>
Disconnect and delete
</AlertDialogAction>
)}
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type * as schema from "@ctrlplane/db/schema";
import Link from "next/link";
import { IconChevronDown, IconExternalLink } from "@tabler/icons-react";

Expand All @@ -9,7 +10,6 @@ import {
DropdownMenuTrigger,
} from "@ctrlplane/ui/dropdown-menu";

import type { GithubOrganizationWithConfigFiles } from "./GithubRemoveOrgDialog";
import { DisconnectDropdownActionButton } from "./DisconnectDropdownActionButton";
import { GithubRemoveOrgDialog } from "./GithubRemoveOrgDialog";

Expand All @@ -19,7 +19,7 @@ type OrgActionDropdownProps = {
botName: string;
clientId: string;
};
org: GithubOrganizationWithConfigFiles;
org: schema.GithubOrganization;
};

export const OrgActionDropdown: React.FC<OrgActionDropdownProps> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Card } from "@ctrlplane/ui/card";
import { env } from "~/env";
import { api } from "~/trpc/server";
import { DeleteGithubUserButton } from "./DeleteGithubUserButton";
import { GithubConfigFileSync } from "./GithubConfigFile";
import { GithubConnectedOrgs } from "./GithubConnectedOrgs";

const githubAuthUrl = (
Expand Down Expand Up @@ -42,17 +41,14 @@ export default async function GitHubIntegrationPage({

const githubUser = await api.github.user.byUserId(session.user.id);

const configFiles = await api.github.configFile.list(workspace.id);

return (
<div className="flex flex-col gap-12">
<div className="flex items-center gap-4">
<SiGithub className="h-14 w-14" />
<div className="flex flex-col gap-1">
<h1 className="text-3xl font-bold">GitHub</h1>
<p className="text-sm text-muted-foreground">
Connect a Github organization to Ctrlplane to configure job agents
and sync config files.
Connect a Github organization to Ctrlplane to configure job agents.
</p>
</div>
</div>
Expand Down Expand Up @@ -101,8 +97,6 @@ export default async function GitHubIntegrationPage({
}}
/>
)}

<GithubConfigFileSync configFiles={configFiles} />
</div>
</div>
);
Expand Down
Loading

0 comments on commit a6faaf3

Please sign in to comment.