You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.6 KiB
84 lines
2.6 KiB
7 years ago
|
import React from 'react';
|
||
|
import { connect } from 'react-redux';
|
||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||
6 years ago
|
import { debounce } from 'lodash';
|
||
7 years ago
|
import PropTypes from 'prop-types';
|
||
|
import LoadingIndicator from '../../components/loading_indicator';
|
||
|
import Column from '../ui/components/column';
|
||
|
import ColumnBackButtonSlim from '../../components/column_back_button_slim';
|
||
|
import DomainContainer from '../../containers/domain_container';
|
||
|
import { fetchDomainBlocks, expandDomainBlocks } from '../../actions/domain_blocks';
|
||
6 years ago
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||
7 years ago
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||
6 years ago
|
import ScrollableList from 'flavours/glitch/components/scrollable_list';
|
||
2 years ago
|
import { Helmet } from 'react-helmet';
|
||
7 years ago
|
|
||
|
const messages = defineMessages({
|
||
5 years ago
|
heading: { id: 'column.domain_blocks', defaultMessage: 'Blocked domains' },
|
||
|
unblockDomain: { id: 'account.unblock_domain', defaultMessage: 'Unblock domain {domain}' },
|
||
7 years ago
|
});
|
||
|
|
||
|
const mapStateToProps = state => ({
|
||
|
domains: state.getIn(['domain_lists', 'blocks', 'items']),
|
||
6 years ago
|
hasMore: !!state.getIn(['domain_lists', 'blocks', 'next']),
|
||
7 years ago
|
});
|
||
|
|
||
5 years ago
|
export default @connect(mapStateToProps)
|
||
7 years ago
|
@injectIntl
|
||
5 years ago
|
class Blocks extends ImmutablePureComponent {
|
||
7 years ago
|
|
||
|
static propTypes = {
|
||
|
params: PropTypes.object.isRequired,
|
||
|
dispatch: PropTypes.func.isRequired,
|
||
6 years ago
|
hasMore: PropTypes.bool,
|
||
7 years ago
|
domains: ImmutablePropTypes.list,
|
||
|
intl: PropTypes.object.isRequired,
|
||
5 years ago
|
multiColumn: PropTypes.bool,
|
||
7 years ago
|
};
|
||
|
|
||
|
componentWillMount () {
|
||
|
this.props.dispatch(fetchDomainBlocks());
|
||
|
}
|
||
|
|
||
|
handleLoadMore = debounce(() => {
|
||
|
this.props.dispatch(expandDomainBlocks());
|
||
|
}, 300, { leading: true });
|
||
|
|
||
|
render () {
|
||
5 years ago
|
const { intl, domains, hasMore, multiColumn } = this.props;
|
||
7 years ago
|
|
||
|
if (!domains) {
|
||
|
return (
|
||
|
<Column>
|
||
|
<LoadingIndicator />
|
||
|
</Column>
|
||
|
);
|
||
|
}
|
||
|
|
||
5 years ago
|
const emptyMessage = <FormattedMessage id='empty_column.domain_blocks' defaultMessage='There are no blocked domains yet.' />;
|
||
6 years ago
|
|
||
7 years ago
|
return (
|
||
5 years ago
|
<Column bindToDocument={!multiColumn} icon='minus-circle' heading={intl.formatMessage(messages.heading)}>
|
||
7 years ago
|
<ColumnBackButtonSlim />
|
||
2 years ago
|
|
||
6 years ago
|
<ScrollableList
|
||
|
scrollKey='domain_blocks'
|
||
|
onLoadMore={this.handleLoadMore}
|
||
6 years ago
|
hasMore={hasMore}
|
||
6 years ago
|
emptyMessage={emptyMessage}
|
||
5 years ago
|
bindToDocument={!multiColumn}
|
||
6 years ago
|
>
|
||
7 years ago
|
{domains.map(domain =>
|
||
5 years ago
|
<DomainContainer key={domain} domain={domain} />,
|
||
7 years ago
|
)}
|
||
|
</ScrollableList>
|
||
2 years ago
|
|
||
|
<Helmet>
|
||
|
<meta name='robots' content='noindex' />
|
||
|
</Helmet>
|
||
7 years ago
|
</Column>
|
||
|
);
|
||
|
}
|
||
|
|
||
|
}
|