-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
issue.ts
58 lines (52 loc) · 1.8 KB
/
issue.ts
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
'use strict';
import { ColorThemeKind, ThemeColor, ThemeIcon, window } from 'vscode';
import { Colors } from '../../constants';
import { RemoteProviderReference } from './remoteProvider';
export const enum IssueOrPullRequestType {
Issue = 'Issue',
PullRequest = 'PullRequest',
}
export interface IssueOrPullRequest {
type: IssueOrPullRequestType;
provider: RemoteProviderReference;
id: string;
date: Date;
title: string;
closed: boolean;
closedDate?: Date;
url: string;
}
export namespace IssueOrPullRequest {
export function getMarkdownIcon(issue: IssueOrPullRequest): string {
if (issue.type === IssueOrPullRequestType.PullRequest) {
if (issue.closed) {
return `<span style="color:${
window.activeColorTheme.kind === ColorThemeKind.Dark ? '#a371f7' : '#8250df'
};">$(git-pull-request)</span>`;
}
return `<span style="color:${
window.activeColorTheme.kind === ColorThemeKind.Dark ? '#3fb950' : '#1a7f37'
};">$(git-pull-request)</span>`;
}
if (issue.closed) {
return `<span style="color:${
window.activeColorTheme.kind === ColorThemeKind.Dark ? '#a371f7' : '#8250df'
};">$(pass)</span>`;
}
return `<span style="color:${
window.activeColorTheme.kind === ColorThemeKind.Dark ? '#3fb950' : '#1a7f37'
};">$(issue)</span>`;
}
export function getThemeIcon(issue: IssueOrPullRequest): ThemeIcon {
if (issue.type === IssueOrPullRequestType.PullRequest) {
if (issue.closed) {
return new ThemeIcon('git-pull-request', new ThemeColor(Colors.MergedPullRequestIconColor));
}
return new ThemeIcon('git-pull-request', new ThemeColor(Colors.OpenPullRequestIconColor));
}
if (issue.closed) {
return new ThemeIcon('pass', new ThemeColor(Colors.MergedPullRequestIconColor));
}
return new ThemeIcon('issues', new ThemeColor(Colors.OpenPullRequestIconColor));
}
}