-
Notifications
You must be signed in to change notification settings - Fork 12
Version 1.0.315 #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Version 1.0.315 #132
Changes from 1 commit
21995a7
ca2bdff
3fa9158
81e3a57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,8 +15,6 @@ public static IList<KvSubscriptionModel> Filter(IList<KvSubscriptionModel> allSu | |
| return allSubscriptions; | ||
| } | ||
|
|
||
| var filteredSubscriptions = new List<KvSubscriptionModel>(); | ||
|
|
||
| foreach (var subscription in allSubscriptions) | ||
| { | ||
| var filteredResourceGroups = subscription.ResourceGroups | ||
|
|
@@ -40,10 +38,19 @@ public static IList<KvSubscriptionModel> Filter(IList<KvSubscriptionModel> allSu | |
| ResourceGroups = new ObservableCollection<KvResourceGroupModel>(filteredResourceGroups) | ||
| }; | ||
|
|
||
| filteredSubscriptions.Add(filteredSubscription); | ||
| new List<KvSubscriptionModel>().Add(filteredSubscription); | ||
| } | ||
| } | ||
|
|
||
| return filteredSubscriptions; | ||
| // Sort the filtered results alphabetically | ||
| var sortedSubscriptions = SortService.SortSubscriptions(new List<KvSubscriptionModel>()); | ||
|
||
|
|
||
| // Sort the nested collections within each subscription | ||
| foreach (var subscription in sortedSubscriptions) | ||
| { | ||
| SortService.SortSubscriptionTree(subscription); | ||
| } | ||
|
|
||
| return sortedSubscriptions; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,4 @@ | ||||||
| using Avalonia.Input; | ||||||
| using Avalonia.Threading; | ||||||
| using Avalonia.Threading; | ||||||
| using Azure.Core; | ||||||
| using Azure.ResourceManager; | ||||||
| using Azure.ResourceManager.KeyVault; | ||||||
|
|
@@ -9,9 +8,6 @@ | |||||
| using KeyVaultExplorer.Models; | ||||||
| using KeyVaultExplorer.Services; | ||||||
| using System; | ||||||
| using System.Buffers; | ||||||
| using System.Collections; | ||||||
| using System.Collections.Generic; | ||||||
| using System.Collections.ObjectModel; | ||||||
| using System.Collections.Specialized; | ||||||
| using System.ComponentModel; | ||||||
|
|
@@ -118,6 +114,8 @@ await DelaySetIsBusy(async () => | |||||
| quickAccess.ResourceGroups[0].KeyVaultResources.Add(kvrResponse); | ||||||
| quickAccess.PropertyChanged += KvSubscriptionModel_PropertyChanged; | ||||||
| } | ||||||
| quickAccess.ResourceGroups[0].KeyVaultResources = SortService.SortKeyVaults(quickAccess.ResourceGroups[0].KeyVaultResources); | ||||||
|
|
||||||
| quickAccess.ResourceGroups[0].ResourceGroupDisplayName = "Pinned"; | ||||||
| quickAccess.ResourceGroups[0].IsExpanded = true; | ||||||
|
|
||||||
|
|
@@ -139,6 +137,7 @@ await DelaySetIsBusy(async () => | |||||
| var searched = await Task.Run(() => | ||||||
| { | ||||||
| return new ObservableCollection<KvSubscriptionModel>(_treeViewList); | ||||||
|
||||||
| return new ObservableCollection<KvSubscriptionModel>(_treeViewList); |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 139 makes line 140 unreachable. Remove line 139 so that the sorting logic on line 140 is executed.
| return new ObservableCollection<KvSubscriptionModel>(_treeViewList); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| using Azure.ResourceManager.KeyVault; | ||
| using KeyVaultExplorer.Models; | ||
| using System.Collections.Generic; | ||
| using System.Collections.ObjectModel; | ||
| using System.Linq; | ||
|
|
||
| namespace KeyVaultExplorer.ViewModels; | ||
|
|
||
| public static class SortService | ||
| { | ||
| /// <summary> | ||
| /// Sorts key vaults alphabetically by name | ||
| /// </summary> | ||
| public static ObservableCollection<KeyVaultResource> SortKeyVaults(IEnumerable<KeyVaultResource> keyVaults) | ||
| { | ||
| var sorted = keyVaults.OrderBy(kv => kv.HasData ? kv.Data.Name : string.Empty); | ||
| return new ObservableCollection<KeyVaultResource>(sorted); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Sorts resource groups alphabetically by display name | ||
| /// </summary> | ||
| public static ObservableCollection<KvResourceGroupModel> SortResourceGroups(IEnumerable<KvResourceGroupModel> resourceGroups) | ||
| { | ||
| var sorted = resourceGroups.OrderBy(rg => rg.ResourceGroupDisplayName ?? string.Empty); | ||
| return new ObservableCollection<KvResourceGroupModel>(sorted); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Sorts subscriptions alphabetically by display name, keeping "Quick Access" at the top | ||
| /// </summary> | ||
| public static ObservableCollection<KvSubscriptionModel> SortSubscriptions(IEnumerable<KvSubscriptionModel> subscriptions) | ||
| { | ||
| var subscriptionsList = subscriptions.ToList(); | ||
|
|
||
| var quickAccess = subscriptionsList.Where(s => s.SubscriptionDisplayName == "Quick Access").ToList(); | ||
| var regularSubscriptions = subscriptionsList.Where(s => s.SubscriptionDisplayName != "Quick Access").ToList(); | ||
|
|
||
| var sortedRegular = regularSubscriptions.OrderBy(s => s.SubscriptionDisplayName ?? string.Empty); | ||
|
|
||
| var result = new List<KvSubscriptionModel>(); | ||
| result.AddRange(quickAccess); | ||
| result.AddRange(sortedRegular); | ||
|
|
||
| return new ObservableCollection<KvSubscriptionModel>(result); | ||
| } | ||
| /// <summary> | ||
| /// Sorts an entire subscription model tree, including all nested collections | ||
| /// </summary> | ||
| public static void SortSubscriptionTree(KvSubscriptionModel subscription) | ||
| { | ||
| subscription.ResourceGroups = SortResourceGroups(subscription.ResourceGroups); | ||
| foreach (var resourceGroup in subscription.ResourceGroups) | ||
| { | ||
| resourceGroup.KeyVaultResources = SortKeyVaults(resourceGroup.KeyVaultResources); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This creates a new list, adds an item to it, but immediately discards the list without storing it anywhere. The filtered subscription is lost. This should be adding to a collection that is used later.