chore: deprecate standalone SecureStoreManager utility
Move SecureStoreManager project and tests to Deprecated folder and remove from solution. SecureStore functionality is now integrated into ConfigManager.
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
using System.Windows.Input;
|
||||
using JdeScoping.SecureStoreManager.Services;
|
||||
|
||||
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 readonly IClipboardService _clipboardService;
|
||||
private bool _isValueVisible;
|
||||
private const string MaskedValue = "********";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SecretItemViewModel"/> class.
|
||||
/// </summary>
|
||||
/// <param name="key">The secret key name.</param>
|
||||
/// <param name="value">The secret value.</param>
|
||||
/// <param name="clipboardService">The clipboard service for copy operations.</param>
|
||||
public SecretItemViewModel(string key, string value, IClipboardService clipboardService)
|
||||
{
|
||||
Key = key;
|
||||
_actualValue = value;
|
||||
_clipboardService = clipboardService ?? throw new ArgumentNullException(nameof(clipboardService));
|
||||
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 fails.
|
||||
/// </summary>
|
||||
public event Action<string>? OnCopyFailed;
|
||||
|
||||
private void ToggleVisibility()
|
||||
{
|
||||
IsValueVisible = !IsValueVisible;
|
||||
}
|
||||
|
||||
private async void CopyToClipboard()
|
||||
{
|
||||
try
|
||||
{
|
||||
await _clipboardService.SetTextAsync(_actualValue);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnCopyFailed?.Invoke($"Failed to copy to clipboard: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user