Extract component to add/remove admin/mod/manager

We remove some duplication by doing so.
This commit is contained in:
Javi Martín
2020-07-01 19:01:06 +02:00
parent 02e27e13dc
commit 08c2bfc255
9 changed files with 63 additions and 33 deletions

View File

@@ -29,7 +29,10 @@
<%= administrator.description %>
</td>
<td>
<%= render Admin::TableActionsComponent.new(administrator) %>
<%= render Admin::Roles::TableActionsComponent.new(
administrator,
actions: [:edit, :destroy]
) %>
</td>
</tr>
<% end %>

View File

@@ -18,16 +18,7 @@
<td><%= user.name %></td>
<td><%= user.email %></td>
<td>
<% if user.administrator? && user.administrator.persisted? %>
<%= render Admin::TableActionsComponent.new(user.administrator, actions: [:destroy]) %>
<% else %>
<%= link_to t("admin.administrators.administrator.add"),
{ controller: "admin/administrators",
action: :create,
user_id: user },
method: :post,
class: "button success expanded" %>
<% end %>
<%= render Admin::Roles::TableActionsComponent.new(user.administrator || user.build_administrator) %>
</td>
</tr>
<% end %>