mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	user profile: Use stream_data.can_unsubscribe_others.
This is necessary to offer the "Unsubscribe" button in full user profiles when the current user has the necessary permissions for a given stream. We remove settings_data.user_can_unsubscribe_other_users, since we've changed its only caller and it is no longer a useful abstraction.
This commit is contained in:
		@@ -130,14 +130,6 @@ run_test("user_can_change_logo", () => {
 | 
			
		||||
    assert.equal(can_change_logo(), false);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
run_test("user_can_unsubscribe_other_users", () => {
 | 
			
		||||
    page_params.is_admin = true;
 | 
			
		||||
    assert.equal(settings_data.user_can_unsubscribe_other_users(), true);
 | 
			
		||||
 | 
			
		||||
    page_params.is_admin = false;
 | 
			
		||||
    assert.equal(settings_data.user_can_unsubscribe_other_users(), false);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
function test_policy(label, policy, validation_func) {
 | 
			
		||||
    run_test(label, () => {
 | 
			
		||||
        page_params.is_admin = true;
 | 
			
		||||
 
 | 
			
		||||
@@ -197,10 +197,6 @@ export function user_can_subscribe_other_users(): boolean {
 | 
			
		||||
    return user_has_permission(page_params.realm_invite_to_stream_policy);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function user_can_unsubscribe_other_users(): boolean {
 | 
			
		||||
    return page_params.is_admin;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function user_can_create_private_streams(): boolean {
 | 
			
		||||
    return user_has_permission(page_params.realm_create_private_stream_policy);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -55,7 +55,7 @@ function initialize_bot_owner(element_id, bot_id) {
 | 
			
		||||
 | 
			
		||||
function format_user_stream_list_item(stream, user) {
 | 
			
		||||
    const show_unsubscribe_button =
 | 
			
		||||
        people.can_admin_user(user) || settings_data.user_can_unsubscribe_other_users();
 | 
			
		||||
        people.can_admin_user(user) || stream_data.can_unsubscribe_others(stream);
 | 
			
		||||
    const show_private_stream_unsub_tooltip =
 | 
			
		||||
        people.is_my_user_id(user.user_id) && stream.invite_only;
 | 
			
		||||
    return render_user_stream_list_item({
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user