Files
ThreadNet-Web/apps/web/src/components/views/dialogs/InfoDialog.tsx
T

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

66 lines
2.1 KiB
TypeScript
Raw Normal View History

2019-01-31 17:57:57 +01:00
/*
2024-09-09 14:57:16 +01:00
Copyright 2024 New Vector Ltd.
Copyright 2015-2021 The Matrix.org Foundation C.I.C.
2019-02-06 19:27:53 +01:00
Copyright 2019 Bastian Masanek, Noxware IT <matrix@noxware.de>
2019-01-31 17:57:57 +01: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-31 17:57:57 +01:00
*/
2025-02-05 13:25:06 +00:00
import React, { type ReactNode } from "react";
import classNames from "classnames";
2019-01-31 17:57:57 +01:00
import { _t } from "../../../languageHandler";
2022-03-02 16:33:40 -07:00
import BaseDialog from "./BaseDialog";
import DialogButtons from "../elements/DialogButtons";
2019-01-31 17:57:57 +01:00
interface IProps {
top?: ReactNode;
title?: string;
description?: ReactNode;
className?: string;
button?: boolean | string;
hasCloseButton?: boolean;
fixedWidth?: boolean;
onKeyDown?(event: KeyboardEvent | React.KeyboardEvent): void;
onFinished(): void;
}
export default class InfoDialog extends React.Component<IProps> {
public static defaultProps: Partial<IProps> = {
2020-08-29 12:14:16 +01:00
title: "",
description: "",
hasCloseButton: false,
};
2019-01-31 17:57:57 +01:00
private onFinished = (): void => {
2019-02-06 19:35:43 +01:00
this.props.onFinished();
2020-08-29 12:14:16 +01:00
};
2019-01-31 17:57:57 +01:00
public render(): React.ReactNode {
2019-01-31 17:57:57 +01:00
return (
2020-03-18 16:40:21 +00:00
<BaseDialog
className="mx_InfoDialog"
onFinished={this.props.onFinished}
top={this.props.top}
2019-01-31 17:57:57 +01:00
title={this.props.title}
contentId="mx_Dialog_content"
2019-08-05 10:45:49 +01:00
hasCancel={this.props.hasCloseButton}
2020-03-18 16:40:21 +00:00
onKeyDown={this.props.onKeyDown}
fixedWidth={this.props.fixedWidth}
2019-01-31 17:57:57 +01:00
>
<div className={classNames("mx_Dialog_content", this.props.className)} id="mx_Dialog_content">
2019-01-31 17:57:57 +01:00
{this.props.description}
</div>
{this.props.button !== false && (
<DialogButtons
primaryButton={this.props.button || _t("action|ok")}
2019-02-06 19:35:43 +01:00
onPrimaryButtonClick={this.onFinished}
2019-01-31 17:57:57 +01:00
hasCancel={false}
2021-07-23 10:23:45 +01:00
/>
)}
2019-01-31 17:57:57 +01:00
</BaseDialog>
);
2020-08-29 12:14:16 +01:00
}
}