avo 3.1.1 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of avo might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14566ebb055bf03bf8ed662ab5cc9e92fd426b62e170a62df3593d798e0e54c8
4
- data.tar.gz: ba1262a02c6302a5f877073d04d0db06d0df47b559cdaa60c79e6e33321a6fab
3
+ metadata.gz: 58201ebf40ea090bc7ff03e588ae9dba48c913c4d39b16eaa4d0068a99c45211
4
+ data.tar.gz: 2c3efea520399494770be31f454086cc4ea6aa24eaa16c735099ef336e059e8d
5
5
  SHA512:
6
- metadata.gz: eecde64af0facc9fdfed0c6c840e4b030ba2f7b72891c0aa240b7e9617393b1a79126d783218409d16c6f6133bab241b3cbd1b391976a99b653db3b4e04e25f6
7
- data.tar.gz: 8719d1f98d148a95f2d7c2bcd7a56a471e010d0253e1e3c78e7151f9e7e3d22d5e563aa22ab07119d9c2acee1d867cf644839074aaf41de3deb2b4058252a251
6
+ metadata.gz: 5ab96094a881dea361ab8c88817030bf277dc737e70f5f273da59545f1db19e6145aaa14877db6bc6b8aa91347df5c2099a1c57183dc52f6ed10dd896831f852
7
+ data.tar.gz: 404d1af6a00033fc33b3e242fb5e10a1c9a66a0b79771615586466848c6022a3a495ca6ec3e890d394f8c3f5c02c28817c30f30e6563dd443aa1cf0cdd7a7084
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (3.1.1)
4
+ avo (3.1.3)
5
5
  actionview (>= 6.1)
6
6
  active_link_to
7
7
  activerecord (>= 6.1)
@@ -7029,6 +7029,10 @@ tag.tagify__tag{
7029
7029
  width:1rem
7030
7030
  }
7031
7031
 
7032
+ .w-screen{
7033
+ width:100vw
7034
+ }
7035
+
7032
7036
  .w-auto{
7033
7037
  width:auto
7034
7038
  }
@@ -41,6 +41,7 @@ class Avo::Fields::HasOneField::ShowComponent < Avo::Fields::ShowComponent
41
41
  args = {
42
42
  via_relation: association_id,
43
43
  via_relation_class: @resource.model_class.to_s,
44
+ via_resource_class: @resource.class,
44
45
  via_record_id: @resource.record.to_param,
45
46
  via_association_type: :has_one
46
47
  }
@@ -101,6 +101,13 @@ module Avo
101
101
  if item.is_sidebar?
102
102
  fields << extract_fields(item)
103
103
  end
104
+ else
105
+ # When `item.is_main_panel? == true` then also `item.is_panel? == true`
106
+ # But when only_root == true we want to extract main_panel items
107
+ # In all other circumstances items will get extracted when checking for `item.is_panel?`
108
+ if item.is_main_panel?
109
+ fields << extract_fields(item)
110
+ end
104
111
  end
105
112
 
106
113
  if item.is_field?
@@ -110,10 +117,6 @@ module Avo
110
117
  if item.is_row?
111
118
  fields << extract_fields(tab)
112
119
  end
113
-
114
- if item.is_main_panel?
115
- fields << extract_fields(item)
116
- end
117
120
  end
118
121
 
119
122
  fields.flatten
@@ -1,39 +1,15 @@
1
1
  module Avo
2
2
  class DynamicRouter
3
- def self.eager_load(entity)
4
- paths = Avo::ENTITIES.fetch entity
5
-
6
- return unless paths.present?
7
-
8
- pathname = Rails.root.join(*paths)
9
- if pathname.directory?
10
- Rails.autoloaders.main.eager_load_dir(pathname.to_s)
11
- end
12
- end
13
-
14
3
  def self.routes
15
4
  Avo::Engine.routes.draw do
16
5
  scope "resources", as: "resources" do
17
- # Check if the user chose to manually register the resource files.
18
- # If so, eager_load the resources dir.
19
- if Avo.configuration.resources.nil?
20
- Avo::DynamicRouter.eager_load(:resources) unless Rails.application.config.eager_load
21
- end
22
-
23
- Avo::Resources::ResourceManager.fetch_resources
24
- .select do |resource|
25
- resource != :BaseResource
26
- end
27
- .select do |resource|
28
- resource.is_a? Class
29
- end
30
- .map do |resource|
31
- resources resource.route_key do
32
- member do
33
- get :preview
34
- end
6
+ Avo::Resources::ResourceManager.fetch_resources.map do |resource|
7
+ resources resource.route_key do
8
+ member do
9
+ get :preview
35
10
  end
36
11
  end
12
+ end
37
13
  end
38
14
  end
39
15
  end
@@ -8,7 +8,6 @@ module Avo
8
8
  class << self
9
9
  def build
10
10
  instance = new
11
- instance.init_resources
12
11
  instance.check_bad_resources
13
12
  instance
14
13
  end
@@ -35,37 +34,30 @@ module Avo
35
34
  # "FishResource",
36
35
  # ]
37
36
  def fetch_resources
38
- resources = if Avo.configuration.resources.nil?
39
- BaseResource.descendants
37
+ if Avo.configuration.resources.present?
38
+ load_configured_resources
40
39
  else
41
- Avo.configuration.resources
40
+ load_resources_namespace
42
41
  end
43
42
 
44
- resources.map do |resource|
45
- if resource.is_a?(Class)
46
- resource
47
- else
48
- resource.to_s.safe_constantize
49
- end
43
+ BaseResource.descendants
44
+ end
45
+
46
+ def load_resources_namespace
47
+ Rails.autoloaders.main.eager_load_namespace(Avo::Resources)
48
+ end
49
+
50
+ def load_configured_resources
51
+ raise 'Resources configuration must be an array' unless Avo.configuration.resources.is_a? Array
52
+
53
+ Avo.configuration.resources.each do |resource|
54
+ resource.to_s.safe_constantize
50
55
  end
51
56
  end
52
57
  end
53
58
 
54
59
  def initialize
55
- @resources = []
56
- end
57
-
58
- def init_resources
59
- self.resources = self.class.fetch_resources
60
- .reject do |resource|
61
- # Remove the BaseResource. We only need the descendants
62
- resource == Avo::BaseResource
63
- end
64
- .uniq do |klass|
65
- # On invalid resource configuration the resource classes get duplicated in `ObjectSpace`
66
- # We need to de-duplicate them
67
- klass.name
68
- end
60
+ @resources = self.class.fetch_resources
69
61
  end
70
62
 
71
63
  def check_bad_resources
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.1.1" unless const_defined?(:VERSION)
2
+ VERSION = "3.1.3" unless const_defined?(:VERSION)
3
3
  end
data/lib/avo.rb CHANGED
@@ -18,16 +18,6 @@ module Avo
18
18
  IN_DEVELOPMENT = ENV["AVO_IN_DEVELOPMENT"] == "1"
19
19
  PACKED = !IN_DEVELOPMENT
20
20
  COOKIES_KEY = "avo"
21
- ENTITIES = {
22
- cards: ["app", "avo", "cards"],
23
- scopes: ["app", "avo", "scopes"],
24
- fields: ["app", "avo", "fields"],
25
- filters: ["app", "avo", "filters"],
26
- actions: ["app", "avo", "actions"],
27
- resources: ["app", "avo", "resources"],
28
- dashboards: ["app", "avo", "dashboards"],
29
- resource_tools: ["app", "avo", "resource_tools"]
30
- }
31
21
 
32
22
  class LicenseVerificationTemperedError < StandardError; end
33
23
 
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.1.1
4
+ version: 3.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-12-06 00:00:00.000000000 Z
12
+ date: 2023-12-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord