mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 12:43:16 +00:00
fix: Disconnect GH -> Logout button (#138)
* fix: Disconnect GH -> Logout button * cr
This commit is contained in:
parent
4fbd1f4861
commit
a99a02223d
4 changed files with 17 additions and 11 deletions
|
|
@ -3,6 +3,8 @@
|
|||
import { useState, useEffect } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { GitHubSVG } from "@/components/icons/github";
|
||||
import { LogOut } from "lucide-react";
|
||||
import { TooltipIconButton } from "../ui/tooltip-icon-button";
|
||||
|
||||
export function GitHubOAuthButton() {
|
||||
const [isAuth, setIsAuth] = useState<boolean | null>(null);
|
||||
|
|
@ -35,7 +37,9 @@ export function GitHubOAuthButton() {
|
|||
method: "POST",
|
||||
});
|
||||
if (response.ok) {
|
||||
localStorage.removeItem("github_app_installed");
|
||||
setIsAuth(false);
|
||||
window.location.href = "/";
|
||||
} else {
|
||||
console.error("Logout failed");
|
||||
}
|
||||
|
|
@ -65,16 +69,15 @@ export function GitHubOAuthButton() {
|
|||
|
||||
if (isAuth) {
|
||||
return (
|
||||
<Button
|
||||
variant="outline"
|
||||
<TooltipIconButton
|
||||
tooltip="Logout"
|
||||
onClick={handleLogout}
|
||||
disabled={isLoading}
|
||||
className="text-xs"
|
||||
size="sm"
|
||||
>
|
||||
<GitHubSVG />
|
||||
{isLoading ? "Disconnecting..." : "Disconnect GitHub"}
|
||||
</Button>
|
||||
<LogOut className="size-4" />
|
||||
</TooltipIconButton>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ export function OpenPRButton() {
|
|||
"text-gray-500 hover:text-gray-600": prState === "draft",
|
||||
"text-[#8957e5] hover:text-[#7847d1]": prState === "merged",
|
||||
})}
|
||||
size="sm"
|
||||
>
|
||||
{prState === "merged" && <GitMerge className="size-4" />}
|
||||
{prState === "draft" && <GitPullRequestDraft className="size-4" />}
|
||||
|
|
|
|||
|
|
@ -95,11 +95,9 @@ export function getGitHubToken(request: NextRequest): GitHubTokenData | null {
|
|||
* @param response NextResponse to set cookies on
|
||||
*/
|
||||
export function clearGitHubToken(response: NextResponse): void {
|
||||
const cookieOptions = getCookieOptions(new Date(0)); // Expire immediately
|
||||
|
||||
response.cookies.set(GITHUB_TOKEN_COOKIE, "", cookieOptions);
|
||||
response.cookies.set(GITHUB_TOKEN_TYPE_COOKIE, "", cookieOptions);
|
||||
response.cookies.set(GITHUB_INSTALLATION_ID_COOKIE, "", cookieOptions);
|
||||
response.cookies.delete(GITHUB_TOKEN_COOKIE);
|
||||
response.cookies.delete(GITHUB_TOKEN_TYPE_COOKIE);
|
||||
response.cookies.delete(GITHUB_INSTALLATION_ID_COOKIE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -249,8 +249,12 @@ export async function getPullRequest(inputs: {
|
|||
headBranch: string;
|
||||
}) {
|
||||
try {
|
||||
const queryParams = new URLSearchParams();
|
||||
queryParams.set("base", inputs.baseBranch);
|
||||
queryParams.set("head", inputs.headBranch);
|
||||
queryParams.set("state", "all");
|
||||
const response = await fetch(
|
||||
`${getBaseApiUrl()}github/proxy/repos/${inputs.owner}/${inputs.repo}/pulls?base=${inputs.baseBranch}&head=${inputs.headBranch}`,
|
||||
`${getBaseApiUrl()}github/proxy/repos/${inputs.owner}/${inputs.repo}/pulls?${queryParams.toString()}`,
|
||||
{
|
||||
headers: {
|
||||
Accept: "application/vnd.github.v3+json",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue