Skip to content

Commit

Permalink
Clean up registerTrees.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
bwateratmsft committed Nov 30, 2023
1 parent eb56b78 commit 2bd1509
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions src/tree/registerTrees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,58 +26,42 @@ export function registerTrees(): void {
ext.containersTree = new AzExtTreeDataProvider(ext.containersRoot, containersLoadMore);
ext.containersTreeView = vscode.window.createTreeView('dockerContainers', { treeDataProvider: ext.containersTree, canSelectMany: true });
ext.context.subscriptions.push(ext.containersTreeView);
/* eslint-disable-next-line @typescript-eslint/promise-function-async */
registerCommand(containersLoadMore, (context: IActionContext, node: AzExtTreeItem) => ext.containersTree.loadMore(node, context));
registerCommand(containersLoadMore, async (context: IActionContext, node: AzExtTreeItem) => ext.containersTree.loadMore(node, context));

ext.networksRoot = new NetworksTreeItem(undefined);
const networksLoadMore = 'vscode-docker.networks.loadMore';
ext.networksTree = new AzExtTreeDataProvider(ext.networksRoot, networksLoadMore);
ext.networksTreeView = vscode.window.createTreeView('dockerNetworks', { treeDataProvider: ext.networksTree, canSelectMany: true });
ext.context.subscriptions.push(ext.networksTreeView);
/* eslint-disable-next-line @typescript-eslint/promise-function-async */
registerCommand(networksLoadMore, (context: IActionContext, node: AzExtTreeItem) => ext.networksTree.loadMore(node, context));
registerCommand(networksLoadMore, async (context: IActionContext, node: AzExtTreeItem) => ext.networksTree.loadMore(node, context));

ext.imagesRoot = new ImagesTreeItem(undefined);
const imagesLoadMore = 'vscode-docker.images.loadMore';
ext.imagesTree = new AzExtTreeDataProvider(ext.imagesRoot, imagesLoadMore);
ext.imagesTreeView = vscode.window.createTreeView('dockerImages', { treeDataProvider: ext.imagesTree, canSelectMany: true });
ext.context.subscriptions.push(ext.imagesTreeView);
/* eslint-disable-next-line @typescript-eslint/promise-function-async */
registerCommand(imagesLoadMore, (context: IActionContext, node: AzExtTreeItem) => ext.imagesTree.loadMore(node, context));
registerCommand(imagesLoadMore, async (context: IActionContext, node: AzExtTreeItem) => ext.imagesTree.loadMore(node, context));

const urtdp = new UnifiedRegistryTreeDataProvider(ext.context.globalState);
const genericRegistryV2DataProvider = new GenericRegistryV2DataProvider(ext.context);
const azureRegistryDataProvider = new AzureRegistryDataProvider(ext.context);
const dockerHubRegistryDataProvider = new DockerHubRegistryDataProvider(ext.context);
const githubRegistryDataProvider = new GitHubRegistryDataProvider(ext.context);
urtdp.registerProvider(githubRegistryDataProvider);
urtdp.registerProvider(dockerHubRegistryDataProvider);
urtdp.registerProvider(azureRegistryDataProvider);
urtdp.registerProvider(genericRegistryV2DataProvider);
ext.registriesRoot = urtdp;
ext.registriesTreeView = vscode.window.createTreeView('dockerRegistries', { treeDataProvider: urtdp });
ext.registriesTree = urtdp;
ext.genericRegistryV2DataProvider = genericRegistryV2DataProvider;
ext.azureRegistryDataProvider = azureRegistryDataProvider;
ext.dockerHubRegistryDataProvider = dockerHubRegistryDataProvider;
ext.githubRegistryDataProvider = githubRegistryDataProvider;
registerRegistryDataProviders(urtdp);
void migrateRegistriesData(ext.context);

ext.volumesRoot = new VolumesTreeItem(undefined);
const volumesLoadMore = 'vscode-docker.volumes.loadMore';
ext.volumesTree = new AzExtTreeDataProvider(ext.volumesRoot, volumesLoadMore);
ext.volumesTreeView = vscode.window.createTreeView('dockerVolumes', { treeDataProvider: ext.volumesTree, canSelectMany: true });
ext.context.subscriptions.push(ext.volumesTreeView);
/* eslint-disable-next-line @typescript-eslint/promise-function-async */
registerCommand(volumesLoadMore, (context: IActionContext, node: AzExtTreeItem) => ext.volumesTree.loadMore(node, context));
registerCommand(volumesLoadMore, async (context: IActionContext, node: AzExtTreeItem) => ext.volumesTree.loadMore(node, context));

ext.contextsRoot = new ContextsTreeItem(undefined);
const contextsLoadMore = 'vscode-docker.contexts.loadMore';
ext.contextsTree = new AzExtTreeDataProvider(ext.contextsRoot, contextsLoadMore);
ext.contextsTreeView = vscode.window.createTreeView('vscode-docker.views.dockerContexts', { treeDataProvider: ext.contextsTree, canSelectMany: false });
ext.context.subscriptions.push(ext.contextsTreeView);
/* eslint-disable-next-line @typescript-eslint/promise-function-async */
registerCommand(contextsLoadMore, (context: IActionContext, node: AzExtTreeItem) => ext.contextsTree.loadMore(node, context));
registerCommand(contextsLoadMore, async (context: IActionContext, node: AzExtTreeItem) => ext.contextsTree.loadMore(node, context));

const helpRoot = new HelpsTreeItem(undefined);
const helpTreeDataProvider = new AzExtTreeDataProvider(helpRoot, 'vscode-docker.help.loadMore');
Expand All @@ -90,3 +74,25 @@ export function registerTrees(): void {
// Register the refresh manager
ext.context.subscriptions.push(new RefreshManager());
}

function registerRegistryDataProviders(urtdp: UnifiedRegistryTreeDataProvider): void {
const githubRegistryDataProvider = new GitHubRegistryDataProvider(ext.context);
ext.context.subscriptions.push(urtdp.registerProvider(githubRegistryDataProvider));
ext.context.subscriptions.push(githubRegistryDataProvider);
ext.githubRegistryDataProvider = githubRegistryDataProvider;

const dockerHubRegistryDataProvider = new DockerHubRegistryDataProvider(ext.context);
ext.context.subscriptions.push(urtdp.registerProvider(dockerHubRegistryDataProvider));
ext.context.subscriptions.push(dockerHubRegistryDataProvider);
ext.dockerHubRegistryDataProvider = dockerHubRegistryDataProvider;

const azureRegistryDataProvider = new AzureRegistryDataProvider(ext.context);
ext.context.subscriptions.push(urtdp.registerProvider(azureRegistryDataProvider));
ext.context.subscriptions.push(azureRegistryDataProvider);
ext.azureRegistryDataProvider = azureRegistryDataProvider;

const genericRegistryV2DataProvider = new GenericRegistryV2DataProvider(ext.context);
ext.context.subscriptions.push(urtdp.registerProvider(genericRegistryV2DataProvider));
ext.context.subscriptions.push(genericRegistryV2DataProvider);
ext.genericRegistryV2DataProvider = genericRegistryV2DataProvider;
}

0 comments on commit 2bd1509

Please sign in to comment.