From 24b61532266db654185e4622d5ec4075fcb9f2b2 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 13 Dec 2024 16:00:41 +0800 Subject: [PATCH] ux: context menu of selected commits * update English translation * re-order the menu items --- src/Resources/Locales/en_US.axaml | 8 ++-- src/ViewModels/Histories.cs | 75 ++++++++++++++++--------------- 2 files changed, 43 insertions(+), 40 deletions(-) diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 2eb38873..65b4dd96 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -102,7 +102,7 @@ Repository URL: CLOSE Editor - Cherry-Pick This Commit + Cherry-Pick Commit Cherry-Pick ... Checkout Commit Compare with HEAD @@ -110,16 +110,16 @@ Copy Info Copy SHA Custom Action - Interactive Rebase ${0}$ to Here + Interactively Rebase ${0}$ on Here Merge to ${0}$ Merge ... - Rebase ${0}$ to Here + Rebase ${0}$ on Here Reset ${0}$ to Here Revert Commit Reword Save as Patch... Squash into Parent - Squash Child Commits to Here + Squash Children into Here CHANGES Search Changes... FILES diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index 8f1e2662..10cb0499 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -482,6 +482,21 @@ namespace SourceGit.ViewModels }; menu.Items.Add(rebase); + if (!commit.HasDecorators) + { + var merge = new MenuItem(); + merge.Header = new Views.NameHighlightedTextBlock("CommitCM.Merge", current.Name); + merge.Icon = App.CreateMenuIcon("Icons.Merge"); + merge.Click += (_, e) => + { + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Merge(_repo, commit, current.Name)); + + e.Handled = true; + }; + menu.Items.Add(merge); + } + var cherryPick = new MenuItem(); cherryPick.Header = App.Text("CommitCM.CherryPick"); cherryPick.Icon = App.CreateMenuIcon("Icons.CherryPick"); @@ -513,21 +528,6 @@ namespace SourceGit.ViewModels e.Handled = true; }; menu.Items.Add(cherryPick); - - if (!commit.HasDecorators) - { - var merge = new MenuItem(); - merge.Header = new Views.NameHighlightedTextBlock("CommitCM.Merge", current.Name); - merge.Icon = App.CreateMenuIcon("Icons.Merge"); - merge.Click += (_, e) => - { - if (PopupHost.CanCreatePopup()) - PopupHost.ShowPopup(new Merge(_repo, commit, current.Name)); - - e.Handled = true; - }; - menu.Items.Add(merge); - } } else { @@ -541,27 +541,6 @@ namespace SourceGit.ViewModels e.Handled = true; }; menu.Items.Add(revert); - - var interactiveRebase = new MenuItem(); - interactiveRebase.Header = new Views.NameHighlightedTextBlock("CommitCM.InteractiveRebase", current.Name); - interactiveRebase.Icon = App.CreateMenuIcon("Icons.InteractiveRebase"); - interactiveRebase.IsVisible = current.Head != commit.SHA; - interactiveRebase.Click += (_, e) => - { - if (_repo.LocalChangesCount > 0) - { - App.RaiseException(_repo.FullPath, "You have local changes. Please run stash or discard first."); - return; - } - - App.OpenDialog(new Views.InteractiveRebase() - { - DataContext = new InteractiveRebase(_repo, current, commit) - }); - - e.Handled = true; - }; - menu.Items.Add(interactiveRebase); } if (current.Head != commit.SHA) @@ -580,6 +559,30 @@ namespace SourceGit.ViewModels menu.Items.Add(new MenuItem() { Header = "-" }); + if (commit.IsMerged && current.Head != commit.SHA) + { + var interactiveRebase = new MenuItem(); + interactiveRebase.Header = new Views.NameHighlightedTextBlock("CommitCM.InteractiveRebase", current.Name); + interactiveRebase.Icon = App.CreateMenuIcon("Icons.InteractiveRebase"); + interactiveRebase.Click += (_, e) => + { + if (_repo.LocalChangesCount > 0) + { + App.RaiseException(_repo.FullPath, "You have local changes. Please run stash or discard first."); + return; + } + + App.OpenDialog(new Views.InteractiveRebase() + { + DataContext = new InteractiveRebase(_repo, current, commit) + }); + + e.Handled = true; + }; + menu.Items.Add(interactiveRebase); + menu.Items.Add(new MenuItem() { Header = "-" }); + } + if (current.Head != commit.SHA) { var compareWithHead = new MenuItem();