From 322fcb002d2e31b2b597ce61c0ecf76b079cf016 Mon Sep 17 00:00:00 2001 From: Will Chen Date: Mon, 28 Apr 2025 22:21:05 -0700 Subject: [PATCH] =?UTF-8?q?Provide=20a=20way=20to=20disconnect=20from=20Gi?= =?UTF-8?q?tHub=20integration=20(due=20to=20permissio=E2=80=A6=20(#39)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/GitHubConnector.tsx | 26 +++++++++++- src/components/GitHubIntegration.tsx | 60 ++++++++++++++++++++++++++++ src/pages/settings.tsx | 12 ++++++ 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 src/components/GitHubIntegration.tsx diff --git a/src/components/GitHubConnector.tsx b/src/components/GitHubConnector.tsx index b37d755..a30d3ed 100644 --- a/src/components/GitHubConnector.tsx +++ b/src/components/GitHubConnector.tsx @@ -1,6 +1,6 @@ import { useState, useEffect } from "react"; import { Button } from "@/components/ui/button"; -import { Github } from "lucide-react"; +import { Github, Clipboard, Check } from "lucide-react"; import { IpcClient } from "@/ipc/ipc_client"; import { useSettings } from "@/hooks/useSettings"; import { useLoadApp } from "@/hooks/useLoadApp"; @@ -23,6 +23,7 @@ export function GitHubConnector({ appId, folderName }: GitHubConnectorProps) { const [githubStatusMessage, setGithubStatusMessage] = useState( null ); + const [codeCopied, setCodeCopied] = useState(false); // --- --- const handleConnectToGithub = async () => { @@ -240,6 +241,29 @@ export function GitHubConnector({ appId, folderName }: GitHubConnectorProps) { {githubUserCode} +

)} diff --git a/src/components/GitHubIntegration.tsx b/src/components/GitHubIntegration.tsx new file mode 100644 index 0000000..4ebaf3d --- /dev/null +++ b/src/components/GitHubIntegration.tsx @@ -0,0 +1,60 @@ +import { useState } from "react"; +import { Button } from "@/components/ui/button"; +import { Github } from "lucide-react"; +import { useSettings } from "@/hooks/useSettings"; +import { showSuccess, showError } from "@/lib/toast"; + +export function GitHubIntegration() { + const { settings, updateSettings } = useSettings(); + const [isDisconnecting, setIsDisconnecting] = useState(false); + + const handleDisconnectFromGithub = async () => { + setIsDisconnecting(true); + try { + const result = await updateSettings({ + githubAccessToken: undefined, + }); + if (result) { + showSuccess("Successfully disconnected from GitHub"); + } else { + showError("Failed to disconnect from GitHub"); + } + } catch (err: any) { + showError( + err.message || "An error occurred while disconnecting from GitHub" + ); + } finally { + setIsDisconnecting(false); + } + }; + + const isConnected = !!settings?.githubAccessToken; + + if (!isConnected) { + return null; + } + + return ( +
+
+

+ GitHub Integration +

+

+ Your account is connected to GitHub. +

+
+ + +
+ ); +} diff --git a/src/pages/settings.tsx b/src/pages/settings.tsx index 42943bc..41d17ca 100644 --- a/src/pages/settings.tsx +++ b/src/pages/settings.tsx @@ -10,6 +10,8 @@ import { useSettings } from "@/hooks/useSettings"; import { Button } from "@/components/ui/button"; import { ArrowLeft } from "lucide-react"; import { useRouter } from "@tanstack/react-router"; +import { GitHubIntegration } from "@/components/GitHubIntegration"; + export default function SettingsPage() { const { theme, setTheme } = useTheme(); const [isResetDialogOpen, setIsResetDialogOpen] = useState(false); @@ -145,6 +147,16 @@ export default function SettingsPage() { + {/* Integrations Section */} +
+

+ Integrations +

+
+ +
+
+ {/* Experiments Section */}