Skip to content

Commit 65017f6

Browse files
committed
[TOOL-4120] Dashboard: Improved team switching UX, switch to same subpage (#6876)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR introduces a new `isOnProjectPage` boolean prop across various components to enhance the handling of project-specific logic in the UI, particularly in team selection and header components. ### Detailed summary - Added `isOnProjectPage` prop to `TeamSelectorMobileMenuButton`. - Updated `TeamSelectionUI` to accept `isOnProjectPage` and utilize it for link generation. - Modified link logic in `TeamSelectionUI` based on `isOnProjectPage`. - Adjusted `AccountHeaderUI` and `TeamHeaderUI` to pass the new prop. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 880650d commit 65017f6

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

apps/dashboard/src/app/(app)/account/components/AccountHeaderUI.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export function AccountHeaderMobileUI(props: AccountHeaderCompProps) {
113113

114114
{props.teamsAndProjects.length > 0 && (
115115
<TeamSelectorMobileMenuButton
116+
isOnProjectPage={false}
116117
currentTeam={undefined}
117118
teamsAndProjects={props.teamsAndProjects}
118119
upgradeTeamLink={undefined}

apps/dashboard/src/app/(app)/team/components/TeamHeader/TeamAndProjectSelectorPopoverButton.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export function TeamAndProjectSelectorPopoverButton(props: TeamSwitcherProps) {
8484
<div className="no-scrollbar flex [&>div]:min-w-[280px]">
8585
{/* Left */}
8686
<TeamSelectionUI
87+
isOnProjectPage={!!props.currentProject}
8788
currentTeam={currentTeam}
8889
setHoveredTeam={setHoveredTeam}
8990
teamsAndProjects={teamsAndProjects}

apps/dashboard/src/app/(app)/team/components/TeamHeader/TeamHeaderUI.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export function TeamHeaderMobileUI(props: TeamHeaderCompProps) {
166166
</Link>
167167

168168
<TeamSelectorMobileMenuButton
169+
isOnProjectPage={!!props.currentProject}
169170
currentTeam={props.currentTeam}
170171
teamsAndProjects={props.teamsAndProjects}
171172
upgradeTeamLink={`/team/${currentTeam.slug}/settings`}

apps/dashboard/src/app/(app)/team/components/TeamHeader/TeamSelectionUI.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { cn } from "@/lib/utils";
99
import type { Account } from "@3rdweb-sdk/react/hooks/useApi";
1010
import { CirclePlusIcon } from "lucide-react";
1111
import Link from "next/link";
12+
import { usePathname } from "next/navigation";
1213
import { useState } from "react";
1314
import type { ThirdwebClient } from "thirdweb";
1415
import { TeamPlanBadge } from "../../../components/TeamPlanBadge";
@@ -23,8 +24,10 @@ export function TeamSelectionUI(props: {
2324
upgradeTeamLink: string | undefined;
2425
account: Pick<Account, "email" | "id" | "image"> | undefined;
2526
client: ThirdwebClient;
27+
isOnProjectPage: boolean;
2628
}) {
2729
const { setHoveredTeam, currentTeam, teamsAndProjects } = props;
30+
const pathname = usePathname();
2831
const teamPlan = currentTeam ? getValidTeamPlan(currentTeam) : undefined;
2932
const teams = teamsAndProjects.map((x) => x.team);
3033
const [searchTeamTerm, setSearchTeamTerm] = useState("");
@@ -88,7 +91,13 @@ export function TeamSelectionUI(props: {
8891
variant="ghost"
8992
asChild
9093
>
91-
<Link href={`/team/${team.slug}`}>
94+
<Link
95+
href={
96+
currentTeam && !props.isOnProjectPage
97+
? pathname.replace(currentTeam.slug, team.slug)
98+
: `/team/${team.slug}`
99+
}
100+
>
92101
<div className="flex items-center gap-2">
93102
<GradientAvatar
94103
src={team.image || ""}

apps/dashboard/src/app/(app)/team/components/TeamHeader/TeamSelectorMobileMenuButton.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type TeamSelectorMobileMenuButtonProps = {
1616
upgradeTeamLink: string | undefined;
1717
account: Pick<Account, "email" | "id"> | undefined;
1818
client: ThirdwebClient;
19+
isOnProjectPage: boolean;
1920
};
2021

2122
export function TeamSelectorMobileMenuButton(
@@ -43,6 +44,7 @@ export function TeamSelectorMobileMenuButton(
4344
<DialogContent dialogCloseClassName="hidden" className="p-0">
4445
<DynamicHeight>
4546
<TeamSelectionUI
47+
isOnProjectPage={props.isOnProjectPage}
4648
currentTeam={currentTeam}
4749
setHoveredTeam={() => {}} // don't care on mobile
4850
teamsAndProjects={teamsAndProjects}

0 commit comments

Comments
 (0)