From 6e11f2478cb092ad55abd3b657e11d61f1996ccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 10 Sep 2021 19:01:05 +0200 Subject: [PATCH] Use IDialogProps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/views/dialogs/BaseDialog.tsx | 9 ++------- src/components/views/dialogs/FeedbackDialog.tsx | 5 ++--- src/components/views/dialogs/IncomingSasDialog.tsx | 4 ++-- .../views/dialogs/IntegrationsDisabledDialog.tsx | 5 ++--- .../views/dialogs/IntegrationsImpossibleDialog.tsx | 6 ++---- src/components/views/dialogs/InteractiveAuthDialog.tsx | 5 ++--- .../views/dialogs/KeySignatureUploadFailedDialog.tsx | 4 ++-- .../views/dialogs/LazyLoadingDisabledDialog.tsx | 3 +-- .../views/dialogs/LazyLoadingResyncDialog.tsx | 5 ++--- .../dialogs/ManualDeviceKeyVerificationDialog.tsx | 4 ++-- .../views/dialogs/MessageEditHistoryDialog.tsx | 4 ++-- src/components/views/dialogs/QuestionDialog.tsx | 4 ++-- .../views/dialogs/SessionRestoreErrorDialog.tsx | 4 ++-- src/components/views/dialogs/SetEmailDialog.tsx | 4 ++-- .../views/dialogs/SlashCommandHelpDialog.tsx | 5 ++--- src/components/views/dialogs/StorageEvictedDialog.tsx | 5 ++--- .../views/dialogs/TabbedIntegrationManagerDialog.tsx | 10 ++-------- src/components/views/dialogs/TextInputDialog.tsx | 4 ++-- src/components/views/dialogs/UploadFailureDialog.tsx | 4 ++-- .../views/dialogs/security/RestoreKeyBackupDialog.tsx | 5 ++--- .../views/dialogs/security/SetupEncryptionDialog.tsx | 6 ++---- 21 files changed, 41 insertions(+), 64 deletions(-) diff --git a/src/components/views/dialogs/BaseDialog.tsx b/src/components/views/dialogs/BaseDialog.tsx index 91cceb3123..0af494f53e 100644 --- a/src/components/views/dialogs/BaseDialog.tsx +++ b/src/components/views/dialogs/BaseDialog.tsx @@ -27,14 +27,9 @@ import { _t } from "../../../languageHandler"; import MatrixClientContext from "../../../contexts/MatrixClientContext"; import { replaceableComponent } from "../../../utils/replaceableComponent"; import { MatrixClient } from "matrix-js-sdk/src/client"; +import { IDialogProps } from "./IDialogProps"; -interface IProps { - // onFinished callback to call when Escape is pressed - // Take a boolean which is true if the dialog was dismissed - // with a positive / confirm action or false if it was - // cancelled (BaseDialog itself only calls this with false). - onFinished: (confirm: any) => void; - +interface IProps extends IDialogProps { // Whether the dialog should have a 'close' button that will // cause the dialog to be cancelled. This should only be set // to false if there is nothing the app can sensibly do if the diff --git a/src/components/views/dialogs/FeedbackDialog.tsx b/src/components/views/dialogs/FeedbackDialog.tsx index 00112ab0c7..6f957452bc 100644 --- a/src/components/views/dialogs/FeedbackDialog.tsx +++ b/src/components/views/dialogs/FeedbackDialog.tsx @@ -25,14 +25,13 @@ import Modal from "../../../Modal"; import BugReportDialog from "./BugReportDialog"; import InfoDialog from "./InfoDialog"; import StyledRadioGroup from "../elements/StyledRadioGroup"; +import { IDialogProps } from "./IDialogProps"; const existingIssuesUrl = "https://github.com/vector-im/element-web/issues" + "?q=is%3Aopen+is%3Aissue+sort%3Areactions-%2B1-desc"; const newIssueUrl = "https://github.com/vector-im/element-web/issues/new/choose"; -interface IProps { - onFinished: () => void; -} +interface IProps extends IDialogProps {} const FeedbackDialog: React.FC = (props: IProps) => { const [rating, setRating] = useState(); diff --git a/src/components/views/dialogs/IncomingSasDialog.tsx b/src/components/views/dialogs/IncomingSasDialog.tsx index 8903b00221..0c689e198d 100644 --- a/src/components/views/dialogs/IncomingSasDialog.tsx +++ b/src/components/views/dialogs/IncomingSasDialog.tsx @@ -26,6 +26,7 @@ import Spinner from "../elements/Spinner"; import VerificationShowSas from "../verification/VerificationShowSas"; import BaseDialog from "./BaseDialog"; import DialogButtons from "../elements/DialogButtons"; +import { IDialogProps } from "./IDialogProps"; const PHASE_START = 0; const PHASE_SHOW_SAS = 1; @@ -33,9 +34,8 @@ const PHASE_WAIT_FOR_PARTNER_TO_CONFIRM = 2; const PHASE_VERIFIED = 3; const PHASE_CANCELLED = 4; -interface IProps { +interface IProps extends IDialogProps { verifier: any; // TODO types - onFinished: (confirmed: boolean) => void; } interface IState { diff --git a/src/components/views/dialogs/IntegrationsDisabledDialog.tsx b/src/components/views/dialogs/IntegrationsDisabledDialog.tsx index f76ed46577..7da4bb84b9 100644 --- a/src/components/views/dialogs/IntegrationsDisabledDialog.tsx +++ b/src/components/views/dialogs/IntegrationsDisabledDialog.tsx @@ -21,10 +21,9 @@ import { Action } from "../../../dispatcher/actions"; import { replaceableComponent } from "../../../utils/replaceableComponent"; import BaseDialog from "./BaseDialog"; import DialogButtons from "../elements/DialogButtons"; +import { IDialogProps } from "./IDialogProps"; -interface IProps { - onFinished: () => void; -} +interface IProps extends IDialogProps {} @replaceableComponent("views.dialogs.IntegrationsDisabledDialog") export default class IntegrationsDisabledDialog extends React.Component { diff --git a/src/components/views/dialogs/IntegrationsImpossibleDialog.tsx b/src/components/views/dialogs/IntegrationsImpossibleDialog.tsx index 36dc42b783..52e3a2fbb8 100644 --- a/src/components/views/dialogs/IntegrationsImpossibleDialog.tsx +++ b/src/components/views/dialogs/IntegrationsImpossibleDialog.tsx @@ -19,11 +19,9 @@ import { _t } from "../../../languageHandler"; import SdkConfig from "../../../SdkConfig"; import * as sdk from "../../../index"; import { replaceableComponent } from "../../../utils/replaceableComponent"; +import { IDialogProps } from "./IDialogProps"; -interface IProps { - onFinished: () => void; - -} +interface IProps extends IDialogProps {} @replaceableComponent("views.dialogs.IntegrationsImpossibleDialog") export default class IntegrationsImpossibleDialog extends React.Component { diff --git a/src/components/views/dialogs/InteractiveAuthDialog.tsx b/src/components/views/dialogs/InteractiveAuthDialog.tsx index e9667c84b5..ededfa3bc0 100644 --- a/src/components/views/dialogs/InteractiveAuthDialog.tsx +++ b/src/components/views/dialogs/InteractiveAuthDialog.tsx @@ -27,8 +27,9 @@ import { replaceableComponent } from "../../../utils/replaceableComponent"; import { MatrixClient } from "matrix-js-sdk/src/client"; import BaseDialog from "./BaseDialog"; import { IAuthData } from "matrix-js-sdk/src/interactive-auth"; +import { IDialogProps } from "./IDialogProps"; -interface IProps { +interface IProps extends IDialogProps { // matrix client to use for UI auth requests matrixClient: MatrixClient; @@ -43,8 +44,6 @@ interface IProps { // callback makeRequest: (auth: IAuthData) => Promise; - onFinished: (confirmed: boolean, result?) => void; - // Optional title and body to show when not showing a particular stage title?: string; body?: string; diff --git a/src/components/views/dialogs/KeySignatureUploadFailedDialog.tsx b/src/components/views/dialogs/KeySignatureUploadFailedDialog.tsx index 20841c46f4..28e4d1ca80 100644 --- a/src/components/views/dialogs/KeySignatureUploadFailedDialog.tsx +++ b/src/components/views/dialogs/KeySignatureUploadFailedDialog.tsx @@ -20,15 +20,15 @@ import SdkConfig from '../../../SdkConfig'; import BaseDialog from "./BaseDialog"; import DialogButtons from "../elements/DialogButtons"; import Spinner from "../elements/Spinner"; +import { IDialogProps } from "./IDialogProps"; -interface IProps { +interface IProps extends IDialogProps { failures: Record>; source: string; continuation: () => void; - onFinished: () => void; } const KeySignatureUploadFailedDialog: React.FC = ({ diff --git a/src/components/views/dialogs/LazyLoadingDisabledDialog.tsx b/src/components/views/dialogs/LazyLoadingDisabledDialog.tsx index 32aaf9c531..79b8306989 100644 --- a/src/components/views/dialogs/LazyLoadingDisabledDialog.tsx +++ b/src/components/views/dialogs/LazyLoadingDisabledDialog.tsx @@ -20,8 +20,7 @@ import QuestionDialog from './QuestionDialog'; import { _t } from '../../../languageHandler'; import SdkConfig from '../../../SdkConfig'; -interface IProps { - onFinished: () => void; +interface IProps extends IDialogProps { host: string; } diff --git a/src/components/views/dialogs/LazyLoadingResyncDialog.tsx b/src/components/views/dialogs/LazyLoadingResyncDialog.tsx index c942126d12..3acedc77e4 100644 --- a/src/components/views/dialogs/LazyLoadingResyncDialog.tsx +++ b/src/components/views/dialogs/LazyLoadingResyncDialog.tsx @@ -19,10 +19,9 @@ import React from 'react'; import QuestionDialog from './QuestionDialog'; import { _t } from '../../../languageHandler'; import SdkConfig from '../../../SdkConfig'; +import { IDialogProps } from "./IDialogProps"; -interface IProps { - onFinished: () => void; -} +interface IProps extends IDialogProps {} const LazyLoadingResyncDialog: React.FC = (props: IProps) => { const brand = SdkConfig.get().brand; diff --git a/src/components/views/dialogs/ManualDeviceKeyVerificationDialog.tsx b/src/components/views/dialogs/ManualDeviceKeyVerificationDialog.tsx index a4c989d7b5..88419d26b8 100644 --- a/src/components/views/dialogs/ManualDeviceKeyVerificationDialog.tsx +++ b/src/components/views/dialogs/ManualDeviceKeyVerificationDialog.tsx @@ -25,11 +25,11 @@ import { _t } from '../../../languageHandler'; import { replaceableComponent } from "../../../utils/replaceableComponent"; import QuestionDialog from "./QuestionDialog"; import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo"; +import { IDialogProps } from "./IDialogProps"; -interface IProps { +interface IProps extends IDialogProps { userId: string; device: DeviceInfo; - onFinished: (confirmed: boolean) => void; } @replaceableComponent("views.dialogs.ManualDeviceKeyVerificationDialog") diff --git a/src/components/views/dialogs/MessageEditHistoryDialog.tsx b/src/components/views/dialogs/MessageEditHistoryDialog.tsx index 30c16b03bd..04313ed9a0 100644 --- a/src/components/views/dialogs/MessageEditHistoryDialog.tsx +++ b/src/components/views/dialogs/MessageEditHistoryDialog.tsx @@ -26,10 +26,10 @@ import ScrollPanel from "../../structures/ScrollPanel"; import Spinner from "../elements/Spinner"; import EditHistoryMessage from "../messages/EditHistoryMessage"; import DateSeparator from "../messages/DateSeparator"; +import { IDialogProps } from "./IDialogProps"; -interface IProps { +interface IProps extends IDialogProps { mxEvent: MatrixEvent; - onFinished: () => void; } interface IState { diff --git a/src/components/views/dialogs/QuestionDialog.tsx b/src/components/views/dialogs/QuestionDialog.tsx index df036293f0..8c6334bac1 100644 --- a/src/components/views/dialogs/QuestionDialog.tsx +++ b/src/components/views/dialogs/QuestionDialog.tsx @@ -20,8 +20,9 @@ import classNames from "classnames"; import * as sdk from '../../../index'; import { _t } from '../../../languageHandler'; +import { IDialogProps } from "./IDialogProps"; -interface IProps { +interface IProps extends IDialogProps { title?: string; description?: React.ReactNode; extraButtons?: React.ReactNode; @@ -29,7 +30,6 @@ interface IProps { 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; diff --git a/src/components/views/dialogs/SessionRestoreErrorDialog.tsx b/src/components/views/dialogs/SessionRestoreErrorDialog.tsx index 752b023f0b..b36dbf548e 100644 --- a/src/components/views/dialogs/SessionRestoreErrorDialog.tsx +++ b/src/components/views/dialogs/SessionRestoreErrorDialog.tsx @@ -25,10 +25,10 @@ import QuestionDialog from "./QuestionDialog"; import BugReportDialog from "./BugReportDialog"; import BaseDialog from "./BaseDialog"; import DialogButtons from "../elements/DialogButtons"; +import { IDialogProps } from "./IDialogProps"; -interface IProps { +interface IProps extends IDialogProps { error: string; - onFinished: () => void; } @replaceableComponent("views.dialogs.SessionRestoreErrorDialog") diff --git a/src/components/views/dialogs/SetEmailDialog.tsx b/src/components/views/dialogs/SetEmailDialog.tsx index 506399d15d..0fa898f1b9 100644 --- a/src/components/views/dialogs/SetEmailDialog.tsx +++ b/src/components/views/dialogs/SetEmailDialog.tsx @@ -26,10 +26,10 @@ import ErrorDialog from "./ErrorDialog"; import QuestionDialog from "./QuestionDialog"; import BaseDialog from "./BaseDialog"; import EditableText from "../elements/EditableText"; +import { IDialogProps } from "./IDialogProps"; -interface IProps { +interface IProps extends IDialogProps { title: string; - onFinished: (confirmed: boolean) => void; } interface IState { diff --git a/src/components/views/dialogs/SlashCommandHelpDialog.tsx b/src/components/views/dialogs/SlashCommandHelpDialog.tsx index c47555567e..ccb157f025 100644 --- a/src/components/views/dialogs/SlashCommandHelpDialog.tsx +++ b/src/components/views/dialogs/SlashCommandHelpDialog.tsx @@ -17,11 +17,10 @@ limitations under the License. import React from 'react'; import { _t } from "../../../languageHandler"; import { CommandCategories, Commands } from "../../../SlashCommands"; +import { IDialogProps } from "./IDialogProps"; import InfoDialog from "./InfoDialog"; -interface IProps { - onFinished: () => void; -} +interface IProps extends IDialogProps {} const SlashCommandHelpDialog: React.FC = ({ onFinished }) => { const categories = {}; diff --git a/src/components/views/dialogs/StorageEvictedDialog.tsx b/src/components/views/dialogs/StorageEvictedDialog.tsx index 60ae049bf6..bdbbf815e6 100644 --- a/src/components/views/dialogs/StorageEvictedDialog.tsx +++ b/src/components/views/dialogs/StorageEvictedDialog.tsx @@ -22,10 +22,9 @@ import { replaceableComponent } from "../../../utils/replaceableComponent"; import BaseDialog from "./BaseDialog"; import DialogButtons from "../elements/DialogButtons"; import BugReportDialog from "./BugReportDialog"; +import { IDialogProps } from "./IDialogProps"; -interface IProps { - onFinished: (confirmed: boolean) => void; -} +interface IProps extends IDialogProps { } @replaceableComponent("views.dialogs.StorageEvictedDialog") export default class StorageEvictedDialog extends React.Component { diff --git a/src/components/views/dialogs/TabbedIntegrationManagerDialog.tsx b/src/components/views/dialogs/TabbedIntegrationManagerDialog.tsx index c8ab25b1bb..7ee54403bd 100644 --- a/src/components/views/dialogs/TabbedIntegrationManagerDialog.tsx +++ b/src/components/views/dialogs/TabbedIntegrationManagerDialog.tsx @@ -25,15 +25,9 @@ import { IntegrationManagerInstance } from "../../../integrations/IntegrationMan import ScalarAuthClient from "../../../ScalarAuthClient"; import AccessibleButton from "../elements/AccessibleButton"; import IntegrationManager from "../settings/IntegrationManager"; +import { IDialogProps } from "./IDialogProps"; -interface IProps { - /** - * Called with: - * * success {bool} True if the user accepted any douments, false if cancelled - * * agreedUrls {string[]} List of agreed URLs - */ - onFinished: () => void; - +interface IProps extends IDialogProps { /** * Optional room where the integration manager should be open to */ diff --git a/src/components/views/dialogs/TextInputDialog.tsx b/src/components/views/dialogs/TextInputDialog.tsx index 624e2a58cb..cc321a0af6 100644 --- a/src/components/views/dialogs/TextInputDialog.tsx +++ b/src/components/views/dialogs/TextInputDialog.tsx @@ -21,8 +21,9 @@ import { replaceableComponent } from "../../../utils/replaceableComponent"; import { IFieldState, IValidationResult } from "../elements/Validation"; import BaseDialog from "./BaseDialog"; import DialogButtons from "../elements/DialogButtons"; +import { IDialogProps } from "./IDialogProps"; - interface IProps { +interface IProps extends IDialogProps { title?: string; description?: string | JSX.Element; value?: string; @@ -30,7 +31,6 @@ import DialogButtons from "../elements/DialogButtons"; button?: string; busyMessage?: string; // pass _td string focus?: boolean; - onFinished: (success: boolean, value?: string) => void; hasCancel?: boolean; validator?: (fieldState: IFieldState) => IValidationResult; // result of withValidation fixedWidth?: boolean; diff --git a/src/components/views/dialogs/UploadFailureDialog.tsx b/src/components/views/dialogs/UploadFailureDialog.tsx index 807cb08195..bb8d14e161 100644 --- a/src/components/views/dialogs/UploadFailureDialog.tsx +++ b/src/components/views/dialogs/UploadFailureDialog.tsx @@ -22,12 +22,12 @@ import ContentMessages from '../../../ContentMessages'; import { replaceableComponent } from "../../../utils/replaceableComponent"; import BaseDialog from "./BaseDialog"; import DialogButtons from "../elements/DialogButtons"; +import { IDialogProps } from "./IDialogProps"; -interface IProps { +interface IProps extends IDialogProps { badFiles: File[]; totalFiles: number; contentMessages: ContentMessages; - onFinished: (success: boolean) => void; } /* diff --git a/src/components/views/dialogs/security/RestoreKeyBackupDialog.tsx b/src/components/views/dialogs/security/RestoreKeyBackupDialog.tsx index d2b850eb85..7d5c3cf857 100644 --- a/src/components/views/dialogs/security/RestoreKeyBackupDialog.tsx +++ b/src/components/views/dialogs/security/RestoreKeyBackupDialog.tsx @@ -23,6 +23,7 @@ import { accessSecretStorage } from '../../../../SecurityManager'; import { IKeyBackupInfo, IKeyBackupRestoreResult } from "matrix-js-sdk/src/crypto/keybackup"; import { ISecretStorageKeyInfo } from "matrix-js-sdk/src/crypto/api"; import * as sdk from '../../../../index'; +import { IDialogProps } from "../IDialogProps"; enum RestoreType { Passphrase = "passphrase", @@ -37,15 +38,13 @@ enum ProgressState { } -interface IProps { +interface IProps extends IDialogProps { // if false, will close the dialog as soon as the restore completes succesfully // default: true showSummary?: boolean; // If specified, gather the key from the user but then call the function with the backup // key rather than actually (necessarily) restoring the backup. keyCallback?: (key: Uint8Array) => void; - - onFinished: (success: boolean) => void; } interface IState { diff --git a/src/components/views/dialogs/security/SetupEncryptionDialog.tsx b/src/components/views/dialogs/security/SetupEncryptionDialog.tsx index b601353d1d..0323769536 100644 --- a/src/components/views/dialogs/security/SetupEncryptionDialog.tsx +++ b/src/components/views/dialogs/security/SetupEncryptionDialog.tsx @@ -20,6 +20,7 @@ import BaseDialog from '../BaseDialog'; import { _t } from '../../../../languageHandler'; import { SetupEncryptionStore, Phase } from '../../../../stores/SetupEncryptionStore'; import { replaceableComponent } from "../../../../utils/replaceableComponent"; +import { IDialogProps } from "../IDialogProps"; function iconFromPhase(phase: Phase) { if (phase === Phase.Done) { @@ -29,10 +30,7 @@ function iconFromPhase(phase: Phase) { } } -interface IProps { - onFinished: (success: boolean) => void; -} - +interface IProps extends IDialogProps {} interface IState { icon: string; }