From 6d2e10cec20f344cefb2dedd9318c898b1301dcb Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 26 Mar 2024 15:56:38 +0800 Subject: [PATCH] feature: embed commit detail page in file histories --- src/SourceGit/ViewModels/FileHistories.cs | 16 ++++++++----- src/SourceGit/Views/FileHistories.axaml | 28 +++++++++++++++++++--- src/SourceGit/Views/FileHistories.axaml.cs | 11 --------- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/SourceGit/ViewModels/FileHistories.cs b/src/SourceGit/ViewModels/FileHistories.cs index 0b5653f5..c9cfe3fb 100644 --- a/src/SourceGit/ViewModels/FileHistories.cs +++ b/src/SourceGit/ViewModels/FileHistories.cs @@ -36,10 +36,12 @@ namespace SourceGit.ViewModels if (value == null) { DiffContext = null; + DetailContext.Commit = null; } else { DiffContext = new DiffContext(_repo, new Models.DiffOption(value, _file), _diffContext); + DetailContext.Commit = value; } } } @@ -51,10 +53,17 @@ namespace SourceGit.ViewModels set => SetProperty(ref _diffContext, value); } + public CommitDetail DetailContext + { + get => _detailContext; + set => SetProperty(ref _detailContext, value); + } + public FileHistories(string repo, string file) { _repo = repo; _file = file; + _detailContext = new CommitDetail(repo); Task.Run(() => { @@ -68,17 +77,12 @@ namespace SourceGit.ViewModels }); } - public void NavigateToCommit(string commitSHA) - { - var repo = Preference.FindRepository(_repo); - if (repo != null) repo.NavigateToCommit(commitSHA); - } - private readonly string _repo = string.Empty; private readonly string _file = string.Empty; private bool _isLoading = true; private List _commits = null; private Models.Commit _selectedCommit = null; private DiffContext _diffContext = null; + private CommitDetail _detailContext = null; } } \ No newline at end of file diff --git a/src/SourceGit/Views/FileHistories.axaml b/src/SourceGit/Views/FileHistories.axaml index 37a4d69f..72d581e3 100644 --- a/src/SourceGit/Views/FileHistories.axaml +++ b/src/SourceGit/Views/FileHistories.axaml @@ -89,7 +89,7 @@ - + @@ -109,14 +109,36 @@ BorderThickness="1,0,0,0" BorderBrush="{DynamicResource Brush.Border2}"/> - - + + + + + + + + + + + + + + + + + + diff --git a/src/SourceGit/Views/FileHistories.axaml.cs b/src/SourceGit/Views/FileHistories.axaml.cs index 7e7278f7..ab9d13cb 100644 --- a/src/SourceGit/Views/FileHistories.axaml.cs +++ b/src/SourceGit/Views/FileHistories.axaml.cs @@ -38,16 +38,5 @@ namespace SourceGit.Views { BeginMoveDrag(e); } - - private void OnPressedSHA(object sender, PointerPressedEventArgs e) - { - if (sender is TextBlock block) - { - var histories = DataContext as ViewModels.FileHistories; - histories.NavigateToCommit(block.Text); - } - - e.Handled = true; - } } } \ No newline at end of file