import { Uri, TreeItem, TreeItemCollapsibleState, Command } from 'vscode'; interface Label { color: string; id: number; name: string; url: string; } export class Issue extends TreeItem { constructor( public readonly label: string, public issueId: number, public body: string, public issueState: string, public assignee: string, public creator: string, public labels: Label[], public collapsibleState: TreeItemCollapsibleState, public readonly command?: Command ) { super(label, collapsibleState); } get tooltip() { return this.label + ' - ' + this.assignee; } labelDependentIcon(dark: boolean = false): Uri { if (this.labels.length === 0) { return createIconWithColor('#868686'); } else { return createIconWithColor(this.labels[0].color); } } iconPath = { light: this.labelDependentIcon(), dark: this.labelDependentIcon(true), }; contextValue = 'issue'; } export function createIconWithColor(color: string): Uri { const icon = ` `.replace(new RegExp('{{color}}', 'g'), '#' + color); return Uri.parse('data:image/svg+xml;base64,' + Buffer.from(icon).toString('base64')); }