Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
a53d7270
Unverified
提交
a53d7270
authored
4月 29, 2025
作者:
Will Chen
提交者:
GitHub
4月 29, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
provide a way to disconnect github repo (#47)
上级
a33e6c6a
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
89 行增加
和
4 行删除
+89
-4
GitHubConnector.tsx
src/components/GitHubConnector.tsx
+32
-1
github_handlers.ts
src/ipc/handlers/github_handlers.ts
+38
-0
ipc_client.ts
src/ipc/ipc_client.ts
+18
-3
preload.ts
src/preload.ts
+1
-0
没有找到文件。
src/components/GitHubConnector.tsx
浏览文件 @
a53d7270
...
@@ -172,6 +172,27 @@ export function GitHubConnector({ appId, folderName }: GitHubConnectorProps) {
...
@@ -172,6 +172,27 @@ export function GitHubConnector({ appId, folderName }: GitHubConnectorProps) {
}
}
};
};
const
[
isDisconnecting
,
setIsDisconnecting
]
=
useState
(
false
);
const
[
disconnectError
,
setDisconnectError
]
=
useState
<
string
|
null
>
(
null
);
const
handleDisconnectRepo
=
async
()
=>
{
if
(
!
appId
)
return
;
setIsDisconnecting
(
true
);
setDisconnectError
(
null
);
try
{
const
result
=
await
IpcClient
.
getInstance
().
disconnectGithubRepo
(
appId
);
if
(
result
.
success
)
{
refreshApp
();
}
else
{
setDisconnectError
(
result
.
error
||
"Failed to disconnect repository."
);
}
}
catch
(
err
:
any
)
{
setDisconnectError
(
err
.
message
||
"Failed to disconnect repository."
);
}
finally
{
setIsDisconnecting
(
false
);
}
};
if
(
!
settings
?.
githubAccessToken
)
{
if
(
!
settings
?.
githubAccessToken
)
{
return
(
return
(
<
div
className=
"mt-1 w-full"
>
<
div
className=
"mt-1 w-full"
>
...
@@ -313,7 +334,7 @@ export function GitHubConnector({ appId, folderName }: GitHubConnectorProps) {
...
@@ -313,7 +334,7 @@ export function GitHubConnector({ appId, folderName }: GitHubConnectorProps) {
>
>
{
app
.
githubOrg
}
/
{
app
.
githubRepo
}
{
app
.
githubOrg
}
/
{
app
.
githubRepo
}
</
a
>
</
a
>
<
div
className=
"mt-2"
>
<
div
className=
"mt-2
flex gap-2
"
>
<
Button
onClick=
{
handleSyncToGithub
}
disabled=
{
isSyncing
}
>
<
Button
onClick=
{
handleSyncToGithub
}
disabled=
{
isSyncing
}
>
{
isSyncing
?
(
{
isSyncing
?
(
<>
<>
...
@@ -344,11 +365,21 @@ export function GitHubConnector({ appId, folderName }: GitHubConnectorProps) {
...
@@ -344,11 +365,21 @@ export function GitHubConnector({ appId, folderName }: GitHubConnectorProps) {
"Sync to GitHub"
"Sync to GitHub"
)
}
)
}
</
Button
>
</
Button
>
<
Button
onClick=
{
handleDisconnectRepo
}
disabled=
{
isDisconnecting
}
variant=
"outline"
>
{
isDisconnecting
?
"Disconnecting..."
:
"Disconnect from repo"
}
</
Button
>
</
div
>
</
div
>
{
syncError
&&
<
p
className=
"text-red-600 mt-2"
>
{
syncError
}
</
p
>
}
{
syncError
&&
<
p
className=
"text-red-600 mt-2"
>
{
syncError
}
</
p
>
}
{
syncSuccess
&&
(
{
syncSuccess
&&
(
<
p
className=
"text-green-600 mt-2"
>
Successfully pushed to GitHub!
</
p
>
<
p
className=
"text-green-600 mt-2"
>
Successfully pushed to GitHub!
</
p
>
)
}
)
}
{
disconnectError
&&
(
<
p
className=
"text-red-600 mt-2"
>
{
disconnectError
}
</
p
>
)
}
</
div
>
</
div
>
);
);
}
else
{
}
else
{
...
...
src/ipc/handlers/github_handlers.ts
浏览文件 @
a53d7270
...
@@ -422,10 +422,48 @@ async function handlePushToGithub(
...
@@ -422,10 +422,48 @@ async function handlePushToGithub(
}
}
}
}
async
function
handleDisconnectGithubRepo
(
event
:
IpcMainInvokeEvent
,
{
appId
}:
{
appId
:
number
}
)
{
try
{
logger
.
log
(
`Disconnecting GitHub repo for appId:
${
appId
}
`
);
// Get the app from the database
const
app
=
await
db
.
query
.
apps
.
findFirst
({
where
:
eq
(
apps
.
id
,
appId
),
});
if
(
!
app
)
{
return
{
success
:
false
,
error
:
"App not found"
};
}
// Update app in database to remove GitHub repo and org
await
db
.
update
(
apps
)
.
set
({
githubRepo
:
null
,
githubOrg
:
null
,
})
.
where
(
eq
(
apps
.
id
,
appId
));
return
{
success
:
true
};
}
catch
(
error
)
{
logger
.
error
(
`Error disconnecting GitHub repo:
${
error
}
`
);
return
{
success
:
false
,
error
:
error
instanceof
Error
?
error
.
message
:
String
(
error
),
};
}
}
// --- Registration ---
// --- Registration ---
export
function
registerGithubHandlers
()
{
export
function
registerGithubHandlers
()
{
ipcMain
.
handle
(
"github:start-flow"
,
handleStartGithubFlow
);
ipcMain
.
handle
(
"github:start-flow"
,
handleStartGithubFlow
);
ipcMain
.
handle
(
"github:is-repo-available"
,
handleIsRepoAvailable
);
ipcMain
.
handle
(
"github:is-repo-available"
,
handleIsRepoAvailable
);
ipcMain
.
handle
(
"github:create-repo"
,
handleCreateRepo
);
ipcMain
.
handle
(
"github:create-repo"
,
handleCreateRepo
);
ipcMain
.
handle
(
"github:push"
,
handlePushToGithub
);
ipcMain
.
handle
(
"github:push"
,
handlePushToGithub
);
ipcMain
.
handle
(
"github:disconnect"
,
(
event
,
args
:
{
appId
:
number
})
=>
handleDisconnectGithubRepo
(
event
,
args
)
);
}
}
src/ipc/ipc_client.ts
浏览文件 @
a53d7270
...
@@ -611,9 +611,24 @@ export class IpcClient {
...
@@ -611,9 +611,24 @@ export class IpcClient {
):
Promise
<
{
success
:
boolean
;
error
?:
string
}
>
{
):
Promise
<
{
success
:
boolean
;
error
?:
string
}
>
{
try
{
try
{
const
result
=
await
this
.
ipcRenderer
.
invoke
(
"github:push"
,
{
appId
});
const
result
=
await
this
.
ipcRenderer
.
invoke
(
"github:push"
,
{
appId
});
return
result
;
return
result
as
{
success
:
boolean
;
error
?:
string
};
}
catch
(
error
:
any
)
{
}
catch
(
error
)
{
return
{
success
:
false
,
error
:
error
.
message
||
"Unknown error"
};
showError
(
error
);
throw
error
;
}
}
public
async
disconnectGithubRepo
(
appId
:
number
):
Promise
<
{
success
:
boolean
;
error
?:
string
}
>
{
try
{
const
result
=
await
this
.
ipcRenderer
.
invoke
(
"github:disconnect"
,
{
appId
,
});
return
result
as
{
success
:
boolean
;
error
?:
string
};
}
catch
(
error
)
{
showError
(
error
);
throw
error
;
}
}
}
}
// --- End GitHub Repo Management ---
// --- End GitHub Repo Management ---
...
...
src/preload.ts
浏览文件 @
a53d7270
...
@@ -38,6 +38,7 @@ const validInvokeChannels = [
...
@@ -38,6 +38,7 @@ const validInvokeChannels = [
"github:is-repo-available"
,
"github:is-repo-available"
,
"github:create-repo"
,
"github:create-repo"
,
"github:push"
,
"github:push"
,
"github:disconnect"
,
"get-app-version"
,
"get-app-version"
,
"reload-env-path"
,
"reload-env-path"
,
"get-proposal"
,
"get-proposal"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论