From d9e8c323415ff300b7d652fedee911f4ab72812c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 20 Sep 2021 13:23:02 +0200 Subject: [PATCH] Convert E2EIcon to TS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- .../views/dialogs/UntrustedDeviceDialog.tsx | 4 +- .../views/right_panel/VerificationPanel.tsx | 6 +-- .../views/rooms/{E2EIcon.js => E2EIcon.tsx} | 40 ++++++++++--------- src/components/views/rooms/EntityTile.tsx | 4 +- 4 files changed, 28 insertions(+), 26 deletions(-) rename src/components/views/rooms/{E2EIcon.js => E2EIcon.tsx} (79%) diff --git a/src/components/views/dialogs/UntrustedDeviceDialog.tsx b/src/components/views/dialogs/UntrustedDeviceDialog.tsx index 8389757347..1a1607c5f4 100644 --- a/src/components/views/dialogs/UntrustedDeviceDialog.tsx +++ b/src/components/views/dialogs/UntrustedDeviceDialog.tsx @@ -19,7 +19,7 @@ import { User } from "matrix-js-sdk/src/models/user"; import { _t } from "../../../languageHandler"; import { MatrixClientPeg } from "../../../MatrixClientPeg"; -import E2EIcon from "../rooms/E2EIcon"; +import E2EIcon, { E2E_STATE } from "../rooms/E2EIcon"; import AccessibleButton from "../elements/AccessibleButton"; import BaseDialog from "./BaseDialog"; import { IDialogProps } from "./IDialogProps"; @@ -47,7 +47,7 @@ const UntrustedDeviceDialog: React.FC = ({ device, user, onFinished }) = onFinished={onFinished} className="mx_UntrustedDeviceDialog" title={<> - + { _t("Not Trusted") } } > diff --git a/src/components/views/right_panel/VerificationPanel.tsx b/src/components/views/right_panel/VerificationPanel.tsx index a29bdea90b..3ed2dc3a3d 100644 --- a/src/components/views/right_panel/VerificationPanel.tsx +++ b/src/components/views/right_panel/VerificationPanel.tsx @@ -28,7 +28,7 @@ import { SAS } from "matrix-js-sdk/src/crypto/verification/SAS"; import VerificationQRCode from "../elements/crypto/VerificationQRCode"; import { _t } from "../../../languageHandler"; import SdkConfig from "../../../SdkConfig"; -import E2EIcon from "../rooms/E2EIcon"; +import E2EIcon, { E2E_STATE } from "../rooms/E2EIcon"; import { Phase } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest"; import Spinner from "../elements/Spinner"; import { replaceableComponent } from "../../../utils/replaceableComponent"; @@ -189,7 +189,7 @@ export default class VerificationPanel extends React.PureComponent

{ description }

- +

{ _t("Verified") }

{ description }

- + { text ?

{ text }

: null } { _t("Got it") } diff --git a/src/components/views/rooms/E2EIcon.js b/src/components/views/rooms/E2EIcon.tsx similarity index 79% rename from src/components/views/rooms/E2EIcon.js rename to src/components/views/rooms/E2EIcon.tsx index 7425af6060..2489eb38a4 100644 --- a/src/components/views/rooms/E2EIcon.js +++ b/src/components/views/rooms/E2EIcon.tsx @@ -16,33 +16,43 @@ limitations under the License. */ import React, { useState } from "react"; -import PropTypes from "prop-types"; import classNames from 'classnames'; import { _t, _td } from '../../../languageHandler'; import AccessibleButton from "../elements/AccessibleButton"; import Tooltip from "../elements/Tooltip"; +import { E2EStatus } from "../../../utils/ShieldUtils"; -export const E2E_STATE = { - VERIFIED: "verified", - WARNING: "warning", - UNKNOWN: "unknown", - NORMAL: "normal", - UNAUTHENTICATED: "unauthenticated", -}; +export enum E2E_STATE { + VERIFIED = "verified", + WARNING = "warning", + UNKNOWN = "unknown", + NORMAL = "normal", + UNAUTHENTICATED = "unauthenticated", +} -const crossSigningUserTitles = { +const crossSigningUserTitles: { [key in E2E_STATE]?: string } = { [E2E_STATE.WARNING]: _td("This user has not verified all of their sessions."), [E2E_STATE.NORMAL]: _td("You have not verified this user."), [E2E_STATE.VERIFIED]: _td("You have verified this user. This user has verified all of their sessions."), }; -const crossSigningRoomTitles = { +const crossSigningRoomTitles: { [key in E2E_STATE]?: string } = { [E2E_STATE.WARNING]: _td("Someone is using an unknown session"), [E2E_STATE.NORMAL]: _td("This room is end-to-end encrypted"), [E2E_STATE.VERIFIED]: _td("Everyone in this room is verified"), }; -const E2EIcon = ({ isUser, status, className, size, onClick, hideTooltip, bordered }) => { +interface IProps { + isUser?: boolean; + status?: E2E_STATE | E2EStatus; + className?: string; + size?: number; + onClick?: () => void; + hideTooltip?: boolean; + bordered?: boolean; +} + +const E2EIcon: React.FC = ({ isUser, status, className, size, onClick, hideTooltip, bordered }) => { const [hover, setHover] = useState(false); const classes = classNames({ @@ -92,12 +102,4 @@ const E2EIcon = ({ isUser, status, className, size, onClick, hideTooltip, border
; }; -E2EIcon.propTypes = { - isUser: PropTypes.bool, - status: PropTypes.oneOf(Object.values(E2E_STATE)), - className: PropTypes.string, - size: PropTypes.number, - onClick: PropTypes.func, -}; - export default E2EIcon; diff --git a/src/components/views/rooms/EntityTile.tsx b/src/components/views/rooms/EntityTile.tsx index 88c54468d8..2897bb5566 100644 --- a/src/components/views/rooms/EntityTile.tsx +++ b/src/components/views/rooms/EntityTile.tsx @@ -20,7 +20,7 @@ import React from 'react'; import AccessibleButton from '../elements/AccessibleButton'; import { _td } from '../../../languageHandler'; import classNames from "classnames"; -import E2EIcon from './E2EIcon'; +import E2EIcon, { E2E_STATE } from './E2EIcon'; import { replaceableComponent } from "../../../utils/replaceableComponent"; import BaseAvatar from '../avatars/BaseAvatar'; import PresenceLabel from "./PresenceLabel"; @@ -75,7 +75,7 @@ interface IProps { suppressOnHover?: boolean; showPresence?: boolean; subtextLabel?: string; - e2eStatus?: string; + e2eStatus?: E2E_STATE; powerStatus?: PowerStatus; }