From 4263010be6aed1f52ab09b48a38f39acf43f71fd Mon Sep 17 00:00:00 2001 From: David Roetzel Date: Tue, 7 Nov 2023 14:35:36 +0100 Subject: [PATCH] Migration to Bootstrap 5. Since Bs5 no longer depends on jQuery, and we do not use it anywhere else, this also removes that dependency. Some visual changes were unavoidable, but overall I took care not to change too much at once and existing users should feel right at home. --- Gemfile | 4 +- Gemfile.lock | 43 ++++++------ app/assets/config/manifest.js | 1 - app/assets/stylesheets/application.scss | 8 +++ app/helpers/application_helper.rb | 12 ++-- app/javascript/application.js | 8 +-- app/views/files/index.html.erb | 60 +++++++++-------- app/views/group_memberships/edit.html.erb | 2 +- app/views/groups/_form.html.erb | 6 +- app/views/groups/show.html.erb | 6 +- app/views/keys/_form.html.erb | 10 +-- app/views/keys/_key_list.html.erb | 8 +-- app/views/keys/_value.html.erb | 4 +- app/views/keys/show.html.erb | 82 +++++++++++------------ app/views/layouts/application.html.erb | 5 +- app/views/ldap_sessions/new.html.erb | 4 +- app/views/nodes/_select_node.html.erb | 6 +- app/views/sessions/new.html.erb | 6 +- app/views/shared/_top_navigation.html.erb | 10 +-- app/views/users/_form.html.erb | 10 +-- app/views/users/show.html.erb | 8 +-- config/importmap.rb | 2 +- config/initializers/assets.rb | 2 +- 23 files changed, 151 insertions(+), 156 deletions(-) diff --git a/Gemfile b/Gemfile index 5561eb05..470bc865 100644 --- a/Gemfile +++ b/Gemfile @@ -14,11 +14,11 @@ gem 'puma', '~> 6.4' gem 'sprockets-rails' gem 'importmap-rails' gem 'dartsass-rails' +gem 'dartsass-sprockets' gem 'turbo-rails' gem 'stimulus-rails' -gem 'bootstrap', '~> 4.6.0' +gem 'bootstrap', '~> 5.3.0' gem 'bootstrap-icons-helper' -gem 'jquery-rails' # Use Redis adapter to run Action Cable in production gem 'redis', '~> 5.0' diff --git a/Gemfile.lock b/Gemfile.lock index ade4d3be..2a1c964b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -104,10 +104,9 @@ GEM bcrypt (3.1.19) bigdecimal (3.1.4) bindex (0.8.1) - bootstrap (4.6.2) + bootstrap (5.3.2) autoprefixer-rails (>= 9.1.0) - popper_js (>= 1.16.1, < 2) - sassc-rails (>= 2.0.0) + popper_js (>= 2.11.8, < 3) bootstrap-icons (1.0.13) nokogiri (~> 1) bootstrap-icons-helper (2.0.1) @@ -136,6 +135,14 @@ GEM dartsass-rails (0.5.0) railties (>= 6.0.0) sass-embedded (~> 1.63) + dartsass-ruby (3.0.2) + sass-embedded (~> 1.54, < 1.67) + dartsass-sprockets (3.0.0) + dartsass-ruby (~> 3.0) + railties (>= 4.0.0) + sprockets (> 3.0) + sprockets-rails + tilt date (3.3.3) deep_merge (1.2.2) diffy (3.4.2) @@ -208,10 +215,6 @@ GEM irb (1.8.3) rdoc reline (>= 0.3.8) - jquery-rails (4.6.0) - rails-dom-testing (>= 1, < 3) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) json (2.6.3) language_server-protocol (3.17.0.3) libv8-node (18.16.0.0) @@ -268,7 +271,7 @@ GEM parser (3.2.2.4) ast (~> 2.4.1) racc - popper_js (1.16.1) + popper_js (2.11.8) protocol-hpack (1.4.2) protocol-http (0.25.0) protocol-http1 (0.16.0) @@ -306,7 +309,7 @@ GEM hocon (>= 1.0) puppetdb-ruby (1.2.0) httparty - racc (1.7.2) + racc (1.7.3) rack (3.0.8) rack-session (2.0.0) rack (>= 3.0.0) @@ -350,7 +353,7 @@ GEM rb-inotify (0.10.1) ffi (~> 1.0) rchardet (1.8.0) - rdoc (6.5.0) + rdoc (6.6.0) psych (>= 4.0.0) redis (5.0.8) redis-client (>= 0.17.0) @@ -396,23 +399,15 @@ GEM rexml ruby2_keywords (0.0.5) rubyzip (2.3.2) - sass-embedded (1.69.5) + sass-embedded (1.66.1) google-protobuf (~> 3.23) rake (>= 13.0.0) - sass-embedded (1.69.5-arm64-darwin) + sass-embedded (1.66.1-arm64-darwin) google-protobuf (~> 3.23) - sass-embedded (1.69.5-x86_64-darwin) + sass-embedded (1.66.1-x86_64-darwin) google-protobuf (~> 3.23) - sass-embedded (1.69.5-x86_64-linux-gnu) + sass-embedded (1.66.1-x86_64-linux-gnu) google-protobuf (~> 3.23) - sassc (2.4.0) - ffi (~> 1.9) - sassc-rails (2.1.2) - railties (>= 4.0.0) - sassc (>= 2.0) - sprockets (> 3.0) - sprockets-rails - tilt sawyer (0.9.2) addressable (>= 2.3.5) faraday (>= 0.17.3, < 3) @@ -477,13 +472,14 @@ PLATFORMS DEPENDENCIES bcrypt (~> 3.1.7) - bootstrap (~> 4.6.0) + bootstrap (~> 5.3.0) bootstrap-icons-helper breadcrumbs_on_rails byebug cancancan capybara (>= 2.15) dartsass-rails + dartsass-sprockets diffy factory_bot_rails faker @@ -494,7 +490,6 @@ DEPENDENCIES github_changelog_generator (>= 1.16.1) hiera-eyaml importmap-rails - jquery-rails listen (~> 3.2) mini_racer net-ldap diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index bae6a19e..4f080526 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -3,5 +3,4 @@ //= link_tree ../../javascript .js //= link_tree ../../../vendor/javascript .js //= link bootstrap -//= link jquery //= link application.css diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 036a839b..b4993828 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -31,6 +31,14 @@ $container-max-widths: ( @import "bootstrap"; +a { + text-decoration: none; +} + +.btn-primary { + --bs-btn-color: #fff; +} + ol.breadcrumb li:first-child { padding-left: 0; } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 17e32c51..0da3df1f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,13 +1,13 @@ module ApplicationHelper FLASH_CLASSES = { - "notice" => "alert alert-success", - "error" => "alert alert-danger", - "alert" => "alert alert-warning" + "notice" => "alert-success", + "error" => "alert-danger", + "alert" => "alert-warning" }.freeze ROLE_BADGE_COLORS = { - "admin" => "badge-danger", - "regular" => "badge-success", - "api" => "badge-info" + "admin" => "bg-danger", + "regular" => "bg-success", + "api" => "bg-info" }.freeze def flash_class(level) diff --git a/app/javascript/application.js b/app/javascript/application.js index 128bf092..1580c4fb 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -2,11 +2,5 @@ import "@hotwired/turbo-rails" import "controllers" -import "jquery" +import * as Popper from "@popperjs/core" import "bootstrap" - -// Bootstrap JS Initialization -document.addEventListener("turbo:load", () => { - $('[data-toggle="tooltip"]').tooltip() - $('[data-toggle="popover"]').popover() -}) diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index be44f955..600a6caf 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -31,41 +31,43 @@ <% file_index = 0 %> <% @files_and_values_by_hierarchy.each do |hierarchy, files_and_values| %> <% hierarchy_index += 1 %> -
-
-
-
-
- <% files_and_values.each do |file, value| %> - <% file_index += 1 %> -
-
-

- -

-
-
-
-
<%= value.value %>
+
+ <%#
%> + <% files_and_values.each do |file, value| %> + <% file_index += 1 %> +
+
+

+ +

+
+
+
+
<%= value.value %>
+
-
- <% end %> + <% end %> + <%#
%>
<% end %> diff --git a/app/views/group_memberships/edit.html.erb b/app/views/group_memberships/edit.html.erb index 3764f48d..d2bdd5d3 100644 --- a/app/views/group_memberships/edit.html.erb +++ b/app/views/group_memberships/edit.html.erb @@ -7,7 +7,7 @@
    <%= form.collection_check_boxes :user_ids, users.compact, :id, :full_name_with_email do |b| %> -
  • +
  • <%= b.check_box %> <%= b.label %>
  • diff --git a/app/views/groups/_form.html.erb b/app/views/groups/_form.html.erb index 6bde02f6..37d894ff 100644 --- a/app/views/groups/_form.html.erb +++ b/app/views/groups/_form.html.erb @@ -9,7 +9,7 @@
<% end %> -
+
<%= form.label :name %> <%= form.text_field :name, class:"form-control", autofocus: true %>
@@ -31,11 +31,11 @@ <% end %>

-
+
<%= form.label :restrict %> <%= form.select :restrict, Group::RESTRICTABLES, {}, class:"form-control" %>
-
+
diff --git a/app/views/groups/show.html.erb b/app/views/groups/show.html.erb index 49bf755b..eda86631 100644 --- a/app/views/groups/show.html.erb +++ b/app/views/groups/show.html.erb @@ -1,15 +1,15 @@

Group Details

<%= form_with(model: @group, local: true) do |form| %> -
+
<%= form.label :name %> <%= form.text_field :name, class:"form-control", readonly: true %>
-
+
<%= form.label :restrict %> <%= form.text_field :restrict, class:"form-control", readonly: true %>
-
+
<%= form.label :rules %> <% form.object.rules.each do |rule| %> <%= render "rule", rule: rule, read_only: true %> diff --git a/app/views/keys/_form.html.erb b/app/views/keys/_form.html.erb index 0b6e43f7..7dd8de8e 100644 --- a/app/views/keys/_form.html.erb +++ b/app/views/keys/_form.html.erb @@ -19,7 +19,7 @@ %>
<% if hierarchy.encryption_possible? %> - <%= link_to "#", class: "btn btn-sm btn-primary text-white ml-2", + <%= link_to "#", class: "btn btn-sm btn-primary text-white ms-2", data: { encryption_target: "decryptButton", action: "click->encryption#decrypt" @@ -28,7 +28,7 @@ Decrypt <% end %> <% if file.writable? %> - <%= link_to "#", class: "btn btn-sm btn-primary text-white ml-2", + <%= link_to "#", class: "btn btn-sm btn-primary text-white ms-2", data: { encryption_target: "encryptButton", action: "click->encryption#encrypt" @@ -40,16 +40,16 @@ <% end %> <% if file.writable? %> <% if file.has_key?(@key) %> - <%= link_to environment_node_key_hierarchy_data_file_value_path(@environment, @node, @key, hierarchy, file), data: {turbo_method: :delete, turbo_confirm: "Are you sure?"}, class: "btn btn-sm btn-danger ml-2" do %> + <%= link_to environment_node_key_hierarchy_data_file_value_path(@environment, @node, @key, hierarchy, file), data: {turbo_method: :delete, turbo_confirm: "Are you sure?"}, class: "btn btn-sm btn-danger ms-2" do %> <%= icon "trash" %> Delete <% end %> <% end %> - <%= f.button type: :reset, class: "btn btn-sm btn-secondary ml-2" do %> + <%= f.button type: :reset, class: "btn btn-sm btn-secondary ms-2" do %> <%= icon "arrow-counterclockwise" %> Reset <% end %> - <%= f.button type: :submit, class: "btn btn-sm btn-success text-white ml-2" do %> + <%= f.button type: :submit, class: "btn btn-sm btn-success text-white ms-2" do %> <%= icon "save" %> Save <% end %> diff --git a/app/views/keys/_key_list.html.erb b/app/views/keys/_key_list.html.erb index 06e7a7de..a48a4fa8 100644 --- a/app/views/keys/_key_list.html.erb +++ b/app/views/keys/_key_list.html.erb @@ -2,11 +2,9 @@
-
- - <%= icon "search" %> - -
+ + <%= icon "search" %> + <%= text_field_tag :search, params[:search], class: "form-control", placeholder: "Search", data: {key_filter_target: "input", action: "keyup->key-filter#filter"} %>
diff --git a/app/views/keys/_value.html.erb b/app/views/keys/_value.html.erb index db409ade..15392f29 100644 --- a/app/views/keys/_value.html.erb +++ b/app/views/keys/_value.html.erb @@ -1,10 +1,10 @@ <% if file.has_differing_value_in_original_environment?(@key) %> diff --git a/app/views/keys/show.html.erb b/app/views/keys/show.html.erb index fe5a29c0..76588044 100644 --- a/app/views/keys/show.html.erb +++ b/app/views/keys/show.html.erb @@ -5,56 +5,56 @@ <%= render "key_list" %>
-
+
Lookup options: - <%= @key.lookup_options(@node) %> + <%= @key.lookup_options(@node) %>
<% index = 0 %> <% @environment.hierarchies.each do |hierarchy| %> -
-
-
- <%= hierarchy.name %> - <%= hierarchy.backend %> -
+
+
+

+ + <%= hierarchy.name %> + <%= hierarchy.backend %> + +

<% hierarchy.files_for(node: @node).each do |file| %> <% index += 1 %> <% value = file.value_for(key: @key) %> -
-
-

- -

-
+
+

+ +

-
-
+
+
<%= render "value", file: file, value: value %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index c9b8e7e0..5dcf59c2 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -21,10 +21,9 @@ <% flash.each do |key, value| %> -
+ <% end %> diff --git a/app/views/ldap_sessions/new.html.erb b/app/views/ldap_sessions/new.html.erb index 4c7df0f1..c44478f2 100644 --- a/app/views/ldap_sessions/new.html.erb +++ b/app/views/ldap_sessions/new.html.erb @@ -3,11 +3,11 @@ <%= render "shared/auth_navigation", active: :ldap %> <%= form_tag ldap_session_path do |form| %> -
+
<%= label_tag :email %> <%= text_field_tag :email, nil, class:"form-control", autofocus: true %>
-
+
<%= label_tag :password %> <%= password_field_tag :password, nil, class:"form-control" %>
diff --git a/app/views/nodes/_select_node.html.erb b/app/views/nodes/_select_node.html.erb index 7b302e43..06369226 100644 --- a/app/views/nodes/_select_node.html.erb +++ b/app/views/nodes/_select_node.html.erb @@ -13,9 +13,9 @@
-
- - +
+ +
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 3b95e3d0..4713b8df 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -3,15 +3,15 @@ <%= render "shared/auth_navigation", active: :local %> <%= form_tag sessions_path do |form| %> -
+
<%= label_tag :email %> <%= text_field_tag :email, nil, class:"form-control", autofocus: true %>
-
+
<%= label_tag :password %> <%= password_field_tag :password, nil, class:"form-control" %>
-
+
<%= button_tag class: "btn btn-primary min-width-btn" do %> <%= icon("box-arrow-in-right") %> Login diff --git a/app/views/shared/_top_navigation.html.erb b/app/views/shared/_top_navigation.html.erb index 12386bc8..52e3870b 100644 --- a/app/views/shared/_top_navigation.html.erb +++ b/app/views/shared/_top_navigation.html.erb @@ -1,17 +1,17 @@ -