bigbuffet-rw/app/soapbox/features/admin/moderation_log.js

68 lines
2 KiB
JavaScript
Raw Normal View History

2021-01-01 10:50:13 -08:00
import React from 'react';
import { defineMessages, injectIntl } from 'react-intl';
import { connect } from 'react-redux';
2021-03-15 15:29:48 -07:00
import ImmutablePropTypes from 'react-immutable-proptypes';
2021-01-01 10:50:13 -08:00
import ImmutablePureComponent from 'react-immutable-pure-component';
import PropTypes from 'prop-types';
import Column from '../ui/components/column';
import ScrollableList from 'soapbox/components/scrollable_list';
import { fetchModerationLog } from 'soapbox/actions/admin';
const messages = defineMessages({
heading: { id: 'column.admin.moderation_log', defaultMessage: 'Moderation Log' },
emptyMessage: { id: 'admin.moderation_log.empty_message', defaultMessage: 'You have not performed any moderation actions yet. When you do, a history will be shown here.' },
});
2021-03-15 15:29:48 -07:00
const mapStateToProps = state => ({
items: state.getIn(['admin_log', 'index']).map(i => state.getIn(['admin_log', 'items', String(i)])),
});
export default @connect(mapStateToProps)
2021-01-01 10:50:13 -08:00
@injectIntl
class ModerationLog extends ImmutablePureComponent {
static propTypes = {
intl: PropTypes.object.isRequired,
2021-03-15 15:29:48 -07:00
list: ImmutablePropTypes.list,
2021-01-01 10:50:13 -08:00
};
state = {
isLoading: true,
2021-03-15 15:29:48 -07:00
lastPage: 0,
2021-01-01 10:50:13 -08:00
}
componentDidMount() {
const { dispatch } = this.props;
dispatch(fetchModerationLog())
2021-03-15 15:29:48 -07:00
.then(data => this.setState({
isLoading: false,
lastPage: 1,
}))
2021-01-01 10:50:13 -08:00
.catch(() => {});
}
render() {
2021-03-15 15:29:48 -07:00
const { intl, items } = this.props;
const { isLoading } = this.state;
2021-01-01 10:50:13 -08:00
const showLoading = isLoading && items.count() === 0;
return (
<Column icon='balance-scale' heading={intl.formatMessage(messages.heading)} backBtnSlim>
2021-01-01 10:50:13 -08:00
<ScrollableList
isLoading={isLoading}
showLoading={showLoading}
scrollKey='moderation-log'
emptyMessage={intl.formatMessage(messages.emptyMessage)}
>
{items.map((item, i) => (
<div className='logentry' key={i}>
{item.get('message')}
</div>
))}
</ScrollableList>
</Column>
);
}
}