1
0
mirror of https://github.com/element-hq/element-web.git synced 2025-09-10 21:51:57 +03:00
Files
element-web/src/components/views/messages/DisambiguatedProfile.tsx
R Midhun Suresh ebef0d353e Implement new memberlist design with MVVM architecture (#28874)
* Add new e2e icon for the member tile

* Add new presence icon for member tile

* Implement new member tile

* Implement memberlist view model

* Implement new memberlist header view

* Support the new memberlist in Diasambiguated profile

1. Use MemberInfo instead of RoomMember
2. CSS changes to reflect the new design

* Implement new memberlist view

* Add and use a new overflow component

We used the EntityTile component as a pretend overflow tile in some
places. This new lighter component is added so  that we can remove the
complex EntityTile component.

* Remove old code

* Add/remove css files from _components.pcss

* Increase minimum width as per design

* Actually use the new memberlist view

* Fix broken jest tests

* Add jest tests

* Playwright: Make it possible to disable presence

* Add playwright tests

* Fix lint error

* Undo translation changes that must be done via localazy

* Update license header

* Use waitFor instead of setTimeout

* Remove comment

* Switch over from template to container hs

* Revert unintended change

* Move config to top level
2025-01-08 17:15:06 +00:00

76 lines
2.4 KiB
TypeScript

/*
Copyright 2024 New Vector Ltd.
Copyright 2022, 2023 The Matrix.org Foundation C.I.C.
Copyright 2021 Šimon Brandner <simon.bra.ag@gmail.com>
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import React from "react";
import classNames from "classnames";
import { _t } from "../../../languageHandler";
import { getUserNameColorClass } from "../../../utils/FormattingUtils";
import UserIdentifier from "../../../customisations/UserIdentifier";
interface MemberInfo {
userId: string;
roomId: string;
rawDisplayName?: string;
disambiguate: boolean;
}
interface IProps {
member?: MemberInfo | null;
fallbackName: string;
onClick?(): void;
colored?: boolean;
emphasizeDisplayName?: boolean;
withTooltip?: boolean;
}
export default class DisambiguatedProfile extends React.Component<IProps> {
public render(): React.ReactNode {
const { fallbackName, member, colored, emphasizeDisplayName, withTooltip, onClick } = this.props;
const rawDisplayName = member?.rawDisplayName || fallbackName;
const mxid = member?.userId;
let colorClass: string | undefined;
if (colored) {
colorClass = getUserNameColorClass(mxid ?? "");
}
let mxidElement;
let title: string | undefined;
if (mxid) {
const identifier =
UserIdentifier.getDisplayUserIdentifier?.(mxid, {
withDisplayName: true,
roomId: member.roomId,
}) ?? mxid;
if (member?.disambiguate) {
mxidElement = <span className="mx_DisambiguatedProfile_mxid">{identifier}</span>;
}
title = _t("timeline|disambiguated_profile", {
displayName: rawDisplayName,
matrixId: identifier,
});
}
const displayNameClasses = classNames(colorClass, {
mx_DisambiguatedProfile_displayName: emphasizeDisplayName,
});
return (
<div className="mx_DisambiguatedProfile" title={withTooltip ? title : undefined} onClick={onClick}>
<span className={displayNameClasses} dir="auto">
{rawDisplayName}
</span>
{mxidElement}
</div>
);
}
}