mirror of
https://github.com/zulip/zulip.git
synced 2025-11-22 15:31:20 +00:00
settings: Do not store pill widgets for new groups in map.
Instead of storing setting pill widgets for new groups in group_setting_widget_map, we just use variable in the user_group_create file to store the widget. This helps in accessing the widget with the key having "new_group_" as prefix which we want to avoid as a pattern. Note that the classes and IDs in templates still use "new_group_" prefix.
This commit is contained in:
@@ -1404,7 +1404,6 @@ export function initialize_disable_btn_hint_popover(
|
||||
|
||||
const group_setting_widget_map = new Map<string, GroupSettingPillContainer | null>([
|
||||
["can_manage_group", null],
|
||||
["new_group_can_manage_group", null],
|
||||
]);
|
||||
|
||||
export function get_group_setting_widget(setting_name: string): GroupSettingPillContainer | null {
|
||||
@@ -1459,7 +1458,7 @@ export function create_group_setting_widget({
|
||||
setting_name: group_setting_name;
|
||||
setting_type: "realm" | "stream" | "group";
|
||||
group?: UserGroup;
|
||||
}): void {
|
||||
}): GroupSettingPillContainer {
|
||||
const pill_widget = group_setting_pill.create_pills(
|
||||
$pill_container,
|
||||
setting_name,
|
||||
@@ -1472,9 +1471,7 @@ export function create_group_setting_widget({
|
||||
};
|
||||
group_setting_pill.set_up_pill_typeahead({pill_widget, $pill_container, opts});
|
||||
|
||||
if (group === undefined) {
|
||||
group_setting_widget_map.set("new_group_" + setting_name, pill_widget);
|
||||
} else {
|
||||
if (group !== undefined) {
|
||||
group_setting_widget_map.set(setting_name, pill_widget);
|
||||
}
|
||||
|
||||
@@ -1502,4 +1499,6 @@ export function create_group_setting_widget({
|
||||
set_group_setting_widget_value(pill_widget, default_group_id);
|
||||
}
|
||||
}
|
||||
|
||||
return pill_widget;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import * as keydown_util from "./keydown_util";
|
||||
import * as loading from "./loading";
|
||||
import {page_params} from "./page_params";
|
||||
import * as settings_components from "./settings_components";
|
||||
import type {GroupSettingPillContainer} from "./typeahead_helper";
|
||||
import * as ui_report from "./ui_report";
|
||||
import * as user_group_components from "./user_group_components";
|
||||
import * as user_group_create_members from "./user_group_create_members";
|
||||
@@ -27,6 +28,8 @@ export function get_name(): string | undefined {
|
||||
return created_group_name;
|
||||
}
|
||||
|
||||
let can_manage_group_widget: GroupSettingPillContainer | undefined;
|
||||
|
||||
class UserGroupMembershipError {
|
||||
report_no_members_to_user_group(): void {
|
||||
$("#user_group_membership_error").text(
|
||||
@@ -150,9 +153,9 @@ function create_user_group(): void {
|
||||
}
|
||||
const user_ids = user_group_create_members.get_principals();
|
||||
|
||||
const pill_widget = settings_components.get_group_setting_widget("new_group_can_manage_group");
|
||||
assert(pill_widget !== null);
|
||||
const can_manage_group = settings_components.get_group_setting_widget_value(pill_widget);
|
||||
assert(can_manage_group_widget !== undefined);
|
||||
const can_manage_group =
|
||||
settings_components.get_group_setting_widget_value(can_manage_group_widget);
|
||||
|
||||
assert(settings_components.new_group_can_mention_group_widget !== null);
|
||||
const can_mention_group_value = settings_components.new_group_can_mention_group_widget.value();
|
||||
@@ -240,7 +243,7 @@ export function set_up_handlers(): void {
|
||||
});
|
||||
|
||||
const $pill_container = $container.find(".can-manage-group-container .pill-container");
|
||||
settings_components.create_group_setting_widget({
|
||||
can_manage_group_widget = settings_components.create_group_setting_widget({
|
||||
$pill_container,
|
||||
setting_name: "can_manage_group",
|
||||
setting_type: "group",
|
||||
|
||||
Reference in New Issue
Block a user