Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Anything Llm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
Mintplex Labs
Anything Llm
Commits
36c5cd16
Unverified
Commit
36c5cd16
authored
8 months ago
by
Sean Hatfield
Committed by
GitHub
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
[REFACTOR] Refactor window path location for settings sidebar (#1856)
use useLocation hook instead of href for window location
parent
2f620163
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/components/SettingsSidebar/MenuOption/index.jsx
+7
-6
7 additions, 6 deletions
frontend/src/components/SettingsSidebar/MenuOption/index.jsx
with
7 additions
and
6 deletions
frontend/src/components/SettingsSidebar/MenuOption/index.jsx
+
7
−
6
View file @
36c5cd16
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
{
CaretRight
}
from
"
@phosphor-icons/react
"
;
import
{
CaretRight
}
from
"
@phosphor-icons/react
"
;
import
{
Link
}
from
"
react-router-dom
"
;
import
{
Link
,
useLocation
}
from
"
react-router-dom
"
;
export
default
function
MenuOption
({
export
default
function
MenuOption
({
btnText
,
btnText
,
...
@@ -14,14 +14,14 @@ export default function MenuOption({
...
@@ -14,14 +14,14 @@ export default function MenuOption({
isChild
=
false
,
isChild
=
false
,
})
{
})
{
const
storageKey
=
generateStorageKey
({
key
:
btnText
});
const
storageKey
=
generateStorageKey
({
key
:
btnText
});
const
location
=
window
.
location
.
pathname
;
const
location
=
useLocation
()
;
const
hasChildren
=
childOptions
.
length
>
0
;
const
hasChildren
=
childOptions
.
length
>
0
;
const
hasVisibleChildren
=
hasVisibleOptions
(
user
,
childOptions
);
const
hasVisibleChildren
=
hasVisibleOptions
(
user
,
childOptions
);
const
{
isExpanded
,
setIsExpanded
}
=
useIsExpanded
({
const
{
isExpanded
,
setIsExpanded
}
=
useIsExpanded
({
storageKey
,
storageKey
,
hasVisibleChildren
,
hasVisibleChildren
,
childOptions
,
childOptions
,
location
,
location
:
location
.
pathname
,
});
});
if
(
hidden
)
return
null
;
if
(
hidden
)
return
null
;
...
@@ -43,9 +43,10 @@ export default function MenuOption({
...
@@ -43,9 +43,10 @@ export default function MenuOption({
}
}
const
isActive
=
hasChildren
const
isActive
=
hasChildren
?
(
!
isExpanded
&&
childOptions
.
some
((
child
)
=>
child
.
href
===
location
))
||
?
(
!
isExpanded
&&
location
===
href
childOptions
.
some
((
child
)
=>
child
.
href
===
location
.
pathname
))
||
:
location
===
href
;
location
.
pathname
===
href
:
location
.
pathname
===
href
;
const
handleClick
=
(
e
)
=>
{
const
handleClick
=
(
e
)
=>
{
if
(
hasChildren
)
{
if
(
hasChildren
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment