mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
ux: re-design submodule preview in revision files
This commit is contained in:
parent
e17e4b9a53
commit
a168b05ac6
6 changed files with 38 additions and 17 deletions
|
@ -587,16 +587,10 @@ namespace SourceGit.Models
|
|||
public string New { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class SubmoduleRevision
|
||||
{
|
||||
public Commit Commit { get; set; } = null;
|
||||
public string FullMessage { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class SubmoduleDiff
|
||||
{
|
||||
public SubmoduleRevision Old { get; set; } = null;
|
||||
public SubmoduleRevision New { get; set; } = null;
|
||||
public RevisionSubmodule Old { get; set; } = null;
|
||||
public RevisionSubmodule New { get; set; } = null;
|
||||
}
|
||||
|
||||
public class DiffResult
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace SourceGit.Models
|
|||
|
||||
public class RevisionSubmodule
|
||||
{
|
||||
public string SHA { get; set; }
|
||||
public Commit Commit { get; set; } = null;
|
||||
public string FullMessage { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,7 +201,34 @@ namespace SourceGit.ViewModels
|
|||
});
|
||||
break;
|
||||
case Models.ObjectType.Commit:
|
||||
ViewRevisionFileContent = new Models.RevisionSubmodule() { SHA = file.SHA };
|
||||
Task.Run(() =>
|
||||
{
|
||||
var submoduleRoot = Path.Combine(_repo, file.Path);
|
||||
var commit = new Commands.QuerySingleCommit(submoduleRoot, file.SHA).Result();
|
||||
if (commit != null)
|
||||
{
|
||||
var body = new Commands.QueryCommitFullMessage(submoduleRoot, file.SHA).Result();
|
||||
Dispatcher.UIThread.Invoke(() =>
|
||||
{
|
||||
ViewRevisionFileContent = new Models.RevisionSubmodule()
|
||||
{
|
||||
Commit = commit,
|
||||
FullMessage = body,
|
||||
};
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Dispatcher.UIThread.Invoke(() =>
|
||||
{
|
||||
ViewRevisionFileContent = new Models.RevisionSubmodule()
|
||||
{
|
||||
Commit = new Models.Commit() { SHA = file.SHA },
|
||||
FullMessage = string.Empty,
|
||||
};
|
||||
});
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
ViewRevisionFileContent = null;
|
||||
|
|
|
@ -210,16 +210,16 @@ namespace SourceGit.ViewModels
|
|||
return size > 0 ? (new Bitmap(stream), size) : (null, size);
|
||||
}
|
||||
|
||||
private Models.SubmoduleRevision QuerySubmoduleRevision(string repo, string sha)
|
||||
private Models.RevisionSubmodule QuerySubmoduleRevision(string repo, string sha)
|
||||
{
|
||||
var commit = new Commands.QuerySingleCommit(repo, sha).Result();
|
||||
if (commit != null)
|
||||
{
|
||||
var body = new Commands.QueryCommitFullMessage(repo, sha).Result();
|
||||
return new Models.SubmoduleRevision() { Commit = commit, FullMessage = body };
|
||||
return new Models.RevisionSubmodule() { Commit = commit, FullMessage = body };
|
||||
}
|
||||
|
||||
return new Models.SubmoduleRevision()
|
||||
return new Models.RevisionSubmodule()
|
||||
{
|
||||
Commit = new Models.Commit() { SHA = sha },
|
||||
FullMessage = string.Empty,
|
||||
|
|
|
@ -151,7 +151,7 @@
|
|||
<Border IsVisible="{Binding Old, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<ContentControl Content="{Binding Old}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="m:SubmoduleRevision">
|
||||
<DataTemplate DataType="m:RevisionSubmodule">
|
||||
<Border Margin="0,0,0,8" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}" Background="{DynamicResource Brush.Window}">
|
||||
<v:CommitBaseInfo MaxHeight="256" Margin="0,0,0,4" CanNavigate="False" Content="{Binding Commit}" Message="{Binding FullMessage}"/>
|
||||
</Border>
|
||||
|
|
|
@ -78,10 +78,9 @@
|
|||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="m:RevisionSubmodule">
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" Margin="8,8,8,0">
|
||||
<TextBlock Text="{DynamicResource Text.CommitDetail.Files.Submodule}" FontSize="18" FontWeight="Bold" HorizontalAlignment="Center" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
<Path Width="64" Height="64" Margin="0,16,0,0" Data="{StaticResource Icons.Submodule}" Fill="{DynamicResource Brush.FG2}"/>
|
||||
<SelectableTextBlock Margin="0,16,0,0" Text="{Binding SHA}" HorizontalAlignment="Center" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
<v:CommitBaseInfo Margin="0,16,0,0" CanNavigate="False" Content="{Binding Commit}" Message="{Binding FullMessage}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
|
|
Loading…
Reference in a new issue