From 61a4bc90b8e9d2f43717ea0841fb212ec1e28904 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 25 Jul 2021 16:27:37 -0500 Subject: [PATCH] InstanceInfoPanel: refactor to reuse InstanceRestrictions component --- .../ui/components/instance_info_panel.js | 150 +----------------- app/styles/components/remote-timeline.scss | 18 ++- 2 files changed, 14 insertions(+), 154 deletions(-) diff --git a/app/soapbox/features/ui/components/instance_info_panel.js b/app/soapbox/features/ui/components/instance_info_panel.js index f27105ee9..ee8440262 100644 --- a/app/soapbox/features/ui/components/instance_info_panel.js +++ b/app/soapbox/features/ui/components/instance_info_panel.js @@ -6,15 +6,8 @@ import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { FormattedMessage } from 'react-intl'; import ImmutablePureComponent from 'react-immutable-pure-component'; -import Icon from 'soapbox/components/icon'; import { makeGetRemoteInstance } from 'soapbox/selectors'; - -const hasRestrictions = remoteInstance => { - return remoteInstance - .get('federation') - .deleteAll(['accept', 'reject_deletes', 'report_removal']) - .reduce((acc, value) => acc || value, false); -}; +import InstanceRestrictions from 'soapbox/features/federation_restrictions/components/instance_restrictions'; const getRemoteInstance = makeGetRemoteInstance(); @@ -35,144 +28,9 @@ class InstanceInfoPanel extends ImmutablePureComponent { remoteInstance: ImmutablePropTypes.map, }; - renderRestrictions = () => { - const { remoteInstance } = this.props; - const items = []; - - const { - avatar_removal, - banner_removal, - federated_timeline_removal, - followers_only, - media_nsfw, - media_removal, - } = remoteInstance.get('federation').toJS(); - - const fullMediaRemoval = media_removal && avatar_removal && banner_removal; - const partialMediaRemoval = media_removal || avatar_removal || banner_removal; - - if (followers_only) { - items.push(( -
-
- -
-
- -
-
- )); - } else if (federated_timeline_removal) { - items.push(( -
-
- -
-
- -
-
- )); - } - - if (fullMediaRemoval) { - items.push(( -
-
- -
-
- -
-
- )); - } else if (partialMediaRemoval) { - items.push(( -
-
- -
-
- -
-
- )); - } - - if (!fullMediaRemoval && media_nsfw) { - items.push(( -
-
- -
-
- -
-
- )); - } - - return items; - } - - renderContent = () => { - const { host, instance, remoteInstance } = this.props; - if (!instance || !remoteInstance) return null; - - if (remoteInstance.getIn(['federation', 'reject']) === true) { - return ( -
- - -
- ); - } else if (hasRestrictions(remoteInstance)) { - return [ - ( -
- -
- ), - this.renderRestrictions(), - ]; - } else { - return ( -
- - -
- ); - } - } - render() { + const { remoteInstance } = this.props; + return (
@@ -182,7 +40,7 @@ class InstanceInfoPanel extends ImmutablePureComponent {
- {this.renderContent()} +
); diff --git a/app/styles/components/remote-timeline.scss b/app/styles/components/remote-timeline.scss index 3fb00e731..76e90b38d 100644 --- a/app/styles/components/remote-timeline.scss +++ b/app/styles/components/remote-timeline.scss @@ -1,16 +1,18 @@ .instance-federation-panel { - &__message { - margin-bottom: 15px; - - i.fa { - padding-right: 10px; - } - } - .wtf-panel__content { box-sizing: border-box; padding: 15px; } + + .instance-restrictions { + &__message { + margin-bottom: 15px; + + i.fa { + padding-right: 10px; + } + } + } } .federation-restriction {