Skip to content

Commit

Permalink
Merge pull request #16275 from opf/chore/turbo-power
Browse files Browse the repository at this point in the history
Add turbo power so we can us its custom actions in turbo streams
  • Loading branch information
klaustopher authored Jul 29, 2024
2 parents 7b0d6c8 + 899ca0e commit a4470a3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ gem "factory_bot", "~> 6.4.0", require: false
# require factory_bot_rails for convenience in core development
gem "factory_bot_rails", "~> 6.4.0", require: false

gem "turbo_power", "~> 0.6.2"
gem "turbo-rails", "~> 2.0.0"

gem "httpx"
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,8 @@ GEM
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
turbo_power (0.6.2)
turbo-rails (>= 1.3.0)
typed_dag (2.0.2)
rails (>= 5.0.4)
tzinfo (2.0.6)
Expand Down Expand Up @@ -1347,6 +1349,7 @@ DEPENDENCIES
timecop (~> 0.9.0)
ttfunk (~> 1.7.0)
turbo-rails (~> 2.0.0)
turbo_power (~> 0.6.2)
turbo_tests!
typed_dag (~> 2.0.2)
tzinfo-data (~> 1.2024.1)
Expand Down
15 changes: 15 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"tablesorter": "^2.31.3",
"ts-action": "^11.0.0",
"ts-action-operators": "^9.1.2",
"turbo_power": "^0.6.2",
"typedjson": "^1.5.1",
"urijs": "^1.19.11",
"uuid": "^8.3.2",
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/turbo/setup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import '../typings/shims.d.ts';
import * as Turbo from '@hotwired/turbo';
import TurboPower from 'turbo_power';
import { registerDialogStreamAction } from './dialog-stream-action';
import { addTurboEventListeners } from './turbo-event-listeners';

Expand All @@ -8,9 +9,13 @@ Turbo.session.drive = false;
// Start turbo
Turbo.start();

// Register our own actions
addTurboEventListeners();
registerDialogStreamAction();

// Register turbo power actions
TurboPower.initialize(Turbo.StreamActions);

// Error handling when "Content missing" returned
document.addEventListener('turbo:frame-missing', (event:CustomEvent) => {
const { detail: { response, visit } } = event as { detail:{ response:Response, visit:(url:string) => void } };
Expand Down

0 comments on commit a4470a3

Please sign in to comment.