2022-05-09 20:27:39 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import { useIntl, defineMessages, FormattedMessage } from 'react-intl';
|
|
|
|
|
|
|
|
import { openModal } from 'soapbox/actions/modals';
|
2023-02-09 09:42:46 -08:00
|
|
|
import DropdownMenu from 'soapbox/components/dropdown-menu';
|
2022-05-28 09:02:04 -07:00
|
|
|
import { Widget } from 'soapbox/components/ui';
|
2022-11-15 11:00:40 -08:00
|
|
|
import InstanceRestrictions from 'soapbox/features/federation-restrictions/components/instance-restrictions';
|
2022-05-09 20:27:39 -07:00
|
|
|
import { useAppSelector, useAppDispatch, useOwnAccount } from 'soapbox/hooks';
|
|
|
|
import { makeGetRemoteInstance } from 'soapbox/selectors';
|
|
|
|
|
|
|
|
const getRemoteInstance = makeGetRemoteInstance();
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
editFederation: { id: 'remote_instance.edit_federation', defaultMessage: 'Edit federation' },
|
|
|
|
});
|
|
|
|
|
|
|
|
interface IInstanceModerationPanel {
|
|
|
|
/** Host (eg "gleasonator.com") of the remote instance to moderate. */
|
2023-02-15 13:26:27 -08:00
|
|
|
host: string
|
2022-05-09 20:27:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Widget for moderators to manage a remote instance. */
|
|
|
|
const InstanceModerationPanel: React.FC<IInstanceModerationPanel> = ({ host }) => {
|
|
|
|
const intl = useIntl();
|
|
|
|
const dispatch = useAppDispatch();
|
|
|
|
|
|
|
|
const account = useOwnAccount();
|
|
|
|
const remoteInstance = useAppSelector(state => getRemoteInstance(state, host));
|
|
|
|
|
|
|
|
const handleEditFederation = () => {
|
|
|
|
dispatch(openModal('EDIT_FEDERATION', { host }));
|
|
|
|
};
|
|
|
|
|
|
|
|
const makeMenu = () => {
|
|
|
|
return [{
|
|
|
|
text: intl.formatMessage(messages.editFederation),
|
|
|
|
action: handleEditFederation,
|
2022-07-09 09:20:02 -07:00
|
|
|
icon: require('@tabler/icons/edit.svg'),
|
2022-05-09 20:27:39 -07:00
|
|
|
}];
|
|
|
|
};
|
|
|
|
|
|
|
|
const menu = makeMenu();
|
|
|
|
|
|
|
|
return (
|
2022-05-28 09:02:04 -07:00
|
|
|
<Widget
|
|
|
|
title={<FormattedMessage id='remote_instance.federation_panel.heading' defaultMessage='Federation Restrictions' />}
|
|
|
|
action={account?.admin ? (
|
2022-07-09 09:20:02 -07:00
|
|
|
<DropdownMenu items={menu} src={require('@tabler/icons/dots-vertical.svg')} />
|
2022-05-28 09:02:04 -07:00
|
|
|
) : undefined}
|
|
|
|
>
|
|
|
|
<InstanceRestrictions remoteInstance={remoteInstance} />
|
|
|
|
</Widget>
|
2022-05-09 20:27:39 -07:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default InstanceModerationPanel;
|