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.

subs: Trigger stream-creation UI for users permitted to create stream.

aryanshridhar9575f88f2239
diff --git a/static/js/subs.js b/static/js/subs.js
index 8d26cf5352f..062339c0749 100644
--- a/static/js/subs.js
+++ b/static/js/subs.js
@@ -657,6 +657,27 @@ export function setup_page(callback) {
throttled_redraw_left_panel();
});
+ // When hitting Enter in the stream creation box, we open the
+ // "create stream" UI with the stream name prepopulated. This
+ // is only useful if the user has permission to create
+ // streams, either explicitly via user_can_create_streams, or
+ // implicitly because page_params.realm_is_zephyr_mirror_realm.
+ $("#stream_filter input[type='text']").on("keypress", (e) => {
+ if (e.which !== 13) {
+ return;
+ }
+
+ if (
+ settings_data.user_can_create_streams() ||
+ page_params.realm_is_zephyr_mirror_realm
+ ) {
+ open_create_stream();
+ e.preventDefault();
+ e.stopPropagation();
+ return;
+ }
+ });
+
$("#clear_search_stream_name").on("click", () => {
$("#stream_filter input[type='text']").val("");
redraw_left_panel();