activeadmin 4.0.0.beta2 → 4.0.0.beta22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -2
  3. data/CONTRIBUTING.md +13 -13
  4. data/README.md +4 -4
  5. data/UPGRADING.md +274 -0
  6. data/app/controllers/active_admin/base_controller/authorization.rb +1 -1
  7. data/app/controllers/active_admin/base_controller/menu.rb +2 -2
  8. data/app/controllers/active_admin/resource_controller/data_access.rb +9 -4
  9. data/app/controllers/active_admin/resource_controller/decorators.rb +1 -1
  10. data/app/controllers/active_admin/resource_controller/streaming.rb +3 -3
  11. data/app/controllers/active_admin/resource_controller.rb +1 -1
  12. data/app/helpers/active_admin/display_helper.rb +3 -3
  13. data/app/helpers/active_admin/form_helper.rb +1 -1
  14. data/app/helpers/active_admin/layout_helper.rb +2 -2
  15. data/app/javascript/active_admin/features/batch_actions.js +10 -4
  16. data/app/javascript/active_admin/features/main_menu.js +3 -2
  17. data/app/views/active_admin/_flash_messages.html.erb +4 -4
  18. data/app/views/active_admin/_main_navigation.html.erb +28 -11
  19. data/app/views/active_admin/_page_header.html.erb +2 -2
  20. data/app/views/active_admin/_site_footer.html.erb +1 -1
  21. data/app/views/active_admin/_site_header.html.erb +7 -7
  22. data/app/views/active_admin/devise/confirmations/new.html.erb +1 -1
  23. data/app/views/active_admin/devise/passwords/edit.html.erb +1 -1
  24. data/app/views/active_admin/devise/passwords/new.html.erb +1 -1
  25. data/app/views/active_admin/devise/registrations/new.html.erb +1 -1
  26. data/app/views/active_admin/devise/sessions/new.html.erb +1 -1
  27. data/app/views/active_admin/devise/unlocks/new.html.erb +1 -1
  28. data/app/views/active_admin/kaminari/_gap.html.erb +1 -1
  29. data/app/views/active_admin/kaminari/_next_page.html.erb +1 -1
  30. data/app/views/active_admin/kaminari/_prev_page.html.erb +1 -1
  31. data/app/views/active_admin/page/index.html.arb +1 -2
  32. data/app/views/active_admin/resource/_form.html.arb +0 -1
  33. data/app/views/active_admin/resource/_form_default.html.arb +0 -1
  34. data/app/views/active_admin/resource/_index_as_table_default.html.arb +0 -1
  35. data/app/views/active_admin/resource/_show_default.html.arb +0 -1
  36. data/app/views/active_admin/resource/edit.html.arb +0 -1
  37. data/app/views/active_admin/resource/index.html.arb +1 -2
  38. data/app/views/active_admin/resource/new.html.arb +0 -1
  39. data/app/views/active_admin/resource/show.html.arb +0 -1
  40. data/app/views/active_admin/shared/_resource_comments.html.erb +7 -7
  41. data/app/views/active_admin/shared/_sidebar_section.html.arb +0 -1
  42. data/app/views/layouts/active_admin.html.erb +1 -1
  43. data/config/importmap.rb +5 -0
  44. data/config/locales/ar.yml +136 -100
  45. data/config/locales/az.yml +103 -102
  46. data/config/locales/bg.yml +91 -90
  47. data/config/locales/bs.yml +95 -94
  48. data/config/locales/ca.yml +131 -77
  49. data/config/locales/cs.yml +82 -81
  50. data/config/locales/da.yml +102 -101
  51. data/config/locales/de.yml +130 -125
  52. data/config/locales/el.yml +94 -93
  53. data/config/locales/en-CA.yml +104 -103
  54. data/config/locales/en-GB.yml +104 -103
  55. data/config/locales/en.yml +134 -130
  56. data/config/locales/eo.yml +107 -106
  57. data/config/locales/es-MX.yml +70 -69
  58. data/config/locales/es.yml +129 -122
  59. data/config/locales/fa.yml +91 -90
  60. data/config/locales/fi.yml +84 -83
  61. data/config/locales/fr.yml +135 -126
  62. data/config/locales/he.yml +103 -102
  63. data/config/locales/hr.yml +95 -94
  64. data/config/locales/hu.yml +76 -75
  65. data/config/locales/id.yml +97 -96
  66. data/config/locales/it.yml +134 -124
  67. data/config/locales/ja.yml +109 -104
  68. data/config/locales/ko.yml +136 -92
  69. data/config/locales/lt.yml +106 -105
  70. data/config/locales/lv.yml +70 -69
  71. data/config/locales/mk.yml +100 -99
  72. data/config/locales/nb.yml +98 -97
  73. data/config/locales/nl.yml +113 -114
  74. data/config/locales/pl.yml +137 -130
  75. data/config/locales/pt-BR.yml +134 -105
  76. data/config/locales/pt-PT.yml +71 -70
  77. data/config/locales/ro.yml +74 -73
  78. data/config/locales/ru.yml +142 -106
  79. data/config/locales/sk.yml +131 -130
  80. data/config/locales/sv-SE.yml +126 -125
  81. data/config/locales/tr.yml +105 -104
  82. data/config/locales/uk.yml +140 -103
  83. data/config/locales/vi.yml +125 -124
  84. data/config/locales/zh-CN.yml +135 -125
  85. data/config/locales/zh-TW.yml +136 -100
  86. data/lib/active_admin/application.rb +5 -5
  87. data/lib/active_admin/application_settings.rb +1 -1
  88. data/lib/active_admin/async_count.rb +21 -0
  89. data/lib/active_admin/batch_actions/resource_extension.rb +2 -2
  90. data/lib/active_admin/batch_actions/views/batch_action_form.rb +1 -1
  91. data/lib/active_admin/batch_actions/views/selection_cells.rb +1 -1
  92. data/lib/active_admin/batch_actions.rb +4 -4
  93. data/lib/active_admin/collection_decorator.rb +1 -1
  94. data/lib/active_admin/csv_builder.rb +1 -1
  95. data/lib/active_admin/dependency.rb +1 -1
  96. data/lib/active_admin/dsl.rb +2 -2
  97. data/lib/active_admin/dynamic_settings_node.rb +2 -2
  98. data/lib/active_admin/engine.rb +5 -2
  99. data/lib/active_admin/filters/active.rb +2 -2
  100. data/lib/active_admin/filters/active_filter.rb +1 -7
  101. data/lib/active_admin/filters/forms.rb +0 -3
  102. data/lib/active_admin/filters/resource_extension.rb +2 -2
  103. data/lib/active_admin/filters.rb +5 -5
  104. data/lib/active_admin/form_builder.rb +4 -9
  105. data/lib/active_admin/helpers/optional_display.rb +1 -1
  106. data/lib/active_admin/inputs/filters/base/search_method_select.rb +2 -2
  107. data/lib/active_admin/inputs/filters/select_input.rb +1 -3
  108. data/lib/active_admin/localizers.rb +1 -1
  109. data/lib/active_admin/menu.rb +2 -2
  110. data/lib/active_admin/menu_item.rb +1 -1
  111. data/lib/active_admin/namespace.rb +1 -1
  112. data/lib/active_admin/namespace_settings.rb +1 -1
  113. data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +1 -1
  114. data/lib/active_admin/orm/active_record/comments/views.rb +2 -2
  115. data/lib/active_admin/orm/active_record/comments.rb +7 -7
  116. data/lib/active_admin/orm/active_record.rb +1 -1
  117. data/lib/active_admin/pundit_adapter.rb +4 -4
  118. data/lib/active_admin/resource/action_items.rb +3 -3
  119. data/lib/active_admin/resource/attributes.rb +8 -1
  120. data/lib/active_admin/resource/belongs_to.rb +0 -1
  121. data/lib/active_admin/resource/naming.rb +1 -1
  122. data/lib/active_admin/resource/page_presenters.rb +2 -2
  123. data/lib/active_admin/resource/sidebars.rb +1 -1
  124. data/lib/active_admin/resource.rb +21 -19
  125. data/lib/active_admin/resource_collection.rb +1 -1
  126. data/lib/active_admin/resource_dsl.rb +2 -2
  127. data/lib/active_admin/router.rb +5 -5
  128. data/lib/active_admin/scope.rb +10 -0
  129. data/lib/active_admin/version.rb +1 -1
  130. data/lib/active_admin/view_helpers/method_or_proc_helper.rb +1 -1
  131. data/lib/active_admin/views/components/active_admin_form.rb +2 -2
  132. data/lib/active_admin/views/components/attributes_table.rb +10 -4
  133. data/lib/active_admin/views/components/paginated_collection.rb +4 -1
  134. data/lib/active_admin/views/components/panel.rb +1 -1
  135. data/lib/active_admin/views/components/scopes.rb +26 -4
  136. data/lib/active_admin/views/components/table_for.rb +7 -2
  137. data/lib/active_admin/views/index_as_table.rb +22 -6
  138. data/lib/active_admin.rb +11 -6
  139. data/lib/activeadmin.rb +1 -1
  140. data/lib/generators/active_admin/assets/templates/active_admin.css +3 -3
  141. data/lib/generators/active_admin/assets/templates/tailwind.config.js +9 -5
  142. data/lib/generators/active_admin/devise/devise_generator.rb +2 -2
  143. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +1 -1
  144. data/lib/generators/active_admin/resource/resource_generator.rb +6 -2
  145. data/lib/generators/active_admin/resource/templates/resource.rb.erb +2 -2
  146. data/plugin.js +424 -0
  147. data/vendor/javascript/flowbite.js +1 -2
  148. data/vendor/javascript/rails_ujs_esm.js +1 -0
  149. metadata +35 -20
  150. data/config/locales/de-CH.yml +0 -84
  151. data/lib/active_admin/views/components/tabs.rb +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b52dc94714f4ab0451a27a11870164d4d9423326ef9c4b9eab899555c0cb2ece
4
- data.tar.gz: 5896f35ef16279d25de84bdd5ca94953c95119ea94eab47478cf966921f24c08
3
+ metadata.gz: '098aea41cb4fc6e731f7456f30043abe69d34fd641f007c1c377b874e9af4bb6'
4
+ data.tar.gz: 0bcd00148dd0e08f1c4b64aef23739cacc18e86961bc619a0e24a289db70a371
5
5
  SHA512:
6
- metadata.gz: cd49148d1d8cd9ea69574847938e2d5e4cc025c10b1585dde009388fb481cd4bd3528f425e035d920dac4f7c6e02beec28dc66eb64a515b8619e1b29b1242000
7
- data.tar.gz: 88e26278700d4f906f44bbb601e1048c6f85b4eed501507238cee43a4b51aadc4a83868782767c6f4269b2cf664e81db89059130fd748c478b1ecff25bf494e8
6
+ metadata.gz: d19914f5a74cf0132c526b7acd6f470f1f4638f6a36ce9cee2011fb5af4ce648113bd8fe7a4e7d74c26a7fcd78abf099347d11d8ad382cab3b7c614ccad7a911
7
+ data.tar.gz: 525b975b7ea335ccb076d51733d7021bbb85d0be4fd5ec206c76d5d67e619b6f09c45941a92777ccaf1d2142a91e28a73f88aa25d4a06670e77d5fb0a2d6a9f5
data/CHANGELOG.md CHANGED
@@ -1,6 +1,22 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ [Future changelogs have moved to GitHub Releases](https://github.com/activeadmin/activeadmin/releases)
4
+
5
+ ## 3.2.0 [☰](https://github.com/activeadmin/activeadmin/compare/v3.1.0..v3.2.0)
6
+
7
+ ### Security Fixes
8
+
9
+ * Backport protect against CSV Injection. [#8167] by [@mgrunberg]
10
+
11
+ ### Enhancements
12
+
13
+ * Backport support citext column type in string filter. [#8165] by [@mgrunberg]
14
+ * Backport provide detail in DB statement timeout error for filters. [#8163] by [@mgrunberg]
15
+
16
+ ### Bug Fixes
17
+
18
+ * Backport make sure menu creation does not modify menu options. [#8166] by [@mgrunberg]
19
+ * Backport ransack error with filters when ActiveStorage is used. [#8164] by [@mgrunberg]
4
20
 
5
21
  ## 3.1.0 [☰](https://github.com/activeadmin/activeadmin/compare/v3.0.0..v3.1.0)
6
22
 
@@ -435,7 +451,7 @@ _No changes_.
435
451
  * Fixed `if:` scope option when a lambda is passed. [#5501] by [@deivid-rodriguez]
436
452
  * Comment validation adding redundant errors when resource is missing. [#5517] by [@deivid-rodriguez]
437
453
  * Fixed resource filtering by association when the resource has custom primary key. [#5446] by [@wasifhossain]
438
- * Fixed "create anoter" checkbox styling. [#5324] by [@faucct]
454
+ * Fixed "create another" checkbox styling. [#5324] by [@faucct]
439
455
 
440
456
  ## 1.3.1 [☰](https://github.com/activeadmin/activeadmin/compare/v1.3.0..v1.3.1)
441
457
 
data/CONTRIBUTING.md CHANGED
@@ -27,8 +27,8 @@ Now install the development dependencies:
27
27
 
28
28
  ```sh
29
29
  gem install foreman
30
- bundle install
31
- bin/yarn install
30
+ bundle install --all
31
+ yarn install
32
32
  ```
33
33
 
34
34
  Now you should be able to run the entire suite using:
@@ -84,6 +84,10 @@ At this point, if your changes look good and tests are passing, you are ready to
84
84
  Github Actions will run our test suite against all supported Rails versions. It's possible that your changes pass tests in one Rails version but fail in another. In that case, you'll have to setup your development
85
85
  environment with the Gemfile for the problematic Rails version, and investigate what's going on.
86
86
 
87
+ ## Commit messages
88
+
89
+ Try your best to follow these [seven rules for a great commit message](https://cbea.ms/git-commit/#seven-rules).
90
+
87
91
  ## Merging a PR (maintainers only)
88
92
 
89
93
  A PR can only be merged into master by a maintainer if: CI is passing, approved by another maintainer and is up to date with the default branch. Any maintainer is allowed to merge a PR if all of these conditions ae met.
@@ -92,15 +96,11 @@ A PR can only be merged into master by a maintainer if: CI is passing, approved
92
96
 
93
97
  Maintainers need to do the following to push out a release:
94
98
 
95
- * Switch to the master branch and make sure it's up to date.
96
- * Make sure you have [chandler] properly configured. Chandler is used to
97
- automatically submit github release notes from the changelog right after
98
- pushing the gem to rubygems.
99
- * Update the version in the `lib/active_admin/version.rb` file.
100
- * Run `bin/bundle` to update all gemfiles.
101
- * Update the `package.json` version. [Prerelease format is 1.0.0-beta1](https://github.com/rails/rails/blob/0d0c30e534af7f80ec8b18eb946aaa613ca30444/tasks/release.rb#L26).
102
- * Review and merge the PR. The generated changelog in the PR should include all user visible changes you intend to ship.
103
- * Run `bin/rake release` from the target branch once the PR is merged.
104
-
105
- [chandler]: https://github.com/mattbrictson/chandler#2-configure-credentials
99
+ * Create a feature branch from master and make sure it's up to date.
100
+ * Run `bin/prep-release [version]` and commit the changes. Use Ruby version format. NPM is handled automatically.
101
+ * Optional: To confirm the release contents, run `gem build` (extract contents) and `npm publish --dry-run`.
102
+ * Review and merge the PR.
103
+ * Run `bin/rake release` from the default branch once the PR is merged.
104
+ * [Create a GitHub Release](https://github.com/activeadmin/activeadmin/releases/new) by selecting the tag and generating the release notes.
105
+
106
106
  [new issue]: https://github.com/activeadmin/activeadmin/issues/new
data/README.md CHANGED
@@ -55,7 +55,7 @@ We try not to reinvent the wheel, so Active Admin is built with other open sourc
55
55
  * [Inherited Resources]
56
56
  * [Kaminari]
57
57
  * [Ransack]
58
- * [TailwindCSS](https://tailwindcss.com)
58
+ * [Tailwind CSS](https://tailwindcss.com)
59
59
 
60
60
  ## Security contact information
61
61
 
@@ -75,8 +75,8 @@ Thanks to [Tidelift][tidelift] and all our Tidelift subscribers.
75
75
  Thanks to [Open Collective][opencollective contributors] and all our Open Collective contributors.
76
76
 
77
77
  [Arbre]: https://github.com/activeadmin/arbre
78
- [Devise]: https://github.com/plataformatec/devise
79
- [Formtastic]: https://github.com/justinfrench/formtastic
78
+ [Devise]: https://github.com/heartcombo/devise
79
+ [Formtastic]: https://github.com/formtastic/formtastic
80
80
  [Inherited Resources]: https://github.com/activeadmin/inherited_resources
81
81
  [Kaminari]: https://github.com/kaminari/kaminari
82
82
  [Ransack]: https://github.com/activerecord-hackery/ransack
@@ -92,7 +92,7 @@ Thanks to [Open Collective][opencollective contributors] and all our Open Collec
92
92
  [tidelift_enterprise]: https://tidelift.com/subscription/pkg/rubygems-activeadmin?utm_source=rubygems-activeadmin&utm_medium=referral&utm_campaign=enterprise
93
93
  [tidelift_support]: https://tidelift.com/subscription/pkg/rubygems-activeadmin?utm_source=rubygems-activeadmin&utm_medium=referral&utm_campaign=github&utm_content=support
94
94
 
95
- [docs]: https://activeadmin.info/0-installation.html
95
+ [docs]: https://activeadmin.info/
96
96
  [wiki]: https://github.com/activeadmin/activeadmin/wiki
97
97
  [stackoverflow]: https://stackoverflow.com/questions/tagged/activeadmin
98
98
  [contributing]: https://github.com/activeadmin/activeadmin/blob/master/CONTRIBUTING.md
data/UPGRADING.md ADDED
@@ -0,0 +1,274 @@
1
+ # Upgrading Guide
2
+
3
+ ## From v3 to v4 (beta)
4
+
5
+ ActiveAdmin v4 uses Tailwind CSS v4. It has **mobile web, dark mode and RTL support** with a default theme that can be customized through partials and CSS. This release assumes `cssbundling-rails` and `importmap-rails` is installed and configured in the host app. Partials can be modified to include a different asset library, e.g. shakapacker.
6
+ **IMPORTANT**: there is **no sortable functionality for has-many forms** in this release so if needed, **do not upgrade**. We are [open to community proposals](https://github.com/activeadmin/activeadmin/discussions/new?category=ideas). The add/remove functionality for has-many forms remains supported.
7
+
8
+ These instructions assume the `cssbundling-rails` and `importmap-rails` gems are already installed and you have run their install commands in your app. If you haven't done so, please do before continuing.
9
+
10
+ Update your `Gemfile` with `gem "activeadmin", "4.0.0.beta22"` and then run `gem install activeadmin --pre`.
11
+
12
+ Now, run `rails generate active_admin:assets` to replace the old assets with the new files.
13
+
14
+ Then add the npm package and update the `build:css` script.
15
+
16
+ ```
17
+ yarn add @activeadmin/activeadmin@4.0.0-beta22
18
+ npm pkg set scripts.build:css="npx @tailwindcss/cli -i ./app/assets/stylesheets/active_admin.css -o ./app/assets/builds/active_admin.css --minify"
19
+ ```
20
+
21
+ If you are already using Tailwind in your app, then update the `build:css` script to chain the above command to your existing one, e.g. `"npx @tailwindcss/cli ... && npx @tailwindcss/cli ..."`, so both stylesheets are generated.
22
+
23
+ Many configs have been removed (meta tags, asset registration, utility nav, etc.) that can now be modified more naturally through partials.
24
+
25
+ Open the `config/initializers/active_admin.rb` file and remove these deleted configs.
26
+
27
+ ```
28
+ site_title_link
29
+ site_title_image
30
+ logout_link_method
31
+ favicon
32
+ meta_tags
33
+ meta_tags_for_logged_out_pages
34
+ register_stylesheet
35
+ register_javascript
36
+ head
37
+ footer
38
+ use_webpacker
39
+ ```
40
+
41
+ Now, run `rails g active_admin:views` which will copy the partials to your app so you can customize if needed.
42
+
43
+ Note that the templates can and will change across releases. There are additional partials that can be copied but they are considered private so you do so at your own risk. You will have to keep those up to date per release.
44
+
45
+ **IMPORTANT**: if your project has copied any ActiveAdmin, Devise, or Kaminari templates from earlier releases, those templates must be updated from this release to avoid potential errors. Path helpers in Devise templates may require using the `main_app` proxy. The Kaminari templates have moved to `app/views/active_admin/kaminari`.
46
+
47
+ With the setup complete, please review the Breaking Changes section and resolve any that may or may not impact your integration.
48
+
49
+ ### Upgrading from an earlier 4.x beta release
50
+
51
+ When upgrading from any earlier 4.0.0 beta release, please apply the changes outlined below.
52
+
53
+ There were important template changes in 4.0.0.beta16. See [PR #8727](https://github.com/activeadmin/activeadmin/pull/8727) for details.
54
+ - The `_site_header.html.erb` partial has changed its main container class from `sticky` to `fixed`.
55
+ - The main layout for `active_admin.html.erb` now includes the `pt-16` utility class.
56
+
57
+ Starting with 4.0.0.beta19, we've migrated to Tailwind CSS v4 which requires several updates.
58
+
59
+ Update your `active_admin.css` file:
60
+
61
+ ```diff
62
+ -@tailwind base;
63
+ -@tailwind components;
64
+ -@tailwind utilities;
65
+ +@import "tailwindcss";
66
+ +
67
+ +@config "../../../tailwind-active_admin.config.js";
68
+ ```
69
+
70
+ Update the `build:css` script in your `package.json`:
71
+
72
+ ```diff
73
+ -"build:css": "tailwindcss -i ./app/assets/stylesheets/active_admin.css -o ./app/assets/builds/active_admin.css --minify -c tailwind-active_admin.config.js"
74
+ +"build:css": "npx @tailwindcss/cli -i ./app/assets/stylesheets/active_admin.css -o ./app/assets/builds/active_admin.css --minify"
75
+ ```
76
+
77
+ You may see the following warning when upgrading:
78
+
79
+ ```
80
+ [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of tailwind-active_admin.config.js is not specified and it doesn't parse as CommonJS.
81
+ Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
82
+ To eliminate this warning, add "type": "module" to ./package.json.
83
+ ```
84
+
85
+ The Tailwind config file now uses ES module syntax. To fix it, either:
86
+ - Rename `tailwind-active_admin.config.js` to `tailwind-active_admin.config.mjs`; or
87
+ - Add `"type": "module"` to your `package.json` (your application may already be compatible with ESM).
88
+
89
+ ### Breaking Changes
90
+ - jQuery and jQuery UI have been removed.
91
+ - The `columns` component has been removed. Use `div`'s with Tailwind classes for modern, responsive layout.
92
+
93
+ <details>
94
+ <summary>Columns Component Migration Alternative</summary>
95
+
96
+ If you did not specify any parameters for `column` and if all you need is equal width columns, then this single component will restore that functionality for any number of columns.
97
+
98
+ ```ruby
99
+ # app/admin/components/columns.rb
100
+ class Columns < ActiveAdmin::Component
101
+ builder_method :columns
102
+
103
+ def build(*args)
104
+ super
105
+ add_class "grid auto-cols-fr grid-flow-col gap-4 mb-4"
106
+ end
107
+
108
+ def column(*args, &block)
109
+ insert_tag Arbre::HTML::Div, *args, &block
110
+ end
111
+ end
112
+ ```
113
+
114
+ Using Tailwind modifiers you can further customize the number of columns for responsive/mobile support.
115
+ </details>
116
+
117
+ - The `tabs` component has been removed. Use a CSS based or third party alternative.
118
+ - Replace `default_main_content` with `render "show_default"`.
119
+
120
+ <details>
121
+ <summary>Show Default Alternative</summary>
122
+
123
+ If block form `default_main_content do ... end` was used or looking for a partial file
124
+ alternative, then replace with existing, public methods.
125
+
126
+ ```ruby
127
+ attributes_table_for(resource) do
128
+ rows *active_admin_config.resource_columns
129
+ row :a
130
+ row :b
131
+ # ...
132
+ end
133
+ active_admin_comments_for(resource) if active_admin_config.comments?
134
+ ```
135
+ </details>
136
+
137
+ - Replace `as: :datepicker` with Formtastic's `as: :date_picker` for native HTML date input.
138
+ - Replace `active_admin_comments` with `active_admin_comments_for(resource)`.
139
+ - In a sidebar section, replace `attributes_table` with `attributes_table_for(resource)`.
140
+ - The `IndexAsBlog`, `IndexAsBlock` and `IndexAsGrid` components have been removed. Please create your own custom index-as components which remain supported.
141
+ - Batch Actions Form DSL has been replaced with Rails partial support so you can supply your own custom form and modal.
142
+
143
+ <details>
144
+ <summary>Batch Action Partial Example</summary>
145
+
146
+ Assuming a Post resource (in the default namespace) with a `mark_published` batch action, we set the partial name and a set of HTML data attributes to trigger a modal using Flowbite which is included by default.
147
+
148
+ Note that you can use any modal JS library you want as long as it can be triggered to open using data attributes. Flowbite usage is not a requirement.
149
+
150
+ ```ruby
151
+ batch_action(
152
+ :mark_published,
153
+ partial: "mark_published_batch_action",
154
+ link_html_options: {
155
+ "data-modal-target": "mark-published-modal",
156
+ "data-modal-show": "mark-published-modal"
157
+ }
158
+ ) do |ids, inputs|
159
+ # ...
160
+ end
161
+ ```
162
+
163
+ In the `app/views/admin/posts` directory, create a `_mark_published_batch_action.html.erb` partial file which will be rendered and included automatically in the posts index admin page.
164
+
165
+ Now add the modal HTML where the `id` attribute must match the data attributes supplied in the `batch_action` example. The form must have an empty `data-batch-action-form` attribute.
166
+
167
+ ```
168
+ <div id="mark-published-modal" class="hidden fixed top-0 ..." aria-hidden="true" ...>
169
+ <!-- ... other modal content --->
170
+ <%= form_tag false, "data-batch-action-form": "" do %>
171
+ <!-- Declare your form inputs. You can use a different form builder too. -->
172
+ <% end %>
173
+ </div>
174
+ ```
175
+
176
+ The `data-batch-action-form` attribute is a hook for a delegated JS event so when you submit the form, it will post and run your batch action block with the supplied form data, functioning as it did before.
177
+ </details>
178
+
179
+ - Deeply nested submenus has been reverted. Only one level nested menu, e.g. `menu parent: "Administrative"`, is supported.
180
+ - Removed `Panel#header_action` method.
181
+ - Removed `index_column` method from index table.
182
+
183
+ <details>
184
+ <summary>Implementation Example</summary>
185
+
186
+ You can re-implement this column with the following:
187
+
188
+ ```ruby
189
+ column "Number", sortable: false do |item|
190
+ @collection.offset_value + @collection.index(item) + 1
191
+ end
192
+ ```
193
+ </details>
194
+ - Using `row 'name'` in an `attributes_table` block, now prints the header text as is. For a localized lookup of the header with titlized fallback, use `row :name` instead. This matches the `column 'name'` behavior of index tables (`TableFor`).
195
+
196
+ #### Resource named methods
197
+
198
+ With the extraction to partials, resource named methods, e.g. `post` or `posts`, used in blocks for `action_item` and `sidebar` will raise an error. You must use the `resource` or `collection` public helper method instead. For example:
199
+
200
+ ```ruby
201
+ action_item :view, if: ->{ post.published? } do link_to(resource) end
202
+ sidebar :author, if: ->{ post.published? }
203
+ # The above must now change to the following:
204
+ action_item :view, if: ->{ resource.published? } do link_to(resource) end
205
+ sidebar :author, if: ->{ resource.published? }
206
+ ```
207
+
208
+ Note that `@post` can also be used here but make sure to call `authorize!` on it if using the authorization feature. The `post` usage would continue to work for `sidebar :name do ... end` content blocks because they can include Arbre but we advise using `resource` or `collection` instead where possible. This may impact other DSL's.
209
+
210
+ ### Visual Related Changes
211
+ - The `sidebar do ... end` contents and the show resource `attributes_table`, are no longer wrapped in a panel so they can be customized.
212
+ - Links in custom `action_item`'s have no default styles. Apply your own or use the library's default `action-item-button` class.
213
+ - The index table `actions dropdown: true` option will be ignored, reverting to original output.
214
+ - An `Arbre::Component` will no longer add a CSS class using the component class name by default.
215
+ - Typographic elements (other than links in main content) [are not styled by default](https://tailwindcss.com/docs/preflight). Use the `@tailwindcss/typography` plugin or apply your own CSS alternative.
216
+
217
+ ### Enhancements
218
+ - Dark mode support.
219
+ - Mobile web support. For responsive `table_for`'s, wrap them in a div with overflow for horizontal scrolling.
220
+ - Customizable admin theme, including main menu and user menu, all through partials.
221
+ - RTL support improved. Now using CSS Logical Properties.
222
+ - Kaminari templates now consolidated into a single set you can customize.
223
+ - Datepicker's now use the native HTML date input. Apply a custom datepicker of your choosing.
224
+ - Batch Actions Form DSL has been replaced with partials and form builder for more customization. Please refer to earlier example.
225
+ - The `status_tag` component now uses unique labels for `false` and `nil` values.
226
+ - Several components: `table_for`, `status_tag`, etc. now use data attributes instead of classes for metadata: status, sort direction, column, etc.
227
+ - Arbre builder methods have been reduced to the minimum so you can use elements or DSLs without clashing e.g. `header`, `footer`, `columns`, etc.
228
+ - The [app-helpers-not-reloading bug has been fixed](https://github.com/activeadmin/activeadmin/pull/8180) and the engine namespace is now isolated.
229
+
230
+ ### Localization Updates
231
+
232
+ This release includes several locale changes. Please [review the en.yml locale](https://github.com/activeadmin/activeadmin/blob/master/config/locales/en.yml) for the latest translations.
233
+
234
+ - Removed keys: `dashboard_welcome`, `dropdown_actions`, `main_content` and `unsupported_browser`.
235
+ - New keys: `toggle_dark_mode`, `toggle_main_navigation_menu`, `toggle_section`, and `toggle_user_menu` have been added.
236
+ - The `active_admin.pagination` keys have been rewritten to be less verbose and include new entries: next and previous.
237
+
238
+ ```diff
239
+ - one: "Displaying <b>1</b> %{model}"
240
+ + one: "Showing <b>1</b> of <b>1</b>"
241
+ - one_page: "Displaying <b>all %{n}</b> %{model}"
242
+ + one_page: "Showing <b>all %{n}</b>"
243
+ - multiple: "Displaying %{model} <b>%{from}&nbsp;-&nbsp;%{to}</b> of <b>%{total}</b> in total"
244
+ + multiple: "Showing <b>%{from}-%{to}</b> of <b>%{total}</b>"
245
+ - multiple_without_total: "Displaying %{model} <b>%{from}&nbsp;-&nbsp;%{to}</b>"
246
+ + multiple_without_total: "Showing <b>%{from}-%{to}</b>"
247
+ - per_page: "Per page: "
248
+ + per_page: "Per page "
249
+ + previous: "Previous"
250
+ + next: "Next"
251
+ ```
252
+
253
+ - The `search_status` key contents has multiple, breaking changes:
254
+
255
+ ```diff
256
+ - headline: "Search status:"
257
+ - current_scope: "Scope:"
258
+ - current_filters: "Current filters:"
259
+ + title: "Active Search"
260
+ + title_with_scope: "Active Search for %{name}"
261
+ - no_current_filters: "None"
262
+ + no_current_filters: "No filters applied"
263
+ ```
264
+
265
+ - The value for the `status_tag.unset` key has changed from "No" to "Unknown".
266
+ - The `comments.title_content` text has been updated with an "All " prefix.
267
+ - The `comments.delete_confirmation` text has been fixed to use singular form.
268
+ - The `batch_actions.succesfully_destroyed` key has been renamed to fix a typo.
269
+
270
+ ```diff
271
+ - succesfully_destroyed:
272
+ + successfully_destroyed:
273
+ ```
274
+ - Inconsistent use of login/sign-in related terms so text now uses "Sign in", Sign out", and "Sign up" throughout.
@@ -40,7 +40,7 @@ module ActiveAdmin
40
40
  end
41
41
 
42
42
  # Authorize the action and subject. Available in the controller
43
- # as well as all the views. If the action is not allowd, it raises
43
+ # as well as all the views. If the action is not allowed, it raises
44
44
  # an ActiveAdmin::AccessDenied exception.
45
45
  #
46
46
  # @param [Symbol] action The action to check if the user has permission
@@ -17,8 +17,8 @@ module ActiveAdmin
17
17
  active_admin_config.navigation_menu
18
18
  end
19
19
 
20
- def current_menu_item?(item)
21
- item.current?(@current_menu_item)
20
+ def current_menu_item?(item, children: true)
21
+ item.current?(@current_menu_item, children: children)
22
22
  end
23
23
 
24
24
  def set_current_menu_item
@@ -168,11 +168,16 @@ module ActiveAdmin
168
168
  #
169
169
  # @return [void]
170
170
  def update_resource(object, attributes)
171
- object = assign_attributes(object, attributes)
171
+ status = nil
172
+ ActiveRecord::Base.transaction do
173
+ object = assign_attributes(object, attributes)
172
174
 
173
- run_update_callbacks object do
174
- save_resource(object)
175
+ run_update_callbacks object do
176
+ status = save_resource(object)
177
+ raise ActiveRecord::Rollback unless status
178
+ end
175
179
  end
180
+ status
176
181
  end
177
182
 
178
183
  # Destroys an object from the database and calls appropriate callbacks.
@@ -231,7 +236,7 @@ module ActiveAdmin
231
236
 
232
237
  def apply_includes(chain)
233
238
  if active_admin_config.includes.any?
234
- chain.includes *active_admin_config.includes
239
+ chain.includes(*active_admin_config.includes)
235
240
  else
236
241
  chain
237
242
  end
@@ -61,7 +61,7 @@ module ActiveAdmin
61
61
  def self.wrap!(parent, name)
62
62
  ::Class.new parent do
63
63
  delegate :reorder, :page, :current_page, :total_pages, :limit_value,
64
- :total_count, :total_pages, :offset, :to_key, :group_values,
64
+ :total_count, :offset, :to_key, :group_values,
65
65
  :except, :find_each, :ransack, to: :object
66
66
 
67
67
  define_singleton_method(:name) { name }
@@ -26,18 +26,18 @@ module ActiveAdmin
26
26
  if ActiveAdmin.application.disable_streaming_in.include? Rails.env
27
27
  self.response_body = block[String.new] # rubocop:disable Performance/UnfreezeString to preserve encoding
28
28
  else
29
- self.response_body = Enumerator.new &block
29
+ self.response_body = Enumerator.new(&block)
30
30
  end
31
31
  end
32
32
 
33
33
  def csv_filename
34
- "#{resource_collection_name.to_s.tr('_', '-')}-#{Time.zone.now.to_date.to_s}.csv"
34
+ "#{resource_collection_name.to_s.tr('_', '-')}-#{Time.zone.now.to_date}.csv"
35
35
  end
36
36
 
37
37
  def stream_csv
38
38
  headers["Content-Type"] = "text/csv; charset=utf-8" # In Rails 5 it's set to HTML??
39
39
  headers["Content-Disposition"] = %{attachment; filename="#{csv_filename}"}
40
- stream_resource &active_admin_config.csv_builder.method(:build).to_proc.curry[self]
40
+ stream_resource(&active_admin_config.csv_builder.method(:build).to_proc.curry[self])
41
41
  end
42
42
 
43
43
  end
@@ -40,7 +40,7 @@ module ActiveAdmin
40
40
  case params[:action].to_sym
41
41
  when :index
42
42
  active_admin_config.get_page_presenter(params[:action], params[:as])
43
- when :new, :edit
43
+ when :new, :edit, :create, :update
44
44
  active_admin_config.get_page_presenter(:form)
45
45
  end || super
46
46
  end
@@ -24,7 +24,7 @@ module ActiveAdmin
24
24
  def display_name(resource)
25
25
  unless resource.nil?
26
26
  result = render_in_context(resource, display_name_method_for(resource))
27
- if result.to_s&.strip&.present?
27
+ if result.to_s.strip.present?
28
28
  ERB::Util.html_escape(result)
29
29
  else
30
30
  ERB::Util.html_escape(render_in_context(resource, DISPLAY_NAME_FALLBACK))
@@ -108,8 +108,8 @@ module ActiveAdmin
108
108
  when TrueClass, FalseClass
109
109
  true
110
110
  else
111
- if resource.class.respond_to? :columns_hash
112
- column = resource.class.columns_hash[attr.to_s] and column.type == :boolean
111
+ if resource.class.respond_to? :attribute_types
112
+ resource.class.attribute_types[attr.to_s].is_a?(ActiveModel::Type::Boolean)
113
113
  end
114
114
  end
115
115
  end
@@ -29,7 +29,7 @@ module ActiveAdmin
29
29
  #
30
30
  def fields_for_params(params, options = {})
31
31
  namespace = options[:namespace]
32
- except = Array.wrap(options[:except]).map &:to_s
32
+ except = Array.wrap(options[:except]).map(&:to_s)
33
33
 
34
34
  params.flat_map do |k, v|
35
35
  next if namespace.nil? && RESERVED_PARAMS.include?(k.to_s)
@@ -22,7 +22,7 @@ module ActiveAdmin
22
22
 
23
23
  def action_items_for_action
24
24
  @action_items_for_action ||= begin
25
- if active_admin_config && active_admin_config.action_items?
25
+ if active_admin_config&.action_items?
26
26
  active_admin_config.action_items_for(params[:action], self)
27
27
  else
28
28
  []
@@ -32,7 +32,7 @@ module ActiveAdmin
32
32
 
33
33
  def sidebar_sections_for_action
34
34
  @sidebar_sections_for_action ||= begin
35
- if active_admin_config && active_admin_config.sidebar_sections?
35
+ if active_admin_config&.sidebar_sections?
36
36
  active_admin_config.sidebar_sections_for(params[:action], self)
37
37
  else
38
38
  []
@@ -1,11 +1,20 @@
1
1
  import Rails from '@rails/ujs';
2
2
 
3
+ const submitForm = function() {
4
+ let form = document.getElementById("collection_selection")
5
+ if (form) {
6
+ form.submit()
7
+ }
8
+ }
9
+
3
10
  const batchActionClick = function(event) {
4
11
  event.preventDefault()
5
12
  let batchAction = document.getElementById("batch_action")
6
13
  if (batchAction) {
7
14
  batchAction.value = this.dataset.action
8
15
  }
16
+
17
+ if (!event.target.dataset.confirm && !event.target.dataset.modalTarget) { submitForm() }
9
18
  }
10
19
 
11
20
  const batchActionConfirmComplete = function(event) {
@@ -15,10 +24,7 @@ const batchActionConfirmComplete = function(event) {
15
24
  if (batchAction) {
16
25
  batchAction.value = this.dataset.action
17
26
  }
18
- let form = document.getElementById("collection_selection")
19
- if (form) {
20
- form.submit()
21
- }
27
+ submitForm()
22
28
  }
23
29
  }
24
30
 
@@ -1,7 +1,8 @@
1
1
  import Rails from '@rails/ujs';
2
2
 
3
- const toggleMenu = function(event) {
4
- const parent = this.parentNode
3
+ const toggleMenu = function() {
4
+ const parent = this.closest([`[data-item-id="${this.dataset.parentId}"]`]) || this.parentNode
5
+
5
6
  if (!("open" in parent.dataset)) {
6
7
  parent.dataset.open = ""
7
8
  } else {
@@ -3,17 +3,17 @@
3
3
  <% flash_messages.each do |type, message| %>
4
4
  <% if type == "error" %>
5
5
  <div class="flex items-center gap-3 p-4 mb-2 rounded-lg bg-red-50 text-red-800 dark:bg-red-800 dark:text-red-300">
6
- <svg class="w-5 h-5 shrink-0" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"><path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM10 15a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm1-4a1 1 0 0 1-2 0V6a1 1 0 0 1 2 0v5Z"/></svg>
6
+ <svg class="w-5 h-5 shrink-0 text-red-400 dark:text-red-300" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"><path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM10 15a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm1-4a1 1 0 0 1-2 0V6a1 1 0 0 1 2 0v5Z"/></svg>
7
7
  <%= message %>
8
8
  </div>
9
9
  <% elsif type == "alert" %>
10
10
  <div class="flex items-center gap-3 p-4 mb-2 rounded-lg bg-yellow-50 text-yellow-800 dark:bg-yellow-800 dark:text-yellow-300">
11
- <svg class="w-5 h-5 shrink-0 rtl:-scale-x-100" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"><path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/></svg>
11
+ <svg class="w-5 h-5 shrink-0 rtl:-scale-x-100 text-yellow-400 dark:text-yellow-300" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"><path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/></svg>
12
12
  <%= message %>
13
13
  </div>
14
14
  <% elsif type == "notice" %>
15
- <div class="flex items-center gap-3 p-4 mb-2 rounded-lg bg-green-50 text-green-800 dark:bg-green-800 dark:text-green-400">
16
- <svg class="w-5 h-5 shrink-0 rtl:-scale-x-100" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"><path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/></svg>
15
+ <div class="flex items-center gap-3 p-4 mb-2 rounded-lg bg-green-50 text-green-800 dark:bg-green-800 dark:text-green-300">
16
+ <svg class="w-5 h-5 shrink-0 rtl:-scale-x-100 text-green-400 dark:text-green-300" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"><path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/></svg>
17
17
  <%= message %>
18
18
  </div>
19
19
  <% end %>