mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
enhance: shows current histories filters and add a button to clear all histories filters (#184)
This commit is contained in:
parent
09d88455c0
commit
99afc74871
6 changed files with 73 additions and 2 deletions
|
@ -81,6 +81,16 @@ namespace SourceGit.Converters
|
|||
return true;
|
||||
});
|
||||
|
||||
public static readonly FuncValueConverter<string, string> TrimRefsPrefix =
|
||||
new FuncValueConverter<string, string>(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();
|
||||
|
||||
|
|
|
@ -398,10 +398,12 @@
|
|||
<x:String x:Key="Text.Repository.Abort" xml:space="preserve">ABORT</x:String>
|
||||
<x:String x:Key="Text.Repository.Clean" xml:space="preserve">Cleanup(GC & Prune)</x:String>
|
||||
<x:String x:Key="Text.Repository.CleanTips" xml:space="preserve">Run `git gc` command for this repository.</x:String>
|
||||
<x:String x:Key="Text.Repository.ClearAllCommitsFilter" xml:space="preserve">Clear all</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.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>
|
||||
<x:String x:Key="Text.Repository.NewBranch" xml:space="preserve">Create Branch</x:String>
|
||||
|
|
|
@ -400,10 +400,12 @@
|
|||
<x:String x:Key="Text.Repository.Abort" xml:space="preserve">终止合并</x:String>
|
||||
<x:String x:Key="Text.Repository.Clean" xml:space="preserve">清理本仓库(GC)</x:String>
|
||||
<x:String x:Key="Text.Repository.CleanTips" xml:space="preserve">本操作将执行`git gc`命令。</x:String>
|
||||
<x:String x:Key="Text.Repository.ClearAllCommitsFilter" 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.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>
|
||||
<x:String x:Key="Text.Repository.NewBranch" xml:space="preserve">新建分支</x:String>
|
||||
|
|
|
@ -400,10 +400,12 @@
|
|||
<x:String x:Key="Text.Repository.Abort" xml:space="preserve">終止合併</x:String>
|
||||
<x:String x:Key="Text.Repository.Clean" xml:space="preserve">清理本倉庫(GC)</x:String>
|
||||
<x:String x:Key="Text.Repository.CleanTips" xml:space="preserve">本操作將執行`git gc`命令。</x:String>
|
||||
<x:String x:Key="Text.Repository.ClearAllCommitsFilter" 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.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>
|
||||
<x:String x:Key="Text.Repository.NewBranch" xml:space="preserve">新建分支</x:String>
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -614,7 +614,7 @@
|
|||
BorderBrush="{DynamicResource Brush.Border0}"/>
|
||||
|
||||
<!-- Right -->
|
||||
<Grid Grid.Column="2" RowDefinitions="Auto,*">
|
||||
<Grid Grid.Column="2" RowDefinitions="Auto,Auto,*">
|
||||
<Grid Grid.Row="0" Height="26" ColumnDefinitions="*,Auto,Auto,Auto" Background="{DynamicResource Brush.Conflict}" IsVisible="{Binding InProgressContext, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<ContentControl Grid.Column="0" Margin="8,0" Content="{Binding InProgressContext}">
|
||||
<ContentControl.DataTemplates>
|
||||
|
@ -646,7 +646,40 @@
|
|||
<Button Grid.Column="3" Classes="flat" FontWeight="Regular" Content="{DynamicResource Text.Repository.Abort}" Height="20" Padding="8,0" Margin="4,0" Command="{Binding AbortMerge}"/>
|
||||
</Grid>
|
||||
|
||||
<ContentControl Grid.Row="1" Content="{Binding SelectedView}">
|
||||
<Border Grid.Row="1" Background="{DynamicResource Brush.Window}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}">
|
||||
<Border.IsVisible>
|
||||
<MultiBinding Converter="{x:Static BoolConverters.And}">
|
||||
<Binding Path="SelectedViewIndex" Converter="{x:Static c:IntConverters.IsZero}"/>
|
||||
<Binding Path="Filters.Count" Converter="{x:Static c:IntConverters.IsGreaterThanZero}"/>
|
||||
</MultiBinding>
|
||||
</Border.IsVisible>
|
||||
|
||||
<Grid Height="28" ColumnDefinitions="Auto,*,Auto">
|
||||
<TextBlock Grid.Column="0" Margin="8,0,0,0" Classes="info_label" Text="{DynamicResource Text.Repository.FilterCommitPrefix}"/>
|
||||
|
||||
<ItemsControl Grid.Column="1" Margin="8,0,0,0" ItemsSource="{Binding Filters}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<VirtualizingStackPanel Orientation="Horizontal" VerticalAlignment="Center"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border Height="20" Margin="0,0,6,0" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}" CornerRadius="12">
|
||||
<TextBlock Classes="monospace" Text="{Binding Converter={x:Static c:StringConverters.TrimRefsPrefix}}" Margin="8,0"/>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<Button Grid.Column="2" Classes="icon_button" Command="{Binding ClearHistoriesFilter}">
|
||||
<TextBlock Margin="16,0,8,0" Text="{DynamicResource Text.Repository.ClearAllCommitsFilter}" Foreground="{DynamicResource Brush.Accent}"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<ContentControl Grid.Row="2" Content="{Binding SelectedView}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="vm:Histories">
|
||||
<v:Histories NavigationId="{Binding NavigationId}"/>
|
||||
|
|
Loading…
Reference in a new issue