diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 4b449708e5..fe536d7905 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -175,6 +175,11 @@ interface IRoomProps extends RoomViewProps { * If true, hide the composer */ hideComposer?: boolean; + + /* + * If true, hide the right panel + */ + hideRightPanel?: boolean; } export { MainSplitContentType }; @@ -2557,7 +2562,8 @@ export class RoomView extends React.Component { ); } - const showRightPanel = !isRoomEncryptionLoading && this.state.room && this.state.showRightPanel; + const showRightPanel = + !this.props.hideRightPanel && !isRoomEncryptionLoading && this.state.room && this.state.showRightPanel; const rightPanel = showRightPanel ? ( { } const roomView = render( - - - - - , + , + { + wrapper: ({ children }) => ( + + {children} + + ), + }, ); await flushPromises(); return roomView; @@ -273,6 +276,28 @@ describe("RoomView", () => { expect(asFragment()).toMatchSnapshot(); }); + it("should hide the right panel when hideRightPanel=true", async () => { + // Join the room + jest.spyOn(room, "getMyMembership").mockReturnValue(KnownMembership.Join); + const { asFragment, rerender } = await mountRoomView(undefined); + + defaultDispatcher.dispatch( + { + action: Action.ViewUser, + member: undefined, + }, + true, + ); + + // Check that the right panel is rendered + await expect(screen.findByTestId("right-panel")).resolves.toBeTruthy(); + // Now rerender with hideRightPanel=true + rerender(); + // Check that the right panel is not rendered + await expect(screen.findByTestId("right-panel")).rejects.toThrow(); + expect(asFragment()).toMatchSnapshot(); + }); + describe("invites", () => { beforeEach(() => { const member = new RoomMember(room.roomId, cli.getSafeUserId()); diff --git a/test/unit-tests/components/structures/__snapshots__/RoomView-test.tsx.snap b/test/unit-tests/components/structures/__snapshots__/RoomView-test.tsx.snap index e66f1def29..15582ebe8a 100644 --- a/test/unit-tests/components/structures/__snapshots__/RoomView-test.tsx.snap +++ b/test/unit-tests/components/structures/__snapshots__/RoomView-test.tsx.snap @@ -363,7 +363,7 @@ exports[`RoomView for a local room in state NEW should match the snapshot 1`] = > `; +exports[`RoomView should hide the right panel when hideRightPanel=true 1`] = ` + +
+