Skip to content

Commit 9973107

Browse files
authored
feat: show notification number for issues, prs, discussions (#1276)
1 parent 7d79649 commit 9973107

16 files changed

+659
-3
lines changed

src/__mocks__/state-mocks.ts

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export const mockSettings: SettingsState = {
8484
showAccountHostname: false,
8585
delayNotificationState: false,
8686
showPills: true,
87+
showNumber: true,
8788
keyboardShortcut: true,
8889
groupBy: GroupBy.REPOSITORY,
8990
filterReasons: [],

src/components/NotificationRow.test.tsx

+20
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,26 @@ describe('components/NotificationRow.tsx', () => {
6161
expect(tree).toMatchSnapshot();
6262
});
6363

64+
it('should render itself & its children - hide numbers', async () => {
65+
jest
66+
.spyOn(global.Date, 'now')
67+
.mockImplementation(() => new Date('2024').valueOf());
68+
69+
const props = {
70+
notification: mockSingleNotification,
71+
account: mockGitHubCloudAccount,
72+
};
73+
74+
const tree = render(
75+
<AppContext.Provider
76+
value={{ settings: { ...mockSettings, showNumber: false } }}
77+
>
78+
<NotificationRow {...props} />
79+
</AppContext.Provider>,
80+
);
81+
expect(tree).toMatchSnapshot();
82+
});
83+
6484
describe('notification interactions', () => {
6585
it('should open a notification in the browser - click', () => {
6686
const removeNotificationFromState = jest.fn();

src/components/NotificationRow.tsx

+17-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ export const NotificationRow: FC<INotificationRow> = ({
7171
notification.subject.type,
7272
]);
7373

74+
const notificationNumber = notification.subject?.number
75+
? `#${notification.subject.number}`
76+
: '';
77+
78+
const notificationTitle =
79+
`${notification.subject.title} ${notificationNumber}`.trim();
80+
7481
const groupByDate = settings.groupBy === 'DATE';
7582

7683
return (
@@ -102,9 +109,18 @@ export const NotificationRow: FC<INotificationRow> = ({
102109
<div
103110
className="mb-1 truncate text-sm"
104111
role="main"
105-
title={notification.subject.title}
112+
title={notificationTitle}
106113
>
107114
{notification.subject.title}
115+
<span
116+
className={cn(
117+
'text-xxs ml-1',
118+
Opacity.READ,
119+
!settings.showNumber && 'hidden',
120+
)}
121+
>
122+
{notificationNumber}
123+
</span>
108124
</div>
109125

110126
<NotificationFooter notification={notification} />

src/components/__snapshots__/AccountNotifications.test.tsx.snap

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)