Chore: Remove deprecation warning post rails upgrade (#7080)
Fixes: https://linear.app/chatwoot/issue/CW-1575/fix-deprecations-post-upgrade-to-rails-7
This commit is contained in:
@@ -56,7 +56,7 @@ class Attachment < ApplicationRecord
|
||||
|
||||
# NOTE: for External services use this methods since redirect doesn't work effectively in a lot of cases
|
||||
def download_url
|
||||
ActiveStorage::Current.host = Rails.application.routes.default_url_options[:host] if ActiveStorage::Current.host.blank?
|
||||
ActiveStorage::Current.url_options = Rails.application.routes.default_url_options if ActiveStorage::Current.url_options.blank?
|
||||
file.attached? ? file.blob.url : ''
|
||||
end
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ By default, the relationship is rendered as a link to the associated object.
|
||||
field.display_associated_resource,
|
||||
super_admin_user_path(field.data),
|
||||
) %>
|
||||
<% elsif valid_action?(:show, field.associated_class) %>
|
||||
<% elsif existing_action?(field.associated_class, :show) %>
|
||||
<%= link_to(
|
||||
field.display_associated_resource,
|
||||
[namespace, field.data],
|
||||
|
||||
@@ -16,7 +16,7 @@ By default, the relationship is rendered as a link to the associated object.
|
||||
%>
|
||||
|
||||
<% if field.data %>
|
||||
<% if valid_action?(:show, field.associated_class) %>
|
||||
<% if existing_action?(field.associated_class, :show) %>
|
||||
<%= link_to(
|
||||
field.display_associated_resource,
|
||||
[namespace, field.data],
|
||||
|
||||
@@ -17,7 +17,7 @@ By default, the relationship is rendered as a link to the associated object.
|
||||
%>
|
||||
|
||||
<% if field.data %>
|
||||
<% if valid_action?(:show, field.data.class) %>
|
||||
<% if existing_action?(field.data.class, :show) %>
|
||||
<%= link_to(
|
||||
field.display_associated_resource,
|
||||
[namespace, field.data],
|
||||
|
||||
@@ -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 valid_action?(:edit) && show_action?(:edit, page.resource) %>
|
||||
) if accessible_action?(page.resource, :edit) %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ to display a collection of resources in an HTML table.
|
||||
<% end %>
|
||||
</th>
|
||||
<% end %>
|
||||
<% [valid_action?(:edit, collection_presenter.resource_name),
|
||||
valid_action?(:destroy, collection_presenter.resource_name)].count(true).times do %>
|
||||
<% [existing_action?(collection_presenter.resource_name, :edit),
|
||||
existing_action?(collection_presenter.resource_name, :destroy)].count(true).times do %>
|
||||
<th scope="col"></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
@@ -56,13 +56,13 @@ to display a collection of resources in an HTML table.
|
||||
<% resources.each do |resource| %>
|
||||
<tr class="js-table-row"
|
||||
tabindex="0"
|
||||
<% if valid_action? :show, collection_presenter.resource_name %>
|
||||
<% if existing_action? collection_presenter.resource_name, :show %>
|
||||
<%= %(role=link data-url=#{polymorphic_path([namespace, resource])}) %>
|
||||
<% end %>
|
||||
>
|
||||
<% collection_presenter.attributes_for(resource).each do |attribute| %>
|
||||
<td class="cell-data cell-data--<%= attribute.html_class %>">
|
||||
<% if show_action? :show, resource -%>
|
||||
<% if authorized_action? resource, :show -%>
|
||||
<a href="<%= polymorphic_path([namespace, resource]) -%>"
|
||||
class="action-show"
|
||||
>
|
||||
@@ -72,22 +72,22 @@ to display a collection of resources in an HTML table.
|
||||
</td>
|
||||
<% end %>
|
||||
|
||||
<% if valid_action? :edit, collection_presenter.resource_name %>
|
||||
<% if existing_action? collection_presenter.resource_name, :edit %>
|
||||
<td><%= link_to(
|
||||
t("administrate.actions.edit"),
|
||||
[:edit, namespace, resource],
|
||||
class: "action-edit",
|
||||
) if show_action? :edit, resource%></td>
|
||||
) if authorized_action? resource, :edit%></td>
|
||||
<% end %>
|
||||
|
||||
<% if valid_action? :destroy, collection_presenter.resource_name %>
|
||||
<% if existing_action? collection_presenter.resource_name, :destroy %>
|
||||
<td><%= link_to(
|
||||
t("administrate.actions.destroy"),
|
||||
[namespace, resource],
|
||||
class: "text-color-red",
|
||||
method: :delete,
|
||||
data: { confirm: t("administrate.actions.confirm") }
|
||||
) if show_action? :destroy, resource %></td>
|
||||
) if authorized_action? resource, :destroy %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -46,7 +46,7 @@ as defined by the routes in the `admin/` namespace
|
||||
<%= link_to(
|
||||
display_resource_name(resource),
|
||||
resource_index_route(resource)
|
||||
) if valid_action? :index, resource %>
|
||||
) if existing_action? resource, :index %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ It renders the `_table` partial to display details about the resources.
|
||||
),
|
||||
[:new, namespace, page.resource_path.to_sym],
|
||||
class: "button",
|
||||
) if valid_action?(:new) && show_action?(:new, new_resource) %>
|
||||
) if accessible_action?(new_resource, :new) %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ to display a collection of resources in an HTML table.
|
||||
<% end %>
|
||||
</th>
|
||||
<% end %>
|
||||
<% [valid_action?(:edit, collection_presenter.resource_name),
|
||||
valid_action?(:destroy, collection_presenter.resource_name)].count(true).times do %>
|
||||
<% [existing_action?(collection_presenter.resource_name, :edit),
|
||||
existing_action?(collection_presenter.resource_name, :destroy)].count(true).times do %>
|
||||
<th scope="col"></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
@@ -56,13 +56,13 @@ to display a collection of resources in an HTML table.
|
||||
<% resources.each do |resource| %>
|
||||
<tr class="js-table-row"
|
||||
tabindex="0"
|
||||
<% if valid_action? :show, collection_presenter.resource_name %>
|
||||
<% if existing_action? collection_presenter.resource_name, :show %>
|
||||
<%= %(role=link data-url=#{polymorphic_path([namespace, resource.becomes(User)])}) %>
|
||||
<% end %>
|
||||
>
|
||||
<% collection_presenter.attributes_for(resource).each do |attribute| %>
|
||||
<td class="cell-data cell-data--<%= attribute.html_class %>">
|
||||
<% if show_action? :show, resource -%>
|
||||
<% if authorized_action? resource, :show -%>
|
||||
<a href="<%= polymorphic_path([namespace, resource.becomes(User)]) -%>"
|
||||
class="action-show"
|
||||
>
|
||||
@@ -72,22 +72,22 @@ to display a collection of resources in an HTML table.
|
||||
</td>
|
||||
<% end %>
|
||||
|
||||
<% if valid_action? :edit, collection_presenter.resource_name %>
|
||||
<% if existing_action? collection_presenter.resource_name, :edit %>
|
||||
<td><%= link_to(
|
||||
t("administrate.actions.edit"),
|
||||
[:edit, namespace, resource.becomes(User)],
|
||||
class: "action-edit",
|
||||
) if show_action? :edit, resource%></td>
|
||||
) if authorized_action? resource, :edit%></td>
|
||||
<% end %>
|
||||
|
||||
<% if valid_action? :destroy, collection_presenter.resource_name %>
|
||||
<% if existing_action? collection_presenter.resource_name, :destroy %>
|
||||
<td><%= link_to(
|
||||
t("administrate.actions.destroy"),
|
||||
[namespace, resource.becomes(User)],
|
||||
class: "text-color-red",
|
||||
method: :delete,
|
||||
data: { confirm: t("administrate.actions.confirm") }
|
||||
) if show_action? :destroy, resource %></td>
|
||||
) if authorized_action? resource, :destroy %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -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 valid_action?(:edit) && show_action?(:edit, page.resource) %>
|
||||
) if accessible_action?(:edit, page.resource) %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user