Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/uno/AzureKeyVaultStudio/AzureKeyVaultStudio/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
Debug.WriteLine(e.Exception.StackTrace);
};

TaskScheduler.UnobservedTaskException += (sender, e) =>
{
Console.WriteLine("Unobserved exception caught!");
foreach (var ex in e.Exception.Flatten().InnerExceptions)
Console.WriteLine(ex);
e.SetObserved();
};

UnhandledException += (sender, args) =>
{
Debug.WriteLine($"[Unhandled] {args.Exception}");
Expand Down Expand Up @@ -53,7 +61,7 @@
#endif
.UseLogging(configure: (context, logBuilder) =>
{
var logLevel = LogLevel.Debug;

Check warning on line 64 in src/uno/AzureKeyVaultStudio/AzureKeyVaultStudio/App.xaml.cs

View workflow job for this annotation

GitHub Actions / Build macOS

The variable 'logLevel' is assigned but its value is never used

Check warning on line 64 in src/uno/AzureKeyVaultStudio/AzureKeyVaultStudio/App.xaml.cs

View workflow job for this annotation

GitHub Actions / Build macOS ARM64

The variable 'logLevel' is assigned but its value is never used

Check warning on line 64 in src/uno/AzureKeyVaultStudio/AzureKeyVaultStudio/App.xaml.cs

View workflow job for this annotation

GitHub Actions / Build Windows x64

The variable 'logLevel' is assigned but its value is never used
// Configure log levels for different categories of logging
logBuilder
.SetMinimumLevel(
Expand Down Expand Up @@ -105,7 +113,7 @@
if (!await authService.LoginOrRefreshAsync(cancellationToken))
return null;
credentials ??= new Dictionary<string, string>();
credentials[nameof(AuthenticatedUserClaims.Username)] = authService.AuthenticatedUserClaims.Username;

Check warning on line 116 in src/uno/AzureKeyVaultStudio/AzureKeyVaultStudio/App.xaml.cs

View workflow job for this annotation

GitHub Actions / Build macOS

Dereference of a possibly null reference.

Check warning on line 116 in src/uno/AzureKeyVaultStudio/AzureKeyVaultStudio/App.xaml.cs

View workflow job for this annotation

GitHub Actions / Build macOS ARM64

Dereference of a possibly null reference.

Check warning on line 116 in src/uno/AzureKeyVaultStudio/AzureKeyVaultStudio/App.xaml.cs

View workflow job for this annotation

GitHub Actions / Build Windows x64

Dereference of a possibly null reference.
credentials["Expiry"] = authService.Expiry.AddMinutes(-10).ToString("g");
return await ValueTask.FromResult<IDictionary<string, string>?>(credentials);
}
Expand All @@ -127,7 +135,7 @@
if (!forcedRefresh)
{
tokenDictionary ??= new Dictionary<string, string>();
tokenDictionary[nameof(AuthenticatedUserClaims.Username)] = authService.AuthenticatedUserClaims.Username;

Check warning on line 138 in src/uno/AzureKeyVaultStudio/AzureKeyVaultStudio/App.xaml.cs

View workflow job for this annotation

GitHub Actions / Build macOS

Dereference of a possibly null reference.

Check warning on line 138 in src/uno/AzureKeyVaultStudio/AzureKeyVaultStudio/App.xaml.cs

View workflow job for this annotation

GitHub Actions / Build macOS ARM64

Dereference of a possibly null reference.

Check warning on line 138 in src/uno/AzureKeyVaultStudio/AzureKeyVaultStudio/App.xaml.cs

View workflow job for this annotation

GitHub Actions / Build Windows x64

Dereference of a possibly null reference.
tokenDictionary["Expiry"] = authService.Expiry.AddMinutes(-10).ToString("g");
return await ValueTask.FromResult<IDictionary<string, string>?>(tokenDictionary);
}
Expand All @@ -152,7 +160,6 @@
services.AddSingleton<ILocalSettingsService>(_ => LocalSettingsServiceFactory.Create());
services.AddSingleton<AuthService>();
services.AddSingleton<VaultService>();
services.AddSingleton<AzureSearchService>();
services.AddSingleton<KeyVaultTreeViewModel>();
services.AddTransient<ItemPropertiesViewModel>();
}).UseNavigation(RegisterRoutes));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

public static async Task<bool> DeleteQuickAccessItemByKeyVaultId(string keyVaultId)
{
if (keyVaultId is null)
return true;

using var connection = await TryCreateDatabaseAndOpenConnection();
await connection.OpenAsync();
using var command = connection.CreateCommand();
Expand Down Expand Up @@ -63,7 +66,7 @@
}
}

public static async Task<List<Subscriptions>> GetStoredSubscriptions(string tenantId = null)

Check warning on line 69 in src/uno/AzureKeyVaultStudio/AzureKeyVaultStudio/Database/DbContext.cs

View workflow job for this annotation

GitHub Actions / Build macOS

Cannot convert null literal to non-nullable reference type.

Check warning on line 69 in src/uno/AzureKeyVaultStudio/AzureKeyVaultStudio/Database/DbContext.cs

View workflow job for this annotation

GitHub Actions / Build Linux

Cannot convert null literal to non-nullable reference type.

Check warning on line 69 in src/uno/AzureKeyVaultStudio/AzureKeyVaultStudio/Database/DbContext.cs

View workflow job for this annotation

GitHub Actions / Build macOS ARM64

Cannot convert null literal to non-nullable reference type.

Check warning on line 69 in src/uno/AzureKeyVaultStudio/AzureKeyVaultStudio/Database/DbContext.cs

View workflow job for this annotation

GitHub Actions / Build Windows x64

Cannot convert null literal to non-nullable reference type.

Check warning on line 69 in src/uno/AzureKeyVaultStudio/AzureKeyVaultStudio/Database/DbContext.cs

View workflow job for this annotation

GitHub Actions / Build Windows ARM64

Cannot convert null literal to non-nullable reference type.
{
using var connection = await TryCreateDatabaseAndOpenConnection();
await connection.OpenAsync();
Expand Down Expand Up @@ -94,6 +97,8 @@

public static async Task InsertQuickAccessItemAsync(QuickAccess item)
{
if (item is null)
return;
using var connection = await TryCreateDatabaseAndOpenConnection();
await connection.OpenAsync();
using var command = connection.CreateCommand();
Expand Down Expand Up @@ -131,6 +136,9 @@

public static async Task<bool> QuickAccessItemByKeyVaultIdExists(string? keyVaultId)
{
if (keyVaultId is null)
return true;

using var connection = await TryCreateDatabaseAndOpenConnection();
await connection.OpenAsync();
using var command = connection.CreateCommand();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ static void SetResourceGroupExpanded(KvResourceGroupModel model, bool value)

foreach (var subscription in allSubscriptions)
{
if (subscription.Type == KvSubscriptionModel.ExplorerItemType.QuickAccess)
{
SetSubscriptionExpanded(subscription, true);
results.Add(subscription);
continue;
}

bool isMatch = false;

if (ContainsQuery(subscription.DisplayName, querySpan))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using System.Diagnostics;
using Azure.ResourceManager.KeyVault;
using Azure.ResourceManager.Resources;

Expand All @@ -22,6 +23,7 @@

public partial class KvSubscriptionModel : ObservableObject
{

[ObservableProperty]
public partial bool HasSubNodeDataBeenFetched { get; set; } = false;

Expand All @@ -38,7 +40,8 @@

public ObservableCollection<KvResourceGroupModel> ResourceGroups { get; set; } = [];
public virtual ObservableCollection<KeyVaultResource> PinnedItems { get; set; } = [];

//adding this to avoid crashing the application.
public virtual ObservableCollection<KeyVaultResource> KeyVaultResources { get; set; } = [];
public SubscriptionResource Subscription { get; set; } = null!;
public string DisplayName { get; set; } = null!;
public string? SubscriptionId { get; set; }
Expand Down Expand Up @@ -67,19 +70,28 @@

protected override DataTemplate SelectTemplateCore(object item)
{
if (item is KvSubscriptionModel model)
try
{
if (model.Type == KvSubscriptionModel.ExplorerItemType.QuickAccess)
return PinnedItemTemplate;
else return SubscriptionTemplate;
}
if (item is KvSubscriptionModel model)
{
if (model.Type == KvSubscriptionModel.ExplorerItemType.QuickAccess)
return PinnedItemTemplate;
else return SubscriptionTemplate;
}

if (item is KvResourceGroupModel)
return ResourceGroupTemplate;
if (item is KvResourceGroupModel)
return ResourceGroupTemplate;

if (item is KeyVaultResource)
return KeyVaultResourceTemplate;
if (item is KeyVaultResource)
return KeyVaultResourceTemplate;

return base.SelectTemplateCore(item);
return base.SelectTemplateCore(item);
}
catch (Exception ex)

Check warning on line 90 in src/uno/AzureKeyVaultStudio/AzureKeyVaultStudio/Models/KeyVaultModel.cs

View workflow job for this annotation

GitHub Actions / Build macOS ARM64

The variable 'ex' is declared but never used
{
Debug.WriteLine($"Error selecting template for item: {item}");
return base.SelectTemplateCore(item);

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@ namespace AzureKeyVaultStudio.Models;

public class KeyVaultResourcePlaceholder : KeyVaultResource
{
public override ResourceIdentifier Id => base.Id;
public override KeyVaultData? Data
private static readonly ResourceIdentifier PlaceholderId =
new("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/loading/providers/Microsoft.KeyVault/vaults/loading");

private static KeyVaultData CreatePlaceholderData()
{
get
{
KeyVaultData? keyVaultData = base.Data ?? null;
return keyVaultData;
}
var properties = new KeyVaultProperties(Guid.Empty, new KeyVaultSku(KeyVaultSkuFamily.A, KeyVaultSkuName.Standard));
return new KeyVaultDataPlaceholder(AzureLocation.EastUS2, properties);
}

private readonly KeyVaultData _placeholderData = CreatePlaceholderData();

public override ResourceIdentifier Id => PlaceholderId;

public override KeyVaultData? Data => _placeholderData;
}

public class KeyVaultDataPlaceholder : KeyVaultData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:uap18="http://schemas.microsoft.com/appx/manifest/uap/windows10/18"
IgnorableNamespaces="uap rescap uap18">

<Identity Version="2.0.2.0" Publisher="CN=FE9032D7-9FA7-4DED-9087-469BC45B4D99" Name="ArthurThomasIV.AzureKeyVaultExplorer-forAzure"/>
<Identity Version="2.0.3.0" Publisher="CN=FE9032D7-9FA7-4DED-9087-469BC45B4D99" Name="ArthurThomasIV.AzureKeyVaultExplorer-forAzure"/>
<Properties>
<DisplayName>Key Vault Explorer</DisplayName>
<PublisherDisplayName>Arthur Thomas IV</PublisherDisplayName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
x:Uid="LoginPageGettingStartedMessage"
Opacity="0.8"
TextWrapping="Wrap" />

<HyperlinkButton
x:Uid="DocumenationHyperlinkButton"
Margin="-8,10"
HorizontalAlignment="Left"
FontWeight="SemiBold"
NavigateUri="https://github.com/cricketthomas/AzureKeyVaultExplorer?tab=readme-ov-file#setting-up-the-application" />
</StackPanel>

<StackPanel Margin="0,16" Spacing="16">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void ClosePane()
}

private const double PaneMinWidth = 100;
private const double PaneMaxWidth = 700;
private const double PaneMaxWidth = 1000;

public double InvertedSplitViewWidth
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public partial class SettingsViewModel : ObservableRecipient

[ObservableProperty]
public partial AuthenticatedUserClaims? Claims { get; set; }

public string? GitHubRepoistoryBaseUrl => _appConfig.Value.GitHubRepoistoryBaseUrl;
public string? LicenseUrl => _appConfig.Value.LicenseUrl;
public string? NewIssueUrl => _appConfig.Value.NewIssueUrl;
Expand Down Expand Up @@ -146,27 +147,25 @@ private void LoadSettings()
private async Task SaveSettings()
{
var selectedCloud = SelectedCloudEnvironmentIndex >= 0 && SelectedCloudEnvironmentIndex < AzureCloudInstances.Length
? AzureCloudInstances[SelectedCloudEnvironmentIndex]
: AzureCloudInstance.None;
? AzureCloudInstances[SelectedCloudEnvironmentIndex]
: AzureCloudInstance.None;
Save(Constants.SelectedCloudEnvironmentName, (int)selectedCloud);
Save(nameof(SettingsPageClientIdCheckbox), SettingsPageClientIdCheckbox);
Save(nameof(SettingsPageTenantIdCheckbox), SettingsPageTenantIdCheckbox);
Save(nameof(ClearClipboardTimeout), ClearClipboardTimeout < 0 ? 10 : ClearClipboardTimeout);
Save(nameof(CustomClientId), CustomClientId?.Trim() ?? string.Empty);
Save(nameof(CustomTenantId), CustomTenantId?.Trim() ?? string.Empty);
await _localizationService.SetCurrentCultureAsync(Language);

_ = _localizationService.SetCurrentCultureAsync(Language);
WeakReferenceMessenger.Default.Send(new SendInAppNotificationMessage(new Notification
{
Severity = InfoBarSeverity.Informational,
Title = _localizer["SavedTitle"] ?? "Saved.",
Message = _localizer["SavedChangesMessage"] ?? "Your changes have been saved.",
Title = _localizer?["SavedTitle"] ?? "Saved.",
Message = _localizer?["SavedChangesMessage"] ?? "Your changes have been saved.",
Duration = TimeSpan.FromSeconds(5)
}));

}


[RelayCommand]
private async Task SignInOrRefreshTokenAsync()
{
Expand Down Expand Up @@ -200,7 +199,7 @@ private async Task DeleteDatabase()
WeakReferenceMessenger.Default.Send(new SendInAppNotificationMessage(new Notification
{
Severity = InfoBarSeverity.Warning,
Message = _localizer["DatabseDeletedMessage"] ?? "Database deleted. Restart the app to recreate the database.",
Message = _localizer?["DatabseDeletedMessage"] ?? "Database deleted. Restart the app to recreate the database.",
Title = "Info"
}));
}
Expand All @@ -219,7 +218,7 @@ private async Task ResetApplicationState()
WeakReferenceMessenger.Default.Send(new SendInAppNotificationMessage(new Notification
{
Severity = InfoBarSeverity.Warning,
Message = _localizer["ApplicationResetMessage"] ?? "Application has been reset. Please exit the app.",
Message = _localizer?["ApplicationResetMessage"] ?? "Application has been reset. Please exit the app.",
Title = "Danger"
}));
}
Expand All @@ -237,6 +236,4 @@ public static string GetAppVersion()
var version = assembly.GetName().Version;
return version == null ? "(Unknown)" : $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
}

//NotificationQueue.Show(notification);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:8080",
"sslPort": 0
}
},
"profiles": {
"AzureKeyVaultStudio (WinAppSDK Unpackaged)": {
"commandName": "Project",
Expand All @@ -26,5 +18,13 @@
"distributionName": "",
"compatibleTargetFramework": "desktop"
}
},
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:8080",
"sslPort": 0
}
}
}
}
Loading
Loading