Add options to hide header and composer of room view for the module api (#31095)

* feat: add props to hide header in `RoomView`

* feat: add props to hide composer in `RoomView`

* feat: pass `RoomViewProps` to room view in `renderRoomView`

* refactor: add doc and use existing types

* test: add tests for new room view props
This commit is contained in:
Florian Duros
2025-11-05 13:52:10 +01:00
committed by GitHub
parent 52eb8a9979
commit 4d66a85e73
4 changed files with 491 additions and 29 deletions

View File

@@ -12,6 +12,9 @@ import { MatrixClientPeg } from "../MatrixClientPeg";
import type { Room } from "matrix-js-sdk/src/matrix";
interface RoomViewPropsWithRoomId extends RoomViewProps {
/**
* The ID of the room to display
*/
roomId?: string;
}
@@ -26,9 +29,8 @@ interface Components {
}
export class ElementWebBuiltinsApi implements BuiltinsApi {
private _roomView?: React.ComponentType<RoomViewPropsWithRoomId>;
private _roomAvatar?: React.ComponentType<RoomAvatarProps>;
private _roomView?: Components["roomView"];
private _roomAvatar?: Components["roomAvatar"];
/**
* Sets the components used by the API.
*
@@ -59,9 +61,9 @@ export class ElementWebBuiltinsApi implements BuiltinsApi {
return this._roomAvatar;
}
public renderRoomView(roomId: string): React.ReactNode {
public renderRoomView(roomId: string, props?: RoomViewProps): React.ReactNode {
const Component = this.getRoomViewComponent();
return <Component roomId={roomId} />;
return <Component roomId={roomId} {...props} />;
}
public renderRoomAvatar(roomId: string, size?: string): React.ReactNode {