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