From 5a703bbf5028c5e5a7ba3a3be531a90bd5f3bf55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Wed, 28 Sep 2022 22:57:25 +0200 Subject: [PATCH] TS/FC: Migrations page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/features/migration/index.js | 119 --------------------- app/soapbox/features/migration/index.tsx | 125 +++++++++++++++++++++++ 2 files changed, 125 insertions(+), 119 deletions(-) delete mode 100644 app/soapbox/features/migration/index.js create mode 100644 app/soapbox/features/migration/index.tsx diff --git a/app/soapbox/features/migration/index.js b/app/soapbox/features/migration/index.js deleted file mode 100644 index b323c833c..000000000 --- a/app/soapbox/features/migration/index.js +++ /dev/null @@ -1,119 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import ImmutablePureComponent from 'react-immutable-pure-component'; -import { defineMessages, FormattedMessage, injectIntl } from 'react-intl'; -import { connect } from 'react-redux'; -import { Link } from 'react-router-dom'; - -import { moveAccount } from 'soapbox/actions/security'; -import snackbar from 'soapbox/actions/snackbar'; -// import Column from 'soapbox/features/ui/components/column'; -import { Button, Column, Form, FormActions, FormGroup, Input, Text } from 'soapbox/components/ui'; - -const messages = defineMessages({ - heading: { id: 'column.migration', defaultMessage: 'Account migration' }, - submit: { id: 'migration.submit', defaultMessage: 'Move followers' }, - moveAccountSuccess: { id: 'migration.move_account.success', defaultMessage: 'Account successfully moved.' }, - moveAccountFail: { id: 'migration.move_account.fail', defaultMessage: 'Account migration failed.' }, - acctFieldLabel: { id: 'migration.fields.acct.label', defaultMessage: 'Handle of the new account' }, - acctFieldPlaceholder: { id: 'migration.fields.acct.placeholder', defaultMessage: 'username@domain' }, - currentPasswordFieldLabel: { id: 'migration.fields.confirm_password.label', defaultMessage: 'Current password' }, -}); - -export default @connect() -@injectIntl -class Migration extends ImmutablePureComponent { - - static propTypes = { - dispatch: PropTypes.func.isRequired, - intl: PropTypes.object.isRequired, - }; - - state = { - targetAccount: '', - password: '', - isLoading: false, - } - - handleInputChange = e => { - this.setState({ [e.target.name]: e.target.value }); - } - - clearForm = () => { - this.setState({ targetAccount: '', password: '' }); - } - - handleSubmit = e => { - const { targetAccount, password } = this.state; - const { dispatch, intl } = this.props; - this.setState({ isLoading: true }); - return dispatch(moveAccount(targetAccount, password)).then(() => { - this.clearForm(); - dispatch(snackbar.success(intl.formatMessage(messages.moveAccountSuccess))); - }).catch(error => { - dispatch(snackbar.error(intl.formatMessage(messages.moveAccountFail))); - }).then(() => { - this.setState({ isLoading: false }); - }); - } - - render() { - const { intl } = this.props; - - return ( - -
- - - - - ), - }} - /> - - - - - - - - -