{# GET /permissions/grants — crate::pages::permissions::grants::ui::GrantsTemplate One matrix per profile: objects down the side, actions across the top. Every button on the page — a single cell, a whole row, a whole profile, everything — posts the same form to /permissions/grants/apply and differs only in the list of object|action pairs it carries. The lists are built in Rust (grants::state), so the page never asks the server to work out what "all" meant. #} {% extends "ui/base.html" %} {% block title %}{{ nav.tr("perm-tab-access") }}{% endblock %} {% macro apply(role, mode, pairs, label, style, hint) %}
{% for pair in pairs %}{% endfor %}
{% endmacro %} {% block content %}

{{ nav.tr("perm-eyebrow") }}

{{ nav.tr("perm-tab-access") }}

{{ nav.tr("grants-description") }}

{% include "pages/permissions/tabs.html" %} {% if page.updated %}

{{ nav.tr("grants-updated-notice") }}

{% endif %} {% if page.roles.is_empty() %}

{{ nav.tr("grants-no-role") }}

{{ nav.tr("grants-no-role-hint")|safe }}

{% else %}

{{ nav.tr("grants-role-heading") }}

{% if !page.selected_parent.is_empty() %} {{ nav.tr_args_html("grants-inherits-parent", [("role", page.selected_role.clone()), ("parent", page.selected_parent.clone())])|safe }} {% else %} {{ nav.tr_args_html("grants-inherits-none", [("role", page.selected_role.clone())])|safe }} {% endif %} {% if page.selected_is_structural %} {{ nav.tr("grants-structural-hint") }} {% endif %}

{{ nav.tr("grants-shortcuts") }}

{{ nav.tr("grants-shortcuts-hint") }}

{% call apply(page.selected_role, "grant", page.everything_read_pairs(), nav.tr("roles-access-read"), "secondary", nav.tr("grants-read-everything-hint")) %}{% endcall %} {% call apply(page.selected_role, "grant", page.everything_pairs(), nav.tr("grants-full-access-everything"), "secondary", nav.tr("grants-full-everything-hint")) %}{% endcall %} {% if page.has_direct() %} {% call apply(page.selected_role, "revoke", page.direct_pairs(), nav.tr("grants-remove-all-access"), "danger", nav.tr("grants-remove-all-hint")) %}{% endcall %} {% endif %}
{% for group in page.groups %}

{% if group.global %}{{ nav.tr("grants-everything-everywhere") }}{% else %}{{ nav.tr("grants-profile-prefix") }} {{ group.title }}{% endif %}{{ group.rows.len() }}

{% if group.has_wildcards() %} {% call apply(page.selected_role, "grant", group.read_pairs(), nav.tr("grants-read-only"), "secondary", nav.tr("grants-read-only-hint")) %}{% endcall %} {% call apply(page.selected_role, "grant", group.all_pairs(), nav.tr("grants-full-access"), "secondary", nav.tr("grants-full-access-hint")) %}{% endcall %} {% endif %} {% if group.has_direct() %} {% call apply(page.selected_role, "revoke", group.direct_pairs(), nav.tr("grants-clear"), "danger", nav.tr("grants-clear-hint")) %}{% endcall %} {% endif %}
{% for action in page.actions() %}{% endfor %} {% for row in group.rows %} {% for cell in row.cells %} {% endfor %} {% endfor %}
{{ nav.tr("grants-th-object") }}{{ action }}{{ nav.tr("grants-th-row") }}
{{ row.label }} {% if !row.note.is_empty() %}{{ row.note }}{% endif %} {{ row.object }} {% if !cell.allowed %} · {% else if cell.direct %} {% call apply(page.selected_role, "revoke", row.one_pair(cell.action.as_str()), "✓", "cell-on", nav.tr("grants-cell-direct")) %}{% endcall %} {% else if cell.inherited %} {% else %} {% call apply(page.selected_role, "grant", row.one_pair(cell.action.as_str()), "+", "cell-off", nav.tr("grants-cell-grant")) %}{% endcall %} {% endif %}
{% call apply(page.selected_role, "grant", row.all_pairs(), nav.tr("grants-all"), "secondary", nav.tr("grants-all-hint")) %}{% endcall %} {% if row.has_direct() %} {% call apply(page.selected_role, "revoke", row.direct_pairs(), nav.tr("grants-none"), "danger", nav.tr("grants-none-hint")) %}{% endcall %} {% endif %}
{% endfor %} {% endif %}
{% endblock %}