Skip to content

Commit c97ba94

Browse files
committed
remove org slug
1 parent 6600689 commit c97ba94

30 files changed

+212
-642
lines changed

components/dashboard/src/AppNotifications.tsx

+1-1
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

+25-35
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",
@@ -164,8 +159,7 @@ export default function Menu() {
164159
}
165160

166161
// Find project matching with slug, otherwise with name
167-
const project =
168-
projectSlug && projects.find((p) => (p.slug ? p.slug === projectSlug : p.name === projectSlug));
162+
const project = projectSlug && projects.find((p) => Project.slug(p) === projectSlug);
169163
if (!project) {
170164
return;
171165
}
@@ -191,22 +185,21 @@ export default function Menu() {
191185
}
192186
}, [team]);
193187

194-
const teamOrUserSlug = !!team ? "/t/" + team.slug : "/projects";
195188
const secondLevelMenu: Entry[] = (() => {
196189
// Project menu
197190
if (projectSlug) {
198191
return [
199192
{
200193
title: "Branches",
201-
link: `${teamOrUserSlug}/${projectSlug}`,
194+
link: `/projects/${projectSlug}`,
202195
},
203196
{
204197
title: "Prebuilds",
205-
link: `${teamOrUserSlug}/${projectSlug}/prebuilds`,
198+
link: `/projects/${projectSlug}/prebuilds`,
206199
},
207200
{
208201
title: "Settings",
209-
link: `${teamOrUserSlug}/${projectSlug}/settings`,
202+
link: `/projects/${projectSlug}/settings`,
210203
alternatives: getProjectSettingsMenu({ slug: projectSlug } as Project, team).flatMap((e) => e.link),
211204
},
212205
];
@@ -220,12 +213,12 @@ export default function Menu() {
220213
const teamSettingsList = [
221214
{
222215
title: "Projects",
223-
link: `/t/${team.slug}/projects`,
216+
link: `/projects`,
224217
alternatives: [] as string[],
225218
},
226219
{
227220
title: "Members",
228-
link: `/t/${team.slug}/members`,
221+
link: `/members`,
229222
},
230223
];
231224
if (
@@ -234,13 +227,13 @@ export default function Menu() {
234227
) {
235228
teamSettingsList.push({
236229
title: "Usage",
237-
link: `/t/${team.slug}/usage`,
230+
link: `/org-usage`,
238231
});
239232
}
240233
if (currentUserInTeam?.role === "owner") {
241234
teamSettingsList.push({
242235
title: "Settings",
243-
link: `/t/${team.slug}/settings`,
236+
link: `/org-settings`,
244237
alternatives: getTeamSettingsMenu({
245238
team,
246239
billingMode: teamBillingMode,
@@ -277,7 +270,7 @@ export default function Menu() {
277270
const onFeedbackFormClose = () => {
278271
setFeedbackFormVisible(false);
279272
};
280-
const isTeamLevelActive = !projectSlug && !isWorkspacesUI && !isPersonalSettingsUI && !isAdminUI && teamOrUserSlug;
273+
const isTeamLevelActive = !projectSlug && !isWorkspacesUI && !isPersonalSettingsUI && !isAdminUI;
281274
const renderTeamMenu = () => {
282275
if (!hasIndividualProjects && (!teams || teams.length === 0)) {
283276
return (
@@ -291,8 +284,8 @@ export default function Menu() {
291284
);
292285
}
293286
const userFullName = user?.fullName || user?.name || "...";
294-
const entries: (ContextMenuEntry & { slug: string })[] = [
295-
...(hasIndividualProjects
287+
const entries: ContextMenuEntry[] = [
288+
...(!user?.additionalData?.isMigratedToTeamOnlyAttribution
296289
? [
297290
{
298291
title: userFullName,
@@ -304,16 +297,14 @@ export default function Menu() {
304297
<span className="">Personal Account</span>
305298
</div>
306299
),
307-
active: getSelectedTeamSlug() === "",
300+
active: team === undefined,
308301
separator: true,
309-
slug: "",
310-
link: "/projects",
302+
link: `${location.pathname}?org=0`,
311303
},
312304
]
313305
: []),
314306
...(teams || [])
315307
.map((t) => ({
316-
slug: t.slug,
317308
title: t.name,
318309
customContent: (
319310
<div className="w-full text-gray-400 flex flex-col">
@@ -325,13 +316,12 @@ export default function Menu() {
325316
</span>
326317
</div>
327318
),
328-
active: getSelectedTeamSlug() === t.slug,
319+
active: team?.id === t.id,
329320
separator: true,
330-
link: `/t/${t.slug}`,
321+
link: `/projects/?org=${t.id}`,
331322
}))
332323
.sort((a, b) => (a.title.toLowerCase() > b.title.toLowerCase() ? 1 : -1)),
333324
{
334-
slug: "new",
335325
title: "Create a new organization",
336326
customContent: (
337327
<div className="w-full text-gray-400 flex items-center">
@@ -354,7 +344,7 @@ export default function Menu() {
354344
(isTeamLevelActive
355345
? "text-gray-50 bg-gray-800 dark:bg-gray-50 dark:text-gray-900 border-gray-700 dark:border-gray-200"
356346
: "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];
347+
const selectedEntry = entries.find((e) => e.active) || entries[0];
358348
return (
359349
<div className="flex p-1">
360350
<Link to={selectedEntry.link!}>
@@ -378,14 +368,14 @@ export default function Menu() {
378368
</ContextMenu>
379369
</div>
380370
{projectSlug && !prebuildId && !isAdminUI && (
381-
<Link to={`${teamOrUserSlug}/${projectSlug}${prebuildId ? "/prebuilds" : ""}`}>
371+
<Link to={`/projects/${projectSlug}${prebuildId ? "/prebuilds" : ""}`}>
382372
<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">
383373
{project?.name}
384374
</span>
385375
</Link>
386376
)}
387377
{prebuildId && (
388-
<Link to={`${teamOrUserSlug}/${projectSlug}${prebuildId ? "/prebuilds" : ""}`}>
378+
<Link to={`/projects/${projectSlug}${prebuildId ? "/prebuilds" : ""}`}>
389379
<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">
390380
{project?.name}
391381
</span>
@@ -403,7 +393,7 @@ export default function Menu() {
403393
/>
404394
</svg>
405395
</div>
406-
<Link to={`${teamOrUserSlug}/${projectSlug}/${prebuildId}`}>
396+
<Link to={`/projects/${projectSlug}/${prebuildId}`}>
407397
<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">
408398
{prebuildId.substring(0, 8).trimEnd()}
409399
</span>

components/dashboard/src/admin/TeamDetail.tsx

+1-1
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

+22-84
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,14 @@ import {
2424
settingsPathNotifications,
2525
settingsPathPlans,
2626
settingsPathPreferences,
27-
settingsPathTeams,
28-
settingsPathTeamsJoin,
29-
settingsPathOrgs,
30-
settingsPathOrgsJoin,
31-
settingsPathOrgsNew,
3227
settingsPathVariables,
3328
settingsPathSSHKeys,
3429
usagePathMain,
3530
settingsPathPersonalAccessTokens,
3631
settingsPathPersonalAccessTokenCreate,
3732
settingsPathPersonalAccessTokenEdit,
3833
} from "../settings/settings.routes";
39-
import {
40-
projectsPathInstallGitHubApp,
41-
projectsPathMain,
42-
projectsPathMainWithParams,
43-
projectsPathNew,
44-
} from "../projects/projects.routes";
34+
import { projectsPathInstallGitHubApp, projectsPathNew } from "../projects/projects.routes";
4535
import { workspacesPathMain } from "../workspaces/workspaces.routes";
4636
import { LocalPreviewAlert } from "./LocalPreviewAlert";
4737
import OAuthClientApproval from "../OauthClientApproval";
@@ -60,7 +50,7 @@ const Account = React.lazy(() => import(/* webpackPrefetch: true */ "../settings
6050
const Notifications = React.lazy(() => import(/* webpackPrefetch: true */ "../settings/Notifications"));
6151
const Billing = React.lazy(() => import(/* webpackPrefetch: true */ "../settings/Billing"));
6252
const Plans = React.lazy(() => import(/* webpackPrefetch: true */ "../settings/Plans"));
63-
const Teams = React.lazy(() => import(/* webpackPrefetch: true */ "../settings/Teams"));
53+
const ChargebeeTeams = React.lazy(() => import(/* webpackPrefetch: true */ "../settings/ChargebeeTeams"));
6454
const EnvironmentVariables = React.lazy(() => import(/* webpackPrefetch: true */ "../settings/EnvironmentVariables"));
6555
const SSHKeys = React.lazy(() => import(/* webpackPrefetch: true */ "../settings/SSHKeys"));
6656
const Integrations = React.lazy(() => import(/* webpackPrefetch: true */ "../settings/Integrations"));
@@ -228,79 +218,27 @@ export const AppRoutes: FunctionComponent<AppRoutesProps> = ({ user, teams }) =>
228218
<p className="mt-4 text-lg text-gitpod-red">{decodeURIComponent(getURLHash())}</p>
229219
</div>
230220
</Route>
231-
<Route path={projectsPathMain}>
232-
<Route exact path={projectsPathMain} component={Projects} />
233-
<Route
234-
exact
235-
path={projectsPathMainWithParams}
236-
render={({ match }) => {
237-
const { resourceOrPrebuild } = match.params;
238-
switch (resourceOrPrebuild) {
239-
case "events":
240-
return <Events />;
241-
case "prebuilds":
242-
return <Prebuilds />;
243-
case "settings":
244-
return <ProjectSettings />;
245-
case "variables":
246-
return <ProjectVariables />;
247-
default:
248-
return resourceOrPrebuild ? <Prebuild /> : <Project />;
249-
}
250-
}}
251-
/>
252-
</Route>
253-
{/* TODO remove these navigation after a few weeks */}
254-
<Route path={settingsPathTeams}>
255-
<Route exact path={settingsPathTeamsJoin} component={JoinTeam} />
256-
</Route>
257-
<Route path={settingsPathOrgs}>
258-
<Route exact path={settingsPathOrgs} component={Teams} />
259-
<Route exact path={settingsPathOrgsNew} component={NewTeam} />
260-
<Route exact path={settingsPathOrgsJoin} component={JoinTeam} />
221+
<Route exact path="/old-team-plans" component={ChargebeeTeams} />
222+
{/* TODO remove the /teams/join navigation after a few weeks */}
223+
<Route exact path="/teams/join" component={JoinTeam} />
224+
<Route exact path="/orgs/new" component={NewTeam} />
225+
<Route exact path="/orgs/join" component={JoinTeam} />
226+
<Route exact path="/members" component={Members} />
227+
<Route exact path="/projects" component={Projects} />
228+
<Route exact path="/org-settings" component={TeamSettings} />
229+
<Route exact path="/org-billing" component={TeamBilling} />
230+
<Route exact path="/org-usage" component={TeamUsage} />
231+
<Route exact path="/sso" component={SSO} />
232+
<Route exact path={`/projects/:projectSlug`} component={Project} />
233+
<Route exact path={`/projects/:projectSlug/events`} component={Events} />
234+
<Route exact path={`/projects/:projectSlug/prebuilds`} component={Prebuilds} />
235+
<Route exact path={`/projects/:projectSlug/settings`} component={ProjectSettings} />
236+
<Route exact path={`/projects/:projectSlug/variables`} component={ProjectVariables} />
237+
<Route exact path={`/projects/:projectSlug/:prebuildId`} component={Prebuild} />
238+
{/* basic redirect for old team slugs */}
239+
<Route path={["/t/"]} exact>
240+
<Redirect to="/projects" />
261241
</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-
))}
304242
<Route
305243
path="*"
306244
render={(_match) => {

0 commit comments

Comments
 (0)