avo 0.5.0.beta9 → 0.5.0.beta14

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 (128) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +46 -50
  3. data/Gemfile.lock +1 -6
  4. data/Rakefile +14 -14
  5. data/app/components/avo/common/multiple_file_viewer_component.rb +1 -1
  6. data/app/components/avo/common/single_file_viewer_component.rb +1 -1
  7. data/app/components/avo/edit/field_wrapper_component.rb +3 -3
  8. data/app/components/avo/index/field_wrapper_component.rb +1 -1
  9. data/app/components/avo/index/grid_item_component.rb +10 -9
  10. data/app/components/avo/index/resource_controls_component.rb +2 -2
  11. data/app/components/avo/panel_component.rb +7 -6
  12. data/app/components/avo/resource_component.rb +4 -3
  13. data/app/components/avo/show/field_wrapper_component.rb +3 -3
  14. data/app/components/avo/views/resource_edit_component.rb +4 -3
  15. data/app/components/avo/views/resource_index_component.rb +8 -7
  16. data/app/components/avo/views/resource_new_component.rb +4 -3
  17. data/app/components/avo/views/resource_show_component.rb +21 -21
  18. data/app/controllers/avo/actions_controller.rb +30 -29
  19. data/app/controllers/avo/application_controller.rb +113 -126
  20. data/app/controllers/avo/attachments_controller.rb +3 -3
  21. data/app/controllers/avo/base_controller.rb +81 -80
  22. data/app/controllers/avo/home_controller.rb +2 -2
  23. data/app/controllers/avo/relations_controller.rb +29 -28
  24. data/app/controllers/avo/resources_controller.rb +1 -1
  25. data/app/controllers/avo/search_controller.rb +20 -19
  26. data/app/helpers/avo/application_helper.rb +48 -42
  27. data/app/helpers/avo/resources_helper.rb +11 -11
  28. data/app/mailers/avo/application_mailer.rb +2 -2
  29. data/app/packs/entrypoints/application.js +9 -7
  30. data/app/packs/images/logo.png +0 -0
  31. data/app/packs/js/controllers/fields/code_field_controller.js +14 -14
  32. data/app/packs/js/controllers/filter_controller.js +9 -8
  33. data/app/packs/js/toastr.js +1 -0
  34. data/avo.gemspec +30 -31
  35. data/config/initializers/pagy.rb +1 -1
  36. data/config/routes.rb +12 -12
  37. data/config/spring.rb +5 -5
  38. data/config/webpack/base.js +2 -2
  39. data/config/webpacker.yml +32 -0
  40. data/db/factories.rb +3 -5
  41. data/lib/avo.rb +6 -6
  42. data/lib/avo/app.rb +18 -18
  43. data/lib/avo/base_action.rb +20 -20
  44. data/lib/avo/base_resource.rb +41 -45
  45. data/lib/avo/configuration.rb +16 -18
  46. data/lib/avo/engine.rb +18 -18
  47. data/lib/avo/fields/badge_field.rb +2 -2
  48. data/lib/avo/fields/base_field.rb +25 -26
  49. data/lib/avo/fields/belongs_to_field.rb +13 -12
  50. data/lib/avo/fields/boolean_field.rb +4 -4
  51. data/lib/avo/fields/boolean_group_field.rb +3 -3
  52. data/lib/avo/fields/code_field.rb +4 -4
  53. data/lib/avo/fields/country_field.rb +2 -2
  54. data/lib/avo/fields/currency_field.rb +3 -3
  55. data/lib/avo/fields/date_field.rb +3 -3
  56. data/lib/avo/fields/date_time_field.rb +2 -2
  57. data/lib/avo/fields/external_image_field.rb +2 -2
  58. data/lib/avo/fields/field_extensions/has_field_name.rb +2 -2
  59. data/lib/avo/fields/field_extensions/visible_in_different_views.rb +34 -33
  60. data/lib/avo/fields/file_field.rb +1 -1
  61. data/lib/avo/fields/files_field.rb +2 -2
  62. data/lib/avo/fields/gravatar_field.rb +9 -9
  63. data/lib/avo/fields/has_and_belongs_to_many_field.rb +1 -1
  64. data/lib/avo/fields/has_many_field.rb +1 -1
  65. data/lib/avo/fields/has_one_field.rb +2 -2
  66. data/lib/avo/fields/heading_field.rb +2 -2
  67. data/lib/avo/fields/hidden_field.rb +1 -1
  68. data/lib/avo/fields/id_field.rb +3 -3
  69. data/lib/avo/fields/key_value_field.rb +12 -12
  70. data/lib/avo/fields/markdown_field.rb +2 -2
  71. data/lib/avo/fields/number_field.rb +3 -3
  72. data/lib/avo/fields/password_field.rb +1 -1
  73. data/lib/avo/fields/select_field.rb +8 -12
  74. data/lib/avo/fields/status_field.rb +4 -4
  75. data/lib/avo/fields/text_field.rb +2 -2
  76. data/lib/avo/fields/textarea_field.rb +2 -2
  77. data/lib/avo/fields/trix_field.rb +1 -1
  78. data/lib/avo/fields_collector.rb +4 -5
  79. data/lib/avo/filters/base_filter.rb +6 -6
  80. data/lib/avo/filters/boolean_filter.rb +1 -1
  81. data/lib/avo/filters/select_filter.rb +1 -1
  82. data/lib/avo/licensing/h_q.rb +56 -55
  83. data/lib/avo/licensing/license.rb +5 -5
  84. data/lib/avo/licensing/license_manager.rb +4 -4
  85. data/lib/avo/licensing/null_license.rb +2 -2
  86. data/lib/avo/licensing/pro_license.rb +1 -1
  87. data/lib/avo/loaders/fields_loader.rb +4 -4
  88. data/lib/avo/services/authorization_service.rb +2 -2
  89. data/lib/avo/services/panel_service.rb +4 -4
  90. data/lib/avo/version.rb +1 -1
  91. data/lib/generators/avo/action_generator.rb +4 -4
  92. data/lib/generators/avo/controller_generator.rb +4 -4
  93. data/lib/generators/avo/filter_generator.rb +5 -5
  94. data/lib/generators/avo/install_generator.rb +8 -8
  95. data/lib/generators/avo/locales_generator.rb +5 -5
  96. data/lib/generators/avo/partials_generator.rb +4 -4
  97. data/lib/generators/avo/resource_generator.rb +5 -5
  98. data/lib/generators/avo/templates/action.tt +0 -4
  99. data/lib/generators/avo/templates/resource/resource.tt +3 -13
  100. data/lib/tasks/avo_tasks.rake +0 -60
  101. data/public/avo-packs/css/{application-38e7e91b.css → application-9d115b7e.css} +44 -147
  102. data/public/avo-packs/css/application-9d115b7e.css.br +0 -0
  103. data/public/avo-packs/css/application-9d115b7e.css.gz +0 -0
  104. data/public/avo-packs/css/application-9d115b7e.css.map +1 -0
  105. data/public/avo-packs/css/application-9d115b7e.css.map.br +0 -0
  106. data/public/avo-packs/css/application-9d115b7e.css.map.gz +0 -0
  107. data/public/avo-packs/js/{application-2b90fe889f7d6df1ad92.js → application-4751feac1bb0404b9c47.js} +4 -4
  108. data/public/avo-packs/js/{application-2b90fe889f7d6df1ad92.js.LICENSE.txt → application-4751feac1bb0404b9c47.js.LICENSE.txt} +0 -0
  109. data/public/avo-packs/js/application-4751feac1bb0404b9c47.js.br +0 -0
  110. data/public/avo-packs/js/application-4751feac1bb0404b9c47.js.gz +0 -0
  111. data/public/avo-packs/js/application-4751feac1bb0404b9c47.js.map +1 -0
  112. data/public/avo-packs/js/application-4751feac1bb0404b9c47.js.map.br +0 -0
  113. data/public/avo-packs/js/application-4751feac1bb0404b9c47.js.map.gz +0 -0
  114. data/public/avo-packs/manifest.json +16 -16
  115. data/public/avo-packs/media/images/dadf2db36589607d107d.png +0 -0
  116. metadata +16 -31
  117. data/config/initializers/inline_svg.rb +0 -33
  118. data/public/avo-packs/css/application-38e7e91b.css.br +0 -0
  119. data/public/avo-packs/css/application-38e7e91b.css.gz +0 -0
  120. data/public/avo-packs/css/application-38e7e91b.css.map +0 -1
  121. data/public/avo-packs/css/application-38e7e91b.css.map.br +0 -0
  122. data/public/avo-packs/css/application-38e7e91b.css.map.gz +0 -0
  123. data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.br +0 -0
  124. data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.gz +0 -0
  125. data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.map +0 -1
  126. data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.map.br +0 -0
  127. data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.map.gz +0 -0
  128. data/public/avo-packs/media/images/f1b4befac91a3336db9a.png +0 -0
@@ -1,16 +1,16 @@
1
1
  module Avo
2
2
  module ResourcesHelper
3
3
  def resource_table(resources, resource)
4
- render partial: 'avo/partials/resource_table', locals: {
4
+ render partial: "avo/partials/resource_table", locals: {
5
5
  resources: resources,
6
- resource: resource,
6
+ resource: resource
7
7
  }
8
8
  end
9
9
 
10
10
  def resource_grid(resources, resource)
11
- render partial: 'avo/partials/resource_grid', locals: {
11
+ render partial: "avo/partials/resource_grid", locals: {
12
12
  resources: resources,
13
- resource: resource,
13
+ resource: resource
14
14
  }
15
15
  end
16
16
 
@@ -23,7 +23,7 @@ module Avo
23
23
  render partial: field.partial_path_for(:index), locals: {
24
24
  field: field,
25
25
  index: index,
26
- resource: resource,
26
+ resource: resource
27
27
  }
28
28
  end
29
29
  end
@@ -37,7 +37,7 @@ module Avo
37
37
  render partial: field.partial_path_for(:show), locals: {
38
38
  field: field,
39
39
  index: index,
40
- resource: resource,
40
+ resource: resource
41
41
  }
42
42
  end
43
43
  end
@@ -53,7 +53,7 @@ module Avo
53
53
  index: index,
54
54
  resource: resource,
55
55
  form: form,
56
- displayed_in_modal: displayed_in_modal,
56
+ displayed_in_modal: displayed_in_modal
57
57
  }
58
58
  end
59
59
  end
@@ -77,9 +77,9 @@ module Avo
77
77
  end
78
78
 
79
79
  def filter_wrapper(name: nil, index: nil, **args, &block)
80
- render layout: 'layouts/avo/filter_wrapper', locals: {
80
+ render layout: "layouts/avo/filter_wrapper", locals: {
81
81
  name: name,
82
- index: index,
82
+ index: index
83
83
  } do
84
84
  capture(&block)
85
85
  end
@@ -91,9 +91,9 @@ module Avo
91
91
 
92
92
  def item_selector_input(floating: false, size: :md)
93
93
  "<input type='checkbox'
94
- class='mx-3 #{'absolute inset-auto left-0 mt-2 z-10 hidden group-hover:block checked:block' if floating} #{size.to_sym == :lg ? 'w-5 h-5' : 'w-4 h-4'}'
94
+ class='mx-3 #{"absolute inset-auto left-0 mt-2 z-10 hidden group-hover:block checked:block" if floating} #{size.to_sym == :lg ? "w-5 h-5" : "w-4 h-4"}'
95
95
  data-action='input->item-selector#toggle'
96
- title='#{t 'avo.select_item' }'
96
+ title='#{t "avo.select_item"}'
97
97
  data-tippy='tooltip'
98
98
  />"
99
99
  end
@@ -1,6 +1,6 @@
1
1
  module Avo
2
2
  class ApplicationMailer < ::ActionMailer::Base
3
- default from: 'from@example.com'
4
- layout 'mailer'
3
+ default from: "from@example.com"
4
+ layout "mailer"
5
5
  end
6
6
  end
@@ -1,21 +1,23 @@
1
- import 'regenerator-runtime/runtime'
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
2
  import 'core-js/stable'
3
+ // eslint-disable-next-line import/no-extraneous-dependencies
4
+ import 'regenerator-runtime/runtime'
3
5
  import 'trix'
4
6
  import * as Mousetrap from 'mousetrap'
5
7
  import { Application } from 'stimulus'
6
8
  import { Turbo } from '@hotwired/turbo-rails'
7
9
  import { definitionsFromContext } from 'stimulus/webpack-helpers'
10
+ import Rails from '@rails/ujs'
8
11
  import tippy from 'tippy.js'
9
- import Rails from '@rails/ujs';
10
-
11
- Rails.start();
12
-
13
- window.Turbolinks = Turbo
14
12
 
15
13
  // Toastr alerts
16
14
  import '../js/toastr'
17
15
 
18
- Mousetrap.bind('r r r', () => Turbo.visit(window.location.href, { action: "replace" }))
16
+ Rails.start()
17
+
18
+ window.Turbolinks = Turbo
19
+
20
+ Mousetrap.bind('r r r', () => Turbo.visit(window.location.href, { action: 'replace' }))
19
21
 
20
22
  const application = Application.start()
21
23
 
Binary file
@@ -1,20 +1,20 @@
1
+ import 'codemirror/mode/css/css'
2
+
3
+ import 'codemirror/mode/dockerfile/dockerfile'
4
+ import 'codemirror/mode/htmlmixed/htmlmixed'
5
+ import 'codemirror/mode/javascript/javascript'
6
+ import 'codemirror/mode/markdown/markdown'
7
+ import 'codemirror/mode/nginx/nginx'
8
+ import 'codemirror/mode/php/php'
9
+ import 'codemirror/mode/ruby/ruby'
10
+ import 'codemirror/mode/sass/sass'
11
+ import 'codemirror/mode/shell/shell'
12
+ import 'codemirror/mode/sql/sql'
13
+ import 'codemirror/mode/vue/vue'
14
+ import 'codemirror/mode/xml/xml'
1
15
  import { Controller } from 'stimulus'
2
16
  import { castBoolean } from '@/js/helpers/cast_boolean'
3
17
  import CodeMirror from 'codemirror'
4
- import 'codemirror/mode/css/css.js'
5
- import 'codemirror/mode/css/css.js'
6
- import 'codemirror/mode/dockerfile/dockerfile.js'
7
- import 'codemirror/mode/htmlmixed/htmlmixed.js'
8
- import 'codemirror/mode/javascript/javascript.js'
9
- import 'codemirror/mode/markdown/markdown.js'
10
- import 'codemirror/mode/nginx/nginx.js'
11
- import 'codemirror/mode/php/php.js'
12
- import 'codemirror/mode/ruby/ruby.js'
13
- import 'codemirror/mode/sass/sass.js'
14
- import 'codemirror/mode/shell/shell.js'
15
- import 'codemirror/mode/sql/sql.js'
16
- import 'codemirror/mode/vue/vue.js'
17
- import 'codemirror/mode/xml/xml.js'
18
18
 
19
19
  export default class extends Controller {
20
20
  static targets = ['element']
@@ -36,13 +36,14 @@ export default class extends Controller {
36
36
  filters[filterClass] = value
37
37
 
38
38
  const filtered = Object.keys(filters)
39
- .filter(key => filters[key] !== '')
40
- .reduce((obj, key) => {
41
- obj[key] = filters[key];
42
- return obj;
43
- }, {});
39
+ .filter((key) => filters[key] !== '')
40
+ .reduce((obj, key) => {
41
+ obj[key] = filters[key]
44
42
 
45
- let encodedFilters;
43
+ return obj
44
+ }, {})
45
+
46
+ let encodedFilters
46
47
 
47
48
  if (filtered && Object.keys(filtered).length > 0) {
48
49
  encodedFilters = btoa(JSON.stringify(filtered))
@@ -55,9 +56,9 @@ export default class extends Controller {
55
56
  }
56
57
 
57
58
  if (encodedFilters) {
58
- query['filters'] = encodedFilters
59
+ query.filters = encodedFilters
59
60
  } else {
60
- delete query['filters']
61
+ delete query.filters
61
62
  }
62
63
 
63
64
  url.query(query)
@@ -4,6 +4,7 @@ toastr.options.showDuration = 400
4
4
  toastr.options.hideDuration = 400
5
5
  toastr.options.closeButton = true
6
6
  toastr.options.positionClass = 'toast-bottom-right'
7
+ // eslint-disable-next-line max-len
7
8
  toastr.options.closeHtml = '<button class="mt-2 mr-1"><svg class="w-4 h-4 text-gray-700" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /></svg></button>'
8
9
 
9
10
  window.toastr = toastr
data/avo.gemspec CHANGED
@@ -1,47 +1,46 @@
1
- $:.push File.expand_path('lib', __dir__)
1
+ $:.push File.expand_path("lib", __dir__)
2
2
 
3
3
  # Maintain your gem's version:
4
- require 'avo/version'
4
+ require "avo/version"
5
5
 
6
6
  # Describe your gem and declare its dependencies:
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'avo'
9
- spec.version = Avo::VERSION
10
- spec.authors = ['Adrian Marin', 'Mihai Marin']
11
- spec.email = ['avo@avohq.io']
12
- spec.homepage = 'https://avohq.io'
13
- spec.summary = 'Configuration-based, no-maintenance, extendable Ruby on Rails admin.'
14
- spec.description = 'Avo is a beautiful next-generation framework that empowers you, the developer, to create fantastic admin panels for your Ruby on Rails apps with the flexibility to fit your needs as you grow.'
15
- spec.license = 'Commercial'
8
+ spec.name = "avo"
9
+ spec.version = Avo::VERSION
10
+ spec.authors = ["Adrian Marin", "Mihai Marin"]
11
+ spec.email = ["avo@avohq.io"]
12
+ spec.homepage = "https://avohq.io"
13
+ spec.summary = "Configuration-based, no-maintenance, extendable Ruby on Rails admin."
14
+ spec.description = "Avo is a beautiful next-generation framework that empowers you, the developer, to create fantastic admin panels for your Ruby on Rails apps with the flexibility to fit your needs as you grow."
15
+ spec.license = "Commercial"
16
16
 
17
17
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
18
  # to allow pushing to a single host or delete this section to allow pushing to any host.
19
19
  if spec.respond_to?(:metadata)
20
- spec.metadata['bug_tracker_uri'] = 'https://github.com/avo-hq/avo/issues'
21
- spec.metadata['changelog_uri'] = 'https://avohq.io/releases'
22
- spec.metadata['documentation_uri'] = 'https://docs.avohq.io'
23
- spec.metadata['homepage_uri'] = 'https://avohq.io'
24
- spec.metadata['source_code_uri'] = 'https://github.com/avo-hq/avo'
20
+ spec.metadata["bug_tracker_uri"] = "https://github.com/avo-hq/avo/issues"
21
+ spec.metadata["changelog_uri"] = "https://avohq.io/releases"
22
+ spec.metadata["documentation_uri"] = "https://docs.avohq.io"
23
+ spec.metadata["homepage_uri"] = "https://avohq.io"
24
+ spec.metadata["source_code_uri"] = "https://github.com/avo-hq/avo"
25
25
  else
26
- raise 'RubyGems 2.0 or newer is required to protect against ' \
27
- 'public gem pushes.'
26
+ raise "RubyGems 2.0 or newer is required to protect against " \
27
+ "public gem pushes."
28
28
  end
29
29
 
30
30
  spec.post_install_message = "Thank you for using Avo! Docs are available at https://docs.avohq.io"
31
31
 
32
- spec.files = Dir['{bin,app,config,db,lib,public}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md', 'avo.gemspec', 'Gemfile', 'Gemfile.lock']
32
+ spec.files = Dir["{bin,app,config,db,lib,public}/**/*", "MIT-LICENSE", "Rakefile", "README.md", "avo.gemspec", "Gemfile", "Gemfile.lock"]
33
33
 
34
- spec.add_dependency 'rails', '>= 6.0'
35
- spec.add_dependency 'pagy'
36
- spec.add_dependency 'zeitwerk'
37
- spec.add_dependency 'inline_svg'
38
- spec.add_dependency 'webpacker'
39
- spec.add_dependency 'countries'
40
- spec.add_dependency 'pundit'
41
- spec.add_dependency 'httparty'
42
- spec.add_dependency 'active_link_to'
43
- spec.add_dependency 'image_processing'
44
- spec.add_dependency 'view_component'
45
- spec.add_dependency 'hotwire-rails'
46
- spec.add_dependency 'addressable'
34
+ spec.add_dependency "rails", ">= 6.0"
35
+ spec.add_dependency "pagy"
36
+ spec.add_dependency "zeitwerk"
37
+ spec.add_dependency "webpacker"
38
+ spec.add_dependency "countries"
39
+ spec.add_dependency "pundit"
40
+ spec.add_dependency "httparty"
41
+ spec.add_dependency "active_link_to"
42
+ spec.add_dependency "image_processing"
43
+ spec.add_dependency "view_component"
44
+ spec.add_dependency "hotwire-rails"
45
+ spec.add_dependency "addressable"
47
46
  end
@@ -1 +1 @@
1
- require 'pagy/extras/trim'
1
+ require "pagy/extras/trim"
data/config/routes.rb CHANGED
@@ -1,27 +1,27 @@
1
1
  Avo::Engine.routes.draw do
2
- root 'home#index'
2
+ root "home#index"
3
3
 
4
- get 'resources', to: redirect('/avo')
4
+ get "resources", to: redirect("/avo")
5
5
 
6
- scope 'resources', as: 'resources' do
6
+ scope "resources", as: "resources" do
7
7
  # Attachments
8
- get '/:resource_name/:id/active_storage_attachments/:attachment_name/:signed_attachment_id', to: 'attachments#show'
9
- delete '/:resource_name/:id/active_storage_attachments/:attachment_name/:signed_attachment_id', to: 'attachments#destroy'
8
+ get "/:resource_name/:id/active_storage_attachments/:attachment_name/:signed_attachment_id", to: "attachments#show"
9
+ delete "/:resource_name/:id/active_storage_attachments/:attachment_name/:signed_attachment_id", to: "attachments#destroy"
10
10
 
11
11
  # Actions
12
- get '/:resource_name(/:id)/actions/:action_id', to: 'actions#show'
13
- post '/:resource_name(/:id)/actions/:action_id', to: 'actions#handle'
12
+ get "/:resource_name(/:id)/actions/:action_id", to: "actions#show"
13
+ post "/:resource_name(/:id)/actions/:action_id", to: "actions#handle"
14
14
 
15
15
  # Generate resource routes as below:
16
16
  # resources :posts
17
17
  instance_eval(&Avo::App.draw_routes)
18
18
 
19
19
  # Relations
20
- get '/:resource_name/:id/:related_name/new', to: 'relations#new'
21
- get '/:resource_name/:id/:related_name/', to: 'relations#index'
22
- get '/:resource_name/:id/:related_name/:related_id', to: 'relations#show'
23
- post '/:resource_name/:id/:related_name', to: 'relations#create'
24
- delete '/:resource_name/:id/:related_name/:related_id', to: 'relations#destroy'
20
+ get "/:resource_name/:id/:related_name/new", to: "relations#new"
21
+ get "/:resource_name/:id/:related_name/", to: "relations#index"
22
+ get "/:resource_name/:id/:related_name/:related_id", to: "relations#show"
23
+ post "/:resource_name/:id/:related_name", to: "relations#create"
24
+ delete "/:resource_name/:id/:related_name/:related_id", to: "relations#destroy"
25
25
  end
26
26
 
27
27
  # get '/avo-api/search', to: 'search#index'
data/config/spring.rb CHANGED
@@ -1,7 +1,7 @@
1
- Spring.application_root = './spec/dummy'
1
+ Spring.application_root = "./spec/dummy"
2
2
  Spring.watch(
3
- '.ruby-version',
4
- '.rbenv-vars',
5
- 'tmp/restart.txt',
6
- 'tmp/caching-dev.txt'
3
+ ".ruby-version",
4
+ ".rbenv-vars",
5
+ "tmp/restart.txt",
6
+ "tmp/caching-dev.txt"
7
7
  )
@@ -3,8 +3,8 @@ const aliases = require('./aliases')
3
3
 
4
4
  const customConfig = {
5
5
  resolve: {
6
- extensions: ['.css']
7
- }
6
+ extensions: ['.css'],
7
+ },
8
8
  }
9
9
 
10
10
  const config = merge(webpackConfig, aliases, customConfig)
data/config/webpacker.yml CHANGED
@@ -29,6 +29,38 @@ development:
29
29
  # Cache manifest.json for performance
30
30
  cache_manifest: true
31
31
 
32
+ # Even though Avo does not use the dev_server when packed we still need to add the info here.
33
+ # The packed version of Avo will pick up the parent's app information.
34
+ # Reference: https://webpack.js.org/configuration/dev-server/
35
+ dev_server:
36
+ https: false
37
+ host: localhost
38
+ port: 3039
39
+ public: localhost:3039
40
+ # Inject browserside javascript that required by both HMR and Live(full) reload
41
+ inject_client: true
42
+ # Hot Module Replacement updates modules while the application is running without a full reload
43
+ hmr: true
44
+ # Inline should be set to true if using HMR; it inserts a script to take care of live reloading
45
+ inline: true
46
+ # Should we show a full-screen overlay in the browser when there are compiler errors or warnings?
47
+ overlay: true
48
+ # Should we use gzip compression?
49
+ compress: true
50
+ # Note that apps that do not check the host are vulnerable to DNS rebinding attacks
51
+ disable_host_check: true
52
+ # This option lets the browser open with your local IP
53
+ use_local_ip: false
54
+ # When enabled, nothing except the initial startup information will be written to the console.
55
+ # This also means that errors or warnings from webpack are not visible.
56
+ quiet: false
57
+ pretty: true
58
+ headers:
59
+ 'Access-Control-Allow-Origin': '*'
60
+ watch_options:
61
+ ignored: '**/node_modules/**'
62
+ env_prefix: "AVO_WEBPACKER_DEV_SERVER"
63
+
32
64
  test:
33
65
  <<: *default
34
66
  compile: true
data/db/factories.rb CHANGED
@@ -4,7 +4,7 @@ FactoryBot.define do
4
4
  last_name { Faker::Name.last_name }
5
5
  email { Faker::Internet.email }
6
6
  password { Faker::Internet.password }
7
- roles { { admin: false, manager: [true, false].sample, writer: [true, false].sample } }
7
+ roles { {admin: false, manager: [true, false].sample, writer: [true, false].sample} }
8
8
  birthday { Faker::Date.birthday(min_age: 18, max_age: 65) }
9
9
  custom_css { ".header {\n color: red;\n}" }
10
10
  end
@@ -22,8 +22,6 @@ FactoryBot.define do
22
22
  published_at do
23
23
  if [false, true].sample
24
24
  Time.now - rand(10...365).days
25
- else
26
- nil
27
25
  end
28
26
  end
29
27
  end
@@ -31,12 +29,12 @@ FactoryBot.define do
31
29
  factory :project do
32
30
  name { Faker::App.name }
33
31
  status { [:closed, :rejected, :failed, :loading, :running, :waiting].sample }
34
- stage { ['Discovery', 'Idea', 'Done', 'On hold', 'Cancelled'].sample }
32
+ stage { ["Discovery", "Idea", "Done", "On hold", "Cancelled"].sample }
35
33
  budget { Faker::Number.decimal(l_digits: 4) }
36
34
  country { Faker::Address.country_code }
37
35
  description { Faker::Markdown.sandwich(sentences: 5) }
38
36
  users_required { Faker::Number.between(from: 10, to: 100) }
39
37
  started_at { Time.now - rand(10...365).days }
40
- meta { [{ foo: 'bar', hey: 'hi' }, { bar: 'baz' }, { hoho: 'hohoho' }].sample }
38
+ meta { [{foo: "bar", hey: "hi"}, {bar: "baz"}, {hoho: "hohoho"}].sample }
41
39
  end
42
40
  end
data/lib/avo.rb CHANGED
@@ -1,20 +1,20 @@
1
- require 'zeitwerk'
2
- require_relative 'avo/version'
3
- require_relative 'avo/engine' if defined?(Rails)
1
+ require "zeitwerk"
2
+ require_relative "avo/version"
3
+ require_relative "avo/engine" if defined?(Rails)
4
4
 
5
5
  loader = Zeitwerk::Loader.for_gem
6
6
  loader.setup
7
7
 
8
8
  module Avo
9
- ROOT_PATH = Pathname.new(File.join(__dir__, '..'))
10
- IN_DEVELOPMENT = ENV['AVO_IN_DEVELOPMENT'] == '1'
9
+ ROOT_PATH = Pathname.new(File.join(__dir__, ".."))
10
+ IN_DEVELOPMENT = ENV["AVO_IN_DEVELOPMENT"] == "1"
11
11
  PACKED = !IN_DEVELOPMENT
12
12
 
13
13
  class << self
14
14
  def webpacker
15
15
  @webpacker ||= ::Webpacker::Instance.new(
16
16
  root_path: ROOT_PATH,
17
- config_path: ROOT_PATH.join('config/webpacker.yml')
17
+ config_path: ROOT_PATH.join("config/webpacker.yml")
18
18
  )
19
19
  end
20
20
  end
data/lib/avo/app.rb CHANGED
@@ -15,10 +15,10 @@ module Avo
15
15
 
16
16
  I18n.locale = Avo.configuration.language_code
17
17
 
18
- if Rails.cache.class == ActiveSupport::Cache::NullStore
19
- self.app[:cache_store] ||= ActiveSupport::Cache::MemoryStore.new
18
+ if Rails.cache.instance_of?(ActiveSupport::Cache::NullStore)
19
+ app[:cache_store] ||= ActiveSupport::Cache::MemoryStore.new
20
20
  else
21
- self.app[:cache_store] = Rails.cache
21
+ app[:cache_store] = Rails.cache
22
22
  end
23
23
  end
24
24
 
@@ -35,7 +35,7 @@ module Avo
35
35
  end
36
36
 
37
37
  def cache_store
38
- self.app[:cache_store]
38
+ app[:cache_store]
39
39
  end
40
40
 
41
41
  # This method will find all fields available in the Avo::Fields namespace and add them to the fields class_variable array
@@ -47,23 +47,23 @@ module Avo
47
47
  # Avo::Fields::DateTimeField -> date_time
48
48
  def init_fields
49
49
  Avo::Fields::BaseField.descendants.each do |class_name|
50
- next if class_name.to_s == 'BaseField'
50
+ next if class_name.to_s == "BaseField"
51
51
 
52
- if class_name.to_s.end_with? 'Field'
52
+ if class_name.to_s.end_with? "Field"
53
53
  load_field class_name.get_field_name, class_name
54
54
  end
55
55
  end
56
56
  end
57
57
 
58
58
  def load_field(method_name, klass)
59
- self.fields.push(
59
+ fields.push(
60
60
  name: method_name,
61
- class: klass,
61
+ class: klass
62
62
  )
63
63
  end
64
64
 
65
65
  def init_resources
66
- self.app[:resources] = BaseResource.descendants
66
+ app[:resources] = BaseResource.descendants
67
67
  .select do |resource|
68
68
  resource != BaseResource
69
69
  end
@@ -75,14 +75,14 @@ module Avo
75
75
  end
76
76
 
77
77
  def get_resources
78
- self.app[:resources]
78
+ app[:resources]
79
79
  end
80
80
 
81
81
  # Returns the Avo resource by camelized name
82
82
  #
83
83
  # get_resource_by_name('User') => UserResource
84
84
  def get_resource(resource)
85
- self.app[:resources].find do |available_resource|
85
+ app[:resources].find do |available_resource|
86
86
  "#{resource}Resource".safe_constantize == available_resource.class
87
87
  end
88
88
  end
@@ -91,7 +91,7 @@ module Avo
91
91
  #
92
92
  # get_resource_by_name('user') => UserResource
93
93
  def get_resource_by_name(name)
94
- self.get_resource name.singularize.camelize
94
+ get_resource name.singularize.camelize
95
95
  end
96
96
 
97
97
  # Returns the Avo resource by singular snake_cased name
@@ -110,7 +110,7 @@ module Avo
110
110
  # get_resource_by_controller_name('users') => UserResource
111
111
  def get_resource_by_controller_name(name)
112
112
  get_resources.find do |resource|
113
- resource.model_class.to_s.pluralize.underscore.gsub('/', '_') == name.to_s
113
+ resource.model_class.to_s.pluralize.underscore.tr("/", "_") == name.to_s
114
114
  end
115
115
  end
116
116
 
@@ -124,7 +124,7 @@ module Avo
124
124
  def get_available_resources(user = nil)
125
125
  App.get_resources
126
126
  .select do |resource|
127
- Services::AuthorizationService.authorize user, resource.model, Avo.configuration.authorization_methods.stringify_keys['index'], raise_exception: false
127
+ Services::AuthorizationService.authorize user, resource.model, Avo.configuration.authorization_methods.stringify_keys["index"], raise_exception: false
128
128
  end
129
129
  .sort_by { |r| r.name }
130
130
  end
@@ -139,17 +139,17 @@ module Avo
139
139
  # We should eager load all the classes so we find all descendants
140
140
  Rails.application.eager_load!
141
141
 
142
- Proc.new do
142
+ proc do
143
143
  BaseResource.descendants
144
144
  .select do |resource|
145
145
  resource != :BaseResource
146
146
  end
147
147
  .map do |resource|
148
148
  if resource.is_a? Class
149
- if resource.model_class.present?
150
- route_key = resource.model_class.model_name.route_key
149
+ route_key = if resource.model_class.present?
150
+ resource.model_class.model_name.route_key
151
151
  else
152
- route_key = resource.to_s.underscore.gsub('_resource', '').downcase.pluralize.to_sym
152
+ resource.to_s.underscore.gsub("_resource", "").downcase.pluralize.to_sym
153
153
  end
154
154
 
155
155
  resources route_key