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.

stream_create: Restrict height of subscribers table.

Sahil Batrac0e84865413e
diff --git a/web/src/resize.ts b/web/src/resize.ts
index f3455c5c32d..9e602e2a591 100644
--- a/web/src/resize.ts
+++ b/web/src/resize.ts
@@ -226,6 +226,64 @@ export function resize_stream_subscribers_list(): void {
$(":root").css("--stream-subscriber-list-max-height", `${subscribers_list_height}px`);
}
+export function resize_stream_creation_subscribers_list(): void {
+ // Calculates the height of the subscribers list in stream creation form.
+ // This prevents the stream settings from overflowing the container and
+ // having a scroll bar.
+
+ if ($("#channels_overlay_container").find(".two-pane-settings-overlay.show").length === 0) {
+ // Don't run if stream settings overlay is not open.
+ return;
+ }
+
+ if ($("#stream_creation_form .subscribers_container").css("display") === "none") {
+ // Don't run if the subscribers section of the stream creation form is
+ // not open.
+ return;
+ }
+
+ const $container = $("#stream_creation_form .two-pane-settings-creation-simplebar-container");
+ const $choose_subscribers_title = $container.find(".new-stream-subscribers-title");
+ const $pill_input_container = $container.find(".subscriber_list_settings");
+ const $subscribers_list_header = $container.find(".create_stream_subscriber_list_header");
+
+ const elements_above_subscribers_list = [
+ $choose_subscribers_title,
+ $pill_input_container,
+ $subscribers_list_header,
+ ];
+
+ let total_height_of_elements_above_subscribers_list = 0;
+ for (const $elem of elements_above_subscribers_list) {
+ const outer_height = $elem.outerHeight(true) ?? 0;
+ total_height_of_elements_above_subscribers_list += outer_height;
+ }
+
+ const susbcribers_list_container_bottom_border_width = 1;
+ const stream_creation_body_padding = 15;
+ const stream_creation_section_bottom_margin = 20;
+
+ // The two elements whose height is being calculated below
+ // are error elements. If no error is shown, consider height
+ // as 0.
+ const stream_subscription_error_height = $("#stream_subscription_error").height() ?? 0;
+ const $stream_creation_error = $container.find(".stream_create_info");
+ const stream_creation_error_height =
+ $stream_creation_error.css("display") !== "none"
+ ? $stream_creation_error.outerHeight(true)!
+ : 0;
+
+ const subscribers_list_height =
+ $container.height()! -
+ total_height_of_elements_above_subscribers_list -
+ stream_creation_body_padding -
+ stream_creation_section_bottom_margin -
+ stream_subscription_error_height -
+ stream_creation_error_height -
+ susbcribers_list_container_bottom_border_width;
+ $(":root").css("--new-stream-subscriber-list-max-height", `${subscribers_list_height}px`);
+}
+
export function resize_stream_filters_container(): void {
resize_bottom_whitespace();
$("#left_sidebar_scroll_container").css("max-height", get_stream_filters_max_height());
@@ -367,4 +425,5 @@ export function resize_page_components(): void {
resize_settings_creation_overlay($("#groups_overlay_container"));
resize_settings_creation_overlay($("#channels_overlay_container"));
resize_stream_subscribers_list();
+ resize_stream_creation_subscribers_list();
}
diff --git a/web/src/stream_create.ts b/web/src/stream_create.ts
index bf08fbf1c6c..6a89eda7c22 100644
--- a/web/src/stream_create.ts
+++ b/web/src/stream_create.ts
@@ -12,6 +12,7 @@ import {$t, $t_html} from "./i18n.ts";
import * as keydown_util from "./keydown_util.ts";
import * as loading from "./loading.ts";
import * as onboarding_steps from "./onboarding_steps.ts";
+import * as resize from "./resize.ts";
import * as settings_components from "./settings_components.ts";
import * as settings_config from "./settings_config.ts";
import * as settings_data from "./settings_data.ts";
@@ -295,6 +296,7 @@ function create_stream(): void {
$t_html({defaultMessage: "The channel description cannot contain newline characters."}),
$(".stream_create_info"),
);
+ resize.resize_stream_creation_subscribers_list();
return;
}
const subscriptions = JSON.stringify([{name: stream_name, description}]);
@@ -434,6 +436,7 @@ function create_stream(): void {
xhr,
$(".stream_create_info"),
);
+ resize.resize_stream_creation_subscribers_list();
}
loading.destroy_indicator($("#stream_creating_indicator"));
},
@@ -463,6 +466,7 @@ function clear_error_display(): void {
stream_name_error.clear_errors();
$(".stream_create_info").hide();
stream_subscription_error.clear_errors();
+ resize.resize_stream_creation_subscribers_list();
}
export function show_new_stream_modal(): void {
diff --git a/web/src/stream_create_subscribers.ts b/web/src/stream_create_subscribers.ts
index 74c6359525a..2fabb20af4d 100644
--- a/web/src/stream_create_subscribers.ts
+++ b/web/src/stream_create_subscribers.ts
@@ -7,6 +7,7 @@ import * as add_subscribers_pill from "./add_subscribers_pill.ts";
import * as ListWidget from "./list_widget.ts";
import type {ListWidget as ListWidgetType} from "./list_widget.ts";
import * as people from "./people.ts";
+import * as resize from "./resize.ts";
import {current_user} from "./state_data.ts";
import * as stream_create_subscribers_data from "./stream_create_subscribers_data.ts";
import type {CombinedPillContainer} from "./typeahead_helper.ts";
@@ -53,18 +54,27 @@ function build_pill_widget({
const $pill_container = $parent_container.find(".pill-container");
const get_potential_subscribers = stream_create_subscribers_data.get_potential_subscribers;
const get_user_groups = user_groups.get_all_realm_user_groups;
+ const on_pill_create = (user_ids: number[]): void => {
+ add_user_ids(user_ids);
+ resize.resize_stream_creation_subscribers_list();
+ };
+ const on_pill_remove = (user_ids: number[]): void => {
+ sync_user_ids(user_ids);
+ resize.resize_stream_creation_subscribers_list();
+ };
+
return add_subscribers_pill.create({
$pill_container,
get_potential_subscribers,
get_user_groups,
with_add_button: false,
- onPillCreateAction: add_user_ids,
+ onPillCreateAction: on_pill_create,
// It is better to sync the current set of user ids in the input
// instead of removing user_ids from the user_ids_set, otherwise
// we'll have to have more complex logic of when to remove
// a user and when not to depending upon their group, channel
// and individual pills.
- onPillRemoveAction: sync_user_ids,
+ onPillRemoveAction: on_pill_remove,
});
}
diff --git a/web/src/stream_settings_components.ts b/web/src/stream_settings_components.ts
index ebb654f4eaf..149923438d7 100644
--- a/web/src/stream_settings_components.ts
+++ b/web/src/stream_settings_components.ts
@@ -127,6 +127,7 @@ export const show_subs_pane = {
$("#stream-creation").show();
resize.resize_settings_overlay($("#channels_overlay_container"));
resize.resize_settings_creation_overlay($("#channels_overlay_container"));
+ resize.resize_stream_creation_subscribers_list();
},
};
diff --git a/web/styles/app_variables.css b/web/styles/app_variables.css
index dfc3a64894f..adcbe0cd6e6 100644
--- a/web/styles/app_variables.css
+++ b/web/styles/app_variables.css
@@ -693,7 +693,7 @@
This value will be overridden when stream settings is opened.
*/
--stream-subscriber-list-max-height: 100%;
-
+ --new-stream-subscriber-list-max-height: 100%;
/*
Reusable dimensions and offsets.
*/
diff --git a/web/styles/subscriptions.css b/web/styles/subscriptions.css
index 7b572e7275e..e55b9c135a4 100644
--- a/web/styles/subscriptions.css
+++ b/web/styles/subscriptions.css
@@ -253,6 +253,10 @@ h4.user_group_setting_subsection_title {
}
}
+#stream_creation_form .subscriber_list_container {
+ max-height: var(--new-stream-subscriber-list-max-height);
+}
+
.subscriber-name,
.subscriber-email {
padding: 5px;
diff --git a/web/templates/stream_settings/stream_creation_form.hbs b/web/templates/stream_settings/stream_creation_form.hbs
index 1f8381c3b7a..3ad536c0647 100644
--- a/web/templates/stream_settings/stream_creation_form.hbs
+++ b/web/templates/stream_settings/stream_creation_form.hbs
@@ -32,7 +32,7 @@
</div>
<div class="subscribers_container stream_creation_container">
<section class="stream_create_add_subscriber_container">
- <h4 class="stream_setting_subsection_title">
+ <h4 class="stream_setting_subsection_title new-stream-subscribers-title">
<label class="choose-subscribers-label">{{t "Choose subscribers" }}</label>
</h4>
<div id="stream_subscription_error" class="stream_creation_error"></div>