fix(uploader): sign-in default button, neutral watch status, typed MB/s limit
The hidden sign-in button is the default only while visible and sign-in runs only when signed out; the password copy is cleared after success. A watch folder shows a neutral dot until its first check. The MB/s field parses its own text so invalid input reverts instead of showing a framework validation message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
3 files changed
+46
-48
No files matched your search
@@ -17,7 +17,6 @@ public sealed class ConnectViewModel : ObservableObject
|
||||
private string _address;
|
||||
private string _username;
|
||||
private string? _errorText;
|
||||
private bool _isBusy;
|
||||
|
||||
public ConnectViewModel(IServerSession session, IUploaderDialogs dialogs, string? address, string? username)
|
||||
{
|
||||
@@ -53,12 +52,6 @@ public sealed class ConnectViewModel : ObservableObject
|
||||
/// <summary>Set from the view's PasswordBox; never stored.</summary>
|
||||
public string Password { private get; set; } = string.Empty;
|
||||
|
||||
public bool IsBusy
|
||||
{
|
||||
get => _isBusy;
|
||||
private set => Set(ref _isBusy, value);
|
||||
}
|
||||
|
||||
/// <summary>One sentence saying what went wrong; the retry action sits next to it.</summary>
|
||||
public string? ErrorText
|
||||
{
|
||||
@@ -78,36 +71,31 @@ public sealed class ConnectViewModel : ObservableObject
|
||||
|
||||
private async Task SignInAsync()
|
||||
{
|
||||
if (_session.State is not (ConnectionState.NotConfigured or ConnectionState.SignedOut)) return;
|
||||
ErrorText = null;
|
||||
IsBusy = true;
|
||||
try
|
||||
var (result, fingerprint) = await _session.SignInAsync(Address, Username.Trim(), Password, CancellationToken.None);
|
||||
if (result == SignInResult.Untrusted && fingerprint is not null)
|
||||
{
|
||||
var (result, fingerprint) = await _session.SignInAsync(Address, Username.Trim(), Password, CancellationToken.None);
|
||||
if (result == SignInResult.Untrusted && fingerprint is not null)
|
||||
if (!_dialogs.ConfirmTrust(Display(Address), fingerprint))
|
||||
{
|
||||
if (!_dialogs.ConfirmTrust(Display(Address), fingerprint))
|
||||
{
|
||||
ErrorText = Loc.L("Uploader.Connect.Error.Untrusted");
|
||||
return;
|
||||
}
|
||||
_session.Trust(fingerprint);
|
||||
(result, _) = await _session.SignInAsync(Address, Username.Trim(), Password, CancellationToken.None);
|
||||
ErrorText = Loc.L("Uploader.Connect.Error.Untrusted");
|
||||
return;
|
||||
}
|
||||
ErrorText = result switch
|
||||
{
|
||||
SignInResult.Success => null,
|
||||
SignInResult.InvalidAddress => Loc.L("Uploader.Connect.Error.InvalidAddress"),
|
||||
SignInResult.Unreachable => Loc.L("Uploader.Connect.Error.Unreachable"),
|
||||
SignInResult.NotTitano => Loc.L("Uploader.Connect.Error.NotTitano"),
|
||||
SignInResult.BadCredentials => Loc.L("Uploader.Connect.Error.BadCredentials"),
|
||||
SignInResult.Untrusted => Loc.L("Uploader.Connect.Error.Untrusted"),
|
||||
_ => Loc.L("Uploader.Connect.Error.Failed"),
|
||||
};
|
||||
if (result == SignInResult.Success) Address = Display(_session.Address);
|
||||
_session.Trust(fingerprint);
|
||||
(result, _) = await _session.SignInAsync(Address, Username.Trim(), Password, CancellationToken.None);
|
||||
}
|
||||
finally
|
||||
ErrorText = result switch
|
||||
{
|
||||
IsBusy = false;
|
||||
}
|
||||
SignInResult.Success => null,
|
||||
SignInResult.InvalidAddress => Loc.L("Uploader.Connect.Error.InvalidAddress"),
|
||||
SignInResult.Unreachable => Loc.L("Uploader.Connect.Error.Unreachable"),
|
||||
SignInResult.NotTitano => Loc.L("Uploader.Connect.Error.NotTitano"),
|
||||
SignInResult.BadCredentials => Loc.L("Uploader.Connect.Error.BadCredentials"),
|
||||
SignInResult.Untrusted => Loc.L("Uploader.Connect.Error.Untrusted"),
|
||||
_ => Loc.L("Uploader.Connect.Error.Failed"),
|
||||
};
|
||||
if (result != SignInResult.Success) return;
|
||||
Address = Display(_session.Address);
|
||||
Password = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
@@ -237,17 +238,22 @@ public sealed class MainViewModel : LocalizedViewModel
|
||||
/// <summary>Accessible name of the pause/resume button (also the tray menu entry).</summary>
|
||||
public string PauseLabel => Loc.L(IsPaused ? "Uploader.Action.Resume" : "Uploader.Action.Pause");
|
||||
|
||||
/// <summary>Upload limit in MB/s; 0 = unlimited.</summary>
|
||||
public int BandwidthLimit
|
||||
/// <summary>Upload limit in MB/s as typed; 0 = unlimited. Text that is not a whole number reverts.</summary>
|
||||
public string BandwidthLimitText
|
||||
{
|
||||
get => _s.Session.BandwidthLimit;
|
||||
get => _s.Session.BandwidthLimit.ToString(Loc.Culture);
|
||||
set
|
||||
{
|
||||
var clamped = Math.Clamp(value, 0, 100_000);
|
||||
if (clamped == _s.Session.BandwidthLimit) return;
|
||||
_s.Session.BandwidthLimit = clamped;
|
||||
_s.Settings.BandwidthLimit = clamped;
|
||||
_s.SaveSettings();
|
||||
if (int.TryParse(value, NumberStyles.Integer, Loc.Culture, out var limit))
|
||||
{
|
||||
limit = Math.Clamp(limit, 0, 100_000);
|
||||
if (limit != _s.Session.BandwidthLimit)
|
||||
{
|
||||
_s.Session.BandwidthLimit = limit;
|
||||
_s.Settings.BandwidthLimit = limit;
|
||||
_s.SaveSettings();
|
||||
}
|
||||
}
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
@@ -515,7 +521,7 @@ public sealed class MainViewModel : LocalizedViewModel
|
||||
OnPropertyChanged(nameof(ConnectionText));
|
||||
OnPropertyChanged(nameof(QuotaText));
|
||||
OnPropertyChanged(nameof(IsConnectVisible));
|
||||
OnPropertyChanged(nameof(BandwidthLimit));
|
||||
OnPropertyChanged(nameof(BandwidthLimitText));
|
||||
if (e.PropertyName != nameof(IServerSession.State)) return;
|
||||
if (_s.Session.State == ConnectionState.Connected) _ = LoadSequencesAsync();
|
||||
if (IsConnectVisible)
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="{l:Loc Uploader.Connect.Server}" Style="{StaticResource Text.Label}" />
|
||||
<TextBox x:Name="Address" Grid.Column="1" Text="{Binding Address, UpdateSourceTrigger=PropertyChanged}" ui:Field.Glyph="{StaticResource Icon.Server}"
|
||||
<TextBox Grid.Column="1" Text="{Binding Address, UpdateSourceTrigger=PropertyChanged}" ui:Field.Glyph="{StaticResource Icon.Server}"
|
||||
ui:Field.Placeholder="{l:Loc Uploader.Connect.AddressPlaceholder}" ToolTip="{l:Loc Tooltips.Uploader.ServerAddress}" AutomationProperties.Name="{l:Loc Uploader.Connect.Server}" />
|
||||
|
||||
<TextBlock Grid.Row="1" Text="{l:Loc Uploader.Connect.Found}" Style="{StaticResource Text.Label}" Margin="0,8,12,0" VerticalAlignment="Top"
|
||||
@@ -168,7 +168,8 @@
|
||||
</DockPanel>
|
||||
</Border>
|
||||
|
||||
<Button Grid.Row="5" Grid.Column="1" Margin="0,20,0,0" HorizontalAlignment="Left" Style="{StaticResource Button.Primary}" MinWidth="120" IsDefault="True"
|
||||
<Button Grid.Row="5" Grid.Column="1" Margin="0,20,0,0" HorizontalAlignment="Left" Style="{StaticResource Button.Primary}" MinWidth="120"
|
||||
IsDefault="{Binding IsVisible, RelativeSource={RelativeSource Self}}"
|
||||
Content="{l:Loc Uploader.Connect.SignIn}" Command="{Binding SignInCommand}" ToolTip="{l:Loc Tooltips.Uploader.SignIn}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
@@ -188,14 +189,14 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Drop zone: the empty state's sentence and button. -->
|
||||
<Grid x:Name="DropZone" Height="150" Background="Transparent">
|
||||
<Grid Height="150" Background="Transparent">
|
||||
<Rectangle x:Name="DropBorder" RadiusX="8" RadiusY="8" StrokeThickness="2" StrokeDashArray="3 2" SnapsToDevicePixels="True"
|
||||
Stroke="{DynamicResource Brush.Stroke}" Fill="Transparent" />
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<ui:Icon Glyph="{StaticResource Icon.Upload}" Size="28" Foreground="{DynamicResource Brush.TextMuted}" HorizontalAlignment="Center" />
|
||||
<TextBlock Text="{l:Loc Uploader.Drop.Message}" FontSize="{StaticResource Size.Section}" Foreground="{DynamicResource Brush.TextMuted}"
|
||||
HorizontalAlignment="Center" Margin="0,10,0,10" />
|
||||
<Button x:Name="BrowseButton" Content="{l:Loc Uploader.Browse.Button}" Height="30" Padding="14,0" HorizontalAlignment="Center"
|
||||
<Button Content="{l:Loc Uploader.Browse.Button}" Height="30" Padding="14,0" HorizontalAlignment="Center"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.Browse}" Click="OnBrowseClick">
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu>
|
||||
@@ -258,7 +259,7 @@
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="3" Orientation="Horizontal" Margin="16,0,0,0">
|
||||
<TextBlock Text="{l:Loc Uploader.Limit.Label}" Style="{StaticResource Text.Base}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,0,6,0" />
|
||||
<TextBox Width="58" Height="30" Text="{Binding BandwidthLimit}" TextAlignment="Right" ToolTip="{l:Loc Tooltips.Uploader.Limit}"
|
||||
<TextBox Width="58" Height="30" Text="{Binding BandwidthLimitText}" TextAlignment="Right" ToolTip="{l:Loc Tooltips.Uploader.Limit}"
|
||||
AutomationProperties.Name="{l:Loc Uploader.Limit.Label}" />
|
||||
<TextBlock Text="{l:Loc Uploader.Limit.Unit}" Style="{StaticResource Text.Base}" Foreground="{DynamicResource Brush.TextMuted}" Margin="6,0,0,0" />
|
||||
</StackPanel>
|
||||
@@ -299,11 +300,14 @@
|
||||
</Button.ContextMenu>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Ellipse x:Name="Dot" Width="8" Height="8" Margin="0,0,8,0" VerticalAlignment="Center" StrokeThickness="1.5"
|
||||
Fill="{DynamicResource Brush.Success}" />
|
||||
Fill="{DynamicResource Brush.TextFaint}" />
|
||||
<TextBlock Text="{Binding Text}" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<DataTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding IsAvailable}" Value="True">
|
||||
<Setter TargetName="Dot" Property="Fill" Value="{DynamicResource Brush.Success}" />
|
||||
</DataTrigger>
|
||||
<!-- Unreachable: hollow ring (shape, not colour alone), reason in the tooltip. -->
|
||||
<DataTrigger Binding="{Binding IsAvailable}" Value="False">
|
||||
<Setter TargetName="Dot" Property="Fill" Value="Transparent" />
|
||||
@@ -405,7 +409,7 @@
|
||||
<TextBlock Grid.Row="3" Text="{l:Loc Uploader.Settings.Bandwidth}" Style="{StaticResource Text.Label}" MinWidth="0" />
|
||||
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<TextBlock Text="{l:Loc Uploader.Limit.Label}" Style="{StaticResource Text.Base}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,0,6,0" />
|
||||
<TextBox Width="58" Height="30" Text="{Binding BandwidthLimit}" TextAlignment="Right" ToolTip="{l:Loc Tooltips.Uploader.Limit}"
|
||||
<TextBox Width="58" Height="30" Text="{Binding BandwidthLimitText}" TextAlignment="Right" ToolTip="{l:Loc Tooltips.Uploader.Limit}"
|
||||
AutomationProperties.Name="{l:Loc Uploader.Limit.Label}" />
|
||||
<TextBlock Text="{l:Loc Uploader.Limit.Unit}" Style="{StaticResource Text.Base}" Foreground="{DynamicResource Brush.TextMuted}" Margin="6,0,0,0" />
|
||||
</StackPanel>
|
||||
|
||||
Reference in new issue
Block a user