From 437f13cf764cfcc289bddb758f6eff73f4c93649 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Thu, 6 May 2021 14:11:34 +0100 Subject: [PATCH] Convert UploadConfirmDialog to TSX --- ...nfirmDialog.js => UploadConfirmDialog.tsx} | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) rename src/components/views/dialogs/{UploadConfirmDialog.js => UploadConfirmDialog.tsx} (80%) diff --git a/src/components/views/dialogs/UploadConfirmDialog.js b/src/components/views/dialogs/UploadConfirmDialog.tsx similarity index 80% rename from src/components/views/dialogs/UploadConfirmDialog.js rename to src/components/views/dialogs/UploadConfirmDialog.tsx index 2ff16b9440..8fdfbfda12 100644 --- a/src/components/views/dialogs/UploadConfirmDialog.js +++ b/src/components/views/dialogs/UploadConfirmDialog.tsx @@ -1,5 +1,5 @@ /* -Copyright 2019 New Vector Ltd +Copyright 2019, 2021 The Matrix.org Foundation C.I.C. Copyright 2019 Michael Telatynski <7t3chguy@gmail.com> Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,20 +16,21 @@ limitations under the License. */ import React from 'react'; -import PropTypes from 'prop-types'; import * as sdk from '../../../index'; import { _t } from '../../../languageHandler'; import filesize from "filesize"; -import {replaceableComponent} from "../../../utils/replaceableComponent"; +import { replaceableComponent } from "../../../utils/replaceableComponent"; + +interface IProps { + file: File; + currentIndex: number; + totalFiles?: number; + onFinished: (uploadConfirmed: boolean, uploadAll?: boolean) => void; +} @replaceableComponent("views.dialogs.UploadConfirmDialog") -export default class UploadConfirmDialog extends React.Component { - static propTypes = { - file: PropTypes.object.isRequired, - currentIndex: PropTypes.number, - totalFiles: PropTypes.number, - onFinished: PropTypes.func.isRequired, - } +export default class UploadConfirmDialog extends React.Component { + private objectUrl: string; static defaultProps = { totalFiles: 1, @@ -38,22 +39,22 @@ export default class UploadConfirmDialog extends React.Component { constructor(props) { super(props); - this._objectUrl = URL.createObjectURL(props.file); + this.objectUrl = URL.createObjectURL(props.file); } componentWillUnmount() { - if (this._objectUrl) URL.revokeObjectURL(this._objectUrl); + if (this.objectUrl) URL.revokeObjectURL(this.objectUrl); } - _onCancelClick = () => { + private onCancelClick = () => { this.props.onFinished(false); } - _onUploadClick = () => { + private onUploadClick = () => { this.props.onFinished(true); } - _onUploadAllClick = () => { + private onUploadAllClick = () => { this.props.onFinished(true, true); } @@ -78,7 +79,7 @@ export default class UploadConfirmDialog extends React.Component { if (this.props.file.type.startsWith('image/')) { preview =
-
+
{this.props.file.name} ({filesize(this.props.file.size)})
; @@ -95,7 +96,7 @@ export default class UploadConfirmDialog extends React.Component { let uploadAllButton; if (this.props.currentIndex + 1 < this.props.totalFiles) { - uploadAllButton = ; } @@ -103,7 +104,7 @@ export default class UploadConfirmDialog extends React.Component { return ( @@ -113,7 +114,7 @@ export default class UploadConfirmDialog extends React.Component { {uploadAllButton}