diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 69953566d3..cba1105238 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,10 @@ jobs: strategy: fail-fast: false matrix: - ruby: ["3.0", 3.1] + ruby: + - "3.0" + - "3.1" + - "3.2" gemfile: [gemfiles/rails_7.0.gemfile] orm: [active_record] adapter: [sqlite3] diff --git a/.rubocop.yml b/.rubocop.yml index 7d5d5b5f14..7e5adc8643 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -9,6 +9,7 @@ AllCops: - "node_modules/**/*" - "spec/dummy_app/bin/**/*" - "spec/dummy_app/db/schema.rb" + - "spec/dummy_app/node_modules/**/*" - "spec/dummy_app/tmp/**/*" - "vendor/bundle/**/*" NewCops: disable @@ -108,7 +109,7 @@ Metrics/BlockNesting: Metrics/ClassLength: CountComments: false - Max: 132 # TODO: Lower to 100 + Max: 200 # TODO: Lower to 100 Metrics/CyclomaticComplexity: Max: 15 # TODO: Lower to 6 @@ -162,9 +163,6 @@ Style/DoubleNegation: Style/EachWithObject: Enabled: false -Style/Encoding: - Enabled: false - Style/EndlessMethod: Enabled: true diff --git a/CHANGELOG.md b/CHANGELOG.md index e504b6c8e0..ce6fbed3bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,38 @@ ## [Unreleased](https://github.com/railsadminteam/rails_admin/tree/HEAD) -[Full Changelog](https://github.com/railsadminteam/rails_admin/compare/v3.1.0...HEAD) +[Full Changelog](https://github.com/railsadminteam/rails_admin/compare/v3.1.2...HEAD) + +## [3.1.2](https://github.com/railsadminteam/rails_admin/tree/v3.1.2) - 2023-03-23 + +[Full Changelog](https://github.com/railsadminteam/rails_admin/compare/v3.1.1...v3.1.2) + +### Fixed + +- Fix install failing with importmap setup ([aca22b6](https://github.com/railsadminteam/rails_admin/commit/aca22b6ba1eca1ac618525334cf14fc946e1c99e), [#3609](https://github.com/railsadminteam/rails_admin/issues/3609)) +- 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)) +- 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)) +- Restore caching in RailsAdmin::Config::Model#excluded? ([#3587](https://github.com/railsadminteam/rails_admin/pull/3587)) +- Optimize/simplify viable_models file path to class name logic ([#3589](https://github.com/railsadminteam/rails_admin/pull/3589)) + +## [3.1.1](https://github.com/railsadminteam/rails_admin/tree/v3.1.1) - 2022-12-18 + +[Full Changelog](https://github.com/railsadminteam/rails_admin/compare/v3.1.0...v3.1.1) + +### Changed + +- 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)) + +### Removed + +- Remove unused glphyicon assets ([#3578](https://github.com/railsadminteam/rails_admin/pull/3578)) + +### Fixed + +- Simplify uses of defined? ([#3561](https://github.com/railsadminteam/rails_admin/pull/3561)) +- Define jQuery object in separate file to support esbuild ([#3571](https://github.com/railsadminteam/rails_admin/pull/3571)) +- 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)) +- 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)) ## [3.1.0](https://github.com/railsadminteam/rails_admin/tree/v3.1.0) - 2022-11-06 @@ -142,7 +173,7 @@ ### Added - Support Mongoid's Storage Field Names ([cefa23c](https://github.com/railsadminteam/rails_admin/commit/cefa23c9d23d06dc1134228e142e6f0aa4655c54), [#1745](https://github.com/railsadminteam/rails_admin/issues/1745)) -- 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)) +- 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)) - 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)) - Add ability to hide the dashboard history section ([#3189](https://github.com/railsadminteam/rails_admin/pull/3189)) - 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)) diff --git a/README.md b/README.md index 3f7672264a..421a70bea7 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # RailsAdmin [![Gem Version](https://img.shields.io/gem/v/rails_admin.svg)][gem] -[![Build Status](https://img.shields.io/github/workflow/status/railsadminteam/rails_admin/Test)][ghactions] +[![Build Status](https://github.com/railsadminteam/rails_admin/actions/workflows/test.yml/badge.svg)][ghactions] [![Coverage Status](https://img.shields.io/coveralls/railsadminteam/rails_admin.svg)][coveralls] [![Code Climate](https://codeclimate.com/github/railsadminteam/rails_admin.svg)][codeclimate] [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=rails_admin&package-manager=bundler&version-scheme=semver)][semver] [gem]: https://rubygems.org/gems/rails_admin -[ghactions]: https://github.com/railsadminteam/rails_admin/actions +[ghactions]: https://github.com/railsadminteam/rails_admin/actions/workflows/test.yml [coveralls]: https://coveralls.io/r/railsadminteam/rails_admin [codeclimate]: https://codeclimate.com/github/railsadminteam/rails_admin [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 - Ruby 2.6 - Ruby 2.7 - Ruby 3.0 +- Ruby 3.1 +- Ruby 3.2 - [JRuby][] [jruby]: http://jruby.org/ diff --git a/app/controllers/rails_admin/main_controller.rb b/app/controllers/rails_admin/main_controller.rb index 5968bb7bec..af5a69aba3 100644 --- a/app/controllers/rails_admin/main_controller.rb +++ b/app/controllers/rails_admin/main_controller.rb @@ -56,7 +56,11 @@ def respond_to_missing?(sym, include_private) end def back_or_index - params[:return_to].presence && params[:return_to].include?(request.host) && (params[:return_to] != request.fullpath) ? params[:return_to] : index_path + allowed_return_to?(params[:return_to].to_s) ? params[:return_to] : index_path + end + + def allowed_return_to?(url) + url != request.fullpath && url.start_with?(request.base_url, '/') && !url.start_with?('//') end def get_sort_hash(model_config) diff --git a/app/helpers/rails_admin/application_helper.rb b/app/helpers/rails_admin/application_helper.rb index 9432effc7d..147fd7ca3f 100644 --- a/app/helpers/rails_admin/application_helper.rb +++ b/app/helpers/rails_admin/application_helper.rb @@ -122,7 +122,7 @@ def navigation(parent_groups, nodes, level = 0) nav_icon = node.navigation_icon ? %().html_safe : '' css_classes = ['nav-link'] css_classes.push("nav-level-#{level}") if level > 0 - css_classes.push('active') if defined?(@action) && current_action?(@action, model_param) + css_classes.push('active') if @action && current_action?(@action, model_param) li = content_tag :li, data: {model: model_param} do link_to nav_icon + " " + node.label_plural, url, class: css_classes.join(' ') end diff --git a/app/views/rails_admin/main/delete.html.erb b/app/views/rails_admin/main/delete.html.erb index 6b08bedce8..94cfcb6130 100644 --- a/app/views/rails_admin/main/delete.html.erb +++ b/app/views/rails_admin/main/delete.html.erb @@ -1,6 +1,6 @@

<%= t("admin.form.are_you_sure_you_want_to_delete_the_object", model_name: @abstract_model.pretty_name.downcase) %> - “<%= @model_config.with(object: @object).object_label %>” + <%= @model_config.with(object: @object).object_label %> <%= t("admin.form.all_of_the_following_related_items_will_be_deleted") %>