avo 2.14.3.pre.4.tosqlfix → 2.14.3.pre.7.polytranslations1

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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/app/assets/stylesheets/{avo.css → avo.base.css} +0 -0
  4. data/app/components/avo/base_component.rb +2 -3
  5. data/app/components/avo/fields/belongs_to_field/edit_component.html.erb +2 -2
  6. data/app/components/avo/resource_component.rb +3 -2
  7. data/app/components/avo/sidebar_component.html.erb +1 -1
  8. data/app/components/avo/views/resource_edit_component.rb +0 -2
  9. data/app/controllers/avo/debug_controller.rb +3 -5
  10. data/app/controllers/avo/team_users_controller.rb +4 -0
  11. data/app/javascript/{avo.js → avo.base.js} +0 -0
  12. data/app/views/avo/debug/index.html.erb +13 -10
  13. data/app/views/avo/sidebar/_license_warnings.html.erb +1 -1
  14. data/app/views/layouts/avo/application.html.erb +5 -5
  15. data/lib/avo/app.rb +2 -2
  16. data/lib/avo/base_resource.rb +5 -1
  17. data/lib/avo/concerns/fetches_things.rb +13 -2
  18. data/lib/avo/configuration.rb +2 -0
  19. data/lib/avo/licensing/h_q.rb +23 -1
  20. data/lib/avo/licensing/license_manager.rb +1 -1
  21. data/lib/avo/svg_finder.rb +8 -5
  22. data/lib/avo/version.rb +1 -1
  23. data/lib/generators/avo/base_generator.rb +5 -1
  24. data/lib/generators/avo/js/install_generator.rb +64 -0
  25. data/lib/generators/avo/tailwindcss/install_generator.rb +54 -0
  26. data/lib/generators/avo/templates/initializer/avo.tt +10 -7
  27. data/lib/generators/avo/templates/js/avo.custom.js +2 -0
  28. data/lib/generators/avo/templates/tailwindcss/Procfile.dev +2 -0
  29. data/lib/generators/avo/templates/tailwindcss/avo.tailwind.css +13 -0
  30. data/lib/tasks/avo_tasks.rake +8 -8
  31. data/lib/tasks/tailwindcss_rails.rake +24 -0
  32. data/public/avo-assets/{avo.css → avo.base.css} +0 -0
  33. data/public/avo-assets/{avo.js → avo.base.js} +1 -1
  34. data/public/avo-assets/{avo.js.map → avo.base.js.map} +1 -1
  35. metadata +14 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ca2d8bf622f2be404af63aba48284bd741bdc3b77731f8e365921ffd274e7af
4
- data.tar.gz: 65bb6d4b73155e0ad8e0c8efb3d6aaed6985ad0e97b2ff2bdda3af95933ec04c
3
+ metadata.gz: '08e8a7a0b1ecf1e365341c775e703357f735d907284d362bf3f35c09639e2a2d'
4
+ data.tar.gz: 67f15cd7898525ea94de74f7957efdffa259c7d4fc5c0d3275d58184b9c5c4ac
5
5
  SHA512:
6
- metadata.gz: 4a081b4459f0773f7a9e9932632efe96e67c3a96265331e241280d5e883b93f9d1910ec391792ebe4ad3076fd522d6ac62e159bf0df7a196d96d1d48aff4d2a6
7
- data.tar.gz: 1167d44bde57b81f5b9159dd6658a7352f3a00f252c327762c2f21bba487dc0549a7a77c79ddeab34180463a46c42e11fb834ba51f3704d228250380de32e824
6
+ metadata.gz: 0e12474cfb3fbc1a2e0bdda53510ad05983f0712f8b1ed45f9bd1755edb632baae5d2b160aaf38e591a4d32dacf7668af9060eeccb5df4417f86b37c667f13ae
7
+ data.tar.gz: 1175c1f975c4426dff88a75e388d18d6b4e509c8a78556b4a5fe492dc87317a5f3ffd0d2b043304b077d09e7c1a02f0c9b07cd27b7aa3d197f8b775a8b1cc749
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.14.3.pre.4.tosqlfix)
4
+ avo (2.14.3.pre.7.polytranslations1)
5
5
  active_link_to
6
6
  addressable
7
7
  breadcrumbs_on_rails
File without changes
@@ -9,10 +9,9 @@ class Avo::BaseComponent < ViewComponent::Base
9
9
 
10
10
  private
11
11
 
12
- # Figure out what is the corresponding field for this @reflection
12
+ # Use the @parent_resource to fetch the field using the @reflection name.
13
13
  def field
14
- fields = ::Avo::App.get_resource_by_model_name(@reflection.active_record.name).get_field_definitions
15
- fields.find { |f| f.id == @reflection.name }
14
+ @parent_resource.get_field_definitions.find { |f| f.id == @reflection.name }
16
15
  rescue
17
16
  nil
18
17
  end
@@ -13,7 +13,7 @@
13
13
  data-association-class="<%= @field&.target_resource&.model_class || nil %>"
14
14
  >
15
15
  <%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal, help: @field.polymorphic_help || '' do %>
16
- <%= @form.select @field.type_input_foreign_key, @field.types.map { |type| [type.to_s.underscore.humanize, type.to_s] },
16
+ <%= @form.select @field.type_input_foreign_key, @field.types.map { |type| [::Avo::App.get_resource_by_model_name(type.to_s).name, type.to_s] },
17
17
  {
18
18
  value: @field.value,
19
19
  include_blank: @field.placeholder,
@@ -40,7 +40,7 @@
40
40
  data-belongs-to-field-target="type"
41
41
  data-type="<%= type %>"
42
42
  >
43
- <%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal, label: type.to_s.underscore.humanize do %>
43
+ <%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal, label: ::Avo::App.get_resource_by_model_name(type.to_s).name do %>
44
44
  <% if @field.searchable %>
45
45
  <%= render Avo::Fields::BelongsToField::AutocompleteComponent.new form: @form,
46
46
  disabled: disabled,
@@ -4,6 +4,7 @@ class Avo::ResourceComponent < Avo::BaseComponent
4
4
  attr_reader :has_many_panels
5
5
  attr_reader :has_as_belongs_to_many_panels
6
6
  attr_reader :resource_tools
7
+ attr_reader :resource
7
8
  attr_reader :view
8
9
 
9
10
  def can_create?
@@ -19,7 +20,7 @@ class Avo::ResourceComponent < Avo::BaseComponent
19
20
  end
20
21
 
21
22
  def can_detach?
22
- authorize_association_for("detach")
23
+ authorize_association_for(:detach)
23
24
  end
24
25
 
25
26
  def detach_path
@@ -53,7 +54,7 @@ class Avo::ResourceComponent < Avo::BaseComponent
53
54
 
54
55
  if @reflection.present?
55
56
  # Fetch the appropiate resource
56
- reflection_resource = ::Avo::App.get_resource_by_model_name(@reflection.active_record.name)
57
+ reflection_resource = field.resource
57
58
  # Fetch the model
58
59
  # Hydrate the resource with the model if we have one
59
60
  reflection_resource.hydrate(model: @parent_model) if @parent_model.present?
@@ -57,7 +57,7 @@
57
57
  <%= render partial: "/avo/partials/sidebar_extra" %>
58
58
  </div>
59
59
  </div>
60
- <%= helpers.render_license_warnings %>
60
+ <%= helpers.render_license_warnings unless Rails.env.production? %>
61
61
  <%= render Avo::SidebarProfileComponent.new user: helpers._current_user %>
62
62
  </div>
63
63
  </div>
@@ -4,8 +4,6 @@ class Avo::Views::ResourceEditComponent < Avo::ResourceComponent
4
4
  include Avo::ResourcesHelper
5
5
  include Avo::ApplicationHelper
6
6
 
7
- attr_reader :view
8
-
9
7
  def initialize(resource: nil, model: nil, actions: [], view: :edit)
10
8
  @resource = resource
11
9
  @model = model
@@ -13,12 +13,10 @@ module Avo
13
13
 
14
14
  if license.valid?
15
15
  flash[:notice] = "avohq.io responded: \"#{license.id.humanize} license is valid\"."
16
+ elsif license.response['reason'].present?
17
+ flash[:error] = "avohq.io responded: \"#{license.response['reason']}\"."
16
18
  else
17
- if license.response['reason'].present?
18
- flash[:error] = "avohq.io responded: \"#{license.response['reason']}\"."
19
- else
20
- flash[:error] = license.response['error']
21
- end
19
+ flash[:error] = license.response['error']
22
20
  end
23
21
 
24
22
  redirect_back fallback_location: avo.avo_private_debug_index_path
@@ -0,0 +1,4 @@
1
+ # This controller has been generated to enable Rails' resource routes.
2
+ # You shouldn't need to modify it in order to use Avo.
3
+ class Avo::TeamUsersController < Avo::ResourcesController
4
+ end
File without changes
@@ -20,7 +20,20 @@
20
20
  <% c.bare_content do %>
21
21
  <div class="grid gap-4 sm:grid-cols-3">
22
22
  <div class="relative flex flex-col bg-white rounded shadow-panel p-4 space-y-4 h-full col-span-1">
23
+ <div class="flex justify-between w-full">
23
24
  <div class="font-semibold">License info</div>
25
+ <div class="flex justify-self-end">
26
+ <%= a_button style: :outline,
27
+ color: :blue,
28
+ url: "#{root_path}avo_private/debug/refresh_license",
29
+ method: :post,
30
+ loading: true,
31
+ size: :xs,
32
+ icon: 'heroicons/outline/refresh' do %>
33
+ Refresh license
34
+ <% end %>
35
+ </div>
36
+ </div>
24
37
  <div class="flex flex-col flex-1">
25
38
  <div>
26
39
  <div class="text-xl font-semibold"><%= license.name %></div>
@@ -54,16 +67,6 @@
54
67
  </dl>
55
68
  </div>
56
69
  </div>
57
- <div class="flex justify-end mt-4">
58
- <%= a_button style: :outline,
59
- color: :blue,
60
- url: "#{root_path}avo_private/debug/refresh_license",
61
- method: :post,
62
- loading: true,
63
- icon: 'heroicons/outline/refresh' do %>
64
- Refresh license
65
- <% end %>
66
- </div>
67
70
  </div>
68
71
  </div>
69
72
  <div class="relative bg-white rounded shadow-panel p-4 space-y-4 col-span-2">
@@ -2,5 +2,5 @@
2
2
  <%= render_license_warning title: 'Trial Mode', message: 'You are experiencing paid features that need to be licensed before deploying this site. Enjoy!' %>
3
3
  <% end %>
4
4
  <% if license[:error].present? && !(Avo.configuration.display_license_request_timeout_error === false && license[:error] === "Request timeout.") %>
5
- <%= render_license_warning title: 'Avo HQ Error', message: "#{license[:error]}. Checking back every 5 minutes." %>
5
+ <%= render_license_warning title: 'Avo HQ Error', message: "#{license[:error]} Checking back every 5 minutes." %>
6
6
  <% end %>
@@ -6,17 +6,17 @@
6
6
  <%= csrf_meta_tags %>
7
7
  <%= csp_meta_tag %>
8
8
  <%= render partial: 'avo/partials/javascript' %>
9
- <%= render partial: 'avo/partials/head' %>
10
9
  <% 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 %>
10
+ <%= javascript_include_tag "/avo-assets/avo.base", "data-turbo-track": "reload", defer: true %>
11
+ <%= stylesheet_link_tag "/avo-assets/avo.base", "data-turbo-track": "reload", defer: true %>
13
12
  <% else %>
14
- <%= javascript_include_tag "avo", "data-turbo-track": "reload", defer: true %>
15
- <%= stylesheet_link_tag "avo", "data-turbo-track": "reload", defer: true %>
13
+ <%= javascript_include_tag "avo.base", "data-turbo-track": "reload", defer: true %>
14
+ <%= stylesheet_link_tag "avo.base", "data-turbo-track": "reload", defer: true %>
16
15
  <% if Rails.env.development? %>
17
16
  <%= javascript_include_tag "hotwire-livereload", defer: true %>
18
17
  <% end %>
19
18
  <% end %>
19
+ <%= render partial: 'avo/partials/head' %>
20
20
  </head>
21
21
  <body class="bg-application os-mac">
22
22
  <div class="relative flex flex-1 w-full min-h-full" data-controller="sidebar" data-sidebar-open-value="<%= @sidebar_open %>">
data/lib/avo/app.rb CHANGED
@@ -161,12 +161,12 @@ module Avo
161
161
 
162
162
  hq = Avo::Licensing::HQ.new(request)
163
163
 
164
- payload[:thread_count] = get_thread_count
165
- payload[:hq_payload] = hq&.payload
166
164
  payload[:license_id] = Avo::App&.license&.id
167
165
  payload[:license_valid] = Avo::App&.license&.valid?
168
166
  payload[:license_payload] = Avo::App&.license&.payload
169
167
  payload[:license_response] = Avo::App&.license&.response
168
+ payload[:hq_payload] = hq&.payload
169
+ payload[:thread_count] = get_thread_count
170
170
  payload[:license_abilities] = Avo::App&.license&.abilities
171
171
  payload[:cache_store] = self.cache_store&.class&.to_s
172
172
  payload[:avo_metadata] = hq&.avo_metadata
@@ -20,7 +20,6 @@ module Avo
20
20
  delegate :context, to: ::Avo::App
21
21
 
22
22
  attr_accessor :view
23
- attr_accessor :model
24
23
  attr_accessor :reflection
25
24
  attr_accessor :user
26
25
  attr_accessor :params
@@ -111,6 +110,11 @@ module Avo
111
110
  end
112
111
  end
113
112
 
113
+ def record
114
+ @model
115
+ end
116
+ alias :model :record
117
+
114
118
  def hydrate(model: nil, view: nil, user: nil, params: nil)
115
119
  @view = view if view.present?
116
120
  @user = user if user.present?
@@ -51,10 +51,15 @@ module Avo
51
51
  #
52
52
  # get_resource_by_name('User') => UserResource
53
53
  # get_resource_by_name(User) => UserResource
54
- def get_resource_by_model_name(name)
54
+ def get_resource_by_model_name(klass)
55
+ # Fetch the mappings imposed by the user.
56
+ # If they are present, use those ones.
57
+ mapping = get_mapping_for_model klass
58
+ return get_resource(mapping) if mapping.present?
59
+
55
60
  valid_resources
56
61
  .find do |resource|
57
- resource.model_class.model_name.name == name.to_s
62
+ resource.model_class.model_name.name == klass.to_s
58
63
  end
59
64
  end
60
65
 
@@ -128,6 +133,12 @@ module Avo
128
133
 
129
134
  get_sidebar_partials
130
135
  end
136
+
137
+ private
138
+
139
+ def get_mapping_for_model(klass)
140
+ (Avo.configuration.model_resource_mapping || {}).stringify_keys.transform_values(&:to_s)[klass.to_s]
141
+ end
131
142
  end
132
143
  end
133
144
  end
@@ -34,6 +34,7 @@ module Avo
34
34
  attr_accessor :buttons_on_form_footers
35
35
  attr_accessor :main_menu
36
36
  attr_accessor :profile_menu
37
+ attr_accessor :model_resource_mapping
37
38
  attr_accessor :tabs_style
38
39
 
39
40
  def initialize
@@ -79,6 +80,7 @@ module Avo
79
80
  @buttons_on_form_footers = false
80
81
  @main_menu = nil
81
82
  @profile_menu = nil
83
+ @model_resource_mapping = {}
82
84
  @tabs_style = :tabs
83
85
  end
84
86
 
@@ -153,6 +153,8 @@ module Avo
153
153
  end
154
154
 
155
155
  def cache_response(response: nil, time: CACHE_TIME)
156
+ response = normalize_response response
157
+
156
158
  response.merge!(
157
159
  expiry: time,
158
160
  fetched_at: Time.now,
@@ -164,6 +166,21 @@ module Avo
164
166
  response
165
167
  end
166
168
 
169
+ def normalize_response(response)
170
+ if response.is_a? Hash
171
+ response
172
+ else
173
+ {
174
+ normalized_response: JSON.stringify(response)
175
+ }
176
+ end
177
+ response.merge({})
178
+ rescue
179
+ {
180
+ normalized_response: "rescued"
181
+ }
182
+ end
183
+
167
184
  def perform_request
168
185
  ::Rails.logger.debug "[Avo] Performing request to avohq.io API to check license availability." if Rails.env.development?
169
186
 
@@ -199,7 +216,12 @@ module Avo
199
216
  end
200
217
 
201
218
  def cache_and_return_error(error, exception_message = "")
202
- cache_response response: {error: error, exception_message: exception_message}.stringify_keys, time: 5.minutes.to_i
219
+ cache_response response: {
220
+ id: Avo.configuration.license,
221
+ valid: true,
222
+ error: error,
223
+ exception_message: exception_message
224
+ }.stringify_keys, time: 5.minutes.to_i
203
225
  end
204
226
 
205
227
  def has_cached_response
@@ -17,7 +17,7 @@ module Avo
17
17
  end
18
18
 
19
19
  def self.refresh_license(request)
20
- self.new(Licensing::HQ.new(request).fresh_response).license
20
+ new(Licensing::HQ.new(request).fresh_response).license
21
21
  end
22
22
  end
23
23
  end
@@ -22,18 +22,22 @@ class Avo::SvgFinder
22
22
  Avo::Engine.root.join(@filename).to_s,
23
23
  ]
24
24
 
25
- path = paths.find do |path|
25
+ paths.find do |path|
26
26
  File.exist? path
27
27
  end
28
-
29
- path
30
28
  end
31
29
 
32
30
  def default_strategy
33
- if ::Rails.application.config.assets.compile
31
+ # If the app uses Propshaft, grab it from there
32
+ if defined?(Propshaft)
33
+ asset_path = ::Rails.application.assets.load_path.find(@filename)
34
+ asset_path&.path
35
+ elsif ::Rails.application.config.assets.compile
36
+ # Grab the asset from the compiled asset manifest
34
37
  asset = ::Rails.application.assets[@filename]
35
38
  Pathname.new(asset.filename) if asset.present?
36
39
  else
40
+ # Grab the asset from the manifest
37
41
  manifest = ::Rails.application.assets_manifest
38
42
  asset_path = manifest.assets[@filename]
39
43
  unless asset_path.nil?
@@ -42,4 +46,3 @@ class Avo::SvgFinder
42
46
  end
43
47
  end
44
48
  end
45
-
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.14.3.pre.4.tosqlfix" unless const_defined?(:VERSION)
2
+ VERSION = "2.14.3.pre.7.polytranslations1" unless const_defined?(:VERSION)
3
3
  end
@@ -7,7 +7,11 @@ module Generators
7
7
 
8
8
  def initialize(*args)
9
9
  super(*args)
10
- invoke "avo:version", *args
10
+
11
+ # Don't output the version if requested so
12
+ unless args.include?(["--no-avo-version"])
13
+ invoke "avo:version", *args
14
+ end
11
15
  end
12
16
  end
13
17
  end
@@ -0,0 +1,64 @@
1
+ require_relative "../base_generator"
2
+
3
+ module Generators
4
+ module Avo
5
+ module Js
6
+ class InstallGenerator < BaseGenerator
7
+ source_root File.expand_path("../templates", __dir__)
8
+
9
+ namespace "avo:js:install"
10
+ desc "Add custom JavaScript assets to your Avo project."
11
+
12
+ # possible values: importmap or esbuild
13
+ class_option :bundler, type: :string, default: "importmap"
14
+
15
+ def create_files
16
+ case options[:bundler].to_s
17
+ when "importmap"
18
+ install_for_importmap
19
+ when "esbuild"
20
+ install_for_esbuild
21
+ else
22
+ say "We don't know how to install Avo JS for this bundler \"#{options[:bundler]}\""
23
+ end
24
+ end
25
+
26
+ no_tasks do
27
+ def install_for_importmap
28
+ unless Rails.root.join("app", "javascript", "avo.custom.js").exist?
29
+ say "Add default app/javascript/avo.custom.js"
30
+ copy_file template_path("avo.custom.js"), "app/javascript/avo.custom.js"
31
+ end
32
+
33
+ say "Ejecting the _head.html.erb partial"
34
+ Rails::Generators.invoke("avo:eject", [":head", "--no-avo-version"], {destination_root: Rails.root})
35
+
36
+ say "Adding the JS asset to the partial"
37
+ append_to_file Rails.root.join("app", "views", "avo", "partials", "_head.html.erb"), "<%= javascript_importmap_tags \"avo.custom\" %>"
38
+
39
+ # pin to importmap
40
+ say "Pin the new entrypoint to your importmap config"
41
+ append_to_file Rails.root.join("config", "importmap.rb"), "\n# Avo custom JS entrypoint\npin \"avo.custom\", preload: true\n"
42
+ end
43
+
44
+ def install_for_esbuild
45
+ unless Rails.root.join("app", "javascript", "avo.custom.js").exist?
46
+ say "Add default app/javascript/avo.custom.js"
47
+ copy_file template_path("avo.custom.js"), "app/javascript/avo.custom.js"
48
+ end
49
+
50
+ say "Ejecting the _head.html.erb partial"
51
+ Rails::Generators.invoke("avo:eject", [":head", "--no-avo-version"], {destination_root: Rails.root})
52
+
53
+ say "Adding the JS asset to the partial"
54
+ append_to_file Rails.root.join("app", "views", "avo", "partials", "_head.html.erb"), "<%= javascript_include_tag \"avo.custom\", \"data-turbo-track\": \"reload\", defer: true %>"
55
+ end
56
+
57
+ def template_path(filename)
58
+ Pathname.new(__dir__).join("..", "templates", "js", filename).to_s
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,54 @@
1
+ require_relative "../base_generator"
2
+
3
+ module Generators
4
+ module Avo
5
+ module Tailwindcss
6
+ class InstallGenerator < BaseGenerator
7
+ source_root File.expand_path("../templates", __dir__)
8
+
9
+ namespace "avo:tailwindcss:install"
10
+ desc "Add Tailwindcss to your Avo project."
11
+
12
+ def create_files
13
+ unless tailwindcss_installed?
14
+ system "./bin/bundle add tailwindcss-rails"
15
+ system "./bin/rails tailwindcss:install"
16
+ end
17
+
18
+ unless Rails.root.join("app", "assets", "stylesheets", "avo.tailwind.css").exist?
19
+ say "Add default app/assets/stylesheets/avo.tailwind.css"
20
+ copy_file template_path("avo.tailwind.css"), "app/assets/stylesheets/avo.tailwind.css"
21
+ end
22
+
23
+ if Rails.root.join("Procfile.dev").exist?
24
+ append_to_file "Procfile.dev", "css: bin/rails avo:tailwindcss:watch\n"
25
+ else
26
+ say "Add default Procfile.dev"
27
+ copy_file template_path("Procfile.dev"), "Procfile.dev"
28
+
29
+ say "Ensure foreman is installed"
30
+ run "gem install foreman"
31
+ end
32
+
33
+ append_to_file "Procfile.dev", "avo_css: bin/rails tailwindcss:watch\n"
34
+
35
+ say "Ejecting the _head.html.erb partial"
36
+ Rails::Generators.invoke("avo:eject", [":head", "--no-avo-version"], {destination_root: Rails.root})
37
+
38
+ say "Adding the CSS asset to the partial"
39
+ prepend_to_file Rails.root.join("app", "views", "avo", "partials", "_head.html.erb"), "<%= stylesheet_link_tag \"avo.tailwind.css\", media: \"all\" %>"
40
+ end
41
+
42
+ no_tasks do
43
+ def template_path(filename)
44
+ Pathname.new(__dir__).join("..", "templates", "tailwindcss", filename).to_s
45
+ end
46
+
47
+ def tailwindcss_installed?
48
+ Rails.root.join("config", "tailwind.config.js").exist? || Rails.root.join("tailwind.config.js").exist?
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -34,19 +34,23 @@ Avo.configure do |config|
34
34
  ## == Localization ==
35
35
  # config.locale = 'en-US'
36
36
 
37
+ ## == Resource options ==
38
+ # config.resource_controls = :right
39
+ # config.model_resource_mapping = {}
40
+ # config.default_view_type = :table
41
+ # config.per_page = 24
42
+ # config.per_page_steps = [12, 24, 48, 72]
43
+ # config.via_per_page = 8
44
+ # config.id_links_to_resource = false
45
+ # config.cache_resources_on_index_view = true
46
+
37
47
  ## == Customization ==
38
48
  # config.app_name = 'Avocadelicious'
39
49
  # config.timezone = 'UTC'
40
50
  # config.currency = 'USD'
41
- # config.per_page = 24
42
- # config.per_page_steps = [12, 24, 48, 72]
43
- # config.via_per_page = 8
44
- # config.default_view_type = :table
45
51
  # config.hide_layout_when_printing = false
46
- # config.id_links_to_resource = false
47
52
  # config.full_width_container = false
48
53
  # config.full_width_index_view = false
49
- # config.cache_resources_on_index_view = true
50
54
  # config.search_debounce = 300
51
55
  # config.view_component_path = "app/components"
52
56
  # config.display_license_request_timeout_error = true
@@ -54,7 +58,6 @@ Avo.configure do |config|
54
58
  # config.resource_controls = :right
55
59
  # config.tabs_style = :tabs # can be :tabs or :pills
56
60
 
57
-
58
61
  ## == Breadcrumbs ==
59
62
  # config.display_breadcrumbs = true
60
63
  # config.set_initial_breadcrumbs do
@@ -0,0 +1,2 @@
1
+ // eslint-disable-next-line no-console
2
+ console.log('Hi from Avo custom JS 👋')
@@ -0,0 +1,2 @@
1
+ web: bin/rails server -p 3000
2
+ css: bin/rails avo:tailwindcss:watch
@@ -0,0 +1,13 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ /*
6
+
7
+ @layer components {
8
+ .btn-primary {
9
+ @apply py-2 px-4 bg-blue-200;
10
+ }
11
+ }
12
+
13
+ */
@@ -3,9 +3,9 @@
3
3
  # # Task goes here
4
4
  # end
5
5
 
6
- desc 'Installs Avo assets and bundles them for when you want to use the GitHub repo in your app'
7
- task 'avo:build-assets' do
8
- spec = get_gem_spec 'avo'
6
+ desc "Installs Avo assets and bundles them for when you want to use the GitHub repo in your app"
7
+ task "avo:build-assets" do
8
+ spec = get_gem_spec "avo"
9
9
  # Uncomment to enable only when the source is github.com
10
10
  # enabled = spec.source.to_s.include?('https://github.com/avo-hq/avo')
11
11
  enabled = true
@@ -15,8 +15,8 @@ task 'avo:build-assets' do
15
15
  path = spec.full_gem_path
16
16
 
17
17
  Dir.chdir(path) do
18
- system 'yarn'
19
- system 'yarn prod:build'
18
+ system "yarn"
19
+ system "yarn prod:build"
20
20
  end
21
21
 
22
22
  puts "Done"
@@ -28,10 +28,10 @@ end
28
28
  # From
29
29
  # https://stackoverflow.com/questions/9322078/programmatically-determine-gems-path-using-bundler
30
30
  def get_gem_spec(name)
31
- spec = Bundler.load.specs.find{|s| s.name == name }
31
+ spec = Bundler.load.specs.find { |s| s.name == name }
32
32
  raise GemNotFound, "Could not find gem '#{name}' in the current bundle." unless spec
33
- if spec.name == 'bundler'
34
- return File.expand_path('../../../', __FILE__)
33
+ if spec.name == "bundler"
34
+ return File.expand_path("../../../", __FILE__)
35
35
  end
36
36
 
37
37
  spec
@@ -0,0 +1,24 @@
1
+ # Use the user provided asset or use the default
2
+ ASSET_FILE = ARGV[0] || "app/assets/builds/avo.tailwind.css"
3
+ # Se the tailwindcss-rails package name
4
+ TAILWINDCSS_RAILS = "tailwindcss-rails"
5
+
6
+ # Check if tailwindcss-rails is being used
7
+ if Gem.loaded_specs.key? TAILWINDCSS_RAILS
8
+ # Get the path
9
+ GEM_PATH = Gem.loaded_specs[TAILWINDCSS_RAILS].full_gem_path
10
+ # Compose the compile command
11
+ AVO_TAILWIND_COMPILE_COMMAND = "#{RbConfig.ruby} #{Pathname.new(GEM_PATH)}/exe/tailwindcss -i '#{Rails.root.join("app/assets/stylesheets/avo.css")}' -o '#{Rails.root.join(ASSET_FILE)}' -c '#{Rails.root.join("config/tailwind.config.js")}' --minify"
12
+
13
+ namespace "avo:tailwindcss" do
14
+ desc "Build your Tailwind CSS"
15
+ task :build do
16
+ system(AVO_TAILWIND_COMPILE_COMMAND, exception: true)
17
+ end
18
+
19
+ desc "Watch and build your Tailwind CSS on file changes"
20
+ task :watch do
21
+ system "#{AVO_TAILWIND_COMPILE_COMMAND} -w"
22
+ end
23
+ end
24
+ end
File without changes
@@ -510,4 +510,4 @@ PERFORMANCE OF THIS SOFTWARE.
510
510
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
511
511
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
512
512
  */
513
- //# sourceMappingURL=avo.js.map
513
+ //# sourceMappingURL=avo.base.js.map