From 261498f6a3d7002d4e78823a1db52712fde12677 Mon Sep 17 00:00:00 2001 From: Afonso Jorge Ramos Date: Tue, 12 May 2026 02:16:25 +0100 Subject: [PATCH] refactor(forges): expose participatingDocsUrl on the adapter --- .../settings/NotificationSettings.test.tsx | 4 +- .../settings/NotificationSettings.tsx | 43 +++++++++++-------- src/renderer/utils/forges/github/adapter.ts | 1 + src/renderer/utils/forges/types.ts | 6 +++ src/renderer/utils/system/links.test.ts | 7 --- src/renderer/utils/system/links.ts | 6 --- 6 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/renderer/components/settings/NotificationSettings.test.tsx b/src/renderer/components/settings/NotificationSettings.test.tsx index e52a6f92e..5bf20192e 100644 --- a/src/renderer/components/settings/NotificationSettings.test.tsx +++ b/src/renderer/components/settings/NotificationSettings.test.tsx @@ -212,9 +212,7 @@ describe('renderer/components/settings/NotificationSettings.tsx', () => { const tooltipElement = screen.getByLabelText('tooltip-showOnlyParticipating'); await userEvent.click(tooltipElement); - await userEvent.click( - screen.getByTitle('Open GitHub documentation for participating and watching notifications'), - ); + await userEvent.click(screen.getByTitle('Open the participating-vs-watching documentation')); expect(openExternalLinkSpy).toHaveBeenCalledTimes(1); expect(openExternalLinkSpy).toHaveBeenCalledWith( diff --git a/src/renderer/components/settings/NotificationSettings.tsx b/src/renderer/components/settings/NotificationSettings.tsx index 75676ca9f..d1725031a 100644 --- a/src/renderer/components/settings/NotificationSettings.tsx +++ b/src/renderer/components/settings/NotificationSettings.tsx @@ -34,7 +34,8 @@ import { Title } from '../primitives/Title'; import { FetchType, GroupBy, Size } from '../../types'; import { hasAlternateScopes, hasRecommendedScopes } from '../../utils/auth/scopes'; -import { openGitHubParticipatingDocs } from '../../utils/system/links'; +import { getAdapter } from '../../utils/forges/registry'; +import { openExternalLink } from '../../utils/system/comms'; export const NotificationSettings: FC = () => { const navigate = useNavigate(); @@ -43,6 +44,12 @@ export const NotificationSettings: FC = () => { const [fetchInterval, setFetchInterval] = useState(settings.fetchInterval); + // Surface the first signed-in forge's participating-vs-watching docs link. + // Hidden when no registered account advertises one (e.g. Gitea-only setups). + const participatingDocsUrl = auth.accounts + .map((account) => getAdapter(account).participatingDocsUrl) + .find((url): url is NonNullable => Boolean(url)); + useEffect(() => { setFetchInterval(settings.fetchInterval); }, [settings.fetchInterval]); @@ -332,22 +339,24 @@ export const NotificationSettings: FC = () => { When unchecked, {APPLICATION.NAME} will fetch participating and watching notifications. - - See{' '} - {' '} - for more details. - + {participatingDocsUrl && ( + + See{' '} + {' '} + for more details. + + )} } /> diff --git a/src/renderer/utils/forges/github/adapter.ts b/src/renderer/utils/forges/github/adapter.ts index e89e8a627..70798e782 100644 --- a/src/renderer/utils/forges/github/adapter.ts +++ b/src/renderer/utils/forges/github/adapter.ts @@ -99,6 +99,7 @@ export const githubAdapter: ForgeAdapter = { getPersonalAccessTokenSettingsUrl: getNewTokenURL, getAccountSettingsUrl: getDeveloperSettingsURL, documentationUrl: Constants.GITHUB_DOCS.PAT_URL as Link, + participatingDocsUrl: Constants.GITHUB_DOCS.PARTICIPATING_URL, supportsOAuthScopes: true, diff --git a/src/renderer/utils/forges/types.ts b/src/renderer/utils/forges/types.ts index e6404bae7..64496856c 100644 --- a/src/renderer/utils/forges/types.ts +++ b/src/renderer/utils/forges/types.ts @@ -176,6 +176,12 @@ export interface ForgeAdapter { loginMethods: ReadonlyArray; /** External documentation link shown in the PAT login route. */ documentationUrl: Link; + /** + * Optional link to the forge's docs explaining participating-vs-watching + * notification behaviour. Surfaced in NotificationSettings; the button is + * hidden when no registered account exposes one. + */ + participatingDocsUrl?: Link; // --- Auth flows --- // Optional because not every forge supports every flow. Gitea today is diff --git a/src/renderer/utils/system/links.test.ts b/src/renderer/utils/system/links.test.ts index d37862b79..a50c6bbcc 100644 --- a/src/renderer/utils/system/links.test.ts +++ b/src/renderer/utils/system/links.test.ts @@ -14,7 +14,6 @@ import { openAccountSettings, openHostIssues, openHostNotifications, - openGitHubParticipatingDocs, openHostPulls, openGitifyReleaseNotes, openHost, @@ -100,10 +99,4 @@ describe('renderer/utils/links.ts', () => { expect(openExternalLinkSpy).toHaveBeenCalledWith(mockNotificationUrl); }); - - it('openParticipatingDocs', () => { - openGitHubParticipatingDocs(); - - expect(openExternalLinkSpy).toHaveBeenCalledWith(Constants.GITHUB_DOCS.PARTICIPATING_URL); - }); }); diff --git a/src/renderer/utils/system/links.ts b/src/renderer/utils/system/links.ts index 4a278429b..b84d726ba 100644 --- a/src/renderer/utils/system/links.ts +++ b/src/renderer/utils/system/links.ts @@ -1,7 +1,5 @@ import { APPLICATION } from '../../../shared/constants'; -import { Constants } from '../../constants'; - import type { Account, GitifyNotification, @@ -66,7 +64,3 @@ export async function openNotification(notification: GitifyNotification) { const url = await generateGitHubWebUrl(notification); openExternalLink(url); } - -export function openGitHubParticipatingDocs() { - openExternalLink(Constants.GITHUB_DOCS.PARTICIPATING_URL); -}