Skip to content

Commit e6c0db6

Browse files
committed
[TOOL-4120] Dashboard: Improved team switching UX, switch to same subpage
1 parent 880650d commit e6c0db6

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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 10 additions & 1 deletion
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

Lines changed: 2 additions & 0 deletions
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)