Migrate AskInviteAnywayDialog to TypeScript

pull/21833/head
Germain Souquet 2021-06-14 21:03:12 +01:00
parent 5f2ab50a90
commit f2250af565
1 changed files with 22 additions and 19 deletions

View File

@ -15,39 +15,41 @@ limitations under the License.
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import * as sdk from '../../../index'; import * as sdk from '../../../index';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import SettingsStore from "../../../settings/SettingsStore"; import SettingsStore from "../../../settings/SettingsStore";
import { SettingLevel } from "../../../settings/SettingLevel"; import { SettingLevel } from "../../../settings/SettingLevel";
import { replaceableComponent } from "../../../utils/replaceableComponent"; import { replaceableComponent } from "../../../utils/replaceableComponent";
@replaceableComponent("views.dialogs.AskInviteAnywayDialog") interface IProps {
export default class AskInviteAnywayDialog extends React.Component { unknownProfileUsers: Array<{
static propTypes = { userId: string;
unknownProfileUsers: PropTypes.array.isRequired, // [ {userId, errorText}... ] errorText: string;
onInviteAnyways: PropTypes.func.isRequired, }>;
onGiveUp: PropTypes.func.isRequired, onInviteAnyways: () => void;
onFinished: PropTypes.func.isRequired, onGiveUp: () => void;
}; onFinished: (success: boolean) => void;
}
_onInviteClicked = () => { @replaceableComponent("views.dialogs.AskInviteAnywayDialog")
export default class AskInviteAnywayDialog extends React.Component<IProps> {
private onInviteClicked = (): void => {
this.props.onInviteAnyways(); this.props.onInviteAnyways();
this.props.onFinished(true); this.props.onFinished(true);
}; };
_onInviteNeverWarnClicked = () => { private onInviteNeverWarnClicked = (): void => {
SettingsStore.setValue("promptBeforeInviteUnknownUsers", null, SettingLevel.ACCOUNT, false); SettingsStore.setValue("promptBeforeInviteUnknownUsers", null, SettingLevel.ACCOUNT, false);
this.props.onInviteAnyways(); this.props.onInviteAnyways();
this.props.onFinished(true); this.props.onFinished(true);
}; };
_onGiveUpClicked = () => { private onGiveUpClicked = (): void => {
this.props.onGiveUp(); this.props.onGiveUp();
this.props.onFinished(false); this.props.onFinished(false);
}; };
render() { public render() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const errorList = this.props.unknownProfileUsers const errorList = this.props.unknownProfileUsers
@ -55,11 +57,12 @@ export default class AskInviteAnywayDialog extends React.Component {
return ( return (
<BaseDialog className='mx_RetryInvitesDialog' <BaseDialog className='mx_RetryInvitesDialog'
onFinished={this._onGiveUpClicked} onFinished={this.onGiveUpClicked}
title={_t('The following users may not exist')} title={_t('The following users may not exist')}
contentId='mx_Dialog_content' contentId='mx_Dialog_content'
> >
<div id='mx_Dialog_content'> <div id='mx_Dialog_content'>
{/* eslint-disable-next-line */}
<p>{_t("Unable to find profiles for the Matrix IDs listed below - would you like to invite them anyway?")}</p> <p>{_t("Unable to find profiles for the Matrix IDs listed below - would you like to invite them anyway?")}</p>
<ul> <ul>
{ errorList } { errorList }
@ -67,13 +70,13 @@ export default class AskInviteAnywayDialog extends React.Component {
</div> </div>
<div className="mx_Dialog_buttons"> <div className="mx_Dialog_buttons">
<button onClick={this._onGiveUpClicked}> <button onClick={this.onGiveUpClicked}>
{ _t('Close') } { _t('Close') }
</button> </button>
<button onClick={this._onInviteNeverWarnClicked}> <button onClick={this.onInviteNeverWarnClicked}>
{ _t('Invite anyway and never warn me again') } { _t('Invite anyway and never warn me again') }
</button> </button>
<button onClick={this._onInviteClicked} autoFocus={true}> <button onClick={this.onInviteClicked} autoFocus={true}>
{ _t('Invite anyway') } { _t('Invite anyway') }
</button> </button>
</div> </div>