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
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue