Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = ["modal"]

connect() {
// Handle trailing slashes or query params safely
if (!window.location.pathname.startsWith("/docs/editors/godot")) return

const key = this.storageKey()
const dismissed = window.localStorage.getItem(key)

if (!dismissed) this.open()
}

open() {
this.modalTarget.classList.remove("hidden")
document.documentElement.classList.add("overflow-hidden")
}

dismiss() {
window.localStorage.setItem(this.storageKey(), "1")
this.modalTarget.classList.add("hidden")
document.documentElement.classList.remove("overflow-hidden")
}

storageKey() {
// bump this if you ever need to force-show again
return "hackatime_godot_wakatime_upgrade_warning_v1_dismissed"
}
}
41 changes: 41 additions & 0 deletions app/javascript/controllers/sitewide_notice_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = ["modal", "banner"]

connect() {
// Banner in case we ever want to use it
// if (this.hasBannerTarget) {
// this.bannerTarget.classList.remove("hidden")
// }

// side-wide noti scooter use it if ya want
// if (!this.modalDismissed()) {
// this.openModal()
// }
}
Comment on lines +6 to +16
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The sitewide_notice_controller.js has an empty connect() method, which prevents the sitewide notice modal from ever being displayed, rendering the feature non-functional.
Severity: HIGH | Confidence: High

🔍 Detailed Analysis

The connect() method in sitewide_notice_controller.js is empty, with its logic commented out. As this method is the entry point for Stimulus controllers, the sitewide notice modal and banner will never be displayed to users. The controller is correctly attached to the DOM via the _sitewide_notice.html.erb partial on every page, but because the initialization logic in connect() is disabled, the modal remains hidden indefinitely. This renders the entire sitewide notice feature non-functional, despite all the supporting HTML and controller methods being in place.

💡 Suggested Fix

To re-enable the sitewide notice feature, uncomment the logic within the connect() method in sitewide_notice_controller.js. This will allow the controller to check if the modal has been dismissed and call openModal() on page load. If the intention was to permanently remove the feature, the controller and the corresponding partial rendering in the application layout should be removed entirely.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: app/javascript/controllers/sitewide_notice_controller.js#L6-L16

Potential issue: The `connect()` method in `sitewide_notice_controller.js` is empty,
with its logic commented out. As this method is the entry point for Stimulus
controllers, the sitewide notice modal and banner will never be displayed to users. The
controller is correctly attached to the DOM via the `_sitewide_notice.html.erb` partial
on every page, but because the initialization logic in `connect()` is disabled, the
modal remains hidden indefinitely. This renders the entire sitewide notice feature
non-functional, despite all the supporting HTML and controller methods being in place.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 7509002


openModal() {
this.modalTarget.classList.remove("hidden")
document.documentElement.classList.add("overflow-hidden")
}

dismissModal() {
window.localStorage.setItem(this.modalKey(), "1")
this.modalTarget.classList.add("hidden")
document.documentElement.classList.remove("overflow-hidden")
}

// Banner dismissa;
dismissBanner() {
this.bannerTarget.classList.add("hidden")
}

modalDismissed() {
return window.localStorage.getItem(this.modalKey()) === "1"
}

modalKey() {
return "hackatime_sitewide_required_update_modal_v1"
}
}
27 changes: 27 additions & 0 deletions app/views/docs/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,32 @@
<% end %>
<% end %>
</nav>

<%# Godot-only: separate alert box above the docs card %>
<% if request.path.start_with?("/docs/editors/godot") %>
<div class="mb-6 not-prose rounded-2xl border border-red-500/40 bg-red-500/10 p-5">
<div class="text-sm font-semibold uppercase tracking-wide text-red-200">
Important: Required Godot plugin update (mandatory)
</div>

<div class="mt-2 text-zinc-100">
You must install or upgrade to the newest version of <strong>Godot Super WakaTime</strong> from:
<a class="underline break-all" href="https://github.com/BudzioT/Godot_Super-Wakatime" target="_blank" rel="noreferrer">
https://github.com/BudzioT/Godot_Super-Wakatime
</a>
</div>

<div class="mt-3 text-zinc-100">
<strong>Effective January 1, 2026</strong>, any Hackatime project that uses the old Godot time-tracking
plugin/extension will be <strong>immediately rejected</strong>.
</div>

<div class="mt-3 text-zinc-100">
If you installed this plugin before, you still need to update. Do not assume you are on the newest version.
</div>
</div>
<% end %>

<div class="bg-dark rounded-lg p-8 mb-8 prose prose-invert prose-lg max-w-none
prose-headings:text-primary prose-headings:font-bold prose-headings:leading-tight
prose-h1:text-4xl prose-h1:mb-6 prose-h1:text-primary prose-h1:mt-0
Expand Down Expand Up @@ -105,6 +131,7 @@
[&_.editor-steps_li]:mb-2">
<%= raw @rendered_content %>
</div>

<div class="text-center bg-darkless rounded-lg p-6">
<p class="text-secondary">
Found an issue with this page?
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,6 @@
method: "delete"
}
] %>
<%= render "shared/sitewide_notice" %>
</body>
</html>
88 changes: 88 additions & 0 deletions app/views/shared/_sitewide_notice.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<div data-controller="sitewide-notice" class="not-prose">
<!-- Top banner (dismissible, can persist even after modal is dismissed) -->
<div
data-sitewide-notice-target="banner"
class="hidden fixed top-0 left-0 right-0 z-[9998]"
>
<div class="mx-auto max-w-6xl px-4 pt-4">
<div class="rounded-2xl border border-red-500/40 bg-red-500/10 px-4 py-3 shadow-lg">
<div class="flex items-start justify-between gap-4">
<div class="text-sm text-zinc-100">
<span class="font-semibold uppercase tracking-wide text-red-200">Required update (mandatory):</span>
All users must install the newest version of <span class="font-semibold">Godot Super WakaTime</span>:
<a class="underline break-all" href="https://github.com/BudzioT/Godot_Super-Wakatime" target="_blank" rel="noreferrer">
https://github.com/BudzioT/Godot_Super-Wakatime
</a>
<span class="block mt-1">
Effective <span class="font-semibold">January 1, 2026</span>, any Hackatime project using the old Godot time-tracking plugin/extension will be
<span class="font-semibold">immediately rejected</span>.
</span>
</div>

<button
type="button"
class="shrink-0 rounded-lg bg-zinc-900/60 px-3 py-2 text-xs font-semibold text-white hover:bg-zinc-900"
data-action="sitewide-notice#dismissBanner"
aria-label="Dismiss notice banner"
>
Dismiss
</button>
</div>
</div>
</div>
</div>

<!-- Modal popup (one-time, centered, not clipped) -->
<div
data-sitewide-notice-target="modal"
class="hidden fixed inset-0 z-[9999] flex items-center justify-center p-4"
aria-modal="true"
role="dialog"
>
<!-- Backdrop -->
<div class="absolute inset-0 bg-black/70"></div>

<!-- Modal panel -->
<div class="relative w-full max-w-2xl rounded-2xl bg-darkless p-6 shadow-2xl border border-red-500/30">
<h2 class="text-xl font-semibold text-white">
REQUIRED UPDATE (MANDATORY)
</h2>

<p class="mt-3 text-zinc-200">
You must install or upgrade to the newest version of <strong>Godot Super WakaTime</strong>:
<br />
<a class="underline break-all" href="https://github.com/BudzioT/Godot_Super-Wakatime" target="_blank" rel="noreferrer">
https://github.com/BudzioT/Godot_Super-Wakatime
</a>
</p>

<p class="mt-3 text-zinc-200">
<strong>Effective January 1, 2026</strong>, any Hackatime project that uses the old Godot time-tracking
plugin/extension will be <strong>immediately rejected</strong>.
</p>

<p class="mt-3 text-zinc-200">
If you installed this plugin before, you still need to update. Do not assume you are on the newest version.
</p>

<div class="mt-6 flex flex-wrap items-center justify-end gap-3">
<a
class="rounded-lg bg-white px-4 py-2 text-sm font-semibold text-black"
href="https://github.com/BudzioT/Godot_Super-Wakatime"
target="_blank"
rel="noreferrer"
>
Get the newest version
</a>

<button
type="button"
class="rounded-lg bg-zinc-800 px-4 py-2 text-sm font-semibold text-white hover:bg-zinc-700"
data-action="sitewide-notice#dismissModal"
>
I understand
</button>
</div>
</div>
</div>
</div>