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
This commit is contained in:
Evy Kassirer
2025-06-29 22:07:38 -07:00
committed by Tim Abbott
parent 072343a101
commit 25cebcd119
2 changed files with 18 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import * as tippy from "tippy.js";
import * as drafts from "./drafts.ts"; import * as drafts from "./drafts.ts";
import {$t} from "./i18n.ts"; import {$t} from "./i18n.ts";
import * as scheduled_messages from "./scheduled_messages.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 * as starred_messages from "./starred_messages.ts";
import { import {
EXTRA_LONG_HOVER_DELAY, EXTRA_LONG_HOVER_DELAY,
@@ -136,11 +137,22 @@ export function initialize(): void {
}); });
tippy.delegate("body", { tippy.delegate("body", {
target: [ target: ["#streams_header .streams-tooltip-target", "#filter_streams_tooltip"].join(","),
"#streams_header .streams-tooltip-target", appendTo: () => document.body,
"#add_streams_tooltip", });
"#filter_streams_tooltip",
].join(","), 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, appendTo: () => document.body,
}); });

View File

@@ -190,7 +190,7 @@
<h4 class="left-sidebar-title"><span class="streams-tooltip-target" data-tooltip-template-id="filter-streams-tooltip-template">{{t 'CHANNELS' }}</span></h4> <h4 class="left-sidebar-title"><span class="streams-tooltip-target" data-tooltip-template-id="filter-streams-tooltip-template">{{t 'CHANNELS' }}</span></h4>
<div class="left-sidebar-controls"> <div class="left-sidebar-controls">
<i id="filter_streams_tooltip" class="streams_filter_icon zulip-icon zulip-icon-search" aria-hidden="true" data-tooltip-template-id="filter-streams-tooltip-template"></i> <i id="filter_streams_tooltip" class="streams_filter_icon zulip-icon zulip-icon-search" aria-hidden="true" data-tooltip-template-id="filter-streams-tooltip-template"></i>
<span id="add_streams_tooltip" class="hidden-for-spectators" data-tippy-content="{{t 'Add channels' }}"> <span id="add_streams_tooltip" class="hidden-for-spectators">
<i id="streams_inline_icon" class="zulip-icon zulip-icon-square-plus" aria-hidden="true" ></i> <i id="streams_inline_icon" class="zulip-icon zulip-icon-square-plus" aria-hidden="true" ></i>
</span> </span>
</div> </div>