Skip to content

Commit

Permalink
Add Turbo Drive enabled status to the info tab
Browse files Browse the repository at this point in the history
  • Loading branch information
leonvogt committed Jun 3, 2024
1 parent 2fcc5c9 commit 6db393f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
25 changes: 20 additions & 5 deletions src/components/detail_panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,29 @@ export default class DetailPanel {
<span>Turbo Frames:</span>
<span>${document.querySelectorAll("turbo-frame").length}</span>
</div>
${
typeof this.devTool.turboDetails.turboDriveEnabled === "boolean"
? `
<div class="info-tab-content-wrapper" title="Checks 'window.Turbo.session.drive' to see if Turbo Drive is enabled">
<span>Turbo Drive:</span>
<span>${this.devTool.turboDetails.turboDriveEnabled ? "On" : "Off"}</span>
</div>
`
: `
<div class="info-tab-content-wrapper" title="Checks 'window.Turbo.session.drive' to see if Turbo Drive is enabled">
<span>Turbo Drive:</span>
<span>-</span>
</div>
`
}
${
getMetaContent("turbo-prefetch") === "false"
? `
<div class="info-tab-content-wrapper">
<span>Link Prefetch:</span>
<span>Off</span>
</div>
`
<div class="info-tab-content-wrapper" title="Checks the meta tag 'turbo-prefetch' to see if Link Prefetch is enabled">
<span>Link Prefetch:</span>
<span>Off</span>
</div>
`
: ""
}
<div class="info-tab-content-wrapper" title="Defines how Turbo handles page refreshes. Meta Tag: turbo-refresh-method">
Expand Down
2 changes: 1 addition & 1 deletion src/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const injectedScriptMessageHandler = (event) => {
}
break
case "turboDetails":
detailPanel.turboDetails = event.data.details
devTool.turboDetails = event.data.details
renderDetailPanel()
break
}
Expand Down
2 changes: 2 additions & 0 deletions src/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ const events = ["DOMContentLoaded", "turbolinks:load", "turbo:load", "turbo:fram
events.forEach((event) => {
document.addEventListener(event, sendWindowDetails)
})

sendWindowDetails()

0 comments on commit 6db393f

Please sign in to comment.