Fix up UIA types and remove unused prop (#29255)

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2025-02-17 09:53:26 +00:00
committed by GitHub
parent 52060235e4
commit dd2da5c132
7 changed files with 18 additions and 42 deletions

View File

@@ -27,13 +27,10 @@ import Spinner from "../views/elements/Spinner";
export const ERROR_USER_CANCELLED = new Error("User cancelled auth session");
type InteractiveAuthCallbackSuccess<T> = (
success: true,
response: T,
extra?: { emailSid?: string; clientSecret?: string },
) => Promise<void>;
type InteractiveAuthCallbackFailure = (success: false, response: IAuthData | Error) => Promise<void>;
export type InteractiveAuthCallback<T> = InteractiveAuthCallbackSuccess<T> & InteractiveAuthCallbackFailure;
export type InteractiveAuthCallback<T> = {
(success: true, response: T, extra?: { emailSid?: string; clientSecret?: string }): Promise<void>;
(success: false, response: IAuthData | Error): Promise<void>;
};
export interface InteractiveAuthProps<T> {
// matrix client to use for UI auth requests
@@ -49,10 +46,6 @@ export interface InteractiveAuthProps<T> {
emailSid?: string;
// If true, poll to see if the auth flow has been completed out-of-band
poll?: boolean;
// If true, components will be told that the 'Continue' button
// is managed by some other party and should not be managed by
// the component itself.
continueIsManaged?: boolean;
// continueText and continueKind are passed straight through to the AuthEntryComponent.
continueText?: string;
continueKind?: ContinueKind;
@@ -288,7 +281,6 @@ export default class InteractiveAuthComponent<T> extends React.Component<Interac
stageState={this.state.stageState}
fail={this.onAuthStageFailed}
setEmailSid={this.setEmailSid}
showContinue={!this.props.continueIsManaged}
onPhaseChange={this.onPhaseChange}
requestEmailToken={this.authLogic.requestEmailToken}
continueText={this.props.continueText}

View File

@@ -85,7 +85,6 @@ interface IAuthEntryProps {
requestEmailToken?: () => Promise<void>;
fail: (error: Error) => void;
clientSecret: string;
showContinue: boolean;
}
interface IPasswordAuthEntryState {
@@ -361,9 +360,11 @@ export class TermsAuthEntry extends React.Component<ITermsAuthEntryProps, ITerms
);
}
let submitButton: JSX.Element | undefined;
if (this.props.showContinue !== false) {
submitButton = (
return (
<div className="mx_InteractiveAuthEntryComponents">
<p>{_t("auth|uia|terms")}</p>
{checkboxes}
{errorSection}
<AccessibleButton
kind="primary"
className="mx_InteractiveAuthEntryComponents_termsSubmit"
@@ -372,15 +373,6 @@ export class TermsAuthEntry extends React.Component<ITermsAuthEntryProps, ITerms
>
{_t("action|accept")}
</AccessibleButton>
);
}
return (
<div className="mx_InteractiveAuthEntryComponents">
<p>{_t("auth|uia|terms")}</p>
{checkboxes}
{errorSection}
{submitButton}
</div>
);
}

View File

@@ -9,7 +9,7 @@ Please see LICENSE files in the repository root for full details.
*/
import React from "react";
import { type MatrixClient, type UIAResponse } from "matrix-js-sdk/src/matrix";
import { type MatrixClient } from "matrix-js-sdk/src/matrix";
import { type AuthType } from "matrix-js-sdk/src/interactive-auth";
import { _t } from "../../../languageHandler";
@@ -63,7 +63,7 @@ export interface InteractiveAuthDialogProps<T = unknown>
// Default is defined in _getDefaultDialogAesthetics()
aestheticsForStagePhases?: DialogAesthetics;
onFinished(success?: boolean, result?: UIAResponse<T> | Error | null): void;
onFinished(success?: boolean, result?: T | Error | null): void;
}
interface IState {
@@ -111,7 +111,7 @@ export default class InteractiveAuthDialog<T> extends React.Component<Interactiv
private onAuthFinished: InteractiveAuthCallback<T> = async (success, result): Promise<void> => {
if (success) {
this.props.onFinished(true, result);
this.props.onFinished(true, result as T);
} else {
if (result === ERROR_USER_CANCELLED) {
this.props.onFinished(false, null);