mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	left_sidebar: Hide stream section separator when there is only one.
Showing section separators in the left sidebar ("Pinned streams",
"Active streams", etc.) is unnecessary when there is only one section,
and can feel confusing. We should show the separators only when there
is more than one section present.
Fixes #22843.
			
			
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							72b5af2260
						
					
				
				
					commit
					dd39a9747d
				
			@@ -606,12 +606,8 @@ test_ui("separators_only_pinned_and_dormant", ({override_rewire, mock_template})
 | 
				
			|||||||
    assert.ok(inactive_subheader_flag);
 | 
					    assert.ok(inactive_subheader_flag);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test_ui("separators_only_pinned", ({mock_template}) => {
 | 
					test_ui("separators_only_pinned", () => {
 | 
				
			||||||
    // Test only pinned streams
 | 
					    // Test only pinned streams
 | 
				
			||||||
 | 
					 | 
				
			||||||
    create_stream_subheader({mock_template});
 | 
					 | 
				
			||||||
    pinned_subheader_flag = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Get coverage on early-exit.
 | 
					    // Get coverage on early-exit.
 | 
				
			||||||
    stream_list.build_stream_list();
 | 
					    stream_list.build_stream_list();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -640,16 +636,14 @@ test_ui("separators_only_pinned", ({mock_template}) => {
 | 
				
			|||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    stream_list.build_stream_list();
 | 
					    stream_list.build_stream_list();
 | 
				
			||||||
    const $pinned_subheader = $("<pinned-subheader-stub>");
 | 
					 | 
				
			||||||
    const expected_elems = [
 | 
					    const expected_elems = [
 | 
				
			||||||
        $pinned_subheader.html(), // pinned
 | 
					        // no section sub-header since there is only one section
 | 
				
			||||||
        $("<devel-sidebar-row-stub>"),
 | 
					        $("<devel-sidebar-row-stub>"),
 | 
				
			||||||
        $("<Rome-sidebar-row-stub>"),
 | 
					        $("<Rome-sidebar-row-stub>"),
 | 
				
			||||||
        // no separator at the end as no stream follows
 | 
					        // no separator at the end as no stream follows
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    assert.deepEqual(appended_elems, expected_elems);
 | 
					    assert.deepEqual(appended_elems, expected_elems);
 | 
				
			||||||
    assert.ok(pinned_subheader_flag);
 | 
					 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test_ui("rename_stream", ({mock_template}) => {
 | 
					test_ui("rename_stream", ({mock_template}) => {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -145,8 +145,13 @@ export function build_stream_list(force_rerender) {
 | 
				
			|||||||
    const any_pinned_streams = stream_groups.pinned_streams.length > 0;
 | 
					    const any_pinned_streams = stream_groups.pinned_streams.length > 0;
 | 
				
			||||||
    const any_normal_streams = stream_groups.normal_streams.length > 0;
 | 
					    const any_normal_streams = stream_groups.normal_streams.length > 0;
 | 
				
			||||||
    const any_dormant_streams = stream_groups.dormant_streams.length > 0;
 | 
					    const any_dormant_streams = stream_groups.dormant_streams.length > 0;
 | 
				
			||||||
 | 
					    const need_section_subheaders =
 | 
				
			||||||
 | 
					        (any_pinned_streams ? 1 : 0) +
 | 
				
			||||||
 | 
					            (any_normal_streams ? 1 : 0) +
 | 
				
			||||||
 | 
					            (any_dormant_streams ? 1 : 0) >=
 | 
				
			||||||
 | 
					        2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (any_pinned_streams) {
 | 
					    if (any_pinned_streams && need_section_subheaders) {
 | 
				
			||||||
        elems.push(
 | 
					        elems.push(
 | 
				
			||||||
            render_stream_subheader({
 | 
					            render_stream_subheader({
 | 
				
			||||||
                subheader_name: $t({
 | 
					                subheader_name: $t({
 | 
				
			||||||
@@ -164,7 +169,7 @@ export function build_stream_list(force_rerender) {
 | 
				
			|||||||
        add_sidebar_li(stream_id);
 | 
					        add_sidebar_li(stream_id);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (any_normal_streams) {
 | 
					    if (any_normal_streams && need_section_subheaders) {
 | 
				
			||||||
        elems.push(
 | 
					        elems.push(
 | 
				
			||||||
            render_stream_subheader({
 | 
					            render_stream_subheader({
 | 
				
			||||||
                subheader_name: $t({
 | 
					                subheader_name: $t({
 | 
				
			||||||
@@ -182,7 +187,7 @@ export function build_stream_list(force_rerender) {
 | 
				
			|||||||
        add_sidebar_li(stream_id);
 | 
					        add_sidebar_li(stream_id);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (any_dormant_streams) {
 | 
					    if (any_dormant_streams && need_section_subheaders) {
 | 
				
			||||||
        elems.push(
 | 
					        elems.push(
 | 
				
			||||||
            render_stream_subheader({
 | 
					            render_stream_subheader({
 | 
				
			||||||
                subheader_name: $t({
 | 
					                subheader_name: $t({
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user