diff --git a/CHANGELOG b/CHANGELOG index c5e87f14d..9a75375d0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ [v#.#.#] ([month] [YYYY]) - Upgrade to Rails 7.0.8 - Add importmap-rails to handle js libraries + - Remove turbolinks and add turbo-rails - Upgraded gems: - [gem] - Bugs fixes: diff --git a/Gemfile b/Gemfile index 87b500ee1..fe826e7c8 100644 --- a/Gemfile +++ b/Gemfile @@ -22,8 +22,7 @@ gem 'coffee-rails', '~> 5.0' # Cache-friendly, client-side local time gem 'local_time', '>= 2.0.0' -# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks -gem 'turbolinks', '~> 5' +gem 'turbo-rails', '~> 1.4' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.7' @@ -236,15 +235,15 @@ end # ----------------------------------------------------------------- Calculators -gem 'dradis-calculator_cvss', '~> 4.10.0' -gem 'dradis-calculator_dread', '~> 4.10.0' +gem 'dradis-calculator_cvss', github: 'dradis/dradis-calculator_cvss', branch: 'turbo' +gem 'dradis-calculator_dread', github: 'dradis/dradis-calculator_dread', branch: 'turbo' # ---------------------------------------------------------------------- Export gem 'dradis-csv_export', '~> 4.10.0' gem 'dradis-html_export', github: 'dradis/dradis-html_export', branch: 'rails-7-upgrade' # ---------------------------------------------------------------------- Import -gem 'dradis-csv', '~> 4.10.0' +gem 'dradis-csv', github: 'dradis/dradis-csv', branch: 'turbo' # ---------------------------------------------------------------------- Upload gem 'dradis-acunetix', '~> 4.10.0' diff --git a/Gemfile.lock b/Gemfile.lock index e0aeb2ea2..62634e740 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,27 @@ +GIT + remote: https://github.com/dradis/dradis-calculator_cvss.git + revision: 489eb724381a26daf5420e572f4a7e94510faa5b + branch: turbo + specs: + dradis-calculator_cvss (4.10.0) + dradis-plugins (~> 4.0) + +GIT + remote: https://github.com/dradis/dradis-calculator_dread.git + revision: f8367f6144c260bee1b1f11aca9afe1380f11bdf + branch: turbo + specs: + dradis-calculator_dread (4.10.0) + dradis-plugins (~> 4.0) + +GIT + remote: https://github.com/dradis/dradis-csv.git + revision: 8cc5e6d771d236fdce4f3e8ed99dc2ca3686b9b3 + branch: turbo + specs: + dradis-csv (4.10.0) + dradis-plugins (~> 4.0) + GIT remote: https://github.com/dradis/dradis-html_export.git revision: 70ccfe4e99d8cf077afe5aa5a97c73b2dd07049b @@ -141,14 +165,8 @@ GEM dradis-burp (4.10.0) dradis-plugins (~> 4.0) nokogiri (~> 1.3) - dradis-calculator_cvss (4.10.0) - dradis-plugins (~> 4.0) - dradis-calculator_dread (4.10.0) - dradis-plugins (~> 4.0) dradis-coreimpact (4.10.0) dradis-plugins (~> 4.0) - dradis-csv (4.10.0) - dradis-plugins (~> 4.0) dradis-csv_export (4.10.0) dradis-plugins (>= 4.8.0) dradis-metasploit (4.10.0) @@ -486,9 +504,10 @@ GEM date timecop (0.9.5) timeout (0.4.0) - turbolinks (5.2.1) - turbolinks-source (~> 5.2) - turbolinks-source (5.2.0) + turbo-rails (1.5.0) + actionpack (>= 6.0.0) + activejob (>= 6.0.0) + railties (>= 6.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.3.0) @@ -539,10 +558,10 @@ DEPENDENCIES dradis-api! dradis-brakeman (~> 4.10.0) dradis-burp (~> 4.10.0) - dradis-calculator_cvss (~> 4.10.0) - dradis-calculator_dread (~> 4.10.0) + dradis-calculator_cvss! + dradis-calculator_dread! dradis-coreimpact (~> 4.10.0) - dradis-csv (~> 4.10.0) + dradis-csv! dradis-csv_export (~> 4.10.0) dradis-html_export! dradis-metasploit (~> 4.10.0) @@ -614,7 +633,7 @@ DEPENDENCIES thor (~> 1.2.1) time (>= 0.2.2) timecop - turbolinks (~> 5) + turbo-rails (~> 1.4) unicorn (= 6.1.0) warden (~> 1.2.3) web-console (>= 4.1.0) diff --git a/app/assets/javascripts/cable/subscriptions/notifications_channel.js.coffee b/app/assets/javascripts/cable/subscriptions/notifications_channel.js.coffee index b1f1858a3..566993bbe 100644 --- a/app/assets/javascripts/cable/subscriptions/notifications_channel.js.coffee +++ b/app/assets/javascripts/cable/subscriptions/notifications_channel.js.coffee @@ -2,7 +2,7 @@ App.cable.subscriptions.create 'NotificationsChannel', connected: -> console.log('Subscribed to NotificationsChannel.') @perform('check_unread', {}) - $(document).on 'turbolinks:load.notifications', => + $(document).on 'turbo:load.notifications', => @perform('check_unread', {}) rejected: -> diff --git a/app/assets/javascripts/legacy.application.js b/app/assets/javascripts/legacy.application.js index 44d69463b..f480d0860 100644 --- a/app/assets/javascripts/legacy.application.js +++ b/app/assets/javascripts/legacy.application.js @@ -1,4 +1,3 @@ -//= require turbolinks //= require jquery3 //= require popper //= require rails-ujs diff --git a/app/assets/javascripts/shared/behaviors.js b/app/assets/javascripts/shared/behaviors.js index cd6ac4f75..d197c78b0 100644 --- a/app/assets/javascripts/shared/behaviors.js +++ b/app/assets/javascripts/shared/behaviors.js @@ -88,7 +88,7 @@ }); } - document.addEventListener('turbolinks:load', function () { + document.addEventListener('turbo:load', function () { initBehaviors(document.querySelector('body')); }); diff --git a/app/assets/javascripts/shared/datatable/main.js b/app/assets/javascripts/shared/datatable/main.js index 195ae9035..83bc5d0f1 100644 --- a/app/assets/javascripts/shared/datatable/main.js +++ b/app/assets/javascripts/shared/datatable/main.js @@ -293,7 +293,7 @@ class DradisDatatable { unbindDataTable() { var that = this; - document.addEventListener('turbolinks:before-cache', function () { + document.addEventListener('turbo:before-cache', function () { that.dataTable.destroy(); }); } diff --git a/app/assets/javascripts/shared/notifications.js b/app/assets/javascripts/shared/notifications.js index 4a459c273..de5bb4596 100644 --- a/app/assets/javascripts/shared/notifications.js +++ b/app/assets/javascripts/shared/notifications.js @@ -30,7 +30,7 @@ function initNotificationsDropdown() { } } -document.addEventListener('turbolinks:load', function () { +document.addEventListener('turbo:load', function () { initNotificationsDropdown(); }); diff --git a/app/assets/javascripts/shared/revisions.js.coffee b/app/assets/javascripts/shared/revisions.js.coffee index 692424d1b..1c9b4e9e7 100644 --- a/app/assets/javascripts/shared/revisions.js.coffee +++ b/app/assets/javascripts/shared/revisions.js.coffee @@ -1,4 +1,4 @@ -document.addEventListener "turbolinks:load", -> +document.addEventListener "turbo:load", -> if $('.js-diff-body').length delRegex = /\[31m([\s\S]*?)\[0m/g diff --git a/app/assets/javascripts/shared/sessions.js b/app/assets/javascripts/shared/sessions.js index 8017c4361..6a179f24f 100644 --- a/app/assets/javascripts/shared/sessions.js +++ b/app/assets/javascripts/shared/sessions.js @@ -1,4 +1,4 @@ -document.addEventListener('turbolinks:load', function() { +document.addEventListener('turbo:load', function() { if ($('body.unauthenticated').length) { var charCount = 0, strings = setStrings(), diff --git a/app/assets/javascripts/tylium.js b/app/assets/javascripts/tylium.js index a447a2131..e06c5dc67 100644 --- a/app/assets/javascripts/tylium.js +++ b/app/assets/javascripts/tylium.js @@ -1,7 +1,6 @@ //= require jquery3 //= require jquery-ui //= require rails-ujs -//= require turbolinks // require activestorage //= require jquery.form //= require jquery.textchange.min diff --git a/app/assets/javascripts/tylium/behaviors.js.coffee b/app/assets/javascripts/tylium/behaviors.js.coffee index 3627efdbf..e74107535 100644 --- a/app/assets/javascripts/tylium/behaviors.js.coffee +++ b/app/assets/javascripts/tylium/behaviors.js.coffee @@ -6,7 +6,7 @@ # The current list of plugins: # * jQuery.Textile - handles the note editor (/vendor/) -document.addEventListener "turbolinks:load", -> +document.addEventListener "turbo:load", -> # --------------------------------------------------- Standard jQuery plugins @@ -174,11 +174,11 @@ document.addEventListener "turbolinks:load", -> else $(this).find($('[data-behavior~=scroll-wrapper]')).removeClass('hidden'); - # Disable turbolinks for on-page anchor links (prevents page from jumping to top and allows smooth-scrolling) + # Disable turbo for on-page anchor links (prevents page from jumping to top and allows smooth-scrolling) if $('a[href^="#"]').length $('a[href^="#"]').each -> - if !$(this).data('turbolinks') - $(this).attr 'data-turbolinks', 'false' + if !$(this).data('turbo') + $(this).attr 'data-turbo', 'false' return # Smooth Scrolling - scroll to element on page load if hash present in current browser url diff --git a/app/assets/javascripts/tylium/engines.js.erb b/app/assets/javascripts/tylium/engines.js.erb index 26806a156..01a6f7552 100644 --- a/app/assets/javascripts/tylium/engines.js.erb +++ b/app/assets/javascripts/tylium/engines.js.erb @@ -1,4 +1,4 @@ -document.addEventListener('turbolinks:load', function(){ +document.addEventListener('turbo:load', function(){ <% Dradis::Plugins::with_feature(:addon).sort_by(&:plugin_description).each do |plugin| begin diff --git a/app/assets/javascripts/tylium/keyboard_shortcuts.js.coffee b/app/assets/javascripts/tylium/keyboard_shortcuts.js.coffee index 2dd630d96..0ffbda2f3 100644 --- a/app/assets/javascripts/tylium/keyboard_shortcuts.js.coffee +++ b/app/assets/javascripts/tylium/keyboard_shortcuts.js.coffee @@ -1,4 +1,4 @@ -document.addEventListener "turbolinks:load", -> +document.addEventListener "turbo:load", -> # Nodes#show shortcuts if $('body.nodes').length diff --git a/app/assets/javascripts/tylium/modules/configurations.js.coffee b/app/assets/javascripts/tylium/modules/configurations.js.coffee index 52c925d1c..2b001f9e9 100644 --- a/app/assets/javascripts/tylium/modules/configurations.js.coffee +++ b/app/assets/javascripts/tylium/modules/configurations.js.coffee @@ -1,4 +1,4 @@ -document.addEventListener "turbolinks:load", -> +document.addEventListener "turbo:load", -> if $('body.configurations').length $('tbody tr.gemified td.value').on('blur', 'input', -> diff --git a/app/assets/javascripts/tylium/modules/export.js.coffee b/app/assets/javascripts/tylium/modules/export.js.coffee index ae9f71afd..ef2819942 100644 --- a/app/assets/javascripts/tylium/modules/export.js.coffee +++ b/app/assets/javascripts/tylium/modules/export.js.coffee @@ -1,4 +1,4 @@ -document.addEventListener "turbolinks:load", -> +document.addEventListener "turbo:load", -> if $('body.export').length # Detect Export click diff --git a/app/assets/javascripts/tylium/modules/fileupload.js b/app/assets/javascripts/tylium/modules/fileupload.js index d7b5be9db..f24340e6e 100644 --- a/app/assets/javascripts/tylium/modules/fileupload.js +++ b/app/assets/javascripts/tylium/modules/fileupload.js @@ -30,13 +30,13 @@ function fileUploadInit() { }); } -document.addEventListener("turbolinks:load", function() { +document.addEventListener("turbo:load", function() { // Bind fileUpload on page load. fileUploadInit(); }); // Un-bind fileUpload on page unload. -document.addEventListener('turbolinks:before-cache', function() { +document.addEventListener('turbo:before-cache', function() { $('[data-behavior~=jquery-upload]').each(function() { $(this).fileupload('destroy'); }); diff --git a/app/assets/javascripts/tylium/modules/issues/evidence.js.coffee b/app/assets/javascripts/tylium/modules/issues/evidence.js.coffee index d7e9e246d..d7dbda5c9 100644 --- a/app/assets/javascripts/tylium/modules/issues/evidence.js.coffee +++ b/app/assets/javascripts/tylium/modules/issues/evidence.js.coffee @@ -1,4 +1,4 @@ -document.addEventListener "turbolinks:load", -> +document.addEventListener "turbo:load", -> if $('body.evidence.new').length $('#evidence-host-list a[data-bs-toggle~=pill]').on 'click', (ev)-> path = $(this).data('path') diff --git a/app/assets/javascripts/tylium/modules/issues/importer.js.coffee b/app/assets/javascripts/tylium/modules/issues/importer.js.coffee index 9394df978..0f40942ab 100644 --- a/app/assets/javascripts/tylium/modules/issues/importer.js.coffee +++ b/app/assets/javascripts/tylium/modules/issues/importer.js.coffee @@ -12,7 +12,7 @@ } } -document.addEventListener "turbolinks:load", -> +document.addEventListener "turbo:load", -> if $('#issues').length # Detect if we're displaying results of a query and toggle the widget if $('.results').length diff --git a/app/assets/javascripts/tylium/modules/issues/merge.js.coffee b/app/assets/javascripts/tylium/modules/issues/merge.js.coffee index 2d4c72fa9..e9d3b50f1 100644 --- a/app/assets/javascripts/tylium/modules/issues/merge.js.coffee +++ b/app/assets/javascripts/tylium/modules/issues/merge.js.coffee @@ -1,4 +1,4 @@ -document.addEventListener "turbolinks:load", -> +document.addEventListener "turbo:load", -> if ($("body.merge.new").length) # when clicking on the "expand/collapse" arrow icon, turn it upside down diff --git a/app/assets/javascripts/tylium/modules/issues/tag-input.js.coffee b/app/assets/javascripts/tylium/modules/issues/tag-input.js.coffee index cce858733..fb6422208 100644 --- a/app/assets/javascripts/tylium/modules/issues/tag-input.js.coffee +++ b/app/assets/javascripts/tylium/modules/issues/tag-input.js.coffee @@ -8,7 +8,7 @@ class @SelectTagDropdown $span.css("color", @$target.css("color")) $span.html(@$target.html()) -document.addEventListener "turbolinks:load", -> +document.addEventListener "turbo:load", -> $('#issues_editor .js-taglink').click (e) -> $target = $(e.target) new SelectTagDropdown($target) diff --git a/app/assets/javascripts/tylium/modules/nodes.js.coffee b/app/assets/javascripts/tylium/modules/nodes.js.coffee index d93d530e7..b0336c32c 100644 --- a/app/assets/javascripts/tylium/modules/nodes.js.coffee +++ b/app/assets/javascripts/tylium/modules/nodes.js.coffee @@ -1,4 +1,4 @@ -document.addEventListener "turbolinks:load", -> +document.addEventListener "turbo:load", -> $(".add_node_radio").click -> $this = $(this) $modal = $this.closest(".modal") diff --git a/app/assets/javascripts/tylium/modules/search.js.coffee b/app/assets/javascripts/tylium/modules/search.js.coffee index f1cc029a9..12c1eadec 100644 --- a/app/assets/javascripts/tylium/modules/search.js.coffee +++ b/app/assets/javascripts/tylium/modules/search.js.coffee @@ -8,7 +8,7 @@ class SearchWordHighlight element.html src_str -document.addEventListener "turbolinks:load", -> +document.addEventListener "turbo:load", -> if $('body.search.index').length highlighter = new SearchWordHighlight query = $(".form-search #q").val() diff --git a/app/assets/javascripts/tylium/modules/sidebar.js b/app/assets/javascripts/tylium/modules/sidebar.js index 549a302e3..142da5ada 100644 --- a/app/assets/javascripts/tylium/modules/sidebar.js +++ b/app/assets/javascripts/tylium/modules/sidebar.js @@ -64,7 +64,7 @@ }, changeState: function (key, state) { localStorage.setItem(key, state); - Turbolinks.clearCache(); + Turbo.cache.clear(); }, close: function () { this.$sidebar diff --git a/app/assets/javascripts/tylium/modules/state_button.js b/app/assets/javascripts/tylium/modules/state_button.js index d360b1a5c..24ed70380 100644 --- a/app/assets/javascripts/tylium/modules/state_button.js +++ b/app/assets/javascripts/tylium/modules/state_button.js @@ -1,4 +1,4 @@ -document.addEventListener('turbolinks:load', function () { +document.addEventListener('turbo:load', function () { if ($('[data-behavior~=state-radio]').length) { function updateBtn($selectedRadio) { var selectedState = $selectedRadio diff --git a/app/assets/javascripts/tylium/modules/uploads.js.coffee b/app/assets/javascripts/tylium/modules/uploads.js.coffee index 82c28bf22..2e9fe3296 100644 --- a/app/assets/javascripts/tylium/modules/uploads.js.coffee +++ b/app/assets/javascripts/tylium/modules/uploads.js.coffee @@ -1,4 +1,4 @@ -document.addEventListener "turbolinks:load", -> +document.addEventListener "turbo:load", -> if $('body.upload').length # Enable Ajax file uploads via 3rd party plugin $bar = $('.progress-bar'); diff --git a/app/assets/javascripts/tylium/pages/activities.js b/app/assets/javascripts/tylium/pages/activities.js index 289db617a..5b84e1a21 100644 --- a/app/assets/javascripts/tylium/pages/activities.js +++ b/app/assets/javascripts/tylium/pages/activities.js @@ -1,4 +1,4 @@ -document.addEventListener('turbolinks:load', function() { +document.addEventListener('turbo:load', function() { var $infiniteScrollContainer = $('[data-behavior="infinite-scroll-container"]'); var loading = false; diff --git a/app/assets/javascripts/tylium/pages/boards/index.js.coffee b/app/assets/javascripts/tylium/pages/boards/index.js.coffee index b61369bdd..705964bbf 100644 --- a/app/assets/javascripts/tylium/pages/boards/index.js.coffee +++ b/app/assets/javascripts/tylium/pages/boards/index.js.coffee @@ -1,4 +1,4 @@ -document.addEventListener "turbolinks:load", -> +document.addEventListener "turbo:load", -> if $('body.boards.index').length diff --git a/app/assets/javascripts/tylium/pages/boards/show.js.coffee b/app/assets/javascripts/tylium/pages/boards/show.js.coffee index eeadfcef4..51f3162af 100644 --- a/app/assets/javascripts/tylium/pages/boards/show.js.coffee +++ b/app/assets/javascripts/tylium/pages/boards/show.js.coffee @@ -35,7 +35,7 @@ class SortableBoards return -document.addEventListener "turbolinks:load", -> +document.addEventListener "turbo:load", -> if $('body.boards.show').length # ------------------------------------------------------------- List modals diff --git a/app/assets/javascripts/tylium/pages/issues.js b/app/assets/javascripts/tylium/pages/issues.js index 9dafc88f4..49312e401 100644 --- a/app/assets/javascripts/tylium/pages/issues.js +++ b/app/assets/javascripts/tylium/pages/issues.js @@ -1,4 +1,4 @@ -document.addEventListener('turbolinks:load', function () { +document.addEventListener('turbo:load', function () { if ($('body.issues.index').length) { $('[data-behavior~=issues-dropdown-toggle]').on('click', function (e) { e.stopPropagation(); diff --git a/app/assets/javascripts/tylium/pages/nodes/new_form.js b/app/assets/javascripts/tylium/pages/nodes/new_form.js index 09c02b7c2..e3afded1c 100644 --- a/app/assets/javascripts/tylium/pages/nodes/new_form.js +++ b/app/assets/javascripts/tylium/pages/nodes/new_form.js @@ -1,5 +1,5 @@ (function() { - document.addEventListener('turbolinks:load', function() { + document.addEventListener('turbo:load', function() { var copyOver = function($to, fromVal, $typeTo, typeFromVal) { if ($to.val() === '' && fromVal !== '') { $to.val(fromVal.trim().split('\n')[0] + '\n'); diff --git a/app/assets/javascripts/tylium/pages/projects/boards_summary.js b/app/assets/javascripts/tylium/pages/projects/boards_summary.js index a103a181f..40f5f3c20 100644 --- a/app/assets/javascripts/tylium/pages/projects/boards_summary.js +++ b/app/assets/javascripts/tylium/pages/projects/boards_summary.js @@ -1,4 +1,4 @@ -document.addEventListener('turbolinks:load', function(){ +document.addEventListener('turbo:load', function(){ if ($('[data-behavior~=boards-summary]').length) { var $boardsSummary = $('[data-behavior~=boards-summary]'); var url = $boardsSummary.data('url'); diff --git a/app/assets/javascripts/tylium/pages/projects/issues_chart.js b/app/assets/javascripts/tylium/pages/projects/issues_chart.js index 126c477a2..982b5f240 100644 --- a/app/assets/javascripts/tylium/pages/projects/issues_chart.js +++ b/app/assets/javascripts/tylium/pages/projects/issues_chart.js @@ -1,4 +1,4 @@ -document.addEventListener('turbolinks:load', function(){ +document.addEventListener('turbo:load', function(){ var $dataElement = $('#issues-summary-data'), $chartElement = $('#issue-chart'); diff --git a/app/assets/javascripts/tylium/pages/projects/summary.js b/app/assets/javascripts/tylium/pages/projects/summary.js index 2a2e64075..f0d83a5ad 100644 --- a/app/assets/javascripts/tylium/pages/projects/summary.js +++ b/app/assets/javascripts/tylium/pages/projects/summary.js @@ -1,4 +1,4 @@ -document.addEventListener('turbolinks:load', function () { +document.addEventListener('turbo:load', function () { if ($('body.projects.show').length) { $('a[data-bs-toggle="collapse"]').click(function () { if ($(this).hasClass('collapsed')) { diff --git a/app/assets/javascripts/tylium/pages/qa.js b/app/assets/javascripts/tylium/pages/qa.js index 16bb7943e..b49102979 100644 --- a/app/assets/javascripts/tylium/pages/qa.js +++ b/app/assets/javascripts/tylium/pages/qa.js @@ -1,4 +1,4 @@ -document.addEventListener('turbolinks:load', function () { +document.addEventListener('turbo:load', function () { if ($('[data-behavior~=qa-viewer]').length) { $('[data-qa-visible]').each(function () { $(this).toggleClass('d-none', $(this).data('qa-visible') === false); diff --git a/app/assets/javascripts/tylium/pages/upload.js b/app/assets/javascripts/tylium/pages/upload.js index bf669b069..0d4806deb 100644 --- a/app/assets/javascripts/tylium/pages/upload.js +++ b/app/assets/javascripts/tylium/pages/upload.js @@ -1,4 +1,4 @@ -document.addEventListener('turbolinks:load', function () { +document.addEventListener('turbo:load', function () { if ($('body.upload.index').length) { $('[data-behavior~=tool-select]').on('change', function () { let toolsWithInheritedState = [ diff --git a/app/assets/javascripts/tylium/pages/uploads/validation.js b/app/assets/javascripts/tylium/pages/uploads/validation.js index 87de348f4..08b7603c9 100644 --- a/app/assets/javascripts/tylium/pages/uploads/validation.js +++ b/app/assets/javascripts/tylium/pages/uploads/validation.js @@ -1,4 +1,4 @@ -document.addEventListener('turbolinks:load', function() { +document.addEventListener('turbo:load', function() { var $rtpValidation = $('[data-behavior~=rtp-validation]'); if ($rtpValidation.length) { diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 835cf6705..41da37ff4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,6 +3,7 @@ class ApplicationController < ActionController::Base include Authentication + include Turbo::Redirection protect_from_forgery with: :exception end diff --git a/app/controllers/concerns/turbo/redirection.rb b/app/controllers/concerns/turbo/redirection.rb new file mode 100644 index 000000000..26ba040ea --- /dev/null +++ b/app/controllers/concerns/turbo/redirection.rb @@ -0,0 +1,31 @@ +module Turbo + module Redirection + extend ActiveSupport::Concern + + def redirect_to(url = {}, options = {}) + turbo = options.delete(:turbo) + + super.tap do + if turbo != false && request.xhr? && !request.get? + visit_location_with_turbo(location, turbo) + end + end + end + + private + def visit_location_with_turbo(location, action) + visit_options = { + action: action.to_s == 'advance' ? action : 'replace' + } + + script = [] + script << 'Turbo.cache.clear()' + script << "Turbo.visit(#{location.to_json}, #{visit_options.to_json})" + + self.status = 200 + self.response_body = script.join("\n") + response.content_type = 'text/javascript' + response.headers['X-Xhr-Redirect'] = location + end + end +end diff --git a/app/javascript/application.js b/app/javascript/application.js index 03422366f..18b7b3338 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -1,3 +1,8 @@ // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails +import '@hotwired/turbo-rails' import 'datatables' import 'stupidtable' + +// Forms by default will not be submitted with turbo unless the +// data-turbo="true" attribute is present. See: https://github.com/hotwired/turbo/pull/419 +Turbo.setFormMode("optin") diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index dc22bfc1c..40849b8c8 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -32,7 +32,7 @@ - <%= link_to local_time_ago(comment.created_at), "##{dom_id(comment)}", data: { turbolinks: false } %> + <%= link_to local_time_ago(comment.created_at), "##{dom_id(comment)}", data: { turbo: false } %> diff --git a/app/views/console/status.js.erb b/app/views/console/status.js.erb index 9a197c748..05923fe12 100644 --- a/app/views/console/status.js.erb +++ b/app/views/console/status.js.erb @@ -16,14 +16,14 @@ if (anyLogs) { var close_url = $('#result').data('close-url'); if (!working && close_url) { - if (window.Turbolinks) { // Turbolinks is only present in tylium: + if (window.Turbo) { $('#modal-console').on('hide', function() { - Turbolinks.clearCache(); - Turbolinks.visit(close_url); + Turbo.cache.clear(); + Turbo.visit(close_url); }); $("#modal-console .modal-footer").removeClass('d-none'); } else if (window.location != close_url) { - // if Turbolinks isn't present, do it the old-fashioned way: + // if Turbo isn't present, do it the old-fashioned way: window.location = close_url; } else { // if .location == close_url, we need to do it this way: window.location.reload(true); diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 8d9fd7697..efaafedc9 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -2,8 +2,8 @@ <%= [content_for(:title), 'Dradis Community Edition'].compact.join(' | ') %> - <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> - <%= javascript_include_tag 'legacy.application', 'data-turbolinks-track' => true %> + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbo-track' => true %> + <%= javascript_include_tag 'legacy.application', 'data-turbo-track' => true %> <%= favicon_link_tag %> <%= csrf_meta_tags %> <%= csp_meta_tag %> diff --git a/app/views/layouts/setup.html.erb b/app/views/layouts/setup.html.erb index 0e8a24167..d417989b0 100644 --- a/app/views/layouts/setup.html.erb +++ b/app/views/layouts/setup.html.erb @@ -3,7 +3,7 @@ <%= content_for?(:title) ? yield(:title) : 'Dradis Community Edition' %> - <%= stylesheet_link_tag 'setup/setup', media: 'all', 'data-turbolinks-track' => true %> + <%= stylesheet_link_tag 'setup/setup', media: 'all', 'data-turbo-track' => true %> <%= favicon_link_tag %> <%= csrf_meta_tag %> diff --git a/app/views/layouts/tylium.html.erb b/app/views/layouts/tylium.html.erb index 899df6e8b..dfc55e7cf 100644 --- a/app/views/layouts/tylium.html.erb +++ b/app/views/layouts/tylium.html.erb @@ -11,7 +11,7 @@ <% if flash.any? %> <% # when flash messages present, disable turbolinks cache to avoid # the message appear and disappear in the next page load %> - + <% end %> <%= render 'comments/mentionable_users' if @mentionable_users %> @@ -21,8 +21,8 @@ 'data-unread': image_path('favicon-unread.ico'), 'data-read': image_path('favicon.ico') %> - <%= stylesheet_link_tag 'tylium', media: 'all', 'data-turbolinks-track' => true %> - <%= javascript_include_tag 'tylium', 'data-turbolinks-track' => true %> + <%= stylesheet_link_tag 'tylium', media: 'all', 'data-turbo-track' => true %> + <%= javascript_include_tag 'tylium', 'data-turbo-track' => true %> <%= csrf_meta_tag %> <%= csp_meta_tag %> <%= javascript_importmap_tags %> diff --git a/app/views/layouts/tylium/_navbar.html.erb b/app/views/layouts/tylium/_navbar.html.erb index b0c456118..6ab62abe3 100644 --- a/app/views/layouts/tylium/_navbar.html.erb +++ b/app/views/layouts/tylium/_navbar.html.erb @@ -62,7 +62,7 @@ diff --git a/config/importmap.rb b/config/importmap.rb index 848ae586b..3d0b27f09 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -1,6 +1,7 @@ # Pin npm packages by running ./bin/importmap pin 'application', preload: true +pin '@hotwired/turbo-rails', to: 'turbo.min.js', preload: true pin 'datatables' pin 'stupidtable' diff --git a/spec/features/note_pages_spec.rb b/spec/features/note_pages_spec.rb index ade0d559f..e2ca4b653 100644 --- a/spec/features/note_pages_spec.rb +++ b/spec/features/note_pages_spec.rb @@ -152,7 +152,7 @@ describe 'cancel button' do it 'returns to the note page' do cancel_form - expect(current_path).to eq project_node_note_path(current_project, @node, @note) + expect(page).to have_current_path(project_node_note_path(current_project, @node, @note)) end end @@ -226,7 +226,7 @@ describe 'cancel button' do it 'returns to the node page' do cancel_form - expect(current_path).to eq project_node_path(current_project, @node) + expect(page).to have_current_path(project_node_path(current_project, @node)) end end end diff --git a/spec/features/tags_spec.rb b/spec/features/tags_spec.rb index 1a4044165..c157ecbf0 100644 --- a/spec/features/tags_spec.rb +++ b/spec/features/tags_spec.rb @@ -64,7 +64,7 @@ it 'renders manage tag' do click_link 'Manage tags' - expect(current_path).to eq(project_tags_path(current_project)) + expect(page).to have_current_path(project_tags_path(current_project)) end end diff --git a/spec/support/qa_shared_examples.rb b/spec/support/qa_shared_examples.rb index 551a6842e..bd43791e2 100644 --- a/spec/support/qa_shared_examples.rb +++ b/spec/support/qa_shared_examples.rb @@ -18,7 +18,7 @@ find('.dataTable tbody tr:first-of-type').hover click_link 'Edit' - expect(current_path).to eq polymorphic_path([:edit, current_project, :qa, records.first]) + expect(page).to have_current_path(polymorphic_path([:edit, current_project, :qa, records.first])) click_button "Update #{item_type.to_s.titleize}"