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

The previous commit remove an obsolete form laying within
subscription_table_body.hbs. However, doing so broke the functionality
of triggering the stream-creation modal using the 'Enter' hotkey.

This commit re-introduces the functionality of loading the stream
creation modal only if the user has the permission to create streams.

At the same time, we make sure it's still possible to subscribe to
streams within zephyr mirroring organizations.
This commit is contained in:
aryanshridhar
2021-05-04 12:26:45 +05:30
committed by Tim Abbott
parent 472c845908
commit 9575f88f22

View File

@@ -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();