Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
keyboard: Add shortcut to open set status modal.
Rakshit Chauhan86d9626fe773
diff --git a/starlight_help/src/content/docs/keyboard-shortcuts.mdx b/starlight_help/src/content/docs/keyboard-shortcuts.mdxindex ed5587e9775..5b81a9da4f7 100644--- a/starlight_help/src/content/docs/keyboard-shortcuts.mdx+++ b/starlight_help/src/content/docs/keyboard-shortcuts.mdx@@ -48,6 +48,7 @@ reference in the Zulip app to add more to your repertoire as needed.* **Next unread followed topic**: <kbd>Shift</kbd> + <kbd>N</kbd>* **Next unread direct message**: <kbd>P</kbd>* **Search messages**: <kbd>/</kbd>+* **Set status**: <kbd>Shift</kbd> + <kbd>Y</kbd>* **Toggle keyboard shortcuts view**: <kbd>?</kbd>* **Go to your home view**: <kbd data-mac-key="Ctrl">Ctrl</kbd> + <kbd>\[</kbd>(or <kbd>Esc</kbd>, [if enabled][disable-escape])diff --git a/web/src/hotkey.ts b/web/src/hotkey.tsindex 93e39567b47..17c419516c4 100644--- a/web/src/hotkey.ts+++ b/web/src/hotkey.ts@@ -68,6 +68,7 @@ import * as unread_ops from "./unread_ops.ts";import * as user_card_popover from "./user_card_popover.ts";import * as user_group_popover from "./user_group_popover.ts";import {user_settings} from "./user_settings.ts";+import * as user_status_ui from "./user_status_ui.ts";import * as user_topics_ui from "./user_topics_ui.ts";import * as util from "./util.ts";@@ -167,6 +168,7 @@ const KEYDOWN_MAPPINGS: Record<string, Hotkey | Hotkey[]> = {{name: "view_selected_stream", message_view_only: false},{name: "toggle_read_receipts", message_view_only: true},],+ "Shift+Y": {name: "set_status", message_view_only: false},"Shift+Tab": {name: "shift_tab", message_view_only: false},"Shift+ ": {name: "shift_spacebar", message_view_only: true},"Shift+ArrowLeft": {name: "left_arrow", message_view_only: false},@@ -1178,6 +1180,12 @@ function process_hotkey(e: JQuery.KeyDownEvent, hotkey: Hotkey): boolean {case "gear_menu":gear_menu.toggle();return true;+ case "set_status":+ if (page_params.is_spectator) {+ return false;+ }+ user_status_ui.open_user_status_modal();+ return true;case "show_shortcuts": // Show keyboard shortcuts pagebrowser_history.go_to_location("keyboard-shortcuts");return true;diff --git a/web/templates/keyboard_shortcuts.hbs b/web/templates/keyboard_shortcuts.hbsindex 48587990771..269aea7b742 100644--- a/web/templates/keyboard_shortcuts.hbs+++ b/web/templates/keyboard_shortcuts.hbs@@ -100,6 +100,10 @@</span></td></tr>+ <tr>+ <td class="definition">{{t 'Set status' }}</td>+ <td><span class="hotkey"><kbd>Shift</kbd> + <kbd>Y</kbd></span></td>+ </tr><tr><td class="definition">{{t 'Show keyboard shortcuts' }}</td><td><span class="hotkey"><kbd>?</kbd></span></td>diff --git a/web/tests/hotkey.test.cjs b/web/tests/hotkey.test.cjsindex d3ed10cfa43..5a95916eb61 100644--- a/web/tests/hotkey.test.cjs+++ b/web/tests/hotkey.test.cjs@@ -90,6 +90,7 @@ const settings_data = mock_esm("../src/settings_data");const sidebar_ui = mock_esm("../src/sidebar_ui");const stream_popover = mock_esm("../src/stream_popover");const stream_settings_ui = mock_esm("../src/stream_settings_ui");+const user_status_ui = mock_esm("../src/user_status_ui");mock_esm("../src/recent_view_ui", {is_in_focus: () => false,@@ -186,6 +187,7 @@ run_test("mappings", () => {map_down("V", true).map((item) => item.name),["view_selected_stream", "toggle_read_receipts"],);+ assert.equal(map_down("Y", true).name, "set_status");assert.equal(map_down("/").name, "search");assert.equal(map_down("j").name, "vim_down");@@ -269,6 +271,7 @@ run_test("mappings non-latin keyboard", () => {map_down("М", "KeyV", true).map((item) => item.name),["view_selected_stream", "toggle_read_receipts"],);+ assert.equal(map_down("Н", "KeyY", true).name, "set_status");assert.equal(map_down("о", "KeyJ").name, "vim_down");assert.equal(map_down("х", "BracketLeft", false, true).name, "escape");assert.equal(map_down("с", "KeyC", false, true).name, "copy_with_c");@@ -362,7 +365,7 @@ run_test("unmapped keys return false easily", () => {// calling any functions outside of hotkey.ts.// (unless we are editing text)assert_unmapped("bfo");- assert_unmapped("BEFLOQTWXYZ");+ assert_unmapped("BEFLOQTWXZ");});run_test("allow normal typing when editing text", ({override, override_rewire}) => {@@ -415,6 +418,7 @@ test_while_not_editing_text("basic mappings", () => {assert_mapping("x", compose_actions, "start");assert_mapping("P", message_view, "show", true);assert_mapping("g", gear_menu, "toggle");+ assert_mapping("Y", user_status_ui, "open_user_status_modal", true);});test_while_not_editing_text("drafts open", ({override}) => {