From d4b81882e55c2e3905333a38c68a1305ad7607bb Mon Sep 17 00:00:00 2001 From: maheichyk Date: Tue, 21 Mar 2023 12:06:43 +0300 Subject: [PATCH] Show filterContainer if "UIComponent.filterContainer" is enabled (#10381) Signed-off-by: Mikhail Aheichyk Co-authored-by: Mikhail Aheichyk --- res/css/structures/_LeftPanel.pcss | 4 ++ src/components/structures/LeftPanel.tsx | 2 +- src/settings/UIFeature.ts | 5 ++ test/components/structures/LeftPanel-test.tsx | 54 +++++++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 test/components/structures/LeftPanel-test.tsx diff --git a/res/css/structures/_LeftPanel.pcss b/res/css/structures/_LeftPanel.pcss index 0846c59a81..95ca5c350d 100644 --- a/res/css/structures/_LeftPanel.pcss +++ b/res/css/structures/_LeftPanel.pcss @@ -185,6 +185,10 @@ $roomListCollapsedWidth: 68px; } } + .mx_RoomListHeader:first-child { + margin-top: 12px; + } + .mx_LeftPanel_roomListWrapper { /* Make the y-scrollbar more responsive */ padding-right: 2px; diff --git a/src/components/structures/LeftPanel.tsx b/src/components/structures/LeftPanel.tsx index bb83005d7c..eab1972798 100644 --- a/src/components/structures/LeftPanel.tsx +++ b/src/components/structures/LeftPanel.tsx @@ -393,7 +393,7 @@ export default class LeftPanel extends React.Component { return (
- {this.renderSearchDialExplore()} + {shouldShowComponent(UIComponent.FilterContainer) && this.renderSearchDialExplore()} {this.renderBreadcrumbs()} {!this.props.isMinimized && } ({ + shouldShowComponent: jest.fn(), +})); + +describe("LeftPanel", () => { + function renderComponent(): RenderResult { + return render( + , + ); + } + + it("does not show filter container when disabled by UIComponent customisations", () => { + mocked(shouldShowComponent).mockReturnValue(false); + renderComponent(); + expect(shouldShowComponent).toHaveBeenCalledWith(UIComponent.FilterContainer); + expect(screen.queryByRole("button", { name: /search/i })).not.toBeInTheDocument(); + expect(screen.queryByRole("button", { name: "Explore rooms" })).not.toBeInTheDocument(); + }); + + it("renders filter container when enabled by UIComponent customisations", () => { + mocked(shouldShowComponent).mockReturnValue(true); + renderComponent(); + expect(shouldShowComponent).toHaveBeenCalledWith(UIComponent.FilterContainer); + expect(screen.getByRole("button", { name: /search/i })).toBeInTheDocument(); + expect(screen.getByRole("button", { name: "Explore rooms" })).toBeInTheDocument(); + }); +});