feature: supports filter displayed branches

This commit is contained in:
leo 2024-05-14 11:47:56 +08:00
parent 17e48d86fe
commit 02e71d4d75
6 changed files with 121 additions and 43 deletions

View file

@ -342,6 +342,7 @@
<x:String x:Key="Text.Repository.Configure" xml:space="preserve">Configure this repository</x:String> <x:String x:Key="Text.Repository.Configure" xml:space="preserve">Configure this repository</x:String>
<x:String x:Key="Text.Repository.Continue" xml:space="preserve">CONTINUE</x:String> <x:String x:Key="Text.Repository.Continue" xml:space="preserve">CONTINUE</x:String>
<x:String x:Key="Text.Repository.Explore" xml:space="preserve">Open In File Browser</x:String> <x:String x:Key="Text.Repository.Explore" xml:space="preserve">Open In File Browser</x:String>
<x:String x:Key="Text.Repository.FilterBranchTip" xml:space="preserve">Filter Branches</x:String>
<x:String x:Key="Text.Repository.LocalBranches" xml:space="preserve">LOCAL BRANCHES</x:String> <x:String x:Key="Text.Repository.LocalBranches" xml:space="preserve">LOCAL BRANCHES</x:String>
<x:String x:Key="Text.Repository.NavigateToCurrentHead" xml:space="preserve">Navigate To HEAD</x:String> <x:String x:Key="Text.Repository.NavigateToCurrentHead" xml:space="preserve">Navigate To HEAD</x:String>
<x:String x:Key="Text.Repository.NewBranch" xml:space="preserve">Create Branch</x:String> <x:String x:Key="Text.Repository.NewBranch" xml:space="preserve">Create Branch</x:String>

View file

@ -342,6 +342,7 @@
<x:String x:Key="Text.Repository.Configure" xml:space="preserve">配置本仓库</x:String> <x:String x:Key="Text.Repository.Configure" xml:space="preserve">配置本仓库</x:String>
<x:String x:Key="Text.Repository.Continue" xml:space="preserve">下一步</x:String> <x:String x:Key="Text.Repository.Continue" xml:space="preserve">下一步</x:String>
<x:String x:Key="Text.Repository.Explore" xml:space="preserve">在文件浏览器中打开</x:String> <x:String x:Key="Text.Repository.Explore" xml:space="preserve">在文件浏览器中打开</x:String>
<x:String x:Key="Text.Repository.FilterBranchTip" xml:space="preserve">过滤显示分支</x:String>
<x:String x:Key="Text.Repository.LocalBranches" xml:space="preserve">本地分支</x:String> <x:String x:Key="Text.Repository.LocalBranches" xml:space="preserve">本地分支</x:String>
<x:String x:Key="Text.Repository.NavigateToCurrentHead" xml:space="preserve">定位HEAD</x:String> <x:String x:Key="Text.Repository.NavigateToCurrentHead" xml:space="preserve">定位HEAD</x:String>
<x:String x:Key="Text.Repository.NewBranch" xml:space="preserve">新建分支</x:String> <x:String x:Key="Text.Repository.NewBranch" xml:space="preserve">新建分支</x:String>

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using Avalonia.Collections; using Avalonia.Collections;
namespace SourceGit.Models namespace SourceGit.ViewModels
{ {
public enum BranchTreeNodeType public enum BranchTreeNodeType
{ {
@ -23,12 +23,12 @@ namespace SourceGit.Models
public bool IsUpstreamTrackStatusVisible public bool IsUpstreamTrackStatusVisible
{ {
get => IsBranch && !string.IsNullOrEmpty((Backend as Branch).UpstreamTrackStatus); get => IsBranch && !string.IsNullOrEmpty((Backend as Models.Branch).UpstreamTrackStatus);
} }
public string UpstreamTrackStatus public string UpstreamTrackStatus
{ {
get => Type == BranchTreeNodeType.Branch ? (Backend as Branch).UpstreamTrackStatus : ""; get => Type == BranchTreeNodeType.Branch ? (Backend as Models.Branch).UpstreamTrackStatus : "";
} }
public bool IsRemote public bool IsRemote
@ -48,7 +48,7 @@ namespace SourceGit.Models
public bool IsCurrent public bool IsCurrent
{ {
get => IsBranch && (Backend as Branch).IsCurrent; get => IsBranch && (Backend as Models.Branch).IsCurrent;
} }
public class Builder public class Builder
@ -56,7 +56,7 @@ namespace SourceGit.Models
public List<BranchTreeNode> Locals => _locals; public List<BranchTreeNode> Locals => _locals;
public List<BranchTreeNode> Remotes => _remotes; public List<BranchTreeNode> Remotes => _remotes;
public void Run(List<Branch> branches, List<Remote> remotes) public void Run(List<Models.Branch> branches, List<Models.Remote> remotes, bool bForceExpanded)
{ {
foreach (var remote in remotes) foreach (var remote in remotes)
{ {
@ -66,7 +66,7 @@ namespace SourceGit.Models
Name = remote.Name, Name = remote.Name,
Type = BranchTreeNodeType.Remote, Type = BranchTreeNodeType.Remote,
Backend = remote, Backend = remote,
IsExpanded = _expanded.Contains(path), IsExpanded = bForceExpanded || _expanded.Contains(path),
}; };
_maps.Add(path, node); _maps.Add(path, node);
@ -78,13 +78,13 @@ namespace SourceGit.Models
var isFiltered = _filters.Contains(branch.FullName); var isFiltered = _filters.Contains(branch.FullName);
if (branch.IsLocal) if (branch.IsLocal)
{ {
MakeBranchNode(branch, _locals, "local", isFiltered); MakeBranchNode(branch, _locals, "local", isFiltered, bForceExpanded);
} }
else else
{ {
var remote = _remotes.Find(x => x.Name == branch.Remote); var remote = _remotes.Find(x => x.Name == branch.Remote);
if (remote != null) if (remote != null)
MakeBranchNode(branch, remote.Children, $"remote/{remote.Name}", isFiltered); MakeBranchNode(branch, remote.Children, $"remote/{remote.Name}", isFiltered, bForceExpanded);
} }
} }
@ -113,7 +113,7 @@ namespace SourceGit.Models
} }
} }
private void MakeBranchNode(Branch branch, List<BranchTreeNode> roots, string prefix, bool isFiltered) private void MakeBranchNode(Models.Branch branch, List<BranchTreeNode> roots, string prefix, bool isFiltered, bool bForceExpanded)
{ {
var subs = branch.Name.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); var subs = branch.Name.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
@ -132,8 +132,8 @@ namespace SourceGit.Models
} }
BranchTreeNode lastFolder = null; BranchTreeNode lastFolder = null;
string path = prefix; var path = prefix;
for (int i = 0; i < subs.Length - 1; i++) for (var i = 0; i < subs.Length - 1; i++)
{ {
path = string.Concat(path, "/", subs[i]); path = string.Concat(path, "/", subs[i]);
if (_maps.TryGetValue(path, out var value)) if (_maps.TryGetValue(path, out var value))
@ -146,7 +146,7 @@ namespace SourceGit.Models
{ {
Name = subs[i], Name = subs[i],
Type = BranchTreeNodeType.Folder, Type = BranchTreeNodeType.Folder,
IsExpanded = branch.IsCurrent || _expanded.Contains(path), IsExpanded = bForceExpanded || branch.IsCurrent || _expanded.Contains(path),
}; };
roots.Add(lastFolder); roots.Add(lastFolder);
_maps.Add(path, lastFolder); _maps.Add(path, lastFolder);
@ -157,7 +157,7 @@ namespace SourceGit.Models
{ {
Name = subs[i], Name = subs[i],
Type = BranchTreeNodeType.Folder, Type = BranchTreeNodeType.Folder,
IsExpanded = branch.IsCurrent || _expanded.Contains(path), IsExpanded = bForceExpanded || branch.IsCurrent || _expanded.Contains(path),
}; };
_maps.Add(path, folder); _maps.Add(path, folder);
lastFolder.Children.Add(folder); lastFolder.Children.Add(folder);
@ -186,7 +186,7 @@ namespace SourceGit.Models
} }
else else
{ {
return (int)(l.Type) - (int)(r.Type); return (int)l.Type - (int)r.Type;
} }
}); });

View file

@ -89,6 +89,21 @@ namespace SourceGit.ViewModels
set => SetProperty(ref _selectedView, value); set => SetProperty(ref _selectedView, value);
} }
[JsonIgnore]
public string SearchBranchFilter
{
get => _searchBranchFilter;
set
{
if (SetProperty(ref _searchBranchFilter, value))
{
var builder = BuildBranchTree(_branches, _remotes);
LocalBranchTrees = builder.Locals;
RemoteBranchTrees = builder.Remotes;
}
}
}
[JsonIgnore] [JsonIgnore]
public List<Models.Remote> Remotes public List<Models.Remote> Remotes
{ {
@ -104,14 +119,14 @@ namespace SourceGit.ViewModels
} }
[JsonIgnore] [JsonIgnore]
public List<Models.BranchTreeNode> LocalBranchTrees public List<BranchTreeNode> LocalBranchTrees
{ {
get => _localBranchTrees; get => _localBranchTrees;
private set => SetProperty(ref _localBranchTrees, value); private set => SetProperty(ref _localBranchTrees, value);
} }
[JsonIgnore] [JsonIgnore]
public List<Models.BranchTreeNode> RemoteBranchTrees public List<BranchTreeNode> RemoteBranchTrees
{ {
get => _remoteBranchTrees; get => _remoteBranchTrees;
private set => SetProperty(ref _remoteBranchTrees, value); private set => SetProperty(ref _remoteBranchTrees, value);
@ -422,6 +437,11 @@ namespace SourceGit.ViewModels
SearchedCommits = visible; SearchedCommits = visible;
} }
public void ClearSearchBranchFilter()
{
SearchBranchFilter = string.Empty;
}
public void SetWatcherEnabled(bool enabled) public void SetWatcherEnabled(bool enabled)
{ {
if (_watcher != null) if (_watcher != null)
@ -533,12 +553,7 @@ namespace SourceGit.ViewModels
{ {
var branches = new Commands.QueryBranches(FullPath).Result(); var branches = new Commands.QueryBranches(FullPath).Result();
var remotes = new Commands.QueryRemotes(FullPath).Result(); var remotes = new Commands.QueryRemotes(FullPath).Result();
var builder = BuildBranchTree(branches, remotes);
var builder = new Models.BranchTreeNode.Builder();
builder.SetFilters(Filters);
builder.CollectExpandedNodes(_localBranchTrees, true);
builder.CollectExpandedNodes(_remoteBranchTrees, false);
builder.Run(branches, remotes);
Dispatcher.UIThread.Invoke(() => Dispatcher.UIThread.Invoke(() =>
{ {
@ -1354,6 +1369,32 @@ namespace SourceGit.ViewModels
return menu; return menu;
} }
private BranchTreeNode.Builder BuildBranchTree(List<Models.Branch> branches, List<Models.Remote> remotes)
{
var builder = new BranchTreeNode.Builder();
builder.SetFilters(Filters);
if (string.IsNullOrEmpty(_searchBranchFilter))
{
builder.CollectExpandedNodes(_localBranchTrees, true);
builder.CollectExpandedNodes(_remoteBranchTrees, false);
builder.Run(branches, remotes, false);
}
else
{
var visibles = new List<Models.Branch>();
foreach (var b in branches)
{
if (b.FullName.Contains(_searchBranchFilter, StringComparison.OrdinalIgnoreCase))
visibles.Add(b);
}
builder.Run(visibles, remotes, true);
}
return builder;
}
private string _fullpath = string.Empty; private string _fullpath = string.Empty;
private string _gitDir = string.Empty; private string _gitDir = string.Empty;
private Models.GitFlow _gitflow = new Models.GitFlow(); private Models.GitFlow _gitflow = new Models.GitFlow();
@ -1372,10 +1413,12 @@ namespace SourceGit.ViewModels
private bool _isTagGroupExpanded = false; private bool _isTagGroupExpanded = false;
private bool _isSubmoduleGroupExpanded = false; private bool _isSubmoduleGroupExpanded = false;
private string _searchBranchFilter = string.Empty;
private List<Models.Remote> _remotes = new List<Models.Remote>(); private List<Models.Remote> _remotes = new List<Models.Remote>();
private List<Models.Branch> _branches = new List<Models.Branch>(); private List<Models.Branch> _branches = new List<Models.Branch>();
private List<Models.BranchTreeNode> _localBranchTrees = new List<Models.BranchTreeNode>(); private List<BranchTreeNode> _localBranchTrees = new List<BranchTreeNode>();
private List<Models.BranchTreeNode> _remoteBranchTrees = new List<Models.BranchTreeNode>(); private List<BranchTreeNode> _remoteBranchTrees = new List<BranchTreeNode>();
private List<Models.Tag> _tags = new List<Models.Tag>(); private List<Models.Tag> _tags = new List<Models.Tag>();
private List<string> _submodules = new List<string>(); private List<string> _submodules = new List<string>();
private bool _canCommitWithPush = false; private bool _canCommitWithPush = false;

View file

@ -109,7 +109,7 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- Left Normal Mode --> <!-- Left Normal Mode -->
<Grid Grid.Column="0" RowDefinitions="28,Auto,28,Auto,28,*,28,Auto,28,Auto" Margin="0,0,0,4" IsVisible="{Binding !IsSearching}"> <Grid Grid.Column="0" RowDefinitions="28,Auto,5,28,28,Auto,28,*,28,Auto,28,Auto" Margin="0,0,0,4" IsVisible="{Binding !IsSearching}">
<!-- WorkingCopy --> <!-- WorkingCopy -->
<TextBlock Grid.Row="0" Classes="group_header_label" Text="{DynamicResource Text.Repository.Workspace}"/> <TextBlock Grid.Row="0" Classes="group_header_label" Text="{DynamicResource Text.Repository.Workspace}"/>
<ListBox Grid.Row="1" Classes="page_switcher" Background="Transparent" SelectedIndex="{Binding SelectedViewIndex, Mode=TwoWay}"> <ListBox Grid.Row="1" Classes="page_switcher" Background="Transparent" SelectedIndex="{Binding SelectedViewIndex, Mode=TwoWay}">
@ -159,9 +159,42 @@
</ListBoxItem> </ListBoxItem>
</ListBox> </ListBox>
<!-- Filter Branches -->
<Rectangle Grid.Row="2" Height=".65" HorizontalAlignment="Stretch" VerticalAlignment="Center" Fill="{DynamicResource Brush.Border2}"/>
<TextBox Grid.Row="3"
Margin="4,2,4,0"
Height="24"
BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}"
Background="{DynamicResource Brush.Contents}"
Watermark="{DynamicResource Text.Repository.FilterBranchTip}"
Text="{Binding SearchBranchFilter, Mode=TwoWay}"
VerticalContentAlignment="Center">
<TextBox.InnerLeftContent>
<Path Width="14" Height="14"
Margin="6,0,0,0"
Fill="{DynamicResource Brush.FG2}"
Data="{StaticResource Icons.Search}"/>
</TextBox.InnerLeftContent>
<TextBox.InnerRightContent>
<Button Classes="icon_button"
Width="16"
Margin="0,0,6,0"
Command="{Binding ClearSearchBranchFilter}"
IsVisible="{Binding SearchBranchFilter, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
HorizontalAlignment="Right">
<Path Width="14" Height="14"
Margin="0,1,0,0"
Fill="{DynamicResource Brush.FG1}"
Data="{StaticResource Icons.Clear}"/>
</Button>
</TextBox.InnerRightContent>
</TextBox>
<!-- Local Branches --> <!-- Local Branches -->
<TextBlock Grid.Row="2" Classes="group_header_label" Text="{DynamicResource Text.Repository.LocalBranches}"/> <TextBlock Grid.Row="4" Classes="group_header_label" Text="{DynamicResource Text.Repository.LocalBranches}"/>
<TreeView Grid.Row="3" <TreeView Grid.Row="5"
x:Name="localBranchTree" x:Name="localBranchTree"
MaxHeight="400" MaxHeight="400"
ItemsSource="{Binding LocalBranchTrees}" ItemsSource="{Binding LocalBranchTrees}"
@ -170,12 +203,12 @@
LostFocus="OnLocalBranchTreeLostFocus" LostFocus="OnLocalBranchTreeLostFocus"
SelectionChanged="OnLocalBranchTreeSelectionChanged"> SelectionChanged="OnLocalBranchTreeSelectionChanged">
<TreeView.Styles> <TreeView.Styles>
<Style Selector="TreeViewItem" x:DataType="m:BranchTreeNode"> <Style Selector="TreeViewItem" x:DataType="vm:BranchTreeNode">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/> <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
</Style> </Style>
</TreeView.Styles> </TreeView.Styles>
<TreeView.ItemTemplate> <TreeView.ItemTemplate>
<TreeDataTemplate ItemsSource="{Binding Children}" x:DataType="{x:Type m:BranchTreeNode}"> <TreeDataTemplate ItemsSource="{Binding Children}" x:DataType="{x:Type vm:BranchTreeNode}">
<Grid Height="24" ColumnDefinitions="20,*,Auto,Auto" Background="Transparent" ContextRequested="OnLocalBranchContextMenuRequested" DoubleTapped="OnDoubleTappedLocalBranchNode"> <Grid Height="24" ColumnDefinitions="20,*,Auto,Auto" Background="Transparent" ContextRequested="OnLocalBranchContextMenuRequested" DoubleTapped="OnDoubleTappedLocalBranchNode">
<Path Grid.Column="0" Classes="folder_icon" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,1,0,0" IsVisible="{Binding IsFolder}"/> <Path Grid.Column="0" Classes="folder_icon" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,1,0,0" IsVisible="{Binding IsFolder}"/>
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,2,0,0" Data="{StaticResource Icons.Check}" IsVisible="{Binding IsCurrent}" VerticalAlignment="Center"/> <Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,2,0,0" Data="{StaticResource Icons.Check}" IsVisible="{Binding IsCurrent}" VerticalAlignment="Center"/>
@ -208,13 +241,13 @@
</TreeView> </TreeView>
<!-- Remotes --> <!-- Remotes -->
<Grid Grid.Row="4" ColumnDefinitions="*,Auto"> <Grid Grid.Row="6" ColumnDefinitions="*,Auto">
<TextBlock Grid.Column="0" Classes="group_header_label" Text="{DynamicResource Text.Repository.Remotes}"/> <TextBlock Grid.Column="0" Classes="group_header_label" Text="{DynamicResource Text.Repository.Remotes}"/>
<Button Grid.Column="1" Classes="icon_button" Width="14" Margin="8,0" Command="{Binding AddRemote}" ToolTip.Tip="{DynamicResource Text.Repository.Remotes.Add}"> <Button Grid.Column="1" Classes="icon_button" Width="14" Margin="8,0" Command="{Binding AddRemote}" ToolTip.Tip="{DynamicResource Text.Repository.Remotes.Add}">
<Path Width="12" Height="12" Data="{StaticResource Icons.Remote.Add}"/> <Path Width="12" Height="12" Data="{StaticResource Icons.Remote.Add}"/>
</Button> </Button>
</Grid> </Grid>
<TreeView Grid.Row="5" <TreeView Grid.Row="7"
x:Name="remoteBranchTree" x:Name="remoteBranchTree"
ItemsSource="{Binding RemoteBranchTrees}" ItemsSource="{Binding RemoteBranchTrees}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
@ -222,13 +255,13 @@
LostFocus="OnRemoteBranchTreeLostFocus" LostFocus="OnRemoteBranchTreeLostFocus"
SelectionChanged="OnRemoteBranchTreeSelectionChanged"> SelectionChanged="OnRemoteBranchTreeSelectionChanged">
<TreeView.Styles> <TreeView.Styles>
<Style Selector="TreeViewItem" x:DataType="m:BranchTreeNode"> <Style Selector="TreeViewItem" x:DataType="vm:BranchTreeNode">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/> <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
</Style> </Style>
</TreeView.Styles> </TreeView.Styles>
<TreeView.ItemTemplate> <TreeView.ItemTemplate>
<TreeDataTemplate ItemsSource="{Binding Children}" x:DataType="{x:Type m:BranchTreeNode}"> <TreeDataTemplate ItemsSource="{Binding Children}" x:DataType="{x:Type vm:BranchTreeNode}">
<Grid Height="24" ColumnDefinitions="20,*,Auto" Background="Transparent" ContextRequested="OnRemoteBranchContextMenuRequested"> <Grid Height="24" ColumnDefinitions="20,*,Auto" Background="Transparent" ContextRequested="OnRemoteBranchContextMenuRequested">
<Path Grid.Column="0" Classes="folder_icon" Width="10" Height="10" HorizontalAlignment="Left" Margin="0,2,0,0" IsVisible="{Binding IsFolder}" VerticalAlignment="Center"/> <Path Grid.Column="0" Classes="folder_icon" Width="10" Height="10" HorizontalAlignment="Left" Margin="0,2,0,0" IsVisible="{Binding IsFolder}" VerticalAlignment="Center"/>
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,2,0,0" Data="{StaticResource Icons.Remote}" IsVisible="{Binding IsRemote}" VerticalAlignment="Center"/> <Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,2,0,0" Data="{StaticResource Icons.Remote}" IsVisible="{Binding IsRemote}" VerticalAlignment="Center"/>
@ -250,7 +283,7 @@
</TreeView> </TreeView>
<!-- Tags --> <!-- Tags -->
<ToggleButton Grid.Row="6" Classes="group_expander" IsChecked="{Binding IsTagGroupExpanded, Mode=TwoWay}"> <ToggleButton Grid.Row="8" Classes="group_expander" IsChecked="{Binding IsTagGroupExpanded, Mode=TwoWay}">
<Grid ColumnDefinitions="Auto,*,Auto"> <Grid ColumnDefinitions="Auto,*,Auto">
<TextBlock Grid.Column="0" Classes="group_header_label" Margin="4,0,0,0" Text="{DynamicResource Text.Repository.Tags}"/> <TextBlock Grid.Column="0" Classes="group_header_label" Margin="4,0,0,0" Text="{DynamicResource Text.Repository.Tags}"/>
<TextBlock Grid.Column="1" Text="{Binding Tags, Converter={x:Static c:ListConverters.ToCount}}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/> <TextBlock Grid.Column="1" Text="{Binding Tags, Converter={x:Static c:ListConverters.ToCount}}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/>
@ -259,7 +292,7 @@
</Button> </Button>
</Grid> </Grid>
</ToggleButton> </ToggleButton>
<DataGrid Grid.Row="7" <DataGrid Grid.Row="9"
MaxHeight="200" MaxHeight="200"
Background="Transparent" Background="Transparent"
ItemsSource="{Binding Tags}" ItemsSource="{Binding Tags}"
@ -310,7 +343,7 @@
</DataGrid> </DataGrid>
<!-- Submodules --> <!-- Submodules -->
<ToggleButton Grid.Row="8" Classes="group_expander" IsChecked="{Binding IsSubmoduleGroupExpanded, Mode=TwoWay}"> <ToggleButton Grid.Row="10" Classes="group_expander" IsChecked="{Binding IsSubmoduleGroupExpanded, Mode=TwoWay}">
<Grid ColumnDefinitions="Auto,*,Auto,Auto"> <Grid ColumnDefinitions="Auto,*,Auto,Auto">
<TextBlock Grid.Column="0" Classes="group_header_label" Margin="4,0,0,0" Text="{DynamicResource Text.Repository.Submodules}"/> <TextBlock Grid.Column="0" Classes="group_header_label" Margin="4,0,0,0" Text="{DynamicResource Text.Repository.Submodules}"/>
<TextBlock Grid.Column="1" Text="{Binding Submodules, Converter={x:Static c:ListConverters.ToCount}}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/> <TextBlock Grid.Column="1" Text="{Binding Submodules, Converter={x:Static c:ListConverters.ToCount}}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/>
@ -328,7 +361,7 @@
</Button> </Button>
</Grid> </Grid>
</ToggleButton> </ToggleButton>
<DataGrid Grid.Row="9" <DataGrid Grid.Row="11"
MaxHeight="200" MaxHeight="200"
Background="Transparent" Background="Transparent"
ItemsSource="{Binding Submodules}" ItemsSource="{Binding Submodules}"

View file

@ -98,7 +98,7 @@ namespace SourceGit.Views
{ {
remoteBranchTree.UnselectAll(); remoteBranchTree.UnselectAll();
var node = tree.SelectedItem as Models.BranchTreeNode; var node = tree.SelectedItem as ViewModels.BranchTreeNode;
if (node.IsBranch && DataContext is ViewModels.Repository repo) if (node.IsBranch && DataContext is ViewModels.Repository repo)
{ {
repo.NavigateToCommit((node.Backend as Models.Branch).Head); repo.NavigateToCommit((node.Backend as Models.Branch).Head);
@ -112,7 +112,7 @@ namespace SourceGit.Views
{ {
localBranchTree.UnselectAll(); localBranchTree.UnselectAll();
var node = tree.SelectedItem as Models.BranchTreeNode; var node = tree.SelectedItem as ViewModels.BranchTreeNode;
if (node.IsBranch && DataContext is ViewModels.Repository repo) if (node.IsBranch && DataContext is ViewModels.Repository repo)
{ {
repo.NavigateToCommit((node.Backend as Models.Branch).Head); repo.NavigateToCommit((node.Backend as Models.Branch).Head);
@ -171,7 +171,7 @@ namespace SourceGit.Views
if (sender is ToggleButton toggle) if (sender is ToggleButton toggle)
{ {
var filter = string.Empty; var filter = string.Empty;
if (toggle.DataContext is Models.BranchTreeNode node) if (toggle.DataContext is ViewModels.BranchTreeNode node)
{ {
if (node.IsBranch) if (node.IsBranch)
{ {
@ -196,7 +196,7 @@ namespace SourceGit.Views
{ {
remoteBranchTree.UnselectAll(); remoteBranchTree.UnselectAll();
if (sender is Grid grid && grid.DataContext is Models.BranchTreeNode node) if (sender is Grid grid && grid.DataContext is ViewModels.BranchTreeNode node)
{ {
if (node.IsBranch && DataContext is ViewModels.Repository repo) if (node.IsBranch && DataContext is ViewModels.Repository repo)
{ {
@ -213,7 +213,7 @@ namespace SourceGit.Views
{ {
localBranchTree.UnselectAll(); localBranchTree.UnselectAll();
if (sender is Grid grid && grid.DataContext is Models.BranchTreeNode node && DataContext is ViewModels.Repository repo) if (sender is Grid grid && grid.DataContext is ViewModels.BranchTreeNode node && DataContext is ViewModels.Repository repo)
{ {
if (node.IsRemote) if (node.IsRemote)
{ {
@ -291,7 +291,7 @@ namespace SourceGit.Views
if (sender is Grid grid && DataContext is ViewModels.Repository repo) if (sender is Grid grid && DataContext is ViewModels.Repository repo)
{ {
var node = grid.DataContext as Models.BranchTreeNode; var node = grid.DataContext as ViewModels.BranchTreeNode;
if (node != null && node.IsBranch) if (node != null && node.IsBranch)
{ {
var branch = node.Backend as Models.Branch; var branch = node.Backend as Models.Branch;