Skip to content

Commit

Permalink
Drop peer-dependency & re-support older Turbo versions (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
OutlawAndy authored Dec 31, 2024
1 parent c99bcf1 commit ff78aeb
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Install Ruby and gems for dummy app
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3.5'
ruby-version: '3.3.6'
bundler-cache: true

- name: Setup dummy app
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{
"name": "@rolemodel/turbo-confirm",
"type": "module",
"version": "2.1.0",
"version": "2.1.1",
"description": "Drop-in upgrade for Rails' data-turbo-confirm feature to support custom HTML dialogs.",
"main": "src/index.js",
"peerDependencies": {
"@hotwired/turbo": ">= 8.0.6"
},
"directories": {
"lib": "src/lib"
},
Expand Down Expand Up @@ -36,7 +33,7 @@
},
"homepage": "https://github.com/RoleModel/turbo-confirm#readme",
"devDependencies": {
"@playwright/test": "^1.47",
"@playwright/test": "^1.49.1",
"@types/node": "^20.11.30"
}
}
8 changes: 7 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const start = (options) => {
if (!window.Turbo) throw TurboConfirmError.noTurbo()
const tc = new TurboConfirm(options)

window.Turbo.config.forms.confirm = async (message, formElement, submitter) => {
const confirmationHandler = async (message, formElement, submitter) => {
const response = await tc.confirm(message, formElement, submitter)

if (response) {
Expand All @@ -16,6 +16,12 @@ const start = (options) => {

return response
}

if (window.Turbo.config) {
window.Turbo.config.forms.confirm = confirmationHandler
} else {
window.Turbo.setConfirmMethod(confirmationHandler)
}
}

export default { start }
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/.ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.5
3.3.6
2 changes: 1 addition & 1 deletion test/dummy/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ DEPENDENCIES
web-console

RUBY VERSION
ruby 3.3.5p100
ruby 3.3.6p108

BUNDLED WITH
2.5.7
18 changes: 9 additions & 9 deletions test/dummy/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -501,17 +501,17 @@
integrity sha512-eGeIqNOQpXoPAIP7tC1+1Yc1yl1xnwYqg+3mzqxyrbE5pg5YFBZcA6YoTiByJB6DKAEsiWtl6tjTJS4IYtbB7A==

"@hotwired/turbo-rails@^8.0.4":
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==
version "8.0.12"
resolved "https://registry.yarnpkg.com/@hotwired/turbo-rails/-/turbo-rails-8.0.12.tgz#6f1a2661122c0a2bf717f3bc68b5106638798c89"
integrity sha512-ZXwu9ez+Gd4RQNeHIitqOQgi/LyqY8J4JqsUN0nnYiZDBRq7IreeFdMbz29VdJpIsmYqwooE4cFzPU7QvJkQkA==
dependencies:
"@hotwired/turbo" "^8.0.6"
"@hotwired/turbo" "^8.0.12"
"@rails/actioncable" "^7.0"

"@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==
"@hotwired/turbo@^8.0.12":
version "8.0.12"
resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-8.0.12.tgz#50aa8345d7f62402680c6d2d9814660761837001"
integrity sha512-l3BiQRkD7qrnQv6ms6sqPLczvwbQpXt5iAVwjDvX0iumrz6yEonQkNAzNjeDX25/OJMFDTxpHjkJZHGpM9ikWw==

"@jest/schemas@^29.6.3":
version "29.6.3"
Expand Down Expand Up @@ -585,7 +585,7 @@
modern-css-reset "^1.4.0"

"@rolemodel/turbo-confirm@link:../..":
version "2.1.0"
version "2.1.1"

"@sinclair/typebox@^0.27.8":
version "0.27.8"
Expand Down
5 changes: 5 additions & 0 deletions test/system/turbo.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ test.beforeAll(async ({ request }) => {
const response = await request.post('/todos/setup')
expect(response.ok()).toBeTruthy()
todos = await response.json()

expect(todos.length).toBe(3)
todos.forEach(todo => {
expect(Object.keys(todo)).toEqual(expect.arrayContaining(['id', 'title', 'body']))
})
})

test.afterAll(async ({ request }) => {
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# yarn lockfile v1


"@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==
"@playwright/test@^1.49.1":
version "1.49.1"
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.49.1.tgz#55fa360658b3187bfb6371e2f8a64f50ef80c827"
integrity sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g==
dependencies:
playwright "1.47.2"
playwright "1.49.1"

"@types/node@^20.11.30":
version "20.11.30"
Expand All @@ -21,17 +21,17 @@ [email protected]:
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==

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-core@1.49.1:
version "1.49.1"
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.49.1.tgz#32c62f046e950f586ff9e35ed490a424f2248015"
integrity sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg==

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==
playwright@1.49.1:
version "1.49.1"
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.49.1.tgz#830266dbca3008022afa7b4783565db9944ded7c"
integrity sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA==
dependencies:
playwright-core "1.47.2"
playwright-core "1.49.1"
optionalDependencies:
fsevents "2.3.2"

Expand Down

0 comments on commit ff78aeb

Please sign in to comment.