-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathissue.ts
More file actions
73 lines (64 loc) · 2.23 KB
/
Copy pathissue.ts
File metadata and controls
73 lines (64 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { Uri, TreeItem, TreeItemCollapsibleState, Command } from 'vscode';
interface Label {
color: string;
id: number;
name: string;
url: string;
}
export class Issue extends TreeItem {
contextValue = 'issue';
original_issue? : Issue;
static createIssue(element: Issue) {
let ret = new Issue(
element.label,
element.issueId,
element.body,
element.state,
element.assignee,
element.assignees,
element.creator,
element.labels,
element.collapsibleState,
element.title,
element.html_url)
ret.original_issue = element;
return ret
}
constructor(
public readonly label: string,
public issueId: number,
public body: string,
public state: string,
public assignee: string,
public assignees: any[],
public creator: string,
public labels: Label[],
public collapsibleState: TreeItemCollapsibleState,
public title: string,
public html_url: string,
public command?: Command
) {
super(label, collapsibleState);
this.tooltip = 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),
};
}
export function createIconWithColor(color: string): Uri {
const icon = `<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16 31.5C24.5604 31.5 31.5 24.5604 31.5 16C31.5 7.43959 24.5604 0.5 16 0.5C7.43959 0.5 0.5 7.43959 0.5 16C0.5 24.5604 7.43959 31.5 16 31.5Z" stroke="{{color}}"/>
<path d="M19 6C19 4.34315 17.6569 3 16 3C14.3431 3 13 4.34315 13 6V20C13 21.6569 14.3431 23 16 23C17.6569 23 19 21.6569 19 20V6Z" fill="{{color}}"/>
<path d="M16.5 24H15.5C14.1193 24 13 25.1193 13 26.5C13 27.8807 14.1193 29 15.5 29H16.5C17.8807 29 19 27.8807 19 26.5C19 25.1193 17.8807 24 16.5 24Z" fill="{{color}}"/>
</svg>
`.replace(new RegExp('{{color}}', 'g'), '#' + color);
return Uri.parse('data:image/svg+xml;base64,' + Buffer.from(icon).toString('base64'));
}