mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
Compare commits
5 commits
1ba294a07b
...
d34aa8cb7e
Author | SHA1 | Date | |
---|---|---|---|
|
d34aa8cb7e | ||
|
5d2a442144 | ||
|
21498f7009 | ||
|
4a08caddad | ||
|
1cda5d858e |
7 changed files with 86 additions and 25 deletions
|
@ -10,6 +10,9 @@ namespace SourceGit.Converters
|
||||||
public static readonly FuncValueConverter<IList, string> ToCount =
|
public static readonly FuncValueConverter<IList, string> ToCount =
|
||||||
new FuncValueConverter<IList, string>(v => v == null ? " (0)" : $" ({v.Count})");
|
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 =
|
public static readonly FuncValueConverter<IList, bool> IsNotNullOrEmpty =
|
||||||
new FuncValueConverter<IList, bool>(v => v != null && v.Count > 0);
|
new FuncValueConverter<IList, bool>(v => v != null && v.Count > 0);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ namespace SourceGit.Models
|
||||||
new ResetMode("Soft", "Keep all changes. Stage differences", "--soft", Brushes.Green),
|
new ResetMode("Soft", "Keep all changes. Stage differences", "--soft", Brushes.Green),
|
||||||
new ResetMode("Mixed", "Keep all changes. Unstage differences", "--mixed", Brushes.Orange),
|
new ResetMode("Mixed", "Keep all changes. Unstage differences", "--mixed", Brushes.Orange),
|
||||||
new ResetMode("Hard", "Discard all changes", "--hard", Brushes.Red),
|
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; }
|
public string Name { get; set; }
|
||||||
|
|
|
@ -291,6 +291,7 @@
|
||||||
<x:String x:Key="Text.GitLFS.Locks" xml:space="preserve">Show Locks</x:String>
|
<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.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.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.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.Unlock" xml:space="preserve">Unlock</x:String>
|
||||||
<x:String x:Key="Text.GitLFS.Locks.UnlockForce" xml:space="preserve">Force Unlock</x:String>
|
<x:String x:Key="Text.GitLFS.Locks.UnlockForce" xml:space="preserve">Force Unlock</x:String>
|
||||||
|
|
|
@ -294,6 +294,7 @@
|
||||||
<x:String x:Key="Text.GitLFS.Locks" xml:space="preserve">显示LFS对象锁</x:String>
|
<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.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.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.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.Unlock" xml:space="preserve">解锁</x:String>
|
||||||
<x:String x:Key="Text.GitLFS.Locks.UnlockForce" xml:space="preserve">强制解锁</x:String>
|
<x:String x:Key="Text.GitLFS.Locks.UnlockForce" xml:space="preserve">强制解锁</x:String>
|
||||||
|
|
|
@ -294,6 +294,7 @@
|
||||||
<x:String x:Key="Text.GitLFS.Locks" xml:space="preserve">顯示 LFS 物件鎖</x:String>
|
<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.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.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.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.Unlock" xml:space="preserve">解鎖</x:String>
|
||||||
<x:String x:Key="Text.GitLFS.Locks.UnlockForce" xml:space="preserve">強制解鎖</x:String>
|
<x:String x:Key="Text.GitLFS.Locks.UnlockForce" xml:space="preserve">強制解鎖</x:String>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Threading.Tasks;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using Avalonia.Collections;
|
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
@ -9,40 +9,49 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
public class LFSLocks : ObservableObject
|
public class LFSLocks : ObservableObject
|
||||||
{
|
{
|
||||||
|
public bool HasValidUserName
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
} = false;
|
||||||
|
|
||||||
public bool IsLoading
|
public bool IsLoading
|
||||||
{
|
{
|
||||||
get => _isLoading;
|
get => _isLoading;
|
||||||
private set => SetProperty(ref _isLoading, value);
|
private set => SetProperty(ref _isLoading, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsEmpty
|
public bool ShowOnlyMyLocks
|
||||||
{
|
{
|
||||||
get => _isEmpty;
|
get => _showOnlyMyLocks;
|
||||||
private set => SetProperty(ref _isEmpty, value);
|
set
|
||||||
|
{
|
||||||
|
if (SetProperty(ref _showOnlyMyLocks, value))
|
||||||
|
UpdateVisibleLocks();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AvaloniaList<Models.LFSLock> Locks
|
public List<Models.LFSLock> VisibleLocks
|
||||||
{
|
{
|
||||||
get;
|
get => _visibleLocks;
|
||||||
private set;
|
private set => SetProperty(ref _visibleLocks, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LFSLocks(string repo, string remote)
|
public LFSLocks(string repo, string remote)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_remote = remote;
|
_remote = remote;
|
||||||
Locks = new AvaloniaList<Models.LFSLock>();
|
_userName = new Commands.Config(repo).Get("user.name");
|
||||||
|
|
||||||
|
HasValidUserName = !string.IsNullOrEmpty(_userName);
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
var collect = new Commands.LFS(_repo).Locks(_remote);
|
_cachedLocks = new Commands.LFS(_repo).Locks(_remote);
|
||||||
Dispatcher.UIThread.Invoke(() =>
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
{
|
{
|
||||||
if (collect.Count > 0)
|
UpdateVisibleLocks();
|
||||||
Locks.AddRange(collect);
|
|
||||||
|
|
||||||
IsLoading = false;
|
IsLoading = false;
|
||||||
IsEmpty = collect.Count == 0;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -59,17 +68,41 @@ namespace SourceGit.ViewModels
|
||||||
Dispatcher.UIThread.Invoke(() =>
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
{
|
{
|
||||||
if (succ)
|
if (succ)
|
||||||
Locks.Remove(lfsLock);
|
{
|
||||||
|
_cachedLocks.Remove(lfsLock);
|
||||||
|
UpdateVisibleLocks();
|
||||||
|
}
|
||||||
|
|
||||||
IsLoading = false;
|
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 _repo;
|
||||||
private string _remote;
|
private string _remote;
|
||||||
private bool _isLoading = true;
|
private bool _isLoading = true;
|
||||||
private bool _isEmpty = false;
|
private List<Models.LFSLock> _cachedLocks = [];
|
||||||
|
private List<Models.LFSLock> _visibleLocks = [];
|
||||||
|
private bool _showOnlyMyLocks = false;
|
||||||
|
private string _userName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
xmlns:m="using:SourceGit.Models"
|
xmlns:m="using:SourceGit.Models"
|
||||||
xmlns:vm="using:SourceGit.ViewModels"
|
xmlns:vm="using:SourceGit.ViewModels"
|
||||||
xmlns:v="using:SourceGit.Views"
|
xmlns:v="using:SourceGit.Views"
|
||||||
|
xmlns:c="using:SourceGit.Converters"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="SourceGit.Views.LFSLocks"
|
x:Class="SourceGit.Views.LFSLocks"
|
||||||
x:DataType="vm:LFSLocks"
|
x:DataType="vm:LFSLocks"
|
||||||
|
@ -13,7 +14,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 +44,25 @@
|
||||||
IsVisible="{OnPlatform True, macOS=False}"/>
|
IsVisible="{OnPlatform True, macOS=False}"/>
|
||||||
</Grid>
|
</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 -->
|
<!-- 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 VisibleLocks}"
|
||||||
SelectionMode="Single"
|
SelectionMode="Single"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
BorderBrush="{DynamicResource Brush.Border2}"
|
BorderBrush="{DynamicResource Brush.Border2}"
|
||||||
|
@ -89,9 +104,14 @@
|
||||||
</ListBox>
|
</ListBox>
|
||||||
|
|
||||||
<!-- Empty -->
|
<!-- Empty -->
|
||||||
<StackPanel Orientation="Vertical"
|
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
<StackPanel.IsVisible>
|
||||||
IsVisible="{Binding IsEmpty}">
|
<MultiBinding Converter="{x:Static BoolConverters.And}">
|
||||||
|
<Binding Path="!IsLoading"/>
|
||||||
|
<Binding Path="VisibleLocks" Converter="{x:Static c:ListConverters.IsNullOrEmpty}"/>
|
||||||
|
</MultiBinding>
|
||||||
|
</StackPanel.IsVisible>
|
||||||
|
|
||||||
<Path Width="48" Height="48" Data="{StaticResource Icons.Empty}" Fill="{DynamicResource Brush.FG2}"/>
|
<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}"/>
|
<TextBlock Margin="0,16,0,0" Text="{DynamicResource Text.GitLFS.Locks.Empty}" Foreground="{DynamicResource Brush.FG2}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
Loading…
Reference in a new issue