Skip to content

Commit

Permalink
Merge pull request #4787 from opsmill/dga-20241030-fix-menu
Browse files Browse the repository at this point in the history
Create section in the menu for each top level items automatically imported from the schema
  • Loading branch information
dgarros authored Oct 30, 2024
2 parents 0cd7597 + fdbf0fa commit 6018684
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
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

0 comments on commit 6018684

Please sign in to comment.