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: Loop over group setting when setting up widgets.

Shubham Padiabfd5089837a3
diff --git a/web/src/stream_create.ts b/web/src/stream_create.ts
index 44ebea7ec3f..5049036e01e 100644
--- a/web/src/stream_create.ts
+++ b/web/src/stream_create.ts
@@ -20,6 +20,7 @@ import * as stream_create_subscribers from "./stream_create_subscribers.ts";
import * as stream_data from "./stream_data.ts";
import * as stream_settings_components from "./stream_settings_components.ts";
import * as stream_settings_data from "./stream_settings_data.ts";
+import {stream_permission_group_settings_schema} from "./stream_types.ts";
import * as stream_ui_updates from "./stream_ui_updates.ts";
import type {GroupSettingPillContainer} from "./typeahead_helper.ts";
import type {HTMLSelectOneElement} from "./types.ts";
@@ -365,10 +366,13 @@ function create_stream(): void {
const principals = JSON.stringify(user_ids);
set_current_user_subscribed_to_created_stream(user_ids.includes(current_user.user_id));
- assert(can_remove_subscribers_group_widget !== undefined);
- const can_remove_subscribers_group_value = settings_components.get_group_setting_widget_value(
- can_remove_subscribers_group_widget,
- );
+ const group_setting_values: Record<string, string> = {};
+ for (const setting_name of Object.keys(realm.server_supported_permission_settings.stream)) {
+ assert(group_setting_widgets[setting_name] !== undefined);
+ group_setting_values[setting_name] = JSON.stringify(
+ settings_components.get_group_setting_widget_value(group_setting_widgets[setting_name]),
+ );
+ }
loading.make_indicator($("#stream_creating_indicator"), {
text: $t({defaultMessage: "Creating channel..."}),
@@ -384,7 +388,7 @@ function create_stream(): void {
message_retention_days: JSON.stringify(message_retention_selection),
announce: JSON.stringify(announce),
principals,
- can_remove_subscribers_group: JSON.stringify(can_remove_subscribers_group_value),
+ ...group_setting_values,
};
// Subscribe yourself and possible other people to a new stream.
@@ -507,13 +511,16 @@ export function show_new_stream_modal(): void {
clear_error_display();
}
-let can_remove_subscribers_group_widget: GroupSettingPillContainer | undefined;
+let group_setting_widgets: Record<string, GroupSettingPillContainer | undefined> = {};
function set_up_group_setting_widgets(): void {
- can_remove_subscribers_group_widget = settings_components.create_stream_group_setting_widget({
- $pill_container: $("#id_new_can_remove_subscribers_group"),
- setting_name: "can_remove_subscribers_group",
- });
+ for (const setting_name of Object.keys(realm.server_supported_permission_settings.stream)) {
+ group_setting_widgets[setting_name] =
+ settings_components.create_stream_group_setting_widget({
+ $pill_container: $("#id_new_" + setting_name),
+ setting_name: stream_permission_group_settings_schema.parse(setting_name),
+ });
+ }
}
export function set_up_handlers(): void {