mirror of https://github.com/zulip/zulip.git
components: Let toggle label be optional.
`stream_settings_ui` has only `label_html` and no `label`, so we need fix this type to be able to convert that module to typescript.
This commit is contained in:
parent
dc0e82deef
commit
919cebe0f9
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue