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

Fix text link buttons on UserInfo panel #8247

Merged
merged 10 commits into from
May 2, 2022
27 changes: 14 additions & 13 deletions res/css/views/right_panel/_UserInfo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ limitations under the License.

.mx_UserInfo_container {
padding: 8px 16px;

luixxiul marked this conversation as resolved.
Show resolved Hide resolved
.mx_UserInfo_container_verifyButton {
margin-top: $spacing-8;
}
}

.mx_UserInfo_separator {
Expand Down Expand Up @@ -193,10 +197,7 @@ limitations under the License.
}

.mx_UserInfo_field {
cursor: pointer;
color: $accent;
line-height: $font-16px;
margin: 8px 0;

&.mx_UserInfo_destructive {
color: $alert;
Expand Down Expand Up @@ -228,14 +229,18 @@ limitations under the License.
padding-bottom: 0;

> :not(h3) {
margin-left: 8px;
margin-inline-start: $spacing-8;
display: flex;
flex-flow: column;
align-items: flex-start;
row-gap: $spacing-8;
}
}

.mx_UserInfo_devices {
.mx_UserInfo_device {
display: flex;
margin: 8px 0;
margin: $spacing-8 0;

&.mx_UserInfo_device_verified {
.mx_UserInfo_device_trusted {
Expand All @@ -250,7 +255,7 @@ limitations under the License.

.mx_UserInfo_device_name {
flex: 1;
margin-right: 5px;
margin: 0 5px;
word-break: break-word;
}
}
Expand All @@ -259,20 +264,16 @@ limitations under the License.
.mx_E2EIcon {
// don't squeeze
flex: 0 0 auto;
margin: 2px 5px 0 0;
margin: 0;
width: 12px;
height: 12px;
}

.mx_UserInfo_expand {
display: flex;
margin-top: 11px;
column-gap: 5px; // cf: mx_UserInfo_device_name
margin-bottom: 11px;
}
}

.mx_AccessibleButton.mx_AccessibleButton_hasKind {
padding: 8px 18px;
}
}

.mx_UserInfo.mx_UserInfo_smallAvatar {
Expand Down
70 changes: 57 additions & 13 deletions src/components/views/right_panel/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,17 @@ function DevicesSection({ devices, userId, loading }: { devices: IDevice[], user
let expandButton;
if (expandSectionDevices.length) {
if (isExpanded) {
expandButton = (<AccessibleButton className="mx_UserInfo_expand mx_linkButton"
expandButton = (<AccessibleButton
kind="link"
className="mx_UserInfo_expand"
onClick={() => setExpanded(false)}
>
<div>{ expandHideCaption }</div>
</AccessibleButton>);
} else {
expandButton = (<AccessibleButton className="mx_UserInfo_expand mx_linkButton"
expandButton = (<AccessibleButton
kind="link"
luixxiul marked this conversation as resolved.
Show resolved Hide resolved
className="mx_UserInfo_expand"
onClick={() => setExpanded(true)}
>
<div className={expandIconClasses} />
Expand Down Expand Up @@ -331,6 +335,7 @@ const MessageButton = ({ userId }: { userId: string }) => {

return (
<AccessibleButton
kind="link"
onClick={async (ev) => {
if (busy) return;
setBusy(true);
Expand Down Expand Up @@ -383,6 +388,7 @@ const UserOptionsSection: React.FC<{

ignoreButton = (
<AccessibleButton
kind="link"
onClick={onIgnoreToggle}
className={classNames("mx_UserInfo_field", { mx_UserInfo_destructive: !isIgnored })}
>
Expand Down Expand Up @@ -413,14 +419,22 @@ const UserOptionsSection: React.FC<{
const room = cli.getRoom(member.roomId);
if (room?.getEventReadUpTo(member.userId)) {
readReceiptButton = (
<AccessibleButton onClick={onReadReceiptButton} className="mx_UserInfo_field">
<AccessibleButton
kind="link"
onClick={onReadReceiptButton}
className="mx_UserInfo_field"
>
{ _t('Jump to read receipt') }
</AccessibleButton>
);
}

insertPillButton = (
<AccessibleButton onClick={onInsertPillButton} className="mx_UserInfo_field">
<AccessibleButton
kind="link"
onClick={onInsertPillButton}
className="mx_UserInfo_field"
>
{ _t('Mention') }
</AccessibleButton>
);
Expand Down Expand Up @@ -448,15 +462,23 @@ const UserOptionsSection: React.FC<{
};

inviteUserButton = (
<AccessibleButton onClick={onInviteUserButton} className="mx_UserInfo_field">
<AccessibleButton
kind="link"
onClick={onInviteUserButton}
className="mx_UserInfo_field"
>
{ _t('Invite') }
</AccessibleButton>
);
}
}

const shareUserButton = (
<AccessibleButton onClick={onShareUserClick} className="mx_UserInfo_field">
<AccessibleButton
kind="link"
onClick={onShareUserClick}
className="mx_UserInfo_field"
>
{ _t('Share Link to User') }
</AccessibleButton>
);
Expand Down Expand Up @@ -624,7 +646,11 @@ const RoomKickButton = ({ room, member, startUpdating, stopUpdating }: Omit<IBas
member.membership === "invite" ? _t("Disinvite from space") : _t("Remove from space")
: member.membership === "invite" ? _t("Disinvite from room") : _t("Remove from room");

return <AccessibleButton className="mx_UserInfo_field mx_UserInfo_destructive" onClick={onKick}>
return <AccessibleButton
kind="link"
className="mx_UserInfo_field mx_UserInfo_destructive"
onClick={onKick}
>
{ kickLabel }
</AccessibleButton>;
};
Expand All @@ -642,7 +668,11 @@ const RedactMessagesButton: React.FC<IBaseProps> = ({ member }) => {
});
};

return <AccessibleButton className="mx_UserInfo_field mx_UserInfo_destructive" onClick={onRedactAllMessages}>
return <AccessibleButton
kind="link"
className="mx_UserInfo_field mx_UserInfo_destructive"
onClick={onRedactAllMessages}
>
{ _t("Remove recent messages") }
</AccessibleButton>;
};
Expand Down Expand Up @@ -739,7 +769,11 @@ const BanToggleButton = ({ room, member, startUpdating, stopUpdating }: Omit<IBa
mx_UserInfo_destructive: !isBanned,
});

return <AccessibleButton className={classes} onClick={onBanOrUnban}>
return <AccessibleButton
kind="link"
className={classes}
onClick={onBanOrUnban}
>
{ label }
</AccessibleButton>;
};
Expand Down Expand Up @@ -809,7 +843,11 @@ const MuteToggleButton: React.FC<IBaseRoomProps> = ({ member, room, powerLevels,
});

const muteLabel = muted ? _t("Unmute") : _t("Mute");
return <AccessibleButton className={classes} onClick={onMuteToggle}>
return <AccessibleButton
kind="link"
className={classes}
onClick={onMuteToggle}
>
{ muteLabel }
</AccessibleButton>;
};
Expand Down Expand Up @@ -1212,7 +1250,11 @@ const BasicUserInfo: React.FC<{
// FIXME this should be using cli instead of MatrixClientPeg.matrixClient
if (isSynapseAdmin && member.userId.endsWith(`:${MatrixClientPeg.getHomeserverName()}`)) {
synapseDeactivateButton = (
<AccessibleButton onClick={onSynapseDeactivate} className="mx_UserInfo_field mx_UserInfo_destructive">
<AccessibleButton
kind="link"
className="mx_UserInfo_field mx_UserInfo_destructive"
onClick={onSynapseDeactivate}
>
{ _t("Deactivate user") }
</AccessibleButton>
);
Expand Down Expand Up @@ -1290,8 +1332,9 @@ const BasicUserInfo: React.FC<{
if (canVerify) {
if (hasCrossSigningKeys !== undefined) {
// Note: mx_UserInfo_verifyButton is for the end-to-end tests
verifyButton = (
verifyButton = (<div className="mx_UserInfo_container_verifyButton">
<AccessibleButton
kind="link"
className="mx_UserInfo_field mx_UserInfo_verifyButton"
onClick={() => {
if (hasCrossSigningKeys) {
Expand All @@ -1303,7 +1346,7 @@ const BasicUserInfo: React.FC<{
>
{ _t("Verify") }
</AccessibleButton>
);
</div>);
} else if (!showDeviceListSpinner) {
// HACK: only show a spinner if the device section spinner is not shown,
// to avoid showing a double spinner
Expand All @@ -1316,6 +1359,7 @@ const BasicUserInfo: React.FC<{
if (member.userId == cli.getUserId()) {
editDevices = (<div>
<AccessibleButton
kind="link"
className="mx_UserInfo_field"
onClick={() => {
dis.dispatch({
Expand Down