diff --git a/CHANGELOG.md b/CHANGELOG.md index d22c6baa..b1f66b85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/webviz_config/_config_parser.py b/webviz_config/_config_parser.py index 56f2eb90..94bd0841 100644 --- a/webviz_config/_config_parser.py +++ b/webviz_config/_config_parser.py @@ -519,6 +519,19 @@ 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( @@ -526,7 +539,7 @@ def _parse_navigation(self) -> None: ): 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}" @@ -540,5 +553,6 @@ def _parse_navigation(self) -> None: "bar_position": "left", "drawer_position": "left", "initially_pinned": False, + "initially_collapsed": False, "show_logo": True, } diff --git a/webviz_config/_docs/_create_schema.py b/webviz_config/_docs/_create_schema.py index 46c92a12..1a108dca 100644 --- a/webviz_config/_docs/_create_schema.py +++ b/webviz_config/_docs/_create_schema.py @@ -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, }, diff --git a/webviz_config/templates/webviz_template.py.jinja2 b/webviz_config/templates/webviz_template.py.jinja2 index cf890991..84c146fc 100644 --- a/webviz_config/templates/webviz_template.py.jinja2 +++ b/webviz_config/templates/webviz_template.py.jinja2 @@ -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}}, ) ]