-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Antony Milne <[email protected]>
- Loading branch information
1 parent
c7b7ac7
commit bc835cf
Showing
9 changed files
with
185 additions
and
161 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
vizro-core/changelog.d/20231017_212005_huong_li_nguyen_navigation.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!-- | ||
A new scriv changelog fragment. | ||
Uncomment the section that is right (remove the HTML comment wrapper). | ||
--> | ||
|
||
### Removed | ||
|
||
- Remove warning message if not all registered pages are used in `Navigation` ([#117](https://github.com/mckinsey/vizro/pull/117)) | ||
|
||
<!-- | ||
### Added | ||
- A bullet item for the Added category. | ||
--> | ||
|
||
### Changed | ||
|
||
- Autopopulate `navigation.pages` with registered pages during `Dashboard` validation if `navigation.pages = None` ([#117](https://github.com/mckinsey/vizro/pull/117)) | ||
|
||
<!-- | ||
### Deprecated | ||
- A bullet item for the Deprecated category. | ||
--> | ||
<!-- | ||
### Fixed | ||
- A bullet item for the Fixed category. | ||
--> | ||
<!-- | ||
### Security | ||
- A bullet item for the Security category. | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
vizro-core/src/vizro/models/_navigation/_navigation_utils.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import itertools | ||
|
||
from vizro.managers import model_manager | ||
|
||
|
||
def _validate_pages(pages): | ||
"""Reusable validator to check if provided Page IDs exist as registered pages.""" | ||
from vizro.models import Page | ||
|
||
pages_as_list = list(itertools.chain(*pages.values())) if isinstance(pages, dict) else pages | ||
|
||
if not pages_as_list: | ||
raise ValueError("Ensure this value has at least 1 item.") | ||
|
||
# Ideally we would use dash.page_registry or maybe dashboard.pages here, but we only register pages in | ||
# dashboard.pre_build and model manager cannot find a Dashboard at validation time. | ||
# page[0] gives the page model ID. | ||
registered_pages = [page[0] for page in model_manager._items_with_type(Page)] | ||
if unknown_pages := [page for page in pages_as_list if page not in registered_pages]: | ||
raise ValueError(f"Unknown page ID {unknown_pages} provided to argument 'pages'.") | ||
return pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,3 +91,7 @@ | |
flex-direction: column; | ||
width: 100%; | ||
} | ||
|
||
.hidden { | ||
display: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.