Skip to content

Commit d90183f

Browse files
authored
Merge branch 'railsadminteam:master' into order-csv-exports
2 parents d994430 + e158beb commit d90183f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+281
-67
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
ruby: ["3.0", 3.1]
11+
ruby:
12+
- "3.0"
13+
- "3.1"
14+
- "3.2"
1215
gemfile: [gemfiles/rails_7.0.gemfile]
1316
orm: [active_record]
1417
adapter: [sqlite3]

.rubocop.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ AllCops:
99
- "node_modules/**/*"
1010
- "spec/dummy_app/bin/**/*"
1111
- "spec/dummy_app/db/schema.rb"
12+
- "spec/dummy_app/node_modules/**/*"
1213
- "spec/dummy_app/tmp/**/*"
1314
- "vendor/bundle/**/*"
1415
NewCops: disable
@@ -108,7 +109,7 @@ Metrics/BlockNesting:
108109

109110
Metrics/ClassLength:
110111
CountComments: false
111-
Max: 132 # TODO: Lower to 100
112+
Max: 200 # TODO: Lower to 100
112113

113114
Metrics/CyclomaticComplexity:
114115
Max: 15 # TODO: Lower to 6
@@ -162,9 +163,6 @@ Style/DoubleNegation:
162163
Style/EachWithObject:
163164
Enabled: false
164165

165-
Style/Encoding:
166-
Enabled: false
167-
168166
Style/EndlessMethod:
169167
Enabled: true
170168

CHANGELOG.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,38 @@
22

33
## [Unreleased](https://github.com/railsadminteam/rails_admin/tree/HEAD)
44

5-
[Full Changelog](https://github.com/railsadminteam/rails_admin/compare/v3.1.0...HEAD)
5+
[Full Changelog](https://github.com/railsadminteam/rails_admin/compare/v3.1.2...HEAD)
6+
7+
## [3.1.2](https://github.com/railsadminteam/rails_admin/tree/v3.1.2) - 2023-03-23
8+
9+
[Full Changelog](https://github.com/railsadminteam/rails_admin/compare/v3.1.1...v3.1.2)
10+
11+
### Fixed
12+
13+
- Fix install failing with importmap setup ([aca22b6](https://github.com/railsadminteam/rails_admin/commit/aca22b6ba1eca1ac618525334cf14fc946e1c99e), [#3609](https://github.com/railsadminteam/rails_admin/issues/3609))
14+
- Fix to show non-eager-loaded models which are explicitly configured ([87c9d5b](https://github.com/railsadminteam/rails_admin/commit/87c9d5bc5b6ffb423e72054b3cfe8f949c12c178), [#3604](https://github.com/railsadminteam/rails_admin/issues/3604))
15+
- Fix `rails_admin.dom_ready` event not triggered with jQuery `on` ([2ee43de](https://github.com/railsadminteam/rails_admin/commit/2ee43deb1fa8d3a9e3ea0e589c1687d684e19ad6), [33773d7](https://github.com/railsadminteam/rails_admin/commit/33773d7f8dd43eeb0f6a7c125c4bee170132e5d2), [#3600](https://github.com/railsadminteam/rails_admin/discussions/3600))
16+
- Restore caching in RailsAdmin::Config::Model#excluded? ([#3587](https://github.com/railsadminteam/rails_admin/pull/3587))
17+
- Optimize/simplify viable_models file path to class name logic ([#3589](https://github.com/railsadminteam/rails_admin/pull/3589))
18+
19+
## [3.1.1](https://github.com/railsadminteam/rails_admin/tree/v3.1.1) - 2022-12-18
20+
21+
[Full Changelog](https://github.com/railsadminteam/rails_admin/compare/v3.1.0...v3.1.1)
22+
23+
### Changed
24+
25+
- Relax Font-Awesome dependency to allow Webpacker users to stay on 5.x ([3a7f348](https://github.com/railsadminteam/rails_admin/commit/3a7f34875248e446b48fd76870f0c337fee6dcf9), [#3565](https://github.com/railsadminteam/rails_admin/issues/3565))
26+
27+
### Removed
28+
29+
- Remove unused glphyicon assets ([#3578](https://github.com/railsadminteam/rails_admin/pull/3578))
30+
31+
### Fixed
32+
33+
- Simplify uses of defined? ([#3561](https://github.com/railsadminteam/rails_admin/pull/3561))
34+
- Define jQuery object in separate file to support esbuild ([#3571](https://github.com/railsadminteam/rails_admin/pull/3571))
35+
- Fix filter box being duplicated on browser back ([c6b1893](https://github.com/railsadminteam/rails_admin/commit/c6b18934cff3db0768836d799ee1bea54045709c), [#3570](https://github.com/railsadminteam/rails_admin/issues/3570))
36+
- Fix sidebar menu expanding horizontally, preventing vertical scroll ([9997c10](https://github.com/railsadminteam/rails_admin/commit/9997c1095066aaac39afb27bf8de705cf6ccb1ef), [#3564](https://github.com/railsadminteam/rails_admin/issues/3564))
637

738
## [3.1.0](https://github.com/railsadminteam/rails_admin/tree/v3.1.0) - 2022-11-06
839

@@ -142,7 +173,7 @@
142173
### Added
143174

144175
- Support Mongoid's Storage Field Names ([cefa23c](https://github.com/railsadminteam/rails_admin/commit/cefa23c9d23d06dc1134228e142e6f0aa4655c54), [#1745](https://github.com/railsadminteam/rails_admin/issues/1745))
145-
- Allow save/delete oprations to be disabled based on an object's `#read_only?` status ([9cd7541](https://github.com/railsadminteam/rails_admin/commit/9cd7541a2e6af4ae4941b200840a1474baeb2f06), [#1684](https://github.com/railsadminteam/rails_admin/issues/1684))
176+
- Allow save/delete operations to be disabled based on an object's `#read_only?` status ([9cd7541](https://github.com/railsadminteam/rails_admin/commit/9cd7541a2e6af4ae4941b200840a1474baeb2f06), [#1684](https://github.com/railsadminteam/rails_admin/issues/1684))
146177
- Allow customizing model's last created time ([d6d380a](https://github.com/railsadminteam/rails_admin/commit/d6d380a02e955c3b14ff7dc30f1809a2a6cd0f47), [#3010](https://github.com/railsadminteam/rails_admin/issues/3010))
147178
- Add ability to hide the dashboard history section ([#3189](https://github.com/railsadminteam/rails_admin/pull/3189))
148179
- Add model scope configuration option, which enables 'unscoped' mode ([8d905f9](https://github.com/railsadminteam/rails_admin/commit/8d905f9e2f1102e8addf324b496720e3fd47bf1d), [#1348](https://github.com/railsadminteam/rails_admin/issues/1348))

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# RailsAdmin
22

33
[![Gem Version](https://img.shields.io/gem/v/rails_admin.svg)][gem]
4-
[![Build Status](https://img.shields.io/github/workflow/status/railsadminteam/rails_admin/Test)][ghactions]
4+
[![Build Status](https://github.com/railsadminteam/rails_admin/actions/workflows/test.yml/badge.svg)][ghactions]
55
[![Coverage Status](https://img.shields.io/coveralls/railsadminteam/rails_admin.svg)][coveralls]
66
[![Code Climate](https://codeclimate.com/github/railsadminteam/rails_admin.svg)][codeclimate]
77
[![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=rails_admin&package-manager=bundler&version-scheme=semver)][semver]
88

99
[gem]: https://rubygems.org/gems/rails_admin
10-
[ghactions]: https://github.com/railsadminteam/rails_admin/actions
10+
[ghactions]: https://github.com/railsadminteam/rails_admin/actions/workflows/test.yml
1111
[coveralls]: https://coveralls.io/r/railsadminteam/rails_admin
1212
[codeclimate]: https://codeclimate.com/github/railsadminteam/rails_admin
1313
[semver]: https://dependabot.com/compatibility-score.html?dependency-name=rails_admin&package-manager=bundler&version-scheme=semver
@@ -98,6 +98,8 @@ This library aims to support and is [tested against][ghactions] the following Ru
9898
- Ruby 2.6
9999
- Ruby 2.7
100100
- Ruby 3.0
101+
- Ruby 3.1
102+
- Ruby 3.2
101103
- [JRuby][]
102104

103105
[jruby]: http://jruby.org/

app/controllers/rails_admin/main_controller.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ def respond_to_missing?(sym, include_private)
5656
end
5757

5858
def back_or_index
59-
params[:return_to].presence && params[:return_to].include?(request.host) && (params[:return_to] != request.fullpath) ? params[:return_to] : index_path
59+
allowed_return_to?(params[:return_to].to_s) ? params[:return_to] : index_path
60+
end
61+
62+
def allowed_return_to?(url)
63+
url != request.fullpath && url.start_with?(request.base_url, '/') && !url.start_with?('//')
6064
end
6165

6266
def get_sort_hash(model_config)

app/helpers/rails_admin/application_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def navigation(parent_groups, nodes, level = 0)
122122
nav_icon = node.navigation_icon ? %(<i class="#{node.navigation_icon}"></i>).html_safe : ''
123123
css_classes = ['nav-link']
124124
css_classes.push("nav-level-#{level}") if level > 0
125-
css_classes.push('active') if defined?(@action) && current_action?(@action, model_param)
125+
css_classes.push('active') if @action && current_action?(@action, model_param)
126126
li = content_tag :li, data: {model: model_param} do
127127
link_to nav_icon + " " + node.label_plural, url, class: css_classes.join(' ')
128128
end

app/views/rails_admin/main/delete.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<h4>
22
<%= t("admin.form.are_you_sure_you_want_to_delete_the_object", model_name: @abstract_model.pretty_name.downcase) %>
3-
&ldquo;<strong><%= @model_config.with(object: @object).object_label %></strong>&rdquo;
3+
<q><strong><%= @model_config.with(object: @object).object_label %></strong></q>
44
<%= t("admin.form.all_of_the_following_related_items_will_be_deleted") %>
55
</h4>
66
<ul>

lib/generators/rails_admin/importmap_formatter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def initialize(path = 'confing/importmap.rails_admin.rb')
1111
end
1212

1313
def format
14-
imports = packager.import("rails_admin@#{RailsAdmin::Version.js}")
14+
imports = packager.import("rails_admin@#{RailsAdmin::Version.js}", from: 'jspm.io')
1515

1616
# Use ESM compatible version to work around https://github.com/cljsjs/packages/issues/1579
1717
imports['@popperjs/core'].gsub!('lib/index.js', 'dist/esm/popper.js')

lib/generators/rails_admin/install_generator.rb

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def configure_for_webpacker5
6464
run "yarn add rails_admin@#{RailsAdmin::Version.js}"
6565
template 'rails_admin.webpacker.js', 'app/javascript/packs/rails_admin.js'
6666
template 'rails_admin.scss.erb', 'app/javascript/stylesheets/rails_admin.scss'
67+
# To work around https://github.com/railsadminteam/rails_admin/issues/3565
68+
add_package_json_field('resolutions', {'rails_admin/@fortawesome/fontawesome-free' => '^5.15.0'})
6769
end
6870

6971
def configure_for_webpack
@@ -99,28 +101,29 @@ def setup_css(additional_script_entries = {})
99101
else
100102
add_file 'config/initializers/assets.rb', asset_config
101103
end
102-
add_scripts(additional_script_entries.merge({'build:css' => 'sass ./app/assets/stylesheets/rails_admin.scss:./app/assets/builds/rails_admin.css --no-source-map --load-path=node_modules'}))
104+
add_package_json_field('scripts', additional_script_entries.merge({'build:css' => 'sass ./app/assets/stylesheets/rails_admin.scss:./app/assets/builds/rails_admin.css --no-source-map --load-path=node_modules'}), <<~INSTRUCTION)
105+
Taking 'build:css' as an example, if you're already have application.sass.css for the sass build, the resulting script would look like:
106+
sass ./app/assets/stylesheets/application.sass.scss:./app/assets/builds/application.css ./app/assets/stylesheets/rails_admin.scss:./app/assets/builds/rails_admin.css --no-source-map --load-path=node_modules
107+
INSTRUCTION
103108
end
104109

105-
def add_scripts(entries)
106-
display 'Add scripts to package.json'
110+
def add_package_json_field(name, entries, instruction = nil)
111+
display "Add #{name} to package.json"
107112
package = begin
108113
JSON.parse(File.read(File.join(destination_root, 'package.json')))
109114
rescue Errno::ENOENT, JSON::ParserError
110115
{}
111116
end
112-
if package['scripts'] && (package['scripts'].keys & entries.keys).any?
113-
say <<-MESSAGE.gsub(/^ {10}/, ''), :red
114-
You need to merge "scripts": #{JSON.pretty_generate(entries)} into the existing scripts in your package.json .
115-
Taking 'build:css' as an example, if you're already have application.sass.css for the sass build, the resulting script would look like:
116-
sass ./app/assets/stylesheets/application.sass.scss:./app/assets/builds/application.css ./app/assets/stylesheets/rails_admin.scss:./app/assets/builds/rails_admin.css --no-source-map --load-path=node_modules
117+
if package[name] && (package[name].keys & entries.keys).any?
118+
say <<~MESSAGE, :red
119+
You need to merge "#{name}": #{JSON.pretty_generate(entries)} into the existing #{name} in your package.json.#{instruction && "\n#{instruction}"}
117120
MESSAGE
118121
else
119-
package['scripts'] ||= {}
120-
entries.each do |entry, build_script|
121-
package['scripts'][entry] = build_script
122+
package[name] ||= {}
123+
entries.each do |entry, value|
124+
package[name][entry] = value
122125
end
123-
add_file 'package.json', JSON.pretty_generate(package)
126+
add_file 'package.json', "#{JSON.pretty_generate(package)}\n"
124127
end
125128
end
126129
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<%= instance_variable_defined?(:@fa_font_path) ? %{$fa-font-path: "#{@fa_font_path}";\n} : '' %>@import "rails_admin/src/rails_admin/styles/base";
1+
<%= @fa_font_path ? %{$fa-font-path: "#{@fa_font_path}";\n} : '' %>@import "rails_admin/src/rails_admin/styles/base";

0 commit comments

Comments
 (0)