avo 2.5.2.pre.7 → 2.6.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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/app/assets/stylesheets/avo.css +33 -1
  4. data/app/assets/stylesheets/css/search.css +1 -1
  5. data/app/assets/svgs/heroicons/solid/user-remove.svg +1 -1
  6. data/app/components/avo/actions_component.html.erb +3 -2
  7. data/app/components/avo/alert_component.html.erb +1 -1
  8. data/app/components/avo/alert_component.rb +24 -5
  9. data/app/components/avo/button_component.rb +50 -17
  10. data/app/components/avo/card_component.rb +12 -0
  11. data/app/components/avo/fields/concerns/item_labels.rb +40 -0
  12. data/app/components/avo/fields/tags_field/edit_component.html.erb +1 -1
  13. data/app/components/avo/fields/tags_field/index_component.html.erb +1 -5
  14. data/app/components/avo/fields/tags_field/index_component.rb +2 -0
  15. data/app/components/avo/fields/tags_field/show_component.rb +3 -7
  16. data/app/components/avo/fields/tags_field/tag_component.html.erb +1 -1
  17. data/app/components/avo/filters_component.html.erb +1 -1
  18. data/app/components/avo/index/field_wrapper_component.html.erb +1 -1
  19. data/app/components/avo/index/grid_cover_empty_state_component.html.erb +1 -1
  20. data/app/components/avo/index/table_row_component.html.erb +1 -1
  21. data/app/components/avo/panel_component.html.erb +3 -3
  22. data/app/components/avo/panel_component.rb +1 -1
  23. data/app/components/avo/resource_component.rb +50 -0
  24. data/app/components/avo/sidebar/group_component.html.erb +4 -2
  25. data/app/components/avo/sidebar/heading_component.html.erb +1 -1
  26. data/app/components/avo/sidebar/link_component.html.erb +1 -1
  27. data/app/components/avo/sidebar/link_component.rb +1 -1
  28. data/app/components/avo/sidebar_component.html.erb +5 -13
  29. data/app/components/avo/sidebar_profile_component.html.erb +1 -1
  30. data/app/components/avo/views/resource_edit_component.html.erb +28 -3
  31. data/app/components/avo/views/resource_edit_component.rb +4 -6
  32. data/app/components/avo/views/resource_index_component.html.erb +17 -9
  33. data/app/components/avo/views/resource_new_component.html.erb +8 -2
  34. data/app/components/avo/views/resource_show_component.html.erb +16 -6
  35. data/app/components/avo/views/resource_show_component.rb +0 -45
  36. data/app/controllers/avo/actions_controller.rb +23 -8
  37. data/app/controllers/avo/associations_controller.rb +3 -3
  38. data/app/controllers/avo/base_controller.rb +11 -21
  39. data/app/controllers/avo/private_controller.rb +1 -0
  40. data/app/controllers/avo/search_controller.rb +2 -2
  41. data/app/helpers/avo/application_helper.rb +1 -1
  42. data/app/javascript/js/controllers/fields/key_value_controller.js +1 -1
  43. data/app/javascript/js/controllers/fields/tags_field_controller.js +3 -3
  44. data/app/javascript/js/controllers/filter_controller.js +4 -1
  45. data/app/javascript/js/controllers.js +0 -2
  46. data/app/views/avo/actions/show.html.erb +5 -2
  47. data/app/views/avo/dashboards/_chartkick_card.html.erb +1 -1
  48. data/app/views/avo/dashboards/_metric_card.html.erb +1 -1
  49. data/app/views/avo/partials/_logo.html.erb +1 -1
  50. data/app/views/avo/partials/_navbar.html.erb +9 -6
  51. data/app/views/avo/partials/_table_header.html.erb +3 -2
  52. data/app/views/avo/private/_links_and_buttons.html.erb +2 -2
  53. data/app/views/layouts/avo/application.html.erb +50 -53
  54. data/lib/avo/base_action.rb +24 -6
  55. data/lib/avo/engine.rb +1 -1
  56. data/lib/avo/fields/belongs_to_field.rb +4 -4
  57. data/lib/avo/fields/has_and_belongs_to_many_field.rb +2 -2
  58. data/lib/avo/fields/has_base_field.rb +2 -0
  59. data/lib/avo/fields/has_many_field.rb +2 -2
  60. data/lib/avo/fields/has_one_field.rb +2 -2
  61. data/lib/avo/fields/tags_field.rb +5 -5
  62. data/lib/avo/version.rb +1 -1
  63. data/lib/generators/avo/templates/cards/chartkick_card.tt +1 -1
  64. data/lib/generators/avo/templates/cards/chartkick_card_sample.tt +1 -1
  65. data/lib/generators/avo/templates/cards/metric_card.tt +1 -1
  66. data/lib/generators/avo/templates/cards/metric_card_sample.tt +1 -1
  67. data/lib/tasks/avo_tasks.rake +7 -3
  68. data/public/avo-assets/avo.css +233 -176
  69. data/public/avo-assets/avo.js +63 -63
  70. data/public/avo-assets/avo.js.map +3 -3
  71. metadata +5 -9
  72. data/app/assets/builds/avo.css +0 -9557
  73. data/app/assets/builds/avo.js +0 -512
  74. data/app/assets/builds/avo.js.map +0 -7
  75. data/app/assets/stylesheets/css/alerts.css +0 -35
  76. data/app/javascript/js/controllers/alerts_controller.js +0 -26
@@ -1,60 +1,57 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <meta name="viewport" content="width=device-width, initial-scale=1">
5
- <%= display_meta_tags site: Avo.configuration.app_name, reverse: true, separator: "—" %>
6
-
7
- <%= csrf_meta_tags %>
8
- <%= csp_meta_tag %>
9
-
10
- <%= render partial: 'avo/partials/javascript' %>
11
- <%= render partial: 'avo/partials/head' %>
12
-
13
- <% if Avo::PACKED %>
14
- <%= javascript_include_tag "/avo-assets/avo", "data-turbo-track": "reload", defer: true %>
15
- <%= stylesheet_link_tag "/avo-assets/avo", "data-turbo-track": "reload", defer: true %>
16
- <% else %>
17
- <%= javascript_include_tag "avo", "data-turbo-track": "reload", defer: true %>
18
- <%= stylesheet_link_tag "avo", "data-turbo-track": "reload", defer: true %>
19
- <% if Rails.env.development? %>
20
- <%= javascript_include_tag "hotwire-livereload", defer: true %>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1">
5
+ <%= display_meta_tags site: Avo.configuration.app_name, reverse: true, separator: "—" %>
6
+ <%= csrf_meta_tags %>
7
+ <%= csp_meta_tag %>
8
+ <%= render partial: 'avo/partials/javascript' %>
9
+ <%= render partial: 'avo/partials/head' %>
10
+ <% if Avo::PACKED %>
11
+ <%= javascript_include_tag "/avo-assets/avo", "data-turbo-track": "reload", defer: true %>
12
+ <%= stylesheet_link_tag "/avo-assets/avo", "data-turbo-track": "reload", defer: true %>
13
+ <% else %>
14
+ <%= javascript_include_tag "avo", "data-turbo-track": "reload", defer: true %>
15
+ <%= stylesheet_link_tag "avo", "data-turbo-track": "reload", defer: true %>
16
+ <% if Rails.env.development? %>
17
+ <%= javascript_include_tag "hotwire-livereload", defer: true %>
18
+ <% end %>
21
19
  <% end %>
22
- <% end %>
23
- </head>
24
- <body class="bg-application os-mac">
25
- <div class="relative flex flex-1 w-full min-h-full" data-controller="mobile">
26
- <%= render Avo::SidebarComponent.new %>
27
-
28
- <div class="lg:pl-64 flex-1 flex flex-col min-h-full max-w-full">
29
- <%= render partial: "avo/partials/navbar" %>
30
-
31
- <div class="content py-4 lg:py-8 px-4 lg:px-8 flex-1 flex flex-col justify-between items-stretch <%= @container_classes %>">
32
- <%= render partial: "avo/partials/custom_tools_alert" if @custom_tools_alert_visible %>
33
-
34
- <div class="flex flex-1 flex-col justify-between items-stretch space-y-8">
35
- <%= yield %>
36
- <%= render partial: "avo/partials/footer" %>
20
+ </head>
21
+ <body class="bg-gray-25 os-mac">
22
+ <div class="relative flex flex-1 w-full min-h-full" data-controller="mobile">
23
+ <div class="flex-1 flex flex-col max-w-full">
24
+ <%= render partial: "avo/partials/navbar" %>
25
+ <div class="flex-1 flex pt-16 relative">
26
+ <%= render Avo::SidebarComponent.new %>
27
+ <div class="lg:pl-64 flex-1 flex flex-col min-h-full max-w-full">
28
+ <div class="content p-4 lg:p-6 flex-1 flex flex-col justify-between items-stretch <%= @container_classes %>">
29
+ <%= render partial: "avo/partials/custom_tools_alert" if @custom_tools_alert_visible %>
30
+ <div class="flex flex-1 flex-col justify-between items-stretch space-y-8">
31
+ <%= yield %>
32
+ <%= render partial: "avo/partials/footer" %>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ </div>
37
37
  </div>
38
38
  </div>
39
- </div>
40
- </div>
41
-
42
- <%= turbo_frame_tag 'actions_show' %>
43
- <%= turbo_frame_tag 'attach_modal' %>
44
- <%= turbo_frame_tag 'destroy_attachment_form' %>
45
-
46
- <%= turbo_frame_tag 'alerts', class: "fixed inset-0 bottom-0 flex flex-col space-y-4 items-end justify-right px-4 py-6 sm:p-6 justify-end z-50 pointer-events-none" do %>
47
- <%= render Avo::FlashAlertsComponent.new flashes: flash %>
48
-
49
- <% # In case we have other general error messages %>
50
- <% if @errors.present? %>
51
- <% @errors.each do |message| %>
52
- <%= render Avo::AlertComponent.new :error, message %>
39
+ <%= turbo_frame_tag 'actions_show' %>
40
+ <%= turbo_frame_tag 'attach_modal' %>
41
+ <%= turbo_frame_tag 'destroy_attachment_form' %>
42
+ <%= turbo_frame_tag 'alerts', class: "fixed inset-0 bottom-0 flex flex-col space-y-4 items-end justify-right px-4 py-6 sm:p-6 justify-end z-50 pointer-events-none" do %>
43
+ <%= render Avo::FlashAlertsComponent.new flashes: flash %>
44
+ <% # In case we have other general error messages %>
45
+ <% if @errors.present? %>
46
+ <% @errors.each do |message| %>
47
+ <%= render Avo::AlertComponent.new :error, message %>
48
+ <% end %>
49
+ <% end %>
53
50
  <% end %>
54
- <% end %>
55
- <% end %>
56
-
57
- <%= render partial: "avo/partials/scripts" %>
58
- <!-- Avo version: <%= Avo::VERSION %> -->
59
- </body>
51
+ <%= render partial: "avo/partials/scripts" %>
52
+ <!-- Avo version: <%= Avo::VERSION %> -->
53
+ <!-- Environment: <%= Rails.env %> -->
54
+ <!-- License ID: <%= Avo::App.license.id %> -->
55
+ <!-- License valid?: <%= Avo::App.license.valid ? "valid" : "invalid" %> -->
56
+ </body>
60
57
  </html>
@@ -61,8 +61,7 @@ module Avo
61
61
  self.class.cancel_button_label ||= I18n.t("avo.cancel")
62
62
 
63
63
  @response ||= {}
64
- @response[:message_type] ||= :notice
65
- @response[:message] ||= I18n.t("avo.action_ran_successfully")
64
+ @response[:messages] = []
66
65
  end
67
66
 
68
67
  def context
@@ -131,15 +130,25 @@ module Avo
131
130
  end
132
131
 
133
132
  def succeed(text)
134
- response[:message_type] = :notice
135
- response[:message] = text
133
+ add_message text, :success
136
134
 
137
135
  self
138
136
  end
139
137
 
140
138
  def fail(text)
141
- response[:message_type] = :alert
142
- response[:message] = text
139
+ add_message text, :error
140
+
141
+ self
142
+ end
143
+
144
+ def inform(text)
145
+ add_message text, :info
146
+
147
+ self
148
+ end
149
+
150
+ def warn(text)
151
+ add_message text, :warning
143
152
 
144
153
  self
145
154
  end
@@ -168,5 +177,14 @@ module Avo
168
177
 
169
178
  self
170
179
  end
180
+
181
+ private
182
+
183
+ def add_message(body, type = :info)
184
+ response[:messages] << {
185
+ type: type,
186
+ body: body
187
+ }
188
+ end
171
189
  end
172
190
  end
data/lib/avo/engine.rb CHANGED
@@ -31,7 +31,7 @@ module Avo
31
31
  path = Rails.root.join(*path_params)
32
32
 
33
33
  if File.directory? path.to_s
34
- Rails.autoloaders.main.push_dir path
34
+ Rails.autoloaders.main.push_dir path.to_s
35
35
  end
36
36
  end
37
37
  end
@@ -62,7 +62,7 @@ module Avo
62
62
  attr_reader :relation_method
63
63
  attr_reader :types # for Polymorphic associations
64
64
  attr_reader :allow_via_detaching
65
- attr_reader :scope
65
+ attr_reader :attach_scope
66
66
  attr_reader :polymorphic_help
67
67
 
68
68
  def initialize(id, **args, &block)
@@ -75,7 +75,7 @@ module Avo
75
75
  @types = args[:types]
76
76
  @relation_method = id.to_s.parameterize.underscore
77
77
  @allow_via_detaching = args[:allow_via_detaching] == true
78
- @scope = args[:scope]
78
+ @attach_scope = args[:attach_scope]
79
79
  @polymorphic_help = args[:polymorphic_help]
80
80
  end
81
81
 
@@ -117,8 +117,8 @@ module Avo
117
117
 
118
118
  query = Avo::Services::AuthorizationService.apply_policy(user, resource.class.query_scope)
119
119
 
120
- if scope.present?
121
- query = Avo::Hosts::AssociationScopeHost.new(block: scope, query: query, parent: get_model).handle
120
+ if attach_scope.present?
121
+ query = Avo::Hosts::AssociationScopeHost.new(block: attach_scope, query: query, parent: get_model).handle
122
122
  end
123
123
 
124
124
  query.all.map do |model|
@@ -4,10 +4,10 @@ module Avo
4
4
  def initialize(id, **args, &block)
5
5
  args[:updatable] = false
6
6
 
7
- super(id, **args, &block)
8
-
9
7
  hide_on :all
10
8
  show_on :show
9
+
10
+ super(id, **args, &block)
11
11
  end
12
12
 
13
13
  def view_component_name
@@ -3,12 +3,14 @@ module Avo
3
3
  class HasBaseField < BaseField
4
4
  attr_accessor :display
5
5
  attr_accessor :scope
6
+ attr_accessor :attach_scope
6
7
  attr_accessor :description
7
8
 
8
9
  def initialize(id, **args, &block)
9
10
  super(id, **args, &block)
10
11
 
11
12
  @scope = args[:scope].present? ? args[:scope] : nil
13
+ @attach_scope = args[:attach_scope].present? ? args[:attach_scope] : nil
12
14
  @display = args[:display].present? ? args[:display] : :show
13
15
  @searchable = args[:searchable] == true
14
16
  @description = args[:description]
@@ -4,10 +4,10 @@ module Avo
4
4
  def initialize(id, **args, &block)
5
5
  args[:updatable] = false
6
6
 
7
- super(id, **args, &block)
8
-
9
7
  hide_on :all
10
8
  show_on :show
9
+
10
+ super(id, **args, &block)
11
11
  end
12
12
  end
13
13
  end
@@ -4,10 +4,10 @@ module Avo
4
4
  attr_accessor :relation_method
5
5
 
6
6
  def initialize(id, **args, &block)
7
- super(id, **args, &block)
8
-
9
7
  hide_on :new, :edit
10
8
 
9
+ super(id, **args, &block)
10
+
11
11
  @placeholder ||= I18n.t "avo.choose_an_option"
12
12
 
13
13
  @relation_method = name.to_s.parameterize.underscore
@@ -12,7 +12,7 @@ module Avo
12
12
  add_boolean_prop args, :close_on_select
13
13
  add_boolean_prop args, :enforce_suggestions
14
14
  add_string_prop args, :acts_as_taggable_on
15
- add_array_prop args, :blacklist
15
+ add_array_prop args, :disallowed
16
16
  add_array_prop args, :delimiters, [","]
17
17
  add_array_prop args, :suggestions
18
18
  end
@@ -51,11 +51,11 @@ module Avo
51
51
  []
52
52
  end
53
53
 
54
- def blacklist
55
- return @blacklist if @blacklist.is_a? Array
54
+ def disallowed
55
+ return @disallowed if @disallowed.is_a? Array
56
56
 
57
- if @blacklist.respond_to? :call
58
- return Avo::Hosts::RecordHost.new(block: @blacklist, record: model).handle
57
+ if @disallowed.respond_to? :call
58
+ return Avo::Hosts::RecordHost.new(block: @disallowed, record: model).handle
59
59
  end
60
60
 
61
61
  []
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.5.2.pre.7" unless const_defined?(:VERSION)
2
+ VERSION = "2.6.0" unless const_defined?(:VERSION)
3
3
  end
@@ -3,7 +3,7 @@ class <%= class_name.camelize %> < Avo::Dashboards::ChartkickCard
3
3
  self.label = "<%= name.underscore.humanize %>"
4
4
  self.chart_type = :area_chart
5
5
 
6
- query do
6
+ def query
7
7
  data = 3.times.map do |index|
8
8
  {
9
9
  name: "Batch #{index}",
@@ -9,7 +9,7 @@ class <%= class_name.camelize %> < Avo::Dashboards::ChartkickCard
9
9
  # self.chart_options = { library: { plugins: { legend: { display: true } } } }
10
10
  # self.flush = true
11
11
 
12
- query do
12
+ def query
13
13
  points = 16
14
14
  i = Time.new.year.to_i - points
15
15
  base_data = Array.new(points).map do
@@ -2,7 +2,7 @@ class <%= class_name.camelize %> < Avo::Dashboards::MetricCard
2
2
  self.id = "<%= name.underscore %>"
3
3
  self.label = "<%= name.underscore.humanize %>"
4
4
 
5
- query do
5
+ def query
6
6
  result 101
7
7
  end
8
8
  end
@@ -8,7 +8,7 @@ class <%= class_name.camelize %> < Avo::Dashboards::MetricCard
8
8
  # self.prefix = ""
9
9
  # self.suffix = ""
10
10
 
11
- query do
11
+ def query
12
12
  # from = Date.today.midnight - 1.week
13
13
  # to = DateTime.current
14
14
 
@@ -5,11 +5,14 @@
5
5
 
6
6
  desc 'Installs Avo assets and bundles them for when you want to use the GitHub repo in your app'
7
7
  task 'avo:build-assets' do
8
+ spec = get_gem_spec 'avo'
9
+ # Uncomment to enable only when the source is github.com
10
+ # enabled = spec.source.to_s.include?('https://github.com/avo-hq/avo')
8
11
  enabled = true
9
12
 
10
13
  if enabled
11
14
  puts "Starting avo:build-assets"
12
- path = locate_gem 'avo'
15
+ path = spec.full_gem_path
13
16
 
14
17
  Dir.chdir(path) do
15
18
  system 'yarn'
@@ -24,11 +27,12 @@ end
24
27
 
25
28
  # From
26
29
  # https://stackoverflow.com/questions/9322078/programmatically-determine-gems-path-using-bundler
27
- def locate_gem(name)
30
+ def get_gem_spec(name)
28
31
  spec = Bundler.load.specs.find{|s| s.name == name }
29
32
  raise GemNotFound, "Could not find gem '#{name}' in the current bundle." unless spec
30
33
  if spec.name == 'bundler'
31
34
  return File.expand_path('../../../', __FILE__)
32
35
  end
33
- spec.full_gem_path
36
+
37
+ spec
34
38
  end