From 5f583e51462b04b8925c705d8f38482322ee1501 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 15 Jan 2021 09:53:58 +0800 Subject: [PATCH] optimize: auto disable some context menu actions when the branch is at the same point with its upstream --- src/UI/Dashboard.xaml.cs | 3 +++ src/UI/Histories.xaml.cs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/UI/Dashboard.xaml.cs b/src/UI/Dashboard.xaml.cs index 2bc1b05f..e47eeb3b 100644 --- a/src/UI/Dashboard.xaml.cs +++ b/src/UI/Dashboard.xaml.cs @@ -594,6 +594,7 @@ namespace SourceGit.UI { var push = new MenuItem(); push.Header = App.Format("BranchCM.Push", branch.Name); + push.IsEnabled = !string.IsNullOrEmpty(branch.UpstreamTrack); push.Click += (o, e) => { Push.Show(repo, branch); e.Handled = true; @@ -613,6 +614,7 @@ namespace SourceGit.UI { var upstream = branch.Upstream.Substring(13); var fastForward = new MenuItem(); fastForward.Header = App.Format("BranchCM.FastForward", upstream); + fastForward.IsEnabled = !string.IsNullOrEmpty(branch.UpstreamTrack); fastForward.Click += (o, e) => { Merge.StartDirectly(repo, upstream, branch.Name); e.Handled = true; @@ -620,6 +622,7 @@ namespace SourceGit.UI { var pull = new MenuItem(); pull.Header = App.Format("BranchCM.Pull", upstream); + pull.IsEnabled = !string.IsNullOrEmpty(branch.UpstreamTrack); pull.Click += (o, e) => { Pull.Show(repo); e.Handled = true; diff --git a/src/UI/Histories.xaml.cs b/src/UI/Histories.xaml.cs index 8ac0f227..4114677c 100644 --- a/src/UI/Histories.xaml.cs +++ b/src/UI/Histories.xaml.cs @@ -227,6 +227,7 @@ namespace SourceGit.UI { var upstream = branch.Upstream.Substring(13); var fastForward = new MenuItem(); fastForward.Header = App.Format("BranchCM.FastForward", upstream); + fastForward.IsEnabled = !string.IsNullOrEmpty(branch.UpstreamTrack); fastForward.Click += (o, e) => { Merge.StartDirectly(Repo, upstream, branch.Name); e.Handled = true; @@ -235,6 +236,7 @@ namespace SourceGit.UI { var pull = new MenuItem(); pull.Header = App.Format("BranchCM.Pull", upstream); + pull.IsEnabled = !string.IsNullOrEmpty(branch.UpstreamTrack); pull.Click += (o, e) => { Pull.Show(Repo); e.Handled = true; @@ -244,6 +246,7 @@ namespace SourceGit.UI { var push = new MenuItem(); push.Header = App.Format("BranchCM.Push", branch.Name); + push.IsEnabled = !string.IsNullOrEmpty(branch.UpstreamTrack); push.Click += (o, e) => { Push.Show(Repo, branch); e.Handled = true;