mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-30 00:30:29 -04:00
Merge from vscode 8aa90d444f5d051984e8055f547c4252d53479b3 (#5587)
* Merge from vscode 8aa90d444f5d051984e8055f547c4252d53479b3 * pipeline errors * fix build
This commit is contained in:
@@ -19,6 +19,8 @@ import { IAccessibilityService } from 'vs/platform/accessibility/common/accessib
|
||||
import { IAsyncDataSource, ITreeNode } from 'vs/base/browser/ui/tree/tree';
|
||||
import { IListVirtualDelegate, IListRenderer } from 'vs/base/browser/ui/list/list';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { isNonEmptyArray } from 'vs/base/common/arrays';
|
||||
|
||||
export interface IExtensionTemplateData {
|
||||
icon: HTMLImageElement;
|
||||
@@ -217,4 +219,46 @@ export class ExtensionsTree extends WorkbenchAsyncDataTree<IExtensionData, IExte
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtensionData implements IExtensionData {
|
||||
|
||||
readonly extension: IExtension;
|
||||
readonly parent: IExtensionData | null;
|
||||
private readonly getChildrenExtensionIds: (extension: IExtension) => string[];
|
||||
private readonly childrenExtensionIds: string[];
|
||||
private readonly extensionsWorkbenchService: IExtensionsWorkbenchService;
|
||||
|
||||
constructor(extension: IExtension, parent: IExtensionData | null, getChildrenExtensionIds: (extension: IExtension) => string[], extensionsWorkbenchService: IExtensionsWorkbenchService) {
|
||||
this.extension = extension;
|
||||
this.parent = parent;
|
||||
this.getChildrenExtensionIds = getChildrenExtensionIds;
|
||||
this.extensionsWorkbenchService = extensionsWorkbenchService;
|
||||
this.childrenExtensionIds = this.getChildrenExtensionIds(extension);
|
||||
}
|
||||
|
||||
get hasChildren(): boolean {
|
||||
return isNonEmptyArray(this.childrenExtensionIds);
|
||||
}
|
||||
|
||||
async getChildren(): Promise<IExtensionData[] | null> {
|
||||
if (this.hasChildren) {
|
||||
const localById = this.extensionsWorkbenchService.local.reduce((result, e) => { result.set(e.identifier.id.toLowerCase(), e); return result; }, new Map<string, IExtension>());
|
||||
const result: IExtension[] = [];
|
||||
const toQuery: string[] = [];
|
||||
for (const extensionId of this.childrenExtensionIds) {
|
||||
const id = extensionId.toLowerCase();
|
||||
const local = localById.get(id);
|
||||
if (local) {
|
||||
result.push(local);
|
||||
} else {
|
||||
toQuery.push(id);
|
||||
}
|
||||
}
|
||||
const galleryResult = await this.extensionsWorkbenchService.queryGallery({ names: this.childrenExtensionIds, pageSize: this.childrenExtensionIds.length }, CancellationToken.None);
|
||||
result.push(...galleryResult.firstPage);
|
||||
return result.map(extension => new ExtensionData(extension, this, this.getChildrenExtensionIds, this.extensionsWorkbenchService));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user