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

Commit

Permalink
Add tooltip to disabled invite button due to lack of permissions (#10869
Browse files Browse the repository at this point in the history
)
  • Loading branch information
t3chguy authored and richvdh committed May 12, 2023
1 parent 38454f4 commit 7823234
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/components/views/rooms/MemberList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { shouldShowComponent } from "../../../customisations/helpers/UIComponent
import { UIComponent } from "../../../settings/UIFeature";
import PosthogTrackers from "../../../PosthogTrackers";
import { SDKContext } from "../../../contexts/SDKContext";
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";

const INITIAL_LOAD_NUM_MEMBERS = 30;
const INITIAL_LOAD_NUM_INVITED = 5;
Expand Down Expand Up @@ -349,23 +350,32 @@ export default class MemberList extends React.Component<IProps, IState> {

const cli = MatrixClientPeg.get();
const room = cli.getRoom(this.props.roomId);
let inviteButton;
let inviteButton: JSX.Element | undefined;

if (room?.getMyMembership() === "join" && shouldShowComponent(UIComponent.InviteUsers)) {
let inviteButtonText = _t("Invite to this room");
if (room.isSpaceRoom()) {
inviteButtonText = _t("Invite to this space");
}

inviteButton = (
<AccessibleButton
className="mx_MemberList_invite"
onClick={this.onInviteButtonClick}
disabled={!this.state.canInvite}
>
<span>{inviteButtonText}</span>
</AccessibleButton>
);
if (this.state.canInvite) {
inviteButton = (
<AccessibleButton className="mx_MemberList_invite" onClick={this.onInviteButtonClick}>
<span>{inviteButtonText}</span>
</AccessibleButton>
);
} else {
inviteButton = (
<AccessibleTooltipButton
className="mx_MemberList_invite"
onClick={null}
disabled
tooltip={_t("You do not have permission to invite users")}
>
<span>{inviteButtonText}</span>
</AccessibleTooltipButton>
);
}
}

let invitedHeader;
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1947,6 +1947,7 @@
"and %(count)s others...|one": "and one other...",
"Invite to this room": "Invite to this room",
"Invite to this space": "Invite to this space",
"You do not have permission to invite users": "You do not have permission to invite users",
"Invited": "Invited",
"Filter room members": "Filter room members",
"%(userName)s (power %(powerLevelNumber)s)": "%(userName)s (power %(powerLevelNumber)s)",
Expand Down

0 comments on commit 7823234

Please sign in to comment.