From c0865f655078abf11bb547e800f83c7f3d8216dd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 11:41:55 +0000 Subject: [PATCH 1/5] Initial plan From e1b8bc1c625464b61d15101830aa6b16ff93b6e0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 11:46:08 +0000 Subject: [PATCH 2/5] Initial assessment: Add tags editing capability to Azure Key Vault Explorer Co-authored-by: cricketthomas <15821271+cricketthomas@users.noreply.github.com> --- Desktop/Desktop.csproj | 4 ++-- KeyVaultExplorer/KeyVaultExplorer.csproj | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Desktop/Desktop.csproj b/Desktop/Desktop.csproj index b4e4180..a0b1345 100644 --- a/Desktop/Desktop.csproj +++ b/Desktop/Desktop.csproj @@ -3,9 +3,9 @@ WinExe - net9.0 + net8.0 - $(TargetFrameworks);net9.0-windows10.0.19041.0 + $(TargetFrameworks);net8.0-windows10.0.19041.0 10.0.19041.41 enable diff --git a/KeyVaultExplorer/KeyVaultExplorer.csproj b/KeyVaultExplorer/KeyVaultExplorer.csproj index 263decf..3ed8295 100644 --- a/KeyVaultExplorer/KeyVaultExplorer.csproj +++ b/KeyVaultExplorer/KeyVaultExplorer.csproj @@ -1,7 +1,7 @@  - net9.0 - $(TargetFrameworks);net9.0-windows10.0.19041.0 + net8.0 + $(TargetFrameworks);net8.0-windows10.0.19041.0 10.0.19041.41 From 37eafe4c0e8746f845bbff6f2219e32845fd564e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 11:51:28 +0000 Subject: [PATCH 3/5] Add basic tags editing functionality for secrets with TagsEditor control Co-authored-by: cricketthomas <15821271+cricketthomas@users.noreply.github.com> --- KeyVaultExplorer/Services/VaultService.cs | 8 ++ .../CreateNewSecretVersionViewModel.cs | 23 +++++ .../Views/CustomControls/TagsEditor.axaml | 61 ++++++++++++ .../Views/CustomControls/TagsEditor.axaml.cs | 98 +++++++++++++++++++ .../CreateNewSecretVersion.axaml | 7 ++ .../CreateNewSecretVersion.axaml.cs | 20 ++++ 6 files changed, 217 insertions(+) create mode 100644 KeyVaultExplorer/Views/CustomControls/TagsEditor.axaml create mode 100644 KeyVaultExplorer/Views/CustomControls/TagsEditor.axaml.cs diff --git a/KeyVaultExplorer/Services/VaultService.cs b/KeyVaultExplorer/Services/VaultService.cs index af146bc..0f6857f 100644 --- a/KeyVaultExplorer/Services/VaultService.cs +++ b/KeyVaultExplorer/Services/VaultService.cs @@ -357,4 +357,12 @@ public async Task UpdateSecret(SecretProperties properties, Ur var client = new SecretClient(KeyVaultUri, token); return await client.UpdateSecretPropertiesAsync(properties); } + + public async Task UpdateCertificate(CertificateProperties properties, Uri KeyVaultUri) + { + var token = new CustomTokenCredential(await _authService.GetAzureKeyVaultTokenSilent()); + var client = new CertificateClient(KeyVaultUri, token); + var response = await client.UpdateCertificatePropertiesAsync(properties); + return response.Value.Properties; + } } \ No newline at end of file diff --git a/KeyVaultExplorer/ViewModels/CreateNewSecretVersionViewModel.cs b/KeyVaultExplorer/ViewModels/CreateNewSecretVersionViewModel.cs index e6bdd7a..194314d 100644 --- a/KeyVaultExplorer/ViewModels/CreateNewSecretVersionViewModel.cs +++ b/KeyVaultExplorer/ViewModels/CreateNewSecretVersionViewModel.cs @@ -4,6 +4,7 @@ using KeyVaultExplorer.Services; using KeyVaultExplorer.Validations; using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; @@ -64,6 +65,9 @@ public CreateNewSecretVersionViewModel() ValidateAllProperties(); } + // Delegate to get updated tags from the UI + public Func>? GetUpdatedTags { get; set; } + [ObservableProperty] public bool hasActivationDateChecked; @@ -86,6 +90,9 @@ public async Task EditDetails() else KeyVaultSecretModel.ExpiresOn = null; + // Update tags from the TagsEditor if available + UpdateTagsFromEditor(); + var updatedProps = await _vaultService.UpdateSecret(KeyVaultSecretModel, KeyVaultSecretModel.VaultUri); KeyVaultSecretModel = updatedProps; } @@ -102,6 +109,9 @@ private async Task NewVersion() newSecret.Properties.ContentType = KeyVaultSecretModel.ContentType; + // Update tags from the TagsEditor before creating new version + UpdateTagsFromEditor(); + foreach (var tag in KeyVaultSecretModel.Tags) newSecret.Properties.Tags.Add(tag.Key, tag.Value); @@ -137,6 +147,19 @@ partial void OnHasExpirationDateCheckedChanged(bool oldValue, bool newValue) } } + private void UpdateTagsFromEditor() + { + if (GetUpdatedTags != null) + { + var updatedTags = GetUpdatedTags(); + KeyVaultSecretModel.Tags.Clear(); + foreach (var tag in updatedTags) + { + KeyVaultSecretModel.Tags[tag.Key] = tag.Value; + } + } + } + //public async Task> GetAvailableSubscriptions() //{ // var subscriptions = new List(); diff --git a/KeyVaultExplorer/Views/CustomControls/TagsEditor.axaml b/KeyVaultExplorer/Views/CustomControls/TagsEditor.axaml new file mode 100644 index 0000000..0a1e1d9 --- /dev/null +++ b/KeyVaultExplorer/Views/CustomControls/TagsEditor.axaml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + +