mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	stream-settings: Fix live update of subscribers UI.
Changes done here are - - Previously the pill input, "Add" button and tooltip shown when user did not have permission were not live updated when updating can_add_subscribers_group and can_subscribe_group stream level settings or can_add_subscribers_group realm level setting. This commit fixes that. - Also, when the UI was live updated to give user permission to subscribe others, "Add" button was enabled even when input was empty. This is also fixed in this commit.
This commit is contained in:
		@@ -77,6 +77,8 @@ const settings_users = mock_esm("../src/settings_users");
 | 
			
		||||
const sidebar_ui = mock_esm("../src/sidebar_ui");
 | 
			
		||||
const stream_data = mock_esm("../src/stream_data");
 | 
			
		||||
const stream_list = mock_esm("../src/stream_list");
 | 
			
		||||
const stream_settings_components = mock_esm("../src/stream_settings_components");
 | 
			
		||||
const stream_settings_data = mock_esm("../src/stream_settings_data");
 | 
			
		||||
const stream_settings_ui = mock_esm("../src/stream_settings_ui");
 | 
			
		||||
const stream_list_sort = mock_esm("../src/stream_list_sort");
 | 
			
		||||
const stream_topic_history = mock_esm("../src/stream_topic_history");
 | 
			
		||||
@@ -607,6 +609,19 @@ run_test("realm settings", ({override}) => {
 | 
			
		||||
    });
 | 
			
		||||
    override(settings_org, "populate_auth_methods", noop);
 | 
			
		||||
    override(user_group_edit, "update_realm_setting_in_permissions_panel", noop);
 | 
			
		||||
    override(overlays, "streams_open", () => true);
 | 
			
		||||
    override(stream_settings_components, "get_active_data", () => ({
 | 
			
		||||
        id: events.test_streams.devel.stream_id,
 | 
			
		||||
    }));
 | 
			
		||||
    override(stream_settings_data, "get_sub_for_settings", () => ({
 | 
			
		||||
        ...events.test_streams.devel,
 | 
			
		||||
        can_add_subscribers: false,
 | 
			
		||||
    }));
 | 
			
		||||
    let add_subscribers_element_updated = false;
 | 
			
		||||
    override(stream_ui_updates, "update_add_subscriptions_elements", (sub) => {
 | 
			
		||||
        assert.deepEqual(sub, {...events.test_streams.devel, can_add_subscribers: false});
 | 
			
		||||
        add_subscribers_element_updated = true;
 | 
			
		||||
    });
 | 
			
		||||
    dispatch(event);
 | 
			
		||||
    assert_same(realm.realm_create_multiuse_invite_group, 3);
 | 
			
		||||
    assert_same(realm.realm_allow_message_editing, true);
 | 
			
		||||
@@ -626,6 +641,7 @@ run_test("realm settings", ({override}) => {
 | 
			
		||||
    assert_same(realm.realm_upload_quota_mib, 50000);
 | 
			
		||||
    assert_same(realm.max_file_upload_size_mib, 1024);
 | 
			
		||||
    assert_same(update_stream_privacy_choices_called, true);
 | 
			
		||||
    assert_same(add_subscribers_element_updated, true);
 | 
			
		||||
 | 
			
		||||
    event = event_fixtures.realm__update_dict__icon;
 | 
			
		||||
    override(realm_icon, "rerender", noop);
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,7 @@ const stream_color_events = mock_esm("../src/stream_color_events");
 | 
			
		||||
const stream_list = mock_esm("../src/stream_list");
 | 
			
		||||
const stream_muting = mock_esm("../src/stream_muting");
 | 
			
		||||
const stream_settings_api = mock_esm("../src/stream_settings_api");
 | 
			
		||||
const stream_settings_data = mock_esm("../src/stream_settings_data");
 | 
			
		||||
const onboarding_steps = mock_esm("../src/onboarding_steps");
 | 
			
		||||
const stream_settings_ui = mock_esm("../src/stream_settings_ui", {
 | 
			
		||||
    update_settings_for_subscribed: noop,
 | 
			
		||||
@@ -290,6 +291,10 @@ test("update_property", ({override}) => {
 | 
			
		||||
    {
 | 
			
		||||
        const stub = make_stub();
 | 
			
		||||
        override(stream_settings_ui, "update_stream_permission_group_setting", stub.f);
 | 
			
		||||
        override(stream_settings_data, "get_sub_for_settings", () => ({
 | 
			
		||||
            can_add_subscribers: false,
 | 
			
		||||
            ...sub,
 | 
			
		||||
        }));
 | 
			
		||||
        stream_events.update_property(stream_id, "can_administer_channel_group", 3);
 | 
			
		||||
        assert.equal(stub.num_calls, 1);
 | 
			
		||||
        const args = stub.get_args("setting_name", "sub", "val");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user