Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tooltip to disabled invite button due to lack of permissions #10869

Merged
merged 1 commit into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading