You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-05 23:10:41 +03:00
Disable forward buttons for rooms without send permissions
…and add a tooltip to explain why they can't accept forwarded messages. It was chosen to disable the buttons rather than hide the entries from the list, since hiding them without explanation could cause confusion. Signed-off-by: Robin Townsend <robin@robin.town>
This commit is contained in:
@@ -31,6 +31,7 @@ import EventTile from "../rooms/EventTile";
|
||||
import SearchBox from "../../structures/SearchBox";
|
||||
import RoomAvatar from "../avatars/RoomAvatar";
|
||||
import AccessibleButton from "../elements/AccessibleButton";
|
||||
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
|
||||
import AutoHideScrollbar from "../../structures/AutoHideScrollbar";
|
||||
import DMRoomMap from "../../../utils/DMRoomMap";
|
||||
import {RoomPermalinkCreator} from "../../../utils/permalinks/Permalinks";
|
||||
@@ -63,6 +64,8 @@ enum SendState {
|
||||
const Entry: React.FC<IEntryProps> = ({ room, send }) => {
|
||||
const [sendState, setSendState] = useState<SendState>(SendState.CanSend);
|
||||
|
||||
let button;
|
||||
if (room.maySendMessage()) {
|
||||
let label;
|
||||
let className;
|
||||
if (sendState === SendState.CanSend) {
|
||||
@@ -79,9 +82,7 @@ const Entry: React.FC<IEntryProps> = ({ room, send }) => {
|
||||
className = "mx_ForwardList_sendFailed";
|
||||
}
|
||||
|
||||
return <div className="mx_ForwardList_entry">
|
||||
<RoomAvatar room={room} height={32} width={32} />
|
||||
<span className="mx_ForwardList_entry_name">{ room.name }</span>
|
||||
button =
|
||||
<AccessibleButton
|
||||
kind={sendState === SendState.Failed ? "danger_outline" : "primary_outline"}
|
||||
className={className}
|
||||
@@ -97,7 +98,24 @@ const Entry: React.FC<IEntryProps> = ({ room, send }) => {
|
||||
disabled={sendState !== SendState.CanSend}
|
||||
>
|
||||
{ label }
|
||||
</AccessibleButton>
|
||||
</AccessibleButton>;
|
||||
} else {
|
||||
button =
|
||||
<AccessibleTooltipButton
|
||||
kind="primary_outline"
|
||||
className={"mx_ForwardList_canSend"}
|
||||
onClick={() => {}}
|
||||
disabled={true}
|
||||
title={_t("You do not have permission to post to this room")}
|
||||
>
|
||||
{ _t("Send") }
|
||||
</AccessibleTooltipButton>;
|
||||
}
|
||||
|
||||
return <div className="mx_ForwardList_entry">
|
||||
<RoomAvatar room={room} height={32} width={32} />
|
||||
<span className="mx_ForwardList_entry_name">{ room.name }</span>
|
||||
{ button }
|
||||
</div>;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user