Skip to content

Commit 091e1e2

Browse files
authored
feat: link version number to release notes (#925)
1 parent e8d24f2 commit 091e1e2

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

src/routes/Settings.test.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { AppContext } from '../context/App';
1010
import * as apiRequests from '../utils/api-requests';
1111
import Constants from '../utils/constants';
1212
import { SettingsRoute } from './Settings';
13+
import { shell } from 'electron';
1314

1415
const mockNavigate = jest.fn();
1516
jest.mock('react-router-dom', () => ({
@@ -390,4 +391,30 @@ describe('routes/Settings.tsx', () => {
390391
).parentNode.parentNode,
391392
).toMatchSnapshot();
392393
});
394+
395+
it('should open release notes', async () => {
396+
let getByTitle;
397+
398+
await act(async () => {
399+
const { getByTitle: getByTitleLocal } = render(
400+
<AppContext.Provider
401+
value={{
402+
settings: mockSettings,
403+
accounts: mockAccounts,
404+
}}
405+
>
406+
<MemoryRouter>
407+
<SettingsRoute />
408+
</MemoryRouter>
409+
</AppContext.Provider>,
410+
);
411+
getByTitle = getByTitleLocal;
412+
});
413+
414+
fireEvent.click(getByTitle('View release notes'));
415+
expect(shell.openExternal).toHaveBeenCalledTimes(1);
416+
expect(shell.openExternal).toHaveBeenCalledWith(
417+
'https://github.com/gitify-app/gitify/releases/tag/v0.0.1',
418+
);
419+
});
393420
});

src/routes/Settings.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { AppContext } from '../context/App';
2020
import { Appearance } from '../types';
2121
import { apiRequestAuth } from '../utils/api-requests';
2222
import { setAppearance } from '../utils/appearance';
23-
import { updateTrayIcon } from '../utils/comms';
23+
import { openExternalLink, updateTrayIcon } from '../utils/comms';
2424
import Constants from '../utils/constants';
2525
import { generateGitHubAPIUrl } from '../utils/helpers';
2626

@@ -32,6 +32,12 @@ export const SettingsRoute: React.FC = () => {
3232
const [appVersion, setAppVersion] = useState<string | null>(null);
3333
const [colorScope, setColorScope] = useState<boolean>(false);
3434

35+
const openGitHubReleaseNotes = useCallback((version) => {
36+
openExternalLink(
37+
`https://github.com/${Constants.REPO_SLUG}/releases/tag/v${version}`,
38+
);
39+
}, []);
40+
3541
useEffect(() => {
3642
ipcRenderer.invoke('get-platform').then((result: string) => {
3743
setIsLinux(result === 'linux');
@@ -166,8 +172,13 @@ export const SettingsRoute: React.FC = () => {
166172
</div>
167173

168174
<div className="flex justify-between items-center bg-gray-200 dark:bg-gray-darker py-4 px-8">
169-
<small className="font-semibold">Gitify v{appVersion}</small>
170-
175+
<small
176+
className="font-semibold cursor-pointer"
177+
title="View release notes"
178+
onClick={() => openGitHubReleaseNotes(appVersion)}
179+
>
180+
Gitify v{appVersion}
181+
</small>
171182
<div>
172183
<button
173184
className={footerButtonClass}

src/routes/__snapshots__/Settings.test.tsx.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ exports[`routes/Settings.tsx should render itself & its children 1`] = `
281281
class="flex justify-between items-center bg-gray-200 dark:bg-gray-darker py-4 px-8"
282282
>
283283
<small
284-
class="font-semibold"
284+
class="font-semibold cursor-pointer"
285+
title="View release notes"
285286
>
286287
Gitify v
287288
0.0.1

0 commit comments

Comments
 (0)