Files
ThreadNet-Web/src/toasts/ServerLimitToast.tsx
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.6 KiB
TypeScript
Raw Normal View History

2020-05-22 22:27:19 +01:00
/*
2024-09-09 14:57:16 +01:00
Copyright 2024 New Vector Ltd.
2020-05-22 22:27:19 +01:00
Copyright 2020 The Matrix.org Foundation C.I.C.
2024-09-09 14:57:16 +01:00
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
2020-05-22 22:27:19 +01:00
*/
import React from "react";
import { _t, _td } from "../languageHandler";
import GenericToast from "../components/views/toasts/GenericToast";
import ToastStore from "../stores/ToastStore";
2021-06-29 13:11:58 +01:00
import { messageForResourceLimitError } from "../utils/ErrorUtils";
2020-05-22 22:27:19 +01:00
const TOAST_KEY = "serverlimit";
export const showToast = (
limitType: string,
onHideToast: () => void,
adminContact?: string,
syncError?: boolean,
): void => {
2020-05-22 22:27:19 +01:00
const errorText = messageForResourceLimitError(limitType, adminContact, {
"monthly_active_user": _td("error|mau"),
"hs_blocked": _td("error|hs_blocked"),
"": _td("error|resource_limits"),
2020-05-22 22:27:19 +01:00
});
const contactText = messageForResourceLimitError(limitType, adminContact, {
"": _td("error|admin_contact_short"),
2020-05-22 22:27:19 +01:00
});
ToastStore.sharedInstance().addOrReplaceToast({
key: TOAST_KEY,
title: _t("common|warning"),
2020-05-22 22:27:19 +01:00
props: {
description: (
<React.Fragment>
{errorText} {contactText}
</React.Fragment>
),
2024-07-30 13:57:15 +01:00
primaryLabel: _t("action|ok"),
onPrimaryClick: () => {
2021-06-29 13:11:58 +01:00
hideToast();
2021-02-24 11:20:58 -07:00
if (onHideToast) onHideToast();
},
2020-05-22 22:27:19 +01:00
},
component: GenericToast,
2020-05-22 22:29:09 +01:00
priority: 70,
2020-05-22 22:27:19 +01:00
});
};
export const hideToast = (): void => {
2020-05-22 22:27:19 +01:00
ToastStore.sharedInstance().dismissToast(TOAST_KEY);
};