From efe989a8f15772cfa7025eac960d118e6bb54595 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 26 Jul 2021 11:46:44 -0500 Subject: [PATCH] FederationRestrictions: conditional display --- .../features/federation_restrictions/index.js | 15 ++++++++++++--- app/soapbox/pages/remote_instance_page.js | 6 ++++-- app/soapbox/utils/state.js | 4 ++++ .../components/federation-restrictions.scss | 10 +++++++++- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/app/soapbox/features/federation_restrictions/index.js b/app/soapbox/features/federation_restrictions/index.js index fa1987b1e..1007e0921 100644 --- a/app/soapbox/features/federation_restrictions/index.js +++ b/app/soapbox/features/federation_restrictions/index.js @@ -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 (
@@ -59,11 +67,12 @@ class FederationRestrictions extends ImmutablePureComponent { > {intl.formatMessage(messages.boxMessage, { siteTitle })} -
- {hosts.map(host => )} + + {hosts.map(host => )} +
); diff --git a/app/soapbox/pages/remote_instance_page.js b/app/soapbox/pages/remote_instance_page.js index 6c34940e0..e1b764b2e 100644 --- a/app/soapbox/pages/remote_instance_page.js +++ b/app/soapbox/pages/remote_instance_page.js @@ -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 features = getFeatures(state.get('instance')); @@ -15,6 +16,7 @@ const mapStateToProps = state => { return { showTrendsPanel: features.trends, showWhoToFollowPanel: features.suggestions, + disclosed: federationRestrictionsDisclosed(state), }; }; @@ -22,7 +24,7 @@ export default @connect(mapStateToProps) class RemoteInstancePage extends ImmutablePureComponent { render() { - const { children, showTrendsPanel, showWhoToFollowPanel, params: { instance: host } } = this.props; + const { children, showTrendsPanel, showWhoToFollowPanel, params: { instance: host }, disclosed } = this.props; return (
@@ -31,7 +33,7 @@ class RemoteInstancePage extends ImmutablePureComponent {
- + {disclosed && }
diff --git a/app/soapbox/utils/state.js b/app/soapbox/utils/state.js index aacf07d18..50acad114 100644 --- a/app/soapbox/utils/state.js +++ b/app/soapbox/utils/state.js @@ -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']); +}; diff --git a/app/styles/components/federation-restrictions.scss b/app/styles/components/federation-restrictions.scss index dab37d89b..b14b601f4 100644 --- a/app/styles/components/federation-restrictions.scss +++ b/app/styles/components/federation-restrictions.scss @@ -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 {