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

Allow options to cascade kicks/bans throughout spaces #6829

Merged
merged 10 commits into from
Oct 14, 2021
11 changes: 2 additions & 9 deletions src/components/views/dialogs/ConfirmSpaceUserActionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ limitations under the License.
*/

import React, { ComponentProps, useMemo, useState } from 'react';

import ConfirmUserActionDialog from "./ConfirmUserActionDialog";
import SpaceStore from "../../../stores/SpaceStore";
import { Room } from "matrix-js-sdk/src/models/room";
import SpaceChildrenPicker from "../spaces/SpaceChildrenPicker";
import { _t } from '../../../languageHandler';

type BaseProps = ComponentProps<typeof ConfirmUserActionDialog>;
interface IProps extends Omit<BaseProps, "groupMember" | "matrixClient" | "children" | "onFinished"> {
Expand Down Expand Up @@ -54,14 +54,7 @@ const ConfirmSpaceUserActionDialog: React.FC<IProps> = ({
const selectedRooms = useMemo(() => new Set(roomsToLeave), [roomsToLeave]);

let warning: JSX.Element;
if (!spaceChildren.length) {
warning = <div className="mx_ConfirmSpaceUserActionDialog_warning">
{ _t("You’re not an admin of anything they’re a member of in <SpaceName/>, " +
"so banning won’t remove them from any rooms or spaces in <SpaceName/>.", {}, {
SpaceName: () => <b>{ space.name }</b>,
}) }
</div>;
} else if (warningMessage) {
if (warningMessage) {
warning = <div className="mx_ConfirmSpaceUserActionDialog_warning">
{ warningMessage }
</div>;
Expand Down
44 changes: 9 additions & 35 deletions src/components/views/right_panel/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -541,29 +541,16 @@ const RoomKickButton = ({ room, member, startUpdating, stopUpdating }: Omit<IBas
if (member.membership !== "invite" && member.membership !== "join") return null;

const onKick = async () => {
let title: string;
if (room.isSpaceRoom()) {
if (member.membership === "invite") {
title = _t("Disinvite this user from %(spaceName)s?", { spaceName: room.name });
} else {
title = _t("Kick this user from %(spaceName)s?", { spaceName: room.name });
}
} else {
if (member.membership === "invite") {
title = _t("Disinvite this user?");
} else {
title = _t("Kick this user?");
}
}

const { finished } = Modal.createTrackedDialog(
'Confirm User Action Dialog',
'onKick',
room.isSpaceRoom() ? ConfirmSpaceUserActionDialog : ConfirmUserActionDialog,
{
member,
action: member.membership === "invite" ? _t("Disinvite") : _t("Kick"),
title,
title: member.membership === "invite"
? _t("Disinvite from %(roomName)s", { roomName: room.name })
: _t("Kick from %(roomName)s", { roomName: room.name }),
askReason: member.membership === "join",
danger: true,
// space-specific props
Expand All @@ -579,7 +566,7 @@ const RoomKickButton = ({ room, member, startUpdating, stopUpdating }: Omit<IBas
allLabel: _t("Kick them from everything I'm able to"),
specificLabel: _t("Kick them from specific things I'm able to"),
warningMessage: _t("If you're not an admin of a room or space in <SpaceName/>, " +
"they'll still be able to access it after you kick them.", {}, {
"they'll still be able to access whatever you're not an admin of.", {}, {
SpaceName: () => <b>{ room.name }</b>,
}),
},
Expand Down Expand Up @@ -696,29 +683,16 @@ const BanToggleButton = ({ room, member, startUpdating, stopUpdating }: Omit<IBa

const isBanned = member.membership === "ban";
const onBanOrUnban = async () => {
let title: string;
if (room.isSpaceRoom()) {
if (isBanned) {
title = _t("Unban this user from %(spaceName)s?", { spaceName: room.name });
} else {
title = _t("Ban this user from %(spaceName)s?", { spaceName: room.name });
}
} else {
if (isBanned) {
title = _t("Unban this user?");
} else {
title = _t("Ban this user?");
}
}

const { finished } = Modal.createTrackedDialog(
'Confirm User Action Dialog',
'onBanOrUnban',
room.isSpaceRoom() ? ConfirmSpaceUserActionDialog : ConfirmUserActionDialog,
{
member,
action: isBanned ? _t("Unban") : _t("Ban"),
title,
title: isBanned
? _t("Unban from %(roomName)s", { roomName: room.name })
: _t("Ban from %(roomName)s", { roomName: room.name }),
askReason: !isBanned,
danger: !isBanned,
// space-specific props
Expand Down Expand Up @@ -748,11 +722,11 @@ const BanToggleButton = ({ room, member, startUpdating, stopUpdating }: Omit<IBa
: _t("Ban them from specific things I'm able to"),
warningMessage: isBanned
? _t("If you’re not an admin of a room or space in <SpaceName/>, " +
"they wont be unbanned from it.", {}, {
"they still won't be able to access whatever you're not an admin of.", {}, {
SpaceName: () => <b>{ room.name }</b>,
})
: _t("If you're not an admin of a room or space in <SpaceName/>, " +
"they'll still be able to access it after you ban them.", {}, {
"they'll still be able to access whatever you're not an admin of.", {}, {
SpaceName: () => <b>{ room.name }</b>,
}),
},
Expand Down
18 changes: 6 additions & 12 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1845,15 +1845,13 @@
"You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the space it will be impossible to regain privileges.": "You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the space it will be impossible to regain privileges.",
"You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the room it will be impossible to regain privileges.": "You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the room it will be impossible to regain privileges.",
"Demote": "Demote",
"Disinvite this user from %(spaceName)s?": "Disinvite this user from %(spaceName)s?",
"Kick this user from %(spaceName)s?": "Kick this user from %(spaceName)s?",
"Disinvite this user?": "Disinvite this user?",
"Kick this user?": "Kick this user?",
"Disinvite": "Disinvite",
"Kick": "Kick",
"Disinvite from %(roomName)s": "Disinvite from %(roomName)s",
"Kick from %(roomName)s": "Kick from %(roomName)s",
"Kick them from everything I'm able to": "Kick them from everything I'm able to",
"Kick them from specific things I'm able to": "Kick them from specific things I'm able to",
"If you're not an admin of a room or space in <SpaceName/>, they'll still be able to access it after you kick them.": "If you're not an admin of a room or space in <SpaceName/>, they'll still be able to access it after you kick them.",
"If you're not an admin of a room or space in <SpaceName/>, they'll still be able to access whatever you're not an admin of.": "If you're not an admin of a room or space in <SpaceName/>, they'll still be able to access whatever you're not an admin of.",
"Failed to kick": "Failed to kick",
"No recent messages by %(user)s found": "No recent messages by %(user)s found",
"Try scrolling up in the timeline to see if there are any earlier ones.": "Try scrolling up in the timeline to see if there are any earlier ones.",
Expand All @@ -1864,17 +1862,14 @@
"Remove %(count)s messages|other": "Remove %(count)s messages",
"Remove %(count)s messages|one": "Remove 1 message",
"Remove recent messages": "Remove recent messages",
"Unban this user from %(spaceName)s?": "Unban this user from %(spaceName)s?",
"Ban this user from %(spaceName)s?": "Ban this user from %(spaceName)s?",
"Unban this user?": "Unban this user?",
"Ban this user?": "Ban this user?",
"Ban": "Ban",
"Unban from %(roomName)s": "Unban from %(roomName)s",
"Ban from %(roomName)s": "Ban from %(roomName)s",
"Unban them from everything I'm able to": "Unban them from everything I'm able to",
"Ban them from everything I'm able to": "Ban them from everything I'm able to",
"Unban them from specific things I'm able to": "Unban them from specific things I'm able to",
"Ban them from specific things I'm able to": "Ban them from specific things I'm able to",
"If you’re not an admin of a room or space in <SpaceName/>, they won’t be unbanned from it.": "If you’re not an admin of a room or space in <SpaceName/>, they won’t be unbanned from it.",
"If you're not an admin of a room or space in <SpaceName/>, they'll still be able to access it after you ban them.": "If you're not an admin of a room or space in <SpaceName/>, they'll still be able to access it after you ban them.",
"If you’re not an admin of a room or space in <SpaceName/>, they still won't be able to access whatever you're not an admin of.": "If you’re not an admin of a room or space in <SpaceName/>, they still won't be able to access whatever you're not an admin of.",
"Failed to ban user": "Failed to ban user",
"Failed to mute user": "Failed to mute user",
"Unmute": "Unmute",
Expand Down Expand Up @@ -2233,7 +2228,6 @@
"Confirm Removal": "Confirm Removal",
"Are you sure you wish to remove (delete) this event? Note that if you delete a room name or topic change, it could undo the change.": "Are you sure you wish to remove (delete) this event? Note that if you delete a room name or topic change, it could undo the change.",
"Reason (optional)": "Reason (optional)",
"You’re not an admin of anything they’re a member of in <SpaceName/>, so banning won’t remove them from any rooms or spaces in <SpaceName/>.": "You’re not an admin of anything they’re a member of in <SpaceName/>, so banning won’t remove them from any rooms or spaces in <SpaceName/>.",
"Clear all data in this session?": "Clear all data in this session?",
"Clearing all data from this session is permanent. Encrypted messages will be lost unless their keys have been backed up.": "Clearing all data from this session is permanent. Encrypted messages will be lost unless their keys have been backed up.",
"Clear all data": "Clear all data",
Expand Down