mirror of https://github.com/zulip/zulip.git
types: Migrated add_stream_options_popover to TypeScript.
The migration requires some new assert statements as well as a change in how the `return undefined` case is spelled to match the types declared by Tippy upstream.
This commit is contained in:
parent
45cfa42469
commit
20e44997e2
|
@ -46,7 +46,7 @@ EXEMPT_FILES = make_set(
|
|||
[
|
||||
"web/shared/src/poll_data.ts",
|
||||
"web/src/about_zulip.ts",
|
||||
"web/src/add_stream_options_popover.js",
|
||||
"web/src/add_stream_options_popover.ts",
|
||||
"web/src/add_subscribers_pill.js",
|
||||
"web/src/admin.js",
|
||||
"web/src/alert_popup.ts",
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import $ from "jquery";
|
||||
import assert from "minimalistic-assert";
|
||||
import type {ReferenceElement} from "tippy.js";
|
||||
|
||||
import render_left_sidebar_stream_setting_popover from "../templates/popovers/left_sidebar_stream_setting_popover.hbs";
|
||||
|
||||
|
@ -6,7 +8,7 @@ import * as popover_menus from "./popover_menus";
|
|||
import * as settings_data from "./settings_data";
|
||||
import {parse_html} from "./ui_util";
|
||||
|
||||
export function initialize() {
|
||||
export function initialize(): void {
|
||||
popover_menus.register_popover_menu("#streams_inline_icon", {
|
||||
onShow(instance) {
|
||||
const can_create_streams =
|
||||
|
@ -31,32 +33,41 @@ export function initialize() {
|
|||
// When showing the popover menu, we want the
|
||||
// "Add streams" and the "Filter streams" tooltip
|
||||
// to appear below the "Add streams" icon.
|
||||
const add_streams_tooltip = $("#add_streams_tooltip").get(0);
|
||||
const add_streams_tooltip: ReferenceElement | undefined =
|
||||
$("#add_streams_tooltip").get(0);
|
||||
assert(add_streams_tooltip !== undefined);
|
||||
add_streams_tooltip._tippy?.setProps({
|
||||
placement: "bottom",
|
||||
});
|
||||
const filter_streams_tooltip = $("#filter_streams_tooltip").get(0);
|
||||
|
||||
const filter_streams_tooltip: (ReferenceElement & HTMLElement) | undefined =
|
||||
$("#filter_streams_tooltip").get(0);
|
||||
// If `filter_streams_tooltip` is not triggered yet, this will set its initial placement.
|
||||
assert(filter_streams_tooltip !== undefined);
|
||||
filter_streams_tooltip.dataset.tippyPlacement = "bottom";
|
||||
filter_streams_tooltip._tippy?.setProps({
|
||||
placement: "bottom",
|
||||
});
|
||||
|
||||
// The linter complains about unbalanced returns
|
||||
return true;
|
||||
return undefined;
|
||||
},
|
||||
onHidden(instance) {
|
||||
instance.destroy();
|
||||
popover_menus.popover_instances.stream_settings = undefined;
|
||||
popover_menus.popover_instances.stream_settings = null;
|
||||
// After the popover menu is closed, we want the
|
||||
// "Add streams" and the "Filter streams" tooltip
|
||||
// to appear at it's original position that is
|
||||
// above the "Add streams" icon.
|
||||
const add_streams_tooltip = $("#add_streams_tooltip").get(0);
|
||||
const add_streams_tooltip: ReferenceElement | undefined =
|
||||
$("#add_streams_tooltip").get(0);
|
||||
assert(add_streams_tooltip !== undefined);
|
||||
add_streams_tooltip._tippy?.setProps({
|
||||
placement: "top",
|
||||
});
|
||||
const filter_streams_tooltip = $("#filter_streams_tooltip").get(0);
|
||||
|
||||
const filter_streams_tooltip: (ReferenceElement & HTMLElement) | undefined =
|
||||
$("#filter_streams_tooltip").get(0);
|
||||
assert(filter_streams_tooltip !== undefined);
|
||||
filter_streams_tooltip.dataset.tippyPlacement = "top";
|
||||
filter_streams_tooltip._tippy?.setProps({
|
||||
placement: "top",
|
Loading…
Reference in New Issue