Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: support navigat filter to repository view
- Add branch and tag navigation support to the repository view model.
- Increase filter item height and replace text block with clickable button for navigation.
- Add navigation functionality for different filter types in the repository view.
  • Loading branch information
heartacker committed Aug 8, 2025
commit 28d90fafb918ca8f2980271552d4e7c64ed0aa79
16 changes: 16 additions & 0 deletions src/ViewModels/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1006,10 +1006,26 @@ public void NavigateToCommit(string sha, bool isDelayMode = false)
else if (_histories != null)
{
SelectedViewIndex = 0;
if (sha == "HEAD")
sha = _currentBranch.Head;
_histories.NavigateTo(sha);
}
}

public void NavigateToBranch(string branch, bool isDelayMode = false)
{
var b = _branches.Find(b => b.FullName.Equals(branch, StringComparison.Ordinal));
if (b != null)
NavigateToCommit(b.Head);
}

public void NavigateToTag(string tag, bool isDelayMode = false)
{
var t = _tags.Find(t => t.Name.Equals(tag, StringComparison.Ordinal));
if (t != null)
NavigateToCommit(t.SHA);
}

public void ClearCommitMessage()
{
if (_workingCopy is not null)
Expand Down
12 changes: 9 additions & 3 deletions src/Views/Repository.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -800,16 +800,22 @@

<ItemsControl.ItemTemplate>
<DataTemplate DataType="m:Filter">
<Border Height="20"
<Border Height="24"
Margin="0,0,6,0"
CornerRadius="12"
BorderThickness="1"
BorderBrush="{Binding Mode, Converter={x:Static c:FilterModeConverters.ToBorderBrush}}">
<StackPanel Orientation="Horizontal" Margin="8,0">
<Path Width="10" Height="10" Data="{StaticResource Icons.Branch}" IsVisible="{Binding IsBranch}"/>
<Path Width="10" Height="10" Data="{StaticResource Icons.Tag}" IsVisible="{Binding !IsBranch}"/>
<TextBlock Classes="primary" Text="{Binding Pattern, Converter={x:Static c:StringConverters.TrimRefsPrefix}}" Margin="4,0,8,0"/>

<Button Margin="4,0,8,0"
Padding="0"
Background="Transparent"
BorderThickness="0"
Classes="icon_button"
Click="OnNavigateToFilter"
Content="{Binding Pattern, Converter={x:Static c:StringConverters.TrimRefsPrefix}}"
/>
<Button Classes="icon_button" VerticalAlignment="Center" Margin="0" Padding="0" Click="OnRemoveSelectedHistoriesFilter">
<Path Width="8" Height="8" Data="{StaticResource Icons.Close}"/>
</Button>
Expand Down
29 changes: 29 additions & 0 deletions src/Views/Repository.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,35 @@ private async void OnAbortInProgress(object sender, RoutedEventArgs e)
e.Handled = true;
}

private void OnNavigateToFilter(object sender, RoutedEventArgs e)
{
if (DataContext is ViewModels.Repository repo && sender is Button { DataContext: Models.Filter filter })
{
if (filter.Mode == Models.FilterMode.Excluded)
return;

switch (filter.Type)
{
default:
case Models.FilterType.LocalBranchFolder:
case Models.FilterType.RemoteBranchFolder:
break;
case Models.FilterType.LocalBranch:
case Models.FilterType.RemoteBranch:
repo.NavigateToBranch(filter.Pattern);
break;
case Models.FilterType.Tag:
repo.NavigateToTag(filter.Pattern);
break;
case Models.FilterType.SoloCommits:
repo.NavigateToCommit(filter.Pattern);
break;
}
e.Handled = true;
}
}


private void OnRemoveSelectedHistoriesFilter(object sender, RoutedEventArgs e)
{
if (DataContext is ViewModels.Repository repo && sender is Button { DataContext: Models.Filter filter })
Expand Down