From c79e2d92779863454c4ffcd728479b5c43c778b8 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Tue, 6 Aug 2024 01:20:14 -0400 Subject: [PATCH 1/7] feat(account): add avatar and account-level quick links Signed-off-by: Adam Setch --- src/__mocks__/state-mocks.ts | 2 + src/components/AccountNotifications.tsx | 32 +- src/components/RepositoryNotifications.tsx | 2 +- .../AccountNotifications.test.tsx.snap | 1068 +++++++++++++---- .../RepositoryNotifications.test.tsx.snap | 14 +- src/context/App.tsx | 22 +- src/routes/Accounts.tsx | 31 +- .../__snapshots__/Accounts.test.tsx.snap | 99 +- src/types.ts | 1 + src/utils/auth/utils.test.ts | 16 +- src/utils/auth/utils.ts | 39 +- 11 files changed, 1006 insertions(+), 320 deletions(-) diff --git a/src/__mocks__/state-mocks.ts b/src/__mocks__/state-mocks.ts index 0065b2390..68f46e8e5 100644 --- a/src/__mocks__/state-mocks.ts +++ b/src/__mocks__/state-mocks.ts @@ -5,6 +5,7 @@ import { type GitifyUser, GroupBy, type Hostname, + type Link, OpenPreference, type SettingsState, Theme, @@ -24,6 +25,7 @@ export const mockGitifyUser: GitifyUser = { login: 'octocat', name: 'Mona Lisa Octocat', id: 123456789, + avatar: 'https://avatars.githubusercontent.com/u/583231?v=4' as Link, }; export const mockPersonalAccessTokenAccount: Account = { diff --git a/src/components/AccountNotifications.tsx b/src/components/AccountNotifications.tsx index 3714bc649..4e3a2c971 100644 --- a/src/components/AccountNotifications.tsx +++ b/src/components/AccountNotifications.tsx @@ -2,19 +2,27 @@ import { ChevronDownIcon, ChevronLeftIcon, ChevronUpIcon, + FeedPersonIcon, + GitPullRequestIcon, + IssueOpenedIcon, } from '@primer/octicons-react'; import { type FC, type MouseEvent, useContext, useMemo, useState } from 'react'; import { AppContext } from '../context/App'; import { type Account, type GitifyError, Opacity, Size } from '../types'; import type { Notification } from '../typesGitHub'; import { cn } from '../utils/cn'; -import { openAccountProfile } from '../utils/links'; +import { + openAccountProfile, + openGitHubIssues, + openGitHubPulls, +} from '../utils/links'; import { AllRead } from './AllRead'; import { HoverGroup } from './HoverGroup'; import { NotificationRow } from './NotificationRow'; import { Oops } from './Oops'; import { RepositoryNotifications } from './RepositoryNotifications'; import { InteractionButton } from './buttons/InteractionButton'; +import { AvatarIcon } from './icons/AvatarIcon'; import { PlatformIcon } from './icons/PlatformIcon'; interface IAccountNotifications { @@ -85,8 +93,13 @@ export const AccountNotifications: FC = ( onClick={toggleAccountNotifications} >
-
- +
+
+ + openGitHubIssues(account.hostname)} + /> + openGitHubPulls(account.hostname)} + /> = ({ >
- - - + octocat's avatar
+ + + + +
@@ -1160,27 +1360,13 @@ exports[`components/AccountNotifications.tsx should render itself - group notifi class="flex" >
- - - + octocat's avatar
+ + - - -
-

- 🎊 -

-

- No new notifications. -

-
- - , - "container":
-
-
-
-
- + + +
+
+
+

+ 🎊 +

+

+ No new notifications. +

+
+
+ , + "container":
+
+
+
+ octocat's avatar +
+ + + + +
@@ -94,6 +103,20 @@ export const AccountsRoute: FC = () => {
+
@@ -142,6 +148,27 @@ exports[`routes/Accounts.tsx General should render itself & its children 1`] = `
+
@@ -247,6 +280,27 @@ exports[`routes/Accounts.tsx General should render itself & its children 1`] = `
+
@@ -352,6 +412,27 @@ exports[`routes/Accounts.tsx General should render itself & its children 1`] = `
+