Skip to content

Commit c548282

Browse files
committed
[Dashboard] Add staff mode for viewing teams without membership
1 parent 2510c4f commit c548282

File tree

2 files changed

+37
-24
lines changed

2 files changed

+37
-24
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/layout.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { getProjects } from "@/api/projects";
2-
import { getTeams } from "@/api/team";
2+
import { getTeamBySlug, getTeams } from "@/api/team";
33
import { AppFooter } from "@/components/blocks/app-footer";
4+
import { Button } from "@/components/ui/button";
45
import { TabPathLinks } from "@/components/ui/tabs";
56
import { getClientThirdwebClient } from "@/constants/thirdweb-client.client";
67
import { AnnouncementBanner } from "components/notices/AnnouncementBanner";
8+
import Link from "next/link";
79
import { redirect } from "next/navigation";
810
import { siwaExamplePrompts } from "../../../(dashboard)/support/page";
911
import { CustomChatButton } from "../../../../nebula-app/(app)/components/CustomChat/CustomChatButton";
@@ -20,25 +22,18 @@ export default async function TeamLayout(props: {
2022
}) {
2123
const params = await props.params;
2224

23-
const [accountAddress, account, teams, authToken] = await Promise.all([
25+
const [accountAddress, account, teams, authToken, team] = await Promise.all([
2426
getAuthTokenWalletAddress(),
2527
getValidAccount(`/team/${params.team_slug}`),
2628
getTeams(),
2729
getAuthToken(),
30+
getTeamBySlug(params.team_slug),
2831
]);
2932

30-
if (!teams || !accountAddress || !authToken) {
33+
if (!teams || !accountAddress || !authToken || !team) {
3134
redirect("/login");
3235
}
3336

34-
const team = teams.find(
35-
(t) => t.slug === decodeURIComponent(params.team_slug),
36-
);
37-
38-
if (!team) {
39-
redirect("/team");
40-
}
41-
4237
const teamsAndProjects = await Promise.all(
4338
teams.map(async (team) => ({
4439
team,
@@ -53,6 +48,21 @@ export default async function TeamLayout(props: {
5348

5449
return (
5550
<div className="flex h-full grow flex-col">
51+
{!teams.some((t) => t.slug === team.slug) && (
52+
<div className="bg-warning-text">
53+
<div className="container flex items-center justify-between py-4">
54+
<div className="flex flex-col gap-2">
55+
<p className="font-bold text-white text-xl">👀 STAFF MODE 👀</p>
56+
<p className="text-sm text-white">
57+
You can only view this team, not take any actions.
58+
</p>
59+
</div>
60+
<Button variant="default" asChild>
61+
<Link href="/team/~">Leave Staff Mode</Link>
62+
</Button>
63+
</div>
64+
</div>
65+
)}
5666
<AnnouncementBanner />
5767
<div className="bg-card">
5868
<TeamHeaderLoggedIn

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,23 @@ export function TeamHeaderDesktopUI(props: TeamHeaderCompProps) {
5454
<SlashSeparator />
5555

5656
<div className="flex items-center gap-1">
57-
<Link
58-
href={`/team/${currentTeam.slug}`}
59-
className="flex flex-row items-center gap-2 font-normal text-sm"
60-
>
61-
<GradientAvatar
62-
id={currentTeam.id}
63-
src={currentTeam.image || ""}
64-
className="size-6"
65-
client={props.client}
66-
/>
67-
<span> {currentTeam.name} </span>
68-
<TeamVerifiedIcon domain={currentTeam.verifiedDomain} />
57+
<span className="flex flex-row items-center gap-2 font-normal text-sm">
58+
<Link
59+
href={`/team/${currentTeam.slug}`}
60+
className="flex flex-row items-center gap-2 font-normal text-sm"
61+
>
62+
<GradientAvatar
63+
id={currentTeam.id}
64+
src={currentTeam.image || ""}
65+
className="size-6"
66+
client={props.client}
67+
/>
68+
<span> {currentTeam.name} </span>
69+
<TeamVerifiedIcon domain={currentTeam.verifiedDomain} />
70+
</Link>
71+
{/* may render its own link so has to be outside of the link */}
6972
<TeamPlanBadge plan={teamPlan} teamSlug={currentTeam.slug} />
70-
</Link>
73+
</span>
7174

7275
<TeamAndProjectSelectorPopoverButton
7376
currentProject={props.currentProject}

0 commit comments

Comments
 (0)