-
-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
8 additions
and
21 deletions.
There are no files selected for viewing
29 changes: 8 additions & 21 deletions
29
app/components/avo/fields/preview_field/index_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
class Avo::Fields::PreviewField::IndexComponent < Avo::Fields::IndexComponent | ||
include Avo::Concerns::ChecksShowAuthorization | ||
|
||
# Used by Avo::Concerns::ChecksShowAuthorization | ||
attr_reader :resource | ||
|
||
def render_preview | ||
# Do not render the link if the user is not authorized to view the resource, | ||
# as the link exposes the result of `record.to_param`. | ||
return preview_icon if !can_view? | ||
|
||
link_to resource_view_path, title: t("avo.view_item", item: @resource.name).humanize do | ||
preview_icon | ||
helpers.svg( | ||
"heroicons/outline/magnifying-glass-circle", | ||
class: "block h-6 text-gray-600", | ||
data: { | ||
controller: "preview", | ||
preview_url_value: helpers.preview_resource_path(resource: @resource, turbo_frame: :preview_modal), | ||
} | ||
) | ||
end | ||
end | ||
|
||
def preview_icon | ||
helpers.svg( | ||
"heroicons/outline/magnifying-glass-circle", | ||
class: "block h-6 text-gray-600", | ||
data: { | ||
controller: "preview", | ||
preview_url_value: helpers.preview_resource_path(resource: @resource, turbo_frame: :preview_modal), | ||
} | ||
) | ||
end | ||
end |