diff --git a/apps/dokploy/components/dashboard/settings/git/show-git-providers.tsx b/apps/dokploy/components/dashboard/settings/git/show-git-providers.tsx index 05273ca2a..593f8f994 100644 --- a/apps/dokploy/components/dashboard/settings/git/show-git-providers.tsx +++ b/apps/dokploy/components/dashboard/settings/git/show-git-providers.tsx @@ -1,27 +1,27 @@ import { - BitbucketIcon, - GiteaIcon, - GithubIcon, - GitlabIcon, + BitbucketIcon, + GiteaIcon, + GithubIcon, + GitlabIcon, } from "@/components/icons/data-tools-icons"; import { DialogAction } from "@/components/shared/dialog-action"; import { Button, buttonVariants } from "@/components/ui/button"; import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, } from "@/components/ui/card"; import { api } from "@/utils/api"; import { useUrl } from "@/utils/hooks/use-url"; import { formatDate } from "date-fns"; import { - ExternalLinkIcon, - GitBranch, - ImportIcon, - Loader2, - Trash2, + ExternalLinkIcon, + GitBranch, + ImportIcon, + Loader2, + Trash2, } from "lucide-react"; import Link from "next/link"; import { toast } from "sonner"; @@ -33,249 +33,256 @@ import { AddGithubProvider } from "./github/add-github-provider"; import { EditGithubProvider } from "./github/edit-github-provider"; import { AddGitlabProvider } from "./gitlab/add-gitlab-provider"; import { EditGitlabProvider } from "./gitlab/edit-gitlab-provider"; +import { Badge } from "@/components/ui/badge"; export const ShowGitProviders = () => { - const { data, isLoading, refetch } = api.gitProvider.getAll.useQuery(); - const { mutateAsync, isLoading: isRemoving } = - api.gitProvider.remove.useMutation(); - const url = useUrl(); + const { data, isLoading, refetch } = api.gitProvider.getAll.useQuery(); + const { mutateAsync, isLoading: isRemoving } = + api.gitProvider.remove.useMutation(); + const url = useUrl(); - const getGitlabUrl = ( - clientId: string, - gitlabId: string, - gitlabUrl: string, - ) => { - const redirectUri = `${url}/api/providers/gitlab/callback?gitlabId=${gitlabId}`; - const scope = "api read_user read_repository"; - const authUrl = `${gitlabUrl}/oauth/authorize?client_id=${clientId}&redirect_uri=${encodeURIComponent(redirectUri)}&response_type=code&scope=${encodeURIComponent(scope)}`; - return authUrl; - }; + const getGitlabUrl = ( + clientId: string, + gitlabId: string, + gitlabUrl: string, + ) => { + const redirectUri = `${url}/api/providers/gitlab/callback?gitlabId=${gitlabId}`; + const scope = "api read_user read_repository"; + const authUrl = `${gitlabUrl}/oauth/authorize?client_id=${clientId}&redirect_uri=${encodeURIComponent(redirectUri)}&response_type=code&scope=${encodeURIComponent(scope)}`; + return authUrl; + }; - return ( -
- -
- - - - Git Providers - - - Connect your Git provider for authentication. - - - - {isLoading ? ( -
- Loading... - -
- ) : ( - <> - {data?.length === 0 ? ( -
- - - Create your first Git Provider - -
-
-
- - - - -
-
-
-
- ) : ( -
-
- - Available Providers - -
-
- - - - -
-
-
+ return ( +
+ +
+ + + + Git Providers + + + Connect your Git provider for authentication. + + + + {isLoading ? ( +
+ Loading... + +
+ ) : ( + <> + {data?.length === 0 ? ( +
+ + + Create your first Git Provider + +
+
+
+ + + + +
+
+
+
+ ) : ( +
+
+ + Available Providers + +
+
+ + + + +
+
+
-
- {data?.map((gitProvider, _index) => { - const isGithub = gitProvider.providerType === "github"; - const isGitlab = gitProvider.providerType === "gitlab"; - const isBitbucket = - gitProvider.providerType === "bitbucket"; - const isGitea = gitProvider.providerType === "gitea"; +
+ {data?.map((gitProvider, _index) => { + const isGithub = gitProvider.providerType === "github"; + const isGitlab = gitProvider.providerType === "gitlab"; + const isBitbucket = + gitProvider.providerType === "bitbucket"; + const isGitea = gitProvider.providerType === "gitea"; - const haveGithubRequirements = - isGithub && - gitProvider.github?.githubPrivateKey && - gitProvider.github?.githubAppId && - gitProvider.github?.githubInstallationId; + const haveGithubRequirements = + isGithub && + gitProvider.github?.githubPrivateKey && + gitProvider.github?.githubAppId && + gitProvider.github?.githubInstallationId; - const haveGitlabRequirements = - isGitlab && - gitProvider.gitlab?.accessToken && - gitProvider.gitlab?.refreshToken; + const haveGitlabRequirements = + isGitlab && + gitProvider.gitlab?.accessToken && + gitProvider.gitlab?.refreshToken; - return ( -
-
-
-
- {isGithub && ( - - )} - {isGitlab && ( - - )} - {isBitbucket && ( - - )} - {isGitea && } -
- - {gitProvider.name} - - - {formatDate( - gitProvider.createdAt, - "yyyy-MM-dd hh:mm:ss a", - )} - -
-
-
+ return ( +
+
+
+
+ {isGithub && ( + + )} + {isGitlab && ( + + )} + {isBitbucket && ( + + )} + {isGitea && } +
+ + {gitProvider.name} + + + {formatDate( + gitProvider.createdAt, + "yyyy-MM-dd hh:mm:ss a", + )} + +
+
+
-
- {!haveGithubRequirements && isGithub && ( -
- - - -
- )} - {haveGithubRequirements && isGithub && ( -
- - - -
- )} - {!haveGitlabRequirements && isGitlab && ( -
- - - -
- )} +
+ {!haveGithubRequirements && isGithub && ( +
+ + Action Required + + + + +
+ )} + {haveGithubRequirements && isGithub && ( +
+ + + +
+ )} + {!haveGitlabRequirements && isGitlab && ( +
+ + Action Required + + + + +
+ )} - {isGithub && haveGithubRequirements && ( - - )} + {isGithub && haveGithubRequirements && ( + + )} - {isGitlab && ( - - )} + {isGitlab && ( + + )} - {isBitbucket && ( - - )} + {isBitbucket && ( + + )} - {isGitea && ( - - )} + {isGitea && ( + + )} - { - await mutateAsync({ - gitProviderId: gitProvider.gitProviderId, - }) - .then(() => { - toast.success( - "Git Provider deleted successfully", - ); - refetch(); - }) - .catch(() => { - toast.error( - "Error deleting Git Provider", - ); - }); - }} - > - - -
-
-
- ); - })} -
+ { + await mutateAsync({ + gitProviderId: gitProvider.gitProviderId, + }) + .then(() => { + toast.success( + "Git Provider deleted successfully", + ); + refetch(); + }) + .catch(() => { + toast.error( + "Error deleting Git Provider", + ); + }); + }} + > + + +
+
+
+ ); + })} +
-
- {/* */} -
-
- )} - - )} -
-
-
-
- ); +
+ {/* */} +
+
+ )} + + )} +
+
+
+
+ ); };