Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

components: Let toggle label be optional.

evykassirer919cebe0f925
diff --git a/web/src/components.ts b/web/src/components.ts
index 677f539a967..f9cd36f828a 100644
--- a/web/src/components.ts
+++ b/web/src/components.ts
@@ -28,8 +28,10 @@ export type Toggle = {
export function toggle(opts: {
html_class?: string;
- values: {label: string; label_html?: string; key: string}[];
- callback?: (label: string, value: string) => void;
+ values: (({label: string; label_html?: never} | {label_html: string; label?: never}) & {
+ key: string;
+ })[];
+ callback?: (label: string | undefined, value: string) => void;
child_wants_focus?: boolean;
selected?: number;
}): Toggle {
@@ -50,7 +52,7 @@ export function toggle(opts: {
if (value.label_html !== undefined) {
const html = value.label_html;
$tab.html(html);
- } else {
+ } else if (value.label !== undefined) {
$tab.text(value.label);
}
diff --git a/web/src/info_overlay.ts b/web/src/info_overlay.ts
index 1f888457581..76d471458b8 100644
--- a/web/src/info_overlay.ts
+++ b/web/src/info_overlay.ts
@@ -298,7 +298,7 @@ export function set_up_toggler(): void {
{label: $t({defaultMessage: "Message formatting"}), key: "message-formatting"},
{label: $t({defaultMessage: "Search filters"}), key: "search-operators"},
],
- callback(_name: string, key: string) {
+ callback(_name: string | undefined, key: string) {
$(".overlay-modal").hide();
$(`#${CSS.escape(key)}`).show();
scroll_util
diff --git a/web/src/user_profile.ts b/web/src/user_profile.ts
index a4d520194e9..8aceee366f6 100644
--- a/web/src/user_profile.ts
+++ b/web/src/user_profile.ts
@@ -580,7 +580,7 @@ export function show_user_profile(user: User, default_tab_key = "profile-tab"):
{label: $t({defaultMessage: "Channels"}), key: "user-profile-streams-tab"},
{label: $t({defaultMessage: "User groups"}), key: "user-profile-groups-tab"},
],
- callback(_name: string, key: string) {
+ callback(_name: string | undefined, key: string) {
$(".tabcontent").hide();
$(`#${CSS.escape(key)}`).show();
$("#user-profile-modal .modal__footer").hide();