Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit d4b8188

Browse files
authored
Show filterContainer if "UIComponent.filterContainer" is enabled (#10381)
Signed-off-by: Mikhail Aheichyk <[email protected]> Co-authored-by: Mikhail Aheichyk <[email protected]>
1 parent 2245190 commit d4b8188

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed

res/css/structures/_LeftPanel.pcss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ $roomListCollapsedWidth: 68px;
185185
}
186186
}
187187

188+
.mx_RoomListHeader:first-child {
189+
margin-top: 12px;
190+
}
191+
188192
.mx_LeftPanel_roomListWrapper {
189193
/* Make the y-scrollbar more responsive */
190194
padding-right: 2px;

src/components/structures/LeftPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ export default class LeftPanel extends React.Component<IProps, IState> {
393393
return (
394394
<div className={containerClasses}>
395395
<div className="mx_LeftPanel_roomListContainer">
396-
{this.renderSearchDialExplore()}
396+
{shouldShowComponent(UIComponent.FilterContainer) && this.renderSearchDialExplore()}
397397
{this.renderBreadcrumbs()}
398398
{!this.props.isMinimized && <RoomListHeader onVisibilityChange={this.refreshStickyHeaders} />}
399399
<UserOnboardingButton

src/settings/UIFeature.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,9 @@ export enum UIComponent {
6464
* and integrations to the room, such as from the room information card.
6565
*/
6666
AddIntegrations = "UIComponent.addIntegrations",
67+
68+
/**
69+
* Component that lead to the user being able to search, dial, explore rooms
70+
*/
71+
FilterContainer = "UIComponent.filterContainer",
6772
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
Copyright 2023 Mikhail Aheichyk
3+
Copyright 2023 Nordeck IT + Consulting GmbH.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
import React from "react";
19+
import { render, RenderResult, screen } from "@testing-library/react";
20+
import { mocked } from "jest-mock";
21+
22+
import LeftPanel from "../../../src/components/structures/LeftPanel";
23+
import PageType from "../../../src/PageTypes";
24+
import ResizeNotifier from "../../../src/utils/ResizeNotifier";
25+
import { shouldShowComponent } from "../../../src/customisations/helpers/UIComponents";
26+
import { UIComponent } from "../../../src/settings/UIFeature";
27+
28+
jest.mock("../../../src/customisations/helpers/UIComponents", () => ({
29+
shouldShowComponent: jest.fn(),
30+
}));
31+
32+
describe("LeftPanel", () => {
33+
function renderComponent(): RenderResult {
34+
return render(
35+
<LeftPanel isMinimized={false} pageType={PageType.RoomView} resizeNotifier={new ResizeNotifier()} />,
36+
);
37+
}
38+
39+
it("does not show filter container when disabled by UIComponent customisations", () => {
40+
mocked(shouldShowComponent).mockReturnValue(false);
41+
renderComponent();
42+
expect(shouldShowComponent).toHaveBeenCalledWith(UIComponent.FilterContainer);
43+
expect(screen.queryByRole("button", { name: /search/i })).not.toBeInTheDocument();
44+
expect(screen.queryByRole("button", { name: "Explore rooms" })).not.toBeInTheDocument();
45+
});
46+
47+
it("renders filter container when enabled by UIComponent customisations", () => {
48+
mocked(shouldShowComponent).mockReturnValue(true);
49+
renderComponent();
50+
expect(shouldShowComponent).toHaveBeenCalledWith(UIComponent.FilterContainer);
51+
expect(screen.getByRole("button", { name: /search/i })).toBeInTheDocument();
52+
expect(screen.getByRole("button", { name: "Explore rooms" })).toBeInTheDocument();
53+
});
54+
});

0 commit comments

Comments
 (0)