mirror of https://github.com/vector-im/riot-web
Merge pull request #5220 from matrix-org/t3chguy/fix/15202
Clean up UserInfo to not show a blank Power Selector for users not in roompull/21833/head
commit
4d15a44d61
|
@ -952,30 +952,26 @@ function useRoomPermissions(cli, room, user) {
|
||||||
|
|
||||||
const PowerLevelSection = ({user, room, roomPermissions, powerLevels}) => {
|
const PowerLevelSection = ({user, room, roomPermissions, powerLevels}) => {
|
||||||
const [isEditing, setEditing] = useState(false);
|
const [isEditing, setEditing] = useState(false);
|
||||||
if (room && user.roomId) { // is in room
|
if (isEditing) {
|
||||||
if (isEditing) {
|
return (<PowerLevelEditor
|
||||||
return (<PowerLevelEditor
|
user={user} room={room} roomPermissions={roomPermissions}
|
||||||
user={user} room={room} roomPermissions={roomPermissions}
|
onFinished={() => setEditing(false)} />);
|
||||||
onFinished={() => setEditing(false)} />);
|
|
||||||
} else {
|
|
||||||
const IconButton = sdk.getComponent('elements.IconButton');
|
|
||||||
const powerLevelUsersDefault = powerLevels.users_default || 0;
|
|
||||||
const powerLevel = parseInt(user.powerLevel, 10);
|
|
||||||
const modifyButton = roomPermissions.canEdit ?
|
|
||||||
(<IconButton icon="edit" onClick={() => setEditing(true)} />) : null;
|
|
||||||
const role = textualPowerLevel(powerLevel, powerLevelUsersDefault);
|
|
||||||
const label = _t("<strong>%(role)s</strong> in %(roomName)s",
|
|
||||||
{role, roomName: room.name},
|
|
||||||
{strong: label => <strong>{label}</strong>},
|
|
||||||
);
|
|
||||||
return (
|
|
||||||
<div className="mx_UserInfo_profileField">
|
|
||||||
<div className="mx_UserInfo_roleDescription">{label}{modifyButton}</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
const IconButton = sdk.getComponent('elements.IconButton');
|
||||||
|
const powerLevelUsersDefault = powerLevels.users_default || 0;
|
||||||
|
const powerLevel = parseInt(user.powerLevel, 10);
|
||||||
|
const modifyButton = roomPermissions.canEdit ?
|
||||||
|
(<IconButton icon="edit" onClick={() => setEditing(true)} />) : null;
|
||||||
|
const role = textualPowerLevel(powerLevel, powerLevelUsersDefault);
|
||||||
|
const label = _t("<strong>%(role)s</strong> in %(roomName)s",
|
||||||
|
{role, roomName: room.name},
|
||||||
|
{strong: label => <strong>{label}</strong>},
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<div className="mx_UserInfo_profileField">
|
||||||
|
<div className="mx_UserInfo_roleDescription">{label}{modifyButton}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1268,14 +1264,15 @@ const BasicUserInfo = ({room, member, groupId, devices, isRoomEncrypted}) => {
|
||||||
spinner = <Loader imgClassName="mx_ContextualMenu_spinner" />;
|
spinner = <Loader imgClassName="mx_ContextualMenu_spinner" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const memberDetails = (
|
let memberDetails;
|
||||||
<PowerLevelSection
|
if (room && member.roomId) {
|
||||||
|
memberDetails = <PowerLevelSection
|
||||||
powerLevels={powerLevels}
|
powerLevels={powerLevels}
|
||||||
user={member}
|
user={member}
|
||||||
room={room}
|
room={room}
|
||||||
roomPermissions={roomPermissions}
|
roomPermissions={roomPermissions}
|
||||||
/>
|
/>;
|
||||||
);
|
}
|
||||||
|
|
||||||
// only display the devices list if our client supports E2E
|
// only display the devices list if our client supports E2E
|
||||||
const cryptoEnabled = cli.isCryptoEnabled();
|
const cryptoEnabled = cli.isCryptoEnabled();
|
||||||
|
|
Loading…
Reference in New Issue