rails_admin 3.0.0.rc3 → 3.0.0.rc4

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

Potentially problematic release.


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

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ed0d71c0798b98c4a0afdff5fa2ed48ffd05d1e0124d52ccdb371012d117479
4
- data.tar.gz: ed51dc928885ae4c57e9f02a9e40cf7689731570a78efc7d1bdfbe3afbd7e298
3
+ metadata.gz: e9316454f8142d78f5723f035c4dae4d4c1e43b1a4f67b9fe3382a46fac7a3a7
4
+ data.tar.gz: 42019837af600e34a153786615addcc21c1709bdffb78f96dddfd322ad54d5d6
5
5
  SHA512:
6
- metadata.gz: ff6f4ff15d8722cb44f4bbfeb8375c6c68c24be7cfadaa1e0b2dcf323f43321bc40296c60cdbcd2a9ecc28685261ca5ef00b046481394044d3f6f3970e6ddf86
7
- data.tar.gz: a23d415f1987f61dd8d5bf7dcac7d2d7307e602a0afe3d16c94d8a639ad952135154cc31728bd1f41e181e0f1a829d39afb8898c6fc1a301a75fa64649b117d7
6
+ metadata.gz: 57095a84c563d2b37d54a03ec88a412b32438c7ff0653075380fe86669c9d19206219b896d3827f931f1a1f98434e98b9209ec2fb2a5735f98410fff758cf6a8
7
+ data.tar.gz: 2d3f9afaaef4ebe8a69793ba8e4da469ee5ea91e1821aa2d82f91884165354a79d0b8b5b08d0988f04584eef4f0aebff985006043ace64e8814c434789f65ffb
data/README.md CHANGED
@@ -45,7 +45,7 @@ RailsAdmin is a Rails engine that provides an easy-to-use interface for managing
45
45
 
46
46
  ## Installation
47
47
 
48
- 1. On your gemfile: `gem 'rails_admin', ['>= 3.0.0.rc3', '< 4']`
48
+ 1. On your gemfile: `gem 'rails_admin', ['>= 3.0.0.rc4', '< 4']`
49
49
  2. Run `bundle install`
50
50
  3. Run `rails g rails_admin:install`
51
51
  4. Provide a namespace for the routes when asked
@@ -169,7 +169,7 @@ module RailsAdmin
169
169
  else
170
170
  'javascript:void(0)'
171
171
  end
172
- content_tag(:a, label, {href: href, target: action.link_target, class: ['nav-link', current_action?(action) && 'active', !action.enabled? && 'disabled'].compact})
172
+ content_tag(:a, label, {href: href, target: action.link_target, class: ['nav-link', current_action?(action) && 'active', !action.enabled? && 'disabled'].compact}.merge(action.turbo? ? {} : {data: {turbo: 'false'}}))
173
173
  else
174
174
  content_tag(:span, label)
175
175
  end
@@ -5,13 +5,16 @@
5
5
  <%= csrf_meta_tag %>
6
6
  <% case RailsAdmin::config.asset_source
7
7
  when :webpacker %>
8
- <%= stylesheet_pack_tag "rails_admin" %>
9
- <%= javascript_pack_tag "rails_admin", async: true %>
10
- <% when :webpack, :sprockets %>
8
+ <%= stylesheet_pack_tag "rails_admin", data: {'turbo-track': 'reload'} %>
9
+ <%= javascript_pack_tag "rails_admin", async: true, data: {'turbo-track': 'reload'} %>
10
+ <% when :sprockets %>
11
11
  <% handle_asset_dependency_error do %>
12
- <%= stylesheet_link_tag "rails_admin/application.css", media: :all %>
13
- <%= javascript_include_tag "rails_admin/application.js", async: true %>
12
+ <%= stylesheet_link_tag "rails_admin/application.css", media: :all, data: {'turbo-track': 'reload'} %>
13
+ <%= javascript_include_tag "rails_admin/application.js", async: true, data: {'turbo-track': 'reload'} %>
14
14
  <% end %>
15
+ <% when :webpack %>
16
+ <%= stylesheet_link_tag "rails_admin.css", media: :all, data: {'turbo-track': 'reload'} %>
17
+ <%= javascript_include_tag "rails_admin.js", async: true, data: {'turbo-track': 'reload'} %>
15
18
  <% else
16
19
  raise "Unknown asset_source: #{RailsAdmin::config.asset_source}"
17
20
  end %>
@@ -1,7 +1,7 @@
1
1
  <ul class="navbar-nav ms-auto root_links">
2
2
  <% actions(:root).select(&:show_in_navigation).each do |action| %>
3
3
  <li class="nav-item <%= action.action_name %>_root_link">
4
- <%= link_to wording_for(:menu, action), { action: action.action_name, controller: 'rails_admin/main' }, class: ['nav-link'] %>
4
+ <%= link_to wording_for(:menu, action), { action: action.action_name, controller: 'rails_admin/main' }, {class: ['nav-link']}.merge(action.turbo? ? {} : {data: {turbo: 'false'}}) %>
5
5
  </li>
6
6
  <% end %>
7
7
  <% if main_app_root_path = (main_app.root_path rescue false) %>
@@ -17,7 +17,7 @@
17
17
  <% end %>
18
18
  <% if logout_path.present? %>
19
19
  <li class="nav-item">
20
- <%= link_to t('admin.misc.log_out'), logout_path, method: logout_method, class: 'nav-link label label-danger' %>
20
+ <%= link_to t('admin.misc.log_out'), logout_path, method: logout_method, class: 'nav-link label label-danger', data: {turbo: 'false'} %>
21
21
  </li>
22
22
  <% end %>
23
23
  <% end %>
@@ -14,7 +14,7 @@
14
14
  <%= render "layouts/rails_admin/sidebar_navigation" %>
15
15
  </div>
16
16
  <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2">
17
- <div class="container">
17
+ <div class="container-fluid">
18
18
  <%= render template: 'layouts/rails_admin/content' %>
19
19
  </div>
20
20
  </div>
@@ -10,16 +10,18 @@
10
10
  <%= fieldset.help %>
11
11
  </p>
12
12
  <% end %>
13
- <dl>
13
+ <div class="list-group">
14
14
  <% fields.each_with_index do |field, index| %>
15
- <dt>
16
- <span class="<%= field.type_css_class %> <%= field.css_class %> label label-info">
17
- <%= field.label %>
18
- </span>
19
- </dt>
20
- <dd class="well">
21
- <%= field.pretty_value %>
22
- </dd>
15
+ <div class="list-group-item border-0 <%= field.type_css_class %> <%= field.css_class %>">
16
+ <div class="card">
17
+ <h5 class="card-header bg-light">
18
+ <%= field.label %>
19
+ </h5>
20
+ <div class="card-body">
21
+ <%= field.pretty_value %>
22
+ </div>
23
+ </div>
24
+ </div>
23
25
  <% end %>
24
26
  </dl>
25
27
  </div>
@@ -78,6 +78,11 @@ module RailsAdmin
78
78
  nil
79
79
  end
80
80
 
81
+ # Determines whether to navigate via Turbo Drive or not
82
+ register_instance_option :turbo? do
83
+ true
84
+ end
85
+
81
86
  # This block is evaluated in the context of the controller when action is called
82
87
  # You can access:
83
88
  # - @objects if you're on a model scope
@@ -25,6 +25,10 @@ module RailsAdmin
25
25
  register_instance_option :link_icon do
26
26
  'fas fa-eye'
27
27
  end
28
+
29
+ register_instance_option :turbo? do
30
+ false
31
+ end
28
32
  end
29
33
  end
30
34
  end
@@ -2,6 +2,7 @@ require 'kaminari'
2
2
  require 'nested_form'
3
3
  require 'rails'
4
4
  require 'rails_admin'
5
+ require 'rails_admin/version'
5
6
  require 'turbo-rails'
6
7
 
7
8
  module RailsAdmin
@@ -11,7 +12,7 @@ module RailsAdmin
11
12
  config.action_dispatch.rescue_responses['RailsAdmin::ActionNotAllowed'] = :forbidden
12
13
 
13
14
  initializer 'RailsAdmin precompile hook', group: :all do |app|
14
- if app.config.respond_to?(:assets)
15
+ if defined?(Sprockets)
15
16
  app.config.assets.precompile += %w[
16
17
  rails_admin/application.js
17
18
  rails_admin/application.css
@@ -69,6 +70,8 @@ module RailsAdmin
69
70
 
70
71
  # Force route reload, since it doesn't reflect RailsAdmin action configuration yet
71
72
  app.reload_routes!
73
+
74
+ RailsAdmin::Version.warn_with_js_version
72
75
  end
73
76
  end
74
77
  end
@@ -7,7 +7,7 @@ module RailsAdmin
7
7
  class AuthorizationAdapter
8
8
  # This method is called first time only and used for setup
9
9
  def self.setup
10
- RailsAdmin::Extensions::ControllerExtension.include ::Pundit
10
+ RailsAdmin::Extensions::ControllerExtension.include defined?(::Pundit::Authorization) ? ::Pundit::Authorization : ::Pundit
11
11
  end
12
12
 
13
13
  # See the +authorize_with+ config method for where the initialization happens.
@@ -3,7 +3,7 @@ module RailsAdmin
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
5
  PATCH = 0
6
- PRE = 'rc3'.freeze
6
+ PRE = 'rc4'.freeze
7
7
 
8
8
  class << self
9
9
  # @return [String]
@@ -14,6 +14,39 @@ module RailsAdmin
14
14
  def js
15
15
  JSON.parse(File.read("#{__dir__}/../../package.json"))['version']
16
16
  end
17
+
18
+ def actual_js_version
19
+ case RailsAdmin.config.asset_source
20
+ when :webpacker, :webpack
21
+ js_version_from_node_modules
22
+ else
23
+ js
24
+ end
25
+ end
26
+
27
+ def warn_with_js_version
28
+ return unless Rails.env.development? || Rails.env.test?
29
+
30
+ case actual_js_version
31
+ when js
32
+ # Good
33
+ when nil
34
+ warn "[Warning] Failed to detect RailsAdmin npm package, did you run 'yarn install'?"
35
+ else
36
+ warn <<~MSG
37
+ [Warning] RailsAdmin npm package version inconsistency detected, expected #{js} but actually used is #{actual_js_version}.
38
+ This may cause partial or total malfunction of RailsAdmin frontend features.
39
+ MSG
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def js_version_from_node_modules
46
+ JSON.parse(File.read(Rails.root.join('node_modules/rails_admin/package.json')))['version']
47
+ rescue StandardError
48
+ nil
49
+ end
17
50
  end
18
51
  end
19
52
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rails_admin",
3
- "version": "3.0.0-rc3",
3
+ "version": "3.0.0-rc4",
4
4
  "description": "RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data.",
5
5
  "homepage": "https://github.com/railsadminteam/rails_admin",
6
6
  "license": "MIT",
@@ -98,6 +98,10 @@ import I18n from "./i18n";
98
98
  $.each($("#filters_box").data("options"), function () {
99
99
  $.filters.append(this);
100
100
  });
101
+ // Workaround for https://github.com/heartcombo/devise/issues/5458
102
+ $("a[data-method]").on("click", function (event) {
103
+ window.Turbo.session.drive = false;
104
+ });
101
105
  });
102
106
 
103
107
  $(document).on("click", ".bulk-link", function (event) {