/*
Copyright 2019, 2020 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import React from "react";
import { RoomMember, User } from "matrix-js-sdk/src/matrix";
import { _t } from "../../../languageHandler";
import AccessibleButton from "../elements/AccessibleButton";
import Spinner from "../elements/Spinner";
export const PendingActionSpinner: React.FC<{ text: string }> = ({ text }) => {
return (
{text}
);
};
interface IProps {
waitingForOtherParty: boolean;
waitingForNetwork: boolean;
member: RoomMember | User;
onStartVerification: () => Promise;
isRoomEncrypted: boolean;
inDialog: boolean;
isSelfVerification: boolean;
}
const EncryptionInfo: React.FC = ({
waitingForOtherParty,
waitingForNetwork,
member,
onStartVerification,
isRoomEncrypted,
inDialog,
isSelfVerification,
}: IProps) => {
let content: JSX.Element;
if (waitingForOtherParty && isSelfVerification) {
content = {_t("encryption|verification|self_verification_hint")}
;
} else if (waitingForOtherParty || waitingForNetwork) {
let text: string;
if (waitingForOtherParty) {
text = _t("encryption|verification|waiting_for_user_accept", {
displayName: (member as User).displayName || (member as RoomMember).name || member.userId,
});
} else {
text = _t("encryption|verification|accepting");
}
content = ;
} else {
content = (
{_t("encryption|verification|start_button")}
);
}
let description: JSX.Element;
if (isRoomEncrypted) {
description = (
{_t("user_info|room_encrypted")}
{_t("user_info|room_encrypted_detail")}
);
} else {
description = (
{_t("user_info|room_unencrypted")}
{_t("user_info|room_unencrypted_detail")}
);
}
if (inDialog) {
return content;
}
return (
{_t("settings|security|encryption_section")}
{description}
{_t("user_info|verify_button")}
{_t("user_info|verify_explainer")}
{_t("encryption|verification|in_person")}
{content}
);
};
export default EncryptionInfo;