From 7629d34d4cd527bb0b30b3c0f40df6dec086ca8f Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Mar 2026 13:31:19 -0800 Subject: [PATCH 1/2] replace action_bar hot keys with Stimulus --- app/javascript/controllers/index.ts | 3 + .../mark_all_as_read_controller.ts | 15 +++++ .../feeds/_single_feed_action_bar.html.erb | 32 ++--------- app/views/stories/_action_bar.html.erb | 39 ++----------- .../stories/_mark_all_as_read_form.html.erb | 2 +- app/views/stories/archived.html.erb | 28 +--------- app/views/stories/starred.html.erb | 28 +--------- .../mark_all_as_read_controller_spec.ts | 56 +++++++++++++++++++ 8 files changed, 90 insertions(+), 113 deletions(-) create mode 100644 app/javascript/controllers/mark_all_as_read_controller.ts create mode 100644 spec/javascript/controllers/mark_all_as_read_controller_spec.ts diff --git a/app/javascript/controllers/index.ts b/app/javascript/controllers/index.ts index 103dfcfdb..806d7496a 100644 --- a/app/javascript/controllers/index.ts +++ b/app/javascript/controllers/index.ts @@ -15,5 +15,8 @@ application.register("hotkeys", HotkeysController); import KeepUnreadToggleController from "./keep_unread_toggle_controller"; application.register("keep-unread-toggle", KeepUnreadToggleController); +import MarkAllAsReadController from "./mark_all_as_read_controller"; +application.register("mark-all-as-read", MarkAllAsReadController); + import StarToggleController from "./star_toggle_controller"; application.register("star-toggle", StarToggleController); diff --git a/app/javascript/controllers/mark_all_as_read_controller.ts b/app/javascript/controllers/mark_all_as_read_controller.ts new file mode 100644 index 000000000..d237103fd --- /dev/null +++ b/app/javascript/controllers/mark_all_as_read_controller.ts @@ -0,0 +1,15 @@ +import {Controller} from "@hotwired/stimulus"; + +import {assert} from "helpers/assert"; + +export default class extends Controller { + static override targets = ["form"]; + + formTarget!: HTMLFormElement; + + submit(event: Event): void { + event.preventDefault(); + + assert(this.formTarget).requestSubmit(); + } +} diff --git a/app/views/feeds/_single_feed_action_bar.html.erb b/app/views/feeds/_single_feed_action_bar.html.erb index 7b4e17730..ee0bd0ac1 100644 --- a/app/views/feeds/_single_feed_action_bar.html.erb +++ b/app/views/feeds/_single_feed_action_bar.html.erb @@ -1,13 +1,13 @@ -
+
- - diff --git a/app/views/stories/_action_bar.html.erb b/app/views/stories/_action_bar.html.erb index adde91546..87ad929d2 100644 --- a/app/views/stories/_action_bar.html.erb +++ b/app/views/stories/_action_bar.html.erb @@ -1,10 +1,10 @@ -