2019-01-10 21:43:21 -07:00
|
|
|
/*
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2023-02-23 10:52:58 +00:00
|
|
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2019 New Vector Ltd
|
2019-01-10 21:43:21 -07:00
|
|
|
|
2025-01-06 11:18:54 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
2024-09-09 14:57:16 +01:00
|
|
|
Please see LICENSE files in the repository root for full details.
|
2019-01-10 21:43:21 -07:00
|
|
|
*/
|
|
|
|
|
|
2025-03-27 10:43:58 +00:00
|
|
|
import React, { type JSX, useCallback } from "react";
|
2021-10-22 17:23:32 -05:00
|
|
|
|
2019-01-10 21:43:21 -07:00
|
|
|
import { _t } from "../../../languageHandler";
|
|
|
|
|
import SettingsStore from "../../../settings/SettingsStore";
|
2021-06-14 21:03:12 +01:00
|
|
|
import { SettingLevel } from "../../../settings/SettingLevel";
|
2021-07-02 17:08:27 +02:00
|
|
|
import BaseDialog from "./BaseDialog";
|
2021-06-14 21:03:12 +01:00
|
|
|
|
2023-04-05 13:13:51 +02:00
|
|
|
export interface UnknownProfile {
|
|
|
|
|
userId: string;
|
|
|
|
|
errorText: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type UnknownProfiles = UnknownProfile[];
|
|
|
|
|
|
2023-02-23 10:52:58 +00:00
|
|
|
export interface AskInviteAnywayDialogProps {
|
2023-04-05 13:13:51 +02:00
|
|
|
unknownProfileUsers: UnknownProfiles;
|
2021-06-14 21:03:12 +01:00
|
|
|
onInviteAnyways: () => void;
|
|
|
|
|
onGiveUp: () => void;
|
|
|
|
|
onFinished: (success: boolean) => void;
|
2023-04-05 13:13:51 +02:00
|
|
|
description?: string;
|
|
|
|
|
inviteNeverWarnLabel?: string;
|
|
|
|
|
inviteLabel?: string;
|
2021-06-14 21:03:12 +01:00
|
|
|
}
|
2019-01-10 21:43:21 -07:00
|
|
|
|
2023-02-23 10:52:58 +00:00
|
|
|
export default function AskInviteAnywayDialog({
|
|
|
|
|
onFinished,
|
|
|
|
|
onGiveUp,
|
|
|
|
|
onInviteAnyways,
|
|
|
|
|
unknownProfileUsers,
|
2023-04-05 13:13:51 +02:00
|
|
|
description: descriptionProp,
|
|
|
|
|
inviteNeverWarnLabel,
|
|
|
|
|
inviteLabel,
|
2023-02-23 10:52:58 +00:00
|
|
|
}: AskInviteAnywayDialogProps): JSX.Element {
|
|
|
|
|
const onInviteClicked = useCallback((): void => {
|
|
|
|
|
onInviteAnyways();
|
|
|
|
|
onFinished(true);
|
|
|
|
|
}, [onInviteAnyways, onFinished]);
|
2019-01-10 21:43:21 -07:00
|
|
|
|
2023-02-23 10:52:58 +00:00
|
|
|
const onInviteNeverWarnClicked = useCallback((): void => {
|
2019-01-16 15:07:30 +00:00
|
|
|
SettingsStore.setValue("promptBeforeInviteUnknownUsers", null, SettingLevel.ACCOUNT, false);
|
2023-02-23 10:52:58 +00:00
|
|
|
onInviteAnyways();
|
|
|
|
|
onFinished(true);
|
|
|
|
|
}, [onInviteAnyways, onFinished]);
|
2019-01-10 21:43:21 -07:00
|
|
|
|
2023-02-23 10:52:58 +00:00
|
|
|
const onGiveUpClicked = useCallback((): void => {
|
|
|
|
|
onGiveUp();
|
|
|
|
|
onFinished(false);
|
|
|
|
|
}, [onGiveUp, onFinished]);
|
2019-01-10 21:43:21 -07:00
|
|
|
|
2023-02-23 10:52:58 +00:00
|
|
|
const errorList = unknownProfileUsers.map((address) => (
|
|
|
|
|
<li key={address.userId}>
|
|
|
|
|
{address.userId}: {address.errorText}
|
|
|
|
|
</li>
|
|
|
|
|
));
|
2019-01-10 21:43:21 -07:00
|
|
|
|
2023-10-03 19:17:26 +01:00
|
|
|
const description = descriptionProp ?? _t("invite|unable_find_profiles_description_default");
|
2023-04-05 13:13:51 +02:00
|
|
|
|
2023-02-23 10:52:58 +00:00
|
|
|
return (
|
|
|
|
|
<BaseDialog
|
|
|
|
|
className="mx_RetryInvitesDialog"
|
|
|
|
|
onFinished={onGiveUpClicked}
|
2023-10-03 19:17:26 +01:00
|
|
|
title={_t("invite|unable_find_profiles_title")}
|
2023-02-23 10:52:58 +00:00
|
|
|
contentId="mx_Dialog_content"
|
|
|
|
|
>
|
|
|
|
|
<div id="mx_Dialog_content">
|
2023-04-05 13:13:51 +02:00
|
|
|
<p>{description}</p>
|
2023-02-23 10:52:58 +00:00
|
|
|
<ul>{errorList}</ul>
|
|
|
|
|
</div>
|
2019-01-10 21:43:21 -07:00
|
|
|
|
2023-02-23 10:52:58 +00:00
|
|
|
<div className="mx_Dialog_buttons">
|
2023-08-23 11:57:22 +01:00
|
|
|
<button onClick={onGiveUpClicked}>{_t("action|close")}</button>
|
2023-04-05 13:13:51 +02:00
|
|
|
<button onClick={onInviteNeverWarnClicked}>
|
2023-10-03 19:17:26 +01:00
|
|
|
{inviteNeverWarnLabel ?? _t("invite|unable_find_profiles_invite_never_warn_label_default")}
|
2023-04-05 13:13:51 +02:00
|
|
|
</button>
|
2023-02-23 10:52:58 +00:00
|
|
|
<button onClick={onInviteClicked} autoFocus={true}>
|
2023-10-03 19:17:26 +01:00
|
|
|
{inviteLabel ?? _t("invite|unable_find_profiles_invite_label_default")}
|
2023-02-23 10:52:58 +00:00
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</BaseDialog>
|
|
|
|
|
);
|
2020-08-29 12:14:16 +01:00
|
|
|
}
|