From dce6e5a649494ba28dc69c8f9dc2e428fd1100c1 Mon Sep 17 00:00:00 2001 From: Andy Cohen Date: Tue, 1 Oct 2024 15:55:36 -0500 Subject: [PATCH] [Fix #28] adopt new Turbo Integration Point Minimum required Turbo Version: v8.0.6 --- package.json | 7 +++++-- src/index.js | 7 +++---- test/dummy/.ruby-version | 2 +- test/dummy/Gemfile | 7 ++++++- test/dummy/Gemfile.lock | 8 +++++++- test/dummy/yarn.lock | 16 ++++++++-------- yarn.lock | 33 +++++++++++++++++++-------------- 7 files changed, 49 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index 8e2dd38..9b98007 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,12 @@ { "name": "@rolemodel/turbo-confirm", "type": "module", - "version": "2.0.2", + "version": "2.1.0", "description": "Drop-in upgrade for Rails' data-turbo-confirm feature to support custom HTML dialogs.", "main": "src/index.js", + "dependencies": { + "@hotwired/turbo": ">= 8.0.6" + }, "directories": { "lib": "src/lib" }, @@ -33,7 +36,7 @@ }, "homepage": "https://github.com/RoleModel/turbo-confirm#readme", "devDependencies": { - "@playwright/test": "^1.42.1", + "@playwright/test": "^1.47", "@types/node": "^20.11.30" } } diff --git a/src/index.js b/src/index.js index 5531846..359fb67 100644 --- a/src/index.js +++ b/src/index.js @@ -2,11 +2,10 @@ import { dispatch, TurboConfirmError } from './lib/utils.js' import { TurboConfirm } from './lib/TurboConfirm.js' const start = (options) => { - const tc = new TurboConfirm(options) - if (!window.Turbo) throw TurboConfirmError.noTurbo() + const tc = new TurboConfirm(options) - window.Turbo.setConfirmMethod(async (message, formElement, submitter) => { + window.Turbo.config.forms.confirm = async (message, formElement, submitter) => { const response = await tc.confirm(message, formElement, submitter) if (response) { @@ -16,7 +15,7 @@ const start = (options) => { } return response - }) + } } export default { start } diff --git a/test/dummy/.ruby-version b/test/dummy/.ruby-version index bea438e..fa7adc7 100644 --- a/test/dummy/.ruby-version +++ b/test/dummy/.ruby-version @@ -1 +1 @@ -3.3.1 +3.3.5 diff --git a/test/dummy/Gemfile b/test/dummy/Gemfile index 692c230..8cfdb48 100644 --- a/test/dummy/Gemfile +++ b/test/dummy/Gemfile @@ -1,6 +1,6 @@ source "https://rubygems.org" -ruby "3.3.1" +ruby file: ".ruby-version" # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" gem "rails", "~> 7.1.3", ">= 7.1.3.2" @@ -32,6 +32,11 @@ gem "tzinfo-data", platforms: %i[ windows jruby ] # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", require: false +# will be removed from stdlib in Ruby 3.5 +gem "ostruct" +gem "fiddle" +gem "logger" + group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem "debug", platforms: %i[ mri windows ] diff --git a/test/dummy/Gemfile.lock b/test/dummy/Gemfile.lock index 33c6961..a104446 100644 --- a/test/dummy/Gemfile.lock +++ b/test/dummy/Gemfile.lock @@ -98,6 +98,7 @@ GEM reline (>= 0.3.8) drb (2.2.1) erubi (1.12.0) + fiddle (1.1.2) foreman (0.87.2) globalid (1.2.1) activesupport (>= 6.1) @@ -109,6 +110,7 @@ GEM reline (>= 0.4.2) jsbundling-rails (1.3.0) railties (>= 6.0.0) + logger (1.6.0) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -144,6 +146,7 @@ GEM racc (~> 1.4) nokogiri (1.16.5-x86_64-linux) racc (~> 1.4) + ostruct (0.6.0) psych (5.1.2) stringio puma (6.4.3) @@ -243,8 +246,11 @@ DEPENDENCIES bootsnap cssbundling-rails debug + fiddle foreman jsbundling-rails + logger + ostruct puma (>= 5.0) rails (~> 7.1.3, >= 7.1.3.2) rolemodel_rails! @@ -257,7 +263,7 @@ DEPENDENCIES web-console RUBY VERSION - ruby 3.3.1p55 + ruby 3.3.5p100 BUNDLED WITH 2.5.7 diff --git a/test/dummy/yarn.lock b/test/dummy/yarn.lock index 7a84dd9..a987e06 100644 --- a/test/dummy/yarn.lock +++ b/test/dummy/yarn.lock @@ -501,17 +501,17 @@ integrity sha512-eGeIqNOQpXoPAIP7tC1+1Yc1yl1xnwYqg+3mzqxyrbE5pg5YFBZcA6YoTiByJB6DKAEsiWtl6tjTJS4IYtbB7A== "@hotwired/turbo-rails@^8.0.4": - version "8.0.4" - resolved "https://registry.yarnpkg.com/@hotwired/turbo-rails/-/turbo-rails-8.0.4.tgz#d224f524a9e33fe687cec5d706054eb6fe13fa5b" - integrity sha512-GHCv5+B2VzYZZvMFpg/g9JLx/8pl/8chcubSB7T+Xn1zYOMqAKB6cT80vvWUzxdwfm/2KfaRysfDz+BmvtjFaw== + version "8.0.10" + resolved "https://registry.yarnpkg.com/@hotwired/turbo-rails/-/turbo-rails-8.0.10.tgz#28b0c1243868d9efc4a71f4a2ff7d97ee9cefbfa" + integrity sha512-BkERfjTbNwMb9/YQi0RL9+f9zkD+dZH2klEONtGwXrIE3O9BE1937Nn9++koZpDryD4XN3zE5U5ibyWoYJAWBg== dependencies: - "@hotwired/turbo" "^8.0.4" + "@hotwired/turbo" "^8.0.6" "@rails/actioncable" "^7.0" -"@hotwired/turbo@^8.0.4": - version "8.0.4" - resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-8.0.4.tgz#5c5361c06a37cdf10dcba4223f1afd0ca1c75091" - integrity sha512-mlZEFUZrJnpfj+g/XeCWWuokvQyN68WvM78JM+0jfSFc98wegm259vCbC1zSllcspRwbgXK31ibehCy5PA78/Q== +"@hotwired/turbo@>=8.0.6", "@hotwired/turbo@^8.0.6": + version "8.0.10" + resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-8.0.10.tgz#d95569d259f0daad6e824ee1ada877ff94beb72b" + integrity sha512-xen1YhNQirAHlA8vr/444XsTNITC1Il2l/Vx4w8hAWPpI5nQO78mVHNsmFuayETodzPwh25ob2TgfCEV/Loiog== "@jest/schemas@^29.6.3": version "29.6.3" diff --git a/yarn.lock b/yarn.lock index b3486a6..f4a9187 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,12 +2,17 @@ # yarn lockfile v1 -"@playwright/test@^1.42.1": - version "1.42.1" - resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.42.1.tgz#9eff7417bcaa770e9e9a00439e078284b301f31c" - integrity sha512-Gq9rmS54mjBL/7/MvBaNOBwbfnh7beHvS6oS4srqXFcQHpQCV1+c8JXWE8VLPyRDhgS3H8x8A7hztqI9VnwrAQ== +"@hotwired/turbo@>=8.0.6": + version "8.0.10" + resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-8.0.10.tgz#d95569d259f0daad6e824ee1ada877ff94beb72b" + integrity sha512-xen1YhNQirAHlA8vr/444XsTNITC1Il2l/Vx4w8hAWPpI5nQO78mVHNsmFuayETodzPwh25ob2TgfCEV/Loiog== + +"@playwright/test@^1.47": + version "1.47.2" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.47.2.tgz#dbe7051336bfc5cc599954214f9111181dbc7475" + integrity sha512-jTXRsoSPONAs8Za9QEQdyjFn+0ZQFjCiIztAIF6bi1HqhBzG9Ma7g1WotyiGqFSBRZjIEqMdT8RUlbk1QVhzCQ== dependencies: - playwright "1.42.1" + playwright "1.47.2" "@types/node@^20.11.30": version "20.11.30" @@ -21,17 +26,17 @@ fsevents@2.3.2: resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== -playwright-core@1.42.1: - version "1.42.1" - resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.42.1.tgz#13c150b93c940a3280ab1d3fbc945bc855c9459e" - integrity sha512-mxz6zclokgrke9p1vtdy/COWBH+eOZgYUVVU34C73M+4j4HLlQJHtfcqiqqxpP0o8HhMkflvfbquLX5dg6wlfA== +playwright-core@1.47.2: + version "1.47.2" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.47.2.tgz#7858da9377fa32a08be46ba47d7523dbd9460a4e" + integrity sha512-3JvMfF+9LJfe16l7AbSmU555PaTl2tPyQsVInqm3id16pdDfvZ8TTZ/pyzmkbDrZTQefyzU7AIHlZqQnxpqHVQ== -playwright@1.42.1: - version "1.42.1" - resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.42.1.tgz#79c828b51fe3830211137550542426111dc8239f" - integrity sha512-PgwB03s2DZBcNRoW+1w9E+VkLBxweib6KTXM0M3tkiT4jVxKSi6PmVJ591J+0u10LUrgxB7dLRbiJqO5s2QPMg== +playwright@1.47.2: + version "1.47.2" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.47.2.tgz#155688aa06491ee21fb3e7555b748b525f86eb20" + integrity sha512-nx1cLMmQWqmA3UsnjaaokyoUpdVaaDhJhMoxX2qj3McpjnsqFHs516QAKYhqHAgOP+oCFTEOCOAaD1RgD/RQfA== dependencies: - playwright-core "1.42.1" + playwright-core "1.47.2" optionalDependencies: fsevents "2.3.2"