avo 3.0.1.beta21 → 3.0.1.beta23
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 +4 -4
- data/Gemfile.lock +1 -1
- data/app/components/avo/views/resource_index_component.html.erb +1 -1
- data/app/components/avo/views/resource_index_component.rb +6 -2
- data/app/views/avo/partials/_javascript.html.erb +1 -1
- data/lib/avo/configuration.rb +29 -0
- data/lib/avo/current.rb +7 -2
- data/lib/avo/execution_context.rb +2 -2
- data/lib/avo/fields/has_base_field.rb +1 -1
- data/lib/avo/fields/has_one_field.rb +1 -1
- data/lib/avo/licensing/h_q.rb +1 -2
- data/lib/avo/reloader.rb +1 -1
- data/lib/avo/services/debug_service.rb +17 -17
- data/lib/avo/version.rb +1 -1
- data/lib/avo.rb +2 -17
- data/lib/generators/avo/templates/initializer/avo.tt +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 752167e356e45bd34eb4a0526e250506bc807f5bb9a59dad82959f28864e24a1
|
4
|
+
data.tar.gz: e60fe61fe32893ba186186b5cf7d039be49247ff10aa7106660633968b18b23b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a83d1e966d0369f72cbaff8359747f259ed2abc3b1843038f680010bc1234e7e4401d9d88eabd7c8e4420c9e5be1b6aada7f6021e2ffbe1cf3849c0ee4406499
|
7
|
+
data.tar.gz: 2f36355a106ff0cad99a2fe1c57682ac01daee1990c5801230ecfe173fc886afa34ad822d5f7b01688e5c30a23edc7d01424cefca17df2bc37aeba59b8aa6219
|
data/Gemfile.lock
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<%= render partial: 'avo/partials/view_toggle_button', locals: { available_view_types: available_view_types, view_type: view_type, turbo_frame: turbo_frame } %>
|
34
34
|
</div>
|
35
35
|
</div>
|
36
|
-
<% if
|
36
|
+
<% if has_dynamic_filters? %>
|
37
37
|
<%= render Avo::DynamicFilters::FiltersComponent.new resource: resource, turbo_frame: turbo_frame %>
|
38
38
|
<% end %>
|
39
39
|
</div>
|
@@ -141,7 +141,7 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
141
141
|
end
|
142
142
|
|
143
143
|
def render_dynamic_filters_button
|
144
|
-
return unless Avo.
|
144
|
+
return unless Avo.avo_dynamic_filters_installed?
|
145
145
|
return unless resource.has_filters?
|
146
146
|
return if Avo::DynamicFilters.configuration.always_expanded
|
147
147
|
|
@@ -192,7 +192,11 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
192
192
|
end
|
193
193
|
|
194
194
|
def header_visible?
|
195
|
-
search_query_present? || filters_present? || has_many_view_types? ||
|
195
|
+
search_query_present? || filters_present? || has_many_view_types? || has_dynamic_filters?
|
196
|
+
end
|
197
|
+
|
198
|
+
def has_dynamic_filters?
|
199
|
+
Avo.avo_dynamic_filters_installed? && resource.has_filters?
|
196
200
|
end
|
197
201
|
|
198
202
|
def search_query_present?
|
@@ -4,7 +4,7 @@
|
|
4
4
|
Avo.configuration.root_path = '<%= root_path_without_url %>'
|
5
5
|
Avo.configuration.search_debounce = '<%= Avo.configuration.search_debounce %>'
|
6
6
|
Avo.configuration.cookies_key = '<%= Avo::COOKIES_KEY %>'
|
7
|
-
<% if Avo.
|
7
|
+
<% if Avo.avo_dynamic_filters_installed? %>
|
8
8
|
Avo.configuration.avo_filters = {
|
9
9
|
param_key: '<%= Avo::DynamicFilters.configuration.param_key %>'
|
10
10
|
}
|
data/lib/avo/configuration.rb
CHANGED
@@ -5,6 +5,7 @@ module Avo
|
|
5
5
|
attr_writer :app_name
|
6
6
|
attr_writer :branding
|
7
7
|
attr_writer :root_path
|
8
|
+
attr_writer :cache_store
|
8
9
|
attr_accessor :timezone
|
9
10
|
attr_accessor :per_page
|
10
11
|
attr_accessor :per_page_steps
|
@@ -95,6 +96,7 @@ module Avo
|
|
95
96
|
@resources = nil
|
96
97
|
@resource_parent_controller = "Avo::ResourcesController"
|
97
98
|
@mount_avo_engines = true
|
99
|
+
@cache_store = computed_cache_store
|
98
100
|
end
|
99
101
|
|
100
102
|
def current_user_method(&block)
|
@@ -164,6 +166,33 @@ module Avo
|
|
164
166
|
def resource_default_view=(view)
|
165
167
|
@resource_default_view = Avo::ViewInquirer.new(view.to_s)
|
166
168
|
end
|
169
|
+
|
170
|
+
def cache_store
|
171
|
+
Avo::ExecutionContext.new(
|
172
|
+
target: @cache_store,
|
173
|
+
production_rejected_cache_stores: %w[ActiveSupport::Cache::MemoryStore ActiveSupport::Cache::NullStore]
|
174
|
+
).handle
|
175
|
+
end
|
176
|
+
|
177
|
+
# When not in production or test we'll just use the MemoryStore which is good enough.
|
178
|
+
# When running in production we'll use Rails.cache if it's not ActiveSupport::Cache::MemoryStore or ActiveSupport::Cache::NullStore.
|
179
|
+
# If it's one of rejected cache stores, we'll use the FileStore.
|
180
|
+
# We decided against the MemoryStore in production because it will not be shared between multiple processes (when using Puma).
|
181
|
+
def computed_cache_store
|
182
|
+
-> {
|
183
|
+
if Rails.env.production?
|
184
|
+
if Rails.cache.class.to_s.in?(production_rejected_cache_stores)
|
185
|
+
ActiveSupport::Cache.lookup_store(:file_store, Rails.root.join("tmp", "cache"))
|
186
|
+
else
|
187
|
+
Rails.cache
|
188
|
+
end
|
189
|
+
elsif Rails.env.test?
|
190
|
+
Rails.cache
|
191
|
+
else
|
192
|
+
ActiveSupport::Cache.lookup_store(:memory_store)
|
193
|
+
end
|
194
|
+
}
|
195
|
+
end
|
167
196
|
end
|
168
197
|
|
169
198
|
def self.configuration
|
data/lib/avo/current.rb
CHANGED
@@ -26,9 +26,14 @@ class Avo::Current < ActiveSupport::CurrentAttributes
|
|
26
26
|
attribute :plugin_manager
|
27
27
|
attribute :locale
|
28
28
|
|
29
|
-
|
29
|
+
# Protect from error #<RuntimeError: Missing rack.input> when request is ActionDispatch::Request.empty
|
30
|
+
def params
|
31
|
+
request.params
|
32
|
+
rescue
|
33
|
+
{}
|
34
|
+
end
|
30
35
|
|
31
36
|
def request
|
32
|
-
view_context
|
37
|
+
view_context&.request || ActionDispatch::Request.empty
|
33
38
|
end
|
34
39
|
end
|
@@ -27,8 +27,8 @@ module Avo
|
|
27
27
|
@request ||= Avo::Current.request
|
28
28
|
@view_context ||= Avo::Current.view_context
|
29
29
|
@locale ||= Avo::Current.locale
|
30
|
-
@main_app ||= @view_context
|
31
|
-
@avo ||= @view_context
|
30
|
+
@main_app ||= @view_context&.main_app
|
31
|
+
@avo ||= @view_context&.avo
|
32
32
|
end
|
33
33
|
|
34
34
|
delegate :result, to: :card
|
data/lib/avo/licensing/h_q.rb
CHANGED
@@ -4,8 +4,7 @@ module Avo
|
|
4
4
|
attr_accessor :current_request
|
5
5
|
attr_accessor :cache_store
|
6
6
|
|
7
|
-
|
8
|
-
ENDPOINT = "https://avohq.io/api/v1/licenses/check".freeze unless const_defined?(:ENDPOINT)
|
7
|
+
ENDPOINT = "https://v3.avohq.io/api/v3/licenses/check".freeze unless const_defined?(:ENDPOINT)
|
9
8
|
REQUEST_TIMEOUT = 5 unless const_defined?(:REQUEST_TIMEOUT) # seconds
|
10
9
|
CACHE_TIME = 3600 unless const_defined?(:CACHE_TIME) # seconds
|
11
10
|
|
data/lib/avo/reloader.rb
CHANGED
@@ -45,7 +45,7 @@ class Avo::Reloader
|
|
45
45
|
# watch the lib directory in Avo development
|
46
46
|
if reload_lib?
|
47
47
|
dirs[Avo::Engine.root.join("lib", "avo").to_s] = ["rb"]
|
48
|
-
if Avo.
|
48
|
+
if Avo.avo_dynamic_filters_installed?
|
49
49
|
dirs[Avo::DynamicFilters::Engine.root.join("lib", "avo", "dynamic_filters").to_s] = ["rb"]
|
50
50
|
end
|
51
51
|
end
|
@@ -33,30 +33,30 @@ class Avo::Services::DebugService
|
|
33
33
|
def avo_metadata
|
34
34
|
resources = Avo.resource_manager.all
|
35
35
|
dashboards = defined?(Avo::Dashboards) ? Avo::Dashboards.dashboard_manager.all : []
|
36
|
-
field_definitions = resources.map(&:get_field_definitions)
|
37
|
-
fields_count = field_definitions.map(&:count).sum
|
38
|
-
fields_per_resource = sprintf("%0.01f", fields_count / (resources.count + 0.0))
|
36
|
+
# field_definitions = resources.map(&:get_field_definitions)
|
37
|
+
# fields_count = field_definitions.map(&:count).sum
|
38
|
+
# fields_per_resource = sprintf("%0.01f", fields_count / (resources.count + 0.0))
|
39
39
|
|
40
|
-
field_types = {}
|
41
|
-
custom_fields_count = 0
|
42
|
-
field_definitions.each do |fields|
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
# field_types = {}
|
41
|
+
# custom_fields_count = 0
|
42
|
+
# field_definitions.each do |fields|
|
43
|
+
# fields.each do |field|
|
44
|
+
# field_types[field.type] ||= 0
|
45
|
+
# field_types[field.type] += 1
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
end
|
47
|
+
# custom_fields_count += 1 if field.custom?
|
48
|
+
# end
|
49
|
+
# end
|
50
50
|
|
51
51
|
{
|
52
52
|
resources_count: resources.count,
|
53
53
|
dashboards_count: dashboards.count,
|
54
|
-
fields_count: fields_count,
|
55
|
-
fields_per_resource: fields_per_resource,
|
56
|
-
custom_fields_count: custom_fields_count,
|
57
|
-
field_types: field_types,
|
54
|
+
# fields_count: fields_count,
|
55
|
+
# fields_per_resource: fields_per_resource,
|
56
|
+
# custom_fields_count: custom_fields_count,
|
57
|
+
# field_types: field_types,
|
58
58
|
# **other_metadata(:actions), # TODO: this is fetching actions without hydration
|
59
|
-
**other_metadata(:filters),
|
59
|
+
# **other_metadata(:filters),
|
60
60
|
main_menu_present: Avo.configuration.main_menu.present?,
|
61
61
|
profile_menu_present: Avo.configuration.profile_menu.present?,
|
62
62
|
cache_store: Avo.cache_store&.class&.to_s,
|
data/lib/avo/version.rb
CHANGED
data/lib/avo.rb
CHANGED
@@ -51,7 +51,7 @@ module Avo
|
|
51
51
|
def boot
|
52
52
|
boot_logger
|
53
53
|
boot_fields
|
54
|
-
@cache_store =
|
54
|
+
@cache_store = Avo.configuration.cache_store
|
55
55
|
plugin_manager.boot_plugins
|
56
56
|
Avo.run_load_hooks(:boot, self)
|
57
57
|
end
|
@@ -98,7 +98,7 @@ module Avo
|
|
98
98
|
license.valid?
|
99
99
|
end
|
100
100
|
|
101
|
-
def
|
101
|
+
def avo_dynamic_filters_installed?
|
102
102
|
defined?(Avo::DynamicFilters).present?
|
103
103
|
end
|
104
104
|
|
@@ -143,21 +143,6 @@ module Avo
|
|
143
143
|
def boot_fields
|
144
144
|
@field_manager = Avo::Fields::FieldManager.build
|
145
145
|
end
|
146
|
-
|
147
|
-
def get_cache_store
|
148
|
-
if Rails.env.production?
|
149
|
-
case Rails.cache.class.to_s
|
150
|
-
when "ActiveSupport::Cache::MemCacheStore", "ActiveSupport::Cache::RedisCacheStore", "SolidCache::Store"
|
151
|
-
Rails.cache
|
152
|
-
else
|
153
|
-
ActiveSupport::Cache.lookup_store(:file_store, Rails.root.join("tmp", "cache"))
|
154
|
-
end
|
155
|
-
elsif Rails.env.test?
|
156
|
-
Rails.cache
|
157
|
-
else
|
158
|
-
ActiveSupport::Cache.lookup_store(:memory_store)
|
159
|
-
end
|
160
|
-
end
|
161
146
|
end
|
162
147
|
end
|
163
148
|
|
@@ -51,6 +51,13 @@ Avo.configure do |config|
|
|
51
51
|
# config.per_page_steps = [12, 24, 48, 72]
|
52
52
|
# config.via_per_page = 8
|
53
53
|
# config.id_links_to_resource = false
|
54
|
+
|
55
|
+
## == Cache options ==
|
56
|
+
## Provide a lambda to customize the cache store used by Avo.
|
57
|
+
## We compute the cache store by default, this is NOT the default, just an example.
|
58
|
+
# config.cache_store = -> {
|
59
|
+
# ActiveSupport::Cache.lookup_store(:solid_cache_store)
|
60
|
+
# }
|
54
61
|
# config.cache_resources_on_index_view = true
|
55
62
|
## permanent enable or disable cache_resource_filters, default value is false
|
56
63
|
# config.cache_resource_filters = false
|
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.0.1.
|
4
|
+
version: 3.0.1.beta23
|
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-10-
|
12
|
+
date: 2023-10-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|