RemoteTimeline: rename InstanceInfoPanel

This commit is contained in:
Alex Gleason 2021-08-11 18:35:31 -05:00
parent a5460bb97e
commit 9e12e978d8
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 82 additions and 0 deletions

View File

@ -0,0 +1,80 @@
'use strict';
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { injectIntl, defineMessages, FormattedMessage } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { makeGetRemoteInstance } from 'soapbox/selectors';
import InstanceRestrictions from 'soapbox/features/federation_restrictions/components/instance_restrictions';
import DropdownMenu from 'soapbox/containers/dropdown_menu_container';
import { openModal } from 'soapbox/actions/modal';
import { isAdmin } from 'soapbox/utils/accounts';
const getRemoteInstance = makeGetRemoteInstance();
const messages = defineMessages({
editFederation: { id: 'remote_instance.edit_federation', defaultMessage: 'Edit federation' },
});
const mapStateToProps = (state, { host }) => {
const me = state.get('me');
const account = state.getIn(['accounts', me]);
return {
instance: state.get('instance'),
remoteInstance: getRemoteInstance(state, host),
isAdmin: isAdmin(account),
};
};
export default @connect(mapStateToProps, null, null, { forwardRef: true })
@injectIntl
class InstanceModerationPanel extends ImmutablePureComponent {
static propTypes = {
intl: PropTypes.object.isRequired,
host: PropTypes.string.isRequired,
instance: ImmutablePropTypes.map,
remoteInstance: ImmutablePropTypes.map,
isAdmin: PropTypes.bool,
};
handleEditFederation = e => {
const { dispatch, host } = this.props;
dispatch(openModal('EDIT_FEDERATION', { host }));
}
makeMenu = () => {
const { intl } = this.props;
return [{
text: intl.formatMessage(messages.editFederation),
action: this.handleEditFederation,
}];
}
render() {
const { remoteInstance, isAdmin } = this.props;
const menu = this.makeMenu();
return (
<div className='wtf-panel instance-federation-panel'>
<div className='wtf-panel-header'>
<i role='img' alt='gavel' className='fa fa-gavel wtf-panel-header__icon' />
<span className='wtf-panel-header__label'>
<span><FormattedMessage id='remote_instance.federation_panel.heading' defaultMessage='Federation Restrictions' /></span>
</span>
{isAdmin && <div className='wtf-panel__menu'>
<DropdownMenu items={menu} icon='ellipsis-v' size={18} direction='right' />
</div>}
</div>
<div className='wtf-panel__content'>
<InstanceRestrictions remoteInstance={remoteInstance} />
</div>
</div>
);
}
}

View File

@ -8,6 +8,7 @@ import FeaturesPanel from 'soapbox/features/ui/components/features_panel';
import LinkFooter from 'soapbox/features/ui/components/link_footer'; import LinkFooter from 'soapbox/features/ui/components/link_footer';
import { getFeatures } from 'soapbox/utils/features'; import { getFeatures } from 'soapbox/utils/features';
import InstanceInfoPanel from 'soapbox/features/ui/components/instance_info_panel'; import InstanceInfoPanel from 'soapbox/features/ui/components/instance_info_panel';
import InstanceModerationPanel from 'soapbox/features/ui/components/instance_moderation_panel';
import { federationRestrictionsDisclosed } from 'soapbox/utils/state'; import { federationRestrictionsDisclosed } from 'soapbox/utils/state';
import { isAdmin } from 'soapbox/utils/accounts'; import { isAdmin } from 'soapbox/utils/accounts';
@ -38,6 +39,7 @@ class RemoteInstancePage extends ImmutablePureComponent {
<div className='columns-area__panels__pane columns-area__panels__pane--left'> <div className='columns-area__panels__pane columns-area__panels__pane--left'>
<div className='columns-area__panels__pane__inner'> <div className='columns-area__panels__pane__inner'>
<InstanceModerationPanel host={host} />
{(disclosed || isAdmin) && <InstanceInfoPanel host={host} />} {(disclosed || isAdmin) && <InstanceInfoPanel host={host} />}
</div> </div>
</div> </div>