From ee18c5f28406b833ba771cf96186874ee0e2fb27 Mon Sep 17 00:00:00 2001 From: Sue Zhou Date: Thu, 23 Jan 2025 20:27:05 +0000 Subject: [PATCH 1/8] update to cope with the bootstrap 5 upgrade --- app/helpers/ndr_error/application_helper.rb | 5 ----- app/helpers/ndr_error/errors_helper.rb | 18 +++++++++--------- app/views/layouts/ndr_error/ndr_error.html.erb | 13 ++++--------- app/views/ndr_error/errors/edit.html.erb | 2 +- app/views/ndr_error/errors/index.html.erb | 13 ++++++------- app/views/ndr_error/errors/show.html.erb | 10 +++++----- .../ndr_error/application_helper_test.rb | 6 ------ 7 files changed, 25 insertions(+), 42 deletions(-) diff --git a/app/helpers/ndr_error/application_helper.rb b/app/helpers/ndr_error/application_helper.rb index 546a728..92915ea 100644 --- a/app/helpers/ndr_error/application_helper.rb +++ b/app/helpers/ndr_error/application_helper.rb @@ -2,11 +2,6 @@ module NdrError # Application-wide helpers. # TODO: await ndr_ui gem! module ApplicationHelper - # Bootstrap icon tag. - def glyphicon_tag(type) - content_tag(:span, '', class: "glyphicon glyphicon-#{type}") - end - # Pagination helper for will_paginate: def pagination_summary_for(collection) page = collection.current_page diff --git a/app/helpers/ndr_error/errors_helper.rb b/app/helpers/ndr_error/errors_helper.rb index 4296571..f3faf52 100644 --- a/app/helpers/ndr_error/errors_helper.rb +++ b/app/helpers/ndr_error/errors_helper.rb @@ -57,8 +57,8 @@ def downstream_fingerprint_link(print) end def ticket_link_for(fingerprint, small = false) - text = glyphicon_tag('asterisk') + ' View ticket' - css = 'btn btn-default' + text = bootstrap_icon_tag('asterisk', :bi) + ' View ticket' + css = 'btn btn-outline-secondary' css << ' btn-xs' if small url = fingerprint.ticket_url @@ -66,15 +66,15 @@ def ticket_link_for(fingerprint, small = false) end def edit_button_for(fingerprint) - css = 'btn btn-default' - text = glyphicon_tag('pencil') + ' Edit Ticket' + css = 'btn btn-outline-secondary' + text = bootstrap_icon_tag('pencil', :bi) + ' Edit Ticket' link_to(text, edit_error_fingerprint_path(fingerprint), class: css) end def purge_button_for(fingerprint) css = 'btn btn-danger' - text = glyphicon_tag('trash icon-white') + ' Purge' + text = bootstrap_icon_tag('trash-fill', :bi) + ' Purge' options = { 'method' => :delete, @@ -86,18 +86,18 @@ def purge_button_for(fingerprint) end def previous_button_for(error) - css = 'btn btn-default' + css = 'btn btn-outline-secondary' css << ' disabled' if error.nil? - text = glyphicon_tag('chevron-left') + text = bootstrap_icon_tag('chevron-left', :bi) path = error.nil? ? '#' : error_fingerprint_path(error.error_fingerprint, log_id: error) link_to(text, path, class: css) end def next_button_for(error) - css = 'btn btn-default' + css = 'btn btn-outline-secondary' css << ' disabled' if error.nil? - text = glyphicon_tag('chevron-right') + text = bootstrap_icon_tag('chevron-right', :bi) path = error.nil? ? '#' : error_fingerprint_path(error.error_fingerprint, log_id: error) link_to(text, path, class: css) diff --git a/app/views/layouts/ndr_error/ndr_error.html.erb b/app/views/layouts/ndr_error/ndr_error.html.erb index ea98962..0e829f2 100644 --- a/app/views/layouts/ndr_error/ndr_error.html.erb +++ b/app/views/layouts/ndr_error/ndr_error.html.erb @@ -8,19 +8,14 @@ - <%= form.submit 'Update', class: 'btn btn-primary' %> - <%= link_to 'Cancel', error_fingerprint_path(@fingerprint), class: 'btn btn-default' %> + <%= link_to 'Cancel', error_fingerprint_path(@fingerprint), class: 'btn btn-outline-secondary' %> <% end %> diff --git a/app/views/ndr_error/errors/index.html.erb b/app/views/ndr_error/errors/index.html.erb index 1652f48..244b32b 100644 --- a/app/views/ndr_error/errors/index.html.erb +++ b/app/views/ndr_error/errors/index.html.erb @@ -5,16 +5,14 @@ %>
-
+
<%= form_tag(error_fingerprints_path, method: :get) do %>
<% if @keywords.any? %> - <%= link_to glyphicon_tag('list icon-white') + ' ' + glyphicon_tag('arrow-left icon-white'), error_fingerprints_path, class: 'btn btn-info input-group-addon' %> + <%= link_to bootstrap_icon_tag(:'list-task', :bi) + ' ' + bootstrap_icon_tag(:'arrow-left-circle-fill', :bi), error_fingerprints_path, class: 'btn btn-info' %> <% end %> <%= text_field_tag :q, @keywords.join(', '), class: 'form-control search-query' %> - - - +
<% end %>
@@ -45,7 +43,7 @@ <%= latest_user_for(fingerprint, @keywords) %> -
+
<%= ticket_link_for(fingerprint, true) if fingerprint.ticket_url.present? %>
@@ -57,7 +55,8 @@ - <%= pagination_summary_for(@fingerprints) %> + <%= pagination_summary_for(@fingerprints) %> + <%# TODO: use bootstrap_will_paginate %> <%= will_paginate(@fingerprints) %>
diff --git a/app/views/ndr_error/errors/show.html.erb b/app/views/ndr_error/errors/show.html.erb index 8ca669b..76fbf0b 100644 --- a/app/views/ndr_error/errors/show.html.erb +++ b/app/views/ndr_error/errors/show.html.erb @@ -7,7 +7,7 @@
-
+
<%= ticket_link_for(@fingerprint) if @fingerprint.ticket_url.present? %> <%= edit_button_for(@fingerprint) if user_can_edit_errors? %> @@ -22,7 +22,7 @@ <%= previous_button_for(@error.previous) %>
- + <%= pluralize(@error.similar_errors.length - 1, 'Similar Error') %> Stored @@ -39,13 +39,13 @@ <% if @fingerprint.causal_error_fingerprint %>
- <%= link_to bootstrap_icon_tag('arrow-up') + ' View Cause', error_fingerprint_path(@fingerprint.causal_error_fingerprint), class: 'btn btn-default' %> + <%= link_to bootstrap_icon_tag('arrow-up') + ' View Cause', error_fingerprint_path(@fingerprint.causal_error_fingerprint), class: 'btn btn-outline-secondary' %>
<% end %> <% if @fingerprint.caused_error_fingerprints.any? %>
- + <%= pluralize(@fingerprint.caused_error_fingerprints.length, 'Downstream Error') %> Stored @@ -117,7 +117,7 @@ <% end %>

- <%= check_box_tag :toggle_app_trace_only %> only app trace? + <%= check_box_tag :toggle_app_trace_only %> only app trace? Backtrace:

<% if (highlighted_trace = highlighted_trace_for(@error)).present? %> diff --git a/test/unit/helpers/ndr_error/application_helper_test.rb b/test/unit/helpers/ndr_error/application_helper_test.rb index ca621aa..a538f8d 100644 --- a/test/unit/helpers/ndr_error/application_helper_test.rb +++ b/test/unit/helpers/ndr_error/application_helper_test.rb @@ -3,12 +3,6 @@ module NdrError # Test application-wide helpers class ApplicationHelperTest < ActionView::TestCase - test 'glyphicon_tag' do - expected = '' - actual = glyphicon_tag(:padlock) - assert_equal expected, actual - end - test 'pagination_summary_for within range' do collection = (1..10).to_a.paginate(per_page: 3, page: 2) assert_equal 'Showing 4 - 6 of 10', pagination_summary_for(collection) From 1af677a9bfdae0c9225b024ac079668baff1f1f1 Mon Sep 17 00:00:00 2001 From: ollietulloch Date: Fri, 24 Jan 2025 09:06:58 +0000 Subject: [PATCH 2/8] Fix concurrent-ruby version to 1.3.4 --- ndr_error.gemspec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ndr_error.gemspec b/ndr_error.gemspec index 25a2b70..fb6129f 100644 --- a/ndr_error.gemspec +++ b/ndr_error.gemspec @@ -20,6 +20,8 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 3.0' s.add_dependency 'rails', '>= 6.1', '< 7.3' + # See https://github.com/rails/rails/issues/54260. + s.add_dependency 'concurrent-ruby', '1.3.4' # Support rails 6.1 with Ruby 3.1 s.add_dependency 'net-imap' From fba727ef95958789d4c2a4e33f06e4f6abc0566a Mon Sep 17 00:00:00 2001 From: Brian Shand Date: Fri, 24 Jan 2025 12:02:20 +0000 Subject: [PATCH 3/8] Require latest ndr_ui with bootstrap 5 support. Fix concurrent-ruby version to 1.3.4 for older Rails versions --- gemfiles/Gemfile.rails61 | 3 +++ gemfiles/Gemfile.rails70 | 3 +++ ndr_error.gemspec | 4 +--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gemfiles/Gemfile.rails61 b/gemfiles/Gemfile.rails61 index ff27abf..8fdb206 100644 --- a/gemfiles/Gemfile.rails61 +++ b/gemfiles/Gemfile.rails61 @@ -7,3 +7,6 @@ gem 'rails', '~> 6.1.0' # Rails 6.1 does not support sqlite3 2.x; it specifies gem "sqlite3", "~> 1.4" # in lib/active_record/connection_adapters/sqlite3_adapter.rb gem 'sqlite3', '~> 1.7' + +# Latest concurrent-ruby breaks Rails < 7.1. See https://github.com/rails/rails/issues/54260 +gem 'concurrent-ruby', '1.3.4' diff --git a/gemfiles/Gemfile.rails70 b/gemfiles/Gemfile.rails70 index 1792693..085807e 100644 --- a/gemfiles/Gemfile.rails70 +++ b/gemfiles/Gemfile.rails70 @@ -7,3 +7,6 @@ gem 'rails', '~> 7.0.0' # Rails 7.0 does not support sqlite3 2.x; it specifies gem "sqlite3", "~> 1.4" # in lib/active_record/connection_adapters/sqlite3_adapter.rb gem 'sqlite3', '~> 1.7' + +# Latest concurrent-ruby breaks Rails < 7.1. See https://github.com/rails/rails/issues/54260 +gem 'concurrent-ruby', '1.3.4' diff --git a/ndr_error.gemspec b/ndr_error.gemspec index fb6129f..5b91377 100644 --- a/ndr_error.gemspec +++ b/ndr_error.gemspec @@ -20,8 +20,6 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 3.0' s.add_dependency 'rails', '>= 6.1', '< 7.3' - # See https://github.com/rails/rails/issues/54260. - s.add_dependency 'concurrent-ruby', '1.3.4' # Support rails 6.1 with Ruby 3.1 s.add_dependency 'net-imap' @@ -30,7 +28,7 @@ Gem::Specification.new do |s| s.add_dependency 'will_paginate' - s.add_dependency 'ndr_ui' + s.add_dependency 'ndr_ui', '>= 5.0' s.add_development_dependency 'pry' s.add_development_dependency 'puma' From 285f4016e7a6403f457b15369f4361b4dc16542b Mon Sep 17 00:00:00 2001 From: Brian Shand Date: Fri, 24 Jan 2025 12:06:46 +0000 Subject: [PATCH 4/8] GitHub Actions gem installation fix: run tests with psych version 4 --- ndr_error.gemspec | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ndr_error.gemspec b/ndr_error.gemspec index 5b91377..80f3fff 100644 --- a/ndr_error.gemspec +++ b/ndr_error.gemspec @@ -38,6 +38,11 @@ Gem::Specification.new do |s| # cf. gemfiles/Gemfile.rails70 s.add_development_dependency 'sqlite3' + # Workaround build issue on GitHub Actions with ruby <= 3.1 when installing sass-embedded + # gem version 1.81.0: NoMethodError: undefined method `parse' for # + # https://bugs.ruby-lang.org/issues/19371 + spec.add_development_dependency 'psych', '< 5' + s.add_development_dependency 'mocha' s.add_development_dependency 'test-unit', '~> 3.0' From 69ab05ac34f8a47e1e5011ffe76385aa59b8e921 Mon Sep 17 00:00:00 2001 From: Brian Shand Date: Fri, 24 Jan 2025 12:08:52 +0000 Subject: [PATCH 5/8] fix typo --- ndr_error.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndr_error.gemspec b/ndr_error.gemspec index 80f3fff..7cb405a 100644 --- a/ndr_error.gemspec +++ b/ndr_error.gemspec @@ -41,7 +41,7 @@ Gem::Specification.new do |s| # Workaround build issue on GitHub Actions with ruby <= 3.1 when installing sass-embedded # gem version 1.81.0: NoMethodError: undefined method `parse' for # # https://bugs.ruby-lang.org/issues/19371 - spec.add_development_dependency 'psych', '< 5' + s.add_development_dependency 'psych', '< 5' s.add_development_dependency 'mocha' s.add_development_dependency 'test-unit', '~> 3.0' From 3274d99252f3d1c5f917dcc7ca0d8bd11550a4d2 Mon Sep 17 00:00:00 2001 From: Brian Shand Date: Fri, 24 Jan 2025 13:50:15 +0000 Subject: [PATCH 6/8] GitHub Actions: precompile assets before running tests --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fa9eaa3..d529fce 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,6 +45,8 @@ jobs: run: bundle install - name: Prepare SQLite run: RAILS_ENV=test bundle exec rake db:migrate --trace + - name: Precompile assets + run: RAILS_ENV=test bundle exec rails app:assets:clobber app:assets:precompile - name: Run tests run: bundle exec rails test From 79a8b2b9399998e65711e17b93b16112fb936c36 Mon Sep 17 00:00:00 2001 From: Brian Shand Date: Fri, 31 Jan 2025 11:49:15 +0000 Subject: [PATCH 7/8] Rubocop tweaks --- app/helpers/ndr_error/errors_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/ndr_error/errors_helper.rb b/app/helpers/ndr_error/errors_helper.rb index f3faf52..9b28641 100644 --- a/app/helpers/ndr_error/errors_helper.rb +++ b/app/helpers/ndr_error/errors_helper.rb @@ -56,8 +56,8 @@ def downstream_fingerprint_link(print) bootstrap_list_link_to hash + ' - ' + text, error_fingerprint_path(print) end - def ticket_link_for(fingerprint, small = false) - text = bootstrap_icon_tag('asterisk', :bi) + ' View ticket' + def ticket_link_for(fingerprint, small = false) # rubocop:disable Style/OptionalBooleanParameter + text = "#{bootstrap_icon_tag('asterisk', :bi)} View ticket" css = 'btn btn-outline-secondary' css << ' btn-xs' if small @@ -67,14 +67,14 @@ def ticket_link_for(fingerprint, small = false) def edit_button_for(fingerprint) css = 'btn btn-outline-secondary' - text = bootstrap_icon_tag('pencil', :bi) + ' Edit Ticket' + text = "#{bootstrap_icon_tag('pencil', :bi)} Edit Ticket" link_to(text, edit_error_fingerprint_path(fingerprint), class: css) end def purge_button_for(fingerprint) css = 'btn btn-danger' - text = bootstrap_icon_tag('trash-fill', :bi) + ' Purge' + text = "#{bootstrap_icon_tag('trash-fill', :bi)} Purge" options = { 'method' => :delete, From 4dfb77b750b000174878b28a7a027edc0a79b128 Mon Sep 17 00:00:00 2001 From: Brian Shand Date: Fri, 31 Jan 2025 11:56:24 +0000 Subject: [PATCH 8/8] Add changelog entry for update to cope with the bootstrap 5 upgrade --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6943646..cb19bc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## [Unreleased] -* no unreleased changes +### Changed +* new views with bootstrap 5 styles +* switch to bootstrap-icons as glyphicon no longer available in bootstrap 5 ## 2.3.2 / 2024-11-21 ### Fixed