diff --git a/components/dashboard/src/Menu.tsx b/components/dashboard/src/Menu.tsx index f8e59266e45cdc..2be09b07b800a1 100644 --- a/components/dashboard/src/Menu.tsx +++ b/components/dashboard/src/Menu.tsx @@ -111,7 +111,6 @@ export default function Menu() { "account", "notifications", "billing", - "usage", "plans", "teams", "orgs", @@ -206,7 +205,22 @@ export default function Menu() { } // Team menu if (!team) { - return []; + return [ + { + title: "Projects", + link: `/projects`, + alternatives: [] as string[], + }, + ...(BillingMode.showUsageBasedBilling(userBillingMode) && + !user?.additionalData?.isMigratedToTeamOnlyAttribution + ? [ + { + title: "Usage", + link: "/usage", + }, + ] + : []), + ]; } const currentUserInTeam = (teamMembers[team.id] || []).find((m) => m.userId === user?.id); @@ -227,7 +241,7 @@ export default function Menu() { ) { teamSettingsList.push({ title: "Usage", - link: `/org-usage`, + link: `/usage`, }); } if (currentUserInTeam?.role === "owner") { @@ -465,15 +479,6 @@ export default function Menu() { title: "Settings", link: "/settings", }, - ...(BillingMode.showUsageBasedBilling(userBillingMode) && - !user?.additionalData?.isMigratedToTeamOnlyAttribution - ? [ - { - title: "Usage", - link: "/usage", - }, - ] - : []), { title: "Docs", href: "https://www.gitpod.io/docs/", diff --git a/components/dashboard/src/Usage.tsx b/components/dashboard/src/Usage.tsx index 701d82b04eebe1..0bffa280505ffa 100644 --- a/components/dashboard/src/Usage.tsx +++ b/components/dashboard/src/Usage.tsx @@ -4,19 +4,25 @@ * See License.AGPL.txt in the project root for license information. */ -import { useContext } from "react"; - +import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution"; import UsageView from "./components/UsageView"; -import { UserContext } from "./user-context"; +import { useCurrentTeam } from "./teams/teams-context"; +import { useCurrentUser } from "./user-context"; -function TeamUsage() { - const { user } = useContext(UserContext); +function Usage() { + const user = useCurrentUser(); + const org = useCurrentTeam(); if (!user) { return <>; } - return ; + let attributionId: AttributionId = { kind: "user", userId: user.id }; + if (org) { + attributionId = { kind: "team", teamId: org.id }; + } + + return ; } -export default TeamUsage; +export default Usage; diff --git a/components/dashboard/src/app/AppRoutes.tsx b/components/dashboard/src/app/AppRoutes.tsx index a8d25d7898afad..edac971b2d3cbf 100644 --- a/components/dashboard/src/app/AppRoutes.tsx +++ b/components/dashboard/src/app/AppRoutes.tsx @@ -65,7 +65,6 @@ const Members = React.lazy(() => import(/* webpackPrefetch: true */ "../teams/Me const TeamSettings = React.lazy(() => import(/* webpackPrefetch: true */ "../teams/TeamSettings")); const TeamBilling = React.lazy(() => import(/* webpackPrefetch: true */ "../teams/TeamBilling")); const SSO = React.lazy(() => import(/* webpackPrefetch: true */ "../teams/SSO")); -const TeamUsage = React.lazy(() => import(/* webpackPrefetch: true */ "../teams/TeamUsage")); const NewProject = React.lazy(() => import(/* webpackPrefetch: true */ "../projects/NewProject")); const Projects = React.lazy(() => import(/* webpackPrefetch: true */ "../projects/Projects")); const Project = React.lazy(() => import(/* webpackPrefetch: true */ "../projects/Project")); @@ -227,7 +226,6 @@ export const AppRoutes: FunctionComponent = ({ user, teams }) => - diff --git a/components/dashboard/src/teams/TeamUsage.tsx b/components/dashboard/src/teams/TeamUsage.tsx deleted file mode 100644 index 27714a2d6be1c1..00000000000000 --- a/components/dashboard/src/teams/TeamUsage.tsx +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2022 Gitpod GmbH. All rights reserved. - * Licensed under the GNU Affero General Public License (AGPL). - * See License.AGPL.txt in the project root for license information. - */ - -import { useCurrentTeam } from "./teams-context"; -import UsageView from "../components/UsageView"; - -function TeamUsage() { - const team = useCurrentTeam(); - if (!team) { - return <>; - } - - return ( - - ); -} - -export default TeamUsage;