avo 1.17.1 → 1.18.0.pre.1

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.

Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +13 -13
  4. data/app/components/avo/fields/common/multiple_file_viewer_component.rb +2 -1
  5. data/app/components/avo/fields/common/single_file_viewer_component.rb +2 -1
  6. data/app/components/avo/fields/file_field/edit_component.html.erb +1 -1
  7. data/app/components/avo/fields/files_field/edit_component.html.erb +1 -1
  8. data/app/packs/entrypoints/application.js +2 -0
  9. data/config/routes.rb +1 -0
  10. data/lib/avo/app.rb +2 -2
  11. data/lib/avo/engine.rb +0 -1
  12. data/lib/avo/fields/date_time_field.rb +1 -1
  13. data/lib/avo/fields/file_field.rb +2 -0
  14. data/lib/avo/fields/files_field.rb +7 -0
  15. data/lib/avo/version.rb +1 -1
  16. data/lib/generators/avo/templates/filters/boolean_filter.tt +1 -1
  17. data/public/avo-packs/css/application-2b4685ca.css.map +1 -1
  18. data/public/avo-packs/css/application-2b4685ca.css.map.br +0 -0
  19. data/public/avo-packs/css/application-2b4685ca.css.map.gz +0 -0
  20. data/public/avo-packs/js/application-6842378de4da9b615e18.js +26 -0
  21. data/public/avo-packs/js/{application-1f1c66b45a54b2d06bfe.js.LICENSE.txt → application-6842378de4da9b615e18.js.LICENSE.txt} +0 -0
  22. data/public/avo-packs/js/application-6842378de4da9b615e18.js.br +0 -0
  23. data/public/avo-packs/js/application-6842378de4da9b615e18.js.gz +0 -0
  24. data/public/avo-packs/js/application-6842378de4da9b615e18.js.map +1 -0
  25. data/public/avo-packs/js/application-6842378de4da9b615e18.js.map.br +0 -0
  26. data/public/avo-packs/js/application-6842378de4da9b615e18.js.map.gz +0 -0
  27. data/public/avo-packs/manifest.json +8 -8
  28. metadata +11 -11
  29. data/public/avo-packs/js/application-1f1c66b45a54b2d06bfe.js +0 -26
  30. data/public/avo-packs/js/application-1f1c66b45a54b2d06bfe.js.br +0 -0
  31. data/public/avo-packs/js/application-1f1c66b45a54b2d06bfe.js.gz +0 -0
  32. data/public/avo-packs/js/application-1f1c66b45a54b2d06bfe.js.map +0 -1
  33. data/public/avo-packs/js/application-1f1c66b45a54b2d06bfe.js.map.br +0 -0
  34. data/public/avo-packs/js/application-1f1c66b45a54b2d06bfe.js.map.gz +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f979b13adfa02e58a8d2b3b4f6463d0fcef9200cdc4a4dee76b268ebc5a5e8b0
4
- data.tar.gz: acdddcbb5516ffd36f1538877472f4f8a4ec5f2423a4ddea69b7eed5b156c308
3
+ metadata.gz: ccd552281f8ac8b77ea15f6d9000271a447a01190cb3c46905898f94df366009
4
+ data.tar.gz: c97173ac80821f5ef2de0f3d1060be50fe1c3b2c19d1b2f8eb177c9fc750f2d2
5
5
  SHA512:
6
- metadata.gz: '050786326a44c661a9c3467cf9f5b3ed5df27a8b713040a9126be15f96b3fcf553b8cd7c7f23fe01339665eac1f41d2a203fca4c3c671676c28b9c6efaf18cb9'
7
- data.tar.gz: 417a94817cdad9255904bbff41dc5aa911b2dfa02c31ac2f1d2deb46c6038e7a563d802ad0d2b4533e6001e06d455b2fd9cf48a47c2556539e143f48b95ff6ee
6
+ metadata.gz: 84703917f0960fb186bd79b5b7463298afd544e625f0b9ef83af6373c56d673e22479c2e88528cd2df1add04bd2ced0c31d50ea4bc6d856cfb26dd00a07cac42
7
+ data.tar.gz: f0e6a6d3b59bf79dac877bb012da1f56c979bf72897241e0f9d1633c7745e7fc1ce769d72610105d42b1e37d4a86f19e8a1e39370e709a2be24869a4b7a20981
data/Gemfile CHANGED
@@ -115,7 +115,7 @@ gem "hotwire-rails"
115
115
 
116
116
  gem "active_link_to"
117
117
 
118
- gem "view_component", require: "view_component/engine"
118
+ gem "view_component"
119
119
 
120
120
  gem "addressable"
121
121
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (1.17.1)
4
+ avo (1.18.0.pre.1)
5
5
  active_link_to
6
6
  addressable
7
7
  breadcrumbs_on_rails
@@ -107,7 +107,7 @@ GEM
107
107
  aws-eventstream (~> 1, >= 1.0.2)
108
108
  bcrypt (3.1.16)
109
109
  bindex (0.8.1)
110
- bootsnap (1.7.3)
110
+ bootsnap (1.9.3)
111
111
  msgpack (~> 1.0)
112
112
  breadcrumbs_on_rails (4.0.0)
113
113
  rails (>= 5.0)
@@ -123,7 +123,7 @@ GEM
123
123
  regexp_parser (~> 1.5)
124
124
  xpath (~> 3.2)
125
125
  childprocess (3.0.0)
126
- concurrent-ruby (1.1.8)
126
+ concurrent-ruby (1.1.9)
127
127
  countries (3.1.0)
128
128
  i18n_data (~> 0.11.0)
129
129
  sixarm_ruby_unaccent (~> 1.1)
@@ -131,7 +131,7 @@ GEM
131
131
  crack (0.4.4)
132
132
  crass (1.0.6)
133
133
  database_cleaner (1.8.5)
134
- devise (4.7.3)
134
+ devise (4.8.1)
135
135
  bcrypt (~> 3.0)
136
136
  orm_adapter (~> 0.1)
137
137
  railties (>= 4.1.0)
@@ -168,7 +168,7 @@ GEM
168
168
  httparty (0.18.1)
169
169
  mime-types (~> 3.0)
170
170
  multi_xml (>= 0.5.2)
171
- i18n (1.8.10)
171
+ i18n (1.8.11)
172
172
  concurrent-ruby (~> 1.0)
173
173
  i18n_data (0.11.0)
174
174
  image_processing (1.12.1)
@@ -184,7 +184,7 @@ GEM
184
184
  listen (3.5.1)
185
185
  rb-fsevent (~> 0.10, >= 0.10.3)
186
186
  rb-inotify (~> 0.9, >= 0.9.10)
187
- loofah (2.9.1)
187
+ loofah (2.13.0)
188
188
  crass (~> 1.0.2)
189
189
  nokogiri (>= 1.5.9)
190
190
  mail (2.7.1)
@@ -202,7 +202,7 @@ GEM
202
202
  mini_magick (4.11.0)
203
203
  mini_mime (1.0.3)
204
204
  mini_portile2 (2.6.1)
205
- minitest (5.14.4)
205
+ minitest (5.15.0)
206
206
  msgpack (1.4.2)
207
207
  multi_xml (0.6.0)
208
208
  nio4r (2.5.8)
@@ -210,7 +210,7 @@ GEM
210
210
  mini_portile2 (~> 2.6.1)
211
211
  racc (~> 1.4)
212
212
  orm_adapter (0.5.0)
213
- pagy (4.11.0)
213
+ pagy (5.6.6)
214
214
  parallel (1.20.1)
215
215
  parser (3.0.0.0)
216
216
  ast (~> 2.4.1)
@@ -220,7 +220,7 @@ GEM
220
220
  nio4r (~> 2.0)
221
221
  pundit (2.1.0)
222
222
  activesupport (>= 3.0.0)
223
- racc (1.5.2)
223
+ racc (1.6.0)
224
224
  rack (2.2.3)
225
225
  rack-proxy (0.6.5)
226
226
  rack
@@ -248,7 +248,7 @@ GEM
248
248
  rails-dom-testing (2.0.3)
249
249
  activesupport (>= 4.2.0)
250
250
  nokogiri (>= 1.6)
251
- rails-html-sanitizer (1.3.0)
251
+ rails-html-sanitizer (1.4.2)
252
252
  loofah (~> 2.3)
253
253
  railties (6.1.3.2)
254
254
  actionpack (= 6.1.3.2)
@@ -257,7 +257,7 @@ GEM
257
257
  rake (>= 0.8.7)
258
258
  thor (~> 1.0)
259
259
  rainbow (3.0.0)
260
- rake (13.0.3)
260
+ rake (13.0.6)
261
261
  ransack (2.4.2)
262
262
  activerecord (>= 5.2.4)
263
263
  activesupport (>= 5.2.4)
@@ -379,7 +379,7 @@ GEM
379
379
  websocket-extensions (0.1.5)
380
380
  xpath (3.2.0)
381
381
  nokogiri (~> 1.8)
382
- zeitwerk (2.4.2)
382
+ zeitwerk (2.5.2)
383
383
 
384
384
  PLATFORMS
385
385
  ruby
@@ -439,4 +439,4 @@ DEPENDENCIES
439
439
  zeitwerk (~> 2.3)
440
440
 
441
441
  BUNDLED WITH
442
- 2.2.29
442
+ 2.2.32
@@ -3,10 +3,11 @@
3
3
  class Avo::Fields::Common::MultipleFileViewerComponent < ViewComponent::Base
4
4
  include Avo::ApplicationHelper
5
5
 
6
- def initialize(id:, file:, is_image:, resource:, button_size: :md)
6
+ def initialize(id:, file:, is_image:, direct_upload: false, resource:, button_size: :md)
7
7
  @id = id
8
8
  @file = file
9
9
  @is_image = is_image
10
+ @direct_upload = direct_upload
10
11
  @button_size = button_size
11
12
  @resource = resource
12
13
  end
@@ -3,10 +3,11 @@
3
3
  class Avo::Fields::Common::SingleFileViewerComponent < ViewComponent::Base
4
4
  include Avo::ApplicationHelper
5
5
 
6
- def initialize(id:, file:, is_image:, resource:, button_size: :md)
6
+ def initialize(id:, file:, is_image:, direct_upload: false, resource:, button_size: :md)
7
7
  @id = id
8
8
  @file = file
9
9
  @is_image = is_image
10
+ @direct_upload = direct_upload
10
11
  @button_size = button_size
11
12
  @resource = resource
12
13
  end
@@ -6,6 +6,6 @@
6
6
  <% end %>
7
7
 
8
8
  <% if @resource.authorization.authorize_action(:upload_attachments?, raise_exception: false) %>
9
- <%= @form.file_field @field.id, disabled: @field.readonly %>
9
+ <%= @form.file_field @field.id, disabled: @field.readonly, direct_upload: @field.direct_upload %>
10
10
  <% end %>
11
11
  <% end %>
@@ -2,6 +2,6 @@
2
2
  <%= render Avo::Fields::Common::FilesListViewerComponent.new(field: @field, resource: @resource) if @field.value.present? %>
3
3
 
4
4
  <% if @resource.authorization.authorize_action(:upload_attachments?, raise_exception: false) %>
5
- <%= @form.file_field @field.id, disabled: @field.readonly, multiple: true %>
5
+ <%= @form.file_field @field.id, disabled: @field.readonly, multiple: true, direct_upload: @field.direct_upload %>
6
6
  <% end %>
7
7
  <% end %>
@@ -2,6 +2,7 @@
2
2
  import 'core-js/stable'
3
3
  // eslint-disable-next-line import/no-extraneous-dependencies
4
4
  import 'regenerator-runtime/runtime'
5
+ import * as ActiveStorage from '@rails/activestorage'
5
6
  import * as Mousetrap from 'mousetrap'
6
7
  import { Application } from 'stimulus'
7
8
  import { Turbo } from '@hotwired/turbo-rails'
@@ -32,6 +33,7 @@ function initTippy() {
32
33
  window.initTippy = initTippy
33
34
 
34
35
  const application = Application.start()
36
+ ActiveStorage.start()
35
37
 
36
38
  const context = require.context('./../js/controllers', true, /\.js$/)
37
39
  application.load(definitionsFromContext(context))
data/config/routes.rb CHANGED
@@ -2,6 +2,7 @@ Avo::Engine.routes.draw do
2
2
  root "home#index"
3
3
 
4
4
  get "resources", to: redirect("/admin")
5
+ post "/rails/active_storage/direct_uploads", to: "/active_storage/direct_uploads#create"
5
6
 
6
7
  scope "avo_api", as: "avo_api" do
7
8
  get "/search", to: "search#index"
data/lib/avo/app.rb CHANGED
@@ -32,9 +32,9 @@ module Avo
32
32
 
33
33
  # Set the current host for ActiveStorage
34
34
  begin
35
- ActiveStorage::Current.host = request.base_url
35
+ ActiveStorage::Current.url_options = request.base_url
36
36
  rescue => exception
37
- Rails.logger.debug "[Avo] Failed to set ActiveStorage::Current.host, #{exception.inspect}"
37
+ Rails.logger.debug "[Avo] Failed to set ActiveStorage::Current.url_options, #{exception.inspect}"
38
38
  end
39
39
 
40
40
  init_resources
data/lib/avo/engine.rb CHANGED
@@ -2,7 +2,6 @@
2
2
  Gem.loaded_specs["avo"].dependencies.each do |d|
3
3
  require d.name
4
4
  end
5
- require "view_component/engine"
6
5
 
7
6
  module Avo
8
7
  class Engine < ::Rails::Engine
@@ -17,7 +17,7 @@ module Avo
17
17
  return nil if value.nil?
18
18
 
19
19
  if @format.is_a?(Symbol)
20
- value.to_time.in_time_zone(timezone).to_s(@format)
20
+ value.to_time.in_time_zone(timezone).to_formatted_s(@format)
21
21
  else
22
22
  value.to_time.in_time_zone(timezone).strftime(@format)
23
23
  end
@@ -4,6 +4,7 @@ module Avo
4
4
  attr_accessor :link_to_resource
5
5
  attr_accessor :is_avatar
6
6
  attr_accessor :is_image
7
+ attr_accessor :direct_upload
7
8
 
8
9
  def initialize(id, **args, &block)
9
10
  super(id, **args, &block)
@@ -11,6 +12,7 @@ module Avo
11
12
  @link_to_resource = args[:link_to_resource].present? ? args[:link_to_resource] : false
12
13
  @is_avatar = args[:is_avatar].present? ? args[:is_avatar] : false
13
14
  @is_image = args[:is_image].present? ? args[:is_image] : @is_avatar
15
+ @direct_upload = args[:direct_upload].present? ? args[:direct_upload] : false
14
16
  end
15
17
 
16
18
  def path
@@ -2,11 +2,13 @@ module Avo
2
2
  module Fields
3
3
  class FilesField < BaseField
4
4
  attr_accessor :is_image
5
+ attr_accessor :direct_upload
5
6
 
6
7
  def initialize(id, **args, &block)
7
8
  super(id, **args, &block)
8
9
 
9
10
  @is_image = args[:is_image].present? ? args[:is_image] : @is_avatar
11
+ @direct_upload = args[:direct_upload].present? ? args[:direct_upload] : false
10
12
  end
11
13
 
12
14
  def view_component_name
@@ -21,6 +23,11 @@ module Avo
21
23
  return model unless model.methods.include? key.to_sym
22
24
 
23
25
  value.each do |file|
26
+ # Skip empty values
27
+ next unless file.present?
28
+ # Skip Capybara Nil files in tests
29
+ next unless file.class === Capybara::RackTest::Form::NilUploadedFile
30
+
24
31
  model.send(key).attach file
25
32
  end
26
33
 
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "1.17.1"
2
+ VERSION = "1.18.0.pre.1"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  class <%= class_name.camelize %> < Avo::Filters::BooleanFilter
2
2
  self.name = '<%= name.underscore.humanize %>'
3
3
 
4
- def apply(request, query, value)
4
+ def apply(request, query, values)
5
5
  query
6
6
  end
7
7