diff --git a/app/helpers/administrate/application_helper.rb b/app/helpers/administrate/application_helper.rb
index 6586dc67b8..c604850779 100644
--- a/app/helpers/administrate/application_helper.rb
+++ b/app/helpers/administrate/application_helper.rb
@@ -35,7 +35,7 @@ def model_from_resource(resource_name)
# - Symbol: name of a resource class
# - Class: resource class
# - ActiveRecord::Base: resource instance
- def administrate_valid_action?(target, action_name)
+ def accessible_action?(target, action_name)
target = target.to_sym if target.is_a?(String)
target_class_or_class_name =
target.is_a?(ActiveRecord::Base) ? target.class : target
diff --git a/app/views/administrate/application/_collection.html.erb b/app/views/administrate/application/_collection.html.erb
index 0d9ec13cc9..044a53efdd 100644
--- a/app/views/administrate/application/_collection.html.erb
+++ b/app/views/administrate/application/_collection.html.erb
@@ -59,13 +59,13 @@ to display a collection of resources in an HTML table.
<% resources.each do |resource| %>
+ <% if accessible_action?(resource, :show) %>
<%= %(tabindex=0 role=link data-url=#{polymorphic_path([namespace, resource])}) %>
<% end %>
>
<% collection_presenter.attributes_for(resource).each do |attribute| %>
- <% if administrate_valid_action?(resource, :show) -%>
+ <% if accessible_action?(resource, :show) -%>
+ ) if accessible_action?(resource, :edit) %>
<% end %>
<% if existing_action?(:destroy, collection_presenter.resource_name) %>
@@ -13,5 +13,5 @@
class: "text-color-red",
method: :delete,
data: { confirm: t("administrate.actions.confirm") }
- ) if administrate_valid_action?(resource, :destroy) %>
+ ) if accessible_action?(resource, :destroy) %>
<% end %>
diff --git a/app/views/administrate/application/_index_header.html.erb b/app/views/administrate/application/_index_header.html.erb
index c69d79d40d..ad069cac3a 100644
--- a/app/views/administrate/application/_index_header.html.erb
+++ b/app/views/administrate/application/_index_header.html.erb
@@ -23,6 +23,6 @@
),
[:new, namespace, page.resource_path.to_sym],
class: "button",
- ) if administrate_valid_action?(new_resource, :new) %>
+ ) if accessible_action?(new_resource, :new) %>
diff --git a/app/views/administrate/application/_navigation.html.erb b/app/views/administrate/application/_navigation.html.erb
index 014f6d13b5..8df01ef8f3 100644
--- a/app/views/administrate/application/_navigation.html.erb
+++ b/app/views/administrate/application/_navigation.html.erb
@@ -15,6 +15,6 @@ as defined by the routes in the `admin/` namespace
display_resource_name(resource),
resource_index_route(resource),
class: "navigation__link navigation__link--#{nav_link_state(resource)}"
- ) if administrate_valid_action?(resource.singularize, :index) %>
+ ) if accessible_action?(resource.singularize, :index) %>
<% end %>
diff --git a/app/views/administrate/application/edit.html.erb b/app/views/administrate/application/edit.html.erb
index 2165022cd1..415de8a5c8 100644
--- a/app/views/administrate/application/edit.html.erb
+++ b/app/views/administrate/application/edit.html.erb
@@ -27,7 +27,7 @@ It displays a header, and renders the `_form` partial to do the heavy lifting.
t("administrate.actions.show_resource", name: page.page_title),
[namespace, page.resource],
class: "button",
- ) if administrate_valid_action?(page.resource, :show) %>
+ ) if accessible_action?(page.resource, :show) %>
diff --git a/app/views/administrate/application/show.html.erb b/app/views/administrate/application/show.html.erb
index 16b01d606a..71b4638ff7 100644
--- a/app/views/administrate/application/show.html.erb
+++ b/app/views/administrate/application/show.html.erb
@@ -28,7 +28,7 @@ as well as a link to its edit page.
t("administrate.actions.edit_resource", name: page.page_title),
[:edit, namespace, page.resource],
class: "button",
- ) if administrate_valid_action?(page.resource, :edit) %>
+ ) if accessible_action?(page.resource, :edit) %>
<%= link_to(
t("administrate.actions.destroy"),
@@ -36,7 +36,7 @@ as well as a link to its edit page.
class: "button button--danger",
method: :delete,
data: { confirm: t("administrate.actions.confirm") }
- ) if administrate_valid_action?(page.resource, :destroy) %>
+ ) if accessible_action?(page.resource, :destroy) %>
diff --git a/app/views/fields/belongs_to/_index.html.erb b/app/views/fields/belongs_to/_index.html.erb
index d9a7e555e0..1e0ab2f4c9 100644
--- a/app/views/fields/belongs_to/_index.html.erb
+++ b/app/views/fields/belongs_to/_index.html.erb
@@ -16,7 +16,7 @@ By default, the relationship is rendered as a link to the associated object.
%>
<% if field.data %>
- <% if administrate_valid_action?(field.data, :show) %>
+ <% if accessible_action?(field.data, :show) %>
<%= link_to(
field.display_associated_resource,
[namespace, field.data],
diff --git a/app/views/fields/belongs_to/_show.html.erb b/app/views/fields/belongs_to/_show.html.erb
index 3299bcc148..3bca714d68 100644
--- a/app/views/fields/belongs_to/_show.html.erb
+++ b/app/views/fields/belongs_to/_show.html.erb
@@ -16,7 +16,7 @@ By default, the relationship is rendered as a link to the associated object.
%>
<% if field.data %>
- <% if administrate_valid_action?(field.data, :show) %>
+ <% if accessible_action?(field.data, :show) %>
<%= link_to(
field.display_associated_resource,
[namespace, field.data],
diff --git a/app/views/fields/has_one/_index.html.erb b/app/views/fields/has_one/_index.html.erb
index e8f32fa95c..4ff3ad1747 100644
--- a/app/views/fields/has_one/_index.html.erb
+++ b/app/views/fields/has_one/_index.html.erb
@@ -17,7 +17,7 @@ By default, the relationship is rendered as a link to the associated object.
<% if field.linkable? %>
<%= link_to_if(
- administrate_valid_action?(field.data, :show),
+ accessible_action?(field.data, :show),
field.display_associated_resource,
[namespace, field.data],
) %>
diff --git a/app/views/fields/has_one/_show.html.erb b/app/views/fields/has_one/_show.html.erb
index 9e0a09989f..542af5e09d 100644
--- a/app/views/fields/has_one/_show.html.erb
+++ b/app/views/fields/has_one/_show.html.erb
@@ -19,7 +19,7 @@ All show page attributes of has_one relationship would be rendered