Skip to content

Commit 714602d

Browse files
committed
Nebula scope changes in create project modal and project settings page (#5684)
DASH-578
1 parent c11ae45 commit 714602d

File tree

17 files changed

+115
-43
lines changed

17 files changed

+115
-43
lines changed

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/embed/embed-setup.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ export const EmbedSetup: React.FC<EmbedSetupProps> = ({
313313
});
314314
apiKeys.refetch();
315315
}}
316+
enableNebulaServiceByDefault={false}
316317
/>
317318

318319
<Flex gap={8} direction={{ base: "column", md: "row" }}>

apps/dashboard/src/app/account/components/AccountHeader.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ export function AccountHeader(props: {
2121
}) {
2222
const myAccountQuery = useAccount();
2323
const router = useDashboardRouter();
24-
const [isCreateProjectDialogOpen, setIsCreateProjectDialogOpen] =
25-
useState(false);
24+
const [createProjectDialogState, setCreateProjectDialogState] = useState<
25+
{ team: Team; isOpen: true } | { isOpen: false }
26+
>({ isOpen: false });
27+
2628
const client = useThirdwebClient();
2729
const wallet = useActiveWallet();
2830
const { disconnect } = useDisconnect();
@@ -43,7 +45,11 @@ export function AccountHeader(props: {
4345
teamsAndProjects: props.teamsAndProjects,
4446
logout: logout,
4547
connectButton: <CustomConnectWallet />,
46-
createProject: () => setIsCreateProjectDialogOpen(true),
48+
createProject: (team: Team) =>
49+
setCreateProjectDialogState({
50+
team,
51+
isOpen: true,
52+
}),
4753
account: myAccountQuery.data,
4854
client,
4955
};
@@ -54,12 +60,20 @@ export function AccountHeader(props: {
5460
<AccountHeaderMobileUI {...headerProps} className="lg:hidden" />
5561

5662
<LazyCreateAPIKeyDialog
57-
open={isCreateProjectDialogOpen}
58-
onOpenChange={setIsCreateProjectDialogOpen}
63+
open={createProjectDialogState.isOpen}
64+
onOpenChange={() =>
65+
setCreateProjectDialogState({
66+
isOpen: false,
67+
})
68+
}
5969
onCreateAndComplete={() => {
6070
// refresh projects
6171
router.refresh();
6272
}}
73+
enableNebulaServiceByDefault={
74+
createProjectDialogState.isOpen &&
75+
createProjectDialogState.team.enabledScopes.includes("nebula")
76+
}
6377
/>
6478
</div>
6579
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export type AccountHeaderCompProps = {
1616
logout: () => void;
1717
connectButton: React.ReactNode;
1818
teamsAndProjects: Array<{ team: Team; projects: Project[] }>;
19-
createProject: () => void;
19+
createProject: (team: Team) => void;
2020
account: Pick<Account, "email" | "id"> | undefined;
2121
client: ThirdwebClient;
2222
};

apps/dashboard/src/app/team/[team_slug]/(team)/~/projects/TeamProjectsPage.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
"use client";
22

33
import type { Project } from "@/api/projects";
4+
import type { Team } from "@/api/team";
5+
import { ProjectAvatar } from "@/components/blocks/Avatars/ProjectAvatar";
6+
import { CopyButton } from "@/components/ui/CopyButton";
47
import { Button } from "@/components/ui/button";
58
import {
69
DropdownMenu,
710
DropdownMenuContent,
811
DropdownMenuTrigger,
912
} from "@/components/ui/dropdown-menu";
1013
import { Input } from "@/components/ui/input";
11-
import { format } from "date-fns";
12-
import { ChevronDownIcon, SearchIcon } from "lucide-react";
13-
import Link from "next/link";
14-
import { useState } from "react";
15-
16-
import { ProjectAvatar } from "@/components/blocks/Avatars/ProjectAvatar";
17-
import { CopyButton } from "@/components/ui/CopyButton";
1814
import {
1915
Select,
2016
SelectContent,
@@ -23,12 +19,16 @@ import {
2319
} from "@/components/ui/select";
2420
import { useDashboardRouter } from "@/lib/DashboardRouter";
2521
import { LazyCreateAPIKeyDialog } from "components/settings/ApiKeys/Create/LazyCreateAPIKeyDialog";
22+
import { format } from "date-fns";
23+
import { ChevronDownIcon, SearchIcon } from "lucide-react";
24+
import Link from "next/link";
25+
import { useState } from "react";
2626

2727
type SortyById = "name" | "createdAt";
2828

2929
export function TeamProjectsPage(props: {
3030
projects: Project[];
31-
team_slug: string;
31+
team: Team;
3232
}) {
3333
const { projects } = props;
3434
const [searchTerm, setSearchTerm] = useState("");
@@ -69,7 +69,7 @@ export function TeamProjectsPage(props: {
6969
<SelectBy value={sortBy} onChange={setSortBy} />
7070
<AddNewButton
7171
createProject={() => setIsCreateProjectDialogOpen(true)}
72-
teamMembersSettingsPath={`/team/${props.team_slug}/~/settings/members`}
72+
teamMembersSettingsPath={`/team/${props.team.slug}/~/settings/members`}
7373
/>
7474
</div>
7575
</div>
@@ -88,7 +88,7 @@ export function TeamProjectsPage(props: {
8888
<ProjectCard
8989
key={project.id}
9090
project={project}
91-
team_slug={props.team_slug}
91+
team_slug={props.team.slug}
9292
/>
9393
);
9494
})}
@@ -104,6 +104,9 @@ export function TeamProjectsPage(props: {
104104
// refresh projects
105105
router.refresh();
106106
}}
107+
enableNebulaServiceByDefault={props.team.enabledScopes.includes(
108+
"nebula",
109+
)}
107110
/>
108111
</div>
109112
);
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import { getProjects } from "@/api/projects";
2+
import { getTeamBySlug } from "@/api/team";
3+
import { redirect } from "next/navigation";
24
import { TeamProjectsPage } from "./TeamProjectsPage";
35

46
export default async function Page(props: {
57
params: Promise<{ team_slug: string }>;
68
}) {
7-
const projects = await getProjects((await props.params).team_slug);
8-
9-
return (
10-
<TeamProjectsPage
11-
projects={projects}
12-
team_slug={(await props.params).team_slug}
13-
/>
14-
);
9+
const params = await props.params;
10+
const team = await getTeamBySlug(params.team_slug);
11+
12+
if (!team) {
13+
redirect("/team");
14+
}
15+
16+
const projects = await getProjects(params.team_slug);
17+
18+
return <TeamProjectsPage projects={projects} team={team} />;
1519
}

apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/ProjectGeneralSettingsPage.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ function Story() {
6060
payConfig: "/payConfig",
6161
}}
6262
onKeyUpdated={undefined}
63+
showNebulaSettings={false}
6364
/>
6465

6566
<Toaster richColors />

apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/ProjectGeneralSettingsPage.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export function ProjectGeneralSettingsPage(props: {
5151
apiKey: ApiKey;
5252
paths: EditProjectUIPaths;
5353
onKeyUpdated: (() => void) | undefined;
54+
showNebulaSettings: boolean;
5455
}) {
5556
const updateMutation = useUpdateApiKey();
5657
const deleteMutation = useRevokeApiKey();
@@ -62,6 +63,7 @@ export function ProjectGeneralSettingsPage(props: {
6263
deleteMutation={deleteMutation}
6364
paths={props.paths}
6465
onKeyUpdated={props.onKeyUpdated}
66+
showNebulaSettings={props.showNebulaSettings}
6567
/>
6668
);
6769
}
@@ -81,6 +83,7 @@ interface EditApiKeyProps {
8183
deleteMutation: DeleteMutation;
8284
paths: EditProjectUIPaths;
8385
onKeyUpdated: (() => void) | undefined;
86+
showNebulaSettings: boolean;
8487
}
8588

8689
type UpdateAPIForm = UseFormReturn<ApiKeyValidationSchema>;
@@ -233,6 +236,7 @@ export const ProjectGeneralSettingsPageUI: React.FC<EditApiKeyProps> = (
233236
updateMutation={updateMutation}
234237
handleSubmit={handleSubmit}
235238
paths={props.paths}
239+
showNebulaSettings={props.showNebulaSettings}
236240
/>
237241

238242
<DeleteProject
@@ -470,6 +474,7 @@ function EnabledServicesSetting(props: {
470474
handleSubmit: () => void;
471475
apiKey: ApiKey;
472476
paths: EditApiKeyProps["paths"];
477+
showNebulaSettings: boolean;
473478
}) {
474479
const { form, handleSubmit, updateMutation } = props;
475480

@@ -512,7 +517,10 @@ function EnabledServicesSetting(props: {
512517
<div className="flex flex-col">
513518
{fields.map((srv, idx) => {
514519
const service = getServiceByName(srv.name as ServiceName);
515-
const hidden = HIDDEN_SERVICES.includes(service.name);
520+
const hidden =
521+
(service.name === "nebula" && !props.showNebulaSettings) ||
522+
HIDDEN_SERVICES.includes(service.name);
523+
516524
const serviceName = getServiceByName(service.name as ServiceName);
517525
const shouldShow = !hidden && serviceName;
518526

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
"use client";
22

3+
import type { Team } from "@/api/team";
34
import { useDashboardRouter } from "@/lib/DashboardRouter";
45
import type { ApiKey } from "@3rdweb-sdk/react/hooks/useApi";
56
import { ProjectGeneralSettingsPage } from "./ProjectGeneralSettingsPage";
67

78
export function ProjectGeneralSettingsPageForTeams(props: {
8-
team_slug: string;
9+
team: Team;
910
project_slug: string;
1011
apiKey: ApiKey;
1112
}) {
1213
const router = useDashboardRouter();
13-
const { team_slug, project_slug, apiKey } = props;
14-
const projectSettingsLayout = `/team/${team_slug}/${project_slug}/settings`;
14+
const { team, project_slug, apiKey } = props;
15+
const projectSettingsLayout = `/team/${team.slug}/${project_slug}/settings`;
1516

1617
// TODO - add a Project Image form field on this page
1718

@@ -22,11 +23,12 @@ export function ProjectGeneralSettingsPageForTeams(props: {
2223
aaConfig: `${projectSettingsLayout}/account-abstraction`,
2324
inAppConfig: `${projectSettingsLayout}/in-app-wallets`,
2425
payConfig: `${projectSettingsLayout}/pay`,
25-
afterDeleteRedirectTo: `/team/${team_slug}`,
26+
afterDeleteRedirectTo: `/team/${team.slug}`,
2627
}}
2728
onKeyUpdated={() => {
2829
router.refresh();
2930
}}
31+
showNebulaSettings={team.enabledScopes.includes("nebula")}
3032
/>
3133
);
3234
}

apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/page.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
import { getProject } from "@/api/projects";
2-
import { notFound } from "next/navigation";
2+
import { getTeamBySlug } from "@/api/team";
3+
import { notFound, redirect } from "next/navigation";
34
import { getAPIKeyForProjectId } from "../../../../api/lib/getAPIKeys";
45
import { ProjectGeneralSettingsPageForTeams } from "./ProjectGeneralSettingsPageForTeams";
56

67
export default async function Page(props: {
78
params: Promise<{ team_slug: string; project_slug: string }>;
89
}) {
910
const { team_slug, project_slug } = await props.params;
11+
12+
const team = await getTeamBySlug(team_slug);
13+
14+
if (!team) {
15+
redirect("/team");
16+
}
17+
1018
const project = await getProject(team_slug, project_slug);
1119

1220
if (!project) {
@@ -23,7 +31,7 @@ export default async function Page(props: {
2331
<ProjectGeneralSettingsPageForTeams
2432
apiKey={apiKey}
2533
project_slug={project_slug}
26-
team_slug={team_slug}
34+
team={team}
2735
/>
2836
);
2937
}

apps/dashboard/src/app/team/components/TeamHeader/ProjectSelectorMobileMenuButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type ProjectSelectorMobileMenuButtonProps = {
1313
currentProject: Project;
1414
projects: Project[];
1515
team: Team;
16-
createProject: () => void;
16+
createProject: (team: Team) => void;
1717
};
1818

1919
export function ProjectSelectorMobileMenuButton(
@@ -49,7 +49,7 @@ export function ProjectSelectorMobileMenuButton(
4949
projects={props.projects}
5050
team={props.team}
5151
createProject={() => {
52-
props.createProject();
52+
props.createProject(props.team);
5353
setOpen(false);
5454
}}
5555
/>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type TeamSwitcherProps = {
2121
currentProject: Project | undefined;
2222
teamsAndProjects: Array<{ team: Team; projects: Project[] }>;
2323
focus: "project-selection" | "team-selection";
24-
createProject: () => void;
24+
createProject: (team: Team) => void;
2525
account: Pick<Account, "email" | "id"> | undefined;
2626
};
2727

@@ -104,7 +104,7 @@ export function TeamAndProjectSelectorPopoverButton(props: TeamSwitcherProps) {
104104
team={projectsToShowOfTeam}
105105
createProject={() => {
106106
setOpen(false);
107-
props.createProject();
107+
props.createProject(projectsToShowOfTeam);
108108
}}
109109
/>
110110
)}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type TeamHeaderCompProps = {
2323
account: Pick<Account, "email" | "id"> | undefined;
2424
logout: () => void;
2525
connectButton: React.ReactNode;
26-
createProject: () => void;
26+
createProject: (team: Team) => void;
2727
client: ThirdwebClient;
2828
};
2929

apps/dashboard/src/app/team/components/TeamHeader/team-header-logged-in.client.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ export function TeamHeaderLoggedIn(props: {
2222
currentProject: Project | undefined;
2323
account: Pick<Account, "email" | "id">;
2424
}) {
25-
const [isCreateProjectDialogOpen, setIsCreateProjectDialogOpen] =
26-
useState(false);
25+
const [createProjectDialogState, setCreateProjectDialogState] = useState<
26+
{ team: Team; isOpen: true } | { isOpen: false }
27+
>({ isOpen: false });
2728
const activeWallet = useActiveWallet();
2829
const { disconnect } = useDisconnect();
2930
const router = useDashboardRouter();
@@ -48,7 +49,12 @@ export function TeamHeaderLoggedIn(props: {
4849
account: props.account,
4950
logout: logout,
5051
connectButton: <CustomConnectWallet />,
51-
createProject: () => setIsCreateProjectDialogOpen(true),
52+
createProject: (team: Team) => {
53+
setCreateProjectDialogState({
54+
isOpen: true,
55+
team,
56+
});
57+
},
5258
client: getThirdwebClient(),
5359
};
5460

@@ -58,12 +64,20 @@ export function TeamHeaderLoggedIn(props: {
5864
<TeamHeaderMobileUI {...headerProps} className="lg:hidden" />
5965

6066
<LazyCreateAPIKeyDialog
61-
open={isCreateProjectDialogOpen}
62-
onOpenChange={setIsCreateProjectDialogOpen}
67+
open={createProjectDialogState.isOpen}
68+
onOpenChange={() =>
69+
setCreateProjectDialogState({
70+
isOpen: false,
71+
})
72+
}
6373
onCreateAndComplete={() => {
6474
// refresh projects
6575
router.refresh();
6676
}}
77+
enableNebulaServiceByDefault={
78+
createProjectDialogState.isOpen &&
79+
createProjectDialogState.team.enabledScopes.includes("nebula")
80+
}
6781
/>
6882
</div>
6983
);

apps/dashboard/src/components/settings/ApiKeys/Create/CreateApiKeyModal.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ function Story(props: {
5252
onOpenChange={setIsOpen}
5353
createKeyMutation={mutation}
5454
prefill={props.prefill}
55+
enableNebulaServiceByDefault={false}
5556
/>
5657

5758
<Button

0 commit comments

Comments
 (0)