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

Create section in the menu for each top level items automatically imported from the schema #4787

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/infrahub/menu/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ async def generate_menu(db: InfrahubDatabase, branch: Branch, menu_items: list[C
continue

if not schema.menu_placement:
first_element = MenuItemDict.from_schema(model=schema)
first_element.identifier = f"{first_element.identifier}Sub"
first_element.order_weight = 1
menu_item.children[first_element.identifier] = first_element
structure.data[menu_item.identifier] = menu_item
items_to_add[item_name] = True
elif menu_placement := structure.find_item(name=schema.menu_placement):
Expand Down
1 change: 1 addition & 0 deletions backend/tests/unit/menu/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ async def test_generate_menu_top_level(
assert menu
assert "TestMenu0" in menu.data.keys()
assert "TestCar" in menu.data.keys()
assert "TestCarSub" in menu.data["TestCar"].children.keys()


async def test_generate_menu_default(
Expand Down
Loading