From d6aa4c9d1433239f9c527e3a257265291901bb81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 5 Sep 2021 12:57:41 +0200 Subject: [PATCH] Convert QuestionDialog to TS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- .../{QuestionDialog.js => QuestionDialog.tsx} | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) rename src/components/views/dialogs/{QuestionDialog.js => QuestionDialog.tsx} (76%) diff --git a/src/components/views/dialogs/QuestionDialog.js b/src/components/views/dialogs/QuestionDialog.tsx similarity index 76% rename from src/components/views/dialogs/QuestionDialog.js rename to src/components/views/dialogs/QuestionDialog.tsx index 3d90236b08..df036293f0 100644 --- a/src/components/views/dialogs/QuestionDialog.js +++ b/src/components/views/dialogs/QuestionDialog.tsx @@ -16,29 +16,30 @@ limitations under the License. */ import React from 'react'; -import PropTypes from 'prop-types'; import classNames from "classnames"; import * as sdk from '../../../index'; import { _t } from '../../../languageHandler'; -export default class QuestionDialog extends React.Component { - static propTypes = { - title: PropTypes.string, - description: PropTypes.node, - extraButtons: PropTypes.node, - button: PropTypes.string, - buttonDisabled: PropTypes.bool, - danger: PropTypes.bool, - focus: PropTypes.bool, - onFinished: PropTypes.func.isRequired, - headerImage: PropTypes.string, - quitOnly: PropTypes.bool, // quitOnly doesn't show the cancel button just the quit [x]. - fixedWidth: PropTypes.bool, - className: PropTypes.string, - }; +interface IProps { + title?: string; + description?: React.ReactNode; + extraButtons?: React.ReactNode; + button?: string; + buttonDisabled?: boolean; + danger?: boolean; + focus?: boolean; + onFinished: (confirmed: boolean) => void; + headerImage?: string; + quitOnly?: boolean; // quitOnly doesn't show the cancel button just the quit [x]. + fixedWidth?: boolean; + className?: string; + hasCancelButton?: boolean; + cancelButton?: JSX.Element; +} - static defaultProps = { +export default class QuestionDialog extends React.Component { + public static defaultProps: Partial = { title: "", description: "", extraButtons: null, @@ -48,17 +49,19 @@ export default class QuestionDialog extends React.Component { quitOnly: false, }; - onOk = () => { + private onOk = (): void => { this.props.onFinished(true); }; - onCancel = () => { + private onCancel = (): void => { this.props.onFinished(false); }; - render() { + public render(): JSX.Element { + // Converting these to imports breaks wrench tests const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const DialogButtons = sdk.getComponent('views.elements.DialogButtons'); + let primaryButtonClass = ""; if (this.props.danger) { primaryButtonClass = "danger";