From 3e5d91516f94d95b80130c11fd957c2f16352099 Mon Sep 17 00:00:00 2001 From: Mikhail Aheichyk Date: Wed, 15 Mar 2023 10:06:08 +0300 Subject: [PATCH] Show filterContainer if "UIComponent.filterContainer" is enabled Signed-off-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 0846c59a817..95ca5c350db 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 bb83005d7c2..eab1972798e 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(); + }); +});