avo 1.0.1 → 1.1.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.

Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -3
  3. data/Gemfile.lock +73 -70
  4. data/README.md +3 -1
  5. data/app/components/avo/edit/fields/belongs_to_field_component.html.erb +0 -1
  6. data/app/components/avo/edit/fields/belongs_to_field_component.rb +7 -0
  7. data/app/components/avo/views/resource_index_component.html.erb +2 -2
  8. data/app/controllers/avo/application_controller.rb +7 -8
  9. data/app/helpers/avo/application_helper.rb +0 -24
  10. data/{lib/generators/avo/templates → app/views/avo}/partials/_scripts.html.erb +0 -0
  11. data/app/views/avo/sidebar/_sidebar.html.erb +11 -2
  12. data/app/views/layouts/avo/application.html.erb +3 -3
  13. data/config/webpacker.yml +12 -1
  14. data/lib/avo/app.rb +14 -1
  15. data/lib/avo/base_resource.rb +11 -12
  16. data/lib/avo/fields/belongs_to_field.rb +0 -2
  17. data/lib/avo/version.rb +1 -1
  18. data/lib/generators/avo/eject_generator.rb +55 -0
  19. data/lib/generators/avo/templates/tool/controller.tt +2 -0
  20. data/lib/generators/avo/templates/tool/sidebar_item.tt +1 -0
  21. data/lib/generators/avo/templates/tool/view.tt +27 -0
  22. data/lib/generators/avo/tool_generator.rb +60 -0
  23. data/public/avo-packs/css/application-9d115b7e.css.map +1 -1
  24. data/public/avo-packs/css/application-9d115b7e.css.map.br +0 -0
  25. data/public/avo-packs/css/application-9d115b7e.css.map.gz +0 -0
  26. metadata +8 -8
  27. data/config/webpacker_packed.yml +0 -79
  28. data/lib/generators/avo/partials_generator.rb +0 -14
  29. data/lib/generators/avo/templates/partials/_footer.html.erb +0 -3
  30. data/lib/generators/avo/templates/partials/_header.html.erb +0 -1
  31. data/lib/generators/avo/templates/partials/_logo.html.erb +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9fdcf5553b07360ef48d362721aabb8ee87e9e1d4289e30a8f141851445ebde3
4
- data.tar.gz: c3121bdfbbeeeca0f06d059824ed9d6405dfca16f71b443433e697dea7a8d5ff
3
+ metadata.gz: 1535b91dc05b50bd35b9842c10c5ed266edaec91eced513b8102776637f21fd2
4
+ data.tar.gz: b1ed85745075ff3aac0f32170c39323a6b070b38649d43470222cc56d554cff9
5
5
  SHA512:
6
- metadata.gz: 8bcd1bea917df6700908215c57766c1c071ce1398e75681cdaef9f751feefbe3941fba5539ff4d52bdacd964993dd2579d1d63920cf8a6dbee4f9ffeb28fbab8
7
- data.tar.gz: 1d3ee22e3f143294bc477b7a8c0e0070f63f5846a707272bd14d71cbad5722c3f3c3e24b917b8564e3585ad684a1aed702ba687d88463d2908c351d1731cf99b
6
+ metadata.gz: 14461575f33ab286f132e5b1965c2b504f30edec5ec97cb8695333f63ba93ee08ac9dcb91b1a54fc5cf4421e850018b5298cc76d79586674b5eca722fd1fa30b
7
+ data.tar.gz: c845a9413d258f181a40ea7b0ec816ce2c267c1e0c2d369d131c610e4d65085169945482cd3746de0cc5bb85d7eade7f9ef05cd28a75f2e183a9b938e09c7c36
data/Gemfile CHANGED
@@ -106,9 +106,6 @@ end
106
106
 
107
107
  gem "zeitwerk", "~> 2.3"
108
108
 
109
- # Pagination
110
- gem "pagy"
111
-
112
109
  gem "httparty"
113
110
 
114
111
  gem "iso"
@@ -120,3 +117,5 @@ gem "active_link_to"
120
117
  gem "view_component", require: "view_component/engine"
121
118
 
122
119
  gem "addressable"
120
+
121
+ gem "appraisal"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (1.0.1)
4
+ avo (1.1.0)
5
5
  active_link_to
6
6
  addressable
7
7
  countries
@@ -18,38 +18,38 @@ PATH
18
18
  GEM
19
19
  remote: https://rubygems.org/
20
20
  specs:
21
- actioncable (6.0.3.5)
22
- actionpack (= 6.0.3.5)
21
+ actioncable (6.0.3.6)
22
+ actionpack (= 6.0.3.6)
23
23
  nio4r (~> 2.0)
24
24
  websocket-driver (>= 0.6.1)
25
- actionmailbox (6.0.3.5)
26
- actionpack (= 6.0.3.5)
27
- activejob (= 6.0.3.5)
28
- activerecord (= 6.0.3.5)
29
- activestorage (= 6.0.3.5)
30
- activesupport (= 6.0.3.5)
25
+ actionmailbox (6.0.3.6)
26
+ actionpack (= 6.0.3.6)
27
+ activejob (= 6.0.3.6)
28
+ activerecord (= 6.0.3.6)
29
+ activestorage (= 6.0.3.6)
30
+ activesupport (= 6.0.3.6)
31
31
  mail (>= 2.7.1)
32
- actionmailer (6.0.3.5)
33
- actionpack (= 6.0.3.5)
34
- actionview (= 6.0.3.5)
35
- activejob (= 6.0.3.5)
32
+ actionmailer (6.0.3.6)
33
+ actionpack (= 6.0.3.6)
34
+ actionview (= 6.0.3.6)
35
+ activejob (= 6.0.3.6)
36
36
  mail (~> 2.5, >= 2.5.4)
37
37
  rails-dom-testing (~> 2.0)
38
- actionpack (6.0.3.5)
39
- actionview (= 6.0.3.5)
40
- activesupport (= 6.0.3.5)
38
+ actionpack (6.0.3.6)
39
+ actionview (= 6.0.3.6)
40
+ activesupport (= 6.0.3.6)
41
41
  rack (~> 2.0, >= 2.0.8)
42
42
  rack-test (>= 0.6.3)
43
43
  rails-dom-testing (~> 2.0)
44
44
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
45
- actiontext (6.0.3.5)
46
- actionpack (= 6.0.3.5)
47
- activerecord (= 6.0.3.5)
48
- activestorage (= 6.0.3.5)
49
- activesupport (= 6.0.3.5)
45
+ actiontext (6.0.3.6)
46
+ actionpack (= 6.0.3.6)
47
+ activerecord (= 6.0.3.6)
48
+ activestorage (= 6.0.3.6)
49
+ activesupport (= 6.0.3.6)
50
50
  nokogiri (>= 1.8.5)
51
- actionview (6.0.3.5)
52
- activesupport (= 6.0.3.5)
51
+ actionview (6.0.3.6)
52
+ activesupport (= 6.0.3.6)
53
53
  builder (~> 3.1)
54
54
  erubi (~> 1.4)
55
55
  rails-dom-testing (~> 2.0)
@@ -57,20 +57,20 @@ GEM
57
57
  active_link_to (1.0.5)
58
58
  actionpack
59
59
  addressable
60
- activejob (6.0.3.5)
61
- activesupport (= 6.0.3.5)
60
+ activejob (6.0.3.6)
61
+ activesupport (= 6.0.3.6)
62
62
  globalid (>= 0.3.6)
63
- activemodel (6.0.3.5)
64
- activesupport (= 6.0.3.5)
65
- activerecord (6.0.3.5)
66
- activemodel (= 6.0.3.5)
67
- activesupport (= 6.0.3.5)
68
- activestorage (6.0.3.5)
69
- actionpack (= 6.0.3.5)
70
- activejob (= 6.0.3.5)
71
- activerecord (= 6.0.3.5)
72
- marcel (~> 0.3.1)
73
- activesupport (6.0.3.5)
63
+ activemodel (6.0.3.6)
64
+ activesupport (= 6.0.3.6)
65
+ activerecord (6.0.3.6)
66
+ activemodel (= 6.0.3.6)
67
+ activesupport (= 6.0.3.6)
68
+ activestorage (6.0.3.6)
69
+ actionpack (= 6.0.3.6)
70
+ activejob (= 6.0.3.6)
71
+ activerecord (= 6.0.3.6)
72
+ marcel (~> 1.0.0)
73
+ activesupport (6.0.3.6)
74
74
  concurrent-ruby (~> 1.0, >= 1.0.2)
75
75
  i18n (>= 0.7, < 2)
76
76
  minitest (~> 5.1)
@@ -78,6 +78,10 @@ GEM
78
78
  zeitwerk (~> 2.2, >= 2.2.2)
79
79
  addressable (2.7.0)
80
80
  public_suffix (>= 2.0.2, < 5.0)
81
+ appraisal (2.4.0)
82
+ bundler
83
+ rake
84
+ thor (>= 0.14.0)
81
85
  ast (2.4.2)
82
86
  bcrypt (3.1.16)
83
87
  bindex (0.8.1)
@@ -96,8 +100,8 @@ GEM
96
100
  xpath (~> 3.2)
97
101
  childprocess (3.0.0)
98
102
  concurrent-ruby (1.1.8)
99
- countries (3.0.1)
100
- i18n_data (~> 0.10.0)
103
+ countries (3.1.0)
104
+ i18n_data (~> 0.11.0)
101
105
  sixarm_ruby_unaccent (~> 1.1)
102
106
  unicode_utils (~> 1.4)
103
107
  crack (0.4.4)
@@ -123,7 +127,7 @@ GEM
123
127
  railties (>= 5.0.0)
124
128
  faker (2.14.0)
125
129
  i18n (>= 1.6, < 2)
126
- ffi (1.13.1)
130
+ ffi (1.15.0)
127
131
  fuubar (2.5.0)
128
132
  rspec-core (~> 3.0)
129
133
  ruby-progressbar (~> 1.4)
@@ -138,9 +142,9 @@ GEM
138
142
  httparty (0.18.1)
139
143
  mime-types (~> 3.0)
140
144
  multi_xml (>= 0.5.2)
141
- i18n (1.8.9)
145
+ i18n (1.8.10)
142
146
  concurrent-ruby (~> 1.0)
143
- i18n_data (0.10.0)
147
+ i18n_data (0.11.0)
144
148
  image_processing (1.12.1)
145
149
  mini_magick (>= 4.9.5, < 5)
146
150
  ruby-vips (>= 2.0.17, < 3)
@@ -156,27 +160,25 @@ GEM
156
160
  nokogiri (>= 1.5.9)
157
161
  mail (2.7.1)
158
162
  mini_mime (>= 0.1.1)
159
- marcel (0.3.3)
160
- mimemagic (~> 0.3.2)
163
+ marcel (1.0.0)
161
164
  method_source (1.0.0)
162
165
  mime-types (3.3.1)
163
166
  mime-types-data (~> 3.2015)
164
- mime-types-data (3.2020.0512)
165
- mimemagic (0.3.10)
166
- nokogiri (~> 1)
167
- rake
167
+ mime-types-data (3.2021.0225)
168
168
  mini_magick (4.11.0)
169
- mini_mime (1.0.2)
169
+ mini_mime (1.0.3)
170
170
  mini_portile2 (2.5.0)
171
171
  minitest (5.14.4)
172
172
  msgpack (1.3.3)
173
173
  multi_xml (0.6.0)
174
- nio4r (2.5.5)
174
+ nio4r (2.5.7)
175
175
  nokogiri (1.11.2)
176
176
  mini_portile2 (~> 2.5.0)
177
177
  racc (~> 1.4)
178
+ nokogiri (1.11.2-x86_64-linux)
179
+ racc (~> 1.4)
178
180
  orm_adapter (0.5.0)
179
- pagy (3.10.0)
181
+ pagy (3.12.0)
180
182
  parallel (1.20.1)
181
183
  parser (3.0.0.0)
182
184
  ast (~> 2.4.1)
@@ -192,20 +194,20 @@ GEM
192
194
  rack
193
195
  rack-test (1.1.0)
194
196
  rack (>= 1.0, < 3)
195
- rails (6.0.3.5)
196
- actioncable (= 6.0.3.5)
197
- actionmailbox (= 6.0.3.5)
198
- actionmailer (= 6.0.3.5)
199
- actionpack (= 6.0.3.5)
200
- actiontext (= 6.0.3.5)
201
- actionview (= 6.0.3.5)
202
- activejob (= 6.0.3.5)
203
- activemodel (= 6.0.3.5)
204
- activerecord (= 6.0.3.5)
205
- activestorage (= 6.0.3.5)
206
- activesupport (= 6.0.3.5)
197
+ rails (6.0.3.6)
198
+ actioncable (= 6.0.3.6)
199
+ actionmailbox (= 6.0.3.6)
200
+ actionmailer (= 6.0.3.6)
201
+ actionpack (= 6.0.3.6)
202
+ actiontext (= 6.0.3.6)
203
+ actionview (= 6.0.3.6)
204
+ activejob (= 6.0.3.6)
205
+ activemodel (= 6.0.3.6)
206
+ activerecord (= 6.0.3.6)
207
+ activestorage (= 6.0.3.6)
208
+ activesupport (= 6.0.3.6)
207
209
  bundler (>= 1.3.0)
208
- railties (= 6.0.3.5)
210
+ railties (= 6.0.3.6)
209
211
  sprockets-rails (>= 2.0.0)
210
212
  rails-controller-testing (1.0.5)
211
213
  actionpack (>= 5.0.1.rc1)
@@ -216,9 +218,9 @@ GEM
216
218
  nokogiri (>= 1.6)
217
219
  rails-html-sanitizer (1.3.0)
218
220
  loofah (~> 2.3)
219
- railties (6.0.3.5)
220
- actionpack (= 6.0.3.5)
221
- activesupport (= 6.0.3.5)
221
+ railties (6.0.3.6)
222
+ actionpack (= 6.0.3.6)
223
+ activesupport (= 6.0.3.6)
222
224
  method_source
223
225
  rake (>= 0.8.7)
224
226
  thor (>= 0.20.3, < 2.0)
@@ -266,8 +268,8 @@ GEM
266
268
  ruby-debug-ide (0.7.2)
267
269
  rake (>= 0.8.1)
268
270
  ruby-progressbar (1.10.1)
269
- ruby-vips (2.0.17)
270
- ffi (~> 1.9)
271
+ ruby-vips (2.1.0)
272
+ ffi (~> 1.12)
271
273
  rubyzip (2.3.0)
272
274
  sass-rails (6.0.0)
273
275
  sassc-rails (~> 2.1, >= 2.1.1)
@@ -346,10 +348,12 @@ GEM
346
348
 
347
349
  PLATFORMS
348
350
  ruby
351
+ x86_64-linux
349
352
 
350
353
  DEPENDENCIES
351
354
  active_link_to
352
355
  addressable
356
+ appraisal
353
357
  avo!
354
358
  bootsnap (>= 1.4.2)
355
359
  bump
@@ -369,7 +373,6 @@ DEPENDENCIES
369
373
  iso
370
374
  jbuilder (~> 2.7)
371
375
  listen (>= 3.3.0)
372
- pagy
373
376
  pg (>= 0.18, < 2.0)
374
377
  puma (~> 4.3.5)
375
378
  pundit
@@ -394,4 +397,4 @@ DEPENDENCIES
394
397
  zeitwerk (~> 2.3)
395
398
 
396
399
  BUNDLED WITH
397
- 2.2.15
400
+ 2.2.5
data/README.md CHANGED
@@ -15,10 +15,12 @@ Avo is a beautiful next-generation framework that empowers you, the developer, t
15
15
  **Documentation**: [docs.avohq.io](https://docs.avohq.io)\
16
16
  **Twitter**: [avo_hq](https://twitter.com/avo_hq)\
17
17
  **Community chat**: [discord](https://discord.gg/pkTF6y8)\
18
- **Issue tracker**: [GitHub issues](http://github.com/avo-hq/avo/issues)
18
+ **Issue tracker**: [GitHub issues](http://github.com/avo-hq/avo/issues)\
19
+ **Discussions and feature requests**: [GitHub issues](http://github.com/avo-hq/avo/discussions)
19
20
 
20
21
  ## Features
21
22
 
23
+ - **Powered by Hotwire** - Rails ❤️ Hotwire
22
24
  - **Code driven configuration** - Configure your Rails dashboard entirely by writing Ruby code.
23
25
  - **Resource Management** - Create a CRUD interface for Active Record from one command. No more copy-pasting view and controller files around.
24
26
  - **Active Storage support** - Amazingly easy, **one-line**, single or multi-file integration with **ActiveStorage**.
@@ -1,5 +1,4 @@
1
1
  <%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
2
- <% disabled = @field.readonly || params[:via_resource_id] %>
3
2
  <%= @form.select @field.foreign_key, @field.options.map { |o| [o[:label], o[:value]] },
4
3
  {
5
4
  include_blank: @field.placeholder,
@@ -1,4 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Avo::Edit::Fields::BelongsToFieldComponent < Avo::Edit::Fields::FieldComponent
4
+ def disabled
5
+ return true if @field.readonly
6
+ return true if @field.target_resource.model_class.name == params[:via_resource_class]
7
+ return true if @field.id.to_s == params[:via_relation].to_s
8
+
9
+ false
10
+ end
4
11
  end
@@ -43,7 +43,7 @@
43
43
 
44
44
  <% if @models.present? %>
45
45
  <div class="py-4">
46
- <%= render partial: 'avo/partials/paginator', locals: { pagy: @pagy, turbo_frame: @turbo_frame } %>
46
+ <%= render partial: 'avo/partials/paginator', locals: { pagy: @pagy, turbo_frame: @turbo_frame || 'none' } %>
47
47
  </div>
48
48
  <% end %>
49
49
  </div>
@@ -55,7 +55,7 @@
55
55
  <%= render Avo::Index::ResourceGridComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model) %>
56
56
 
57
57
  <div class="bg-white rounded-xl shadow-xl mt-8 py-6">
58
- <%= render partial: 'avo/partials/paginator', locals: { pagy: @pagy, turbo_frame: @turbo_frame } %>
58
+ <%= render partial: 'avo/partials/paginator', locals: { pagy: @pagy, turbo_frame: @turbo_frame || 'none' } %>
59
59
  </div>
60
60
  <% end %>
61
61
  <% end %>
@@ -51,7 +51,7 @@ module Avo
51
51
  existing_params = Addressable::URI.parse(request.fullpath).query_values.symbolize_keys
52
52
  end
53
53
  rescue; end
54
- send :"resources_#{model.model_name.route_key}_path", **existing_params, **args
54
+ avo.send :"resources_#{model.model_name.route_key}_path", **existing_params, **args
55
55
  end
56
56
 
57
57
  def related_resources_path(parent_model, model, keep_query_params: false, **args)
@@ -70,9 +70,9 @@ module Avo
70
70
  end
71
71
 
72
72
  def resource_path(model = nil, resource_id: nil, keep_query_params: false, **args)
73
- return send :"resources_#{model.model_name.route_key.singularize}_path", resource_id, **args if resource_id.present?
73
+ return avo.send :"resources_#{model.model_name.route_key.singularize}_path", resource_id, **args if resource_id.present?
74
74
 
75
- send :"resources_#{model.model_name.route_key.singularize}_path", model, **args
75
+ avo.send :"resources_#{model.model_name.route_key.singularize}_path", model, **args
76
76
  end
77
77
 
78
78
  def resource_attach_path(model_name, model_id, related_name, related_id = nil)
@@ -92,11 +92,11 @@ module Avo
92
92
  end
93
93
 
94
94
  def new_resource_path(model, **args)
95
- send :"new_resources_#{model.model_name.route_key.singularize}_path", **args
95
+ avo.send :"new_resources_#{model.model_name.route_key.singularize}_path", **args
96
96
  end
97
97
 
98
98
  def edit_resource_path(model, **args)
99
- send :"edit_resources_#{model.model_name.route_key.singularize}_path", model, **args
99
+ avo.send :"edit_resources_#{model.model_name.route_key.singularize}_path", model, **args
100
100
  end
101
101
 
102
102
  private
@@ -110,6 +110,8 @@ module Avo
110
110
  end
111
111
 
112
112
  def set_resource
113
+ raise ActionController::RoutingError.new "No route matches" if resource.nil?
114
+
113
115
  @resource = resource.hydrate(params: params)
114
116
  end
115
117
 
@@ -182,8 +184,6 @@ module Avo
182
184
  def eager_load_files(resource, query)
183
185
  if resource.attached_file_fields.present?
184
186
  resource.attached_file_fields.map do |field|
185
- # abort "#{field.pluralize}".inspect
186
- # abort field.class.inspect
187
187
  attachment = case field.class.to_s
188
188
  when "Avo::Fields::FileField"
189
189
  "attachment"
@@ -194,7 +194,6 @@ module Avo
194
194
  end
195
195
 
196
196
  return query.eager_load "#{field.id}_#{attachment}": :blob
197
- # return query.send :"with_attached_#{field}"
198
197
  end
199
198
  end
200
199
 
@@ -7,30 +7,6 @@ module Avo
7
7
  Avo.webpacker
8
8
  end
9
9
 
10
- def render_logo
11
- render partial: "vendor/avo/partials/logo"
12
- rescue
13
- render partial: "avo/partials/logo"
14
- end
15
-
16
- def render_header
17
- render partial: "vendor/avo/partials/header"
18
- rescue
19
- render partial: "avo/partials/header"
20
- end
21
-
22
- def render_footer
23
- render partial: "vendor/avo/partials/footer"
24
- rescue
25
- render partial: "avo/partials/footer"
26
- end
27
-
28
- def render_scripts
29
- render partial: "vendor/avo/partials/scripts"
30
- rescue
31
- ""
32
- end
33
-
34
10
  def render_license_warnings
35
11
  render partial: "avo/sidebar/license_warnings", locals: {
36
12
  license: Avo::App.license.properties
@@ -1,7 +1,7 @@
1
1
  <div class="application-sidebar flex h-full bg-white text-white w-56 z-50 border-r border-gray-300">
2
2
  <div class="flex flex-col w-full">
3
3
  <%= link_to root_path, class: 'logo-placeholder h-16 bg-white p-2 flex justify-center' do %>
4
- <%= render_logo %>
4
+ <%= render partial: "avo/partials/logo" %>
5
5
  <% end %>
6
6
 
7
7
  <div class="flex-1 flex flex-col justify-between">
@@ -10,9 +10,18 @@
10
10
  <%= render Avo::NavigationHeadingComponent.new label: t('avo.resources') %>
11
11
 
12
12
  <div class="w-full">
13
- <% Avo::App.get_navigation_items(_current_user).each do |resource| %>
13
+ <% Avo::App.resources_navigation(_current_user).each do |resource| %>
14
14
  <%= render Avo::NavigationLinkComponent.new label: resource.name.pluralize.humanize, path: resources_path(resource.model_class) %>
15
15
  <% end %>
16
+
17
+ <% sidebar_partials = Avo::App.get_sidebar_partials %>
18
+ <% if sidebar_partials.present? %>
19
+ <%= render Avo::NavigationHeadingComponent.new label: t('avo.tools') %>
20
+
21
+ <% sidebar_partials.each do |partial| %>
22
+ <%= render partial: "/avo/sidebar/items/#{partial}" %>
23
+ <% end %>
24
+ <% end %>
16
25
  </div>
17
26
 
18
27
  </div>