avo 2.30.2 → 2.31.0

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: fc6bc41d1c4845492b9ee785b1ccd4895d0369ec54d2b307c67835a112059923
4
- data.tar.gz: a04214b31f49e408ecf64166c126dd8a114543f4c3ad01383f33ba1d7216c88d
3
+ metadata.gz: d2d89325380615d00eeac9d1c507409b602452f320e96ce8818830b580cb5ffd
4
+ data.tar.gz: 787b185e5f37182a75dec5935ea5cd0a2d1cd1986981b79ff6393bfc021e649d
5
5
  SHA512:
6
- metadata.gz: e36a294bc70cd7568ea15c7e5d4323b1d261bfeaf7295ae2439cf581bef67ea0efcebe9995d23bfb416904e89810342df73d20591aa6790d128593ffceca7a16
7
- data.tar.gz: d2eac35c9568ed230c05155823be7f52add0e4a86fa0f43ec85dbe2c69e84e5cb6188b7799714c739922269ba16b4919e3a0e7e7eb5f8d79cd4220669e0671ba
6
+ metadata.gz: 02eba26931bf6ea8300df3fc44006ad2390ddb3dd0ca6b474b438bd29953a5203e97f6b301297bc119572a8bef80341b62fcd7cc6c4ecf1dd7b065441ed168ff
7
+ data.tar.gz: fde51151f29f9c2c06d00cbdb0e16be8d594eb72c20669ad54944adb5d4f105098bf5f84b9a3878b3324837a3ea4086f067dc5030151161409f599699b06ae55
data/Gemfile CHANGED
@@ -75,7 +75,7 @@ group :development do
75
75
 
76
76
  gem "htmlbeautifier"
77
77
 
78
- gem "hotwire-livereload", "~> 1.1"
78
+ gem "hotwire-livereload", "~> 1.2"
79
79
 
80
80
  gem "brakeman"
81
81
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.30.2)
4
+ avo (2.31.0)
5
5
  actionview (>= 6.0)
6
6
  active_link_to
7
7
  activerecord (>= 6.0)
@@ -13,7 +13,7 @@ PATH
13
13
  meta-tags
14
14
  pagy
15
15
  turbo-rails
16
- view_component
16
+ view_component (>= 2.54.0)
17
17
  zeitwerk (>= 2.6.2)
18
18
 
19
19
  GEM
@@ -196,7 +196,7 @@ GEM
196
196
  highline (2.1.0)
197
197
  hightop (0.3.0)
198
198
  activesupport (>= 5.2)
199
- hotwire-livereload (1.2.2)
199
+ hotwire-livereload (1.2.3)
200
200
  listen (>= 3.0.0)
201
201
  rails (>= 6.0.0)
202
202
  html_tokenizer (0.0.7)
@@ -233,10 +233,10 @@ GEM
233
233
  json (2.6.2)
234
234
  launchy (2.5.2)
235
235
  addressable (~> 2.8)
236
- listen (3.7.1)
236
+ listen (3.8.0)
237
237
  rb-fsevent (~> 0.10, >= 0.10.3)
238
238
  rb-inotify (~> 0.9, >= 0.9.10)
239
- loofah (2.19.1)
239
+ loofah (2.20.0)
240
240
  crass (~> 1.0.2)
241
241
  nokogiri (>= 1.5.9)
242
242
  mail (2.8.1)
@@ -268,7 +268,7 @@ GEM
268
268
  timeout
269
269
  net-smtp (0.3.3)
270
270
  net-protocol
271
- nio4r (2.5.8)
271
+ nio4r (2.5.9)
272
272
  nokogiri (1.14.3)
273
273
  mini_portile2 (~> 2.8.0)
274
274
  racc (~> 1.4)
@@ -331,7 +331,7 @@ GEM
331
331
  activerecord (>= 6.0.4)
332
332
  activesupport (>= 6.0.4)
333
333
  i18n
334
- rb-fsevent (0.11.1)
334
+ rb-fsevent (0.11.2)
335
335
  rb-inotify (0.10.1)
336
336
  ffi (~> 1.0)
337
337
  redis (4.8.1)
@@ -421,7 +421,7 @@ GEM
421
421
  tzinfo (2.0.6)
422
422
  concurrent-ruby (~> 1.0)
423
423
  unicode-display_width (2.4.0)
424
- view_component (2.82.0)
424
+ view_component (3.0.0)
425
425
  activesupport (>= 5.2.0, < 8.0)
426
426
  concurrent-ruby (~> 1.0)
427
427
  method_source (~> 1.0)
@@ -483,7 +483,7 @@ DEPENDENCIES
483
483
  gem-release
484
484
  groupdate
485
485
  hightop
486
- hotwire-livereload (~> 1.1)
486
+ hotwire-livereload (~> 1.2)
487
487
  htmlbeautifier
488
488
  httparty
489
489
  i18n-tasks (~> 1.0.12)
@@ -11,7 +11,7 @@ class Avo::ActionsComponent < ViewComponent::Base
11
11
  @exclude = exclude
12
12
  @color = color
13
13
  @style = style
14
- @label = label || t("avo.actions")
14
+ @label = label || I18n.t("avo.actions")
15
15
  end
16
16
 
17
17
  def render?
@@ -1,3 +1,3 @@
1
1
  <turbo-frame id="<%= @field.turbo_frame %>" src="<%= @field.frame_url %>" target="_top" class="block">
2
- <%= render(Avo::LoadingComponent.new(title: @field.name)) %>
2
+ <%= render(Avo::LoadingComponent.new(title: @field.plural_name)) %>
3
3
  </turbo-frame>
@@ -4,7 +4,7 @@
4
4
  </turbo-frame>
5
5
  <% else %>
6
6
  <%= render Avo::PanelComponent.new(name: @field.name) do |c| %>
7
- <% c.tools do %>
7
+ <% c.with_tools do %>
8
8
  <% if !@field.is_readonly? && !@field.is_disabled? && can_attach? %>
9
9
  <%= a_link attach_path,
10
10
  icon: 'heroicons/outline/link',
@@ -25,7 +25,7 @@
25
25
  <% end %>
26
26
  <% end %>
27
27
 
28
- <% c.body do %>
28
+ <% c.with_body do %>
29
29
  <div class="py-8 flex justify-center items-center">
30
30
  <%= empty_state by_association: params[:related_name].present? %>
31
31
  </div>
@@ -4,7 +4,7 @@
4
4
  <% end %>
5
5
  <% elsif item.is_panel? %>
6
6
  <%= render Avo::PanelComponent.new(name: item.name, description: item.description, index: index) do |c| %>
7
- <% c.body do %>
7
+ <% c.with_body do %>
8
8
  <div class="divide-y">
9
9
  <% item.visible_items.each_with_index do |field, index| %>
10
10
  <%= render field
@@ -119,7 +119,7 @@ class Avo::ResourceComponent < Avo::BaseComponent
119
119
  end
120
120
 
121
121
  if filtered_fields.present?
122
- filtered_fields.find { |f| f.id == @reflection.name }.readonly
122
+ filtered_fields.find { |f| f.id == @reflection.name }.is_readonly?
123
123
  else
124
124
  false
125
125
  end
@@ -19,7 +19,7 @@
19
19
  <%= render Avo::ReferrerParamsComponent.new back_path: back_path %>
20
20
  <%= content_tag :div, class: 'space-y-12' do %>
21
21
  <%= render Avo::PanelComponent.new(name: title, description: @resource.resource_description, display_breadcrumbs: @reflection.blank?, index: 0, data: { panel_id: "main" }) do |c| %>
22
- <% c.tools do %>
22
+ <% c.with_tools do %>
23
23
  <%= a_link back_path,
24
24
  style: :text,
25
25
  icon: 'arrow-left' do %>
@@ -56,7 +56,7 @@
56
56
  <%# Extract the main panel and display the fields here. %>
57
57
  <%# This way we'll be able to render the footer buttons under the main fields. %>
58
58
  <% if main_panel.present? %>
59
- <% c.body do %>
59
+ <% c.with_body do %>
60
60
  <div class="divide-y">
61
61
  <% main_panel.items.each_with_index do |field, index| %>
62
62
  <%= render field
@@ -69,12 +69,12 @@
69
69
  <% end %>
70
70
  <% end %>
71
71
  <% if sidebar.present? %>
72
- <% c.sidebar do %>
72
+ <% c.with_sidebar do %>
73
73
  <%= render sidebar_component form: form %>
74
74
  <% end %>
75
75
  <% end %>
76
76
  <% if Avo.configuration.buttons_on_form_footers %>
77
- <% c.footer_tools do %>
77
+ <% c.with_footer_tools do %>
78
78
  <div class="mt-4">
79
79
  <%= a_link back_path,
80
80
  style: :text,
@@ -5,7 +5,7 @@
5
5
  **@resource.stimulus_data_attributes
6
6
  } do %>
7
7
  <%= render Avo::PanelComponent.new(name: title, description: description, data: { component: 'resources-index' }, display_breadcrumbs: @reflection.blank?) do |c| %>
8
- <% c.tools do %>
8
+ <% c.with_tools do %>
9
9
  <% if can_attach? %>
10
10
  <%= a_link attach_path,
11
11
  icon: 'heroicons/outline/link',
@@ -29,7 +29,7 @@
29
29
  <% end %>
30
30
  <% end %>
31
31
  <% end %>
32
- <% c.body do %>
32
+ <% c.with_body do %>
33
33
  <div class="flex flex-col xs:flex-row xs:justify-between space-y-2 xs:space-y-0 py-4 <%= 'hidden' if @resource.search_query.nil? && @filters.empty? && available_view_types.count <= 1 %>">
34
34
  <% if show_search_input %>
35
35
  <div class="flex items-center px-4 w-64">
@@ -56,7 +56,7 @@
56
56
  <% end %>
57
57
  <% end %>
58
58
  <% end %>
59
- <% c.bare_content do %>
59
+ <% c.with_bare_content do %>
60
60
  <% if view_type.to_sym == :table %>
61
61
  <% if @models.present? %>
62
62
  <div class="mt-4">
@@ -8,7 +8,7 @@
8
8
  **@resource.stimulus_data_attributes
9
9
  } do %>
10
10
  <%= render Avo::PanelComponent.new(name: title, description: @resource.resource_description, display_breadcrumbs: @reflection.blank?, index: 0, data: { panel_id: "main" }) do |c| %>
11
- <% c.tools do %>
11
+ <% c.with_tools do %>
12
12
  <% if @resource.has_show_controls? %>
13
13
  <% @resource.render_show_controls.each do |control| %>
14
14
  <% if control.back_button? %>
@@ -155,7 +155,7 @@
155
155
  <% end %>
156
156
  <% end %>
157
157
  <% if main_panel.present? %>
158
- <% c.body do %>
158
+ <% c.with_body do %>
159
159
  <%# the overflow helps with long values %>
160
160
  <div class="divide-y overflow-auto">
161
161
  <% main_panel.items.each_with_index do |field, index| %>
@@ -169,7 +169,7 @@
169
169
  <% end %>
170
170
  <% end %>
171
171
  <% if sidebar.present? %>
172
- <% c.sidebar do %>
172
+ <% c.with_sidebar do %>
173
173
  <%= render sidebar_component %>
174
174
  <% end %>
175
175
  <% end %>
@@ -14,7 +14,7 @@
14
14
  data: @action.class.form_data_attributes do |form|
15
15
  %>
16
16
  <%= render Avo::ModalComponent.new do |c| %>
17
- <% c.heading do %>
17
+ <% c.with_heading do %>
18
18
  <%= @action.action_name %>
19
19
  <% end %>
20
20
  <div class="flex-1 flex">
@@ -33,7 +33,7 @@
33
33
  <% end %>
34
34
  </div>
35
35
  <% end %>
36
- <% c.controls do %>
36
+ <% c.with_controls do %>
37
37
  <%= a_button type: :button,
38
38
  data: { action: 'click->modal#close' },
39
39
  size: :sm,
@@ -11,7 +11,7 @@
11
11
  'turbo-frame': '_top'
12
12
  } do |form| %>
13
13
  <%= render Avo::ModalComponent.new do |c| %>
14
- <% c.heading do %>
14
+ <% c.with_heading do %>
15
15
  <%= t 'avo.choose_item', item: @related_resource.name.downcase %>
16
16
  <% end %>
17
17
 
@@ -39,7 +39,7 @@
39
39
  <% end %>
40
40
  </div>
41
41
 
42
- <% c.controls do %>
42
+ <% c.with_controls do %>
43
43
  <%= a_button 'data-action': 'click->modal#close', size: :sm, style: :outline, color: :gray do %>
44
44
  <%= t('avo.cancel') %>
45
45
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <%= render Avo::PanelComponent.new(name: @dashboard.name, description: @dashboard.description) do |c| %>
2
- <% c.bare_content do %>
2
+ <% c.with_bare_content do %>
3
3
  <% if @dashboard.items.present? %>
4
4
  <div class="min-h-24">
5
5
  <%= content_tag(:div, class: "grid gap-4 grid-cols-1 #{@dashboard.classes}") do %>
@@ -23,7 +23,7 @@
23
23
  <div class="w-full h-full">
24
24
  <% if Rails.env.development? %>
25
25
  <%= render Avo::PanelComponent.new do |c| %>
26
- <% c.body do %>
26
+ <% c.with_body do %>
27
27
  <div class="p-6">
28
28
  <%= t 'avo.empty_dashboard_message' %>. <%= link_to 'Docs', 'https://docs.avohq.io/2.0/dashboards.html', target: '_blank' %>
29
29
  </div>
@@ -15,9 +15,9 @@
15
15
  %>
16
16
  <div class="flex flex-col">
17
17
  <%= render Avo::PanelComponent.new(name: 'Debug Avo', description: 'Use this page to debug the Avo license.') do |c| %>
18
- <% c.tools do %>
18
+ <% c.with_tools do %>
19
19
  <% end %>
20
- <% c.bare_content do %>
20
+ <% c.with_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
23
  <div class="flex justify-between w-full">
@@ -1,6 +1,6 @@
1
1
  <div class="flex flex-col">
2
2
  <%= render Avo::PanelComponent.new(name: 'Welcome to Avo', description: 'This page is visible only in development. It will be hidden in other environments.') do |c| %>
3
- <% c.body do %>
3
+ <% c.with_body do %>
4
4
  <div class="flex flex-col justify-between py-6 min-h-24">
5
5
  <div class="px-6 space-y-4">
6
6
  <h3>About</h3>
@@ -1,6 +1,6 @@
1
1
  <div class="flex flex-col">
2
2
  <%= render Avo::PanelComponent.new(name: 'Welcome to Avo', description: 'This page is visible only in development. It will be hidden in other environments.') do |c| %>
3
- <% c.tools do %>
3
+ <% c.with_tools do %>
4
4
  <%= a_link('/admin', icon: 'arrow-left', color: :green, style: :primary, is_link: true) do %>
5
5
  Primary
6
6
  <% end %>
@@ -18,7 +18,7 @@
18
18
  <% end %>
19
19
  <% end %>
20
20
 
21
- <% c.body do %>
21
+ <% c.with_body do %>
22
22
  <div class="flex flex-col justify-between py-6 min-h-24">
23
23
  <%= render 'links_and_buttons' %>
24
24
  </div>
data/avo.gemspec CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
38
38
  spec.add_dependency "zeitwerk", ">= 2.6.2"
39
39
  spec.add_dependency "httparty"
40
40
  spec.add_dependency "active_link_to"
41
- spec.add_dependency "view_component"
41
+ spec.add_dependency "view_component", ">= 2.54.0"
42
42
  spec.add_dependency "turbo-rails"
43
43
  spec.add_dependency "addressable"
44
44
  spec.add_dependency "meta-tags"
data/lib/avo/app.rb CHANGED
@@ -63,7 +63,7 @@ module Avo
63
63
  if Rails::VERSION::MAJOR === 6
64
64
  ActiveStorage::Current.host = request.base_url
65
65
  elsif Rails::VERSION::MAJOR === 7
66
- ActiveStorage::Current.url_options = request.base_url
66
+ ActiveStorage::Current.url_options = {protocol: request.protocol, host: request.host, port: request.port}
67
67
  end
68
68
  end
69
69
  rescue => exception
@@ -0,0 +1,31 @@
1
+ module Avo
2
+ module Concerns
3
+ module PolicyHelpers
4
+ extend ActiveSupport::Concern
5
+
6
+ class_methods do
7
+ def inherit_association_from_policy(association_name, policy_class)
8
+ [:create, :edit, :update, :destroy, :show, :reorder, :act_on].each do |method_action|
9
+ define_policy_method(method_action, association_name, policy_class)
10
+ end
11
+
12
+ define_policy_method("view", association_name, policy_class, "index")
13
+ end
14
+
15
+ private
16
+
17
+ # Define a method for the given action and association name.
18
+ # Call the policy class with the given action passing the user and record.
19
+ # Example:
20
+ # def create_team_members?
21
+ # TeamMemberPolicy.new(user, record).create?
22
+ # end
23
+ def define_policy_method(method_action, association_name, policy_class, policy_action = method_action)
24
+ define_method "#{method_action}_#{association_name}?" do
25
+ policy_class.new(user, record).send "#{policy_action}?"
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
data/lib/avo/engine.rb CHANGED
@@ -14,11 +14,6 @@ Gem.loaded_specs["avo"].dependencies.each do |d|
14
14
  end
15
15
  end
16
16
 
17
- # In development we should load the engine so we get the autoload for components
18
- if ENV["RAILS_ENV"] === "development"
19
- require "view_component/engine"
20
- end
21
-
22
17
  module Avo
23
18
  class Engine < ::Rails::Engine
24
19
  isolate_namespace Avo
@@ -85,7 +85,6 @@ module Avo
85
85
 
86
86
  @args = args
87
87
 
88
- @updatable = !readonly
89
88
  @computable = true
90
89
  @computed = block.present?
91
90
  @computed_value = nil
@@ -257,7 +256,7 @@ module Avo
257
256
  end
258
257
 
259
258
  def updatable
260
- @updatable && visible?
259
+ !is_readonly? && visible?
261
260
  end
262
261
 
263
262
  private
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.30.2" unless const_defined?(:VERSION)
2
+ VERSION = "2.31.0" unless const_defined?(:VERSION)
3
3
  end
@@ -1,12 +1,12 @@
1
1
  <div class="flex flex-col">
2
2
  <%%= render Avo::PanelComponent.new(name: "<%= human_name %>") do |c| %>
3
- <%% c.tools do %>
3
+ <%% c.with_tools do %>
4
4
  <%%= a_link('/avo', icon: 'heroicons/solid/academic-cap', color: :primary, style: :primary) do %>
5
5
  Dummy link
6
6
  <%% end %>
7
7
  <%% end %>
8
8
 
9
- <%% c.body do %>
9
+ <%% c.with_body do %>
10
10
  <div class="flex flex-col p-4 min-h-24">
11
11
  <div class="space-y-4">
12
12
  <h3>🪧 This partial is waiting to be updated</h3>
@@ -1,10 +1,10 @@
1
1
  <div class="flex flex-col">
2
2
  <%%= render Avo::PanelComponent.new(name: '<%= human_name %>', display_breadcrumbs: true) do |c| %>
3
- <%% c.tools do %>
3
+ <%% c.with_tools do %>
4
4
  <div class="text-sm italic">This is the panels tools section.</div>
5
5
  <%% end %>
6
6
 
7
- <%% c.body do %>
7
+ <%% c.with_body do %>
8
8
  <div class="flex flex-col justify-between py-6 min-h-24">
9
9
  <div class="px-6 space-y-4">
10
10
  <h3>What a nice new tool 👋</h3>
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.30.2
4
+ version: 2.31.0
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-04-18 00:00:00.000000000 Z
12
+ date: 2023-04-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -101,14 +101,14 @@ dependencies:
101
101
  requirements:
102
102
  - - ">="
103
103
  - !ruby/object:Gem::Version
104
- version: '0'
104
+ version: 2.54.0
105
105
  type: :runtime
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
- version: '0'
111
+ version: 2.54.0
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: turbo-rails
114
114
  requirement: !ruby/object:Gem::Requirement
@@ -1726,6 +1726,7 @@ files:
1726
1726
  - lib/avo/concerns/has_stimulus_controllers.rb
1727
1727
  - lib/avo/concerns/is_resource_item.rb
1728
1728
  - lib/avo/concerns/model_class_constantized.rb
1729
+ - lib/avo/concerns/policy_helpers.rb
1729
1730
  - lib/avo/concerns/visible_in_dashboard.rb
1730
1731
  - lib/avo/concerns/visible_items.rb
1731
1732
  - lib/avo/configuration.rb