diff --git a/src/components/AccountNotifications.test.tsx b/src/components/AccountNotifications.test.tsx
index c3021424d..c8806b2ca 100644
--- a/src/components/AccountNotifications.test.tsx
+++ b/src/components/AccountNotifications.test.tsx
@@ -49,4 +49,21 @@ describe('components/AccountNotifications.tsx', () => {
expect(openAccountProfileMock).toHaveBeenCalledTimes(1);
expect(openAccountProfileMock).toHaveBeenCalledWith(mockGitHubCloudAccount);
});
+
+ it('should toggle account notifications visibility', async () => {
+ const props = {
+ account: mockGitHubCloudAccount,
+ notifications: mockGitHubNotifications,
+ showAccountHostname: true,
+ };
+
+ await act(async () => {
+ render();
+ });
+
+ fireEvent.click(screen.getByTitle('Hide account notifications'));
+
+ const tree = render();
+ expect(tree).toMatchSnapshot();
+ });
});
diff --git a/src/components/AccountNotifications.tsx b/src/components/AccountNotifications.tsx
index 0bda63707..d4a9ebcfd 100644
--- a/src/components/AccountNotifications.tsx
+++ b/src/components/AccountNotifications.tsx
@@ -1,4 +1,9 @@
-import { ChevronDownIcon, ChevronLeftIcon } from '@primer/octicons-react';
+import {
+ ChevronDownIcon,
+ ChevronLeftIcon,
+ ChevronUpIcon,
+} from '@primer/octicons-react';
+import { useState } from 'react';
import type { Account } from '../types';
import type { Notification } from '../typesGitHub';
import { openAccountProfile } from '../utils/links';
@@ -26,7 +31,25 @@ export const AccountNotifications = (props: IProps) => {
),
);
- const Chevron = notifications.length > 0 ? ChevronDownIcon : ChevronLeftIcon;
+ const [showNotifications, setShowNotifications] = useState(true);
+
+ const toggleNotifications = () => {
+ setShowNotifications(!showNotifications);
+ };
+
+ const ChevronIcon =
+ notifications.length === 0
+ ? ChevronLeftIcon
+ : showNotifications
+ ? ChevronDownIcon
+ : ChevronUpIcon;
+
+ const toggleNotificationsLabel =
+ notifications.length === 0
+ ? 'No notifications for account'
+ : showNotifications
+ ? 'Hide account notifications'
+ : 'Show account notifications';
return (
<>
@@ -43,23 +66,30 @@ export const AccountNotifications = (props: IProps) => {
-
+
)}
- {Object.values(groupedNotifications).map((repoNotifications) => {
- const repoSlug = repoNotifications[0].repository.full_name;
+ {showNotifications &&
+ Object.values(groupedNotifications).map((repoNotifications) => {
+ const repoSlug = repoNotifications[0].repository.full_name;
- return (
-
- );
- })}
+ return (
+
+ );
+ })}
>
);
};
diff --git a/src/components/__snapshots__/AccountNotifications.test.tsx.snap b/src/components/__snapshots__/AccountNotifications.test.tsx.snap
index 024a22adf..0f1e8f305 100644
--- a/src/components/__snapshots__/AccountNotifications.test.tsx.snap
+++ b/src/components/__snapshots__/AccountNotifications.test.tsx.snap
@@ -37,20 +37,25 @@ exports[`components/AccountNotifications.tsx should render itself (github.com wi
@@ -91,20 +96,25 @@ exports[`components/AccountNotifications.tsx should render itself (github.com wi
@@ -202,6 +212,66 @@ exports[`components/AccountNotifications.tsx should render itself (github.com wi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Repository
+
+