From 486409c076b3f723385976f81d52c946edc1077f Mon Sep 17 00:00:00 2001 From: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> Date: Tue, 19 Dec 2023 21:58:50 +0200 Subject: [PATCH] chore: remove ujs (#2256) --- app/components/avo/resource_component.rb | 5 +++-- .../avo/sidebar_profile_component.html.erb | 5 +++-- app/javascript/avo.base.js | 2 -- package.json | 1 - spec/system/avo/belongs_to_polymorphic_spec.rb | 1 + spec/system/avo/sign_out_dropdown_spec.rb | 17 ++++++++--------- yarn.lock | 5 ----- 7 files changed, 15 insertions(+), 21 deletions(-) diff --git a/app/components/avo/resource_component.rb b/app/components/avo/resource_component.rb index 3b7c53861c..0bdbc90c7e 100644 --- a/app/components/avo/resource_component.rb +++ b/app/components/avo/resource_component.rb @@ -240,13 +240,14 @@ def render_edit_button(control) def render_detach_button(control) return unless is_a_related_resource? && can_detach? - a_button url: detach_path, + a_link detach_path, icon: "detach", method: :delete, form_class: "flex flex-col sm:flex-row sm:inline-flex", style: :text, data: { - confirm: "Are you sure you want to detach this #{title}." + turbo_method: :delete, + turbo_confirm: "Are you sure you want to detach this #{title}." } do control.label || t("avo.detach_item", item: title).humanize end diff --git a/app/components/avo/sidebar_profile_component.html.erb b/app/components/avo/sidebar_profile_component.html.erb index 2ac83bcfb1..6e74648b54 100644 --- a/app/components/avo/sidebar_profile_component.html.erb +++ b/app/components/avo/sidebar_profile_component.html.erb @@ -41,11 +41,12 @@ <% end %> <%= render "avo/partials/profile_menu_extra" %> <% if can_destroy_user? %> - <%= button_to helpers.main_app.send(destroy_user_session_path), + <%= link_to helpers.main_app.send(destroy_user_session_path), form: { "data-turbo" => "false" }, method: :delete, data: { - confirm: t('avo.are_you_sure') + turbo_method: :delete, + turbo_confirm: t('avo.are_you_sure') }, class: "flex-1 flex items-center justify-center bg-white text-left cursor-pointer text-red-600 font-semibold hover:bg-red-100 block px-4 py-1 w-full py-3 text-center rounded w-full", form_class: 'flex-1' do %> diff --git a/app/javascript/avo.base.js b/app/javascript/avo.base.js index d53b465c73..28e612ff07 100644 --- a/app/javascript/avo.base.js +++ b/app/javascript/avo.base.js @@ -5,7 +5,6 @@ import 'regenerator-runtime/runtime' import * as ActiveStorage from '@rails/activestorage' import * as Mousetrap from 'mousetrap' import { Turbo } from '@hotwired/turbo-rails' -import Rails from '@rails/ujs' import tippy from 'tippy.js' import { LocalStorageService } from './js/local-storage-service' @@ -18,7 +17,6 @@ import './js/active-storage' import './js/controllers' import './js/custom-stream-actions' -Rails.start() window.Turbolinks = Turbo diff --git a/package.json b/package.json index ef8580d3a3..44c589b693 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,6 @@ "@hotwired/stimulus": "^3.2.2", "@hotwired/turbo-rails": "^7.3.0", "@rails/activestorage": "^6.1.7", - "@rails/ujs": "^6.1.0", "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.10", "@yaireo/tagify": "^4.17.9", diff --git a/spec/system/avo/belongs_to_polymorphic_spec.rb b/spec/system/avo/belongs_to_polymorphic_spec.rb index 8741b55416..5b44190fd7 100644 --- a/spec/system/avo/belongs_to_polymorphic_spec.rb +++ b/spec/system/avo/belongs_to_polymorphic_spec.rb @@ -230,6 +230,7 @@ click_on "Save" wait_for_loaded + sleep 0.5 expect(current_path).to eq "/admin/resources/projects/#{project.id}" diff --git a/spec/system/avo/sign_out_dropdown_spec.rb b/spec/system/avo/sign_out_dropdown_spec.rb index be9057e5bf..5f9d3bb552 100644 --- a/spec/system/avo/sign_out_dropdown_spec.rb +++ b/spec/system/avo/sign_out_dropdown_spec.rb @@ -6,21 +6,20 @@ visit "/admin/resources/posts" expect(page.body).to have_text admin.name - expect(page.body).to have_button "Sign out", visible: false + expect(page.body).to have_link "Sign out", visible: false - dots_button = find("[data-control='profile-dots']") + dots_link = find("[data-control='profile-dots']") - dots_button.click + dots_link.click - expect(page.body).to have_button "Sign out", visible: true + expect(page.body).to have_link "Sign out", visible: true # Test click away - # FIXME: Selenium::WebDriver::Error::ElementNotInteractableError: element not interactable - # page.find("body").click - # expect(page.body).to have_button "Sign out", visible: false + page.find("body").click + expect(page.body).to have_link "Sign out", visible: false - # dots_button.click - click_button "Sign out" + dots_link.click + click_link "Sign out" accept_alert wait_for_loaded diff --git a/yarn.lock b/yarn.lock index 622aa94841..ef71d084c7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1502,11 +1502,6 @@ dependencies: spark-md5 "^3.0.0" -"@rails/ujs@^6.1.0": - version "6.1.0" - resolved "https://registry.yarnpkg.com/@rails/ujs/-/ujs-6.1.0.tgz#9a48df6511cb2b472c9f596c1f37dc0af022e751" - integrity sha512-kQNKyM4ePAc4u9eR1c4OqrbAHH+3SJXt++8izIjeaZeg+P7yBtgoF/dogMD/JPPowNC74ACFpM/4op0Ggp/fPw== - "@tailwindcss/forms@^0.5.7": version "0.5.7" resolved "https://registry.yarnpkg.com/@tailwindcss/forms/-/forms-0.5.7.tgz#db5421f062a757b5f828bc9286ba626c6685e821"