js: Convert static/js/stream_create.js to ES6 module.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-10 07:55:52 -08:00 committed by Tim Abbott
parent 9dd03998f8
commit 03f61c1eb2
5 changed files with 22 additions and 28 deletions

View File

@ -263,7 +263,6 @@
"spoilers": false,
"starred_messages": false,
"stream_color": false,
"stream_create": false,
"stream_data": false,
"stream_edit": false,
"stream_events": false,

View File

@ -69,7 +69,6 @@ import "../stream_data";
import "../stream_topic_history";
import "../stream_muting";
import "../stream_events";
import "../stream_create";
import "../stream_edit";
import "../subs";
import "../message_edit";

View File

@ -130,7 +130,6 @@ declare let settings_user_groups: any;
declare let settings_users: any;
declare let starred_messages: any;
declare let stream_color: any;
declare let stream_create: any;
declare let stream_data: any;
declare let stream_edit: any;
declare let stream_events: any;

View File

@ -1,25 +1,23 @@
"use strict";
import render_announce_stream_docs from "../templates/announce_stream_docs.hbs";
import render_new_stream_users from "../templates/new_stream_users.hbs";
import render_subscription_invites_warning_modal from "../templates/subscription_invites_warning_modal.hbs";
const render_announce_stream_docs = require("../templates/announce_stream_docs.hbs");
const render_new_stream_users = require("../templates/new_stream_users.hbs");
const render_subscription_invites_warning_modal = require("../templates/subscription_invites_warning_modal.hbs");
const peer_data = require("./peer_data");
const people = require("./people");
import * as peer_data from "./peer_data";
import * as people from "./people";
let created_stream;
exports.reset_created_stream = function () {
export function reset_created_stream() {
created_stream = undefined;
};
}
exports.set_name = function (stream) {
export function set_name(stream) {
created_stream = stream;
};
}
exports.get_name = function () {
export function get_name() {
return created_stream;
};
}
class StreamSubscriptionError {
report_no_subs_to_stream() {
@ -234,7 +232,7 @@ function create_stream() {
});
}
exports.new_stream_clicked = function (stream_name) {
export function new_stream_clicked(stream_name) {
// this changes the tab switcher (settings/preview) which isn't necessary
// to a add new stream title.
subs.show_subs_pane.create_stream();
@ -243,9 +241,9 @@ exports.new_stream_clicked = function (stream_name) {
if (stream_name !== "") {
$("#create_stream_name").val(stream_name);
}
exports.show_new_stream_modal();
show_new_stream_modal();
$("#create_stream_name").trigger("focus");
};
}
function clear_error_display() {
stream_name_error.clear_errors();
@ -253,7 +251,7 @@ function clear_error_display() {
stream_subscription_error.clear_errors();
}
exports.show_new_stream_modal = function () {
export function show_new_stream_modal() {
$("#stream-creation").removeClass("hide");
$(".right .settings").hide();
@ -270,7 +268,7 @@ exports.show_new_stream_modal = function () {
const container = $("#people_to_add");
container.html(html);
exports.create_handlers_for_users(container);
create_handlers_for_users(container);
// Make the options default to the same each time:
// public, "announce stream" on.
@ -304,9 +302,9 @@ exports.show_new_stream_modal = function () {
e.preventDefault();
});
};
}
exports.create_handlers_for_users = function (container) {
export function create_handlers_for_users(container) {
// container should be $('#people_to_add')...see caller to verify
container.on("change", "#user-checkboxes input", update_announce_stream_state);
@ -380,9 +378,9 @@ exports.create_handlers_for_users = function (container) {
e.preventDefault();
});
};
}
exports.set_up_handlers = function () {
export function set_up_handlers() {
const container = $("#stream-creation").expectOne();
container.on("change", "#make-invite-only input", update_announce_stream_state);
@ -466,6 +464,4 @@ exports.set_up_handlers = function () {
e.preventDefault();
}
});
};
window.stream_create = exports;
}

View File

@ -10,6 +10,7 @@ const render_subscriptions = require("../templates/subscriptions.hbs");
const components = require("./components");
const people = require("./people");
const search_util = require("./search_util");
const stream_create = require("./stream_create");
const util = require("./util");
exports.show_subs_pane = {