2023-02-06 10:01:03 -08:00
|
|
|
import clsx from 'clsx';
|
2022-05-30 09:18:31 -07:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
|
|
|
import Icon from 'soapbox/components/icon';
|
|
|
|
import { useAppSelector } from 'soapbox/hooks';
|
|
|
|
import { makeGetRemoteInstance } from 'soapbox/selectors';
|
|
|
|
|
2022-11-15 11:00:40 -08:00
|
|
|
import InstanceRestrictions from './instance-restrictions';
|
2022-05-30 09:18:31 -07:00
|
|
|
|
|
|
|
const getRemoteInstance = makeGetRemoteInstance();
|
|
|
|
|
|
|
|
interface IRestrictedInstance {
|
2023-02-15 13:26:27 -08:00
|
|
|
host: string
|
2022-05-30 09:18:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
const RestrictedInstance: React.FC<IRestrictedInstance> = ({ host }) => {
|
|
|
|
const remoteInstance: any = useAppSelector((state) => getRemoteInstance(state, host));
|
|
|
|
|
|
|
|
const [expanded, setExpanded] = useState(false);
|
|
|
|
|
|
|
|
const toggleExpanded: React.MouseEventHandler<HTMLAnchorElement> = e => {
|
|
|
|
setExpanded((value) => !value);
|
|
|
|
e.preventDefault();
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2022-07-10 15:02:08 -07:00
|
|
|
<div>
|
|
|
|
<a href='#' className='flex items-center gap-1 py-2.5 no-underline' onClick={toggleExpanded}>
|
|
|
|
<Icon src={expanded ? require('@tabler/icons/caret-down.svg') : require('@tabler/icons/caret-right.svg')} />
|
2023-02-06 10:01:03 -08:00
|
|
|
<div className={clsx({ 'line-through': remoteInstance.getIn(['federation', 'reject']) })}>
|
2022-05-30 09:18:31 -07:00
|
|
|
{remoteInstance.get('host')}
|
|
|
|
</div>
|
|
|
|
</a>
|
2022-07-10 15:02:08 -07:00
|
|
|
<div
|
2023-02-06 10:01:03 -08:00
|
|
|
className={clsx({
|
2022-07-10 15:02:08 -07:00
|
|
|
'h-0 overflow-hidden': !expanded,
|
|
|
|
'h-auto': expanded,
|
|
|
|
})}
|
|
|
|
>
|
2022-05-30 09:18:31 -07:00
|
|
|
<InstanceRestrictions remoteInstance={remoteInstance} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default RestrictedInstance;
|