From 99afc74871d135e9a1c7be1887f26f944ffe1c02 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 18 Jun 2024 18:27:57 +0800 Subject: [PATCH] enhance: shows current histories filters and add a button to clear all histories filters (#184) --- src/Converters/StringConverters.cs | 10 ++++++++ src/Resources/Locales/en_US.axaml | 2 ++ src/Resources/Locales/zh_CN.axaml | 2 ++ src/Resources/Locales/zh_TW.axaml | 2 ++ src/ViewModels/Repository.cs | 22 ++++++++++++++++++ src/Views/Repository.axaml | 37 ++++++++++++++++++++++++++++-- 6 files changed, 73 insertions(+), 2 deletions(-) diff --git a/src/Converters/StringConverters.cs b/src/Converters/StringConverters.cs index ac1785c0..42eaa164 100644 --- a/src/Converters/StringConverters.cs +++ b/src/Converters/StringConverters.cs @@ -81,6 +81,16 @@ namespace SourceGit.Converters return true; }); + public static readonly FuncValueConverter TrimRefsPrefix = + new FuncValueConverter(v => + { + if (v.StartsWith("refs/heads/", StringComparison.Ordinal)) + return v.Substring(11); + if (v.StartsWith("refs/remotes/", StringComparison.Ordinal)) + return v.Substring(13); + return v; + }); + [GeneratedRegex(@"^[\s\w]*(\d+)\.(\d+)[\.\-](\d+).*$")] private static partial Regex REG_GIT_VERSION(); diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index e42321d7..a7ca7671 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -398,10 +398,12 @@ ABORT Cleanup(GC & Prune) Run `git gc` command for this repository. + Clear all Configure this repository CONTINUE Open In File Browser Filter Branches + FILTERED BY: LOCAL BRANCHES Navigate To HEAD Create Branch diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 677ad43d..e7f88389 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -400,10 +400,12 @@ 终止合并 清理本仓库(GC) 本操作将执行`git gc`命令。 + 清空过滤规则 配置本仓库 下一步 在文件浏览器中打开 过滤显示分支 + 过滤规则 : 本地分支 定位HEAD 新建分支 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 115edc40..d8e5e336 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -400,10 +400,12 @@ 終止合併 清理本倉庫(GC) 本操作將執行`git gc`命令。 + 清空過濾規則 配置本倉庫 下一步 在檔案瀏覽器中開啟 過濾顯示分支 + 過濾規則 : 本地分支 定位HEAD 新建分支 diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index d2b8d462..6dc6fb9e 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -404,6 +404,18 @@ namespace SourceGit.ViewModels PopupHost.ShowPopup(new RepositoryConfigure(this)); } + public void ClearHistoriesFilter() + { + Filters.Clear(); + + Task.Run(() => + { + RefreshBranches(); + RefreshTags(); + RefreshCommits(); + }); + } + public void ClearSearchCommitFilter() { SearchCommitFilter = string.Empty; @@ -602,9 +614,19 @@ namespace SourceGit.ViewModels validFilters.Add(filter); } } + if (validFilters.Count > 0) { limits += string.Join(" ", validFilters); + + if (Filters.Count != validFilters.Count) + { + Dispatcher.UIThread.Post(() => + { + Filters.Clear(); + Filters.AddRange(validFilters); + }); + } } else { diff --git a/src/Views/Repository.axaml b/src/Views/Repository.axaml index 3c0b28d0..0e48186a 100644 --- a/src/Views/Repository.axaml +++ b/src/Views/Repository.axaml @@ -614,7 +614,7 @@ BorderBrush="{DynamicResource Brush.Border0}"/> - + @@ -646,7 +646,40 @@ + + + +