Skip to content

Commit

Permalink
sort registry items by alphabetical order
Browse files Browse the repository at this point in the history
  • Loading branch information
alexyaang committed Sep 22, 2023
1 parent 1ba55e1 commit 6c60967
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/tree/registries/UnifiedRegistryTreeDataProvider.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -35,15 +35,15 @@ export class UnifiedRegistryTreeDataProvider implements vscode.TreeDataProvider<
}

public async getChildren(element?: UnifiedRegistryItem<unknown> | undefined): Promise<UnifiedRegistryItem<unknown>[]> {
const unifiedRegistryItems: UnifiedRegistryItem<unknown>[] = [];

if (element) {
const elements = await element.provider.getChildren(element.wrappedItem);

if (!elements) {
return [];
}

const results: UnifiedRegistryItem<unknown>[] = [];

for (const child of elements) {
const wrapper = {
provider: element.provider,
Expand All @@ -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<unknown>[] = [];

const connectedProviderIds = this.storageMemento.get<string[]>(ConnectedRegistryProvidersKey, []);

for (const provider of this.providers.values()) {
Expand All @@ -74,17 +70,17 @@ export class UnifiedRegistryTreeDataProvider implements vscode.TreeDataProvider<
continue;
}

unifiedRoots.push(...roots.map(r => {
unifiedRegistryItems.push(...roots.map(r => {
return {
provider,
wrappedItem: r,
parent: undefined
};
}));
}

return unifiedRoots;
}

return unifiedRegistryItems.sort((a, b) => (a.wrappedItem as CommonRegistryItem).label.localeCompare((b.wrappedItem as CommonRegistryItem).label));
}

public getParent(element: UnifiedRegistryItem<unknown>): UnifiedRegistryItem<unknown> | undefined {
Expand Down

0 comments on commit 6c60967

Please sign in to comment.