FederationRestrictions: add explanation box

This commit is contained in:
Alex Gleason 2021-07-25 16:16:37 -05:00
parent 075eeee9ee
commit 4599d9e39f
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -7,6 +7,7 @@ import Column from '../ui/components/column';
import { createSelector } from 'reselect';
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
import RestrictedInstance from './components/restricted_instance';
import Accordion from 'soapbox/features/ui/components/accordion';
const getHosts = createSelector([
state => state.getIn(['instance', 'pleroma', 'metadata', 'federation', 'mrf_simple'], ImmutableMap()),
@ -19,6 +20,8 @@ const getHosts = createSelector([
const messages = defineMessages({
heading: { id: 'column.federation_restrictions', defaultMessage: 'Federation Restrictions' },
boxTitle: { id: 'federation_restrictions.explanation_box.title', defaultMessage: 'Instance-specific policies' },
boxMessage: { id: 'federation_restrictions.explanation_box.message', defaultMessage: 'Normally servers on the Fediverse can communicate freely. {siteTitle} has imposed restrictions on the following servers.' },
});
const mapStateToProps = state => ({
@ -34,11 +37,31 @@ class FederationRestrictions extends ImmutablePureComponent {
intl: PropTypes.object.isRequired,
};
state = {
explanationBoxExpanded: true,
}
toggleExplanationBox = setting => {
this.setState({ explanationBoxExpanded: setting });
}
render() {
const { intl, hosts } = this.props;
const { intl, hosts, siteTitle } = this.props;
const { explanationBoxExpanded } = this.state;
return (
<Column icon='gavel' heading={intl.formatMessage(messages.heading)} backBtnSlim>
<div className='explanation-box'>
<Accordion
headline={intl.formatMessage(messages.boxTitle)}
expanded={explanationBoxExpanded}
onToggle={this.toggleExplanationBox}
>
{intl.formatMessage(messages.boxMessage, { siteTitle })}
</Accordion>
</div>
<div className='federation-restrictions'>
{hosts.map(host => <RestrictedInstance key={host} host={host} />)}
</div>