From 0edc02dfa0a4cd9a1bd71cd0fb6db2e84c35b484 Mon Sep 17 00:00:00 2001 From: "marc.sirisak" Date: Thu, 9 Jan 2025 16:38:47 +0100 Subject: [PATCH] TCHAP: hide access settings on DM room --- patches/tchap-modifications.json | 6 +++++ .../tchap-common/css/_tchap_custom.pcss | 5 ++-- .../tabs/room/SecurityRoomSettingsTab.tsx | 9 ++++++- .../settings/SecurityRoomSettingsTab-test.tsx | 25 +++++++++++++++++++ 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/patches/tchap-modifications.json b/patches/tchap-modifications.json index 12fb24240f..94be72dd81 100644 --- a/patches/tchap-modifications.json +++ b/patches/tchap-modifications.json @@ -180,5 +180,11 @@ "src/components/views/auth/AuthPage.tsx", "src/vector/index.html" ] + }, + "hide-access-settings-dm": { + "issue": "https://github.com/tchapgouv/tchap-web-v4/issues/1210", + "files": [ + "src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx" + ] } } \ No newline at end of file diff --git a/res/themes/tchap-common/css/_tchap_custom.pcss b/res/themes/tchap-common/css/_tchap_custom.pcss index 35b206fb90..e0e6ab5594 100644 --- a/res/themes/tchap-common/css/_tchap_custom.pcss +++ b/res/themes/tchap-common/css/_tchap_custom.pcss @@ -64,9 +64,8 @@ } /* since we added a header in welcome pages, we need to add this margin for the footer */ -.mx_AuthPage_modal { - margin-bottom: 25px; - margin-top: 40px !important; +.mx_AuthFooter { + margin-top: 25px !important; } .mx_ThreadsActivityCentreButton .mx_ThreadsActivityCentreButton_Icon, diff --git a/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx b/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx index b279e5f356..3a1cc8fa37 100644 --- a/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx +++ b/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx @@ -45,6 +45,8 @@ import { shouldForceDisableEncryption } from "../../../../../utils/crypto/should import { Caption } from "../../../typography/Caption"; import { MEGOLM_ENCRYPTION_ALGORITHM } from "../../../../../utils/crypto"; +import DMRoomMap from "~tchap-web/src/utils/DMRoomMap"; // :TCHAP: hide-access-settings-dm + interface IProps { room: Room; closeSettingsFn: () => void; @@ -251,7 +253,12 @@ export default class SecurityRoomSettingsTab extends React.Component; + } + // end :TCHAP: let aliasWarning: JSX.Element | undefined; /* :TCHAP: disable-access-options - remove if (room.getJoinRule() === JoinRule.Public && !this.state.hasAliases) { diff --git a/test/unit-tests/tchap/components/views/settings/SecurityRoomSettingsTab-test.tsx b/test/unit-tests/tchap/components/views/settings/SecurityRoomSettingsTab-test.tsx index 8a1efcb9dc..2d22f844bf 100644 --- a/test/unit-tests/tchap/components/views/settings/SecurityRoomSettingsTab-test.tsx +++ b/test/unit-tests/tchap/components/views/settings/SecurityRoomSettingsTab-test.tsx @@ -16,6 +16,7 @@ import MatrixClientContext from "~tchap-web/src/contexts/MatrixClientContext"; import SettingsStore from "~tchap-web/src/settings/SettingsStore"; import { clearAllModals, stubClient } from "~tchap-web/test/test-utils"; import { filterBoolean } from "~tchap-web/src/utils/arrays"; +import DMRoomMap from "~tchap-web/src/utils/DMRoomMap"; describe("", () => { const userId = "@alice:server.org"; @@ -77,6 +78,7 @@ describe("", () => { jest.spyOn(client.getCrypto()!, "isEncryptionEnabledInRoom").mockResolvedValue(false); client.getClientWellKnown.mockReturnValue(undefined); jest.spyOn(SettingsStore, "getValue").mockRestore(); + DMRoomMap.makeShared(client); await clearAllModals(); }); @@ -102,4 +104,27 @@ describe("", () => { expect(screen.getByDisplayValue(HistoryVisibility.Shared)).toBeChecked(); }); }); + + describe("access settings", () => { + it("should render access settings if not dm room", () => { + const room = new Room(roomId, client, userId); + setRoomStateEvents(room); + + getComponent(room); + + expect(screen.queryByText("Access")).toBeInTheDocument(); + }); + + it("should render access settings if dm room", () => { + const room = new Room(roomId, client, userId); + + jest.spyOn(DMRoomMap.shared(), "getUserIdForRoomId").mockReturnValue("userB"); + + setRoomStateEvents(room); + + getComponent(room); + + expect(screen.queryByText("Access")).not.toBeInTheDocument(); + }); + }); });