1
- import {
2
- ComponentProps ,
3
- ReactElement ,
4
- useCallback ,
5
- useContext ,
6
- useRef ,
7
- useState ,
8
- } from 'react'
9
- import { Link , useLocation } from 'react-router-dom'
10
- import { Avatar , Menu , MenuItem } from 'honorable'
11
1
import {
12
2
ArrowTopRightIcon ,
13
- BrowseAppsIcon ,
14
3
ClusterIcon ,
15
4
CookieIcon ,
5
+ CreditCardIcon ,
16
6
Sidebar as DSSidebar ,
17
7
DiscordIcon ,
18
8
GitHubLogoIcon ,
@@ -26,15 +16,25 @@ import {
26
16
SidebarSection ,
27
17
TerminalIcon ,
28
18
} from '@pluralsh/design-system'
29
- import styled , { useTheme } from 'styled-components'
30
19
import { useClickOutside } from '@react-hooks-library/core'
20
+ import { Avatar , Menu , MenuItem } from 'honorable'
21
+ import {
22
+ ComponentProps ,
23
+ ReactElement ,
24
+ useCallback ,
25
+ useContext ,
26
+ useRef ,
27
+ useState ,
28
+ } from 'react'
29
+ import { Link , useLocation } from 'react-router-dom'
30
+ import styled , { useTheme } from 'styled-components'
31
31
32
+ import CurrentUserContext from '../../contexts/CurrentUserContext'
32
33
import { getPreviousUserData } from '../../helpers/authentication'
34
+ import { clearLocalStorage } from '../../helpers/localStorage'
33
35
import { handlePreviousUserClick } from '../login/CurrentUser'
34
- import CurrentUserContext from '../../contexts/CurrentUserContext'
35
- import { useIsCurrentlyOnboarding } from '../shell/hooks/useOnboarded'
36
36
import CreatePublisherModal from '../publisher/CreatePublisherModal'
37
- import { clearLocalStorage } from '../../helpers/localStorage '
37
+ import { useIsCurrentlyOnboarding } from '../shell/hooks/useOnboarded '
38
38
39
39
import Cookiebot from '../../utils/cookiebot'
40
40
@@ -58,12 +58,6 @@ const MENU_ITEMS: MenuItem[] = [
58
58
path : '/shell' ,
59
59
pathRegexp : / ^ \/ ( s h e l l | o a u t h \/ c a l l b a c k \/ .+ \/ s h e l l ) / ,
60
60
} ,
61
- {
62
- text : 'Marketplace' ,
63
- icon : < BrowseAppsIcon /> ,
64
- path : '/marketplace' ,
65
- pathRegexp : / ^ \/ ( m a r k e t p l a c e | i n s t a l l e d | r e p o s i t o r y | s t a c k ) / ,
66
- } ,
67
61
{
68
62
text : 'Audits' ,
69
63
icon : < ListIcon /> ,
@@ -73,6 +67,13 @@ const MENU_ITEMS: MenuItem[] = [
73
67
text : 'Account' ,
74
68
icon : < PeopleIcon /> ,
75
69
path : '/account' ,
70
+ pathRegexp : / ^ \/ a c c o u n t ( \/ (? ! b i l l i n g ) [ ^ / ] * ) ? $ / ,
71
+ } ,
72
+ {
73
+ text : 'Billing' ,
74
+ icon : < CreditCardIcon /> ,
75
+ path : '/account/billing' ,
76
+ pathRegexp : / ^ \/ a c c o u n t \/ b i l l i n g ( \/ .* ) ? $ / ,
76
77
} ,
77
78
// {
78
79
// text: 'Roadmap',
@@ -85,10 +86,8 @@ function isActiveMenuItem(
85
86
{ path, pathRegexp } : Pick < MenuItem , 'path' | 'pathRegexp' > ,
86
87
currentPath
87
88
) {
88
- return (
89
- ( path === '/' ? currentPath === path : currentPath . startsWith ( path ) ) ||
90
- ( pathRegexp && ( currentPath . match ( pathRegexp ) ?. length ?? 0 > 0 ) )
91
- )
89
+ if ( pathRegexp ) return currentPath . match ( pathRegexp ) !== null
90
+ return path === '/' ? currentPath === path : currentPath . startsWith ( path )
92
91
}
93
92
94
93
function SidebarWrapper ( ) {
0 commit comments