mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	group_setting_pill: Pass setting_type in pill_config.
We only use pills UI for can_manage_group setting currently, but we can still pass setting_type in pill_config so that we can use that while calling get_group_permission_setting_config for checking if group is allowed to be used in the setting when creating group pill from group name.
This commit is contained in:
		@@ -13,10 +13,14 @@ import * as user_groups from "./user_groups";
 | 
			
		||||
import type {UserGroup} from "./user_groups";
 | 
			
		||||
import * as user_pill from "./user_pill";
 | 
			
		||||
 | 
			
		||||
function check_group_allowed_for_setting(group_item: UserGroupPill, setting_name: string): boolean {
 | 
			
		||||
function check_group_allowed_for_setting(
 | 
			
		||||
    group_item: UserGroupPill,
 | 
			
		||||
    setting_name: string,
 | 
			
		||||
    setting_type: "realm" | "stream" | "group",
 | 
			
		||||
): boolean {
 | 
			
		||||
    const group_setting_config = group_permission_settings.get_group_permission_setting_config(
 | 
			
		||||
        setting_name,
 | 
			
		||||
        "group",
 | 
			
		||||
        setting_type,
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    assert(group_setting_config !== undefined);
 | 
			
		||||
@@ -46,7 +50,9 @@ export function create_item_from_text(
 | 
			
		||||
    if (group_item) {
 | 
			
		||||
        const setting_name = pill_config?.setting_name;
 | 
			
		||||
        assert(setting_name !== undefined);
 | 
			
		||||
        if (check_group_allowed_for_setting(group_item, setting_name)) {
 | 
			
		||||
        const setting_type = pill_config?.setting_type;
 | 
			
		||||
        assert(setting_type !== undefined);
 | 
			
		||||
        if (check_group_allowed_for_setting(group_item, setting_name, setting_type)) {
 | 
			
		||||
            return group_item;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -91,6 +97,7 @@ export function generate_pill_html(item: GroupSettingPill): string {
 | 
			
		||||
export function create_pills(
 | 
			
		||||
    $pill_container: JQuery,
 | 
			
		||||
    setting_name: string,
 | 
			
		||||
    setting_type: "realm" | "stream" | "group",
 | 
			
		||||
): GroupSettingPillContainer {
 | 
			
		||||
    const pill_widget = input_pill.create<GroupSettingPill>({
 | 
			
		||||
        $container: $pill_container,
 | 
			
		||||
@@ -100,6 +107,7 @@ export function create_pills(
 | 
			
		||||
        generate_pill_html,
 | 
			
		||||
        pill_config: {
 | 
			
		||||
            setting_name,
 | 
			
		||||
            setting_type,
 | 
			
		||||
        },
 | 
			
		||||
    });
 | 
			
		||||
    return pill_widget;
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,7 @@ import * as util from "./util";
 | 
			
		||||
export type InputPillConfig = {
 | 
			
		||||
    exclude_inaccessible_users?: boolean;
 | 
			
		||||
    setting_name?: string;
 | 
			
		||||
    setting_type?: "realm" | "stream" | "group";
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
type InputPillCreateOptions<ItemType> = {
 | 
			
		||||
 
 | 
			
		||||
@@ -1452,7 +1452,11 @@ export function create_group_setting_widget({
 | 
			
		||||
    setting_type: "realm" | "stream" | "group";
 | 
			
		||||
    group?: UserGroup;
 | 
			
		||||
}): void {
 | 
			
		||||
    const pill_widget = group_setting_pill.create_pills($pill_container, setting_name);
 | 
			
		||||
    const pill_widget = group_setting_pill.create_pills(
 | 
			
		||||
        $pill_container,
 | 
			
		||||
        setting_name,
 | 
			
		||||
        setting_type,
 | 
			
		||||
    );
 | 
			
		||||
    const opts = {
 | 
			
		||||
        setting_name,
 | 
			
		||||
        setting_type,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user