Skip to content

Commit ff241c8

Browse files
authored
feat: my quick links (#1259)
* feat: my quick links * refactor: extract sidebar button into component * refactor: extract sidebar button into component
1 parent d6123f0 commit ff241c8

File tree

5 files changed

+268
-1
lines changed

5 files changed

+268
-1
lines changed

src/components/Sidebar.test.tsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,50 @@ describe('components/Sidebar.tsx', () => {
146146
);
147147
});
148148

149+
it('opens my github issues page', () => {
150+
const openExternalLinkMock = jest.spyOn(comms, 'openExternalLink');
151+
152+
render(
153+
<AppContext.Provider
154+
value={{
155+
isLoggedIn: true,
156+
notifications: mockAccountNotifications,
157+
}}
158+
>
159+
<MemoryRouter>
160+
<Sidebar />
161+
</MemoryRouter>
162+
</AppContext.Provider>,
163+
);
164+
fireEvent.click(screen.getByLabelText('My Issues'));
165+
expect(openExternalLinkMock).toHaveBeenCalledTimes(1);
166+
expect(openExternalLinkMock).toHaveBeenCalledWith(
167+
'https://github.com/issues',
168+
);
169+
});
170+
171+
it('opens my github pull requests page', () => {
172+
const openExternalLinkMock = jest.spyOn(comms, 'openExternalLink');
173+
174+
render(
175+
<AppContext.Provider
176+
value={{
177+
isLoggedIn: true,
178+
notifications: mockAccountNotifications,
179+
}}
180+
>
181+
<MemoryRouter>
182+
<Sidebar />
183+
</MemoryRouter>
184+
</AppContext.Provider>,
185+
);
186+
fireEvent.click(screen.getByLabelText('My Pull Requests'));
187+
expect(openExternalLinkMock).toHaveBeenCalledTimes(1);
188+
expect(openExternalLinkMock).toHaveBeenCalledWith(
189+
'https://github.com/pulls',
190+
);
191+
});
192+
149193
it('should quit the app', () => {
150194
const quitAppMock = jest.spyOn(comms, 'quitApp');
151195

src/components/Sidebar.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import {
22
BellIcon,
33
GearIcon,
4+
GitPullRequestIcon,
5+
IssueOpenedIcon,
46
SyncIcon,
57
XCircleIcon,
68
} from '@primer/octicons-react';
@@ -9,7 +11,12 @@ import { useLocation, useNavigate } from 'react-router-dom';
911
import { Logo } from '../components/Logo';
1012
import { AppContext } from '../context/App';
1113
import { quitApp } from '../utils/comms';
12-
import { openGitHubNotifications, openGitifyRepository } from '../utils/links';
14+
import {
15+
openGitHubIssues,
16+
openGitHubNotifications,
17+
openGitHubPulls,
18+
openGitifyRepository,
19+
} from '../utils/links';
1320
import { getNotificationCount } from '../utils/notifications';
1421
import { SidebarButton } from './buttons/SidebarButton';
1522

@@ -56,6 +63,18 @@ export const Sidebar: FC = () => {
5663
icon={BellIcon}
5764
onClick={() => openGitHubNotifications()}
5865
/>
66+
67+
<SidebarButton
68+
title="My Issues"
69+
icon={IssueOpenedIcon}
70+
onClick={() => openGitHubIssues()}
71+
/>
72+
73+
<SidebarButton
74+
title="My Pull Requests"
75+
icon={GitPullRequestIcon}
76+
onClick={() => openGitHubPulls()}
77+
/>
5978
</div>
6079

6180
<div className="px-3 py-4">

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

Lines changed: 180 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/links.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import * as helpers from './helpers';
1010
import {
1111
openAccountProfile,
1212
openDeveloperSettings,
13+
openGitHubIssues,
1314
openGitHubNotifications,
1415
openGitHubParticipatingDocs,
16+
openGitHubPulls,
1517
openGitifyReleaseNotes,
1618
openGitifyRepository,
1719
openHost,
@@ -50,6 +52,20 @@ describe('utils/links.ts', () => {
5052
);
5153
});
5254

55+
it('openGitHubIssues', () => {
56+
openGitHubIssues();
57+
expect(comms.openExternalLink).toHaveBeenCalledWith(
58+
'https://github.com/issues',
59+
);
60+
});
61+
62+
it('openGitHubPulls', () => {
63+
openGitHubPulls();
64+
expect(comms.openExternalLink).toHaveBeenCalledWith(
65+
'https://github.com/pulls',
66+
);
67+
});
68+
5369
it('openAccountProfile', () => {
5470
openAccountProfile(mockGitHubCloudAccount);
5571
expect(comms.openExternalLink).toHaveBeenCalledWith(

src/utils/links.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ export function openGitHubNotifications() {
1919
openExternalLink('https://github.com/notifications' as Link);
2020
}
2121

22+
export function openGitHubIssues() {
23+
openExternalLink('https://github.com/issues' as Link);
24+
}
25+
26+
export function openGitHubPulls() {
27+
openExternalLink('https://github.com/pulls' as Link);
28+
}
29+
2230
export function openAccountProfile(account: Account) {
2331
const url = new URL(`https://${account.hostname}`);
2432
url.pathname = account.user.login;

0 commit comments

Comments
 (0)