activeadmin 2.6.1 → 2.13.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activeadmin might be problematic. Click here for more details.

Files changed (229) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +291 -9
  3. data/CONTRIBUTING.md +9 -25
  4. data/README.md +4 -4
  5. data/app/assets/javascripts/active_admin/base.js +27 -22
  6. data/app/assets/stylesheets/active_admin/_base.scss +53 -37
  7. data/app/assets/stylesheets/active_admin/_forms.scss +0 -10
  8. data/app/assets/stylesheets/active_admin/_header.scss +37 -3
  9. data/app/assets/stylesheets/active_admin/_normalize.scss +25 -123
  10. data/app/assets/stylesheets/active_admin/{print.scss → _print.scss} +0 -0
  11. data/app/assets/stylesheets/active_admin/components/_comments.scss +2 -2
  12. data/app/assets/stylesheets/active_admin/components/_date_picker.scss +1 -2
  13. data/app/assets/stylesheets/active_admin/components/_dropdown_menu.scss +0 -1
  14. data/app/assets/stylesheets/active_admin/mixins/_variables.scss +12 -0
  15. data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +0 -1
  16. data/app/javascript/active_admin/initializers/has-many.js +4 -1
  17. data/app/javascript/active_admin/initializers/per-page.js +1 -1
  18. data/app/javascript/active_admin/lib/checkbox-toggler.js +3 -3
  19. data/app/javascript/active_admin/lib/dropdown-menu.js +1 -1
  20. data/app/javascript/active_admin/lib/modal-dialog.js +7 -7
  21. data/app/javascript/active_admin/lib/per-page.js +1 -1
  22. data/app/javascript/active_admin/lib/table-checkbox-toggler.js +1 -1
  23. data/app/views/active_admin/devise/mailer/reset_password_instructions.html.erb +1 -1
  24. data/app/views/active_admin/devise/mailer/unlock_instructions.html.erb +2 -2
  25. data/app/views/active_admin/devise/shared/_links.erb +1 -1
  26. data/app/views/active_admin/page/index.html.arb +1 -0
  27. data/app/views/active_admin/resource/edit.html.arb +1 -0
  28. data/app/views/active_admin/resource/index.html.arb +1 -0
  29. data/app/views/active_admin/resource/new.html.arb +1 -0
  30. data/app/views/active_admin/resource/show.html.arb +1 -0
  31. data/app/views/layouts/active_admin.html.arb +1 -0
  32. data/app/views/layouts/active_admin_logged_out.html.erb +15 -5
  33. data/config/locales/ar.yml +6 -6
  34. data/config/locales/es-MX.yml +2 -1
  35. data/config/locales/es.yml +2 -2
  36. data/config/locales/it.yml +18 -0
  37. data/config/locales/ja.yml +3 -3
  38. data/config/locales/ko.yml +1 -1
  39. data/config/locales/nl.yml +1 -1
  40. data/config/locales/ro.yml +3 -2
  41. data/config/locales/vi.yml +5 -5
  42. data/docs/0-installation.md +27 -3
  43. data/docs/11-decorators.md +16 -5
  44. data/docs/2-resource-customization.md +10 -1
  45. data/docs/5-forms.md +9 -3
  46. data/docs/6-show-pages.md +12 -0
  47. data/docs/8-custom-actions.md +1 -1
  48. data/docs/Gemfile +3 -2
  49. data/docs/Gemfile.lock +138 -103
  50. data/docs/_includes/top-menu.html +1 -1
  51. data/docs/documentation.md +1 -1
  52. data/docs/index.html +6 -6
  53. data/lib/active_admin/abstract_view_factory.rb +1 -0
  54. data/lib/active_admin/application.rb +19 -19
  55. data/lib/active_admin/application_settings.rb +4 -3
  56. data/lib/active_admin/asset_registration.rb +1 -0
  57. data/lib/active_admin/authorization_adapter.rb +4 -3
  58. data/lib/active_admin/base_controller/authorization.rb +15 -13
  59. data/lib/active_admin/base_controller/menu.rb +1 -0
  60. data/lib/active_admin/base_controller.rb +6 -5
  61. data/lib/active_admin/batch_actions/controller.rb +4 -3
  62. data/lib/active_admin/batch_actions/resource_extension.rb +10 -8
  63. data/lib/active_admin/batch_actions/views/batch_action_form.rb +4 -3
  64. data/lib/active_admin/batch_actions/views/batch_action_selector.rb +7 -6
  65. data/lib/active_admin/batch_actions/views/selection_cells.rb +4 -3
  66. data/lib/active_admin/batch_actions.rb +1 -0
  67. data/lib/active_admin/callbacks.rb +1 -0
  68. data/lib/active_admin/cancan_adapter.rb +2 -1
  69. data/lib/active_admin/collection_decorator.rb +32 -0
  70. data/lib/active_admin/component.rb +1 -0
  71. data/lib/active_admin/controller_action.rb +1 -0
  72. data/lib/active_admin/csv_builder.rb +6 -19
  73. data/lib/active_admin/dependency.rb +13 -12
  74. data/lib/active_admin/deprecation.rb +1 -0
  75. data/lib/active_admin/devise.rb +16 -5
  76. data/lib/active_admin/dsl.rb +2 -1
  77. data/lib/active_admin/dynamic_setting.rb +1 -0
  78. data/lib/active_admin/dynamic_settings_node.rb +3 -2
  79. data/lib/active_admin/engine.rb +13 -9
  80. data/lib/active_admin/error.rb +1 -2
  81. data/lib/active_admin/filters/active.rb +2 -1
  82. data/lib/active_admin/filters/active_filter.rb +6 -6
  83. data/lib/active_admin/filters/active_sidebar.rb +4 -30
  84. data/lib/active_admin/filters/dsl.rb +1 -0
  85. data/lib/active_admin/filters/forms.rb +7 -6
  86. data/lib/active_admin/filters/formtastic_addons.rb +2 -6
  87. data/lib/active_admin/filters/resource_extension.rb +2 -1
  88. data/lib/active_admin/filters.rb +8 -7
  89. data/lib/active_admin/form_builder.rb +25 -20
  90. data/lib/active_admin/generators/boilerplate.rb +2 -1
  91. data/lib/active_admin/helpers/collection.rb +2 -0
  92. data/lib/active_admin/helpers/i18n.rb +1 -0
  93. data/lib/active_admin/helpers/optional_display.rb +3 -2
  94. data/lib/active_admin/helpers/routes/url_helpers.rb +1 -0
  95. data/lib/active_admin/helpers/scope_chain.rb +1 -0
  96. data/lib/active_admin/inputs/datepicker_input.rb +2 -1
  97. data/lib/active_admin/inputs/filters/base/search_method_select.rb +5 -4
  98. data/lib/active_admin/inputs/filters/base.rb +2 -1
  99. data/lib/active_admin/inputs/filters/boolean_input.rb +2 -1
  100. data/lib/active_admin/inputs/filters/check_boxes_input.rb +2 -1
  101. data/lib/active_admin/inputs/filters/date_picker_input.rb +1 -0
  102. data/lib/active_admin/inputs/filters/date_range_input.rb +1 -0
  103. data/lib/active_admin/inputs/filters/numeric_input.rb +1 -0
  104. data/lib/active_admin/inputs/filters/select_input.rb +3 -2
  105. data/lib/active_admin/inputs/filters/string_input.rb +1 -0
  106. data/lib/active_admin/inputs/filters/text_input.rb +1 -0
  107. data/lib/active_admin/inputs.rb +1 -0
  108. data/lib/active_admin/localizers/resource_localizer.rb +4 -3
  109. data/lib/active_admin/localizers.rb +2 -1
  110. data/lib/active_admin/menu.rb +7 -3
  111. data/lib/active_admin/menu_collection.rb +1 -0
  112. data/lib/active_admin/menu_item.rb +8 -7
  113. data/lib/active_admin/namespace.rb +15 -14
  114. data/lib/active_admin/namespace_settings.rb +9 -5
  115. data/lib/active_admin/order_clause.rb +2 -1
  116. data/lib/active_admin/orm/active_record/comments/comment.rb +4 -3
  117. data/lib/active_admin/orm/active_record/comments/namespace_helper.rb +1 -0
  118. data/lib/active_admin/orm/active_record/comments/resource_helper.rb +1 -0
  119. data/lib/active_admin/orm/active_record/comments/show_page_helper.rb +1 -0
  120. data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +20 -19
  121. data/lib/active_admin/orm/active_record/comments/views.rb +3 -2
  122. data/lib/active_admin/orm/active_record/comments.rb +20 -19
  123. data/lib/active_admin/orm/active_record.rb +2 -1
  124. data/lib/active_admin/orm/mongoid.rb +1 -0
  125. data/lib/active_admin/page.rb +2 -1
  126. data/lib/active_admin/page_controller.rb +1 -0
  127. data/lib/active_admin/page_dsl.rb +1 -0
  128. data/lib/active_admin/page_presenter.rb +1 -0
  129. data/lib/active_admin/pundit_adapter.rb +59 -15
  130. data/lib/active_admin/resource/action_items.rb +6 -5
  131. data/lib/active_admin/resource/attributes.rb +2 -1
  132. data/lib/active_admin/resource/belongs_to.rb +3 -2
  133. data/lib/active_admin/resource/controllers.rb +2 -1
  134. data/lib/active_admin/resource/includes.rb +1 -0
  135. data/lib/active_admin/resource/menu.rb +5 -4
  136. data/lib/active_admin/resource/model.rb +1 -0
  137. data/lib/active_admin/resource/naming.rb +5 -4
  138. data/lib/active_admin/resource/ordering.rb +1 -0
  139. data/lib/active_admin/resource/page_presenters.rb +1 -0
  140. data/lib/active_admin/resource/pagination.rb +1 -0
  141. data/lib/active_admin/resource/routes.rb +6 -7
  142. data/lib/active_admin/resource/scope_to.rb +8 -7
  143. data/lib/active_admin/resource/scopes.rb +1 -0
  144. data/lib/active_admin/resource/sidebars.rb +2 -1
  145. data/lib/active_admin/resource.rb +20 -19
  146. data/lib/active_admin/resource_collection.rb +1 -0
  147. data/lib/active_admin/resource_controller/action_builder.rb +1 -0
  148. data/lib/active_admin/resource_controller/data_access.rb +31 -5
  149. data/lib/active_admin/resource_controller/decorators.rb +7 -28
  150. data/lib/active_admin/resource_controller/polymorphic_routes.rb +1 -0
  151. data/lib/active_admin/resource_controller/resource_class_methods.rb +1 -0
  152. data/lib/active_admin/resource_controller/scoping.rb +1 -0
  153. data/lib/active_admin/resource_controller/sidebars.rb +1 -0
  154. data/lib/active_admin/resource_controller/streaming.rb +9 -7
  155. data/lib/active_admin/resource_controller.rb +13 -11
  156. data/lib/active_admin/resource_dsl.rb +11 -25
  157. data/lib/active_admin/router.rb +1 -0
  158. data/lib/active_admin/scope.rb +7 -6
  159. data/lib/active_admin/settings_node.rb +1 -0
  160. data/lib/active_admin/sidebar_section.rb +1 -0
  161. data/lib/active_admin/version.rb +2 -1
  162. data/lib/active_admin/view_factory.rb +18 -17
  163. data/lib/active_admin/view_helpers/active_admin_application_helper.rb +1 -0
  164. data/lib/active_admin/view_helpers/auto_link_helper.rb +1 -0
  165. data/lib/active_admin/view_helpers/breadcrumb_helper.rb +4 -3
  166. data/lib/active_admin/view_helpers/display_helper.rb +15 -7
  167. data/lib/active_admin/view_helpers/download_format_links_helper.rb +2 -1
  168. data/lib/active_admin/view_helpers/fields_for.rb +3 -2
  169. data/lib/active_admin/view_helpers/flash_helper.rb +1 -0
  170. data/lib/active_admin/view_helpers/form_helper.rb +1 -0
  171. data/lib/active_admin/view_helpers/method_or_proc_helper.rb +1 -0
  172. data/lib/active_admin/view_helpers/scope_name_helper.rb +1 -0
  173. data/lib/active_admin/view_helpers/sidebar_helper.rb +1 -0
  174. data/lib/active_admin/view_helpers/title_helper.rb +1 -0
  175. data/lib/active_admin/view_helpers/view_factory_helper.rb +1 -0
  176. data/lib/active_admin/view_helpers.rb +2 -1
  177. data/lib/active_admin/views/action_items.rb +1 -0
  178. data/lib/active_admin/views/components/active_admin_form.rb +7 -6
  179. data/lib/active_admin/views/components/active_filters_sidebar_content.rb +59 -0
  180. data/lib/active_admin/views/components/attributes_table.rb +6 -5
  181. data/lib/active_admin/views/components/blank_slate.rb +2 -1
  182. data/lib/active_admin/views/components/columns.rb +1 -0
  183. data/lib/active_admin/views/components/dropdown_menu.rb +7 -9
  184. data/lib/active_admin/views/components/index_list.rb +4 -3
  185. data/lib/active_admin/views/components/menu.rb +2 -1
  186. data/lib/active_admin/views/components/menu_item.rb +5 -4
  187. data/lib/active_admin/views/components/paginated_collection.rb +19 -18
  188. data/lib/active_admin/views/components/panel.rb +2 -1
  189. data/lib/active_admin/views/components/scopes.rb +8 -5
  190. data/lib/active_admin/views/components/sidebar.rb +1 -0
  191. data/lib/active_admin/views/components/sidebar_section.rb +1 -0
  192. data/lib/active_admin/views/components/site_title.rb +2 -1
  193. data/lib/active_admin/views/components/status_tag.rb +12 -11
  194. data/lib/active_admin/views/components/table_for.rb +18 -17
  195. data/lib/active_admin/views/components/tabs.rb +4 -3
  196. data/lib/active_admin/views/components/unsupported_browser.rb +1 -0
  197. data/lib/active_admin/views/footer.rb +3 -1
  198. data/lib/active_admin/views/header.rb +3 -2
  199. data/lib/active_admin/views/index_as_block.rb +1 -0
  200. data/lib/active_admin/views/index_as_blog.rb +2 -1
  201. data/lib/active_admin/views/index_as_grid.rb +2 -1
  202. data/lib/active_admin/views/index_as_table.rb +17 -16
  203. data/lib/active_admin/views/pages/base.rb +14 -9
  204. data/lib/active_admin/views/pages/form.rb +1 -0
  205. data/lib/active_admin/views/pages/index.rb +15 -13
  206. data/lib/active_admin/views/pages/layout.rb +1 -0
  207. data/lib/active_admin/views/pages/page.rb +1 -0
  208. data/lib/active_admin/views/pages/show.rb +1 -0
  209. data/lib/active_admin/views/tabbed_navigation.rb +3 -2
  210. data/lib/active_admin/views/title_bar.rb +2 -1
  211. data/lib/active_admin/views.rb +2 -1
  212. data/lib/active_admin.rb +61 -61
  213. data/lib/activeadmin.rb +2 -1
  214. data/lib/generators/active_admin/assets/assets_generator.rb +3 -2
  215. data/lib/generators/active_admin/assets/templates/active_admin.scss +2 -2
  216. data/lib/generators/active_admin/devise/devise_generator.rb +6 -5
  217. data/lib/generators/active_admin/install/install_generator.rb +15 -8
  218. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +9 -2
  219. data/lib/generators/active_admin/install/templates/dashboard.rb +1 -0
  220. data/lib/generators/active_admin/page/page_generator.rb +2 -1
  221. data/lib/generators/active_admin/page/templates/page.rb +1 -0
  222. data/lib/generators/active_admin/resource/resource_generator.rb +4 -3
  223. data/lib/generators/active_admin/webpacker/plugins/jquery.js +7 -0
  224. data/lib/generators/active_admin/webpacker/templates/active_admin.js +5 -0
  225. data/lib/generators/active_admin/webpacker/templates/active_admin.scss +17 -0
  226. data/lib/generators/active_admin/webpacker/templates/print.scss +2 -0
  227. data/lib/generators/active_admin/webpacker/webpacker_generator.rb +27 -0
  228. data/lib/ransack_ext.rb +9 -8
  229. metadata +32 -53
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveAdmin
2
3
  module Views
3
4
  class UnsupportedBrowser < Component
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveAdmin
2
3
  module Views
3
4
  class Footer < Component
@@ -20,7 +21,8 @@ module ActiveAdmin
20
21
  end
21
22
 
22
23
  def powered_by_message
23
- I18n.t('active_admin.powered_by',
24
+ I18n.t(
25
+ "active_admin.powered_by",
24
26
  active_admin: link_to("Active Admin", "https://activeadmin.info"),
25
27
  version: ActiveAdmin::VERSION).html_safe
26
28
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveAdmin
2
3
  module Views
3
4
  class Header < Component
@@ -10,8 +11,8 @@ module ActiveAdmin
10
11
  @utility_menu = @namespace.fetch_menu(:utility_navigation)
11
12
 
12
13
  site_title @namespace
13
- global_navigation @menu, class: 'header-item tabs'
14
- utility_navigation @utility_menu, id: "utility_nav", class: 'header-item tabs'
14
+ global_navigation @menu, class: "header-item tabs"
15
+ utility_navigation @utility_menu, id: "utility_nav", class: "header-item tabs"
15
16
  end
16
17
 
17
18
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveAdmin
2
3
  module Views
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveAdmin
2
3
  module Views
3
4
 
@@ -135,7 +136,7 @@ module ActiveAdmin
135
136
 
136
137
  def build_body(post)
137
138
  if @body
138
- div class: 'content' do
139
+ div class: "content" do
139
140
  render_method_on_post_or_call_proc post, @body
140
141
  end
141
142
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveAdmin
2
3
  module Views
3
4
 
@@ -68,7 +69,7 @@ module ActiveAdmin
68
69
  end
69
70
 
70
71
  def build_empty_cell
71
- td '&nbsp;'.html_safe
72
+ td "&nbsp;".html_safe
72
73
  end
73
74
 
74
75
  def default_number_of_columns
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveAdmin
2
3
  module Views
3
4
 
@@ -278,13 +279,13 @@ module ActiveAdmin
278
279
  # Display a column for checkbox
279
280
  def selectable_column
280
281
  return unless active_admin_config.batch_actions.any?
281
- column resource_selection_toggle_cell, class: 'col-selectable', sortable: false do |resource|
282
+ column resource_selection_toggle_cell, class: "col-selectable", sortable: false do |resource|
282
283
  resource_selection_cell resource
283
284
  end
284
285
  end
285
286
 
286
287
  def index_column(start_value = 1)
287
- column '#', class: 'col-index', sortable: false do |resource|
288
+ column "#", class: "col-index", sortable: false do |resource|
288
289
  @collection.offset_value + @collection.index(resource) + start_value
289
290
  end
290
291
  end
@@ -293,9 +294,9 @@ module ActiveAdmin
293
294
  def id_column
294
295
  raise "#{resource_class.name} has no primary_key!" unless resource_class.primary_key
295
296
  column(resource_class.human_attribute_name(resource_class.primary_key), sortable: resource_class.primary_key) do |resource|
296
- if controller.action_methods.include?('show')
297
+ if controller.action_methods.include?("show")
297
298
  link_to resource.id, resource_path(resource), class: "resource_id_link"
298
- elsif controller.action_methods.include?('edit')
299
+ elsif controller.action_methods.include?("edit")
299
300
  link_to resource.id, edit_resource_path(resource), class: "resource_id_link"
300
301
  else
301
302
  resource.id
@@ -304,7 +305,7 @@ module ActiveAdmin
304
305
  end
305
306
 
306
307
  def default_actions
307
- raise '`default_actions` is no longer provided in ActiveAdmin 1.x. Use `actions` instead.'
308
+ raise "`default_actions` is no longer provided in ActiveAdmin 1.x. Use `actions` instead."
308
309
  end
309
310
 
310
311
  # Add links to perform actions.
@@ -344,12 +345,12 @@ module ActiveAdmin
344
345
  #
345
346
  # ```
346
347
  def actions(options = {}, &block)
347
- name = options.delete(:name) { '' }
348
- defaults = options.delete(:defaults) { true }
349
- dropdown = options.delete(:dropdown) { false }
350
- dropdown_name = options.delete(:dropdown_name) { I18n.t 'active_admin.dropdown_actions.button_label', default: 'Actions' }
348
+ name = options.delete(:name) { "" }
349
+ defaults = options.delete(:defaults) { true }
350
+ dropdown = options.delete(:dropdown) { false }
351
+ dropdown_name = options.delete(:dropdown_name) { I18n.t "active_admin.dropdown_actions.button_label", default: "Actions" }
351
352
 
352
- options[:class] ||= 'col-actions'
353
+ options[:class] ||= "col-actions"
353
354
 
354
355
  column name, options do |resource|
355
356
  if dropdown
@@ -373,23 +374,23 @@ module ActiveAdmin
373
374
 
374
375
  def defaults(resource, options = {})
375
376
  localizer = ActiveAdmin::Localizers.resource(active_admin_config)
376
- if controller.action_methods.include?('show') && authorized?(ActiveAdmin::Auth::READ, resource)
377
+ if controller.action_methods.include?("show") && authorized?(ActiveAdmin::Auth::READ, resource)
377
378
  item localizer.t(:view), resource_path(resource), class: "view_link #{options[:css_class]}", title: localizer.t(:view)
378
379
  end
379
- if controller.action_methods.include?('edit') && authorized?(ActiveAdmin::Auth::UPDATE, resource)
380
+ if controller.action_methods.include?("edit") && authorized?(ActiveAdmin::Auth::UPDATE, resource)
380
381
  item localizer.t(:edit), edit_resource_path(resource), class: "edit_link #{options[:css_class]}", title: localizer.t(:edit)
381
382
  end
382
- if controller.action_methods.include?('destroy') && authorized?(ActiveAdmin::Auth::DESTROY, resource)
383
+ if controller.action_methods.include?("destroy") && authorized?(ActiveAdmin::Auth::DESTROY, resource)
383
384
  item localizer.t(:delete), resource_path(resource), class: "delete_link #{options[:css_class]}", title: localizer.t(:delete),
384
- method: :delete, data: { confirm: localizer.t(:delete_confirmation) }
385
+ method: :delete, data: { confirm: localizer.t(:delete_confirmation) }
385
386
  end
386
387
  end
387
388
 
388
389
  class TableActions < ActiveAdmin::Component
389
390
  builder_method :table_actions
390
391
 
391
- def item *args
392
- text_node link_to *args
392
+ def item *args, **kwargs
393
+ text_node link_to(*args, **kwargs)
393
394
  end
394
395
  end
395
396
  end # IndexTableFor
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveAdmin
2
3
  module Views
3
4
  module Pages
@@ -15,7 +16,7 @@ module ActiveAdmin
15
16
  end
16
17
 
17
18
  def main_content
18
- I18n.t('active_admin.main_content', model: title).html_safe
19
+ I18n.t("active_admin.main_content", model: title).html_safe
19
20
  end
20
21
 
21
22
  private
@@ -29,7 +30,8 @@ module ActiveAdmin
29
30
  text_node(active_admin_namespace.head)
30
31
 
31
32
  active_admin_application.stylesheets.each do |style, options|
32
- text_node stylesheet_link_tag(style, options).html_safe
33
+ stylesheet_tag = active_admin_namespace.use_webpacker ? stylesheet_pack_tag(style, **options) : stylesheet_link_tag(style, **options)
34
+ text_node(stylesheet_tag.html_safe) if stylesheet_tag
33
35
  end
34
36
 
35
37
  active_admin_namespace.meta_tags.each do |name, content|
@@ -37,11 +39,14 @@ module ActiveAdmin
37
39
  end
38
40
 
39
41
  active_admin_application.javascripts.each do |path|
40
- text_node(javascript_include_tag(path))
42
+ javascript_tag = active_admin_namespace.use_webpacker ? javascript_pack_tag(path) : javascript_include_tag(path)
43
+ text_node(javascript_tag)
41
44
  end
42
45
 
43
46
  if active_admin_namespace.favicon
44
- text_node(favicon_link_tag(active_admin_namespace.favicon))
47
+ favicon = active_admin_namespace.favicon
48
+ favicon_tag = active_admin_namespace.use_webpacker ? favicon_pack_tag(favicon) : favicon_link_tag(favicon)
49
+ text_node(favicon_tag)
45
50
  end
46
51
 
47
52
  text_node csrf_meta_tag
@@ -63,9 +68,9 @@ module ActiveAdmin
63
68
  def body_classes
64
69
  Arbre::HTML::ClassList.new [
65
70
  params[:action],
66
- params[:controller].tr('/', '_'),
67
- 'active_admin', 'logged_in',
68
- active_admin_namespace.name.to_s + '_namespace'
71
+ params[:controller].tr("/", "_"),
72
+ "active_admin", "logged_in",
73
+ active_admin_namespace.name.to_s + "_namespace"
69
74
  ]
70
75
  end
71
76
 
@@ -79,12 +84,12 @@ module ActiveAdmin
79
84
  build_flash_messages
80
85
  div id: "active_admin_content", class: (skip_sidebar? ? "without_sidebar" : "with_sidebar") do
81
86
  build_main_content_wrapper
82
- sidebar sidebar_sections_for_action, id: 'sidebar' unless skip_sidebar?
87
+ sidebar sidebar_sections_for_action, id: "sidebar" unless skip_sidebar?
83
88
  end
84
89
  end
85
90
 
86
91
  def build_flash_messages
87
- div class: 'flashes' do
92
+ div class: "flashes" do
88
93
  flash_messages.each do |type, messages|
89
94
  [*messages].each do |message|
90
95
  div message, class: "flash flash_#{type}"
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveAdmin
2
3
  module Views
3
4
  module Pages
@@ -1,4 +1,5 @@
1
- require 'active_admin/helpers/collection'
1
+ # frozen_string_literal: true
2
+ require "active_admin/helpers/collection"
2
3
 
3
4
  module ActiveAdmin
4
5
  module Views
@@ -111,7 +112,7 @@ module ActiveAdmin
111
112
 
112
113
  def render_blank_slate
113
114
  blank_slate_content = I18n.t("active_admin.blank_slate.content", resource_name: active_admin_config.plural_resource_label)
114
- if controller.action_methods.include?('new') && authorized?(ActiveAdmin::Auth::CREATE, active_admin_config.resource_class)
115
+ if controller.action_methods.include?("new") && authorized?(ActiveAdmin::Auth::CREATE, active_admin_config.resource_class)
115
116
  blank_slate_content = [blank_slate_content, blank_slate_link].compact.join(" ")
116
117
  end
117
118
  insert_tag(view_factory.blank_slate, blank_slate_content)
@@ -125,18 +126,19 @@ module ActiveAdmin
125
126
  def render_index
126
127
  renderer_class = find_index_renderer_class(config[:as])
127
128
 
128
- paginator = config.fetch(:paginator, true)
129
- download_links = config.fetch(:download_links, active_admin_config.namespace.download_links)
129
+ paginator = config.fetch(:paginator, true)
130
+ download_links = config.fetch(:download_links, active_admin_config.namespace.download_links)
130
131
  pagination_total = config.fetch(:pagination_total, true)
131
- per_page = config.fetch(:per_page, active_admin_config.per_page)
132
-
133
- paginated_collection(collection, entry_name: active_admin_config.resource_label,
134
- entries_name: active_admin_config.plural_resource_label(count: collection_size),
135
- download_links: download_links,
136
- paginator: paginator,
137
- per_page: per_page,
138
- pagination_total: pagination_total) do
139
- div class: 'index_content' do
132
+ per_page = config.fetch(:per_page, active_admin_config.per_page)
133
+
134
+ paginated_collection(
135
+ collection, entry_name: active_admin_config.resource_label,
136
+ entries_name: active_admin_config.plural_resource_label(count: collection_size),
137
+ download_links: download_links,
138
+ paginator: paginator,
139
+ per_page: per_page,
140
+ pagination_total: pagination_total) do
141
+ div class: "index_content" do
140
142
  insert_tag(renderer_class, config, collection)
141
143
  end
142
144
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveAdmin
2
3
  module Views
3
4
  module Pages
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveAdmin
2
3
  module Views
3
4
  module Pages
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveAdmin
2
3
  module Views
3
4
  module Pages
@@ -1,10 +1,11 @@
1
- require_relative 'components/menu'
1
+ # frozen_string_literal: true
2
+ require_relative "components/menu"
2
3
 
3
4
  module ActiveAdmin
4
5
  module Views
5
6
  class TabbedNavigation < Menu
6
7
  def build(menu, options = {})
7
- super(menu, options.reverse_merge(id: 'tabs'))
8
+ super(menu, options.reverse_merge(id: "tabs"))
8
9
  end
9
10
  end
10
11
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveAdmin
2
3
  module Views
3
4
  class TitleBar < Component
@@ -43,7 +44,7 @@ module ActiveAdmin
43
44
  end
44
45
 
45
46
  def build_title_tag
46
- h2(@title, id: 'page_title')
47
+ h2(@title, id: "page_title")
47
48
  end
48
49
 
49
50
  def build_action_items
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveAdmin
2
3
  module Views
3
4
 
4
5
  # Loads all the classes in views/*.rb
5
- Dir[File.expand_path('views', __dir__) + "/**/*.rb"].sort.each { |f| require f }
6
+ Dir[File.expand_path("views", __dir__) + "/**/*.rb"].sort.each { |f| require f }
6
7
 
7
8
  end
8
9
  end
data/lib/active_admin.rb CHANGED
@@ -1,58 +1,58 @@
1
- require 'active_support/core_ext'
2
- require 'set'
1
+ # frozen_string_literal: true
2
+ require "active_support/core_ext"
3
+ require "set"
3
4
 
4
- require 'ransack'
5
- require 'ransack_ext'
6
- require 'kaminari'
7
- require 'formtastic'
8
- require 'formtastic_i18n'
9
- require 'inherited_resources'
10
- require 'jquery-rails'
11
- require 'sassc-rails'
12
- require 'arbre'
5
+ require "ransack"
6
+ require "ransack_ext"
7
+ require "kaminari"
8
+ require "formtastic"
9
+ require "formtastic_i18n"
10
+ require "inherited_resources"
11
+ require "jquery-rails"
12
+ require "arbre"
13
13
 
14
- require 'active_admin/helpers/i18n'
14
+ require "active_admin/helpers/i18n"
15
15
 
16
16
  module ActiveAdmin
17
17
 
18
- autoload :VERSION, 'active_admin/version'
19
- autoload :Application, 'active_admin/application'
20
- autoload :AssetRegistration, 'active_admin/asset_registration'
21
- autoload :Authorization, 'active_admin/authorization_adapter'
22
- autoload :AuthorizationAdapter, 'active_admin/authorization_adapter'
23
- autoload :Callbacks, 'active_admin/callbacks'
24
- autoload :Component, 'active_admin/component'
25
- autoload :BaseController, 'active_admin/base_controller'
26
- autoload :CanCanAdapter, 'active_admin/cancan_adapter'
27
- autoload :ControllerAction, 'active_admin/controller_action'
28
- autoload :CSVBuilder, 'active_admin/csv_builder'
29
- autoload :Dependency, 'active_admin/dependency'
30
- autoload :Deprecation, 'active_admin/deprecation'
31
- autoload :Devise, 'active_admin/devise'
32
- autoload :DSL, 'active_admin/dsl'
33
- autoload :FormBuilder, 'active_admin/form_builder'
34
- autoload :Inputs, 'active_admin/inputs'
35
- autoload :Localizers, 'active_admin/localizers'
36
- autoload :Menu, 'active_admin/menu'
37
- autoload :MenuCollection, 'active_admin/menu_collection'
38
- autoload :MenuItem, 'active_admin/menu_item'
39
- autoload :Namespace, 'active_admin/namespace'
40
- autoload :OrderClause, 'active_admin/order_clause'
41
- autoload :Page, 'active_admin/page'
42
- autoload :PagePresenter, 'active_admin/page_presenter'
43
- autoload :PageController, 'active_admin/page_controller'
44
- autoload :PageDSL, 'active_admin/page_dsl'
45
- autoload :PunditAdapter, 'active_admin/pundit_adapter'
46
- autoload :Resource, 'active_admin/resource'
47
- autoload :ResourceController, 'active_admin/resource_controller'
48
- autoload :ResourceDSL, 'active_admin/resource_dsl'
49
- autoload :Scope, 'active_admin/scope'
50
- autoload :ScopeChain, 'active_admin/helpers/scope_chain'
51
- autoload :SidebarSection, 'active_admin/sidebar_section'
52
- autoload :TableBuilder, 'active_admin/table_builder'
53
- autoload :ViewFactory, 'active_admin/view_factory'
54
- autoload :ViewHelpers, 'active_admin/view_helpers'
55
- autoload :Views, 'active_admin/views'
18
+ autoload :VERSION, "active_admin/version"
19
+ autoload :Application, "active_admin/application"
20
+ autoload :AssetRegistration, "active_admin/asset_registration"
21
+ autoload :Authorization, "active_admin/authorization_adapter"
22
+ autoload :AuthorizationAdapter, "active_admin/authorization_adapter"
23
+ autoload :Callbacks, "active_admin/callbacks"
24
+ autoload :Component, "active_admin/component"
25
+ autoload :BaseController, "active_admin/base_controller"
26
+ autoload :CanCanAdapter, "active_admin/cancan_adapter"
27
+ autoload :ControllerAction, "active_admin/controller_action"
28
+ autoload :CSVBuilder, "active_admin/csv_builder"
29
+ autoload :Dependency, "active_admin/dependency"
30
+ autoload :Deprecation, "active_admin/deprecation"
31
+ autoload :Devise, "active_admin/devise"
32
+ autoload :DSL, "active_admin/dsl"
33
+ autoload :FormBuilder, "active_admin/form_builder"
34
+ autoload :Inputs, "active_admin/inputs"
35
+ autoload :Localizers, "active_admin/localizers"
36
+ autoload :Menu, "active_admin/menu"
37
+ autoload :MenuCollection, "active_admin/menu_collection"
38
+ autoload :MenuItem, "active_admin/menu_item"
39
+ autoload :Namespace, "active_admin/namespace"
40
+ autoload :OrderClause, "active_admin/order_clause"
41
+ autoload :Page, "active_admin/page"
42
+ autoload :PagePresenter, "active_admin/page_presenter"
43
+ autoload :PageController, "active_admin/page_controller"
44
+ autoload :PageDSL, "active_admin/page_dsl"
45
+ autoload :PunditAdapter, "active_admin/pundit_adapter"
46
+ autoload :Resource, "active_admin/resource"
47
+ autoload :ResourceController, "active_admin/resource_controller"
48
+ autoload :ResourceDSL, "active_admin/resource_dsl"
49
+ autoload :Scope, "active_admin/scope"
50
+ autoload :ScopeChain, "active_admin/helpers/scope_chain"
51
+ autoload :SidebarSection, "active_admin/sidebar_section"
52
+ autoload :TableBuilder, "active_admin/table_builder"
53
+ autoload :ViewFactory, "active_admin/view_factory"
54
+ autoload :ViewHelpers, "active_admin/view_helpers"
55
+ autoload :Views, "active_admin/views"
56
56
 
57
57
  class << self
58
58
 
@@ -69,11 +69,11 @@ module ActiveAdmin
69
69
  application.prepare!
70
70
  end
71
71
 
72
- delegate :register, to: :application
72
+ delegate :register, to: :application
73
73
  delegate :register_page, to: :application
74
- delegate :unload!, to: :application
75
- delegate :load!, to: :application
76
- delegate :routes, to: :application
74
+ delegate :unload!, to: :application
75
+ delegate :load!, to: :application
76
+ delegate :routes, to: :application
77
77
 
78
78
  # A callback is triggered each time (before) Active Admin loads the configuration files.
79
79
  # In development mode, this will happen whenever the user changes files. In production
@@ -113,7 +113,7 @@ module ActiveAdmin
113
113
  private
114
114
 
115
115
  def wrap_block_for_active_support_notifications block
116
- proc { |event, *args| block.call *args }
116
+ proc { |_name, _start, _finish, _id, payload| block.call payload[:active_admin_application] }
117
117
  end
118
118
 
119
119
  end
@@ -121,13 +121,13 @@ module ActiveAdmin
121
121
  end
122
122
 
123
123
  # Require things that don't support autoload
124
- require 'active_admin/engine'
125
- require 'active_admin/error'
124
+ require "active_admin/engine"
125
+ require "active_admin/error"
126
126
 
127
127
  # Require internal plugins
128
- require 'active_admin/batch_actions'
129
- require 'active_admin/filters'
128
+ require "active_admin/batch_actions"
129
+ require "active_admin/filters"
130
130
 
131
131
  # Require ORM-specific plugins
132
- require 'active_admin/orm/active_record' if defined? ActiveRecord
133
- require 'active_admin/orm/mongoid' if defined? Mongoid
132
+ require "active_admin/orm/active_record" if defined? ActiveRecord
133
+ require "active_admin/orm/mongoid" if defined? Mongoid
data/lib/activeadmin.rb CHANGED
@@ -1 +1,2 @@
1
- require 'active_admin'
1
+ # frozen_string_literal: true
2
+ require "active_admin"
@@ -1,11 +1,12 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveAdmin
2
3
  module Generators
3
4
  class AssetsGenerator < Rails::Generators::Base
4
5
 
5
- source_root File.expand_path('templates', __dir__)
6
+ source_root File.expand_path("templates", __dir__)
6
7
 
7
8
  def install_assets
8
- template 'active_admin.js', 'app/assets/javascripts/active_admin.js'
9
+ template "active_admin.js", "app/assets/javascripts/active_admin.js"
9
10
  template "active_admin.scss", "app/assets/stylesheets/active_admin.scss"
10
11
  end
11
12
 
@@ -1,4 +1,4 @@
1
- // SASS variable overrides must be declared before loading up Active Admin's styles.
1
+ // Sass variable overrides must be declared before loading up Active Admin's styles.
2
2
  //
3
3
  // To view the variables that Active Admin provides, take a look at
4
4
  // `app/assets/stylesheets/active_admin/mixins/_variables.scss` in the
@@ -11,7 +11,7 @@
11
11
  @import "active_admin/mixins";
12
12
  @import "active_admin/base";
13
13
 
14
- // Overriding any non-variable SASS must be done after the fact.
14
+ // Overriding any non-variable Sass must be done after the fact.
15
15
  // For example, to change the default status-tag color:
16
16
  //
17
17
  // .status_tag { background: #6090DB; }
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "active_admin/error"
2
3
  require "active_admin/dependency"
3
4
 
@@ -7,13 +8,13 @@ module ActiveAdmin
7
8
  desc "Creates an admin user and uses Devise for authentication"
8
9
  argument :name, type: :string, default: "AdminUser"
9
10
 
10
- class_option :registerable, type: :boolean, default: false,
11
- desc: "Should the generated resource be registerable?"
11
+ class_option :registerable, type: :boolean, default: false,
12
+ desc: "Should the generated resource be registerable?"
12
13
 
13
14
  RESERVED_NAMES = [:active_admin_user]
14
15
 
15
- class_option :default_user, type: :boolean, default: true,
16
- desc: "Should a default user be created inside the migration?"
16
+ class_option :default_user, type: :boolean, default: true,
17
+ desc: "Should a default user be created inside the migration?"
17
18
 
18
19
  def install_devise
19
20
  begin
@@ -22,7 +23,7 @@ module ActiveAdmin
22
23
  raise ActiveAdmin::GeneratorError, "#{e.message} If you don't want to use devise, run the generator with --skip-users."
23
24
  end
24
25
 
25
- require 'devise'
26
+ require "devise"
26
27
 
27
28
  initializer_file =
28
29
  File.join(destination_root, "config", "initializers", "devise.rb")
@@ -1,4 +1,5 @@
1
- require 'rails/generators/active_record'
1
+ # frozen_string_literal: true
2
+ require "rails/generators/active_record"
2
3
 
3
4
  module ActiveAdmin
4
5
  module Generators
@@ -8,22 +9,24 @@ module ActiveAdmin
8
9
 
9
10
  hook_for :users, default: "devise", desc: "Admin user generator to run. Skip with --skip-users"
10
11
  class_option :skip_comments, type: :boolean, default: false, desc: "Skip installation of comments"
12
+ class_option :use_webpacker, type: :boolean, default: false, desc: "Use Webpacker assets instead of Sprockets"
11
13
 
12
- source_root File.expand_path('templates', __dir__)
14
+ source_root File.expand_path("templates", __dir__)
13
15
 
14
16
  def copy_initializer
15
- @underscored_user_name = name.underscore.gsub('/', '_')
17
+ @underscored_user_name = name.underscore.gsub("/", "_")
16
18
  @use_authentication_method = options[:users].present?
17
19
  @skip_comments = options[:skip_comments]
18
- template 'active_admin.rb.erb', 'config/initializers/active_admin.rb'
20
+ @use_webpacker = options[:use_webpacker]
21
+ template "active_admin.rb.erb", "config/initializers/active_admin.rb"
19
22
  end
20
23
 
21
24
  def setup_directory
22
25
  empty_directory "app/admin"
23
- template 'dashboard.rb', 'app/admin/dashboard.rb'
26
+ template "dashboard.rb", "app/admin/dashboard.rb"
24
27
  if options[:users].present?
25
28
  @user_class = name
26
- template 'admin_users.rb.erb', "app/admin/#{name.underscore.pluralize}.rb"
29
+ template "admin_users.rb.erb", "app/admin/#{name.underscore.pluralize}.rb"
27
30
  end
28
31
  end
29
32
 
@@ -36,12 +39,16 @@ module ActiveAdmin
36
39
  end
37
40
 
38
41
  def create_assets
39
- generate "active_admin:assets"
42
+ if options[:use_webpacker]
43
+ generate "active_admin:webpacker"
44
+ else
45
+ generate "active_admin:assets"
46
+ end
40
47
  end
41
48
 
42
49
  def create_migrations
43
50
  unless options[:skip_comments]
44
- migration_template 'migrations/create_active_admin_comments.rb.erb', 'db/migrate/create_active_admin_comments.rb'
51
+ migration_template "migrations/create_active_admin_comments.rb.erb", "db/migrate/create_active_admin_comments.rb"
45
52
  end
46
53
  end
47
54
  end