Skip to content

Commit

Permalink
feat: show notification number for issues, prs, discussions (#1276)
Browse files Browse the repository at this point in the history
  • Loading branch information
setchy authored Jul 8, 2024
1 parent 7d79649 commit 9973107
Show file tree
Hide file tree
Showing 16 changed files with 659 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/__mocks__/state-mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const mockSettings: SettingsState = {
showAccountHostname: false,
delayNotificationState: false,
showPills: true,
showNumber: true,
keyboardShortcut: true,
groupBy: GroupBy.REPOSITORY,
filterReasons: [],
Expand Down
20 changes: 20 additions & 0 deletions src/components/NotificationRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@ describe('components/NotificationRow.tsx', () => {
expect(tree).toMatchSnapshot();
});

it('should render itself & its children - hide numbers', async () => {
jest
.spyOn(global.Date, 'now')
.mockImplementation(() => new Date('2024').valueOf());

const props = {
notification: mockSingleNotification,
account: mockGitHubCloudAccount,
};

const tree = render(
<AppContext.Provider
value={{ settings: { ...mockSettings, showNumber: false } }}
>
<NotificationRow {...props} />
</AppContext.Provider>,
);
expect(tree).toMatchSnapshot();
});

describe('notification interactions', () => {
it('should open a notification in the browser - click', () => {
const removeNotificationFromState = jest.fn();
Expand Down
18 changes: 17 additions & 1 deletion src/components/NotificationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ export const NotificationRow: FC<INotificationRow> = ({
notification.subject.type,
]);

const notificationNumber = notification.subject?.number
? `#${notification.subject.number}`
: '';

const notificationTitle =
`${notification.subject.title} ${notificationNumber}`.trim();

const groupByDate = settings.groupBy === 'DATE';

return (
Expand Down Expand Up @@ -102,9 +109,18 @@ export const NotificationRow: FC<INotificationRow> = ({
<div
className="mb-1 truncate text-sm"
role="main"
title={notification.subject.title}
title={notificationTitle}
>
{notification.subject.title}
<span
className={cn(
'text-xxs ml-1',
Opacity.READ,
!settings.showNumber && 'hidden',
)}
>
{notificationNumber}
</span>
</div>

<NotificationFooter notification={notification} />
Expand Down
12 changes: 12 additions & 0 deletions src/components/__snapshots__/AccountNotifications.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9973107

Please sign in to comment.