mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
code_review: PR #428
* remove unused namespace using * remove the duplicated menu seperator between `Open in Merge Tool` and `Reveal in File Explorer` * keep the same menu item orders both in changes and revision files
This commit is contained in:
parent
62c3afb209
commit
ef9396bf57
1 changed files with 43 additions and 51 deletions
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -251,8 +250,6 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
public ContextMenu CreateChangeContextMenu(Models.Change change)
|
public ContextMenu CreateChangeContextMenu(Models.Change change)
|
||||||
{
|
{
|
||||||
var menu = new ContextMenu();
|
|
||||||
|
|
||||||
var diffWithMerger = new MenuItem();
|
var diffWithMerger = new MenuItem();
|
||||||
diffWithMerger.Header = App.Text("DiffWithMerger");
|
diffWithMerger.Header = App.Text("DiffWithMerger");
|
||||||
diffWithMerger.Icon = App.CreateMenuIcon("Icons.OpenWith");
|
diffWithMerger.Icon = App.CreateMenuIcon("Icons.OpenWith");
|
||||||
|
@ -265,25 +262,22 @@ namespace SourceGit.ViewModels
|
||||||
Task.Run(() => Commands.MergeTool.OpenForDiff(_repo.FullPath, toolType, toolPath, opt));
|
Task.Run(() => Commands.MergeTool.OpenForDiff(_repo.FullPath, toolType, toolPath, opt));
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
};
|
};
|
||||||
menu.Items.Add(diffWithMerger);
|
|
||||||
menu.Items.Add(new MenuItem { Header = "-" });
|
|
||||||
|
|
||||||
var fullPath = Path.Combine(_repo.FullPath, change.Path);
|
var fullPath = Path.Combine(_repo.FullPath, change.Path);
|
||||||
if (File.Exists(fullPath))
|
|
||||||
{
|
|
||||||
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.Click += (_, ev) =>
|
explore.Click += (_, ev) =>
|
||||||
{
|
{
|
||||||
Native.OS.OpenInFileManager(fullPath, true);
|
Native.OS.OpenInFileManager(fullPath, true);
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
menu.Items.Add(new MenuItem { Header = "-" });
|
var menu = new ContextMenu();
|
||||||
|
menu.Items.Add(diffWithMerger);
|
||||||
menu.Items.Add(explore);
|
menu.Items.Add(explore);
|
||||||
menu.Items.Add(new MenuItem { Header = "-" });
|
menu.Items.Add(new MenuItem { Header = "-" });
|
||||||
}
|
|
||||||
|
|
||||||
if (change.Index != Models.ChangeState.Deleted)
|
if (change.Index != Models.ChangeState.Deleted)
|
||||||
{
|
{
|
||||||
|
@ -328,13 +322,16 @@ namespace SourceGit.ViewModels
|
||||||
resetToFirstParent.Click += (_, ev) =>
|
resetToFirstParent.Click += (_, ev) =>
|
||||||
{
|
{
|
||||||
if (change.Index == Models.ChangeState.Renamed)
|
if (change.Index == Models.ChangeState.Renamed)
|
||||||
{
|
|
||||||
new Commands.Checkout(_repo.FullPath).FileWithRevision(change.OriginalPath, $"{_commit.SHA}~1");
|
new Commands.Checkout(_repo.FullPath).FileWithRevision(change.OriginalPath, $"{_commit.SHA}~1");
|
||||||
}
|
|
||||||
new Commands.Checkout(_repo.FullPath).FileWithRevision(change.Path, $"{_commit.SHA}~1");
|
new Commands.Checkout(_repo.FullPath).FileWithRevision(change.Path, $"{_commit.SHA}~1");
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
menu.Items.Add(resetToThisRevision);
|
||||||
|
menu.Items.Add(resetToFirstParent);
|
||||||
|
menu.Items.Add(new MenuItem { Header = "-" });
|
||||||
|
|
||||||
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");
|
||||||
|
@ -353,41 +350,14 @@ namespace SourceGit.ViewModels
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
menu.Items.Add(resetToThisRevision);
|
|
||||||
menu.Items.Add(resetToFirstParent);
|
|
||||||
menu.Items.Add(new MenuItem { Header = "-" });
|
|
||||||
menu.Items.Add(copyPath);
|
menu.Items.Add(copyPath);
|
||||||
menu.Items.Add(copyFileName);
|
menu.Items.Add(copyFileName);
|
||||||
|
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContextMenu CreateRevisionFileContextMenu(Models.Object file)
|
public ContextMenu CreateRevisionFileContextMenu(Models.Object file)
|
||||||
{
|
{
|
||||||
var fullPath = Path.Combine(_repo.FullPath, file.Path);
|
var fullPath = Path.Combine(_repo.FullPath, file.Path);
|
||||||
|
|
||||||
var resetToThisRevision = new MenuItem();
|
|
||||||
resetToThisRevision.Header = App.Text("ChangeCM.CheckoutThisRevision");
|
|
||||||
resetToThisRevision.Icon = App.CreateMenuIcon("Icons.File.Checkout");
|
|
||||||
resetToThisRevision.IsEnabled = File.Exists(fullPath);
|
|
||||||
resetToThisRevision.Click += (_, ev) =>
|
|
||||||
{
|
|
||||||
new Commands.Checkout(_repo.FullPath).FileWithRevision(file.Path, $"{_commit.SHA}");
|
|
||||||
ev.Handled = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
var resetToFirstParent = new MenuItem();
|
|
||||||
resetToFirstParent.Header = App.Text("ChangeCM.CheckoutFirstParentRevision");
|
|
||||||
resetToFirstParent.Icon = App.CreateMenuIcon("Icons.File.Checkout");
|
|
||||||
var fileInChanges = _changes.Find(x => x.Path == file.Path);
|
|
||||||
var fileIndex = fileInChanges?.Index;
|
|
||||||
resetToFirstParent.IsEnabled = _commit.Parents.Count > 0 && fileIndex != Models.ChangeState.Renamed;
|
|
||||||
resetToFirstParent.Click += (_, ev) =>
|
|
||||||
{
|
|
||||||
new Commands.Checkout(_repo.FullPath).FileWithRevision(file.Path, $"{_commit.SHA}~1");
|
|
||||||
ev.Handled = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
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");
|
||||||
|
@ -447,6 +417,28 @@ namespace SourceGit.ViewModels
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var resetToThisRevision = new MenuItem();
|
||||||
|
resetToThisRevision.Header = App.Text("ChangeCM.CheckoutThisRevision");
|
||||||
|
resetToThisRevision.Icon = App.CreateMenuIcon("Icons.File.Checkout");
|
||||||
|
resetToThisRevision.IsEnabled = File.Exists(fullPath);
|
||||||
|
resetToThisRevision.Click += (_, ev) =>
|
||||||
|
{
|
||||||
|
new Commands.Checkout(_repo.FullPath).FileWithRevision(file.Path, $"{_commit.SHA}");
|
||||||
|
ev.Handled = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
var resetToFirstParent = new MenuItem();
|
||||||
|
resetToFirstParent.Header = App.Text("ChangeCM.CheckoutFirstParentRevision");
|
||||||
|
resetToFirstParent.Icon = App.CreateMenuIcon("Icons.File.Checkout");
|
||||||
|
var fileInChanges = _changes.Find(x => x.Path == file.Path);
|
||||||
|
var fileIndex = fileInChanges?.Index;
|
||||||
|
resetToFirstParent.IsEnabled = _commit.Parents.Count > 0 && fileIndex != Models.ChangeState.Renamed;
|
||||||
|
resetToFirstParent.Click += (_, ev) =>
|
||||||
|
{
|
||||||
|
new Commands.Checkout(_repo.FullPath).FileWithRevision(file.Path, $"{_commit.SHA}~1");
|
||||||
|
ev.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");
|
||||||
|
@ -466,15 +458,15 @@ namespace SourceGit.ViewModels
|
||||||
};
|
};
|
||||||
|
|
||||||
var menu = new ContextMenu();
|
var menu = new ContextMenu();
|
||||||
menu.Items.Add(resetToThisRevision);
|
|
||||||
menu.Items.Add(resetToFirstParent);
|
|
||||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
|
||||||
menu.Items.Add(explore);
|
menu.Items.Add(explore);
|
||||||
menu.Items.Add(saveAs);
|
menu.Items.Add(saveAs);
|
||||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
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 = "-" });
|
||||||
|
menu.Items.Add(resetToThisRevision);
|
||||||
|
menu.Items.Add(resetToFirstParent);
|
||||||
|
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||||
menu.Items.Add(copyPath);
|
menu.Items.Add(copyPath);
|
||||||
menu.Items.Add(copyFileName);
|
menu.Items.Add(copyFileName);
|
||||||
return menu;
|
return menu;
|
||||||
|
|
Loading…
Reference in a new issue