manager: do not display empty menu on users page (#85199)
gitea/authentic/pipeline/head This commit looks good Details

This commit is contained in:
Yann Weber 2024-01-24 12:35:05 +01:00 committed by Yann Weber
parent 37f389d20f
commit 06ea77c46d
2 changed files with 21 additions and 9 deletions

View File

@ -6,7 +6,14 @@
{% block appbar %}
{{ block.super }}
<span class="actions">
<a class="extra-actions-menu-opener"></a>
{% if extra_actions %}
<a class="extra-actions-menu-opener"></a>
<ul class="extra-actions-menu">
{% for extra_action in extra_actions %}
<li><a href="{{ extra_action.url }}"{% if extra_action.popup %} rel="popup"{% endif %}>{{ extra_action.label }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% if view.can_add %}
<a
{% if add_ou %}href="{% url "a2-manager-user-add" ou_pk=add_ou.pk %}"{% else %}
@ -17,13 +24,6 @@
{% else %}
<a href="#" class="disabled" id="add-user-btn">{% trans "Add user" %}</a>
{% endif %}
{% if extra_actions %}
<ul class="extra-actions-menu">
{% for extra_action in extra_actions %}
<li><a href="{{ extra_action.url }}"{% if extra_action.popup %} rel="popup"{% endif %}>{{ extra_action.label }}</a></li>
{% endfor %}
</ul>
{% endif %}
</span>
{% endblock %}

View File

@ -37,7 +37,7 @@ from authentic2.apps.journal.models import Event
from authentic2.models import Service, Setting
from authentic2.validators import EmailValidator
from .utils import assert_event, get_link_from_mail, login, request_select2, text_content
from .utils import assert_event, get_link_from_mail, login, logout, request_select2, text_content
pytestmark = pytest.mark.django_db
@ -1464,3 +1464,15 @@ def test_manager_menu_json(app, admin):
response = login(app, admin)
response = app.get('/manage/menu.json')
assert response.json == expected
def test_manager_empty_kebab(app, admin, simple_user):
role_admin_roles = Role.objects.get(slug='_a2-manager-of-roles')
simple_user.roles.add(role_admin_roles.pk)
resp = login(app, simple_user, '/manage/users/')
assert '"extra-actions-menu-opener"' not in resp
logout(app)
resp = login(app, admin, '/manage/users/')
assert '"extra-actions-menu-opener"' in resp