New room list: add search section (#29251)
* feat(new room list): move `RoomListView` to its own folder and add styling * feat(new room list): add search section * test(new room list): add tests for `RoomListSearch` * test(new room list): add tests for `RoomListView` * test(e2e): add method to close notification toast to `ElementAppPage` * test(e2e): add tests for the search section * test(e2e): add tests for the room list view * refactor: use Flex component * fix: loop icon size in search button * refactor: remove `focus_room_filter` listener
This commit is contained in:
@@ -390,7 +390,7 @@ export default class LeftPanel extends React.Component<IProps, IState> {
|
||||
return (
|
||||
<div className={containerClasses}>
|
||||
<div className="mx_LeftPanel_roomListContainer">
|
||||
<RoomListView />
|
||||
<RoomListView activeSpace={this.state.activeSpace} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
Copyright 2025 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
type IProps = unknown;
|
||||
|
||||
export const RoomListView: React.FC<IProps> = (props: IProps) => {
|
||||
return <div>New Room List</div>;
|
||||
};
|
||||
69
src/components/views/rooms/RoomListView/RoomListSearch.tsx
Normal file
69
src/components/views/rooms/RoomListView/RoomListSearch.tsx
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import React, { type JSX } from "react";
|
||||
import { Button } from "@vector-im/compound-web";
|
||||
import ExploreIcon from "@vector-im/compound-design-tokens/assets/web/icons/explore";
|
||||
import SearchIcon from "@vector-im/compound-design-tokens/assets/web/icons/search";
|
||||
|
||||
import { IS_MAC, Key } from "../../../../Keyboard";
|
||||
import { _t } from "../../../../languageHandler";
|
||||
import { ALTERNATE_KEY_NAME } from "../../../../accessibility/KeyboardShortcuts";
|
||||
import { shouldShowComponent } from "../../../../customisations/helpers/UIComponents";
|
||||
import { UIComponent } from "../../../../settings/UIFeature";
|
||||
import { MetaSpace } from "../../../../stores/spaces";
|
||||
import { Action } from "../../../../dispatcher/actions";
|
||||
import PosthogTrackers from "../../../../PosthogTrackers";
|
||||
import defaultDispatcher from "../../../../dispatcher/dispatcher";
|
||||
import { Flex } from "../../../utils/Flex";
|
||||
|
||||
type RoomListSearchProps = {
|
||||
/**
|
||||
* Current active space
|
||||
* The explore button is only displayed in the Home meta space
|
||||
*/
|
||||
activeSpace: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* A search component to be displayed at the top of the room list
|
||||
* The `Explore` button is displayed only in the Home meta space and when UIComponent.ExploreRooms is enabled.
|
||||
*/
|
||||
export function RoomListSearch({ activeSpace }: RoomListSearchProps): JSX.Element {
|
||||
const displayExploreButton = activeSpace === MetaSpace.Home && shouldShowComponent(UIComponent.ExploreRooms);
|
||||
|
||||
return (
|
||||
<Flex className="mx_RoomListSearch" role="search" gap="var(--cpd-space-2x)" align="center">
|
||||
<Button
|
||||
className="mx_RoomListSearch_search"
|
||||
kind="secondary"
|
||||
size="sm"
|
||||
Icon={SearchIcon}
|
||||
onClick={() => defaultDispatcher.fire(Action.OpenSpotlight)}
|
||||
>
|
||||
<Flex as="span" justify="space-between">
|
||||
{_t("action|search")}
|
||||
<kbd>{IS_MAC ? "⌘ K" : _t(ALTERNATE_KEY_NAME[Key.CONTROL]) + " K"}</kbd>
|
||||
</Flex>
|
||||
</Button>
|
||||
{displayExploreButton && (
|
||||
<Button
|
||||
className="mx_RoomListSearch_explore"
|
||||
kind="secondary"
|
||||
size="sm"
|
||||
Icon={ExploreIcon}
|
||||
iconOnly={true}
|
||||
aria-label={_t("action|explore_rooms")}
|
||||
onClick={(ev) => {
|
||||
defaultDispatcher.fire(Action.ViewRoomDirectory);
|
||||
PosthogTrackers.trackInteraction("WebLeftPanelExploreRoomsButton", ev);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
33
src/components/views/rooms/RoomListView/RoomListView.tsx
Normal file
33
src/components/views/rooms/RoomListView/RoomListView.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Copyright 2025 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
import { shouldShowComponent } from "../../../../customisations/helpers/UIComponents";
|
||||
import { UIComponent } from "../../../../settings/UIFeature";
|
||||
import { RoomListSearch } from "./RoomListSearch";
|
||||
|
||||
type RoomListViewProps = {
|
||||
/**
|
||||
* Current active space
|
||||
* See {@link RoomListSearch}
|
||||
*/
|
||||
activeSpace: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* A view component for the room list.
|
||||
*/
|
||||
export const RoomListView: React.FC<RoomListViewProps> = ({ activeSpace }) => {
|
||||
const displayRoomSearch = shouldShowComponent(UIComponent.FilterContainer);
|
||||
|
||||
return (
|
||||
<div className="mx_RoomListView" data-testid="room-list-view">
|
||||
{displayRoomSearch && <RoomListSearch activeSpace={activeSpace} />}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
8
src/components/views/rooms/RoomListView/index.ts
Normal file
8
src/components/views/rooms/RoomListView/index.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
export { RoomListView } from "./RoomListView";
|
||||
Reference in New Issue
Block a user