From 8b0df6edb0fde27beecd843ce3d1fca384646a49 Mon Sep 17 00:00:00 2001 From: Calvin Yau Date: Fri, 3 Jan 2025 01:46:27 -0800 Subject: [PATCH 1/2] Appless non-PAT org dropdown clarity changes --- .../ContextSwitcher/ContextSwitcher.test.jsx | 8 ++++++-- src/ui/ContextSwitcher/ContextSwitcher.tsx | 20 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/ui/ContextSwitcher/ContextSwitcher.test.jsx b/src/ui/ContextSwitcher/ContextSwitcher.test.jsx index dc7cbeffbb..4fe6fc53f7 100644 --- a/src/ui/ContextSwitcher/ContextSwitcher.test.jsx +++ b/src/ui/ContextSwitcher/ContextSwitcher.test.jsx @@ -290,7 +290,9 @@ describe('ContextSwitcher', () => { { wrapper: wrapper() } ) - const installCopy = await screen.findByText(/Install Codecov GitHub app/) + const installCopy = await screen.findByText( + /To add another organization, install Codecov GitHub App/ + ) expect(installCopy).toBeInTheDocument() expect(installCopy).toHaveAttribute( 'href', @@ -761,7 +763,9 @@ describe('ContextSwitcher', () => { } ) - const installCopy = await screen.findByText(/Install Codecov GitHub app/) + const installCopy = await screen.findByText( + /To add another organization, install Codecov GitHub App/ + ) expect(installCopy).toBeInTheDocument() expect(installCopy).toHaveAttribute( 'href', diff --git a/src/ui/ContextSwitcher/ContextSwitcher.tsx b/src/ui/ContextSwitcher/ContextSwitcher.tsx index d022970e9b..cedcef6148 100644 --- a/src/ui/ContextSwitcher/ContextSwitcher.tsx +++ b/src/ui/ContextSwitcher/ContextSwitcher.tsx @@ -43,6 +43,7 @@ interface ContextItemProps { owner: { username: string | null } | null pageName: string } + currentUserUsername: string | null defaultOrgUsername: string | null setToggle: (arg: boolean) => void owner?: string @@ -50,6 +51,7 @@ interface ContextItemProps { function ContextItem({ context, + currentUserUsername, defaultOrgUsername, setToggle, owner, @@ -77,7 +79,9 @@ function ContextItem({ >
- {orgUsername} + {!!orgUsername && orgUsername === currentUserUsername + ? `${orgUsername}'s personal organization` + : orgUsername || ''}
@@ -142,6 +146,8 @@ export interface Props { contexts: Context[] currentUser: { defaultOrgUsername: string | null + username: string | null + avatarUrl: string } activeContext: { avatarUrl: string @@ -169,6 +175,7 @@ function ContextSwitcher({ const wrapperRef = useCloseOnLooseFocus({ setToggle }) const intersectionRef = useLoadMore({ onLoadMore }) const defaultOrgUsername = currentUser?.defaultOrgUsername + const currentUserUsername = currentUser?.username const isGh = providerToName(provider) === 'Github' const isSelfHosted = config.IS_SELF_HOSTED @@ -177,6 +184,7 @@ function ContextSwitcher({ // self-hosted cannot use default "codecov" app (must set up custom one) const shouldShowGitHubInstallLink = isGh && (isSelfHosted ? isCustomGitHubApp : true) + const displayUsername = activeContext?.username ?? owner return (
@@ -193,7 +201,12 @@ function ContextSwitcher({ onClick={() => setToggle((toggle) => !toggle)} > -

{activeContext?.username ?? owner}

+

+ {displayUsername} + {displayUsername === currentUserUsername + ? "'s personal organization" + : ''} +