Skip to content

Commit

Permalink
Create a sub menu for all elements of the schema that are placed at t…
Browse files Browse the repository at this point in the history
…he top level
  • Loading branch information
dgarros committed Oct 30, 2024
1 parent 9f7300a commit fdbf0fa
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 fdbf0fa

Please sign in to comment.