navbar: Add navigate to home view tooltip to the organization logo.

The organization logo in the upper left navigates to the user's home
view. We add a tooltip to make this easier to discover.

We show `Esc` as the keyboard shortcut here, unless the user has
disabled it, in which case we show the alt shortcut `Ctrl` + `[`.

Fixes #29185.
This commit is contained in:
Sayam Samal 2024-03-07 00:36:30 +05:30 committed by Tim Abbott
parent 5e18bd762f
commit 70013d0f28
3 changed files with 27 additions and 1 deletions

View File

@ -3,11 +3,13 @@ import assert from "minimalistic-assert";
import tippy, {delegate} from "tippy.js"; import tippy, {delegate} from "tippy.js";
import render_buddy_list_title_tooltip from "../templates/buddy_list/title_tooltip.hbs"; import render_buddy_list_title_tooltip from "../templates/buddy_list/title_tooltip.hbs";
import render_org_logo_tooltip from "../templates/org_logo_tooltip.hbs";
import render_tooltip_templates from "../templates/tooltip_templates.hbs"; import render_tooltip_templates from "../templates/tooltip_templates.hbs";
import {$t} from "./i18n"; import {$t} from "./i18n";
import * as people from "./people"; import * as people from "./people";
import * as popovers from "./popovers"; import * as popovers from "./popovers";
import * as settings_config from "./settings_config";
import * as ui_util from "./ui_util"; import * as ui_util from "./ui_util";
import {user_settings} from "./user_settings"; import {user_settings} from "./user_settings";
@ -575,4 +577,20 @@ export function initialize(): void {
); );
}, },
}); });
delegate("body", {
target: "#realm-logo",
placement: "right",
appendTo: () => document.body,
onShow(instance) {
const escape_navigates_to_home_view = user_settings.web_escape_navigates_to_home_view;
const home_view =
settings_config.web_home_view_values[user_settings.web_home_view].description;
instance.setContent(
ui_util.parse_html(
render_org_logo_tooltip({home_view, escape_navigates_to_home_view}),
),
);
},
});
} }

View File

@ -26,7 +26,7 @@ export type UserSettings = (StreamNotificationSettings &
FollowedTopicNotificationSettings) & { FollowedTopicNotificationSettings) & {
color_scheme: number; color_scheme: number;
default_language: string; default_language: string;
web_home_view: string; web_home_view: "inbox" | "recent_topics" | "all_messages";
desktop_icon_count_display: number; desktop_icon_count_display: number;
demote_inactive_streams: number; demote_inactive_streams: number;
dense_mode: boolean; dense_mode: boolean;

View File

@ -0,0 +1,8 @@
<div>
<div>{{t "Go to home view"}} ({{home_view}})</div>
</div>
{{#if escape_navigates_to_home_view}}
{{tooltip_hotkey_hints "Esc"}}
{{else}}
{{tooltip_hotkey_hints "Ctrl" "["}}
{{/if}}