Added a checkbox in the LFSLocks window to only show the ones locked by "Mat"

This commit is contained in:
Mat 2024-09-21 15:54:35 +02:00
parent 1cda5d858e
commit c3c47f6161
2 changed files with 38 additions and 7 deletions

View file

@ -1,4 +1,6 @@
using System.Threading.Tasks; using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Avalonia.Collections; using Avalonia.Collections;
using Avalonia.Threading; using Avalonia.Threading;
@ -20,11 +22,31 @@ namespace SourceGit.ViewModels
get => _isEmpty; get => _isEmpty;
private set => SetProperty(ref _isEmpty, value); private set => SetProperty(ref _isEmpty, value);
} }
public bool ShowOnlyMyLocks
{
get => _showOnlyMyLocks;
set
{
if (!SetProperty(ref _showOnlyMyLocks, value))
return;
public AvaloniaList<Models.LFSLock> Locks OnPropertyChanged(nameof(FilteredLocks));
IsEmpty = !FilteredLocks.Any();
}
}
private AvaloniaList<Models.LFSLock> Locks
{ {
get; get;
private set; }
public IEnumerable<Models.LFSLock> FilteredLocks
{
get
{
return ShowOnlyMyLocks ? Locks.Where(@lock => @lock.User == "Mat") : Locks;
}
} }
public LFSLocks(string repo, string remote) public LFSLocks(string repo, string remote)
@ -71,5 +93,6 @@ namespace SourceGit.ViewModels
private string _remote; private string _remote;
private bool _isLoading = true; private bool _isLoading = true;
private bool _isEmpty = false; private bool _isEmpty = false;
private bool _showOnlyMyLocks = false;
} }
} }

View file

@ -13,7 +13,7 @@
Title="{DynamicResource Text.GitLFS.Locks.Title}" Title="{DynamicResource Text.GitLFS.Locks.Title}"
Width="600" Height="400" Width="600" Height="400"
WindowStartupLocation="CenterOwner"> WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="Auto,*"> <Grid RowDefinitions="Auto,Auto,*">
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Grid.Column="0" Grid.ColumnSpan="3"
@ -43,11 +43,19 @@
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>
<!-- Filter and Unlock All -->
<Grid Grid.Row="1" ColumnDefinitions="Auto,*,Auto" Margin="8,0,0,0">
<CheckBox Grid.Column="0"
Content="Show only my locks"
IsChecked="{Binding ShowOnlyMyLocks}"
VerticalAlignment="Center" />
</Grid>
<!-- Locked Files --> <!-- Locked Files -->
<Grid Grid.Row="1"> <Grid Grid.Row="2">
<ListBox Margin="8" <ListBox Margin="8,0,8,8"
Background="{DynamicResource Brush.Contents}" Background="{DynamicResource Brush.Contents}"
ItemsSource="{Binding Locks}" ItemsSource="{Binding FilteredLocks}"
SelectionMode="Single" SelectionMode="Single"
BorderThickness="1" BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}" BorderBrush="{DynamicResource Brush.Border2}"