avo 2.14.3.pre.2.tailwindcss → 2.14.3.pre.5.nosprockets
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/base_component.rb +2 -3
- data/app/components/avo/index/resource_table_component.rb +1 -1
- data/app/components/avo/resource_component.rb +3 -2
- data/app/components/avo/sidebar_component.html.erb +1 -1
- data/app/components/avo/views/resource_edit_component.rb +0 -2
- data/app/controllers/avo/debug_controller.rb +3 -5
- data/app/controllers/avo/team_users_controller.rb +4 -0
- data/app/views/avo/debug/index.html.erb +13 -10
- data/app/views/avo/sidebar/_license_warnings.html.erb +1 -1
- data/app/views/layouts/avo/application.html.erb +1 -1
- data/lib/avo/app.rb +2 -2
- data/lib/avo/base_resource.rb +5 -1
- data/lib/avo/concerns/fetches_things.rb +13 -2
- data/lib/avo/configuration.rb +2 -0
- data/lib/avo/licensing/h_q.rb +23 -1
- data/lib/avo/licensing/license_manager.rb +1 -1
- data/lib/avo/svg_finder.rb +8 -5
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/js/install_generator.rb +64 -0
- data/lib/generators/avo/templates/initializer/avo.tt +10 -7
- data/lib/generators/avo/templates/js/avo.custom.js +2 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b277fe8fdc0cd240ea697b7d68a43af06761d12d5be000c6717da4eda00e5a88
|
4
|
+
data.tar.gz: 9e9fad003131d2188bec5eee8358571e2ccb841c4fb9fc3f8f03f17688cf177a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17f9bfe06002beb679269d7011f94ab229fa27b48edb6a7bec44f5e5e59fa0ec2593c2b94da575bfc419bd814f99f4ca7451cddb1240ce96b56936a43437bd2f
|
7
|
+
data.tar.gz: 26fd511e67b214f81959f404272cd4878d1f8d6396fd2b3e886a7fd985cf7bc9892ac8abb55ea61d9bee8aef0e8844d56f6bbe4adc0d5b42b0e4b6b978075df1
|
data/Gemfile.lock
CHANGED
@@ -9,10 +9,9 @@ class Avo::BaseComponent < ViewComponent::Base
|
|
9
9
|
|
10
10
|
private
|
11
11
|
|
12
|
-
#
|
12
|
+
# Use the @parent_resource to fetch the field using the @reflection name.
|
13
13
|
def field
|
14
|
-
|
15
|
-
fields.find { |f| f.id == @reflection.name }
|
14
|
+
@parent_resource.get_field_definitions.find { |f| f.id == @reflection.name }
|
16
15
|
rescue
|
17
16
|
nil
|
18
17
|
end
|
@@ -4,6 +4,7 @@ class Avo::ResourceComponent < Avo::BaseComponent
|
|
4
4
|
attr_reader :has_many_panels
|
5
5
|
attr_reader :has_as_belongs_to_many_panels
|
6
6
|
attr_reader :resource_tools
|
7
|
+
attr_reader :resource
|
7
8
|
attr_reader :view
|
8
9
|
|
9
10
|
def can_create?
|
@@ -19,7 +20,7 @@ class Avo::ResourceComponent < Avo::BaseComponent
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def can_detach?
|
22
|
-
authorize_association_for(
|
23
|
+
authorize_association_for(:detach)
|
23
24
|
end
|
24
25
|
|
25
26
|
def detach_path
|
@@ -53,7 +54,7 @@ class Avo::ResourceComponent < Avo::BaseComponent
|
|
53
54
|
|
54
55
|
if @reflection.present?
|
55
56
|
# Fetch the appropiate resource
|
56
|
-
reflection_resource =
|
57
|
+
reflection_resource = field.resource
|
57
58
|
# Fetch the model
|
58
59
|
# Hydrate the resource with the model if we have one
|
59
60
|
reflection_resource.hydrate(model: @parent_model) if @parent_model.present?
|
@@ -57,7 +57,7 @@
|
|
57
57
|
<%= render partial: "/avo/partials/sidebar_extra" %>
|
58
58
|
</div>
|
59
59
|
</div>
|
60
|
-
<%= helpers.render_license_warnings %>
|
60
|
+
<%= helpers.render_license_warnings unless Rails.env.production? %>
|
61
61
|
<%= render Avo::SidebarProfileComponent.new user: helpers._current_user %>
|
62
62
|
</div>
|
63
63
|
</div>
|
@@ -13,12 +13,10 @@ module Avo
|
|
13
13
|
|
14
14
|
if license.valid?
|
15
15
|
flash[:notice] = "avohq.io responded: \"#{license.id.humanize} license is valid\"."
|
16
|
+
elsif license.response['reason'].present?
|
17
|
+
flash[:error] = "avohq.io responded: \"#{license.response['reason']}\"."
|
16
18
|
else
|
17
|
-
|
18
|
-
flash[:error] = "avohq.io responded: \"#{license.response['reason']}\"."
|
19
|
-
else
|
20
|
-
flash[:error] = license.response['error']
|
21
|
-
end
|
19
|
+
flash[:error] = license.response['error']
|
22
20
|
end
|
23
21
|
|
24
22
|
redirect_back fallback_location: avo.avo_private_debug_index_path
|
@@ -20,7 +20,20 @@
|
|
20
20
|
<% c.bare_content do %>
|
21
21
|
<div class="grid gap-4 sm:grid-cols-3">
|
22
22
|
<div class="relative flex flex-col bg-white rounded shadow-panel p-4 space-y-4 h-full col-span-1">
|
23
|
+
<div class="flex justify-between w-full">
|
23
24
|
<div class="font-semibold">License info</div>
|
25
|
+
<div class="flex justify-self-end">
|
26
|
+
<%= a_button style: :outline,
|
27
|
+
color: :blue,
|
28
|
+
url: "#{root_path}avo_private/debug/refresh_license",
|
29
|
+
method: :post,
|
30
|
+
loading: true,
|
31
|
+
size: :xs,
|
32
|
+
icon: 'heroicons/outline/refresh' do %>
|
33
|
+
Refresh license
|
34
|
+
<% end %>
|
35
|
+
</div>
|
36
|
+
</div>
|
24
37
|
<div class="flex flex-col flex-1">
|
25
38
|
<div>
|
26
39
|
<div class="text-xl font-semibold"><%= license.name %></div>
|
@@ -54,16 +67,6 @@
|
|
54
67
|
</dl>
|
55
68
|
</div>
|
56
69
|
</div>
|
57
|
-
<div class="flex justify-end mt-4">
|
58
|
-
<%= a_button style: :outline,
|
59
|
-
color: :blue,
|
60
|
-
url: "#{root_path}avo_private/debug/refresh_license",
|
61
|
-
method: :post,
|
62
|
-
loading: true,
|
63
|
-
icon: 'heroicons/outline/refresh' do %>
|
64
|
-
Refresh license
|
65
|
-
<% end %>
|
66
|
-
</div>
|
67
70
|
</div>
|
68
71
|
</div>
|
69
72
|
<div class="relative bg-white rounded shadow-panel p-4 space-y-4 col-span-2">
|
@@ -2,5 +2,5 @@
|
|
2
2
|
<%= render_license_warning title: 'Trial Mode', message: 'You are experiencing paid features that need to be licensed before deploying this site. Enjoy!' %>
|
3
3
|
<% end %>
|
4
4
|
<% if license[:error].present? && !(Avo.configuration.display_license_request_timeout_error === false && license[:error] === "Request timeout.") %>
|
5
|
-
<%= render_license_warning title: 'Avo HQ Error', message: "#{license[:error]}
|
5
|
+
<%= render_license_warning title: 'Avo HQ Error', message: "#{license[:error]} Checking back every 5 minutes." %>
|
6
6
|
<% end %>
|
@@ -6,7 +6,6 @@
|
|
6
6
|
<%= csrf_meta_tags %>
|
7
7
|
<%= csp_meta_tag %>
|
8
8
|
<%= render partial: 'avo/partials/javascript' %>
|
9
|
-
<%= render partial: 'avo/partials/head' %>
|
10
9
|
<% if Avo::PACKED %>
|
11
10
|
<%= javascript_include_tag "/avo-assets/avo.base", "data-turbo-track": "reload", defer: true %>
|
12
11
|
<%= stylesheet_link_tag "/avo-assets/avo.base", "data-turbo-track": "reload", defer: true %>
|
@@ -17,6 +16,7 @@
|
|
17
16
|
<%= javascript_include_tag "hotwire-livereload", defer: true %>
|
18
17
|
<% end %>
|
19
18
|
<% end %>
|
19
|
+
<%= render partial: 'avo/partials/head' %>
|
20
20
|
</head>
|
21
21
|
<body class="bg-application os-mac">
|
22
22
|
<div class="relative flex flex-1 w-full min-h-full" data-controller="sidebar" data-sidebar-open-value="<%= @sidebar_open %>">
|
data/lib/avo/app.rb
CHANGED
@@ -161,12 +161,12 @@ module Avo
|
|
161
161
|
|
162
162
|
hq = Avo::Licensing::HQ.new(request)
|
163
163
|
|
164
|
-
payload[:thread_count] = get_thread_count
|
165
|
-
payload[:hq_payload] = hq&.payload
|
166
164
|
payload[:license_id] = Avo::App&.license&.id
|
167
165
|
payload[:license_valid] = Avo::App&.license&.valid?
|
168
166
|
payload[:license_payload] = Avo::App&.license&.payload
|
169
167
|
payload[:license_response] = Avo::App&.license&.response
|
168
|
+
payload[:hq_payload] = hq&.payload
|
169
|
+
payload[:thread_count] = get_thread_count
|
170
170
|
payload[:license_abilities] = Avo::App&.license&.abilities
|
171
171
|
payload[:cache_store] = self.cache_store&.class&.to_s
|
172
172
|
payload[:avo_metadata] = hq&.avo_metadata
|
data/lib/avo/base_resource.rb
CHANGED
@@ -20,7 +20,6 @@ module Avo
|
|
20
20
|
delegate :context, to: ::Avo::App
|
21
21
|
|
22
22
|
attr_accessor :view
|
23
|
-
attr_accessor :model
|
24
23
|
attr_accessor :reflection
|
25
24
|
attr_accessor :user
|
26
25
|
attr_accessor :params
|
@@ -111,6 +110,11 @@ module Avo
|
|
111
110
|
end
|
112
111
|
end
|
113
112
|
|
113
|
+
def record
|
114
|
+
@model
|
115
|
+
end
|
116
|
+
alias :model :record
|
117
|
+
|
114
118
|
def hydrate(model: nil, view: nil, user: nil, params: nil)
|
115
119
|
@view = view if view.present?
|
116
120
|
@user = user if user.present?
|
@@ -51,10 +51,15 @@ module Avo
|
|
51
51
|
#
|
52
52
|
# get_resource_by_name('User') => UserResource
|
53
53
|
# get_resource_by_name(User) => UserResource
|
54
|
-
def get_resource_by_model_name(
|
54
|
+
def get_resource_by_model_name(klass)
|
55
|
+
# Fetch the mappings imposed by the user.
|
56
|
+
# If they are present, use those ones.
|
57
|
+
mapping = get_mapping_for_model klass
|
58
|
+
return get_resource(mapping) if mapping.present?
|
59
|
+
|
55
60
|
valid_resources
|
56
61
|
.find do |resource|
|
57
|
-
resource.model_class.model_name.name ==
|
62
|
+
resource.model_class.model_name.name == klass.to_s
|
58
63
|
end
|
59
64
|
end
|
60
65
|
|
@@ -128,6 +133,12 @@ module Avo
|
|
128
133
|
|
129
134
|
get_sidebar_partials
|
130
135
|
end
|
136
|
+
|
137
|
+
private
|
138
|
+
|
139
|
+
def get_mapping_for_model(klass)
|
140
|
+
(Avo.configuration.model_resource_mapping || {}).stringify_keys.transform_values(&:to_s)[klass.to_s]
|
141
|
+
end
|
131
142
|
end
|
132
143
|
end
|
133
144
|
end
|
data/lib/avo/configuration.rb
CHANGED
@@ -34,6 +34,7 @@ module Avo
|
|
34
34
|
attr_accessor :buttons_on_form_footers
|
35
35
|
attr_accessor :main_menu
|
36
36
|
attr_accessor :profile_menu
|
37
|
+
attr_accessor :model_resource_mapping
|
37
38
|
attr_accessor :tabs_style
|
38
39
|
|
39
40
|
def initialize
|
@@ -79,6 +80,7 @@ module Avo
|
|
79
80
|
@buttons_on_form_footers = false
|
80
81
|
@main_menu = nil
|
81
82
|
@profile_menu = nil
|
83
|
+
@model_resource_mapping = {}
|
82
84
|
@tabs_style = :tabs
|
83
85
|
end
|
84
86
|
|
data/lib/avo/licensing/h_q.rb
CHANGED
@@ -153,6 +153,8 @@ module Avo
|
|
153
153
|
end
|
154
154
|
|
155
155
|
def cache_response(response: nil, time: CACHE_TIME)
|
156
|
+
response = normalize_response response
|
157
|
+
|
156
158
|
response.merge!(
|
157
159
|
expiry: time,
|
158
160
|
fetched_at: Time.now,
|
@@ -164,6 +166,21 @@ module Avo
|
|
164
166
|
response
|
165
167
|
end
|
166
168
|
|
169
|
+
def normalize_response(response)
|
170
|
+
if response.is_a? Hash
|
171
|
+
response
|
172
|
+
else
|
173
|
+
{
|
174
|
+
normalized_response: JSON.stringify(response)
|
175
|
+
}
|
176
|
+
end
|
177
|
+
response.merge({})
|
178
|
+
rescue
|
179
|
+
{
|
180
|
+
normalized_response: "rescued"
|
181
|
+
}
|
182
|
+
end
|
183
|
+
|
167
184
|
def perform_request
|
168
185
|
::Rails.logger.debug "[Avo] Performing request to avohq.io API to check license availability." if Rails.env.development?
|
169
186
|
|
@@ -199,7 +216,12 @@ module Avo
|
|
199
216
|
end
|
200
217
|
|
201
218
|
def cache_and_return_error(error, exception_message = "")
|
202
|
-
cache_response response: {
|
219
|
+
cache_response response: {
|
220
|
+
id: Avo.configuration.license,
|
221
|
+
valid: true,
|
222
|
+
error: error,
|
223
|
+
exception_message: exception_message
|
224
|
+
}.stringify_keys, time: 5.minutes.to_i
|
203
225
|
end
|
204
226
|
|
205
227
|
def has_cached_response
|
data/lib/avo/svg_finder.rb
CHANGED
@@ -22,18 +22,22 @@ class Avo::SvgFinder
|
|
22
22
|
Avo::Engine.root.join(@filename).to_s,
|
23
23
|
]
|
24
24
|
|
25
|
-
|
25
|
+
paths.find do |path|
|
26
26
|
File.exist? path
|
27
27
|
end
|
28
|
-
|
29
|
-
path
|
30
28
|
end
|
31
29
|
|
32
30
|
def default_strategy
|
33
|
-
|
31
|
+
# If the app uses Propshaft, grab it from there
|
32
|
+
if defined?(Propshaft)
|
33
|
+
asset_path = ::Rails.application.assets.load_path.find(@filename)
|
34
|
+
asset_path&.path
|
35
|
+
elsif ::Rails.application.config.assets.compile
|
36
|
+
# Grab the asset from the compiled asset manifest
|
34
37
|
asset = ::Rails.application.assets[@filename]
|
35
38
|
Pathname.new(asset.filename) if asset.present?
|
36
39
|
else
|
40
|
+
# Grab the asset from the manifest
|
37
41
|
manifest = ::Rails.application.assets_manifest
|
38
42
|
asset_path = manifest.assets[@filename]
|
39
43
|
unless asset_path.nil?
|
@@ -42,4 +46,3 @@ class Avo::SvgFinder
|
|
42
46
|
end
|
43
47
|
end
|
44
48
|
end
|
45
|
-
|
data/lib/avo/version.rb
CHANGED
@@ -0,0 +1,64 @@
|
|
1
|
+
require_relative "../base_generator"
|
2
|
+
|
3
|
+
module Generators
|
4
|
+
module Avo
|
5
|
+
module Js
|
6
|
+
class InstallGenerator < BaseGenerator
|
7
|
+
source_root File.expand_path("../templates", __dir__)
|
8
|
+
|
9
|
+
namespace "avo:js:install"
|
10
|
+
desc "Add custom JavaScript assets to your Avo project."
|
11
|
+
|
12
|
+
# possible values: importmap or esbuild
|
13
|
+
class_option :bundler, type: :string, default: "importmap"
|
14
|
+
|
15
|
+
def create_files
|
16
|
+
case options[:bundler].to_s
|
17
|
+
when "importmap"
|
18
|
+
install_for_importmap
|
19
|
+
when "esbuild"
|
20
|
+
install_for_esbuild
|
21
|
+
else
|
22
|
+
say "We don't know how to install Avo JS for this bundler \"#{options[:bundler]}\""
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
no_tasks do
|
27
|
+
def install_for_importmap
|
28
|
+
unless Rails.root.join("app", "javascript", "avo.custom.js").exist?
|
29
|
+
say "Add default app/javascript/avo.custom.js"
|
30
|
+
copy_file template_path("avo.custom.js"), "app/javascript/avo.custom.js"
|
31
|
+
end
|
32
|
+
|
33
|
+
say "Ejecting the _head.html.erb partial"
|
34
|
+
Rails::Generators.invoke("avo:eject", [":head", "--no-avo-version"], {destination_root: Rails.root})
|
35
|
+
|
36
|
+
say "Adding the JS asset to the partial"
|
37
|
+
append_to_file Rails.root.join("app", "views", "avo", "partials", "_head.html.erb"), "<%= javascript_importmap_tags \"avo.custom\" %>"
|
38
|
+
|
39
|
+
# pin to importmap
|
40
|
+
say "Pin the new entrypoint to your importmap config"
|
41
|
+
append_to_file Rails.root.join("config", "importmap.rb"), "\n# Avo custom JS entrypoint\npin \"avo.custom\", preload: true\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
def install_for_esbuild
|
45
|
+
unless Rails.root.join("app", "javascript", "avo.custom.js").exist?
|
46
|
+
say "Add default app/javascript/avo.custom.js"
|
47
|
+
copy_file template_path("avo.custom.js"), "app/javascript/avo.custom.js"
|
48
|
+
end
|
49
|
+
|
50
|
+
say "Ejecting the _head.html.erb partial"
|
51
|
+
Rails::Generators.invoke("avo:eject", [":head", "--no-avo-version"], {destination_root: Rails.root})
|
52
|
+
|
53
|
+
say "Adding the JS asset to the partial"
|
54
|
+
append_to_file Rails.root.join("app", "views", "avo", "partials", "_head.html.erb"), "<%= javascript_include_tag \"avo.custom\", \"data-turbo-track\": \"reload\", defer: true %>"
|
55
|
+
end
|
56
|
+
|
57
|
+
def template_path(filename)
|
58
|
+
Pathname.new(__dir__).join("..", "templates", "js", filename).to_s
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -34,19 +34,23 @@ Avo.configure do |config|
|
|
34
34
|
## == Localization ==
|
35
35
|
# config.locale = 'en-US'
|
36
36
|
|
37
|
+
## == Resource options ==
|
38
|
+
# config.resource_controls = :right
|
39
|
+
# config.model_resource_mapping = {}
|
40
|
+
# config.default_view_type = :table
|
41
|
+
# config.per_page = 24
|
42
|
+
# config.per_page_steps = [12, 24, 48, 72]
|
43
|
+
# config.via_per_page = 8
|
44
|
+
# config.id_links_to_resource = false
|
45
|
+
# config.cache_resources_on_index_view = true
|
46
|
+
|
37
47
|
## == Customization ==
|
38
48
|
# config.app_name = 'Avocadelicious'
|
39
49
|
# config.timezone = 'UTC'
|
40
50
|
# config.currency = 'USD'
|
41
|
-
# config.per_page = 24
|
42
|
-
# config.per_page_steps = [12, 24, 48, 72]
|
43
|
-
# config.via_per_page = 8
|
44
|
-
# config.default_view_type = :table
|
45
51
|
# config.hide_layout_when_printing = false
|
46
|
-
# config.id_links_to_resource = false
|
47
52
|
# config.full_width_container = false
|
48
53
|
# config.full_width_index_view = false
|
49
|
-
# config.cache_resources_on_index_view = true
|
50
54
|
# config.search_debounce = 300
|
51
55
|
# config.view_component_path = "app/components"
|
52
56
|
# config.display_license_request_timeout_error = true
|
@@ -54,7 +58,6 @@ Avo.configure do |config|
|
|
54
58
|
# config.resource_controls = :right
|
55
59
|
# config.tabs_style = :tabs # can be :tabs or :pills
|
56
60
|
|
57
|
-
|
58
61
|
## == Breadcrumbs ==
|
59
62
|
# config.display_breadcrumbs = true
|
60
63
|
# config.set_initial_breadcrumbs do
|
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: 2.14.3.pre.
|
4
|
+
version: 2.14.3.pre.5.nosprockets
|
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: 2022-
|
12
|
+
date: 2022-09-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -1642,6 +1642,7 @@ files:
|
|
1642
1642
|
- app/controllers/avo/reorder_controller.rb
|
1643
1643
|
- app/controllers/avo/resources_controller.rb
|
1644
1644
|
- app/controllers/avo/search_controller.rb
|
1645
|
+
- app/controllers/avo/team_users_controller.rb
|
1645
1646
|
- app/helpers/avo/actions_helper.rb
|
1646
1647
|
- app/helpers/avo/application_helper.rb
|
1647
1648
|
- app/helpers/avo/attachments_helper.rb
|
@@ -1887,6 +1888,7 @@ files:
|
|
1887
1888
|
- lib/generators/avo/field_generator.rb
|
1888
1889
|
- lib/generators/avo/filter_generator.rb
|
1889
1890
|
- lib/generators/avo/install_generator.rb
|
1891
|
+
- lib/generators/avo/js/install_generator.rb
|
1890
1892
|
- lib/generators/avo/locales_generator.rb
|
1891
1893
|
- lib/generators/avo/named_base_generator.rb
|
1892
1894
|
- lib/generators/avo/resource_generator.rb
|
@@ -1913,6 +1915,7 @@ files:
|
|
1913
1915
|
- lib/generators/avo/templates/filters/select_filter.tt
|
1914
1916
|
- lib/generators/avo/templates/filters/text_filter.tt
|
1915
1917
|
- lib/generators/avo/templates/initializer/avo.tt
|
1918
|
+
- lib/generators/avo/templates/js/avo.custom.js
|
1916
1919
|
- lib/generators/avo/templates/locales/avo.en.yml
|
1917
1920
|
- lib/generators/avo/templates/locales/avo.fr.yml
|
1918
1921
|
- lib/generators/avo/templates/locales/avo.nb-NO.yml
|