From 4edf4e42cde989c565cdb0995d65b26484f5038b Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 17 Jul 2024 13:54:35 +0100 Subject: [PATCH] Remove SpaceScopeHeader (#12785) * Remove SpaceScopeHeader It is no longer necessary as we no longer offer the ability to open the member list for a space from any random room. Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove stale test Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../e2e/right-panel/right-panel.spec.ts | 2 - res/css/_components.pcss | 1 - res/css/views/rooms/_SpaceScopeHeader.pcss | 29 ---------- src/components/views/right_panel/UserInfo.tsx | 3 +- src/components/views/rooms/MemberList.tsx | 2 - .../views/rooms/SpaceScopeHeader.tsx | 54 ------------------- .../views/rooms/ThirdPartyMemberInfo.tsx | 3 +- .../views/right_panel/UserInfo-test.tsx | 9 ---- 8 files changed, 2 insertions(+), 101 deletions(-) delete mode 100644 res/css/views/rooms/_SpaceScopeHeader.pcss delete mode 100644 src/components/views/rooms/SpaceScopeHeader.tsx diff --git a/playwright/e2e/right-panel/right-panel.spec.ts b/playwright/e2e/right-panel/right-panel.spec.ts index a5b6e9ec20..51ebb3df92 100644 --- a/playwright/e2e/right-panel/right-panel.spec.ts +++ b/playwright/e2e/right-panel/right-panel.spec.ts @@ -138,12 +138,10 @@ test.describe("RightPanel", () => { .getByRole("button", { name: /\d member/ }) .click(); await expect(page.locator(".mx_MemberList")).toBeVisible(); - await expect(page.locator(".mx_SpaceScopeHeader").getByText(SPACE_NAME)).toBeVisible(); await getMemberTileByName(page, NAME).click(); await expect(page.locator(".mx_UserInfo")).toBeVisible(); await expect(page.locator(".mx_UserInfo_profile").getByText(NAME)).toBeVisible(); - await expect(page.locator(".mx_SpaceScopeHeader").getByText(SPACE_NAME)).toBeVisible(); await page.getByTestId("base-card-back-button").click(); await expect(page.locator(".mx_MemberList")).toBeVisible(); diff --git a/res/css/_components.pcss b/res/css/_components.pcss index 327b86da08..fc929f3d97 100644 --- a/res/css/_components.pcss +++ b/res/css/_components.pcss @@ -312,7 +312,6 @@ @import "./views/rooms/_RoomTile.pcss"; @import "./views/rooms/_RoomUpgradeWarningBar.pcss"; @import "./views/rooms/_SendMessageComposer.pcss"; -@import "./views/rooms/_SpaceScopeHeader.pcss"; @import "./views/rooms/_Stickers.pcss"; @import "./views/rooms/_ThirdPartyMemberInfo.pcss"; @import "./views/rooms/_ThreadSummary.pcss"; diff --git a/res/css/views/rooms/_SpaceScopeHeader.pcss b/res/css/views/rooms/_SpaceScopeHeader.pcss deleted file mode 100644 index 4a94793ba7..0000000000 --- a/res/css/views/rooms/_SpaceScopeHeader.pcss +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright 2023 The Matrix.org Foundation C.I.C. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -.mx_SpaceScopeHeader { - text-align: center; - - display: -webkit-box; - -webkit-box-orient: vertical; - -webkit-line-clamp: 1; - overflow: hidden; - - .mx_BaseAvatar { - margin-right: var(--cpd-space-2x); - vertical-align: middle; - } -} diff --git a/src/components/views/right_panel/UserInfo.tsx b/src/components/views/right_panel/UserInfo.tsx index 165f0707e0..493cb06bcf 100644 --- a/src/components/views/right_panel/UserInfo.tsx +++ b/src/components/views/right_panel/UserInfo.tsx @@ -80,7 +80,6 @@ import { DirectoryMember, startDmOnFirstMessage } from "../../../utils/direct-me import { SdkContextClass } from "../../../contexts/SDKContext"; import { asyncSome } from "../../../utils/arrays"; import UIStore from "../../../stores/UIStore"; -import { createSpaceScopeHeader } from "../rooms/SpaceScopeHeader"; export interface IDevice extends Device { ambiguous?: boolean; @@ -1778,7 +1777,7 @@ const UserInfo: React.FC = ({ user, room, onClose, phase = RightPanelPha return ( { className="mx_MemberList" ariaLabelledBy="memberlist-panel-tab" role="tabpanel" - header={createSpaceScopeHeader(room)} hideHeaderButtons={this.props.hideHeaderButtons} footer={footer} onClose={this.props.onClose} diff --git a/src/components/views/rooms/SpaceScopeHeader.tsx b/src/components/views/rooms/SpaceScopeHeader.tsx deleted file mode 100644 index b9f53b7b8a..0000000000 --- a/src/components/views/rooms/SpaceScopeHeader.tsx +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright 2023 The Matrix.org Foundation C.I.C. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import React from "react"; -import { Room } from "matrix-js-sdk/src/matrix"; -import { Text } from "@vector-im/compound-web"; - -import RoomAvatar from "../avatars/RoomAvatar"; -import { useRoomName } from "../../../hooks/useRoomName"; - -/** - * Returns a space scope header if needed - * @param room The room object - * @returns rendered component if the room is a space room, otherwise returns null - */ -export function createSpaceScopeHeader(room?: Room | null): React.JSX.Element | null { - if (room?.isSpaceRoom()) return ; - else return null; -} - -/** - * Scope header used to decorate right panels that are scoped to a space. - * It renders room avatar and name. - */ -export const SpaceScopeHeader: React.FC<{ room: Room }> = ({ room }) => { - const roomName = useRoomName(room); - - return ( - - - {roomName} - - ); -}; diff --git a/src/components/views/rooms/ThirdPartyMemberInfo.tsx b/src/components/views/rooms/ThirdPartyMemberInfo.tsx index c2b772e78f..b510d5e002 100644 --- a/src/components/views/rooms/ThirdPartyMemberInfo.tsx +++ b/src/components/views/rooms/ThirdPartyMemberInfo.tsx @@ -28,7 +28,6 @@ import { Action } from "../../../dispatcher/actions"; import ErrorDialog from "../dialogs/ErrorDialog"; import BaseCard from "../right_panel/BaseCard"; import { Flex } from "../../utils/Flex"; -import { createSpaceScopeHeader } from "./SpaceScopeHeader"; interface IProps { event: MatrixEvent; @@ -134,7 +133,7 @@ export default class ThirdPartyMemberInfo extends React.Component + {/* same as userinfo name style */} diff --git a/test/components/views/right_panel/UserInfo-test.tsx b/test/components/views/right_panel/UserInfo-test.tsx index bc314e9e32..6875bf227d 100644 --- a/test/components/views/right_panel/UserInfo-test.tsx +++ b/test/components/views/right_panel/UserInfo-test.tsx @@ -302,15 +302,6 @@ describe("", () => { expect(screen.queryByTestId("space-header")).not.toBeInTheDocument(); }); - it("renders space header when room is a space room", () => { - const spaceRoom = { - ...mockRoom, - isSpaceRoom: jest.fn().mockReturnValue(true), - }; - renderComponent({ room: spaceRoom }); - expect(screen.getByTestId("space-header")).toBeInTheDocument(); - }); - it("renders encryption info panel without pending verification", () => { renderComponent({ phase: RightPanelPhases.EncryptionPanel, room: mockRoom }); expect(screen.getByRole("heading", { name: /encryption/i })).toBeInTheDocument();