provide a way to disconnect github repo (#47)
This commit is contained in:
@@ -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 ---
|
||||
export function registerGithubHandlers() {
|
||||
ipcMain.handle("github:start-flow", handleStartGithubFlow);
|
||||
ipcMain.handle("github:is-repo-available", handleIsRepoAvailable);
|
||||
ipcMain.handle("github:create-repo", handleCreateRepo);
|
||||
ipcMain.handle("github:push", handlePushToGithub);
|
||||
ipcMain.handle("github:disconnect", (event, args: { appId: number }) =>
|
||||
handleDisconnectGithubRepo(event, args)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -611,9 +611,24 @@ export class IpcClient {
|
||||
): Promise<{ success: boolean; error?: string }> {
|
||||
try {
|
||||
const result = await this.ipcRenderer.invoke("github:push", { appId });
|
||||
return result;
|
||||
} catch (error: any) {
|
||||
return { success: false, error: error.message || "Unknown error" };
|
||||
return result as { success: boolean; error?: string };
|
||||
} catch (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 ---
|
||||
|
||||
Reference in New Issue
Block a user