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:
parent
35cf0e1c7e
commit
09ba74a851
1 changed files with 47 additions and 29 deletions
|
@ -31,6 +31,7 @@ import EventTile from "../rooms/EventTile";
|
||||||
import SearchBox from "../../structures/SearchBox";
|
import SearchBox from "../../structures/SearchBox";
|
||||||
import RoomAvatar from "../avatars/RoomAvatar";
|
import RoomAvatar from "../avatars/RoomAvatar";
|
||||||
import AccessibleButton from "../elements/AccessibleButton";
|
import AccessibleButton from "../elements/AccessibleButton";
|
||||||
|
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
|
||||||
import AutoHideScrollbar from "../../structures/AutoHideScrollbar";
|
import AutoHideScrollbar from "../../structures/AutoHideScrollbar";
|
||||||
import DMRoomMap from "../../../utils/DMRoomMap";
|
import DMRoomMap from "../../../utils/DMRoomMap";
|
||||||
import {RoomPermalinkCreator} from "../../../utils/permalinks/Permalinks";
|
import {RoomPermalinkCreator} from "../../../utils/permalinks/Permalinks";
|
||||||
|
@ -63,41 +64,58 @@ enum SendState {
|
||||||
const Entry: React.FC<IEntryProps> = ({ room, send }) => {
|
const Entry: React.FC<IEntryProps> = ({ room, send }) => {
|
||||||
const [sendState, setSendState] = useState<SendState>(SendState.CanSend);
|
const [sendState, setSendState] = useState<SendState>(SendState.CanSend);
|
||||||
|
|
||||||
let label;
|
let button;
|
||||||
let className;
|
if (room.maySendMessage()) {
|
||||||
if (sendState === SendState.CanSend) {
|
let label;
|
||||||
label = _t("Send");
|
let className;
|
||||||
className = "mx_ForwardList_canSend";
|
if (sendState === SendState.CanSend) {
|
||||||
} else if (sendState === SendState.Sending) {
|
label = _t("Send");
|
||||||
label = _t("Sending…");
|
className = "mx_ForwardList_canSend";
|
||||||
className = "mx_ForwardList_sending";
|
} else if (sendState === SendState.Sending) {
|
||||||
} else if (sendState === SendState.Sent) {
|
label = _t("Sending…");
|
||||||
label = _t("Sent");
|
className = "mx_ForwardList_sending";
|
||||||
className = "mx_ForwardList_sent";
|
} else if (sendState === SendState.Sent) {
|
||||||
|
label = _t("Sent");
|
||||||
|
className = "mx_ForwardList_sent";
|
||||||
|
} else {
|
||||||
|
label = _t("Failed to send");
|
||||||
|
className = "mx_ForwardList_sendFailed";
|
||||||
|
}
|
||||||
|
|
||||||
|
button =
|
||||||
|
<AccessibleButton
|
||||||
|
kind={sendState === SendState.Failed ? "danger_outline" : "primary_outline"}
|
||||||
|
className={className}
|
||||||
|
onClick={async () => {
|
||||||
|
setSendState(SendState.Sending);
|
||||||
|
try {
|
||||||
|
await send();
|
||||||
|
setSendState(SendState.Sent);
|
||||||
|
} catch (e) {
|
||||||
|
setSendState(SendState.Failed);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
disabled={sendState !== SendState.CanSend}
|
||||||
|
>
|
||||||
|
{ label }
|
||||||
|
</AccessibleButton>;
|
||||||
} else {
|
} else {
|
||||||
label = _t("Failed to send");
|
button =
|
||||||
className = "mx_ForwardList_sendFailed";
|
<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">
|
return <div className="mx_ForwardList_entry">
|
||||||
<RoomAvatar room={room} height={32} width={32} />
|
<RoomAvatar room={room} height={32} width={32} />
|
||||||
<span className="mx_ForwardList_entry_name">{ room.name }</span>
|
<span className="mx_ForwardList_entry_name">{ room.name }</span>
|
||||||
<AccessibleButton
|
{ button }
|
||||||
kind={sendState === SendState.Failed ? "danger_outline" : "primary_outline"}
|
|
||||||
className={className}
|
|
||||||
onClick={async () => {
|
|
||||||
setSendState(SendState.Sending);
|
|
||||||
try {
|
|
||||||
await send();
|
|
||||||
setSendState(SendState.Sent);
|
|
||||||
} catch (e) {
|
|
||||||
setSendState(SendState.Failed);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
disabled={sendState !== SendState.CanSend}
|
|
||||||
>
|
|
||||||
{ label }
|
|
||||||
</AccessibleButton>
|
|
||||||
</div>;
|
</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue