Extract component for organization actions

We remove duplication by doing so, and now we only need to add the call
do render Admin::TableActionsComponent once.
This commit is contained in:
Javi Martín
2020-06-14 22:01:13 +02:00
parent eb3f2bc2ca
commit 1537f25739
5 changed files with 79 additions and 22 deletions

View File

@@ -0,0 +1,13 @@
<%= render Admin::TableActionsComponent.new(actions: []) do %>
<% if can_verify? %>
<%= link_to t("admin.organizations.index.verify"),
verify_admin_organization_path(organization, request.query_parameters),
method: :put, class: "button success small-5" %>
<% end %>
<% if can_reject? %>
<%= link_to t("admin.organizations.index.reject"),
reject_admin_organization_path(organization, request.query_parameters),
method: :put, class: "button hollow alert small-5" %>
<% end %>
<% end %>

View File

@@ -0,0 +1,18 @@
class Admin::Organizations::TableActionsComponent < ApplicationComponent
delegate :can?, to: :controller
attr_reader :organization
def initialize(organization)
@organization = organization
end
private
def can_verify?
can? :verify, organization
end
def can_reject?
can? :reject, organization
end
end