avo 2.1.2.pre1 → 2.1.2.pre2

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: 1ab813d1cba92231f9f5ea655e200739567db3d33a93434add2000d42281f29e
4
- data.tar.gz: 6357611e7245cb45e68749b4c0e72c2c97f353d12a509b5b467f9ae7ff7a261d
3
+ metadata.gz: bde8997aaf953104f34a221e6be3c93b6c7f20bc1b9f125615c0ff994cc6791f
4
+ data.tar.gz: ca3a39976e8046d165cdb66a8aad6260e98d869981e73eba1d6d121bb57a7580
5
5
  SHA512:
6
- metadata.gz: c2723ce4a864c153c8ae515c168e50954a4415a9be8aae5b190fbe8d1fbe5d4227f165cb9f9957f606aa757cc3141e33204eacc53d270c22f14d995c0a3f285b
7
- data.tar.gz: dff128333e8a5700d12c5d951d1ba29cb9a11980b68beb137916547eb1c1ed9bcb44ccc2e3c167ce772e6e6f976a28d29bed0ffde958936f0833ff1f29427b0a
6
+ metadata.gz: 50c30c580b89ad850a34c0125ad0079d34a1af72eefbb99193644f605692ea5f3e2bb54e1a0032ef04e219ba84888171cfcf6b69c6da045475f21afc50747680
7
+ data.tar.gz: 0ce0f8be40b683c2c1ef5b8e963bbbb0d8282e4e0b7d193f4acedee530d9618481a036a0c3955214d4c024876a374009c82df85a788708aebf603943595218c1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.1.2.pre1)
4
+ avo (2.1.2.pre2)
5
5
  active_link_to
6
6
  addressable
7
7
  breadcrumbs_on_rails
@@ -7,31 +7,30 @@
7
7
  title: t('avo.click_to_reveal_filters'),
8
8
  'data-button': 'resource-filters',
9
9
  'data-action': 'click->toggle-panel#togglePanel',
10
- 'data-tippy': 'tooltip' do
11
- %>
12
- <%= t 'avo.filters' %>
13
- <% if params[:filters].present? %>
14
- <span class="ml-1">(<%=JSON.parse(Base64.decode64(params[:filters])).count%> applied)</span>
10
+ 'data-tippy': 'tooltip' do %>
11
+ <%= t 'avo.filters' %>
12
+ <% if params[:filters].present? %>
13
+ <span class="ml-1">(<%=JSON.parse(Base64.decode64(params[:filters])).count%> applied)</span>
14
+ <% end %>
15
15
  <% end %>
16
- <% end %>
17
- <div
16
+ <div
18
17
  class="absolute block inset-auto sm:right-0 top-full bg-white min-w-[300px] mt-2 z-20 shadow-modal rounded hidden divide-y divide-gray-300"
19
18
  data-toggle-panel-target="panel"
20
19
  >
21
- <% @filters.each do |filter| %>
22
- <%= render partial: filter.class.template, locals: {filter: filter} %>
23
- <% end %>
24
- <div class="p-4 border-gray-300 border-t">
25
- <% if params[:filters].present? %>
26
- <%= a_link helpers.resources_path(resource: @resource, filters: nil, keep_query_params: true), color: :gray, size: :sm, class: 'w-full justify-center' do %>
27
- <%= t('avo.reset_filters') %>
28
- <% end %>
29
- <% else %>
30
- <%= a_button class: 'w-full justify-center', disabled: true do %>
31
- <%= t('avo.reset_filters') %>
32
- <% end %>
20
+ <% @filters.each do |filter| %>
21
+ <%= render partial: filter.class.template, locals: {filter: filter} %>
33
22
  <% end %>
23
+ <div class="p-4 border-gray-300 border-t">
24
+ <% if params[:filters].present? %>
25
+ <%= a_link helpers.resources_path(resource: @resource, filters: nil, keep_query_params: true), color: :gray, size: :sm, class: 'w-full justify-center' do %>
26
+ <%= t('avo.reset_filters') %>
27
+ <% end %>
28
+ <% else %>
29
+ <%= a_button class: 'w-full justify-center', disabled: true do %>
30
+ <%= t('avo.reset_filters') %>
31
+ <% end %>
32
+ <% end %>
33
+ </div>
34
34
  </div>
35
35
  </div>
36
36
  </div>
37
- </div>
@@ -1,19 +1,23 @@
1
1
  <div class="text-black border-t border-gray-200 p-4 flex">
2
2
  <div class="flex-1 flex space-x-4">
3
- <div class="relative aspect-square w-10 h-10 overflow-hidden rounded">
4
- <%= image_tag avatar, class: "object-cover min-w-full min-h-full h-full" %>
5
- </div>
3
+ <% if avatar.present? %>
4
+ <div class="relative aspect-square w-10 h-10 overflow-hidden rounded">
5
+ <%= image_tag avatar, class: "object-cover min-w-full min-h-full h-full" %>
6
+ </div>
7
+ <% end %>
6
8
  <div class="flex flex-col">
7
9
  <div class="font-medium">
8
10
  <%= name %>
9
11
  </div>
10
- <div class="text-xs text-gray-500 uppercase">
11
- <%= title %>
12
- </div>
12
+ <% if title.present? %>
13
+ <div class="text-xs text-gray-500 uppercase">
14
+ <%= title %>
15
+ </div>
16
+ <% end %>
13
17
  </div>
14
18
  </div>
15
- <div class="relative" data-controller="toggle-panel">
16
- <% if can_destroy_user? %>
19
+ <% if can_destroy_user? %>
20
+ <div class="relative" data-controller="toggle-panel">
17
21
  <a class="flex items-center h-full cursor-pointer" data-control="profile-dots" data-action="click->toggle-panel#togglePanel">
18
22
  <%= helpers.svg 'three-dots', class: 'h-4' %>
19
23
  </a>
@@ -31,6 +35,6 @@
31
35
  <%= helpers.svg 'logout', class: 'h-4 mr-1' %> <%= t('avo.sign_out') %>
32
36
  <% end %>
33
37
  </div>
34
- <% end %>
35
- </div>
38
+ </div>
39
+ <% end %>
36
40
  </div>
data/lib/avo/app.rb CHANGED
@@ -79,12 +79,16 @@ module Avo
79
79
  def init_resources
80
80
  self.resources = BaseResource.descendants
81
81
  .select do |resource|
82
+ # Remove the BaseResource. We only need the descendants
82
83
  resource != BaseResource
83
84
  end
85
+ .uniq do |klass|
86
+ # On invalid resource configuration the resource classes get duplicated in `ObjectSpace`
87
+ # We need to de-duplicate them
88
+ klass.name
89
+ end
84
90
  .map do |resource|
85
- if resource.is_a? Class
86
- resource.new
87
- end
91
+ resource.new if resource.is_a? Class
88
92
  end
89
93
  end
90
94
 
@@ -285,6 +285,9 @@ module Avo
285
285
  end
286
286
 
287
287
  def name
288
+ # return 'hwhwhw'
289
+
290
+
288
291
  default = class_name_without_resource.titlecase
289
292
 
290
293
  return @name if @name.present?
@@ -1,7 +1,7 @@
1
1
  module Avo
2
2
  module DynamicRouter
3
3
  def self.routes(router)
4
- Rails.application.eager_load!
4
+ Rails.application.eager_load! if Rails.env.development?
5
5
 
6
6
  BaseResource.descendants
7
7
  .select do |resource|
data/lib/avo/engine.rb CHANGED
@@ -19,7 +19,8 @@ module Avo
19
19
 
20
20
  config.i18n.load_path += Dir[Avo::Engine.root.join('lib', 'generators', 'avo', 'templates', 'locales', '*.{rb,yml}')]
21
21
 
22
- initializer "avo.autoload", before: :set_autoload_paths do |app|
22
+ # initializer "avo.autoload", before: :set_autoload_paths do |app|
23
+ initializer "avo.autoload" do |app|
23
24
  [
24
25
  ["app", "avo", "fields"],
25
26
  ["app", "avo", "filters"],
@@ -41,21 +42,11 @@ module Avo
41
42
  ::Avo::App.init_fields
42
43
  end
43
44
 
44
- initializer "avo.reload_avo_files" do |app|
45
- if Avo::IN_DEVELOPMENT && ENV["RELOAD_AVO_FILES"]
46
- avo_root_path = Avo::Engine.root.to_s
47
- # This should only be happening when ENV["RELOAD_AVO_FILES"] is true because it loads all the files into memory on every change and makes rails sluggish.
48
- app.config.autoload_paths += [Avo::Engine.root.join("lib", "avo").to_s]
49
- # Register reloader
50
- app.reloaders << app.config.file_watcher.new([], {
51
- Avo::Engine.root.join("lib", "avo").to_s => ["rb"]
52
- }) {}
53
-
54
- # What to do on file change
55
- config.to_prepare do
56
- Dir.glob(avo_root_path + "/lib/avo/**/*.rb".to_s).each { |c| load c }
57
- Avo::App.boot
58
- end
45
+ initializer "avo.reloader" do |app|
46
+ Avo::Reloader.new.tap do |reloader|
47
+ reloader.execute
48
+ app.reloaders << reloader
49
+ app.reloader.to_run { reloader.execute }
59
50
  end
60
51
  end
61
52
 
@@ -0,0 +1,51 @@
1
+ class Avo::Reloader
2
+ delegate :execute_if_updated, :execute, :updated?, to: :updater
3
+
4
+ def reload!
5
+ # reload all files declared in paths
6
+ paths.each { |path| load path }
7
+
8
+ # reload all files declared in each directory
9
+ directories.keys.each do |dir|
10
+ Dir.glob("#{dir}/**/*.rb".to_s).each { |c| load c }
11
+ end
12
+ end
13
+
14
+ private
15
+ def updater
16
+ @updater ||= config.file_watcher.new(paths, directories) { reload! }
17
+ end
18
+
19
+ def paths
20
+ # we want to watch some files no matter what
21
+ files = [
22
+ Rails.root.join("config", "initializers", "avo.rb"),
23
+ ]
24
+
25
+ # we want to watch some files only in Avo development
26
+ if reload_lib?
27
+ files += []
28
+ end
29
+
30
+ files
31
+ end
32
+
33
+ def directories
34
+ dirs = {}
35
+
36
+ # watch the lib directory in Avo development
37
+ if reload_lib?
38
+ dirs[Avo::Engine.root.join("lib", "avo").to_s] = ["rb"]
39
+ end
40
+
41
+ dirs
42
+ end
43
+
44
+ def config
45
+ Rails.application.config
46
+ end
47
+
48
+ def reload_lib?
49
+ Avo::IN_DEVELOPMENT || ENV['AVO_RELOAD_LIB_DIR']
50
+ end
51
+ end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.1.2.pre1"
2
+ VERSION = "2.1.2.pre2"
3
3
  end
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.1.2.pre1
4
+ version: 2.1.2.pre2
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-04-07 00:00:00.000000000 Z
12
+ date: 2022-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -1193,6 +1193,7 @@ files:
1193
1193
  - lib/avo/loaders/fields_loader.rb
1194
1194
  - lib/avo/loaders/filters_loader.rb
1195
1195
  - lib/avo/loaders/loader.rb
1196
+ - lib/avo/reloader.rb
1196
1197
  - lib/avo/services/authorization_service.rb
1197
1198
  - lib/avo/tools_manager.rb
1198
1199
  - lib/avo/version.rb