avo 3.32.2 → 3.32.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13b1c5a0ed066f284574b8743387b19cbe300f29f0f204f87072908c050ee3be
4
- data.tar.gz: b98a7f5a5692062ebd43f3c56350d28766d504a5bc9f4ee5c1cb49ff7a331341
3
+ metadata.gz: 0f28594c5b85e9c195d101136003422d6ddc321255474393a02313a54cc0aa86
4
+ data.tar.gz: 9e483c35a6ca7cddc0173c63526bed3370d7a81d3d7f356813a98e838c11664e
5
5
  SHA512:
6
- metadata.gz: a92fc374327988751ca0a074da5705b807f7a39fc9ea27973c5f3244fd118d276b74fa5ce67ae6726b92445554ba6bebd32a2b4b6924261acf1336fe015edf8f
7
- data.tar.gz: 9838f165435ecb2529c51a138f02a1cc01d18a0b00dee0f448ae865769a0d85bdf9315e9443c3f0890762b349e5ed5494a7a5c55e6706e602c3af3bc14f98930
6
+ metadata.gz: c5b5123b31107a6acc2456f46d36982af364f665b9593a23cdfc8f45f2edbe32bcc01448dccdbbe406f0c6ae5b3c49bd021e795d2baabbb81cc560228cc84843
7
+ data.tar.gz: cb4c91879fb962f4a0267a60e768ff2f49ce915a361201564a4b5325797839dcebf99a8ad9acfa13dd06cbac72ad361916bbc105aa06d8af4ccb15f38e4447d6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (3.32.2)
4
+ avo (3.32.4)
5
5
  actionview (>= 6.1)
6
6
  active_link_to
7
7
  activerecord (>= 6.1)
@@ -62,6 +62,7 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
62
62
 
63
63
  helpers.new_resource_path(**{
64
64
  via_relation: @field.id.to_s,
65
+ via_relation_class: resource.model_class.to_s,
65
66
  resource: target_resource || @field.target_resource,
66
67
  via_record_id: resource.record.persisted? ? resource.record.to_param : nil,
67
68
  via_belongs_to_resource_class: resource.class.name
@@ -1,6 +1,7 @@
1
1
  module Avo
2
2
  class MediaLibraryController < ApplicationController
3
3
  include Pagy::Backend
4
+
4
5
  before_action :authorize_access!
5
6
 
6
7
  def index
@@ -37,6 +38,13 @@ module Avo
37
38
 
38
39
  def authorize_access!
39
40
  raise_404 if Avo::MediaLibrary.configuration.disabled?
41
+
42
+ # `visible` is the per-user gate for the whole feature, not just the
43
+ # sidebar item. It reads like access control -- a block returning false
44
+ # for a user is plainly meant to keep that user out -- so it has to be
45
+ # enforced here, or every Media Library route stays reachable by URL to
46
+ # anyone who can sign in to Avo.
47
+ raise_404 unless Avo::MediaLibrary.configuration.visible?
40
48
  end
41
49
  end
42
50
  end
@@ -575,16 +575,16 @@ module Avo
575
575
 
576
576
  reflection = @record.class.reflect_on_association(@params[:via_relation]) if @params[:via_relation].present?
577
577
 
578
- if field.polymorphic_as.present? && field.types.map(&:to_s).include?(@params[:via_relation_class])
578
+ if field.polymorphic_as.present? && field.types.map(&:to_s).include?(@params[:via_relation_class]) && @params[:via_record_id].present?
579
579
  # set the value to the actual record
580
580
  via_resource = Avo.resource_manager.get_resource_by_model_class(@params[:via_relation_class])
581
- value = via_resource.find_record(@params[:via_record_id])
582
- elsif reflection.present? && reflection.foreign_key.present? && field.id.to_s == @params[:via_relation].to_s
581
+ value = via_resource.find_record(@params[:via_record_id]) if via_resource.present?
582
+ elsif reflection.present? && reflection.foreign_key.present? && field.id.to_s == @params[:via_relation].to_s && @params[:via_record_id].present?
583
583
  resource = Avo.resource_manager.get_resource_by_model_class params[:via_relation_class]
584
- record = resource.find_record @params[:via_record_id], params: params
584
+ record = resource.find_record @params[:via_record_id], params: params if resource.present?
585
585
  id_param = reflection.options[:primary_key] || :id
586
586
 
587
- value = record.send(id_param)
587
+ value = record.send(id_param) if record.present?
588
588
  end
589
589
  end
590
590
 
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.32.2" unless const_defined?(:VERSION)
2
+ VERSION = "3.32.4" unless const_defined?(:VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.32.2
4
+ version: 3.32.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin