Skip to content

Commit

Permalink
TCHAP: hide access settings on DM room
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcWadai committed Jan 9, 2025
1 parent c79bddd commit 0edc02d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
6 changes: 6 additions & 0 deletions patches/tchap-modifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
5 changes: 2 additions & 3 deletions res/themes/tchap-common/css/_tchap_custom.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -251,7 +253,12 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt

private renderJoinRule(): JSX.Element {
const room = this.props.room;

// :TCHAP: hide-access-settings-dm
const isDm = DMRoomMap.shared().getUserIdForRoomId(room.roomId);
if (isDm) {
return <></>;
}
// end :TCHAP:
let aliasWarning: JSX.Element | undefined;
/* :TCHAP: disable-access-options - remove
if (room.getJoinRule() === JoinRule.Public && !this.state.hasAliases) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("<SecurityRoomSettingsTab />", () => {
const userId = "@alice:server.org";
Expand Down Expand Up @@ -77,6 +78,7 @@ describe("<SecurityRoomSettingsTab />", () => {
jest.spyOn(client.getCrypto()!, "isEncryptionEnabledInRoom").mockResolvedValue(false);
client.getClientWellKnown.mockReturnValue(undefined);
jest.spyOn(SettingsStore, "getValue").mockRestore();
DMRoomMap.makeShared(client);

await clearAllModals();
});
Expand All @@ -102,4 +104,27 @@ describe("<SecurityRoomSettingsTab />", () => {
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();
});
});
});

0 comments on commit 0edc02d

Please sign in to comment.