add some features
This commit is contained in:
+59
-9
@@ -7,6 +7,7 @@
|
||||
import CommitPanel from "./lib/components/CommitPanel.svelte";
|
||||
import CompareDialog from "./lib/components/CompareDialog.svelte";
|
||||
import ComparePanel from "./lib/components/ComparePanel.svelte";
|
||||
import CredentialDialog from "./lib/components/CredentialDialog.svelte";
|
||||
import ExplorerPanel from "./lib/components/ExplorerPanel.svelte";
|
||||
import FileHistoryPanel from "./lib/components/FileHistoryPanel.svelte";
|
||||
import HistoryPanel from "./lib/components/HistoryPanel.svelte";
|
||||
@@ -79,6 +80,10 @@
|
||||
let preparedResolutions: Record<string, PreparedResolution> = {};
|
||||
let autoRefreshEnabled = true;
|
||||
let autoRefreshInFlight = false;
|
||||
let credDialogOpen = false;
|
||||
let credDialogAction: "push" | "pull" | null = null;
|
||||
let credDialogError = "";
|
||||
let sessionCredentials: { username: string; password: string } | null = null;
|
||||
let lastStatusFingerprint = "";
|
||||
const AUTO_REFRESH_INTERVAL = 4000;
|
||||
let autoRefreshTimer: ReturnType<typeof setInterval> | undefined;
|
||||
@@ -265,26 +270,60 @@
|
||||
});
|
||||
}
|
||||
|
||||
async function pullRepo() {
|
||||
function openCredentialDialog(action: "push" | "pull") {
|
||||
if (!activeRepoPath) return;
|
||||
credDialogError = "";
|
||||
credDialogAction = action;
|
||||
credDialogOpen = true;
|
||||
}
|
||||
|
||||
async function doActualPull(username: string, password: string) {
|
||||
errorMessage = "";
|
||||
await runOperation("Pulling", async () => {
|
||||
applyStatus(await pull(activeRepoPath));
|
||||
applyStatus(await pull(activeRepoPath, username, password));
|
||||
await refreshBranchList(activeRepoPath);
|
||||
await refreshCommitHistory(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
});
|
||||
if (errorMessage) { credDialogError = errorMessage; errorMessage = ""; }
|
||||
else { credDialogOpen = false; credDialogAction = null; }
|
||||
}
|
||||
|
||||
async function doActualPush(username: string, password: string) {
|
||||
errorMessage = "";
|
||||
await runOperation("Pushing", async () => {
|
||||
applyStatus(await push(activeRepoPath, username, password));
|
||||
await refreshBranchList(activeRepoPath);
|
||||
await refreshCommitHistory(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
});
|
||||
if (errorMessage) { credDialogError = errorMessage; errorMessage = ""; }
|
||||
else { credDialogOpen = false; credDialogAction = null; }
|
||||
}
|
||||
|
||||
async function handleCredentialSubmit(username: string, password: string, save: boolean) {
|
||||
if (credDialogAction === "pull") await doActualPull(username, password);
|
||||
else if (credDialogAction === "push") await doActualPush(username, password);
|
||||
if (!credDialogOpen && save) sessionCredentials = { username, password };
|
||||
}
|
||||
|
||||
async function pullRepo() {
|
||||
if (!activeRepoPath) return;
|
||||
if (sessionCredentials) {
|
||||
await doActualPull(sessionCredentials.username, sessionCredentials.password);
|
||||
} else {
|
||||
openCredentialDialog("pull");
|
||||
}
|
||||
}
|
||||
|
||||
async function pushRepo() {
|
||||
if (!activeRepoPath) return;
|
||||
await runOperation("Pushing", async () => {
|
||||
applyStatus(await push(activeRepoPath));
|
||||
await refreshBranchList(activeRepoPath);
|
||||
await refreshCommitHistory(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
});
|
||||
if (sessionCredentials) {
|
||||
await doActualPush(sessionCredentials.username, sessionCredentials.password);
|
||||
} else {
|
||||
openCredentialDialog("push");
|
||||
}
|
||||
}
|
||||
|
||||
// ── File staging / restore ─────────────────────────────────────────────────
|
||||
@@ -697,6 +736,17 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<!-- Credential dialog for push/pull -->
|
||||
{#if credDialogOpen && credDialogAction}
|
||||
<CredentialDialog
|
||||
action={credDialogAction}
|
||||
error={credDialogError}
|
||||
{isBusy}
|
||||
onSubmit={handleCredentialSubmit}
|
||||
onCancel={() => { credDialogOpen = false; credDialogAction = null; credDialogError = ""; }}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<!-- Conflict resolve dialog -->
|
||||
{#if resolveDialogOpen}
|
||||
<ResolveDialog
|
||||
|
||||
Reference in New Issue
Block a user