mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
feature: supports to search/filter tags (#215)
This commit is contained in:
parent
575f902a5d
commit
f8c4137c78
6 changed files with 50 additions and 7 deletions
|
@ -431,7 +431,6 @@
|
|||
<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.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.FilterCommitPrefix" xml:space="preserve">FILTERED BY:</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>
|
||||
|
@ -446,6 +445,7 @@
|
|||
<x:String x:Key="Text.Repository.Search.By" xml:space="preserve">Search By</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.ByBaseInfo" xml:space="preserve">Information</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.ByFile" xml:space="preserve">File</x:String>
|
||||
<x:String x:Key="Text.Repository.SearchBranchTag" xml:space="preserve">Search Branches & Tags</x:String>
|
||||
<x:String x:Key="Text.Repository.Statistics" xml:space="preserve">Statistics</x:String>
|
||||
<x:String x:Key="Text.Repository.Submodules" xml:space="preserve">SUBMODULES</x:String>
|
||||
<x:String x:Key="Text.Repository.Submodules.Add" xml:space="preserve">ADD SUBMODULE</x:String>
|
||||
|
|
|
@ -433,7 +433,6 @@
|
|||
<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.Explore" xml:space="preserve">在文件浏览器中打开</x:String>
|
||||
<x:String x:Key="Text.Repository.FilterBranchTip" xml:space="preserve">过滤显示分支</x:String>
|
||||
<x:String x:Key="Text.Repository.FilterCommitPrefix" 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>
|
||||
|
@ -448,6 +447,7 @@
|
|||
<x:String x:Key="Text.Repository.Search.By" xml:space="preserve">搜索途径</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.ByBaseInfo" xml:space="preserve">摘要</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.ByFile" xml:space="preserve">文件</x:String>
|
||||
<x:String x:Key="Text.Repository.SearchBranchTag" xml:space="preserve">快速查找分支、标签</x:String>
|
||||
<x:String x:Key="Text.Repository.Statistics" xml:space="preserve">提交统计</x:String>
|
||||
<x:String x:Key="Text.Repository.Submodules" xml:space="preserve">子模块列表</x:String>
|
||||
<x:String x:Key="Text.Repository.Submodules.Add" xml:space="preserve">添加子模块</x:String>
|
||||
|
|
|
@ -433,7 +433,6 @@
|
|||
<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.Explore" xml:space="preserve">在檔案瀏覽器中開啟</x:String>
|
||||
<x:String x:Key="Text.Repository.FilterBranchTip" xml:space="preserve">過濾顯示分支</x:String>
|
||||
<x:String x:Key="Text.Repository.FilterCommitPrefix" 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>
|
||||
|
@ -448,6 +447,7 @@
|
|||
<x:String x:Key="Text.Repository.Search.By" xml:space="preserve">查詢方式</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.ByBaseInfo" xml:space="preserve">摘要</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.ByFile" xml:space="preserve">檔案</x:String>
|
||||
<x:String x:Key="Text.Repository.SearchBranchTag" xml:space="preserve">快速查找分支、標籤</x:String>
|
||||
<x:String x:Key="Text.Repository.Statistics" xml:space="preserve">提交統計</x:String>
|
||||
<x:String x:Key="Text.Repository.Submodules" xml:space="preserve">子模組列表</x:String>
|
||||
<x:String x:Key="Text.Repository.Submodules.Add" xml:space="preserve">新增子模組</x:String>
|
||||
|
|
|
@ -99,6 +99,7 @@ namespace SourceGit.ViewModels
|
|||
var builder = BuildBranchTree(_branches, _remotes);
|
||||
LocalBranchTrees = builder.Locals;
|
||||
RemoteBranchTrees = builder.Remotes;
|
||||
VisibleTags = BuildVisibleTags();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,6 +146,13 @@ namespace SourceGit.ViewModels
|
|||
private set => SetProperty(ref _tags, value);
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public List<Models.Tag> VisibleTags
|
||||
{
|
||||
get => _visibleTags;
|
||||
private set => SetProperty(ref _visibleTags, value);
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public List<string> Submodules
|
||||
{
|
||||
|
@ -295,6 +303,7 @@ namespace SourceGit.ViewModels
|
|||
_localBranchTrees.Clear();
|
||||
_remoteBranchTrees.Clear();
|
||||
_tags.Clear();
|
||||
_visibleTags.Clear();
|
||||
_submodules.Clear();
|
||||
_searchedCommits.Clear();
|
||||
}
|
||||
|
@ -633,6 +642,7 @@ namespace SourceGit.ViewModels
|
|||
Dispatcher.UIThread.Invoke(() =>
|
||||
{
|
||||
Tags = tags;
|
||||
VisibleTags = BuildVisibleTags();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1827,6 +1837,25 @@ namespace SourceGit.ViewModels
|
|||
return builder;
|
||||
}
|
||||
|
||||
private List<Models.Tag> BuildVisibleTags()
|
||||
{
|
||||
var visible = new List<Models.Tag>();
|
||||
if (string.IsNullOrEmpty(_searchBranchFilter))
|
||||
{
|
||||
visible.AddRange(_tags);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var t in _tags)
|
||||
{
|
||||
if (t.Name.Contains(_searchBranchFilter, StringComparison.OrdinalIgnoreCase))
|
||||
visible.Add(t);
|
||||
}
|
||||
}
|
||||
|
||||
return visible;
|
||||
}
|
||||
|
||||
private string _fullpath = string.Empty;
|
||||
private string _gitDir = string.Empty;
|
||||
|
||||
|
@ -1854,6 +1883,7 @@ namespace SourceGit.ViewModels
|
|||
private List<BranchTreeNode> _remoteBranchTrees = new List<BranchTreeNode>();
|
||||
private List<Models.Worktree> _worktrees = new List<Models.Worktree>();
|
||||
private List<Models.Tag> _tags = new List<Models.Tag>();
|
||||
private List<Models.Tag> _visibleTags = new List<Models.Tag>();
|
||||
private List<string> _submodules = new List<string>();
|
||||
private bool _includeUntracked = true;
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@
|
|||
BorderThickness="1"
|
||||
CornerRadius="4"
|
||||
BorderBrush="{DynamicResource Brush.Border2}"
|
||||
Watermark="{DynamicResource Text.Repository.FilterBranchTip}"
|
||||
Watermark="{DynamicResource Text.Repository.SearchBranchTag}"
|
||||
Text="{Binding SearchBranchFilter, Mode=TwoWay}"
|
||||
VerticalContentAlignment="Center">
|
||||
<TextBox.InnerLeftContent>
|
||||
|
@ -375,10 +375,9 @@
|
|||
</ToggleButton>
|
||||
<DataGrid Grid.Row="7"
|
||||
x:Name="tagsList"
|
||||
MaxHeight="200"
|
||||
Margin="8,0,4,0"
|
||||
Background="Transparent"
|
||||
ItemsSource="{Binding Tags}"
|
||||
ItemsSource="{Binding VisibleTags}"
|
||||
SelectionMode="Single"
|
||||
CanUserReorderColumns="False"
|
||||
CanUserResizeColumns="False"
|
||||
|
@ -391,7 +390,8 @@
|
|||
VerticalScrollBarVisibility="Auto"
|
||||
IsVisible="{Binding IsTagGroupExpanded, Mode=OneWay}"
|
||||
SelectionChanged="OnTagDataGridSelectionChanged"
|
||||
ContextRequested="OnTagContextRequested">
|
||||
ContextRequested="OnTagContextRequested"
|
||||
PropertyChanged="OnTagPropertyChanged">
|
||||
<DataGrid.Styles>
|
||||
<Style Selector="DataGridRow">
|
||||
<Setter Property="CornerRadius" Value="4" />
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Avalonia;
|
||||
|
@ -279,6 +280,18 @@ namespace SourceGit.Views
|
|||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnTagPropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.Property == DataGrid.ItemsSourceProperty && DataContext is ViewModels.Repository vm)
|
||||
{
|
||||
if (vm.VisibleTags == null)
|
||||
return;
|
||||
|
||||
var desiredHeight = tagsList.RowHeight * vm.VisibleTags.Count;
|
||||
tagsList.Height = Math.Min(200, desiredHeight);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnToggleFilter(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is ToggleButton toggle)
|
||||
|
|
Loading…
Reference in a new issue