Compare commits

..

No commits in common. "d34aa8cb7eda202a5af374b0088259ae932e48a5" and "1ba294a07bc665dcc5f0f9681abf8b85101b193c" have entirely different histories.

7 changed files with 25 additions and 86 deletions

View file

@ -10,9 +10,6 @@ namespace SourceGit.Converters
public static readonly FuncValueConverter<IList, string> ToCount =
new FuncValueConverter<IList, string>(v => v == null ? " (0)" : $" ({v.Count})");
public static readonly FuncValueConverter<IList, bool> IsNullOrEmpty =
new FuncValueConverter<IList, bool>(v => v == null || v.Count == 0);
public static readonly FuncValueConverter<IList, bool> IsNotNullOrEmpty =
new FuncValueConverter<IList, bool>(v => v != null && v.Count > 0);

View file

@ -9,8 +9,6 @@ namespace SourceGit.Models
new ResetMode("Soft", "Keep all changes. Stage differences", "--soft", Brushes.Green),
new ResetMode("Mixed", "Keep all changes. Unstage differences", "--mixed", Brushes.Orange),
new ResetMode("Hard", "Discard all changes", "--hard", Brushes.Red),
new ResetMode("Merge", "Reset while keeping unmerged changes", "--merge", Brushes.Green),
new ResetMode("Keep", "Reset while keeping local modifications", "--keep", Brushes.Green),
];
public string Name { get; set; }

View file

@ -291,7 +291,6 @@
<x:String x:Key="Text.GitLFS.Locks" xml:space="preserve">Show Locks</x:String>
<x:String x:Key="Text.GitLFS.Locks.Empty" xml:space="preserve">No Locked Files</x:String>
<x:String x:Key="Text.GitLFS.Locks.Lock" xml:space="preserve">Lock</x:String>
<x:String x:Key="Text.GitLFS.Locks.OnlyMine" xml:space="preserve">Show only my locks</x:String>
<x:String x:Key="Text.GitLFS.Locks.Title" xml:space="preserve">LFS Locks</x:String>
<x:String x:Key="Text.GitLFS.Locks.Unlock" xml:space="preserve">Unlock</x:String>
<x:String x:Key="Text.GitLFS.Locks.UnlockForce" xml:space="preserve">Force Unlock</x:String>

View file

@ -294,7 +294,6 @@
<x:String x:Key="Text.GitLFS.Locks" xml:space="preserve">显示LFS对象锁</x:String>
<x:String x:Key="Text.GitLFS.Locks.Empty" xml:space="preserve">没有锁定的LFS文件</x:String>
<x:String x:Key="Text.GitLFS.Locks.Lock" xml:space="preserve">锁定</x:String>
<x:String x:Key="Text.GitLFS.Locks.OnlyMine" xml:space="preserve">仅显示被我锁定的文件</x:String>
<x:String x:Key="Text.GitLFS.Locks.Title" xml:space="preserve">LFS对象锁状态</x:String>
<x:String x:Key="Text.GitLFS.Locks.Unlock" xml:space="preserve">解锁</x:String>
<x:String x:Key="Text.GitLFS.Locks.UnlockForce" xml:space="preserve">强制解锁</x:String>

View file

@ -294,7 +294,6 @@
<x:String x:Key="Text.GitLFS.Locks" xml:space="preserve">顯示 LFS 物件鎖</x:String>
<x:String x:Key="Text.GitLFS.Locks.Empty" xml:space="preserve">沒有鎖定的 LFS 物件</x:String>
<x:String x:Key="Text.GitLFS.Locks.Lock" xml:space="preserve">鎖定</x:String>
<x:String x:Key="Text.GitLFS.Locks.OnlyMine" xml:space="preserve">僅顯示被我鎖定的檔案</x:String>
<x:String x:Key="Text.GitLFS.Locks.Title" xml:space="preserve">LFS 物件鎖</x:String>
<x:String x:Key="Text.GitLFS.Locks.Unlock" xml:space="preserve">解鎖</x:String>
<x:String x:Key="Text.GitLFS.Locks.UnlockForce" xml:space="preserve">強制解鎖</x:String>

View file

@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Avalonia.Collections;
using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
@ -9,49 +9,40 @@ namespace SourceGit.ViewModels
{
public class LFSLocks : ObservableObject
{
public bool HasValidUserName
{
get;
private set;
} = false;
public bool IsLoading
{
get => _isLoading;
private set => SetProperty(ref _isLoading, value);
}
public bool ShowOnlyMyLocks
public bool IsEmpty
{
get => _showOnlyMyLocks;
set
{
if (SetProperty(ref _showOnlyMyLocks, value))
UpdateVisibleLocks();
}
get => _isEmpty;
private set => SetProperty(ref _isEmpty, value);
}
public List<Models.LFSLock> VisibleLocks
public AvaloniaList<Models.LFSLock> Locks
{
get => _visibleLocks;
private set => SetProperty(ref _visibleLocks, value);
get;
private set;
}
public LFSLocks(string repo, string remote)
{
_repo = repo;
_remote = remote;
_userName = new Commands.Config(repo).Get("user.name");
HasValidUserName = !string.IsNullOrEmpty(_userName);
Locks = new AvaloniaList<Models.LFSLock>();
Task.Run(() =>
{
_cachedLocks = new Commands.LFS(_repo).Locks(_remote);
var collect = new Commands.LFS(_repo).Locks(_remote);
Dispatcher.UIThread.Invoke(() =>
{
UpdateVisibleLocks();
if (collect.Count > 0)
Locks.AddRange(collect);
IsLoading = false;
IsEmpty = collect.Count == 0;
});
});
}
@ -68,41 +59,17 @@ namespace SourceGit.ViewModels
Dispatcher.UIThread.Invoke(() =>
{
if (succ)
{
_cachedLocks.Remove(lfsLock);
UpdateVisibleLocks();
}
Locks.Remove(lfsLock);
IsLoading = false;
IsEmpty = Locks.Count == 0;
});
});
}
private void UpdateVisibleLocks()
{
if (!_showOnlyMyLocks)
{
VisibleLocks = _cachedLocks;
}
else
{
var visible = new List<Models.LFSLock>();
foreach (var lfsLock in _cachedLocks)
{
if (lfsLock.User == _userName)
visible.Add(lfsLock);
}
VisibleLocks = visible;
}
}
private string _repo;
private string _remote;
private bool _isLoading = true;
private List<Models.LFSLock> _cachedLocks = [];
private List<Models.LFSLock> _visibleLocks = [];
private bool _showOnlyMyLocks = false;
private string _userName;
private bool _isEmpty = false;
}
}

View file

@ -5,7 +5,6 @@
xmlns:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels"
xmlns:v="using:SourceGit.Views"
xmlns:c="using:SourceGit.Converters"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.LFSLocks"
x:DataType="vm:LFSLocks"
@ -14,7 +13,7 @@
Title="{DynamicResource Text.GitLFS.Locks.Title}"
Width="600" Height="400"
WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="Auto,Auto,*">
<Grid RowDefinitions="Auto,*">
<!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3"
@ -44,25 +43,11 @@
IsVisible="{OnPlatform True, macOS=False}"/>
</Grid>
<!-- Filter and Unlock All -->
<CheckBox Grid.Row="1"
Margin="8,0,0,0"
Content="{DynamicResource Text.GitLFS.Locks.OnlyMine}"
IsChecked="{Binding ShowOnlyMyLocks, Mode=TwoWay}"
VerticalAlignment="Center">
<CheckBox.IsEnabled>
<MultiBinding Converter="{x:Static BoolConverters.And}">
<Binding Path="HasValidUserName"/>
<Binding Path="!IsLoading"/>
</MultiBinding>
</CheckBox.IsEnabled>
</CheckBox>
<!-- Locked Files -->
<Grid Grid.Row="2">
<ListBox Margin="8,0,8,8"
<Grid Grid.Row="1">
<ListBox Margin="8"
Background="{DynamicResource Brush.Contents}"
ItemsSource="{Binding VisibleLocks}"
ItemsSource="{Binding Locks}"
SelectionMode="Single"
BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}"
@ -104,14 +89,9 @@
</ListBox>
<!-- Empty -->
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel.IsVisible>
<MultiBinding Converter="{x:Static BoolConverters.And}">
<Binding Path="!IsLoading"/>
<Binding Path="VisibleLocks" Converter="{x:Static c:ListConverters.IsNullOrEmpty}"/>
</MultiBinding>
</StackPanel.IsVisible>
<StackPanel Orientation="Vertical"
HorizontalAlignment="Center" VerticalAlignment="Center"
IsVisible="{Binding IsEmpty}">
<Path Width="48" Height="48" Data="{StaticResource Icons.Empty}" Fill="{DynamicResource Brush.FG2}"/>
<TextBlock Margin="0,16,0,0" Text="{DynamicResource Text.GitLFS.Locks.Empty}" Foreground="{DynamicResource Brush.FG2}"/>
</StackPanel>