FederationRestrictions: add RestrictedInstance component
This commit is contained in:
parent
d922c37891
commit
155b342081
5 changed files with 50 additions and 5 deletions
|
@ -0,0 +1,33 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
|
import { makeGetRemoteInstance } from 'soapbox/selectors';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
|
const getRemoteInstance = makeGetRemoteInstance();
|
||||||
|
|
||||||
|
const mapStateToProps = (state, ownProps) => {
|
||||||
|
return {
|
||||||
|
remoteInstance: getRemoteInstance(state, ownProps.host),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default @connect(mapStateToProps)
|
||||||
|
class RestrictedInstance extends ImmutablePureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
host: PropTypes.string.isRequired,
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { remoteInstance } = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={classNames('restricted-instance', { 'restricted-instance--reject': remoteInstance.getIn(['federation', 'reject']) })}>
|
||||||
|
{remoteInstance.get('host')}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
import Column from '../ui/components/column';
|
import Column from '../ui/components/column';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
|
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
|
||||||
|
import RestrictedInstance from './components/restricted_instance';
|
||||||
|
|
||||||
const getHosts = createSelector([
|
const getHosts = createSelector([
|
||||||
state => state.getIn(['instance', 'pleroma', 'metadata', 'federation', 'mrf_simple'], ImmutableMap()),
|
state => state.getIn(['instance', 'pleroma', 'metadata', 'federation', 'mrf_simple'], ImmutableMap()),
|
||||||
|
@ -39,9 +40,7 @@ class FederationRestrictions extends ImmutablePureComponent {
|
||||||
return (
|
return (
|
||||||
<Column icon='gavel' heading={intl.formatMessage(messages.heading)} backBtnSlim>
|
<Column icon='gavel' heading={intl.formatMessage(messages.heading)} backBtnSlim>
|
||||||
<div className='federation-restrictions'>
|
<div className='federation-restrictions'>
|
||||||
<ul>
|
{hosts.map(host => <RestrictedInstance key={host} host={host} />)}
|
||||||
{hosts.map(host => <li key={host}>{host}</li>)}
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
|
|
@ -230,10 +230,12 @@ const getSimplePolicy = (state, host) => (
|
||||||
|
|
||||||
export const makeGetRemoteInstance = () => {
|
export const makeGetRemoteInstance = () => {
|
||||||
return createSelector([
|
return createSelector([
|
||||||
|
(state, host) => host,
|
||||||
getRemoteInstanceFavicon,
|
getRemoteInstanceFavicon,
|
||||||
getSimplePolicy,
|
getSimplePolicy,
|
||||||
], (favicon, federation) => {
|
], (host, favicon, federation) => {
|
||||||
return ImmutableMap({
|
return ImmutableMap({
|
||||||
|
host,
|
||||||
favicon,
|
favicon,
|
||||||
federation,
|
federation,
|
||||||
});
|
});
|
||||||
|
|
|
@ -83,6 +83,6 @@
|
||||||
@import 'components/crypto-donate';
|
@import 'components/crypto-donate';
|
||||||
@import 'components/datepicker';
|
@import 'components/datepicker';
|
||||||
@import 'components/remote-timeline';
|
@import 'components/remote-timeline';
|
||||||
|
@import 'components/federation-restrictions';
|
||||||
// Holiday
|
// Holiday
|
||||||
@import 'holiday/halloween';
|
@import 'holiday/halloween';
|
||||||
|
|
11
app/styles/components/federation-restrictions.scss
Normal file
11
app/styles/components/federation-restrictions.scss
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
.federation-restrictions {
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.restricted-instance {
|
||||||
|
padding: 10px 0;
|
||||||
|
|
||||||
|
&--reject {
|
||||||
|
text-decoration: line-through;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue