Skip to content

Commit 87f1826

Browse files
authored
Merge pull request #81 from yuki24/add-config-for-registering-assets
Add a config to opt out of registering assets
2 parents 2e0571f + c7f1387 commit 87f1826

File tree

5 files changed

+28
-2
lines changed

5 files changed

+28
-2
lines changed

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,23 @@ or later.
198198
gem 'activeadmin', github: 'activeadmin', ref: 'b3a9f4b'
199199
```
200200

201+
### Suppressing warnings from Active Admin
202+
203+
As of Active Admin 1.1.0, `config.register_stylesheet` and `config.register_javascript` have been deprecated. `ActiveAdmin::SortableTree` uses these interfaces to register required assets automatically. Because of this, you may see a deprecation warning:
204+
205+
```
206+
DEPRECATION WARNING: Active Admin: The `register_javascript` config is deprecated and will be removed
207+
in v2. Import your "active_admin/sortable.js" javascript in the active_admin.js.
208+
(called from <main> at config/environment.rb:5)
209+
```
210+
211+
You could opt out of it by setting `config.aa_sortable_tree.register_assets` to `false`:
212+
213+
```ruby
214+
# config/application.rb
215+
config.aa_sortable_tree.register_assets = false
216+
```
217+
201218
## Semantic Versioning
202219

203220
ActiveAdmin::SortableTree follows [semantic versioning](http://semver.org).

lib/active_admin/sortable_tree/engine.rb

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ module SortableTree
55
class Engine < ::Rails::Engine
66
engine_name "active_admin-sortable_tree"
77

8+
config.aa_sortable_tree = ActiveSupport::OrderedOptions.new
9+
config.aa_sortable_tree.register_assets = true
10+
811
initializer "active_admin-sortable_tree.precompile", group: :all do |app|
912
app.config.assets.precompile += [
1013
"active_admin/sortable.css",
@@ -13,8 +16,10 @@ class Engine < ::Rails::Engine
1316
end
1417

1518
initializer "active_admin-sortable_tree.register_assets" do
16-
ActiveAdmin.application.register_stylesheet "active_admin/sortable.css"
17-
ActiveAdmin.application.register_javascript "active_admin/sortable.js"
19+
if config.aa_sortable_tree.register_assets
20+
ActiveAdmin.application.register_stylesheet "active_admin/sortable.css"
21+
ActiveAdmin.application.register_javascript "active_admin/sortable.js"
22+
end
1823
end
1924
end
2025
end
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
//= require active_admin/base
2+
//= require active_admin/sortable
23
//= require jquery.simulate

spec/dummy/app/assets/stylesheets/active_admin.css.scss

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// Active Admin's got SASS!
1111
@import "active_admin/mixins";
1212
@import "active_admin/base";
13+
@import "active_admin/sortable";
1314

1415
// Overriding any non-variable SASS must be done after the fact.
1516
// For example, to change the default status-tag color:

spec/dummy/config/application.rb

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class Application < Rails::Application
5050

5151
# Version of your assets, change this if you want to expire all your assets
5252
config.assets.version = '1.0'
53+
54+
config.aa_sortable_tree.register_assets = false
5355
end
5456
end
5557

0 commit comments

Comments
 (0)