This is an automated email from the ASF dual-hosted git repository.
jedcunningham pushed a commit to branch v2-9-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v2-9-test by this push:
new cddaf23e59 Copy menu_item href for nav bar (#39282)
cddaf23e59 is described below
commit cddaf23e594aa6999421a39ba8cf718f884de9fe
Author: Brent Bovenzi <[email protected]>
AuthorDate: Sat Apr 27 12:21:24 2024 -0400
Copy menu_item href for nav bar (#39282)
Co-authored-by: Jed Cunningham <[email protected]>
(cherry picked from commit 25f901a963001377621abe0ac0a1ff121a042bcd)
---
airflow/auth/managers/base_auth_manager.py | 10 ++++------
tests/auth/managers/test_base_auth_manager.py | 16 +++++++++++++++-
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/airflow/auth/managers/base_auth_manager.py
b/airflow/auth/managers/base_auth_manager.py
index 44fc53a66e..86f0ebd6dc 100644
--- a/airflow/auth/managers/base_auth_manager.py
+++ b/airflow/auth/managers/base_auth_manager.py
@@ -398,12 +398,10 @@ class BaseAuthManager(LoggingMixin):
accessible_items = []
for menu_item in items:
menu_item_copy = MenuItem(
- name=menu_item.name,
- icon=menu_item.icon,
- label=menu_item.label,
- childs=[],
- baseview=menu_item.baseview,
- cond=menu_item.cond,
+ **{
+ **menu_item.__dict__,
+ "childs": [],
+ }
)
if menu_item.childs:
accessible_children = []
diff --git a/tests/auth/managers/test_base_auth_manager.py
b/tests/auth/managers/test_base_auth_manager.py
index a39b60787c..7628924ad6 100644
--- a/tests/auth/managers/test_base_auth_manager.py
+++ b/tests/auth/managers/test_base_auth_manager.py
@@ -300,7 +300,15 @@ class TestBaseAuthManager:
mock_security_manager.has_access.side_effect = [True, False, True,
True, False]
menu = Menu()
- menu.add_link("item1")
+ menu.add_link(
+ # These may not all be valid types, but it does let us check each
attr is copied
+ name="item1",
+ href="h1",
+ icon="i1",
+ label="l1",
+ baseview="b1",
+ cond="c1",
+ )
menu.add_link("item2")
menu.add_link("item3")
menu.add_link("item3.1", category="item3")
@@ -313,6 +321,12 @@ class TestBaseAuthManager:
assert result[1].name == "item3"
assert len(result[1].childs) == 1
assert result[1].childs[0].name == "item3.1"
+ # check we've copied every attr
+ assert result[0].href == "h1"
+ assert result[0].icon == "i1"
+ assert result[0].label == "l1"
+ assert result[0].baseview == "b1"
+ assert result[0].cond == "c1"
@patch.object(EmptyAuthManager, "security_manager")
def test_filter_permitted_menu_items_twice(self, mock_security_manager,
auth_manager):