Skip to content

Commit

Permalink
rename popup to accurately reflect it
Browse files Browse the repository at this point in the history
update filter on keyvault search list to properly filter values DRY
update to run tasks on background thread on startup
  • Loading branch information
cricketthomas committed Aug 6, 2024
1 parent 5e521e3 commit ba77a23
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 88 deletions.
5 changes: 3 additions & 2 deletions KeyVaultExplorer/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ public static void CreateDesktopResources()
if (!dbPassExists)
DatabaseEncryptedPasswordManager.SetSecret($"keyvaultexplorer_{System.Guid.NewGuid().ToString()[..6]}");

Dispatcher.UIThread.Post(async () =>

Task.Run(async () =>
{
await KvExplorerDb.OpenSqlConnection();
if (!dbExists)
KvExplorerDb.InitializeDatabase();
}, DispatcherPriority.Loaded);
});

string settingsPath = Path.Combine(Constants.LocalAppDataFolder, "settings.json");
if (!File.Exists(settingsPath))
Expand Down
2 changes: 1 addition & 1 deletion KeyVaultExplorer/KeyVaultExplorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<!-- <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworks);net8.0-macos</TargetFrameworks> -->
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<LangVersion>preview</LangVersion>
<Version>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)\\..\\VERSION"))</Version>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault>
Expand Down
4 changes: 2 additions & 2 deletions KeyVaultExplorer/Models/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public static class Constants
// Cache settings
public const string CacheFileName = "keyvaultexplorer_msal_cache.txt";

public static readonly string LocalAppDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\keyvaultexplorerforazure";
public static readonly string LocalAppDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\KeyVaultExplorerForAzure";

public static readonly string DatabaseFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\keyvaultexplorerforazure\\keyvaultexplorerforazure.db";
public static readonly string DatabaseFilePath = LocalAppDataFolder+ "\\KeyVaultExplorerForAzure.db";

public const string KeyChainServiceName = "keyvaultexplorerforazure_msal_service";
public const string KeyChainAccountName = "keyvaultexplorerforazure_msal_account";
Expand Down
2 changes: 1 addition & 1 deletion KeyVaultExplorer/Resources/Styles.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
<Canvas
Width="14"
Height="14"
Margin="4,0,1,0"
Margin="4,0,2,0"
Background="Transparent">
<Canvas.Styles>
<!--<Style Selector="ToolTip">
Expand Down
2 changes: 1 addition & 1 deletion KeyVaultExplorer/Services/AuthService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public async Task<AuthenticationResult> LoginAsync(CancellationToken cancellatio
{
var options = new SystemWebViewOptions()
{
HtmlMessageError = "<p> An error occured: {0}. Details {1}</p>",
HtmlMessageError = "<p> An error occurred: {0}. Details {1}</p>",
BrowserRedirectSuccess = new Uri("https://www.microsoft.com")
};
//.WithPrompt(Prompt.ForceLogin) //This is optional. If provided, on each execution, the username and the password must be entered.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ public async Task EditDetails()
else
KeyVaultSecretModel.ExpiresOn = null;


//foreach (var tag in KeyVaultSecretModel.Tags)
// KeyVaultSecretModel.Properties.Tags.Add(tag.Key, tag.Value);

var updatedProps = await _vaultService.UpdateSecret(KeyVaultSecretModel, KeyVaultSecretModel.VaultUri);
KeyVaultSecretModel = updatedProps;
}
Expand Down Expand Up @@ -137,7 +133,6 @@ partial void OnKeyVaultSecretModelChanging(SecretProperties value)
NotBeforeTimespan = value is not null && value.NotBefore.HasValue ? value?.NotBefore.Value.LocalDateTime.TimeOfDay : null;
}


partial void OnHasActivationDateCheckedChanged(bool oldValue, bool newValue)
{
if (newValue is false)
Expand Down
2 changes: 1 addition & 1 deletion KeyVaultExplorer/ViewModels/KeyVaultTreeListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ await DelaySetIsBusy(async () =>
catch (Exception ex)
{
Debug.Write(ex);
_notificationViewModel.ShowErrorPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Error" });
_notificationViewModel.ShowPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Error" });
}
});
}, DispatcherPriority.Background);
Expand Down
2 changes: 1 addition & 1 deletion KeyVaultExplorer/ViewModels/NotificationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void AddMessage(Notification notification)
NotificationManager?.Show(notification);
}

public async void ShowErrorPopup(Notification notification)
public async void ShowPopup(Notification notification)
{
var td = new TaskDialog
{
Expand Down
28 changes: 15 additions & 13 deletions KeyVaultExplorer/ViewModels/PropertiesPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ private async Task Copy()
}
catch (KeyVaultInsufficientPrivilegesException ex)
{
_notificationViewModel.ShowErrorPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Insufficient Privileges" });
_notificationViewModel.ShowPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Insufficient Privileges" });
}
catch (Exception ex)
{
_notificationViewModel.ShowErrorPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Error" });
_notificationViewModel.ShowPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Error" });
}
}

Expand Down Expand Up @@ -181,11 +181,11 @@ private async Task Download(string exportType)
}
catch (KeyVaultInsufficientPrivilegesException ex)
{
_notificationViewModel.ShowErrorPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Insufficient Privileges" });
_notificationViewModel.ShowPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Insufficient Privileges" });
}
catch (Exception ex)
{
_notificationViewModel.ShowErrorPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Error" });
_notificationViewModel.ShowPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Error" });
}
}

Expand Down Expand Up @@ -218,14 +218,16 @@ private async Task EditVersion()
try
{
await viewModel.EditDetailsCommand.ExecuteAsync(null);
_notificationViewModel.ShowPopup(new Avalonia.Controls.Notifications.Notification("Success", "The properties have been updated."));
}
catch (KeyVaultInsufficientPrivilegesException ex)
{
_notificationViewModel.ShowErrorPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Insufficient Privileges" });
_notificationViewModel.ShowPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Insufficient Privileges" });
}
catch (Exception ex)
{
_notificationViewModel.ShowErrorPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Error" });
_notificationViewModel.ShowPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Error" });
}
finally
{
Expand All @@ -245,7 +247,7 @@ private async Task EditVersion()
}
catch (KeyVaultInsufficientPrivilegesException ex)
{
_notificationViewModel.ShowErrorPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Insufficient Privileges" });
_notificationViewModel.ShowPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Insufficient Privileges" });
}
}

Expand Down Expand Up @@ -325,15 +327,15 @@ private async Task NewVersion()
try
{
await vm.NewVersionCommand.ExecuteAsync(null);
_notificationViewModel.AddMessage(new Avalonia.Controls.Notifications.Notification("New Version", "Your value has been created.", Avalonia.Controls.Notifications.NotificationType.Success));
_notificationViewModel.ShowPopup(new Avalonia.Controls.Notifications.Notification("Success", "The secret version has been created."));
}
catch (KeyVaultInsufficientPrivilegesException ex)
{
_notificationViewModel.ShowErrorPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Insufficient Privileges" });
_notificationViewModel.ShowPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Insufficient Privileges" });
}
catch (Exception ex)
{
_notificationViewModel.ShowErrorPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Error" });
_notificationViewModel.ShowPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Error" });
}
finally
{
Expand All @@ -351,7 +353,7 @@ private async Task NewVersion()
}
catch (KeyVaultInsufficientPrivilegesException ex)
{
_notificationViewModel.ShowErrorPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Insufficient Privileges" });
_notificationViewModel.ShowPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Insufficient Privileges" });
}
}

Expand Down Expand Up @@ -399,11 +401,11 @@ await Dispatcher.UIThread.InvokeAsync(async () =>
}
catch (KeyVaultInsufficientPrivilegesException ex)
{
_notificationViewModel.ShowErrorPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Insufficient Privileges" });
_notificationViewModel.ShowPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Insufficient Privileges" });
}
catch (Exception ex)
{
_notificationViewModel.ShowErrorPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Error" });
_notificationViewModel.ShowPopup(new Avalonia.Controls.Notifications.Notification { Message = ex.Message, Title = "Error" });
}
}
}
Loading

0 comments on commit ba77a23

Please sign in to comment.