+
@@ -78,7 +80,7 @@ export const AccountNotifications = (props: IProps) => {
)}
- {showNotifications &&
+ {showAccountNotifications &&
Object.values(groupedNotifications).map((repoNotifications) => {
const repoSlug = repoNotifications[0].repository.full_name;
diff --git a/src/components/Repository.test.tsx b/src/components/Repository.test.tsx
index cf2fa7764..b8b9f3fff 100644
--- a/src/components/Repository.test.tsx
+++ b/src/components/Repository.test.tsx
@@ -1,4 +1,4 @@
-import { fireEvent, render, screen } from '@testing-library/react';
+import { act, fireEvent, render, screen } from '@testing-library/react';
import { mockGitHubCloudAccount } from '../__mocks__/state-mocks';
import { AppContext } from '../context/App';
import type { Link } from '../types';
@@ -91,4 +91,15 @@ describe('components/Repository.tsx', () => {
);
expect(tree).toMatchSnapshot();
});
+
+ it('should toggle account notifications visibility', async () => {
+ await act(async () => {
+ render(
);
+ });
+
+ fireEvent.click(screen.getByTitle('Hide repository notifications'));
+
+ const tree = render(
);
+ expect(tree).toMatchSnapshot();
+ });
});
diff --git a/src/components/Repository.tsx b/src/components/Repository.tsx
index b8cdb9bdf..26da6b267 100644
--- a/src/components/Repository.tsx
+++ b/src/components/Repository.tsx
@@ -1,5 +1,11 @@
-import { CheckIcon, MarkGithubIcon, ReadIcon } from '@primer/octicons-react';
-import { type FC, useCallback, useContext } from 'react';
+import {
+ CheckIcon,
+ ChevronDownIcon,
+ ChevronUpIcon,
+ MarkGithubIcon,
+ ReadIcon,
+} from '@primer/octicons-react';
+import { type FC, useCallback, useContext, useState } from 'react';
import { AppContext } from '../context/App';
import type { Notification } from '../typesGitHub';
import { openRepository } from '../utils/links';
@@ -28,10 +34,25 @@ export const RepositoryNotifications: FC
= ({
const avatarUrl = repoNotifications[0].repository.owner.avatar_url;
const repoSlug = repoNotifications[0].repository.full_name;
+ const [showRepositoryNotifications, setShowRepositoryNotifications] =
+ useState(true);
+
+ const toggleRepositoryNotifications = () => {
+ setShowRepositoryNotifications(!showRepositoryNotifications);
+ };
+
+ const ChevronIcon = showRepositoryNotifications
+ ? ChevronDownIcon
+ : ChevronUpIcon;
+
+ const toggleRepositoryNotificationsLabel = showRepositoryNotifications
+ ? 'Hide repository notifications'
+ : 'Show repository notifications';
+
return (
<>
-
-
+
+
{avatarUrl ? (
= ({
+
- {repoNotifications.map((obj) => (
-
- ))}
+ {showRepositoryNotifications &&
+ repoNotifications.map((obj) => (
+
+ ))}
>
);
};
diff --git a/src/components/__snapshots__/AccountNotifications.test.tsx.snap b/src/components/__snapshots__/AccountNotifications.test.tsx.snap
index d7d8d8798..4c8abbbfd 100644
--- a/src/components/__snapshots__/AccountNotifications.test.tsx.snap
+++ b/src/components/__snapshots__/AccountNotifications.test.tsx.snap
@@ -6,7 +6,7 @@ exports[`components/AccountNotifications.tsx should render itself (github.com wi
"baseElement":
-
+