Skip to content

Commit

Permalink
Implemented initiallyCollapsed setting for menu (#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms authored Oct 24, 2021
1 parent fa416c2 commit af16c66
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [UNRELEASED] - YYYY-MM-DD

### Added
- [#528](https://github.com/equinor/webviz-config/pull/528) - Implemented `initiallyCollapsed` setting for groups in menu.

## [0.3.5] - 2021-10-08

### Changed
Expand Down
16 changes: 15 additions & 1 deletion webviz_config/_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,14 +519,27 @@ def _parse_navigation(self) -> None:
f"{terminal_colors.END}"
)

if "initially_collapsed" not in self.configuration["options"]["menu"]:
self.configuration["options"]["menu"]["initially_collapsed"] = False
elif not isinstance(
self.configuration["options"]["menu"]["initially_collapsed"], bool
):
raise ParserError(
f"{terminal_colors.RED}{terminal_colors.BOLD}"
"Invalid option for options > menu > initially_collapsed: "
f"{self.configuration['options']['menu']['initially_collapsed']}. "
"Please select a boolean value: True, False"
f"{terminal_colors.END}"
)

if "show_logo" not in self.configuration["options"]["menu"]:
self.configuration["options"]["menu"]["show_logo"] = True
elif not isinstance(
self.configuration["options"]["menu"]["show_logo"], bool
):
raise ParserError(
f"{terminal_colors.RED}{terminal_colors.BOLD}"
"Invalid option for options > menu > initially_pinned: "
"Invalid option for options > menu > show_logo: "
f"{self.configuration['options']['menu']['show_logo']}. "
"Please select a boolean value: True, False"
f"{terminal_colors.END}"
Expand All @@ -540,5 +553,6 @@ def _parse_navigation(self) -> None:
"bar_position": "left",
"drawer_position": "left",
"initially_pinned": False,
"initially_collapsed": False,
"show_logo": True,
}
4 changes: 4 additions & 0 deletions webviz_config/_docs/_create_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"description": "State if the menu shall be pinned when initially showing.",
"type": "boolean",
},
"initially_collapsed": {
"description": "State if all groups in menu shall initially be collapsed",
"type": "boolean",
},
},
"additionalProperties": False,
},
Expand Down
1 change: 1 addition & 0 deletions webviz_config/templates/webviz_template.py.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ else:
menuBarPosition="{{options.menu.bar_position}}",
menuDrawerPosition="{{options.menu.drawer_position}}",
initiallyPinned={{options.menu.initially_pinned}},
initiallyCollapsed={{options.menu.initially_collapsed}},
navigationItems={{navigation_items}},
)
]
Expand Down

0 comments on commit af16c66

Please sign in to comment.