diff --git a/frontend/src/components/console/project/add-project.tsx b/frontend/src/components/console/project/add-project.tsx index c6aa4f4f..d2912596 100644 --- a/frontend/src/components/console/project/add-project.tsx +++ b/frontend/src/components/console/project/add-project.tsx @@ -11,9 +11,11 @@ import { import { Command, CommandEmpty, + CommandGroup, CommandInput, CommandItem, CommandList, + CommandSeparator, } from "@/components/ui/command" import { Dialog, @@ -30,9 +32,9 @@ import { PopoverTrigger, } from "@/components/ui/popover" import { cn } from "@/lib/utils" -import { getGitPlatformIcon } from "@/utils/common" +import { getGithubAppInstallUrl, getGitPlatformIcon } from "@/utils/common" import { apiRequest } from "@/utils/requestUtils" -import { IconCheck, IconChevronDown, IconGitBranch, IconLoader, IconReload } from "@tabler/icons-react" +import { IconCheck, IconChevronDown, IconGitBranch, IconLink, IconLoader, IconReload } from "@tabler/icons-react" import { useCallback, useEffect, useMemo, useState } from "react" import { useNavigate } from "react-router-dom" import { useSettingsDialog } from "@/pages/console/user/page" @@ -75,6 +77,8 @@ export default function AddProjectDialog({ () => identities.find((i) => i.id === selectedIdentityId), [identities, selectedIdentityId] ) + const selectedIdentityIsGithub = + selectedIdentity?.platform === ConstsGitPlatform.GitPlatformGithub const selectedRepo = identityRepoOptions.find( (o) => `${o.gitIdentityId}:${o.repository.url || ""}` === selectedRepoValue @@ -137,6 +141,15 @@ export default function AddProjectDialog({ } }, [selectedIdentityId]) + const handleAuthorizeGithubRepos = () => { + const popup = window.open(getGithubAppInstallUrl(), "_blank", "noopener,noreferrer") + if (!popup) { + toast.error("浏览器拦截了新页面,请允许弹出窗口后重试") + return + } + toast.success("已打开 GitHub 配置页,完成授权后请返回并刷新仓库列表") + } + const handleSave = async () => { if (!name.trim()) { toast.error("请输入项目名称") @@ -310,59 +323,119 @@ export default function AddProjectDialog({ ) : identityRepoOptions.length === 0 ? (
暂无仓库或获取失败,请点击重试。
- +当前没有可用仓库
++ {selectedIdentityIsGithub + ? "完成 GitHub 授权后,返回这里点击刷新仓库列表。" + : "请点击刷新重新获取仓库列表。"} +
++ 未找到匹配的仓库 +
+ {selectedIdentityIsGithub ? ( + + ) : null} +