summaryrefslogtreecommitdiff
path: root/app/views/users/_user.html.erb
blob: c9b21f0a900c1651d8d0b3b2b698712db9100458 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<% users.each do |user| %>
<tr>
  <td class="user_login"><%= user.login %></td>
  <td class="user_roles">
    <% if user.roles.any? %>
      <%= user.role_labels.join(", ") %>
    <% else %>
      <span class="field_hint"><%= t(".no_roles") %></span>
    <% end %>
  </td>
  <td class="user_action">
    <%= link_to user_path(user), "aria-label" => t("admin.common.show"),
          title: t("admin.common.show") do %>
      <%= icon("eye", library: "tabler", "aria-hidden": true) %>
    <% end %>
  </td>
  <td class="user_action">
    <% if current_user.admin? || current_user == user %>
      <%= link_to edit_user_path(user), "aria-label" => t("admin.common.edit"),
            title: t("admin.common.edit") do %>
        <%= icon("edit", library: "tabler", "aria-hidden": true) %>
      <% end %>
    <% end %>
  </td>
  <td class="user_action">
    <% if current_user.admin? && current_user != user %>
      <% if user.alumni? %>
        <%= button_to reactivate_user_path(user), method: :put,
              form: { class: 'button_to state_changing' },
              "aria-label" => t(".reactivate"), title: t(".reactivate") do %>
          <%= icon("user-check", library: "tabler", "aria-hidden": true) %>
        <% end %>
      <% else %>
        <%= button_to deactivate_user_path(user), method: :put,
              form: { data: { confirm: t(".confirm_deactivate", :login => user.login) },
                      class: 'button_to destructive' },
              "aria-label" => t(".deactivate"), title: t(".deactivate") do %>
          <%= icon("user-off", library: "tabler", "aria-hidden": true) %>
        <% end %>
      <% end %>
    <% end %>
  </td>
  <td class="user_action">
    <% if current_user.redaktion? && !user.alumni? %>
      <% if user.redaktion? %>
        <% unless user == current_user %>
          <%= button_to revoke_redaktion_user_path(user), method: :put,
                form: { data: { confirm: t(".confirm_revoke_redaktion", :login => user.login) },
                        class: 'button_to destructive' },
                "aria-label" => t(".revoke_redaktion"), title: t(".revoke_redaktion") do %>
            <%= icon("user-minus", library: "tabler", "aria-hidden": true) %>
          <% end %>
        <% end %>
      <% elsif user.otp_enrolled? %>
        <%= button_to grant_redaktion_user_path(user), method: :put,
              form: { data: { confirm: t(".confirm_grant_redaktion", :login => user.login) },
                      class: 'button_to state_changing' },
              "aria-label" => t(".grant_redaktion"), title: t(".grant_redaktion") do %>
          <%= icon("user-plus", library: "tabler", "aria-hidden": true) %>
        <% end %>
      <% else %>
        <span class="field_hint" title="<%= t(".needs_otp") %>"
              aria-label="<%= t(".needs_otp") %>">
          <%= icon("shield-off", library: "tabler", "aria-hidden": true) %>
        </span>
      <% end %>
    <% end %>
  </td>
</tr>
<% end %>