mirror of https://github.com/vector-im/riot-web
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>pull/21833/head
parent
35cf0e1c7e
commit
09ba74a851
|
@ -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>;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue