Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
38 changes: 35 additions & 3 deletions src/ViewModels/LFSLocks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Linq;
using System.Threading.Tasks;

using Avalonia.Collections;
using Avalonia.Threading;
Expand All @@ -20,18 +21,47 @@ public bool IsEmpty
get => _isEmpty;
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;
private set;
}

public AvaloniaList<Models.LFSLock> FilteredLocks
{
get
{
if (string.IsNullOrEmpty(_userName))
{
App.RaiseException(_repo, "Username is empty");
return Locks;
}

return _showOnlyMyLocks ?
new AvaloniaList<Models.LFSLock>(Locks.Where(@lock => @lock.User == _userName)) :
Locks;
}
}

public LFSLocks(string repo, string remote)
{
_repo = repo;
_remote = remote;
Locks = new AvaloniaList<Models.LFSLock>();
new Commands.Config(repo).ListAll().TryGetValue("user.name", out _userName);

Task.Run(() =>
{
Expand Down Expand Up @@ -71,5 +101,7 @@ public void Unlock(Models.LFSLock lfsLock, bool force)
private string _remote;
private bool _isLoading = true;
private bool _isEmpty = false;
private bool _showOnlyMyLocks = false;
private string _userName;
}
}
17 changes: 13 additions & 4 deletions src/Views/LFSLocks.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Title="{DynamicResource Text.GitLFS.Locks.Title}"
Width="600" Height="400"
WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="Auto,*">
<Grid RowDefinitions="Auto,Auto,*">
<!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3"
Expand Down Expand Up @@ -43,11 +43,20 @@
IsVisible="{OnPlatform True, macOS=False}"/>
</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}"
IsEnabled="{Binding !IsLoading}"
VerticalAlignment="Center" />
</Grid>

<!-- Locked Files -->
<Grid Grid.Row="1">
<ListBox Margin="8"
<Grid Grid.Row="2">
<ListBox Margin="8,0,8,8"
Background="{DynamicResource Brush.Contents}"
ItemsSource="{Binding Locks}"
ItemsSource="{Binding FilteredLocks}"
SelectionMode="Single"
BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}"
Expand Down