-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to remember vault choice for a given action and parameter
- Loading branch information
1 parent
3e6d1ea
commit 26c6590
Showing
7 changed files
with
148 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 38 additions & 3 deletions
41
src/ScriptRunner/ScriptRunner.GUI/Views/VaultPicker.axaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,63 @@ | ||
using System.Collections.Generic; | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Interactivity; | ||
using Avalonia.Markup.Xaml; | ||
using ReactiveUI; | ||
using ScriptRunner.GUI.ViewModels; | ||
|
||
namespace ScriptRunner.GUI.Views | ||
{ | ||
public class VaultPickerViewModel:ViewModelBase | ||
{ | ||
public IReadOnlyList<VaultEntry> Entries { get; set; } | ||
|
||
public VaultEntry? SelectedEntry | ||
{ | ||
get => _selectedEntry; | ||
set => this.RaiseAndSetIfChanged(ref _selectedEntry, value); | ||
} | ||
|
||
private VaultEntry? _selectedEntry; | ||
|
||
|
||
|
||
} | ||
|
||
public partial class VaultPicker : Window | ||
{ | ||
public VaultPicker() | ||
{ | ||
|
||
DataContext = VaultProvider.ReadFromVault(); | ||
DataContext = this.ViewModel = new VaultPickerViewModel | ||
{ | ||
Entries = VaultProvider.ReadFromVault() | ||
}; | ||
InitializeComponent(); | ||
#if DEBUG | ||
this.AttachDevTools(); | ||
#endif | ||
} | ||
|
||
public VaultPickerViewModel ViewModel { get; set; } | ||
|
||
|
||
private void Accept(object? sender, RoutedEventArgs e) | ||
{ | ||
Close((SecretsCombo.SelectedItem as VaultEntry)?.Secret); | ||
if(SecretsCombo.SelectedItem is VaultEntry selectedEntry) | ||
{ | ||
Close(new VaultEntryChoice() | ||
{ | ||
RememberBinding = this.Remember.IsChecked ?? false, | ||
SelectedEntry = selectedEntry | ||
}); | ||
} | ||
|
||
} | ||
} | ||
|
||
public class VaultEntryChoice | ||
{ | ||
public bool RememberBinding { get; set; } | ||
public VaultEntry SelectedEntry { get; set; } | ||
} | ||
} |