mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	stream_edit: Extract generic pill functions to be reused in future.
This commit is contained in:
		@@ -292,6 +292,22 @@ exports.sort_but_pin_current_user_on_top = function (users) {
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.create_item_from_text = function (text, current_items) {
 | 
			
		||||
    const item = stream_pill.create_item_from_stream_name(text, current_items);
 | 
			
		||||
    if (item) {
 | 
			
		||||
        return item;
 | 
			
		||||
    }
 | 
			
		||||
    return user_pill.create_item_from_email(text, current_items);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.get_text_from_item = function (item) {
 | 
			
		||||
    const text = stream_pill.get_stream_name_from_item(item);
 | 
			
		||||
    if (text) {
 | 
			
		||||
        return text;
 | 
			
		||||
    }
 | 
			
		||||
    return user_pill.get_email_from_item(item);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
function show_subscription_settings(sub) {
 | 
			
		||||
    const stream_id = sub.stream_id;
 | 
			
		||||
    const sub_settings = exports.settings_for_sub(sub);
 | 
			
		||||
@@ -307,25 +323,10 @@ function show_subscription_settings(sub) {
 | 
			
		||||
        )}'] .pill-container`,
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    function create_item_from_text(text, current_items) {
 | 
			
		||||
        const item = stream_pill.create_item_from_stream_name(text, current_items);
 | 
			
		||||
        if (item) {
 | 
			
		||||
            return item;
 | 
			
		||||
        }
 | 
			
		||||
        return user_pill.create_item_from_email(text, current_items);
 | 
			
		||||
    }
 | 
			
		||||
    function get_text_from_item(item) {
 | 
			
		||||
        const text = stream_pill.get_stream_name_from_item(item);
 | 
			
		||||
        if (text) {
 | 
			
		||||
            return text;
 | 
			
		||||
        }
 | 
			
		||||
        return user_pill.get_email_from_item(item);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    exports.pill_widget = input_pill.create({
 | 
			
		||||
        container,
 | 
			
		||||
        create_item_from_text,
 | 
			
		||||
        get_text_from_item,
 | 
			
		||||
        create_item_from_text: exports.create_item_from_text,
 | 
			
		||||
        get_text_from_item: exports.get_text_from_item,
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    if (!sub.render_subscribers) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user