avo 3.0.0.pre13 → 3.0.0.pre14

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 (115) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +2 -1
  4. data/app/components/avo/alert_component.html.erb +1 -1
  5. data/app/components/avo/base_component.rb +7 -7
  6. data/app/components/avo/field_wrapper_component.rb +1 -1
  7. data/app/components/avo/fields/area_field/edit_component.html.erb +1 -1
  8. data/app/components/avo/fields/belongs_to_field/edit_component.html.erb +5 -5
  9. data/app/components/avo/fields/belongs_to_field/edit_component.rb +4 -4
  10. data/app/components/avo/fields/boolean_field/edit_component.html.erb +1 -0
  11. data/app/components/avo/fields/boolean_group_field/edit_component.html.erb +1 -1
  12. data/app/components/avo/fields/code_field/edit_component.html.erb +1 -0
  13. data/app/components/avo/fields/country_field/edit_component.html.erb +1 -0
  14. data/app/components/avo/fields/file_field/index_component.rb +2 -2
  15. data/app/components/avo/fields/has_one_field/show_component.html.erb +1 -0
  16. data/app/components/avo/fields/index_component.rb +1 -0
  17. data/app/components/avo/fields/location_field/show_component.html.erb +1 -1
  18. data/app/components/avo/fields/markdown_field/edit_component.html.erb +1 -0
  19. data/app/components/avo/fields/number_field/edit_component.html.erb +1 -0
  20. data/app/components/avo/fields/password_field/edit_component.html.erb +1 -0
  21. data/app/components/avo/fields/progress_bar_field/edit_component.html.erb +1 -0
  22. data/app/components/avo/fields/status_field/edit_component.html.erb +1 -1
  23. data/app/components/avo/fields/text_field/edit_component.html.erb +1 -1
  24. data/app/components/avo/fields/textarea_field/edit_component.html.erb +1 -0
  25. data/app/components/avo/fields/trix_field/edit_component.html.erb +2 -1
  26. data/app/components/avo/fields/trix_field/show_component.html.erb +1 -1
  27. data/app/components/avo/index/resource_controls_component.rb +6 -6
  28. data/app/components/avo/item_switcher_component.html.erb +9 -4
  29. data/app/components/avo/item_switcher_component.rb +2 -1
  30. data/app/components/avo/resource_component.rb +5 -3
  31. data/app/components/avo/resource_sidebar_component.rb +1 -1
  32. data/app/components/avo/row_component.html.erb +3 -0
  33. data/app/components/avo/row_component.rb +12 -0
  34. data/app/components/avo/sidebar/link_component.html.erb +2 -0
  35. data/app/components/avo/sidebar/link_component.rb +5 -3
  36. data/app/components/avo/sidebar_component.html.erb +3 -3
  37. data/app/components/avo/sidebar_component.rb +4 -4
  38. data/app/components/avo/sidebar_profile_component.html.erb +3 -3
  39. data/app/components/avo/views/resource_edit_component.rb +1 -1
  40. data/app/components/avo/views/resource_index_component.html.erb +1 -1
  41. data/app/components/avo/views/resource_index_component.rb +8 -8
  42. data/app/controllers/avo/actions_controller.rb +11 -7
  43. data/app/controllers/avo/application_controller.rb +71 -66
  44. data/app/controllers/avo/associations_controller.rb +4 -6
  45. data/app/controllers/avo/attachments_controller.rb +1 -1
  46. data/app/controllers/avo/base_controller.rb +22 -15
  47. data/app/controllers/avo/home_controller.rb +1 -1
  48. data/app/controllers/avo/search_controller.rb +14 -12
  49. data/app/controllers/concerns/avo/initializes_avo.rb +2 -5
  50. data/app/javascript/js/controllers/fields/easy_mde_controller.js +1 -0
  51. data/app/views/avo/associations/new.html.erb +1 -1
  52. data/app/views/avo/debug/status.html.erb +1 -1
  53. data/app/views/avo/partials/_custom_tools_alert.html.erb +2 -2
  54. data/app/views/avo/partials/_footer.html.erb +1 -1
  55. data/app/views/avo/partials/_javascript.html.erb +1 -1
  56. data/app/views/avo/partials/_navbar.html.erb +1 -1
  57. data/app/views/layouts/avo/application.html.erb +2 -2
  58. data/avo.gemspec +1 -0
  59. data/config/initializers/pagy.rb +12 -10
  60. data/config/routes.rb +3 -3
  61. data/db/factories.rb +2 -1
  62. data/lib/avo/base_action.rb +4 -1
  63. data/lib/avo/base_resource.rb +118 -89
  64. data/lib/avo/concerns/has_item_type.rb +4 -0
  65. data/lib/avo/concerns/has_items.rb +20 -15
  66. data/lib/avo/concerns/model_class_constantized.rb +0 -2
  67. data/lib/avo/current.rb +22 -1
  68. data/lib/avo/dsl/field_parser.rb +1 -1
  69. data/lib/avo/dynamic_router.rb +12 -1
  70. data/lib/avo/engine.rb +4 -7
  71. data/lib/avo/fields/base_field.rb +25 -3
  72. data/lib/avo/fields/belongs_to_field.rb +8 -7
  73. data/lib/avo/fields/concerns/is_searchable.rb +1 -1
  74. data/lib/avo/fields/concerns/use_resource.rb +1 -1
  75. data/lib/avo/fields/field_manager.rb +13 -3
  76. data/lib/avo/fields/has_base_field.rb +4 -4
  77. data/lib/avo/fields/has_one_field.rb +1 -1
  78. data/lib/avo/fields/location_field.rb +18 -1
  79. data/lib/avo/licensing/h_q.rb +11 -6
  80. data/lib/avo/licensing/license.rb +1 -1
  81. data/lib/avo/licensing/license_manager.rb +1 -1
  82. data/lib/avo/licensing/{null_license.rb → nil_license.rb} +1 -1
  83. data/lib/avo/loaders/fields_loader.rb +7 -1
  84. data/lib/avo/plugin_manager.rb +2 -4
  85. data/lib/avo/reloader.rb +1 -1
  86. data/lib/avo/resources/items/holder.rb +5 -1
  87. data/lib/avo/resources/items/item_group.rb +1 -0
  88. data/lib/avo/resources/items/row.rb +54 -0
  89. data/lib/avo/resources/resource_manager.rb +4 -7
  90. data/lib/avo/services/debug_service.rb +6 -6
  91. data/lib/avo/services/telemetry_service.rb +3 -3
  92. data/lib/avo/version.rb +1 -1
  93. data/lib/avo.rb +107 -25
  94. data/lib/generators/avo/action_generator.rb +8 -8
  95. data/lib/generators/avo/card_generator.rb +27 -0
  96. data/lib/generators/avo/filter_generator.rb +8 -8
  97. data/lib/generators/avo/templates/action.tt +3 -3
  98. data/lib/generators/avo/templates/cards/chartkick_card.tt +1 -1
  99. data/lib/generators/avo/templates/cards/chartkick_card_sample.tt +1 -1
  100. data/lib/generators/avo/templates/cards/metric_card.tt +1 -1
  101. data/lib/generators/avo/templates/cards/metric_card_sample.tt +1 -1
  102. data/lib/generators/avo/templates/cards/partial_card.tt +1 -1
  103. data/lib/generators/avo/templates/cards/partial_card_sample.tt +1 -1
  104. data/lib/generators/avo/templates/dashboards/dashboard.tt +1 -1
  105. data/lib/generators/avo/templates/scope.tt +1 -1
  106. data/lib/tasks/avo_tasks.rake +1 -28
  107. data/public/avo-assets/avo.base.css +26 -31
  108. data/public/avo-assets/avo.base.js +281 -280
  109. data/public/avo-assets/avo.base.js.map +3 -3
  110. metadata +21 -8
  111. data/lib/avo/app.rb +0 -170
  112. data/lib/generators/avo/card/chartkick_generator.rb +0 -18
  113. data/lib/generators/avo/card/metric_generator.rb +0 -18
  114. data/lib/generators/avo/card/partial_generator.rb +0 -19
  115. data/lib/generators/avo/templates/standalone_action.tt +0 -15
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: 3.0.0.pre13
4
+ version: 3.0.0.pre14
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-06-07 00:00:00.000000000 Z
12
+ date: 2023-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '6.1'
28
+ - !ruby/object:Gem::Dependency
29
+ name: activesupport
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '6.1'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '6.1'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: actionview
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -1553,6 +1567,8 @@ files:
1553
1567
  - app/components/avo/resource_component.rb
1554
1568
  - app/components/avo/resource_sidebar_component.html.erb
1555
1569
  - app/components/avo/resource_sidebar_component.rb
1570
+ - app/components/avo/row_component.html.erb
1571
+ - app/components/avo/row_component.rb
1556
1572
  - app/components/avo/sidebar/base_item_component.rb
1557
1573
  - app/components/avo/sidebar/group_component.html.erb
1558
1574
  - app/components/avo/sidebar/group_component.rb
@@ -1702,7 +1718,6 @@ files:
1702
1718
  - db/factories.rb
1703
1719
  - lib/avo.rb
1704
1720
  - lib/avo/action_model.rb
1705
- - lib/avo/app.rb
1706
1721
  - lib/avo/asset_manager.rb
1707
1722
  - lib/avo/base_action.rb
1708
1723
  - lib/avo/base_resource.rb
@@ -1789,7 +1804,7 @@ files:
1789
1804
  - lib/avo/licensing/h_q.rb
1790
1805
  - lib/avo/licensing/license.rb
1791
1806
  - lib/avo/licensing/license_manager.rb
1792
- - lib/avo/licensing/null_license.rb
1807
+ - lib/avo/licensing/nil_license.rb
1793
1808
  - lib/avo/licensing/pro_license.rb
1794
1809
  - lib/avo/loaders/actions_loader.rb
1795
1810
  - lib/avo/loaders/fields_loader.rb
@@ -1814,6 +1829,7 @@ files:
1814
1829
  - lib/avo/resources/items/item_group.rb
1815
1830
  - lib/avo/resources/items/main_panel.rb
1816
1831
  - lib/avo/resources/items/panel.rb
1832
+ - lib/avo/resources/items/row.rb
1817
1833
  - lib/avo/resources/items/sidebar.rb
1818
1834
  - lib/avo/resources/items/tab.rb
1819
1835
  - lib/avo/resources/items/tab_group.rb
@@ -1829,9 +1845,7 @@ files:
1829
1845
  - lib/avo/version.rb
1830
1846
  - lib/generators/avo/action_generator.rb
1831
1847
  - lib/generators/avo/base_generator.rb
1832
- - lib/generators/avo/card/chartkick_generator.rb
1833
- - lib/generators/avo/card/metric_generator.rb
1834
- - lib/generators/avo/card/partial_generator.rb
1848
+ - lib/generators/avo/card_generator.rb
1835
1849
  - lib/generators/avo/controller_generator.rb
1836
1850
  - lib/generators/avo/dashboard_generator.rb
1837
1851
  - lib/generators/avo/eject_generator.rb
@@ -1883,7 +1897,6 @@ files:
1883
1897
  - lib/generators/avo/templates/resource_tools/partial.tt
1884
1898
  - lib/generators/avo/templates/resource_tools/resource_tool.tt
1885
1899
  - lib/generators/avo/templates/scope.tt
1886
- - lib/generators/avo/templates/standalone_action.tt
1887
1900
  - lib/generators/avo/templates/tailwindcss/Procfile.dev
1888
1901
  - lib/generators/avo/templates/tailwindcss/avo.tailwind.css
1889
1902
  - lib/generators/avo/templates/tool/controller.tt
data/lib/avo/app.rb DELETED
@@ -1,170 +0,0 @@
1
- module Avo
2
- class App
3
- class_attribute :field_manager
4
- class_attribute :cache_store, default: nil
5
- class_attribute :logger
6
-
7
- include ActiveModel::Model
8
-
9
- attr_accessor :request, :context, :current_user, :view_context
10
- attr_accessor :cache_store
11
- attr_accessor :resource_manager
12
- attr_accessor :dashboard_manager
13
- attr_accessor :tool_manager
14
- attr_accessor :error_manager
15
-
16
- class << self
17
- def eager_load(entity)
18
- paths = Avo::ENTITIES.fetch entity
19
-
20
- return unless paths.present?
21
-
22
- pathname = Rails.root.join(*paths)
23
- if pathname.directory?
24
- Rails.autoloaders.main.eager_load_dir(pathname.to_s)
25
- end
26
- end
27
-
28
- def boot
29
- init_logger
30
- init_fields
31
- self.cache_store = get_cache_store
32
- ::Avo.plugin_manager.boot_plugins
33
- end
34
-
35
- def get_cache_store
36
- if Rails.env.production?
37
- case Rails.cache.class.to_s
38
- when "ActiveSupport::Cache::MemCacheStore", "ActiveSupport::Cache::RedisCacheStore"
39
- Rails.cache
40
- else
41
- ActiveSupport::Cache.lookup_store(:file_store, Rails.root.join("tmp", "cache"))
42
- end
43
- elsif Rails.env.test?
44
- Rails.cache
45
- else
46
- ActiveSupport::Cache.lookup_store(:memory_store)
47
- end
48
- end
49
-
50
- def init_logger
51
- file_logger = ActiveSupport::Logger.new(Rails.root.join("log", "avo.log"))
52
-
53
- file_logger.datetime_format = "%Y-%m-%d %H:%M:%S"
54
- file_logger.formatter = proc do |severity, time, progname, msg|
55
- "[Avo] #{time}: #{msg}\n".tap do |i|
56
- puts i
57
- end
58
- end
59
-
60
- self.logger = file_logger
61
- end
62
-
63
- def init_fields
64
- self.field_manager = Avo::Fields::FieldManager.build
65
- end
66
-
67
- def fields
68
- field_manager
69
- end
70
-
71
- def build(request:, context:, current_user:, view_context:)
72
- @app || new(request: request, context: context, current_user: current_user, view_context: view_context)
73
- end
74
-
75
- def license
76
- Current.license
77
- end
78
-
79
- def instance
80
- Current.app
81
- end
82
-
83
- def resources
84
- Current.app.resource_manager
85
- end
86
-
87
- def dashboards
88
- Current.app.dashboard_manager
89
- end
90
-
91
- def tools
92
- Current.app.tool_manager
93
- end
94
-
95
- def errors
96
- Current.app.error_manager
97
- end
98
-
99
- # Renerate a dynamic root path using the URIService
100
- def root_path(paths: [], query: {}, **args)
101
- Avo::Services::URIService.parse(Avo::Current.view_context.avo.root_url.to_s)
102
- .append_paths(paths)
103
- .append_query(query)
104
- .to_s
105
- end
106
-
107
- def mount_path
108
- Avo::Engine.routes.find_script_name({})
109
- end
110
-
111
- def has_main_menu?
112
- return false if Avo::App.license.lacks_with_trial(:menu_editor)
113
- return false if Avo.configuration.main_menu.nil?
114
-
115
- true
116
- end
117
-
118
- def has_profile_menu?
119
- return false if Avo::App.license.lacks_with_trial(:menu_editor)
120
- return false if Avo.configuration.profile_menu.nil?
121
-
122
- true
123
- end
124
-
125
- def main_menu
126
- return unless Avo.plugin_manager.installed?(:avo_menu)
127
-
128
- # Return empty menu if the app doesn't have the profile menu configured
129
- return AvoMenu::Builder.new.build unless has_main_menu?
130
-
131
- AvoMenu::Builder.parse_menu(&Avo.configuration.main_menu)
132
- end
133
-
134
- def profile_menu
135
- return unless Avo.plugin_manager.installed?(:avo_menu)
136
-
137
- # Return empty menu if the app doesn't have the profile menu configured
138
- return AvoMenu::Builder.new.build unless has_profile_menu?
139
-
140
- AvoMenu::Builder.parse_menu(&Avo.configuration.profile_menu)
141
- end
142
- end
143
-
144
- def init
145
- self.error_manager = Avo::ErrorManager.build
146
- self.resource_manager = Avo::Resources::ResourceManager.build
147
- self.tool_manager = Avo::Tools::ToolManager.build
148
- end
149
-
150
- # Renerate a dynamic root path using the URIService
151
- def root_path(paths: [], query: {}, **args)
152
- Avo::Services::URIService.parse(view_context.avo.root_url.to_s)
153
- .append_paths(paths)
154
- .append_query(query)
155
- .to_s
156
- end
157
-
158
- def mount_path
159
- Avo::Engine.routes.find_script_name({})
160
- end
161
-
162
- def app_status
163
- Current.license.valid?
164
- end
165
- end
166
-
167
- def self.logger
168
- Avo::App.logger
169
- end
170
- end
@@ -1,18 +0,0 @@
1
- require_relative "../named_base_generator"
2
-
3
- module Generators
4
- module Avo
5
- module Card
6
- class ChartkickGenerator < Generators::Avo::NamedBaseGenerator
7
- source_root File.expand_path("../templates", __dir__)
8
-
9
- namespace "avo:card:chartkick"
10
- desc "Add a chartkick card for your Avo dashboard."
11
-
12
- def handle
13
- template "cards/chartkick_card_sample.tt", "app/avo/cards/#{name.underscore}.rb"
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1,18 +0,0 @@
1
- require_relative "../named_base_generator"
2
-
3
- module Generators
4
- module Avo
5
- module Card
6
- class MetricGenerator < Generators::Avo::NamedBaseGenerator
7
- source_root File.expand_path("../templates", __dir__)
8
-
9
- namespace "avo:card:metric"
10
- desc "Add a metric card for your Avo dashboard."
11
-
12
- def handle
13
- template "cards/metric_card_sample.tt", "app/avo/cards/#{name.underscore}.rb"
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1,19 +0,0 @@
1
- require_relative "../named_base_generator"
2
-
3
- module Generators
4
- module Avo
5
- module Card
6
- class PartialGenerator < Generators::Avo::NamedBaseGenerator
7
- source_root File.expand_path("../templates", __dir__)
8
-
9
- namespace "avo:card:partial"
10
- desc "Add a partial card for your Avo dashboard."
11
-
12
- def handle
13
- template "cards/partial_card_sample.tt", "app/avo/cards/#{name.underscore}.rb"
14
- template "cards/partial_card_partial.tt", "app/views/avo/cards/_#{name.underscore}.html.erb"
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,15 +0,0 @@
1
- class Avo::Actions::<%= class_name.camelize %> < Avo::BaseAction
2
- self.name = "<%= name.underscore.humanize %>"
3
- self.standalone = true
4
- # self.visible = -> do
5
- # true
6
- # end
7
-
8
- # def fields
9
- # # Add Action fields here
10
- # end
11
-
12
- def handle(fields:, current_user:, resource:)
13
- # Do something here
14
- end
15
- end