Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
1db26d35
Unverified
Commit
1db26d35
authored
Feb 28, 2020
by
Agnès Toulet
Committed by
GitHub
Feb 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Core: add hideFromMenu for child items (#22494)
parent
72628c8e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
4 deletions
+63
-4
public/app/core/components/sidemenu/SideMenuDropDown.test.tsx
+15
-0
public/app/core/components/sidemenu/SideMenuDropDown.tsx
+9
-4
public/app/core/components/sidemenu/__snapshots__/SideMenuDropDown.test.tsx.snap
+39
-0
No files found.
public/app/core/components/sidemenu/SideMenuDropDown.test.tsx
View file @
1db26d35
...
...
@@ -32,4 +32,19 @@ describe('Render', () => {
expect
(
wrapper
).
toMatchSnapshot
();
});
it
(
'should not render hideFromMenu children'
,
()
=>
{
const
wrapper
=
setup
({
link
:
{
text
:
'link'
,
children
:
[
{
id
:
1
,
hideFromMenu
:
false
},
{
id
:
2
,
hideFromMenu
:
true
},
{
id
:
3
,
hideFromMenu
:
false
},
],
},
});
expect
(
wrapper
).
toMatchSnapshot
();
});
});
public/app/core/components/sidemenu/SideMenuDropDown.tsx
View file @
1db26d35
import
React
,
{
FC
}
from
'react'
;
import
_
from
'lodash'
;
import
DropDownChild
from
'./DropDownChild'
;
import
{
NavModelItem
}
from
'@grafana/data'
;
...
...
@@ -8,6 +9,11 @@ interface Props {
const
SideMenuDropDown
:
FC
<
Props
>
=
props
=>
{
const
{
link
}
=
props
;
let
childrenLinks
:
NavModelItem
[]
=
[];
if
(
link
.
children
)
{
childrenLinks
=
_
.
filter
(
link
.
children
,
item
=>
!
item
.
hideFromMenu
);
}
return
(
<
ul
className=
"dropdown-menu dropdown-menu--sidemenu"
role=
"menu"
>
<
li
className=
"side-menu-header"
>
...
...
@@ -15,10 +21,9 @@ const SideMenuDropDown: FC<Props> = props => {
<
span
className=
"sidemenu-item-text"
>
{
link
.
text
}
</
span
>
</
a
>
</
li
>
{
link
.
children
&&
link
.
children
.
map
((
child
,
index
)
=>
{
return
<
DropDownChild
child=
{
child
}
key=
{
`${child.url}-${index}`
}
/>;
})
}
{
childrenLinks
.
map
((
child
,
index
)
=>
{
return
<
DropDownChild
child=
{
child
}
key=
{
`${child.url}-${index}`
}
/>;
})
}
</
ul
>
);
};
...
...
public/app/core/components/sidemenu/__snapshots__/SideMenuDropDown.test.tsx.snap
View file @
1db26d35
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Render should not render hideFromMenu children 1`] = `
<ul
className="dropdown-menu dropdown-menu--sidemenu"
role="menu"
>
<li
className="side-menu-header"
>
<a
className="side-menu-header-link"
>
<span
className="sidemenu-item-text"
>
link
</span>
</a>
</li>
<DropDownChild
child={
Object {
"hideFromMenu": false,
"id": 1,
}
}
key="undefined-0"
/>
<DropDownChild
child={
Object {
"hideFromMenu": false,
"id": 3,
}
}
key="undefined-1"
/>
</ul>
`;
exports[`Render should render children 1`] = `
<ul
className="dropdown-menu dropdown-menu--sidemenu"
...
...
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