Skip to content

Commit 0df0646

Browse files
committed
remove org slug
1 parent df290d0 commit 0df0646

18 files changed

+107
-139
lines changed

components/dashboard/src/Menu.tsx

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { countries } from "countries-list";
1313
import gitpodIcon from "./icons/gitpod.svg";
1414
import { getGitpodService, gitpodHostUrl } from "./service/service";
1515
import { UserContext } from "./user-context";
16-
import { TeamsContext, getCurrentTeam, getSelectedTeamSlug } from "./teams/teams-context";
16+
import { useCurrentTeam, useTeams } from "./teams/teams-context";
1717
import { getAdminMenu } from "./admin/admin-menu";
1818
import ContextMenu, { ContextMenuEntry } from "./components/ContextMenu";
1919
import Separator from "./components/Separator";
@@ -39,9 +39,9 @@ interface Entry {
3939
export default function Menu() {
4040
const { user } = useContext(UserContext);
4141
const { showUsageView, oidcServiceEnabled } = useContext(FeatureFlagContext);
42-
const { teams } = useContext(TeamsContext);
42+
const teams = useTeams();
4343
const location = useLocation();
44-
const team = getCurrentTeam(location, teams);
44+
const team = useCurrentTeam();
4545
const { setCurrency, setIsStudent, setIsChargebeeCustomer } = useContext(PaymentContext);
4646
const [teamBillingMode, setTeamBillingMode] = useState<BillingMode | undefined>(undefined);
4747
const [userBillingMode, setUserBillingMode] = useState<BillingMode | undefined>(undefined);
@@ -57,17 +57,12 @@ export default function Menu() {
5757
getGitpodService().server.getBillingModeForUser().then(setUserBillingMode);
5858
}, []);
5959

60-
const teamRouteMatch = useRouteMatch<{ segment1?: string; segment2?: string; segment3?: string }>(
61-
"/t/:segment1/:segment2?/:segment3?",
62-
);
63-
64-
// TODO: Remove it after remove projects under personal accounts
6560
const projectsRouteMatch = useRouteMatch<{ segment1?: string; segment2?: string }>(
6661
"/projects/:segment1?/:segment2?",
6762
);
6863

6964
const projectSlug = (() => {
70-
const resource = teamRouteMatch?.params?.segment2 || projectsRouteMatch?.params.segment1;
65+
const resource = projectsRouteMatch?.params.segment1;
7166
if (
7267
resource &&
7368
![
@@ -89,7 +84,7 @@ export default function Menu() {
8984
}
9085
})();
9186
const prebuildId = (() => {
92-
const resource = projectSlug && (teamRouteMatch?.params?.segment3 || projectsRouteMatch?.params.segment2);
87+
const resource = projectSlug && projectsRouteMatch?.params.segment2;
9388
if (
9489
resource &&
9590
![
@@ -110,7 +105,7 @@ export default function Menu() {
110105
}
111106

112107
// Hide most of the top menu when in a full-page form.
113-
const isMinimalUI = inResource(location.pathname, ["new", "teams/new", "open"]);
108+
const isMinimalUI = inResource(location.pathname, ["new", "orgs/new", "open"]);
114109
const isWorkspacesUI = inResource(location.pathname, ["workspaces"]);
115110
const isPersonalSettingsUI = inResource(location.pathname, [
116111
"account",
@@ -191,22 +186,21 @@ export default function Menu() {
191186
}
192187
}, [team]);
193188

194-
const teamOrUserSlug = !!team ? "/t/" + team.slug : "/projects";
195189
const secondLevelMenu: Entry[] = (() => {
196190
// Project menu
197191
if (projectSlug) {
198192
return [
199193
{
200194
title: "Branches",
201-
link: `${teamOrUserSlug}/${projectSlug}`,
195+
link: `/projects/${projectSlug}`,
202196
},
203197
{
204198
title: "Prebuilds",
205-
link: `${teamOrUserSlug}/${projectSlug}/prebuilds`,
199+
link: `/projects/${projectSlug}/prebuilds`,
206200
},
207201
{
208202
title: "Settings",
209-
link: `${teamOrUserSlug}/${projectSlug}/settings`,
203+
link: `/projects/${projectSlug}/settings`,
210204
alternatives: getProjectSettingsMenu({ slug: projectSlug } as Project, team).flatMap((e) => e.link),
211205
},
212206
];
@@ -220,12 +214,12 @@ export default function Menu() {
220214
const teamSettingsList = [
221215
{
222216
title: "Projects",
223-
link: `/t/${team.slug}/projects`,
217+
link: `/projects`,
224218
alternatives: [] as string[],
225219
},
226220
{
227221
title: "Members",
228-
link: `/t/${team.slug}/members`,
222+
link: `/members`,
229223
},
230224
];
231225
if (
@@ -234,13 +228,13 @@ export default function Menu() {
234228
) {
235229
teamSettingsList.push({
236230
title: "Usage",
237-
link: `/t/${team.slug}/usage`,
231+
link: `/usage`,
238232
});
239233
}
240234
if (currentUserInTeam?.role === "owner") {
241235
teamSettingsList.push({
242236
title: "Settings",
243-
link: `/t/${team.slug}/settings`,
237+
link: `/org-settings`,
244238
alternatives: getTeamSettingsMenu({
245239
team,
246240
billingMode: teamBillingMode,
@@ -277,7 +271,7 @@ export default function Menu() {
277271
const onFeedbackFormClose = () => {
278272
setFeedbackFormVisible(false);
279273
};
280-
const isTeamLevelActive = !projectSlug && !isWorkspacesUI && !isPersonalSettingsUI && !isAdminUI && teamOrUserSlug;
274+
const isTeamLevelActive = !projectSlug && !isWorkspacesUI && !isPersonalSettingsUI && !isAdminUI;
281275
const renderTeamMenu = () => {
282276
if (!hasIndividualProjects && (!teams || teams.length === 0)) {
283277
return (
@@ -291,7 +285,7 @@ export default function Menu() {
291285
);
292286
}
293287
const userFullName = user?.fullName || user?.name || "...";
294-
const entries: (ContextMenuEntry & { slug: string })[] = [
288+
const entries: ContextMenuEntry[] = [
295289
...(hasIndividualProjects
296290
? [
297291
{
@@ -304,16 +298,14 @@ export default function Menu() {
304298
<span className="">Personal Account</span>
305299
</div>
306300
),
307-
active: getSelectedTeamSlug() === "",
301+
active: team === undefined,
308302
separator: true,
309-
slug: "",
310-
link: "/projects",
303+
link: `${location.pathname}?activateOrg=0`,
311304
},
312305
]
313306
: []),
314307
...(teams || [])
315308
.map((t) => ({
316-
slug: t.slug,
317309
title: t.name,
318310
customContent: (
319311
<div className="w-full text-gray-400 flex flex-col">
@@ -325,13 +317,12 @@ export default function Menu() {
325317
</span>
326318
</div>
327319
),
328-
active: getSelectedTeamSlug() === t.slug,
320+
active: team?.id === t.id,
329321
separator: true,
330-
link: `/t/${t.slug}`,
322+
link: `${location.pathname}?activateOrg=${t.id}`,
331323
}))
332324
.sort((a, b) => (a.title.toLowerCase() > b.title.toLowerCase() ? 1 : -1)),
333325
{
334-
slug: "new",
335326
title: "Create a new organization",
336327
customContent: (
337328
<div className="w-full text-gray-400 flex items-center">
@@ -354,7 +345,7 @@ export default function Menu() {
354345
(isTeamLevelActive
355346
? "text-gray-50 bg-gray-800 dark:bg-gray-50 dark:text-gray-900 border-gray-700 dark:border-gray-200"
356347
: "text-gray-500 bg-gray-50 dark:bg-gray-800 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 dark:border-gray-700");
357-
const selectedEntry = entries.find((e) => e.slug === getSelectedTeamSlug()) || entries[0];
348+
const selectedEntry = entries.find((e) => e.active) || entries[0];
358349
return (
359350
<div className="flex p-1">
360351
<Link to={selectedEntry.link!}>
@@ -378,14 +369,14 @@ export default function Menu() {
378369
</ContextMenu>
379370
</div>
380371
{projectSlug && !prebuildId && !isAdminUI && (
381-
<Link to={`${teamOrUserSlug}/${projectSlug}${prebuildId ? "/prebuilds" : ""}`}>
372+
<Link to={`/projects/${projectSlug}${prebuildId ? "/prebuilds" : ""}`}>
382373
<span className=" flex h-full text-base text-gray-50 bg-gray-800 dark:bg-gray-50 dark:text-gray-900 font-semibold ml-2 px-3 py-1 rounded-2xl border-gray-100">
383374
{project?.name}
384375
</span>
385376
</Link>
386377
)}
387378
{prebuildId && (
388-
<Link to={`${teamOrUserSlug}/${projectSlug}${prebuildId ? "/prebuilds" : ""}`}>
379+
<Link to={`/projects/${projectSlug}${prebuildId ? "/prebuilds" : ""}`}>
389380
<span className=" flex h-full text-base text-gray-500 bg-gray-50 hover:bg-gray-100 dark:text-gray-400 dark:bg-gray-800 dark:hover:bg-gray-700 font-semibold ml-2 px-3 py-1 rounded-2xl border-gray-100">
390381
{project?.name}
391382
</span>
@@ -403,7 +394,7 @@ export default function Menu() {
403394
/>
404395
</svg>
405396
</div>
406-
<Link to={`${teamOrUserSlug}/${projectSlug}/${prebuildId}`}>
397+
<Link to={`/projects/${projectSlug}/${prebuildId}`}>
407398
<span className="flex h-full text-base text-gray-50 bg-gray-800 dark:bg-gray-50 dark:text-gray-900 font-semibold px-3 py-1 rounded-2xl border-gray-100">
408399
{prebuildId.substring(0, 8).trimEnd()}
409400
</span>

components/dashboard/src/components/BillingAccountSelector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useContext, useEffect, useState } from "react";
88
import { Team, TeamMemberInfo } from "@gitpod/gitpod-protocol";
99
import { AttributionId, AttributionTarget } from "@gitpod/gitpod-protocol/lib/attribution";
1010
import { getGitpodService } from "../service/service";
11-
import { TeamsContext } from "../teams/teams-context";
11+
import { useTeams } from "../teams/teams-context";
1212
import { UserContext } from "../user-context";
1313
import SelectableCardSolid from "../components/SelectableCardSolid";
1414
import { ReactComponent as Spinner } from "../icons/Spinner.svg";
@@ -17,7 +17,7 @@ import { publicApiTeamMembersToProtocol, teamsService } from "../service/public-
1717

1818
export function BillingAccountSelector(props: { onSelected?: () => void }) {
1919
const { user, setUser } = useContext(UserContext);
20-
const { teams } = useContext(TeamsContext);
20+
const teams = useTeams();
2121
const [teamsAvailableForAttribution, setTeamsAvailableForAttribution] = useState<Team[] | undefined>();
2222
const [membersByTeam, setMembersByTeam] = useState<Record<string, TeamMemberInfo[]>>({});
2323
const [errorMessage, setErrorMessage] = useState<string | undefined>();

components/dashboard/src/components/UsageLimitReachedModal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
import { Team } from "@gitpod/gitpod-protocol";
88
import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution";
9-
import { useContext, useEffect, useState } from "react";
9+
import { useEffect, useState } from "react";
1010
import { gitpodHostUrl } from "../service/service";
11-
import { TeamsContext } from "../teams/teams-context";
11+
import { useTeams } from "../teams/teams-context";
1212
import Alert from "./Alert";
1313
import Modal from "./Modal";
1414

1515
export function UsageLimitReachedModal(p: { hints: any }) {
16-
const { teams } = useContext(TeamsContext);
16+
const teams = useTeams();
1717
// const [attributionId, setAttributionId] = useState<AttributionId | undefined>();
1818
const [attributedTeam, setAttributedTeam] = useState<Team | undefined>();
1919

components/dashboard/src/contexts/FeatureFlagContext.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
*/
66

77
import React, { createContext, useContext, useState, useEffect } from "react";
8-
import { useLocation } from "react-router";
98
import { getExperimentsClient } from "../experiments/client";
109
import { ProjectContext } from "../projects/project-context";
11-
import { getCurrentTeam, TeamsContext } from "../teams/teams-context";
10+
import { useCurrentTeam, useTeams } from "../teams/teams-context";
1211
import { UserContext } from "../user-context";
1312

1413
interface FeatureFlagConfig {
@@ -33,10 +32,9 @@ const FeatureFlagContext = createContext<{
3332

3433
const FeatureFlagContextProvider: React.FC = ({ children }) => {
3534
const { user } = useContext(UserContext);
36-
const { teams } = useContext(TeamsContext);
35+
const teams = useTeams();
3736
const { project } = useContext(ProjectContext);
38-
const location = useLocation();
39-
const team = getCurrentTeam(location, teams);
37+
const team = useCurrentTeam();
4038
const [showUsageView, setShowUsageView] = useState<boolean>(false);
4139
const [isUsageBasedBillingEnabled, setIsUsageBasedBillingEnabled] = useState<boolean>(false);
4240
const [showUseLastSuccessfulPrebuild, setShowUseLastSuccessfulPrebuild] = useState<boolean>(false);

components/dashboard/src/projects/Events.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
import dayjs from "dayjs";
88
import { PrebuildEvent, Project } from "@gitpod/gitpod-protocol";
99
import { useContext, useEffect, useState } from "react";
10-
import { useLocation, useRouteMatch } from "react-router";
10+
import { useRouteMatch } from "react-router";
1111
import Header from "../components/Header";
1212
import { ItemsList, Item, ItemField } from "../components/ItemsList";
1313
import { getGitpodService } from "../service/service";
14-
import { TeamsContext, getCurrentTeam } from "../teams/teams-context";
14+
import { useTeams, useCurrentTeam } from "../teams/teams-context";
1515
import { toRemoteURL } from "./render-utils";
1616
import Spinner from "../icons/Spinner.svg";
1717
import NoAccess from "../icons/NoAccess.svg";
@@ -21,11 +21,9 @@ import { UserContext } from "../user-context";
2121
import { listAllProjects } from "../service/public-api";
2222

2323
export default function () {
24-
const location = useLocation();
25-
26-
const { teams } = useContext(TeamsContext);
24+
const teams = useTeams();
2725
const { user } = useContext(UserContext);
28-
const team = getCurrentTeam(location, teams);
26+
const team = useCurrentTeam();
2927

3028
const match = useRouteMatch<{ team: string; resource: string }>("/(t/)?:team/:resource");
3129
const projectSlug = match?.params?.resource;

components/dashboard/src/projects/NewProject.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useContext, useEffect, useState } from "react";
88
import { getGitpodService, gitpodHostUrl } from "../service/service";
99
import { iconForAuthProvider, openAuthorizeWindow, simplifyProviderName } from "../provider-utils";
1010
import { AuthProviderInfo, Project, ProviderRepository, Team, TeamMemberInfo, User } from "@gitpod/gitpod-protocol";
11-
import { TeamsContext } from "../teams/teams-context";
11+
import { TeamsContext, useTeams } from "../teams/teams-context";
1212
import { useLocation } from "react-router";
1313
import ContextMenu, { ContextMenuEntry } from "../components/ContextMenu";
1414
import CaretDown from "../icons/CaretDown.svg";
@@ -32,7 +32,7 @@ import { useRefreshProjects } from "../data/projects/list-projects-query";
3232

3333
export default function NewProject() {
3434
const location = useLocation();
35-
const { teams } = useContext(TeamsContext);
35+
const teams = useTeams();
3636
const { user, setUser } = useContext(UserContext);
3737
const refreshProjects = useRefreshProjects();
3838

components/dashboard/src/projects/Prebuild.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,22 @@
77
import dayjs from "dayjs";
88
import { PrebuildWithStatus, Project } from "@gitpod/gitpod-protocol";
99
import { useContext, useEffect, useState } from "react";
10-
import { useHistory, useLocation, useRouteMatch } from "react-router";
10+
import { useHistory, useRouteMatch } from "react-router";
1111
import Header from "../components/Header";
1212
import PrebuildLogs from "../components/PrebuildLogs";
1313
import Spinner from "../icons/Spinner.svg";
1414
import { getGitpodService, gitpodHostUrl } from "../service/service";
15-
import { TeamsContext, getCurrentTeam } from "../teams/teams-context";
15+
import { useTeams, useCurrentTeam } from "../teams/teams-context";
1616
import { shortCommitMessage } from "./render-utils";
1717
import { listAllProjects } from "../service/public-api";
1818
import { UserContext } from "../user-context";
1919

2020
export default function () {
2121
const history = useHistory();
22-
const location = useLocation();
2322

24-
const { teams } = useContext(TeamsContext);
23+
const teams = useTeams();
2524
const { user } = useContext(UserContext);
26-
const team = getCurrentTeam(location, teams);
25+
const team = useCurrentTeam();
2726

2827
const match = useRouteMatch<{ team: string; project: string; prebuildId: string }>(
2928
"/(t/)?:team/:project/:prebuildId",

components/dashboard/src/projects/Prebuilds.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import dayjs from "dayjs";
88
import { PrebuildWithStatus, PrebuiltWorkspaceState, Project } from "@gitpod/gitpod-protocol";
99
import { useContext, useEffect, useState } from "react";
10-
import { useLocation, useRouteMatch } from "react-router";
10+
import { useRouteMatch } from "react-router";
1111
import Header from "../components/Header";
1212
import DropDown, { DropDownEntry } from "../components/DropDown";
1313
import { ItemsList, Item, ItemField } from "../components/ItemsList";
@@ -18,19 +18,17 @@ import StatusCanceled from "../icons/StatusCanceled.svg";
1818
import StatusPaused from "../icons/StatusPaused.svg";
1919
import StatusRunning from "../icons/StatusRunning.svg";
2020
import { getGitpodService } from "../service/service";
21-
import { TeamsContext, getCurrentTeam } from "../teams/teams-context";
21+
import { useTeams, useCurrentTeam } from "../teams/teams-context";
2222
import { shortCommitMessage } from "./render-utils";
2323
import { Link } from "react-router-dom";
2424
import { Disposable } from "vscode-jsonrpc";
2525
import { UserContext } from "../user-context";
2626
import { listAllProjects } from "../service/public-api";
2727

2828
export default function (props: { project?: Project; isAdminDashboard?: boolean }) {
29-
const location = useLocation();
30-
31-
const { teams } = useContext(TeamsContext);
29+
const teams = useTeams();
3230
const { user } = useContext(UserContext);
33-
const team = getCurrentTeam(location, teams);
31+
const team = useCurrentTeam();
3432

3533
const match = useRouteMatch<{ team: string; resource: string }>("/(t/)?:team/:resource");
3634
const projectSlug = props.isAdminDashboard ? props.project?.slug : match?.params?.resource;

components/dashboard/src/projects/Project.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
import dayjs from "dayjs";
88
import { PrebuildWithStatus, Project } from "@gitpod/gitpod-protocol";
99
import { useContext, useEffect, useState } from "react";
10-
import { useHistory, useLocation, useRouteMatch } from "react-router";
10+
import { useHistory, useRouteMatch } from "react-router";
1111
import Header from "../components/Header";
1212
import { ItemsList, Item, ItemField, ItemFieldContextMenu } from "../components/ItemsList";
1313
import { getGitpodService, gitpodHostUrl } from "../service/service";
14-
import { TeamsContext, getCurrentTeam } from "../teams/teams-context";
14+
import { useTeams, useCurrentTeam } from "../teams/teams-context";
1515
import { prebuildStatusIcon, prebuildStatusLabel } from "./Prebuilds";
1616
import { shortCommitMessage, toRemoteURL } from "./render-utils";
1717
import { ReactComponent as Spinner } from "../icons/Spinner.svg";
@@ -24,12 +24,11 @@ import { UserContext } from "../user-context";
2424
import { StartWorkspaceModalContext } from "../workspaces/start-workspace-modal-context";
2525

2626
export default function () {
27-
const location = useLocation();
2827
const history = useHistory();
2928

30-
const { teams } = useContext(TeamsContext);
29+
const teams = useTeams();
3130
const { user } = useContext(UserContext);
32-
const team = getCurrentTeam(location, teams);
31+
const team = useCurrentTeam();
3332
const { setStartWorkspaceModalProps } = useContext(StartWorkspaceModalContext);
3433

3534
const match = useRouteMatch<{ team: string; resource: string }>("/(t/)?:team/:resource");

0 commit comments

Comments
 (0)