Convert QuestionDialog to TS

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
pull/21833/head
Šimon Brandner 2021-09-05 12:57:41 +02:00
parent 5bf64c2075
commit d6aa4c9d14
No known key found for this signature in database
GPG Key ID: 55C211A1226CB17D
1 changed files with 23 additions and 20 deletions

View File

@ -16,29 +16,30 @@ limitations under the License.
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import classNames from "classnames"; import classNames from "classnames";
import * as sdk from '../../../index'; import * as sdk from '../../../index';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
export default class QuestionDialog extends React.Component { interface IProps {
static propTypes = { title?: string;
title: PropTypes.string, description?: React.ReactNode;
description: PropTypes.node, extraButtons?: React.ReactNode;
extraButtons: PropTypes.node, button?: string;
button: PropTypes.string, buttonDisabled?: boolean;
buttonDisabled: PropTypes.bool, danger?: boolean;
danger: PropTypes.bool, focus?: boolean;
focus: PropTypes.bool, onFinished: (confirmed: boolean) => void;
onFinished: PropTypes.func.isRequired, headerImage?: string;
headerImage: PropTypes.string, quitOnly?: boolean; // quitOnly doesn't show the cancel button just the quit [x].
quitOnly: PropTypes.bool, // quitOnly doesn't show the cancel button just the quit [x]. fixedWidth?: boolean;
fixedWidth: PropTypes.bool, className?: string;
className: PropTypes.string, hasCancelButton?: boolean;
}; cancelButton?: JSX.Element;
}
static defaultProps = { export default class QuestionDialog extends React.Component<IProps> {
public static defaultProps: Partial<IProps> = {
title: "", title: "",
description: "", description: "",
extraButtons: null, extraButtons: null,
@ -48,17 +49,19 @@ export default class QuestionDialog extends React.Component {
quitOnly: false, quitOnly: false,
}; };
onOk = () => { private onOk = (): void => {
this.props.onFinished(true); this.props.onFinished(true);
}; };
onCancel = () => { private onCancel = (): void => {
this.props.onFinished(false); this.props.onFinished(false);
}; };
render() { public render(): JSX.Element {
// Converting these to imports breaks wrench tests
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const DialogButtons = sdk.getComponent('views.elements.DialogButtons'); const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
let primaryButtonClass = ""; let primaryButtonClass = "";
if (this.props.danger) { if (this.props.danger) {
primaryButtonClass = "danger"; primaryButtonClass = "danger";