bigbuffet-rw/app/soapbox/features/import_data/index.js

67 lines
2.3 KiB
JavaScript
Raw Normal View History

import PropTypes from 'prop-types';
import React from 'react';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { defineMessages, injectIntl } from 'react-intl';
import { connect } from 'react-redux';
import {
2020-09-27 10:24:38 -07:00
importFollows,
importBlocks,
2021-01-07 12:26:05 -08:00
importMutes,
2020-09-27 10:24:38 -07:00
} from 'soapbox/actions/import_data';
2021-01-07 12:26:05 -08:00
import { getFeatures } from 'soapbox/utils/features';
2022-01-10 14:01:24 -08:00
import Column from '../ui/components/column';
2022-01-10 14:01:24 -08:00
import CSVImporter from './components/csv_importer';
const messages = defineMessages({
2020-09-27 09:18:25 -07:00
heading: { id: 'column.import_data', defaultMessage: 'Import data' },
2020-09-27 10:24:38 -07:00
submit: { id: 'import_data.actions.import', defaultMessage: 'Import' },
});
2020-09-27 10:24:38 -07:00
const followMessages = defineMessages({
input_label: { id: 'import_data.follows_label', defaultMessage: 'Follows' },
input_hint: { id: 'import_data.hints.follows', defaultMessage: 'CSV file containing a list of followed accounts' },
submit: { id: 'import_data.actions.import_follows', defaultMessage: 'Import follows' },
});
const blockMessages = defineMessages({
input_label: { id: 'import_data.blocks_label', defaultMessage: 'Blocks' },
input_hint: { id: 'import_data.hints.blocks', defaultMessage: 'CSV file containing a list of blocked accounts' },
submit: { id: 'import_data.actions.import_blocks', defaultMessage: 'Import blocks' },
});
2021-01-07 12:26:05 -08:00
const muteMessages = defineMessages({
input_label: { id: 'import_data.mutes_label', defaultMessage: 'Mutes' },
input_hint: { id: 'import_data.hints.mutes', defaultMessage: 'CSV file containing a list of muted accounts' },
submit: { id: 'import_data.actions.import_mutes', defaultMessage: 'Import mutes' },
});
const mapStateToProps = state => ({
features: getFeatures(state.get('instance')),
});
2020-09-27 10:24:38 -07:00
2021-01-07 12:26:05 -08:00
export default @connect(mapStateToProps)
@injectIntl
2020-09-27 09:18:25 -07:00
class ImportData extends ImmutablePureComponent {
static propTypes = {
intl: PropTypes.object.isRequired,
2021-01-07 12:26:05 -08:00
features: PropTypes.object,
};
render() {
2021-01-07 12:26:05 -08:00
const { intl, features } = this.props;
return (
<Column icon='cloud-upload-alt' label={intl.formatMessage(messages.heading)}>
2020-09-27 10:24:38 -07:00
<CSVImporter action={importFollows} messages={followMessages} />
<CSVImporter action={importBlocks} messages={blockMessages} />
2021-01-07 12:26:05 -08:00
{features.importMutes && <CSVImporter action={importMutes} messages={muteMessages} />}
</Column>
);
}
}