mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
feature: embed commit detail page in file histories
This commit is contained in:
parent
e443e1657b
commit
6d2e10cec2
3 changed files with 35 additions and 20 deletions
|
@ -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<Models.Commit> _commits = null;
|
||||
private Models.Commit _selectedCommit = null;
|
||||
private DiffContext _diffContext = null;
|
||||
private CommitDetail _detailContext = null;
|
||||
}
|
||||
}
|
|
@ -89,7 +89,7 @@
|
|||
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto,Auto">
|
||||
<v:Avatar Grid.Column="0" Width="16" Height="16" VerticalAlignment="Center" IsHitTestVisible="False" User="{Binding Author}"/>
|
||||
<TextBlock Grid.Column="1" Classes="monospace" Text="{Binding Author.Name}" Margin="8,0,0,0"/>
|
||||
<TextBlock Grid.Column="2" Classes="monospace" Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}" Foreground="DarkOrange" Margin="8,0,0,0" TextDecorations="Underline" Cursor="Hand" PointerPressed="OnPressedSHA"/>
|
||||
<TextBlock Grid.Column="2" Classes="monospace" Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}" Foreground="DarkOrange" Margin="8,0,0,0" TextDecorations="Underline" Cursor="Hand"/>
|
||||
<TextBlock Grid.Column="3" Classes="monospace" Text="{Binding AuthorTimeShortStr}" Foreground="{DynamicResource Brush.FG2}" Margin="8,0,0,0"/>
|
||||
</Grid>
|
||||
|
||||
|
@ -109,14 +109,36 @@
|
|||
BorderThickness="1,0,0,0"
|
||||
BorderBrush="{DynamicResource Brush.Border2}"/>
|
||||
|
||||
<Grid Grid.Column="2">
|
||||
<ContentControl Margin="0,4,4,4" Content="{Binding DiffContext}">
|
||||
<Grid Grid.Column="2" RowDefinitions="*,3,*" Margin="0,4,4,4">
|
||||
<ContentControl Grid.Row="0" Content="{Binding DiffContext}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="vm:DiffContext">
|
||||
<v:DiffView/>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
|
||||
<GridSplitter Grid.Row="1"
|
||||
MinHeight="1"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||
Background="Transparent"/>
|
||||
|
||||
<Grid Grid.Row="2">
|
||||
<Border Background="{DynamicResource Brush.Window}">
|
||||
<Path Width="128" Height="128"
|
||||
Data="{StaticResource Icons.Detail}"
|
||||
HorizontalAlignment="Center"
|
||||
Fill="{DynamicResource Brush.FG2}"/>
|
||||
</Border>
|
||||
|
||||
<ContentControl Content="{Binding DetailContext}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="vm:CommitDetail">
|
||||
<v:CommitDetail/>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue