FederationRestrictions: add RestrictedInstance component

groups
Alex Gleason 2021-07-25 15:08:14 -05:00
rodzic d922c37891
commit 155b342081
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
5 zmienionych plików z 50 dodań i 5 usunięć

Wyświetl plik

@ -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>
);
}
}

Wyświetl plik

@ -6,6 +6,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
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';
const getHosts = createSelector([
state => state.getIn(['instance', 'pleroma', 'metadata', 'federation', 'mrf_simple'], ImmutableMap()),
@ -39,9 +40,7 @@ class FederationRestrictions extends ImmutablePureComponent {
return (
<Column icon='gavel' heading={intl.formatMessage(messages.heading)} backBtnSlim>
<div className='federation-restrictions'>
<ul>
{hosts.map(host => <li key={host}>{host}</li>)}
</ul>
{hosts.map(host => <RestrictedInstance key={host} host={host} />)}
</div>
</Column>
);

Wyświetl plik

@ -230,10 +230,12 @@ const getSimplePolicy = (state, host) => (
export const makeGetRemoteInstance = () => {
return createSelector([
(state, host) => host,
getRemoteInstanceFavicon,
getSimplePolicy,
], (favicon, federation) => {
], (host, favicon, federation) => {
return ImmutableMap({
host,
favicon,
federation,
});

Wyświetl plik

@ -83,6 +83,6 @@
@import 'components/crypto-donate';
@import 'components/datepicker';
@import 'components/remote-timeline';
@import 'components/federation-restrictions';
// Holiday
@import 'holiday/halloween';

Wyświetl plik

@ -0,0 +1,11 @@
.federation-restrictions {
padding: 15px;
}
.restricted-instance {
padding: 10px 0;
&--reject {
text-decoration: line-through;
}
}