-
Notifications
You must be signed in to change notification settings - Fork 286
Expand file tree
/
Copy pathicons.ts
More file actions
113 lines (105 loc) · 2.53 KB
/
icons.ts
File metadata and controls
113 lines (105 loc) · 2.53 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import type { FC } from 'react';
import {
AppsIcon,
CheckIcon,
CommentIcon,
FeedPersonIcon,
FileDiffIcon,
KeyIcon,
MarkGithubIcon,
type OcticonProps,
OrganizationIcon,
PersonIcon,
ServerIcon,
} from '@primer/octicons-react';
import { IconColor, type PullRequestApprovalIcon } from '../types';
import type {
GitifyPullRequestReview,
Subject,
UserType,
} from '../typesGitHub';
import type { AuthMethod, PlatformType } from './auth/types';
export function getNotificationTypeIconColor(subject: Subject): IconColor {
switch (subject.state) {
case 'open':
case 'reopened':
case 'ANSWERED':
case 'success':
return IconColor.GREEN;
case 'closed':
case 'failure':
return IconColor.RED;
case 'completed':
case 'RESOLVED':
case 'merged':
return IconColor.PURPLE;
default:
return IconColor.GRAY;
}
}
export function getPullRequestReviewIcon(
review: GitifyPullRequestReview,
): PullRequestApprovalIcon | null {
const descriptionPrefix = review.users.join(', ');
switch (review.state) {
case 'APPROVED':
return {
type: CheckIcon,
color: IconColor.GREEN,
description: `${descriptionPrefix} approved these changes`,
};
case 'CHANGES_REQUESTED':
return {
type: FileDiffIcon,
color: IconColor.RED,
description: `${descriptionPrefix} requested changes`,
};
case 'COMMENTED':
return {
type: CommentIcon,
color: IconColor.YELLOW,
description: `${descriptionPrefix} left review comments`,
};
case 'DISMISSED':
return {
type: CommentIcon,
color: IconColor.GRAY,
description: `${descriptionPrefix} ${
review.users.length > 1 ? 'reviews have' : 'review has'
} been dismissed`,
};
default:
return null;
}
}
export function getAuthMethodIcon(method: AuthMethod): FC<OcticonProps> | null {
switch (method) {
case 'GitHub App':
return AppsIcon;
case 'OAuth App':
return PersonIcon;
default:
return KeyIcon;
}
}
export function getPlatformIcon(
platform: PlatformType,
): FC<OcticonProps> | null {
switch (platform) {
case 'GitHub Enterprise Server':
return ServerIcon;
default:
return MarkGithubIcon;
}
}
export function getDefaultUserIcon(userType: UserType) {
switch (userType) {
case 'Bot':
case 'Mannequin':
return MarkGithubIcon;
case 'Organization':
return OrganizationIcon;
default:
return FeedPersonIcon;
}
}