mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
ux: show Unset
menu item only if it is necessary (#690)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
04697093a8
commit
28c93da73b
1 changed files with 35 additions and 38 deletions
|
@ -71,20 +71,26 @@ namespace SourceGit.Views
|
|||
if (button == null)
|
||||
return;
|
||||
|
||||
var menu = new ContextMenu();
|
||||
var mode = Models.FilterMode.None;
|
||||
if (DataContext is Models.Tag tag)
|
||||
{
|
||||
var mode = tag.FilterMode;
|
||||
mode = tag.FilterMode;
|
||||
|
||||
var none = new MenuItem();
|
||||
none.Icon = App.CreateMenuIcon("Icons.Eye");
|
||||
none.Header = App.Text("Repository.FilterCommits.Default");
|
||||
none.IsEnabled = mode != Models.FilterMode.None;
|
||||
none.Click += (_, ev) =>
|
||||
if (mode != Models.FilterMode.None)
|
||||
{
|
||||
var unset = new MenuItem();
|
||||
unset.Header = App.Text("Repository.FilterCommits.Default");
|
||||
unset.Click += (_, ev) =>
|
||||
{
|
||||
UpdateTagFilterMode(repo, tag, Models.FilterMode.None);
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
menu.Items.Add(unset);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
}
|
||||
|
||||
var include = new MenuItem();
|
||||
include.Icon = App.CreateMenuIcon("Icons.Filter");
|
||||
include.Header = App.Text("Repository.FilterCommits.Include");
|
||||
|
@ -105,33 +111,27 @@ namespace SourceGit.Views
|
|||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var menu = new ContextMenu();
|
||||
menu.Items.Add(none);
|
||||
menu.Items.Add(include);
|
||||
menu.Items.Add(exclude);
|
||||
|
||||
if (mode == Models.FilterMode.None)
|
||||
{
|
||||
IsContextMenuOpening = true;
|
||||
menu.Closed += (_, _) => IsContextMenuOpening = false;
|
||||
}
|
||||
|
||||
menu.Open(button);
|
||||
}
|
||||
else if (DataContext is ViewModels.BranchTreeNode node)
|
||||
{
|
||||
var mode = node.FilterMode;
|
||||
mode = node.FilterMode;
|
||||
|
||||
var none = new MenuItem();
|
||||
none.Icon = App.CreateMenuIcon("Icons.Eye");
|
||||
none.Header = App.Text("Repository.FilterCommits.Default");
|
||||
none.IsEnabled = mode != Models.FilterMode.None;
|
||||
none.Click += (_, ev) =>
|
||||
if (mode != Models.FilterMode.None)
|
||||
{
|
||||
var unset = new MenuItem();
|
||||
unset.Header = App.Text("Repository.FilterCommits.Default");
|
||||
unset.Click += (_, ev) =>
|
||||
{
|
||||
UpdateBranchFilterMode(repo, node, Models.FilterMode.None);
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
menu.Items.Add(unset);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
}
|
||||
|
||||
var include = new MenuItem();
|
||||
include.Icon = App.CreateMenuIcon("Icons.Filter");
|
||||
include.Header = App.Text("Repository.FilterCommits.Include");
|
||||
|
@ -152,10 +152,9 @@ namespace SourceGit.Views
|
|||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var menu = new ContextMenu();
|
||||
menu.Items.Add(none);
|
||||
menu.Items.Add(include);
|
||||
menu.Items.Add(exclude);
|
||||
}
|
||||
|
||||
if (mode == Models.FilterMode.None)
|
||||
{
|
||||
|
@ -164,8 +163,6 @@ namespace SourceGit.Views
|
|||
}
|
||||
|
||||
menu.Open(button);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue