add Repo Managment / Kontext Menu in Braches
This commit is contained in:
+61
-1
@@ -16,6 +16,7 @@
|
||||
import HistoryPanel from "./lib/components/HistoryPanel.svelte";
|
||||
import LinePatchDialog from "./lib/components/LinePatchDialog.svelte";
|
||||
import NewBranchDialog from "./lib/components/NewBranchDialog.svelte";
|
||||
import RenameBranchDialog from "./lib/components/RenameBranchDialog.svelte";
|
||||
import RepoLoadingOverlay from "./lib/components/RepoLoadingOverlay.svelte";
|
||||
import ResolveDialog from "./lib/components/ResolveDialog.svelte";
|
||||
import StatusPanel from "./lib/components/StatusPanel.svelte";
|
||||
@@ -28,6 +29,7 @@
|
||||
cancelCodeSearch,
|
||||
applyFilePatch,
|
||||
createBranch,
|
||||
deleteBranch,
|
||||
diffFileAgainstWorkingTree,
|
||||
compareFileToParent,
|
||||
getStatus,
|
||||
@@ -40,6 +42,7 @@
|
||||
openRepositoryBundle,
|
||||
pull,
|
||||
push,
|
||||
renameBranch,
|
||||
getRemoteUrl,
|
||||
credLoad,
|
||||
credSave,
|
||||
@@ -121,6 +124,7 @@
|
||||
let compareTo = "";
|
||||
let comparison: GitCommitComparison | null = null;
|
||||
let newBranchCommit: GitCommit | null = null;
|
||||
let renameBranchTarget: GitBranchInfo | null = null;
|
||||
let compareSelectOpen = false;
|
||||
let compareDialogOpen = false;
|
||||
let selectedDiffPath = "";
|
||||
@@ -662,6 +666,45 @@
|
||||
});
|
||||
}
|
||||
|
||||
function renameLocalBranch(branch: GitBranchInfo) {
|
||||
if (!activeRepoPath || branch.remote) return;
|
||||
renameBranchTarget = branch;
|
||||
}
|
||||
|
||||
async function submitRenameBranch(branchName: string) {
|
||||
const branch = renameBranchTarget;
|
||||
const name = branchName.trim();
|
||||
if (!activeRepoPath || !branch || branch.remote || !name || name === branch.name) return;
|
||||
|
||||
await runOperation(`Renaming ${branch.name}`, async () => {
|
||||
applyStatus(await renameBranch(activeRepoPath, branch.name, name));
|
||||
renameBranchTarget = null;
|
||||
await refreshBranchList(activeRepoPath);
|
||||
await refreshCommitHistory(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteLocalBranch(branch: GitBranchInfo) {
|
||||
if (!activeRepoPath || branch.remote) return;
|
||||
if (branch.current) {
|
||||
errorMessage = "The current branch cannot be deleted.";
|
||||
return;
|
||||
}
|
||||
|
||||
const confirmed = window.confirm(`Delete local branch "${branch.name}"?\n\nGit will refuse if the branch has unmerged changes.`);
|
||||
if (!confirmed) return;
|
||||
|
||||
await runOperation(`Deleting ${branch.name}`, async () => {
|
||||
applyStatus(await deleteBranch(activeRepoPath, branch.name));
|
||||
await refreshBranchList(activeRepoPath);
|
||||
await refreshCommitHistory(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
});
|
||||
}
|
||||
|
||||
function openNewBranchDialog(commit: GitCommit) {
|
||||
if (!activeRepoPath || isBusy) return;
|
||||
newBranchCommit = commit;
|
||||
@@ -1271,16 +1314,21 @@
|
||||
function handleWindowKeydown(event: KeyboardEvent) {
|
||||
if (event.key === "Escape" && compareDialogOpen) closeCompareDialog();
|
||||
else if (event.key === "Escape" && newBranchCommit) newBranchCommit = null;
|
||||
else if (event.key === "Escape" && renameBranchTarget) renameBranchTarget = null;
|
||||
else if (event.key === "Escape" && compareSelectOpen) compareSelectOpen = false;
|
||||
else if (event.key === "Escape" && globalSearchOpen) closeGlobalSearchDialog();
|
||||
}
|
||||
|
||||
function handleWindowContextMenu(event: MouseEvent) {
|
||||
event.preventDefault();
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>GitLite</title>
|
||||
</svelte:head>
|
||||
|
||||
<svelte:window on:keydown={handleWindowKeydown} />
|
||||
<svelte:window on:keydown={handleWindowKeydown} on:contextmenu={handleWindowContextMenu} />
|
||||
|
||||
<main class="shell">
|
||||
<TitleBar
|
||||
@@ -1509,6 +1557,8 @@
|
||||
onCheckout={checkout}
|
||||
onMerge={merge}
|
||||
onCreateBranch={createNewBranch}
|
||||
onRenameBranch={renameLocalBranch}
|
||||
onDeleteBranch={deleteLocalBranch}
|
||||
/>
|
||||
<ExplorerPanel
|
||||
{repoFiles}
|
||||
@@ -1658,6 +1708,16 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<!-- Rename a local branch from the branch context menu -->
|
||||
{#if renameBranchTarget}
|
||||
<RenameBranchDialog
|
||||
branch={renameBranchTarget}
|
||||
{isBusy}
|
||||
onRename={submitRenameBranch}
|
||||
onClose={() => { renameBranchTarget = null; }}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<!-- Compare: pick the two commits to diff -->
|
||||
{#if compareSelectOpen}
|
||||
<CompareSelectDialog
|
||||
|
||||
Reference in New Issue
Block a user