[MM-54832] Convert LocalizedInput of 'password_reset_send_link.tsx' to regular input component (#25018)

Этот коммит содержится в:
Akbar Abdrakhmanov
2023-10-20 17:46:22 +06:00
коммит произвёл GitHub
родитель 342b20ba54
Коммит 745e5252ab
4 изменённых файлов: 19 добавлений и 18 удалений

Просмотреть файл

@@ -28,17 +28,11 @@ exports[`components/PasswordResetSendLink should match snapshot 1`] = `
<div <div
className="form-group" className="form-group"
> >
<LocalizedInput <input
autoFocus={true} autoFocus={true}
className="form-control" className="form-control"
id="passwordResetEmailInput" id="passwordResetEmailInput"
name="email" name="email"
placeholder={
Object {
"defaultMessage": "Email",
"id": "password_send.email",
}
}
spellCheck="false" spellCheck="false"
type="email" type="email"
/> />

Просмотреть файл

@@ -5,15 +5,18 @@ import {shallow} from 'enzyme';
import React from 'react'; import React from 'react';
import {MemoryRouter} from 'react-router-dom'; import {MemoryRouter} from 'react-router-dom';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl, type MockIntl} from 'tests/helpers/intl-test-helper';
import PasswordResetSendLink from './password_reset_send_link'; import {PasswordResetSendLink} from './password_reset_send_link';
describe('components/PasswordResetSendLink', () => { describe('components/PasswordResetSendLink', () => {
const baseProps = { const baseProps = {
actions: { actions: {
sendPasswordResetEmail: jest.fn().mockResolvedValue({data: true}), sendPasswordResetEmail: jest.fn().mockResolvedValue({data: true}),
}, },
intl: {
formatMessage: jest.fn(),
} as MockIntl,
}; };
it('should match snapshot', () => { it('should match snapshot', () => {

Просмотреть файл

@@ -2,21 +2,19 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {FormattedMessage} from 'react-intl'; import {FormattedMessage, injectIntl, type IntlShape} from 'react-intl';
import type {ServerError} from '@mattermost/types/errors'; import type {ServerError} from '@mattermost/types/errors';
import {isEmail} from 'mattermost-redux/utils/helpers'; import {isEmail} from 'mattermost-redux/utils/helpers';
import BackButton from 'components/common/back_button'; import BackButton from 'components/common/back_button';
import LocalizedInput from 'components/localized_input/localized_input';
import {t} from 'utils/i18n';
interface Props { interface Props {
actions: { actions: {
sendPasswordResetEmail: (email: string) => Promise<{data: any; error: ServerError}>; sendPasswordResetEmail: (email: string) => Promise<{data: any; error: ServerError}>;
}; };
intl: IntlShape;
} }
interface State { interface State {
@@ -24,7 +22,7 @@ interface State {
updateText: React.ReactNode; updateText: React.ReactNode;
} }
export default class PasswordResetSendLink extends React.PureComponent<Props, State> { export class PasswordResetSendLink extends React.PureComponent<Props, State> {
state = { state = {
error: null, error: null,
updateText: null, updateText: null,
@@ -123,15 +121,15 @@ export default class PasswordResetSendLink extends React.PureComponent<Props, St
/> />
</p> </p>
<div className={formClass}> <div className={formClass}>
<LocalizedInput <input
id='passwordResetEmailInput' id='passwordResetEmailInput'
type='email' type='email'
className='form-control' className='form-control'
name='email' name='email'
placeholder={{ placeholder={this.props.intl.formatMessage({
id: t('password_send.email'), id: 'password_send.email',
defaultMessage: 'Email', defaultMessage: 'Email',
}} })}
ref={this.emailInput} ref={this.emailInput}
spellCheck='false' spellCheck='false'
autoFocus={true} autoFocus={true}
@@ -155,3 +153,5 @@ export default class PasswordResetSendLink extends React.PureComponent<Props, St
); );
} }
} }
export default injectIntl(PasswordResetSendLink);

Просмотреть файл

@@ -114,3 +114,7 @@ export function mountWithIntl<T extends ReactElement | IntlInjectedElement>(elem
}, },
); );
} }
export interface MockIntl extends IntlShape {
formatMessage: jest.Mock;
}