Properly type Modal props to ensure useful typescript checking (#10238
* Properly type Modal props to ensure useful typescript checking * delint * Iterate * Iterate * Fix modal.close loop * Iterate * Fix tests * Add comment * Fix test
This commit is contained in:
parent
ae5725b24c
commit
629e5cb01f
124 changed files with 600 additions and 560 deletions
|
@ -15,9 +15,10 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React, { ComponentType } from "react";
|
||||
import React from "react";
|
||||
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||
|
||||
import type ExportE2eKeysDialog from "../../../async-components/views/dialogs/security/ExportE2eKeysDialog";
|
||||
import Field from "../elements/Field";
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
import AccessibleButton from "../elements/AccessibleButton";
|
||||
|
@ -100,7 +101,7 @@ export default class ChangePassword extends React.Component<IProps, IState> {
|
|||
|
||||
if (userHasOtherDevices && !serverSupportsControlOfDevicesLogout && this.props.confirm) {
|
||||
// warn about logging out all devices
|
||||
const { finished } = Modal.createDialog<[boolean]>(QuestionDialog, {
|
||||
const { finished } = Modal.createDialog(QuestionDialog, {
|
||||
title: _t("Warning!"),
|
||||
description: (
|
||||
<div>
|
||||
|
@ -218,7 +219,7 @@ export default class ChangePassword extends React.Component<IProps, IState> {
|
|||
private onExportE2eKeysClicked = (): void => {
|
||||
Modal.createDialogAsync(
|
||||
import("../../../async-components/views/dialogs/security/ExportE2eKeysDialog") as unknown as Promise<
|
||||
ComponentType<{}>
|
||||
typeof ExportE2eKeysDialog
|
||||
>,
|
||||
{
|
||||
matrixClient: MatrixClientPeg.get(),
|
||||
|
|
|
@ -14,8 +14,10 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React, { ComponentType } from "react";
|
||||
import React from "react";
|
||||
|
||||
import type ExportE2eKeysDialog from "../../../async-components/views/dialogs/security/ExportE2eKeysDialog";
|
||||
import type ImportE2eKeysDialog from "../../../async-components/views/dialogs/security/ImportE2eKeysDialog";
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
import { _t } from "../../../languageHandler";
|
||||
import Modal from "../../../Modal";
|
||||
|
@ -44,7 +46,7 @@ export default class CryptographyPanel extends React.Component<IProps, IState> {
|
|||
identityKey = FormattingUtils.formatCryptoKey(identityKey);
|
||||
}
|
||||
|
||||
let importExportButtons = null;
|
||||
let importExportButtons: JSX.Element | undefined;
|
||||
if (client.isCryptoEnabled()) {
|
||||
importExportButtons = (
|
||||
<div className="mx_CryptographyPanel_importExportButtons">
|
||||
|
@ -58,7 +60,7 @@ export default class CryptographyPanel extends React.Component<IProps, IState> {
|
|||
);
|
||||
}
|
||||
|
||||
let noSendUnverifiedSetting;
|
||||
let noSendUnverifiedSetting: JSX.Element | undefined;
|
||||
if (SettingsStore.isEnabled("blacklistUnverifiedDevices")) {
|
||||
noSendUnverifiedSetting = (
|
||||
<SettingsFlag
|
||||
|
@ -99,7 +101,7 @@ export default class CryptographyPanel extends React.Component<IProps, IState> {
|
|||
private onExportE2eKeysClicked = (): void => {
|
||||
Modal.createDialogAsync(
|
||||
import("../../../async-components/views/dialogs/security/ExportE2eKeysDialog") as unknown as Promise<
|
||||
ComponentType<{}>
|
||||
typeof ExportE2eKeysDialog
|
||||
>,
|
||||
{ matrixClient: MatrixClientPeg.get() },
|
||||
);
|
||||
|
@ -108,7 +110,7 @@ export default class CryptographyPanel extends React.Component<IProps, IState> {
|
|||
private onImportE2eKeysClicked = (): void => {
|
||||
Modal.createDialogAsync(
|
||||
import("../../../async-components/views/dialogs/security/ImportE2eKeysDialog") as unknown as Promise<
|
||||
ComponentType<{}>
|
||||
typeof ImportE2eKeysDialog
|
||||
>,
|
||||
{ matrixClient: MatrixClientPeg.get() },
|
||||
);
|
||||
|
|
|
@ -26,10 +26,10 @@ import Heading from "../typography/Heading";
|
|||
|
||||
interface IProps {
|
||||
// false to display an error saying that we couldn't connect to the integration manager
|
||||
connected: boolean;
|
||||
connected?: boolean;
|
||||
|
||||
// true to display a loading spinner
|
||||
loading: boolean;
|
||||
loading?: boolean;
|
||||
|
||||
// The source URL to load
|
||||
url?: string;
|
||||
|
@ -45,7 +45,7 @@ interface IState {
|
|||
export default class IntegrationManager extends React.Component<IProps, IState> {
|
||||
private dispatcherRef: string;
|
||||
|
||||
public static defaultProps = {
|
||||
public static defaultProps: Partial<IProps> = {
|
||||
connected: true,
|
||||
loading: false,
|
||||
};
|
||||
|
|
|
@ -24,7 +24,6 @@ import { _t } from "../../../languageHandler";
|
|||
import AccessibleButton from "../elements/AccessibleButton";
|
||||
import RoomAvatar from "../avatars/RoomAvatar";
|
||||
import SpaceStore from "../../../stores/spaces/SpaceStore";
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
import Modal from "../../../Modal";
|
||||
import ManageRestrictedJoinRuleDialog from "../dialogs/ManageRestrictedJoinRuleDialog";
|
||||
import RoomUpgradeWarningDialog, { IFinishedOpts } from "../dialogs/RoomUpgradeWarningDialog";
|
||||
|
@ -80,11 +79,9 @@ const JoinRuleSettings: React.FC<IProps> = ({
|
|||
selected = [SpaceStore.instance.activeSpaceRoom.roomId];
|
||||
}
|
||||
|
||||
const matrixClient = MatrixClientPeg.get();
|
||||
const { finished } = Modal.createDialog<[string[]]>(
|
||||
const { finished } = Modal.createDialog(
|
||||
ManageRestrictedJoinRuleDialog,
|
||||
{
|
||||
matrixClient,
|
||||
room,
|
||||
selected,
|
||||
},
|
||||
|
|
|
@ -15,12 +15,13 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React, { ComponentType } from "react";
|
||||
import React from "react";
|
||||
import { IKeyBackupInfo } from "matrix-js-sdk/src/crypto/keybackup";
|
||||
import { TrustInfo } from "matrix-js-sdk/src/crypto/backup";
|
||||
import { CryptoEvent } from "matrix-js-sdk/src/crypto";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
import type CreateKeyBackupDialog from "../../../async-components/views/dialogs/security/CreateKeyBackupDialog";
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
import { _t } from "../../../languageHandler";
|
||||
import Modal from "../../../Modal";
|
||||
|
@ -166,7 +167,7 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {
|
|||
private startNewBackup = (): void => {
|
||||
Modal.createDialogAsync(
|
||||
import("../../../async-components/views/dialogs/security/CreateKeyBackupDialog") as unknown as Promise<
|
||||
ComponentType<{}>
|
||||
typeof CreateKeyBackupDialog
|
||||
>,
|
||||
{
|
||||
onFinished: () => {
|
||||
|
|
|
@ -127,7 +127,7 @@ export default class SetIdServer extends React.Component<IProps, IState> {
|
|||
this.setState({ idServer: u });
|
||||
};
|
||||
|
||||
private getTooltip = (): JSX.Element => {
|
||||
private getTooltip = (): ReactNode => {
|
||||
if (this.state.checking) {
|
||||
return (
|
||||
<div>
|
||||
|
@ -153,7 +153,7 @@ export default class SetIdServer extends React.Component<IProps, IState> {
|
|||
});
|
||||
this.setState({
|
||||
busy: false,
|
||||
error: null,
|
||||
error: undefined,
|
||||
currentClientIdServer: fullUrl,
|
||||
idServer: "",
|
||||
});
|
||||
|
@ -163,7 +163,7 @@ export default class SetIdServer extends React.Component<IProps, IState> {
|
|||
e.preventDefault();
|
||||
const { idServer, currentClientIdServer } = this.state;
|
||||
|
||||
this.setState({ busy: true, checking: true, error: null });
|
||||
this.setState({ busy: true, checking: true, error: undefined });
|
||||
|
||||
const fullUrl = unabbreviateUrl(idServer);
|
||||
|
||||
|
@ -183,7 +183,7 @@ export default class SetIdServer extends React.Component<IProps, IState> {
|
|||
const hasTerms = await doesIdentityServerHaveTerms(fullUrl);
|
||||
if (!hasTerms) {
|
||||
const [confirmed] = await this.showNoTermsWarning(fullUrl);
|
||||
save = confirmed;
|
||||
save = !!confirmed;
|
||||
}
|
||||
|
||||
// Show a general warning, possibly with details about any bound
|
||||
|
@ -201,7 +201,7 @@ export default class SetIdServer extends React.Component<IProps, IState> {
|
|||
),
|
||||
button: _t("Continue"),
|
||||
});
|
||||
save = confirmed;
|
||||
save = !!confirmed;
|
||||
}
|
||||
|
||||
if (save) {
|
||||
|
@ -215,13 +215,13 @@ export default class SetIdServer extends React.Component<IProps, IState> {
|
|||
this.setState({
|
||||
busy: false,
|
||||
checking: false,
|
||||
error: errStr,
|
||||
error: errStr ?? undefined,
|
||||
currentClientIdServer: MatrixClientPeg.get().getIdentityServerUrl(),
|
||||
});
|
||||
};
|
||||
|
||||
private showNoTermsWarning(fullUrl: string): Promise<[boolean]> {
|
||||
const { finished } = Modal.createDialog<[boolean]>(QuestionDialog, {
|
||||
private showNoTermsWarning(fullUrl: string): Promise<[ok?: boolean]> {
|
||||
const { finished } = Modal.createDialog(QuestionDialog, {
|
||||
title: _t("Identity server has no terms of service"),
|
||||
description: (
|
||||
<div>
|
||||
|
@ -264,7 +264,7 @@ export default class SetIdServer extends React.Component<IProps, IState> {
|
|||
title: string;
|
||||
unboundMessage: ReactNode;
|
||||
button: string;
|
||||
}): Promise<[boolean]> {
|
||||
}): Promise<[ok?: boolean]> {
|
||||
const { currentClientIdServer } = this.state;
|
||||
|
||||
let threepids: IThreepid[] = [];
|
||||
|
@ -349,7 +349,7 @@ export default class SetIdServer extends React.Component<IProps, IState> {
|
|||
message = unboundMessage;
|
||||
}
|
||||
|
||||
const { finished } = Modal.createDialog<[boolean]>(QuestionDialog, {
|
||||
const { finished } = Modal.createDialog(QuestionDialog, {
|
||||
title,
|
||||
description: message,
|
||||
button,
|
||||
|
@ -374,7 +374,7 @@ export default class SetIdServer extends React.Component<IProps, IState> {
|
|||
|
||||
this.setState({
|
||||
busy: false,
|
||||
error: null,
|
||||
error: undefined,
|
||||
currentClientIdServer: MatrixClientPeg.get().getIdentityServerUrl(),
|
||||
idServer: newFieldVal,
|
||||
});
|
||||
|
@ -452,7 +452,7 @@ export default class SetIdServer extends React.Component<IProps, IState> {
|
|||
tooltipContent={this.getTooltip()}
|
||||
tooltipClassName="mx_SetIdServer_tooltip"
|
||||
disabled={this.state.busy}
|
||||
forceValidity={this.state.error ? false : null}
|
||||
forceValidity={this.state.error ? false : undefined}
|
||||
/>
|
||||
<AccessibleButton
|
||||
type="submit"
|
||||
|
|
|
@ -25,8 +25,8 @@ import InteractiveAuthDialog from "../../dialogs/InteractiveAuthDialog";
|
|||
|
||||
const makeDeleteRequest =
|
||||
(matrixClient: MatrixClient, deviceIds: string[]) =>
|
||||
async (auth?: IAuthData): Promise<void> => {
|
||||
await matrixClient.deleteMultipleDevices(deviceIds, auth);
|
||||
async (auth?: IAuthData): Promise<IAuthData> => {
|
||||
return matrixClient.deleteMultipleDevices(deviceIds, auth);
|
||||
};
|
||||
|
||||
export const deleteDevicesWithInteractiveAuth = async (
|
||||
|
|
|
@ -32,7 +32,7 @@ import SettingsStore from "../../../../../settings/SettingsStore";
|
|||
import { UIFeature } from "../../../../../settings/UIFeature";
|
||||
import AccessibleButton from "../../../elements/AccessibleButton";
|
||||
import SettingsFlag from "../../../elements/SettingsFlag";
|
||||
import createRoom, { IOpts } from "../../../../../createRoom";
|
||||
import createRoom from "../../../../../createRoom";
|
||||
import CreateRoomDialog from "../../../dialogs/CreateRoomDialog";
|
||||
import JoinRuleSettings from "../../JoinRuleSettings";
|
||||
import ErrorDialog from "../../../dialogs/ErrorDialog";
|
||||
|
@ -204,7 +204,7 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
|
|||
};
|
||||
|
||||
private createNewRoom = async (defaultPublic: boolean, defaultEncrypted: boolean): Promise<boolean> => {
|
||||
const modal = Modal.createDialog<[boolean, IOpts]>(CreateRoomDialog, { defaultPublic, defaultEncrypted });
|
||||
const modal = Modal.createDialog(CreateRoomDialog, { defaultPublic, defaultEncrypted });
|
||||
|
||||
PosthogTrackers.trackInteraction("WebRoomSettingsSecurityTabCreateNewRoomButton");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue