@@ -13,7 +13,7 @@ import { countries } from "countries-list";
13
13
import gitpodIcon from "./icons/gitpod.svg" ;
14
14
import { getGitpodService , gitpodHostUrl } from "./service/service" ;
15
15
import { UserContext } from "./user-context" ;
16
- import { TeamsContext , getCurrentTeam , getSelectedTeamSlug } from "./teams/teams-context" ;
16
+ import { useCurrentTeam , useTeams } from "./teams/teams-context" ;
17
17
import { getAdminMenu } from "./admin/admin-menu" ;
18
18
import ContextMenu , { ContextMenuEntry } from "./components/ContextMenu" ;
19
19
import Separator from "./components/Separator" ;
@@ -39,9 +39,9 @@ interface Entry {
39
39
export default function Menu ( ) {
40
40
const { user } = useContext ( UserContext ) ;
41
41
const { showUsageView, oidcServiceEnabled } = useContext ( FeatureFlagContext ) ;
42
- const { teams } = useContext ( TeamsContext ) ;
42
+ const teams = useTeams ( ) ;
43
43
const location = useLocation ( ) ;
44
- const team = getCurrentTeam ( location , teams ) ;
44
+ const team = useCurrentTeam ( ) ;
45
45
const { setCurrency, setIsStudent, setIsChargebeeCustomer } = useContext ( PaymentContext ) ;
46
46
const [ teamBillingMode , setTeamBillingMode ] = useState < BillingMode | undefined > ( undefined ) ;
47
47
const [ userBillingMode , setUserBillingMode ] = useState < BillingMode | undefined > ( undefined ) ;
@@ -57,17 +57,12 @@ export default function Menu() {
57
57
getGitpodService ( ) . server . getBillingModeForUser ( ) . then ( setUserBillingMode ) ;
58
58
} , [ ] ) ;
59
59
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
65
60
const projectsRouteMatch = useRouteMatch < { segment1 ?: string ; segment2 ?: string } > (
66
61
"/projects/:segment1?/:segment2?" ,
67
62
) ;
68
63
69
64
const projectSlug = ( ( ) => {
70
- const resource = teamRouteMatch ?. params ?. segment2 || projectsRouteMatch ?. params . segment1 ;
65
+ const resource = projectsRouteMatch ?. params . segment1 ;
71
66
if (
72
67
resource &&
73
68
! [
@@ -89,7 +84,7 @@ export default function Menu() {
89
84
}
90
85
} ) ( ) ;
91
86
const prebuildId = ( ( ) => {
92
- const resource = projectSlug && ( teamRouteMatch ?. params ?. segment3 || projectsRouteMatch ?. params . segment2 ) ;
87
+ const resource = projectSlug && projectsRouteMatch ?. params . segment2 ;
93
88
if (
94
89
resource &&
95
90
! [
@@ -110,7 +105,7 @@ export default function Menu() {
110
105
}
111
106
112
107
// 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" ] ) ;
114
109
const isWorkspacesUI = inResource ( location . pathname , [ "workspaces" ] ) ;
115
110
const isPersonalSettingsUI = inResource ( location . pathname , [
116
111
"account" ,
@@ -191,22 +186,21 @@ export default function Menu() {
191
186
}
192
187
} , [ team ] ) ;
193
188
194
- const teamOrUserSlug = ! ! team ? "/t/" + team . slug : "/projects" ;
195
189
const secondLevelMenu : Entry [ ] = ( ( ) => {
196
190
// Project menu
197
191
if ( projectSlug ) {
198
192
return [
199
193
{
200
194
title : "Branches" ,
201
- link : `${ teamOrUserSlug } /${ projectSlug } ` ,
195
+ link : `/projects /${ projectSlug } ` ,
202
196
} ,
203
197
{
204
198
title : "Prebuilds" ,
205
- link : `${ teamOrUserSlug } /${ projectSlug } /prebuilds` ,
199
+ link : `/projects /${ projectSlug } /prebuilds` ,
206
200
} ,
207
201
{
208
202
title : "Settings" ,
209
- link : `${ teamOrUserSlug } /${ projectSlug } /settings` ,
203
+ link : `/projects /${ projectSlug } /settings` ,
210
204
alternatives : getProjectSettingsMenu ( { slug : projectSlug } as Project , team ) . flatMap ( ( e ) => e . link ) ,
211
205
} ,
212
206
] ;
@@ -220,12 +214,12 @@ export default function Menu() {
220
214
const teamSettingsList = [
221
215
{
222
216
title : "Projects" ,
223
- link : `/t/ ${ team . slug } / projects` ,
217
+ link : `/projects` ,
224
218
alternatives : [ ] as string [ ] ,
225
219
} ,
226
220
{
227
221
title : "Members" ,
228
- link : `/t/ ${ team . slug } / members` ,
222
+ link : `/members` ,
229
223
} ,
230
224
] ;
231
225
if (
@@ -234,13 +228,13 @@ export default function Menu() {
234
228
) {
235
229
teamSettingsList . push ( {
236
230
title : "Usage" ,
237
- link : `/t/ ${ team . slug } / usage` ,
231
+ link : `/usage` ,
238
232
} ) ;
239
233
}
240
234
if ( currentUserInTeam ?. role === "owner" ) {
241
235
teamSettingsList . push ( {
242
236
title : "Settings" ,
243
- link : `/t/ ${ team . slug } / settings` ,
237
+ link : `/org- settings` ,
244
238
alternatives : getTeamSettingsMenu ( {
245
239
team,
246
240
billingMode : teamBillingMode ,
@@ -277,7 +271,7 @@ export default function Menu() {
277
271
const onFeedbackFormClose = ( ) => {
278
272
setFeedbackFormVisible ( false ) ;
279
273
} ;
280
- const isTeamLevelActive = ! projectSlug && ! isWorkspacesUI && ! isPersonalSettingsUI && ! isAdminUI && teamOrUserSlug ;
274
+ const isTeamLevelActive = ! projectSlug && ! isWorkspacesUI && ! isPersonalSettingsUI && ! isAdminUI ;
281
275
const renderTeamMenu = ( ) => {
282
276
if ( ! hasIndividualProjects && ( ! teams || teams . length === 0 ) ) {
283
277
return (
@@ -291,7 +285,7 @@ export default function Menu() {
291
285
) ;
292
286
}
293
287
const userFullName = user ?. fullName || user ?. name || "..." ;
294
- const entries : ( ContextMenuEntry & { slug : string } ) [ ] = [
288
+ const entries : ContextMenuEntry [ ] = [
295
289
...( hasIndividualProjects
296
290
? [
297
291
{
@@ -304,16 +298,14 @@ export default function Menu() {
304
298
< span className = "" > Personal Account</ span >
305
299
</ div >
306
300
) ,
307
- active : getSelectedTeamSlug ( ) === "" ,
301
+ active : team === undefined ,
308
302
separator : true ,
309
- slug : "" ,
310
- link : "/projects" ,
303
+ link : `${ location . pathname } ?activateOrg=0` ,
311
304
} ,
312
305
]
313
306
: [ ] ) ,
314
307
...( teams || [ ] )
315
308
. map ( ( t ) => ( {
316
- slug : t . slug ,
317
309
title : t . name ,
318
310
customContent : (
319
311
< div className = "w-full text-gray-400 flex flex-col" >
@@ -325,13 +317,12 @@ export default function Menu() {
325
317
</ span >
326
318
</ div >
327
319
) ,
328
- active : getSelectedTeamSlug ( ) === t . slug ,
320
+ active : team ?. id === t . id ,
329
321
separator : true ,
330
- link : `/t/ ${ t . slug } ` ,
322
+ link : `${ location . pathname } ?activateOrg= ${ t . id } ` ,
331
323
} ) )
332
324
. sort ( ( a , b ) => ( a . title . toLowerCase ( ) > b . title . toLowerCase ( ) ? 1 : - 1 ) ) ,
333
325
{
334
- slug : "new" ,
335
326
title : "Create a new organization" ,
336
327
customContent : (
337
328
< div className = "w-full text-gray-400 flex items-center" >
@@ -354,7 +345,7 @@ export default function Menu() {
354
345
( isTeamLevelActive
355
346
? "text-gray-50 bg-gray-800 dark:bg-gray-50 dark:text-gray-900 border-gray-700 dark:border-gray-200"
356
347
: "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 ] ;
358
349
return (
359
350
< div className = "flex p-1" >
360
351
< Link to = { selectedEntry . link ! } >
@@ -378,14 +369,14 @@ export default function Menu() {
378
369
</ ContextMenu >
379
370
</ div >
380
371
{ projectSlug && ! prebuildId && ! isAdminUI && (
381
- < Link to = { `${ teamOrUserSlug } /${ projectSlug } ${ prebuildId ? "/prebuilds" : "" } ` } >
372
+ < Link to = { `/projects /${ projectSlug } ${ prebuildId ? "/prebuilds" : "" } ` } >
382
373
< 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" >
383
374
{ project ?. name }
384
375
</ span >
385
376
</ Link >
386
377
) }
387
378
{ prebuildId && (
388
- < Link to = { `${ teamOrUserSlug } /${ projectSlug } ${ prebuildId ? "/prebuilds" : "" } ` } >
379
+ < Link to = { `/projects /${ projectSlug } ${ prebuildId ? "/prebuilds" : "" } ` } >
389
380
< 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" >
390
381
{ project ?. name }
391
382
</ span >
@@ -403,7 +394,7 @@ export default function Menu() {
403
394
/>
404
395
</ svg >
405
396
</ div >
406
- < Link to = { `${ teamOrUserSlug } /${ projectSlug } /${ prebuildId } ` } >
397
+ < Link to = { `/projects /${ projectSlug } /${ prebuildId } ` } >
407
398
< 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" >
408
399
{ prebuildId . substring ( 0 , 8 ) . trimEnd ( ) }
409
400
</ span >
0 commit comments