Skip to content
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

Show Connect Registry Command when No Registries are Connected #4095

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/tree/registries/UnifiedRegistryTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ export class UnifiedRegistryTreeDataProvider implements vscode.TreeDataProvider<
}

public getTreeItem(element: UnifiedRegistryItem<unknown>): vscode.TreeItem | Thenable<vscode.TreeItem> {
return element.provider.getTreeItem(element.wrappedItem);
if (!element.provider) {
return element.wrappedItem as vscode.TreeItem;
} else {
return element.provider.getTreeItem(element.wrappedItem);
}
}

public async getChildren(element?: UnifiedRegistryItem<unknown> | undefined): Promise<UnifiedRegistryItem<unknown>[]> {
Expand Down Expand Up @@ -78,6 +82,22 @@ export class UnifiedRegistryTreeDataProvider implements vscode.TreeDataProvider<
};
}));
}

// if there are no connected providers, show a command to connect one
if (unifiedRegistryItems.length === 0) {
unifiedRegistryItems.push({
provider: undefined,
wrappedItem: {
label: vscode.l10n.t('Connect Registry...'),
type: 'connectregistry',
iconPath: new vscode.ThemeIcon('plug'),
command: {
command: 'vscode-docker.registries.connectRegistry'
}
},
parent: undefined,
});
}
}

return unifiedRegistryItems.sort((a, b) => {
Expand Down