From 60ca5ff76836343f70765d2cdc9279be29f912ff Mon Sep 17 00:00:00 2001 From: Sacha Bruttin Date: Fri, 5 May 2023 09:12:10 +0200 Subject: [PATCH] 98 encrypt connection string when entered with characters (#100) * #98 Show * when password is entered * Remove old Textbox replaced by PasswordBox * Add format validation on AccountEndpoint --- src/CosmosDbExplorer/App.xaml | 18 +- .../Styles/CosmosControls.xaml | 86 +++++++--- src/CosmosDbExplorer/Styles/Icons.xaml | 129 +++++++------- src/CosmosDbExplorer/Styles/MetroWindow.xaml | 4 +- src/CosmosDbExplorer/Styles/TextBlock.xaml | 47 ++++-- .../Styles/Themes/Dark.Blue.xaml | 25 ++- .../Styles/Themes/Light.Blue.xaml | 25 ++- src/CosmosDbExplorer/Styles/_Thickness.xaml | 12 +- .../ViewModels/AccountSettingsViewModel.cs | 5 + .../Views/AccountSettingsPage.xaml | 158 ++++++++++++------ 10 files changed, 326 insertions(+), 183 deletions(-) diff --git a/src/CosmosDbExplorer/App.xaml b/src/CosmosDbExplorer/App.xaml index 856231c..05ac986 100644 --- a/src/CosmosDbExplorer/App.xaml +++ b/src/CosmosDbExplorer/App.xaml @@ -3,16 +3,16 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:converters="clr-namespace:CosmosDbExplorer.Converters" - Startup="OnStartup" - Exit="OnExit" xmlns:theming="clr-namespace:CosmosDbExplorer.Styles" - DispatcherUnhandledException="OnDispatcherUnhandledException"> + DispatcherUnhandledException="OnDispatcherUnhandledException" + Exit="OnExit" + Startup="OnStartup"> - + @@ -23,7 +23,7 @@ - + @@ -31,16 +31,16 @@ - + - + diff --git a/src/CosmosDbExplorer/Styles/CosmosControls.xaml b/src/CosmosDbExplorer/Styles/CosmosControls.xaml index 956a4ce..8aa1c00 100644 --- a/src/CosmosDbExplorer/Styles/CosmosControls.xaml +++ b/src/CosmosDbExplorer/Styles/CosmosControls.xaml @@ -1,37 +1,54 @@ - + - - - - - - + + + - - + + @@ -40,30 +57,47 @@ - + - + - + - + - + - + - + - + - + diff --git a/src/CosmosDbExplorer/Styles/Icons.xaml b/src/CosmosDbExplorer/Styles/Icons.xaml index d46af43..a8dd890 100644 --- a/src/CosmosDbExplorer/Styles/Icons.xaml +++ b/src/CosmosDbExplorer/Styles/Icons.xaml @@ -1,24 +1,29 @@ - + - - - - - - + + @@ -30,14 +35,17 @@ - - - - - - + + + @@ -50,8 +58,8 @@ - - + + @@ -65,8 +73,8 @@ - - + + @@ -83,7 +91,7 @@ - + @@ -101,8 +109,8 @@ - - + + @@ -116,8 +124,8 @@ - - + + @@ -132,14 +140,17 @@ - - - - - + + @@ -151,8 +162,8 @@ - - + + @@ -168,8 +179,8 @@ - - + + @@ -181,8 +192,8 @@ - - + + @@ -196,8 +207,8 @@ - - + + @@ -210,8 +221,8 @@ - - + + @@ -225,8 +236,8 @@ - - + + @@ -239,7 +250,7 @@ - + @@ -253,7 +264,7 @@ - + @@ -266,8 +277,8 @@ - - + + @@ -289,7 +300,7 @@ - + @@ -302,8 +313,8 @@ - - + + @@ -316,8 +327,8 @@ - - + + @@ -333,8 +344,8 @@ - - + + @@ -351,7 +362,7 @@ - + @@ -365,7 +376,7 @@ - + @@ -439,7 +450,10 @@ - @@ -488,7 +502,7 @@ - + @@ -503,7 +517,10 @@ - diff --git a/src/CosmosDbExplorer/Styles/MetroWindow.xaml b/src/CosmosDbExplorer/Styles/MetroWindow.xaml index 2ddb27e..98260e8 100644 --- a/src/CosmosDbExplorer/Styles/MetroWindow.xaml +++ b/src/CosmosDbExplorer/Styles/MetroWindow.xaml @@ -5,8 +5,8 @@ - - - + - - - - diff --git a/src/CosmosDbExplorer/Styles/Themes/Dark.Blue.xaml b/src/CosmosDbExplorer/Styles/Themes/Dark.Blue.xaml index 4f58f50..1f1bd38 100644 --- a/src/CosmosDbExplorer/Styles/Themes/Dark.Blue.xaml +++ b/src/CosmosDbExplorer/Styles/Themes/Dark.Blue.xaml @@ -1,9 +1,10 @@ - + Dark.Blue @@ -14,10 +15,16 @@ Blue #FF0078D7 - + False - - + + \ No newline at end of file diff --git a/src/CosmosDbExplorer/Styles/Themes/Light.Blue.xaml b/src/CosmosDbExplorer/Styles/Themes/Light.Blue.xaml index c5301c6..1fe2009 100644 --- a/src/CosmosDbExplorer/Styles/Themes/Light.Blue.xaml +++ b/src/CosmosDbExplorer/Styles/Themes/Light.Blue.xaml @@ -1,9 +1,10 @@ - + Light.Blue @@ -14,10 +15,16 @@ Blue #FF0078D7 - + False - - + + \ No newline at end of file diff --git a/src/CosmosDbExplorer/Styles/_Thickness.xaml b/src/CosmosDbExplorer/Styles/_Thickness.xaml index 49abd94..14423cb 100644 --- a/src/CosmosDbExplorer/Styles/_Thickness.xaml +++ b/src/CosmosDbExplorer/Styles/_Thickness.xaml @@ -1,8 +1,6 @@ - + - + 24,0,0,0 24,24,24,0 0,24,0,0 @@ -10,7 +8,7 @@ 0, 0, 0, 24 24,24,24,24 - + 12, 0, 0, 0 12, 12, 0, 0 12, 0, 12, 0 @@ -19,12 +17,12 @@ 0, 12, 0, 12 12, 12, 12, 12 - + 8, 0, 0, 0 0, 8, 0, 0 8, 8, 8, 8 - + 0, 4, 0, 0 diff --git a/src/CosmosDbExplorer/ViewModels/AccountSettingsViewModel.cs b/src/CosmosDbExplorer/ViewModels/AccountSettingsViewModel.cs index 19dba6e..161f773 100644 --- a/src/CosmosDbExplorer/ViewModels/AccountSettingsViewModel.cs +++ b/src/CosmosDbExplorer/ViewModels/AccountSettingsViewModel.cs @@ -143,6 +143,11 @@ public class AccountSettingsViewModelValidator : AbstractValidator x.AccountEndpoint).NotEmpty().When(x => !x.UseLocalEmulator); + RuleFor(x => x.AccountEndpoint) + .Must(uri => Uri.TryCreate(uri, UriKind.Absolute, out _)) + .When(x => !string.IsNullOrWhiteSpace(x.AccountEndpoint)) + .WithMessage("'{PropertyName}' must be a valid URI."); + RuleFor(x => x.AccountSecret).NotEmpty().When(x => !x.UseLocalEmulator); RuleFor(x => x.Label).NotEmpty(); } diff --git a/src/CosmosDbExplorer/Views/AccountSettingsPage.xaml b/src/CosmosDbExplorer/Views/AccountSettingsPage.xaml index 1b1b577..a0ff500 100644 --- a/src/CosmosDbExplorer/Views/AccountSettingsPage.xaml +++ b/src/CosmosDbExplorer/Views/AccountSettingsPage.xaml @@ -1,25 +1,27 @@ - + - + @@ -27,11 +29,13 @@ - - - - + + + + @@ -39,9 +43,11 @@ - - + + @@ -50,10 +56,17 @@ - - + + @@ -62,9 +75,19 @@ - - + + + @@ -73,10 +96,16 @@ - - + + @@ -84,10 +113,16 @@ - - - + + + @@ -96,20 +131,39 @@ - - + + - + - -