From 6c60967cda34f6a1318594b4938c396bde9d49ca Mon Sep 17 00:00:00 2001 From: alexyaang <59073590+alexyaang@users.noreply.github.com> Date: Fri, 22 Sep 2023 10:59:54 -0400 Subject: [PATCH] sort registry items by alphabetical order --- .../UnifiedRegistryTreeDataProvider.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/tree/registries/UnifiedRegistryTreeDataProvider.ts b/src/tree/registries/UnifiedRegistryTreeDataProvider.ts index 17e74fe6cb..23a7bf6b34 100644 --- a/src/tree/registries/UnifiedRegistryTreeDataProvider.ts +++ b/src/tree/registries/UnifiedRegistryTreeDataProvider.ts @@ -1,4 +1,4 @@ -import { CommonRegistry, CommonRegistryRoot, RegistryDataProvider, isRegistry } from '@microsoft/vscode-docker-registries'; +import { CommonRegistry, CommonRegistryItem, CommonRegistryRoot, RegistryDataProvider, isRegistry } from '@microsoft/vscode-docker-registries'; import * as vscode from 'vscode'; import { ext } from '../../extensionVariables'; import { isAzureSubscriptionRegistryItem } from './Azure/AzureRegistryDataProvider'; @@ -35,6 +35,8 @@ export class UnifiedRegistryTreeDataProvider implements vscode.TreeDataProvider< } public async getChildren(element?: UnifiedRegistryItem | undefined): Promise[]> { + const unifiedRegistryItems: UnifiedRegistryItem[] = []; + if (element) { const elements = await element.provider.getChildren(element.wrappedItem); @@ -42,8 +44,6 @@ export class UnifiedRegistryTreeDataProvider implements vscode.TreeDataProvider< return []; } - const results: UnifiedRegistryItem[] = []; - for (const child of elements) { const wrapper = { provider: element.provider, @@ -55,13 +55,9 @@ export class UnifiedRegistryTreeDataProvider implements vscode.TreeDataProvider< child._urtdp_wrapper = wrapper; } - results.push(wrapper); + unifiedRegistryItems.push(wrapper); } - - return results; } else { - const unifiedRoots: UnifiedRegistryItem[] = []; - const connectedProviderIds = this.storageMemento.get(ConnectedRegistryProvidersKey, []); for (const provider of this.providers.values()) { @@ -74,7 +70,7 @@ export class UnifiedRegistryTreeDataProvider implements vscode.TreeDataProvider< continue; } - unifiedRoots.push(...roots.map(r => { + unifiedRegistryItems.push(...roots.map(r => { return { provider, wrappedItem: r, @@ -82,9 +78,9 @@ export class UnifiedRegistryTreeDataProvider implements vscode.TreeDataProvider< }; })); } - - return unifiedRoots; } + + return unifiedRegistryItems.sort((a, b) => (a.wrappedItem as CommonRegistryItem).label.localeCompare((b.wrappedItem as CommonRegistryItem).label)); } public getParent(element: UnifiedRegistryItem): UnifiedRegistryItem | undefined {