Skip to content

Commit 6dc433f

Browse files
committed
remove org slug
1 parent 6600689 commit 6dc433f

24 files changed

+192
-402
lines changed

components/dashboard/src/AppNotifications.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function AppNotifications() {
5151
if (notifications.length === 1) {
5252
href = `${gitpodHostUrl}billing`;
5353
} else if (notifications.length === 2) {
54-
href = `${gitpodHostUrl}t/${notifications[notifications.length - 1]}/billing`;
54+
href = `${gitpodHostUrl}/org-billing`;
5555
}
5656
return (
5757
<span>

components/dashboard/src/Menu.tsx

Lines changed: 24 additions & 33 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: `/org-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,8 +285,8 @@ export default function Menu() {
291285
);
292286
}
293287
const userFullName = user?.fullName || user?.name || "...";
294-
const entries: (ContextMenuEntry & { slug: string })[] = [
295-
...(hasIndividualProjects
288+
const entries: ContextMenuEntry[] = [
289+
...(!user?.additionalData?.isMigratedToTeamOnlyAttribution
296290
? [
297291
{
298292
title: userFullName,
@@ -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}?org=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: `/projects/?org=${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/admin/TeamDetail.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default function TeamDetail(props: { team: Team }) {
7979
</span>
8080
)}
8181
</div>
82-
<span className="mb-6 text-gray-400">/t/{team.slug}</span>
82+
<span className="mb-6 text-gray-400">{team.id}</span>
8383
<span className="text-gray-400"> · </span>
8484
<span className="text-gray-400">Created on {dayjs(team.creationTime).format("MMM D, YYYY")}</span>
8585
</div>

components/dashboard/src/app/AppRoutes.tsx

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -259,48 +259,47 @@ export const AppRoutes: FunctionComponent<AppRoutesProps> = ({ user, teams }) =>
259259
<Route exact path={settingsPathOrgsNew} component={NewTeam} />
260260
<Route exact path={settingsPathOrgsJoin} component={JoinTeam} />
261261
</Route>
262-
{(teams || []).map((team) => (
263-
<Route path={`/t/${team.slug}`} key={team.slug}>
264-
<Route exact path={`/t/${team.slug}`}>
265-
<Redirect to={`/t/${team.slug}/projects`} />
266-
</Route>
267-
<Route
268-
exact
269-
path={`/t/${team.slug}/:maybeProject/:resourceOrPrebuild?`}
270-
render={({ match }) => {
271-
const { maybeProject, resourceOrPrebuild } = match.params;
272-
switch (maybeProject) {
273-
case "projects":
274-
return <Projects />;
275-
case "members":
276-
return <Members />;
277-
case "settings":
278-
return <TeamSettings />;
279-
case "billing":
280-
return <TeamBilling />;
281-
case "sso":
282-
return <SSO />;
283-
case "usage":
284-
return <TeamUsage />;
285-
default:
286-
break;
287-
}
288-
switch (resourceOrPrebuild) {
289-
case "events":
290-
return <Events />;
291-
case "prebuilds":
292-
return <Prebuilds />;
293-
case "settings":
294-
return <ProjectSettings />;
295-
case "variables":
296-
return <ProjectVariables />;
297-
default:
298-
return resourceOrPrebuild ? <Prebuild /> : <Project />;
299-
}
300-
}}
301-
/>
302-
</Route>
303-
))}
262+
<Route exact path="/members">
263+
<Members />
264+
</Route>
265+
<Route exact path="/projects">
266+
<Projects />
267+
</Route>
268+
<Route exact path="/org-settings">
269+
<TeamSettings />
270+
</Route>
271+
<Route exact path="/org-billing">
272+
<TeamBilling />
273+
</Route>
274+
<Route exact path="/org-usage">
275+
<TeamUsage />
276+
</Route>
277+
<Route exact path="/sso">
278+
<SSO />
279+
</Route>
280+
<Route
281+
exact
282+
path={`/projects/:maybeProject/:resourceOrPrebuild?`}
283+
render={({ match }) => {
284+
const { resourceOrPrebuild } = match.params;
285+
switch (resourceOrPrebuild) {
286+
case "events":
287+
return <Events />;
288+
case "prebuilds":
289+
return <Prebuilds />;
290+
case "settings":
291+
return <ProjectSettings />;
292+
case "variables":
293+
return <ProjectVariables />;
294+
default:
295+
return resourceOrPrebuild ? <Prebuild /> : <Project />;
296+
}
297+
}}
298+
/>
299+
{/* basic redirect for old team slugs */}
300+
<Route path={["/t/"]} exact>
301+
<Redirect to="/projects" />
302+
</Route>
304303
<Route
305304
path="*"
306305
render={(_match) => {

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);

0 commit comments

Comments
 (0)