Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Notify users about denied access on ask-to-join rooms (#11480)
Browse files Browse the repository at this point in the history
* Implement denied request mask and logic

Signed-off-by: AHMAD KADRI <[email protected]>

* refactor / fix deny requests isues

* fix tests create denied message test

Signed-off-by: AHMAD KADRI <[email protected]>

* add another test for the primary action for denied request

Signed-off-by: AHMAD KADRI <[email protected]>

* fix linter issues

Signed-off-by: nurjinn jafar <[email protected]>

* regenerate translation

Signed-off-by: nurjinn jafar <[email protected]>

* fix translation and minor refactoring
Signed-off-by: nurjinn jafar <[email protected]>

* segment into 4

* Remove parallel from Cypress command to avoid talking to Cypress Cloud

* Re-add --parallel flag for Percy

* Prevent event propagation when clicking icon buttons (#11515)

* Prevent event propagation when clicking icon buttons

* Inhibit view user on click behaviour for room header face pile

* Update snapshot

* Add a 'm.relates_to' to edits in receipt tests and disable failing tests (#11501)

* Add a 'm.relates_to' to edits in receipt tests

* Disable a test that fails with real edits

* Wait for the room to be read after we mark it as read

* Skip tests that are failing because of inconsistencies between local and CI behaviour

* Allow creating public knock rooms (#11481)

* Allow creating public knock rooms

Signed-off-by: Charly Nguyen <[email protected]>

* Apply PR feedback

Signed-off-by: Charly Nguyen <[email protected]>

* Apply PR feedback

Signed-off-by: Charly Nguyen <[email protected]>

---------

Signed-off-by: Charly Nguyen <[email protected]>

* Collect `console.debug` logs during cypress tests (#11478)

In order for the logs collected by cypress to actually be useful, we really
need `cons:debug`.

* Migrate more strings to translation keys (#11522)

* Only show Search button in RoomSummaryCard if new room UI enabled (#11524)

* Only show Search button in RoomSummaryCard if new room UI enabled

* Update snapshot

* Update vector-im (#11526)

* Update vector-im

* Update snapshots of Compound Avatars

* Update snapshots of Compound Avatars

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Telatynski <[email protected]>

* Migrate more strings to translation keys (#11530)

* Fix regression around FacePile with overflow (#11527)

* Work around compound-web AvatarStack not applying overlap to non-Avatars

* Fix FacePile overflow tile not being layed out correctly

* Use RoomStateEvent.Update for knocks (#11516)

Signed-off-by: Charly Nguyen <[email protected]>

* Cypress tests for event shields (#11525)

* Factor downloadKey out to `utils.ts`

* Add a new `describe` block for event shields

* create a beforeEach block

* Cypress tests for event shields

* Document how to match the CI config for Cypress (#11531)

* Document how to match the CI config for Cypress

* Clarify language about needing Chrome

* Move Cypress info into the Cypress-specific docs

* Migrate more strings to translation keys (#11532)

---------

Signed-off-by: AHMAD KADRI <[email protected]>
Signed-off-by: nurjinn jafar <[email protected]>
Signed-off-by: Charly Nguyen <[email protected]>
Co-authored-by: AHMAD KADRI <[email protected]>
Co-authored-by: Kerry Archibald <[email protected]>
Co-authored-by: Andy Balaam <[email protected]>
Co-authored-by: Johannes Marbach <[email protected]>
Co-authored-by: Germain <[email protected]>
Co-authored-by: Charly Nguyen <[email protected]>
Co-authored-by: Richard van der Hoff <[email protected]>
Co-authored-by: Michael Telatynski <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
10 people authored Sep 7, 2023
1 parent 36a7a96 commit ce96853
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/structures/RoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2205,6 +2205,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
knocked={myMembership === "knock" || this.state.knocked}
onSubmitAskToJoin={this.onSubmitAskToJoin}
onCancelAskToJoin={this.onCancelAskToJoin}
onForgetClick={this.onForgetClick}
/>
</ErrorBoundary>
</div>
Expand Down
20 changes: 20 additions & 0 deletions src/components/views/rooms/RoomPreviewBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ enum MessageCase {
OtherError = "OtherError",
PromptAskToJoin = "PromptAskToJoin",
Knocked = "Knocked",
RequestDenied = "requestDenied",
}

interface IProps {
Expand Down Expand Up @@ -188,7 +189,11 @@ export default class RoomPreviewBar extends React.Component<IProps, IState> {
const myMember = this.getMyMember();

if (myMember) {
const previousMembership = myMember.events.member?.getPrevContent().membership;
if (myMember.isKicked()) {
if (previousMembership === "knock") {
return MessageCase.RequestDenied;
}
return MessageCase.Kicked;
} else if (myMember.membership === "ban") {
return MessageCase.Banned;
Expand Down Expand Up @@ -397,6 +402,21 @@ export default class RoomPreviewBar extends React.Component<IProps, IState> {
}
break;
}
case MessageCase.RequestDenied: {
title = _t("You have been denied access");

subTitle = _t(
"As you have been denied access, you cannot rejoin unless you are invited by the admin or moderator of the group.",
);

if (isSpace) {
primaryActionLabel = _t("Forget this space");
} else {
primaryActionLabel = _t("Forget this room");
}
primaryActionHandler = this.props.onForgetClick;
break;
}
case MessageCase.Banned: {
const { memberName, reason } = this.getKickOrBanInfo();
if (roomName) {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2150,6 +2150,8 @@
"Forget this space": "Forget this space",
"Forget this room": "Forget this room",
"Re-join": "Re-join",
"You have been denied access": "You have been denied access",
"As you have been denied access, you cannot rejoin unless you are invited by the admin or moderator of the group.": "As you have been denied access, you cannot rejoin unless you are invited by the admin or moderator of the group.",
"You were banned from %(roomName)s by %(memberName)s": "You were banned from %(roomName)s by %(memberName)s",
"You were banned by %(memberName)s": "You were banned by %(memberName)s",
"Something went wrong with your invite to %(roomName)s": "Something went wrong with your invite to %(roomName)s",
Expand Down
30 changes: 28 additions & 2 deletions test/components/views/rooms/RoomPreviewBar-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,27 @@ const makeMockRoomMember = ({
membership,
content,
memberContent,
oldMembership,
}: {
userId?: string;
isKicked?: boolean;
membership?: "invite" | "ban";
membership?: "invite" | "ban" | "leave";
content?: Partial<IContent>;
memberContent?: Partial<IContent>;
oldMembership?: "join" | "knock";
}) =>
({
userId,
rawDisplayName: `${userId} name`,
isKicked: jest.fn().mockReturnValue(!!isKicked),
getContent: jest.fn().mockReturnValue(content || {}),
getPrevContent: jest.fn().mockReturnValue(content || {}),
membership,
events: {
member: {
getSender: jest.fn().mockReturnValue("@kicker:test.com"),
getContent: jest.fn().mockReturnValue({ reason: "test reason", ...memberContent }),
getPrevContent: jest.fn().mockReturnValue({ membership: oldMembership, ...memberContent }),
},
},
} as unknown as RoomMember);
Expand Down Expand Up @@ -168,11 +172,33 @@ describe("<RoomPreviewBar />", () => {
it("renders kicked message", () => {
const room = createRoom(roomId, otherUserId);
jest.spyOn(room, "getMember").mockReturnValue(makeMockRoomMember({ isKicked: true }));
const component = getComponent({ loading: true, room });
const component = getComponent({ room, promptAskToJoin: true });

expect(getMessage(component)).toMatchSnapshot();
});

it("renders denied request message", () => {
const room = createRoom(roomId, otherUserId);
jest.spyOn(room, "getMember").mockReturnValue(
makeMockRoomMember({ isKicked: true, membership: "leave", oldMembership: "knock" }),
);
const component = getComponent({ room, promptAskToJoin: true });

expect(getMessage(component)).toMatchSnapshot();
});

it("triggers the primary action callback for denied request", () => {
const onForgetClick = jest.fn();
const room = createRoom(roomId, otherUserId);
jest.spyOn(room, "getMember").mockReturnValue(
makeMockRoomMember({ isKicked: true, membership: "leave", oldMembership: "knock" }),
);
const component = getComponent({ room, promptAskToJoin: true, onForgetClick });

fireEvent.click(getPrimaryActionButton(component)!);
expect(onForgetClick).toHaveBeenCalled();
});

it("renders banned message", () => {
const room = createRoom(roomId, otherUserId);
jest.spyOn(room, "getMember").mockReturnValue(makeMockRoomMember({ membership: "ban" }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ exports[`<RoomPreviewBar /> renders banned message 1`] = `
</div>
`;

exports[`<RoomPreviewBar /> renders denied request message 1`] = `
<div
class="mx_RoomPreviewBar_message"
>
<h3>
You have been denied access
</h3>
<p>
As you have been denied access, you cannot rejoin unless you are invited by the admin or moderator of the group.
</p>
</div>
`;

exports[`<RoomPreviewBar /> renders kicked message 1`] = `
<div
class="mx_RoomPreviewBar_message"
Expand Down

0 comments on commit ce96853

Please sign in to comment.