Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
65c5eec6
Commit
65c5eec6
authored
Oct 24, 2024
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disable menu item
parent
f292564c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
5 deletions
+9
-5
useNavItems.tsx
lib/hooks/useNavItems.tsx
+4
-2
navigation.ts
types/client/navigation.ts
+1
-0
NavLink.tsx
ui/snippets/navigation/vertical/NavLink.tsx
+4
-3
No files found.
lib/hooks/useNavItems.tsx
View file @
65c5eec6
...
@@ -28,6 +28,7 @@ export default function useNavItems(): ReturnType {
...
@@ -28,6 +28,7 @@ export default function useNavItems(): ReturnType {
balancesQuery
:
rewardsBalancesQuery
,
balancesQuery
:
rewardsBalancesQuery
,
dailyRewardQuery
,
dailyRewardQuery
,
apiToken
:
rewardsApiToken
,
apiToken
:
rewardsApiToken
,
isInitialized
:
isRewardsInitialized
,
}
=
useRewardsContext
();
}
=
useRewardsContext
();
return
React
.
useMemo
(()
=>
{
return
React
.
useMemo
(()
=>
{
...
@@ -273,9 +274,10 @@ export default function useNavItems(): ReturnType {
...
@@ -273,9 +274,10 @@ export default function useNavItems(): ReturnType {
config
.
features
.
rewards
.
isEnabled
?
{
config
.
features
.
rewards
.
isEnabled
?
{
text
:
rewardsBalancesQuery
.
data
?.
total
?
`
${
rewardsBalancesQuery
.
data
?.
total
}
Merits
` : 'Merits',
text
:
rewardsBalancesQuery
.
data
?.
total
?
`
${
rewardsBalancesQuery
.
data
?.
total
}
Merits
` : 'Merits',
nextRoute: { pathname: '/account/rewards' as const },
nextRoute: { pathname: '/account/rewards' as const },
onClick:
rewardsApiToken ? undefined : openRewardsLoginModal
,
onClick:
(isRewardsInitialized && !rewardsApiToken) ? openRewardsLoginModal : undefined
,
icon: dailyRewardQuery.data?.available ? 'merits_with_dot' : 'merits',
icon: dailyRewardQuery.data?.available ? 'merits_with_dot' : 'merits',
isActive: pathname === '/account/rewards',
isActive: pathname === '/account/rewards',
isDisabled: !isRewardsInitialized,
} : null,
} : null,
{
{
text: 'Watch list',
text: 'Watch list',
...
@@ -310,5 +312,5 @@ export default function useNavItems(): ReturnType {
...
@@ -310,5 +312,5 @@ export default function useNavItems(): ReturnType {
].filter(Boolean);
].filter(Boolean);
return { mainNavItems, accountNavItems };
return { mainNavItems, accountNavItems };
}, [ pathname, openRewardsLoginModal, rewardsBalancesQuery, dailyRewardQuery, rewardsApiToken ]);
}, [ pathname, openRewardsLoginModal, rewardsBalancesQuery, dailyRewardQuery, rewardsApiToken
, isRewardsInitialized
]);
}
}
types/client/navigation.ts
View file @
65c5eec6
...
@@ -18,6 +18,7 @@ export type NavItemInternal = NavItemCommon & {
...
@@ -18,6 +18,7 @@ export type NavItemInternal = NavItemCommon & {
nextRoute
:
Route
;
nextRoute
:
Route
;
isActive
?:
boolean
;
isActive
?:
boolean
;
onClick
?:
()
=>
void
;
onClick
?:
()
=>
void
;
isDisabled
?:
boolean
;
}
}
export
type
NavItemExternal
=
{
export
type
NavItemExternal
=
{
...
...
ui/snippets/navigation/vertical/NavLink.tsx
View file @
65c5eec6
...
@@ -42,10 +42,11 @@ const NavLink = ({ item, isCollapsed, px, className, onClick, disableActiveState
...
@@ -42,10 +42,11 @@ const NavLink = ({ item, isCollapsed, px, className, onClick, disableActiveState
}
}
const
isHighlighted
=
checkRouteHighlight
(
item
);
const
isHighlighted
=
checkRouteHighlight
(
item
);
const
isDisabled
=
isInternalLink
&&
item
.
isDisabled
;
const
content
=
(
const
content
=
(
<
Link
<
Link
href=
{
href
}
href=
{
isDisabled
?
undefined
:
href
}
target=
{
isInternalLink
?
'
_self
'
:
'
_blank
'
}
target=
{
isInternalLink
?
'
_self
'
:
'
_blank
'
}
{
...
styleProps
.
itemProps
}
{
...
styleProps
.
itemProps
}
w=
{
{
base
:
'
100%
'
,
lg
:
isExpanded
?
'
100%
'
:
'
60px
'
,
xl
:
isCollapsed
?
'
60px
'
:
'
100%
'
}
}
w=
{
{
base
:
'
100%
'
,
lg
:
isExpanded
?
'
100%
'
:
'
60px
'
,
xl
:
isCollapsed
?
'
60px
'
:
'
100%
'
}
}
...
@@ -58,7 +59,7 @@ const NavLink = ({ item, isCollapsed, px, className, onClick, disableActiveState
...
@@ -58,7 +59,7 @@ const NavLink = ({ item, isCollapsed, px, className, onClick, disableActiveState
onClick=
{
isInternalLink
&&
item
.
onClick
?
item
.
onClick
:
onClick
}
onClick=
{
isInternalLink
&&
item
.
onClick
?
item
.
onClick
:
onClick
}
_hover=
{
{
_hover=
{
{
[
`& *:not(.${ LIGHTNING_LABEL_CLASS_NAME }, .${ LIGHTNING_LABEL_CLASS_NAME } *)`
]:
{
[
`& *:not(.${ LIGHTNING_LABEL_CLASS_NAME }, .${ LIGHTNING_LABEL_CLASS_NAME } *)`
]:
{
color
:
'
link_hovered
'
,
color
:
isDisabled
?
'
inherit
'
:
'
link_hovered
'
,
},
},
}
}
}
}
>
>
...
@@ -88,7 +89,7 @@ const NavLink = ({ item, isCollapsed, px, className, onClick, disableActiveState
...
@@ -88,7 +89,7 @@ const NavLink = ({ item, isCollapsed, px, className, onClick, disableActiveState
return
(
return
(
<
Box
as=
"li"
listStyleType=
"none"
w=
"100%"
className=
{
className
}
>
<
Box
as=
"li"
listStyleType=
"none"
w=
"100%"
className=
{
className
}
>
{
isInternalLink
&&
!
item
.
onClick
?
(
{
isInternalLink
&&
!
item
.
onClick
&&
!
isDisabled
?
(
<
NextLink
href=
{
item
.
nextRoute
}
passHref
legacyBehavior
>
<
NextLink
href=
{
item
.
nextRoute
}
passHref
legacyBehavior
>
{
content
}
{
content
}
</
NextLink
>
</
NextLink
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment