From 25cebcd1190b179df4bab536681524f5aec91de5 Mon Sep 17 00:00:00 2001 From: Evy Kassirer Date: Sun, 29 Jun 2025 22:07:38 -0700 Subject: [PATCH] left_sidebar: Don't show 'add channels' in tooltip if that's not allowed. Discussed here: https://chat.zulip.org/#narrow/channel/101-design/topic/channel.20folders.20in.20left.20sidebar.20.2331972/near/2202343 --- web/src/left_sidebar_tooltips.ts | 22 +++++++++++++++++----- web/templates/left_sidebar.hbs | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/web/src/left_sidebar_tooltips.ts b/web/src/left_sidebar_tooltips.ts index fed691d07d..30a72f2942 100644 --- a/web/src/left_sidebar_tooltips.ts +++ b/web/src/left_sidebar_tooltips.ts @@ -4,6 +4,7 @@ import * as tippy from "tippy.js"; import * as drafts from "./drafts.ts"; import {$t} from "./i18n.ts"; import * as scheduled_messages from "./scheduled_messages.ts"; +import * as settings_data from "./settings_data.ts"; import * as starred_messages from "./starred_messages.ts"; import { EXTRA_LONG_HOVER_DELAY, @@ -136,11 +137,22 @@ export function initialize(): void { }); tippy.delegate("body", { - target: [ - "#streams_header .streams-tooltip-target", - "#add_streams_tooltip", - "#filter_streams_tooltip", - ].join(","), + target: ["#streams_header .streams-tooltip-target", "#filter_streams_tooltip"].join(","), + appendTo: () => document.body, + }); + + tippy.delegate("body", { + target: "#add_streams_tooltip", + onShow(instance) { + const can_create_streams = + settings_data.user_can_create_private_streams() || + settings_data.user_can_create_public_streams() || + settings_data.user_can_create_web_public_streams(); + const tooltip_text = can_create_streams + ? $t({defaultMessage: "Add channels"}) + : $t({defaultMessage: "Browse channels"}); + instance.setContent(tooltip_text); + }, appendTo: () => document.body, }); diff --git a/web/templates/left_sidebar.hbs b/web/templates/left_sidebar.hbs index 0ca71eb318..5039a8d6d1 100644 --- a/web/templates/left_sidebar.hbs +++ b/web/templates/left_sidebar.hbs @@ -190,7 +190,7 @@