Export Follows, Blocks and Mutes as CSV Files

This commit is contained in:
Louise Fleur-de-Sel
2021-08-31 14:58:16 +00:00
committed by Alex Gleason
parent 20f68185d1
commit 174bab0ca5
6 changed files with 222 additions and 0 deletions

View File

@ -0,0 +1,50 @@
import React from 'react';
import { connect } from 'react-redux';
import { injectIntl } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';
import PropTypes from 'prop-types';
import { SimpleForm } from 'soapbox/features/forms';
export default @connect()
@injectIntl
class CSVExporter extends ImmutablePureComponent {
static propTypes = {
action: PropTypes.func.isRequired,
messages: PropTypes.object.isRequired,
dispatch: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
state = {
isLoading: false,
}
handleClick = (event) => {
const { dispatch, action, intl } = this.props;
this.setState({ isLoading: true });
dispatch(action(intl)).then(() => {
this.setState({ isLoading: false });
}).catch((error) => {
this.setState({ isLoading: false });
});
}
render() {
const { intl, messages } = this.props;
return (
<SimpleForm>
<h2 className='export-title'>{intl.formatMessage(messages.input_label)}</h2>
<div>
<p className='export-hint hint'>{intl.formatMessage(messages.input_hint)}</p>
<button name='button' type='button' className='button button-primary' onClick={this.handleClick}>
{intl.formatMessage(messages.submit)}
</button>
</div>
</SimpleForm>
);
}
}