-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathNotificationSettings.tsx
More file actions
253 lines (239 loc) · 9.05 KB
/
NotificationSettings.tsx
File metadata and controls
253 lines (239 loc) · 9.05 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
import { type FC, type MouseEvent, useContext } from 'react';
import {
BellIcon,
CheckIcon,
CommentIcon,
GitPullRequestIcon,
IssueOpenedIcon,
MilestoneIcon,
TagIcon,
} from '@primer/octicons-react';
import { Box, Stack, Text } from '@primer/react';
import { APPLICATION } from '../../../shared/constants';
import { AppContext } from '../../context/App';
import { GroupBy, Size } from '../../types';
import { openGitHubParticipatingDocs } from '../../utils/links';
import { Checkbox } from '../fields/Checkbox';
import { RadioGroup } from '../fields/RadioGroup';
import { Title } from '../primitives/Title';
export const NotificationSettings: FC = () => {
const { settings, updateSetting } = useContext(AppContext);
return (
<fieldset>
<Title icon={BellIcon}>Notifications</Title>
<Stack direction="vertical" gap="condensed">
<RadioGroup
label="Group by:"
name="groupBy"
onChange={(evt) => {
updateSetting('groupBy', evt.target.value as GroupBy);
}}
options={[
{ label: 'Repository', value: GroupBy.REPOSITORY },
{ label: 'Date', value: GroupBy.DATE },
]}
value={settings.groupBy}
/>
<Checkbox
checked={settings.fetchAllNotifications}
label="Fetch all notifications"
name="fetchAllNotifications"
onChange={(evt) =>
updateSetting('fetchAllNotifications', evt.target.checked)
}
tooltip={
<Stack direction="vertical" gap="condensed">
<Text>
When <Text as="u">checked</Text>, {APPLICATION.NAME} will fetch{' '}
<Text as="strong">all</Text> notifications from your inbox.
</Text>
<Text>
When <Text as="u">unchecked</Text>, {APPLICATION.NAME} will
fetch the first page of notifications (max 50 records per GitHub
account)
</Text>
</Stack>
}
/>
<Checkbox
checked={settings.detailedNotifications}
label="Fetch detailed notifications"
name="detailedNotifications"
onChange={(evt) =>
updateSetting('detailedNotifications', evt.target.checked)
}
tooltip={
<Stack direction="vertical" gap="condensed">
<Text>
When <Text as="u">checked</Text>, {APPLICATION.NAME} will enrich
notifications with detailed user and state information. You may
also choose to display{' '}
<Text as="strong">notification metric pills</Text> or{' '}
<Text as="strong">notification reference numbers</Text>.
</Text>
<Text>
When <Text as="u">unchecked</Text>, {APPLICATION.NAME} will only
fetch basic notification details.
</Text>
<Text className="text-gitify-caution">
⚠️ Users with a large number of unread notifications <i>may</i>{' '}
experience rate limiting under certain circumstances. Please
disable this setting if you experience this.
</Text>
</Stack>
}
/>
<Box className="pl-6" hidden={!settings.detailedNotifications}>
<Stack direction="vertical" gap="condensed">
<Checkbox
checked={settings.showPills}
label="Show notification metric pills"
name="showPills"
onChange={(evt) => updateSetting('showPills', evt.target.checked)}
tooltip={
<Stack direction="vertical" gap="condensed">
<Text>Show notification metric pills for:</Text>
<Box className="pl-4">
<Stack direction="vertical" gap="none">
<Stack direction="horizontal" gap="condensed">
<IssueOpenedIcon size={Size.SMALL} />
linked issues
</Stack>
<Stack direction="horizontal" gap="condensed">
<CheckIcon size={Size.SMALL} />
pr reviews
</Stack>
<Stack direction="horizontal" gap="condensed">
<CommentIcon size={Size.SMALL} />
comments
</Stack>
<Stack direction="horizontal" gap="condensed">
<TagIcon size={Size.SMALL} />
labels
</Stack>
<Stack direction="horizontal" gap="condensed">
<MilestoneIcon size={Size.SMALL} />
milestones
</Stack>
</Stack>
</Box>
</Stack>
}
/>
<Checkbox
checked={settings.showNumber}
label="Show GitHub number"
name="showNumber"
onChange={(evt) =>
updateSetting('showNumber', evt.target.checked)
}
tooltip={
<Stack direction="vertical" gap="condensed">
<Text>Show GitHub number for:</Text>
<Box className="pl-4">
<ul>
<li>
<Stack direction="horizontal" gap="condensed">
<CommentIcon size={Size.SMALL} />
Discussion
</Stack>
</li>
<li>
<Stack direction="horizontal" gap="condensed">
<IssueOpenedIcon size={Size.SMALL} />
Issue
</Stack>
</li>
<li>
<Stack direction="horizontal" gap="condensed">
<GitPullRequestIcon size={Size.SMALL} />
Pull Request
</Stack>
</li>
</ul>
</Box>
</Stack>
}
/>
</Stack>
</Box>
<Checkbox
checked={settings.participating}
label="Fetch only participating"
name="showOnlyParticipating"
onChange={(evt) => updateSetting('participating', evt.target.checked)}
tooltip={
<Stack direction="vertical" gap="condensed">
<Text>
When <Text as="u">checked</Text>, {APPLICATION.NAME} will fetch
only participating notifications.
</Text>
<Text>
When <Text as="em">unchecked</Text>, {APPLICATION.NAME} will
fetch participating and watching notifications.
</Text>
<Text>
See{' '}
<Box
className="text-gitify-link cursor-pointer"
onClick={(event: MouseEvent<HTMLElement>) => {
// Don't trigger onClick of parent element.
event.stopPropagation();
openGitHubParticipatingDocs();
}}
title="Open GitHub documentation for participating and watching notifications"
>
official docs
</Box>{' '}
for more details.
</Text>
</Stack>
}
/>
<Checkbox
checked={settings.markAsDoneOnOpen}
label="Mark as done on open"
name="markAsDoneOnOpen"
onChange={(evt) =>
updateSetting('markAsDoneOnOpen', evt.target.checked)
}
tooltip={
<Text>
<Text as="strong">Mark as done</Text> feature is supported in
GitHub Cloud and GitHub Enterprise Server 3.13 or later.
</Text>
}
/>
<Checkbox
checked={settings.markAsDoneOnUnsubscribe}
label="Mark as done on unsubscribe"
name="markAsDoneOnUnsubscribe"
onChange={(evt) =>
updateSetting('markAsDoneOnUnsubscribe', evt.target.checked)
}
tooltip={
<Text>
<Text as="strong">Mark as done</Text> feature is supported in
GitHub Cloud and GitHub Enterprise Server 3.13 or later.
</Text>
}
/>
<Checkbox
checked={settings.delayNotificationState}
label="Delay notification state"
name="delayNotificationState"
onChange={(evt) =>
updateSetting('delayNotificationState', evt.target.checked)
}
tooltip={
<Text>
Keep the notification within {APPLICATION.NAME} upon interaction
(ie: open notification, mark as read, mark as done) until the next
refresh window (scheduled or user initiated).
</Text>
}
/>
</Stack>
</fieldset>
);
};