mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
enhance: add file histories context menu item for staged changes and deleted files (#432)
This commit is contained in:
parent
b0b55c989a
commit
a2c6afc5cc
2 changed files with 37 additions and 28 deletions
|
@ -267,20 +267,13 @@ namespace SourceGit.ViewModels
|
||||||
var explore = new MenuItem();
|
var explore = new MenuItem();
|
||||||
explore.Header = App.Text("RevealFile");
|
explore.Header = App.Text("RevealFile");
|
||||||
explore.Icon = App.CreateMenuIcon("Icons.Explore");
|
explore.Icon = App.CreateMenuIcon("Icons.Explore");
|
||||||
explore.IsVisible = File.Exists(fullPath);
|
explore.IsEnabled = File.Exists(fullPath);
|
||||||
explore.Click += (_, ev) =>
|
explore.Click += (_, ev) =>
|
||||||
{
|
{
|
||||||
Native.OS.OpenInFileManager(fullPath, true);
|
Native.OS.OpenInFileManager(fullPath, true);
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var menu = new ContextMenu();
|
|
||||||
menu.Items.Add(diffWithMerger);
|
|
||||||
menu.Items.Add(explore);
|
|
||||||
menu.Items.Add(new MenuItem { Header = "-" });
|
|
||||||
|
|
||||||
if (change.Index != Models.ChangeState.Deleted)
|
|
||||||
{
|
|
||||||
var history = new MenuItem();
|
var history = new MenuItem();
|
||||||
history.Header = App.Text("FileHistory");
|
history.Header = App.Text("FileHistory");
|
||||||
history.Icon = App.CreateMenuIcon("Icons.Histories");
|
history.Icon = App.CreateMenuIcon("Icons.Histories");
|
||||||
|
@ -294,6 +287,7 @@ namespace SourceGit.ViewModels
|
||||||
var blame = new MenuItem();
|
var blame = new MenuItem();
|
||||||
blame.Header = App.Text("Blame");
|
blame.Header = App.Text("Blame");
|
||||||
blame.Icon = App.CreateMenuIcon("Icons.Blame");
|
blame.Icon = App.CreateMenuIcon("Icons.Blame");
|
||||||
|
blame.IsEnabled = change.Index != Models.ChangeState.Deleted;
|
||||||
blame.Click += (_, ev) =>
|
blame.Click += (_, ev) =>
|
||||||
{
|
{
|
||||||
var window = new Views.Blame() { DataContext = new Blame(_repo.FullPath, change.Path, _commit.SHA) };
|
var window = new Views.Blame() { DataContext = new Blame(_repo.FullPath, change.Path, _commit.SHA) };
|
||||||
|
@ -301,10 +295,13 @@ namespace SourceGit.ViewModels
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var menu = new ContextMenu();
|
||||||
|
menu.Items.Add(diffWithMerger);
|
||||||
|
menu.Items.Add(explore);
|
||||||
|
menu.Items.Add(new MenuItem { Header = "-" });
|
||||||
menu.Items.Add(history);
|
menu.Items.Add(history);
|
||||||
menu.Items.Add(blame);
|
menu.Items.Add(blame);
|
||||||
menu.Items.Add(new MenuItem { Header = "-" });
|
menu.Items.Add(new MenuItem { Header = "-" });
|
||||||
}
|
|
||||||
|
|
||||||
var resetToThisRevision = new MenuItem();
|
var resetToThisRevision = new MenuItem();
|
||||||
resetToThisRevision.Header = App.Text("ChangeCM.CheckoutThisRevision");
|
resetToThisRevision.Header = App.Text("ChangeCM.CheckoutThisRevision");
|
||||||
|
|
|
@ -952,6 +952,16 @@ namespace SourceGit.ViewModels
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var history = new MenuItem();
|
||||||
|
history.Header = App.Text("FileHistory");
|
||||||
|
history.Icon = App.CreateMenuIcon("Icons.Histories");
|
||||||
|
history.Click += (_, e) =>
|
||||||
|
{
|
||||||
|
var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, change.Path) };
|
||||||
|
window.Show();
|
||||||
|
e.Handled = true;
|
||||||
|
};
|
||||||
|
|
||||||
var copyPath = new MenuItem();
|
var copyPath = new MenuItem();
|
||||||
copyPath.Header = App.Text("CopyPath");
|
copyPath.Header = App.Text("CopyPath");
|
||||||
copyPath.Icon = App.CreateMenuIcon("Icons.Copy");
|
copyPath.Icon = App.CreateMenuIcon("Icons.Copy");
|
||||||
|
@ -977,6 +987,8 @@ namespace SourceGit.ViewModels
|
||||||
menu.Items.Add(stash);
|
menu.Items.Add(stash);
|
||||||
menu.Items.Add(patch);
|
menu.Items.Add(patch);
|
||||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||||
|
menu.Items.Add(history);
|
||||||
|
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||||
|
|
||||||
var lfsEnabled = new Commands.LFS(_repo.FullPath).IsEnabled();
|
var lfsEnabled = new Commands.LFS(_repo.FullPath).IsEnabled();
|
||||||
if (lfsEnabled)
|
if (lfsEnabled)
|
||||||
|
|
Loading…
Reference in a new issue