Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
43 changes: 26 additions & 17 deletions src/renderer/components/settings/NotificationSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -43,6 +44,12 @@ export const NotificationSettings: FC = () => {

const [fetchInterval, setFetchInterval] = useState<number>(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<typeof url> => Boolean(url));

useEffect(() => {
setFetchInterval(settings.fetchInterval);
}, [settings.fetchInterval]);
Expand Down Expand Up @@ -332,22 +339,24 @@ export const NotificationSettings: FC = () => {
When <Text as="u">unchecked</Text>, {APPLICATION.NAME} will fetch participating and
watching notifications.
</Text>
<Text>
See{' '}
<button
className="text-gitify-link cursor-pointer"
onClick={(event: MouseEvent<HTMLElement>) => {
// Don't trigger onClick of parent element.
event.stopPropagation();
openGitHubParticipatingDocs();
}}
title="Open GitHub documentation for participating and watching notifications"
type="button"
>
official docs
</button>{' '}
for more details.
</Text>
{participatingDocsUrl && (
<Text>
See{' '}
<button
className="text-gitify-link cursor-pointer"
onClick={(event: MouseEvent<HTMLElement>) => {
// Don't trigger onClick of parent element.
event.stopPropagation();
openExternalLink(participatingDocsUrl);
}}
title="Open the participating-vs-watching documentation"
type="button"
>
official docs
</button>{' '}
for more details.
</Text>
)}
</Stack>
}
/>
Expand Down
1 change: 1 addition & 0 deletions src/renderer/utils/forges/github/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
6 changes: 6 additions & 0 deletions src/renderer/utils/forges/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ export interface ForgeAdapter {
loginMethods: ReadonlyArray<LoginMethodDescriptor>;
/** 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
Expand Down
7 changes: 0 additions & 7 deletions src/renderer/utils/system/links.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
openAccountSettings,
openHostIssues,
openHostNotifications,
openGitHubParticipatingDocs,
openHostPulls,
openGitifyReleaseNotes,
openHost,
Expand Down Expand Up @@ -100,10 +99,4 @@ describe('renderer/utils/links.ts', () => {

expect(openExternalLinkSpy).toHaveBeenCalledWith(mockNotificationUrl);
});

it('openParticipatingDocs', () => {
openGitHubParticipatingDocs();

expect(openExternalLinkSpy).toHaveBeenCalledWith(Constants.GITHUB_DOCS.PARTICIPATING_URL);
});
});
6 changes: 0 additions & 6 deletions src/renderer/utils/system/links.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { APPLICATION } from '../../../shared/constants';

import { Constants } from '../../constants';

import type {
Account,
GitifyNotification,
Expand Down Expand Up @@ -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);
}
Loading