refactor: address code review findings across all projects
Apply comprehensive fixes from code reviews including: - Extract shared utilities (SqlFormatHelper, CellValueConverter, DbDestinationBase) - Add interface abstractions (IAuthenticationService, IDatabaseMigrator, IMisQueryBuilder) - Implement SecureStore for encrypted secrets storage - Fix error handling with proper HTTP status codes and logging - Optimize double enumeration in DevEtlRegistry - Add DataSync.Dev README for developer onboarding - Extract filter panel base classes to reduce duplication - Update code review docs to mark all issues as fixed
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace JdeScoping.SecureStoreManager.ViewModels;
|
||||
|
||||
/// <summary>
|
||||
/// View model for an individual secret item with show/hide toggle.
|
||||
/// </summary>
|
||||
public class SecretItemViewModel : ViewModelBase
|
||||
{
|
||||
private readonly string _actualValue;
|
||||
private bool _isValueVisible;
|
||||
private const string MaskedValue = "********";
|
||||
|
||||
public SecretItemViewModel(string key, string value)
|
||||
{
|
||||
Key = key;
|
||||
_actualValue = value;
|
||||
ToggleVisibilityCommand = new RelayCommand(ToggleVisibility);
|
||||
CopyToClipboardCommand = new RelayCommand(CopyToClipboard);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the secret key.
|
||||
/// </summary>
|
||||
public string Key { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the displayed value (masked or actual based on visibility).
|
||||
/// </summary>
|
||||
public string DisplayValue => _isValueVisible ? _actualValue : MaskedValue;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the actual unmasked value.
|
||||
/// </summary>
|
||||
public string ActualValue => _actualValue;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the value is visible.
|
||||
/// </summary>
|
||||
public bool IsValueVisible
|
||||
{
|
||||
get => _isValueVisible;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _isValueVisible, value))
|
||||
{
|
||||
OnPropertyChanged(nameof(DisplayValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command to toggle visibility of the secret value.
|
||||
/// </summary>
|
||||
public ICommand ToggleVisibilityCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Command to copy the secret value to clipboard.
|
||||
/// </summary>
|
||||
public ICommand CopyToClipboardCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Event raised when clipboard copy is requested.
|
||||
/// The view subscribes to this to perform the actual clipboard operation.
|
||||
/// </summary>
|
||||
public event Func<string, Task>? OnCopyToClipboard;
|
||||
|
||||
private void ToggleVisibility()
|
||||
{
|
||||
IsValueVisible = !IsValueVisible;
|
||||
}
|
||||
|
||||
private async void CopyToClipboard()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (OnCopyToClipboard != null)
|
||||
{
|
||||
await OnCopyToClipboard(_actualValue);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Clipboard operations can fail in some scenarios
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user