Merge branch 'federation-restrictions-improvements' into 'develop'
FederationRestrictions: conditional display See merge request soapbox-pub/soapbox-fe!643
This commit is contained in:
commit
96e210fe3e
|
@ -8,6 +8,8 @@ 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';
|
||||
import ScrollableList from 'soapbox/components/scrollable_list';
|
||||
import { federationRestrictionsDisclosed } from 'soapbox/utils/state';
|
||||
|
||||
const getHosts = createSelector([
|
||||
state => state.getIn(['instance', 'pleroma', 'metadata', 'federation', 'mrf_simple'], ImmutableMap()),
|
||||
|
@ -22,11 +24,14 @@ 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.' },
|
||||
emptyMessage: { id: 'federation_restrictions.empty_message', defaultMessage: '{siteTitle} has not restricted any instances.' },
|
||||
notDisclosed: { id: 'federation_restrictions.not_disclosed_message', defaultMessage: '{siteTitle} does not disclose federation restrictions through the API.' },
|
||||
});
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
siteTitle: state.getIn(['instance', 'title']),
|
||||
hosts: getHosts(state),
|
||||
disclosed: federationRestrictionsDisclosed(state),
|
||||
});
|
||||
|
||||
export default @connect(mapStateToProps)
|
||||
|
@ -35,6 +40,7 @@ class FederationRestrictions extends ImmutablePureComponent {
|
|||
|
||||
static propTypes = {
|
||||
intl: PropTypes.object.isRequired,
|
||||
disclosed: PropTypes.bool,
|
||||
};
|
||||
|
||||
state = {
|
||||
|
@ -46,9 +52,11 @@ class FederationRestrictions extends ImmutablePureComponent {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { intl, hosts, siteTitle } = this.props;
|
||||
const { intl, hosts, siteTitle, disclosed } = this.props;
|
||||
const { explanationBoxExpanded } = this.state;
|
||||
|
||||
const emptyMessage = disclosed ? messages.emptyMessage : messages.notDisclosed;
|
||||
|
||||
return (
|
||||
<Column icon='gavel' heading={intl.formatMessage(messages.heading)} backBtnSlim>
|
||||
<div className='explanation-box'>
|
||||
|
@ -59,11 +67,12 @@ class FederationRestrictions extends ImmutablePureComponent {
|
|||
>
|
||||
{intl.formatMessage(messages.boxMessage, { siteTitle })}
|
||||
</Accordion>
|
||||
|
||||
</div>
|
||||
|
||||
<div className='federation-restrictions'>
|
||||
{hosts.map(host => <RestrictedInstance key={host} host={host} />)}
|
||||
<ScrollableList emptyMessage={intl.formatMessage(emptyMessage, { siteTitle })}>
|
||||
{hosts.map(host => <RestrictedInstance key={host} host={host} />)}
|
||||
</ScrollableList>
|
||||
</div>
|
||||
</Column>
|
||||
);
|
||||
|
|
|
@ -8,6 +8,7 @@ import FeaturesPanel from 'soapbox/features/ui/components/features_panel';
|
|||
import LinkFooter from 'soapbox/features/ui/components/link_footer';
|
||||
import { getFeatures } from 'soapbox/utils/features';
|
||||
import InstanceInfoPanel from 'soapbox/features/ui/components/instance_info_panel';
|
||||
import { federationRestrictionsDisclosed } from 'soapbox/utils/state';
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const me = state.get('me');
|
||||
|
@ -17,6 +18,7 @@ const mapStateToProps = state => {
|
|||
me,
|
||||
showTrendsPanel: features.trends,
|
||||
showWhoToFollowPanel: features.suggestions,
|
||||
disclosed: federationRestrictionsDisclosed(state),
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -24,7 +26,7 @@ export default @connect(mapStateToProps)
|
|||
class RemoteInstancePage extends ImmutablePureComponent {
|
||||
|
||||
render() {
|
||||
const { me, children, showTrendsPanel, showWhoToFollowPanel, params: { instance: host } } = this.props;
|
||||
const { me, children, showTrendsPanel, showWhoToFollowPanel, params: { instance: host }, disclosed } = this.props;
|
||||
|
||||
return (
|
||||
<div className='page'>
|
||||
|
@ -33,7 +35,7 @@ class RemoteInstancePage extends ImmutablePureComponent {
|
|||
|
||||
<div className='columns-area__panels__pane columns-area__panels__pane--left'>
|
||||
<div className='columns-area__panels__pane__inner'>
|
||||
<InstanceInfoPanel host={host} />
|
||||
{disclosed && <InstanceInfoPanel host={host} />}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -4,3 +4,7 @@ export const displayFqn = state => {
|
|||
const soapbox = getSoapboxConfig(state);
|
||||
return soapbox.get('displayFqn');
|
||||
};
|
||||
|
||||
export const federationRestrictionsDisclosed = state => {
|
||||
return state.hasIn(['instance', 'pleroma', 'metadata', 'federation', 'exclusions']);
|
||||
};
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
.federation-restrictions {
|
||||
padding: 15px;
|
||||
padding-top: 15px;
|
||||
|
||||
.slist .item-list > article {
|
||||
padding: 0 20px;
|
||||
|
||||
&:last-child {
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.restricted-instance {
|
||||
|
|
Loading…
Reference in New Issue