Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu permissions #1207

Merged
merged 2 commits into from
Mar 13, 2019
Merged

Menu permissions #1207

merged 2 commits into from
Mar 13, 2019

Conversation

swaterkamp
Copy link
Member

This fixes wrongly displayed menues. We need to make sure that the first child of a Menu is a MenuEntry and not a MenuSection.

Checklist:

  • [ N/A ] Tests
  • [ N/A ] CHANGES Entry

@swaterkamp swaterkamp self-assigned this Mar 8, 2019
@swaterkamp swaterkamp requested a review from bjoernricks March 8, 2019 15:54
@codecov
Copy link

codecov bot commented Mar 8, 2019

Codecov Report

Merging #1207 into gsa-8.0 will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           gsa-8.0   #1207      +/-   ##
==========================================
- Coverage    16.51%   16.5%   -0.02%     
==========================================
  Files          948     948              
  Lines        27592   27610      +18     
  Branches      5906    5925      +19     
==========================================
  Hits          4558    4558              
- Misses       21580   21594      +14     
- Partials      1454    1458       +4
Impacted Files Coverage Δ
gsa/src/web/components/bar/menubar.js 0% <0%> (ø) ⬆️
gsa/src/web/components/menu/menu.js 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b2f043...a5180bc. Read the comment docs.

@@ -114,13 +116,24 @@ const MenuList = styled.ul`
}
`;

const checkChild = child => {
if (child.type === MenuSection && isArray(child.props.children)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not 100 percent sure if this will work. React has a special API to access children because they aren't arrays https://reactjs.org/docs/react-api.html#reactchildren

@@ -114,13 +116,24 @@ const MenuList = styled.ul`
}
`;

const checkChild = child => {
if (child.type === MenuSection && isArray(child.props.children)) {
return child.props.children.find(chil => chil !== false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am really sure this won't work always. Please use the React.Children API (https://reactjs.org/docs/react-api.html#reactchildren) and I guess null and undefined should be checked too. Maybe use

chil => !!chil

if (isDefined(to)) {
link = <Link to={to}>{title}</Link>;
} else if (isDefined(children) && children.length > 0) {
const [child] = children;
let [child] = children;
child = checkChild(child);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO the function name checkChild is a bit misplaced. I do expect either to return a boolean or to raise an exception for a check named function. I guess

getFirstMenuEntry(children)

would fit?

@bjoernricks bjoernricks self-requested a review March 11, 2019 11:35
Copy link
Contributor

@bjoernricks bjoernricks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look at the children handling if that really fits

If the first child is a section, the DefaultEntry receives that section 
as title element instead of the correct menu title.
Copy link
Contributor

@bjoernricks bjoernricks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bjoernricks bjoernricks merged commit fc014db into greenbone:gsa-8.0 Mar 13, 2019
@swaterkamp swaterkamp deleted the MenuPermissions branch February 20, 2020 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants