Skip to content

Commit 0752d08

Browse files
setchyafonsojramos
andauthored
feat: labels indicator (#1161)
Co-authored-by: Afonso Jorge Ramos <afonsojorgeramos@gmail.com>
1 parent e0bfb0d commit 0752d08

File tree

9 files changed

+886
-3
lines changed

9 files changed

+886
-3
lines changed

src/components/NotificationRow.test.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,25 @@ describe('components/NotificationRow.tsx', () => {
117117
});
118118
});
119119

120+
describe('notification labels', () => {
121+
it('should render labels metric when available', async () => {
122+
jest
123+
.spyOn(global.Date, 'now')
124+
.mockImplementation(() => new Date('2024').valueOf());
125+
126+
const mockNotification = mockSingleNotification;
127+
mockNotification.subject.labels = ['enhancement', 'good-first-issue'];
128+
129+
const props = {
130+
notification: mockNotification,
131+
hostname: 'github.com',
132+
};
133+
134+
const tree = render(<NotificationRow {...props} />);
135+
expect(tree).toMatchSnapshot();
136+
});
137+
});
138+
120139
describe('linked issues/prs', () => {
121140
it('should render when linked to one issue/pr', async () => {
122141
jest

src/components/NotificationRow.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
FeedPersonIcon,
66
IssueClosedIcon,
77
ReadIcon,
8+
TagIcon,
89
} from '@primer/octicons-react';
910
import {
1011
type FC,
@@ -92,6 +93,10 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
9293
notification.subject.comments > 1 ? 'comments' : 'comment'
9394
}`;
9495

96+
const labelsPillDescription = notification.subject.labels
97+
?.map((label) => `🏷️ ${label}`)
98+
.join('\n');
99+
95100
const linkedIssuesPillDescription = `Linked to ${
96101
notification.subject.linkedIssues?.length > 1 ? 'issues' : 'issue'
97102
} ${notification.subject?.linkedIssues?.join(', ')}`;
@@ -201,6 +206,18 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
201206
</button>
202207
</span>
203208
)}
209+
{notification.subject?.labels?.length > 0 && (
210+
<span className="ml-1" title={labelsPillDescription}>
211+
<button type="button" className={Constants.PILL_CLASS_NAME}>
212+
<TagIcon
213+
size={12}
214+
className={`mr-1 ${IconColor.GRAY}`}
215+
aria-label={labelsPillDescription}
216+
/>
217+
{notification.subject.labels.length}
218+
</button>
219+
</span>
220+
)}
204221
</span>
205222
</span>
206223
</div>

0 commit comments

Comments
 (0)