2023-05-23 04:52:27 -04:00
|
|
|
import { useCallback } from 'react';
|
2023-05-10 06:59:29 -04:00
|
|
|
|
2023-05-31 17:43:39 -04:00
|
|
|
import { defineMessages, useIntl } from 'react-intl';
|
2023-05-10 06:59:29 -04:00
|
|
|
|
2024-01-16 05:27:26 -05:00
|
|
|
import LockOpenIcon from '@/material-icons/400-24px/lock_open.svg?react';
|
2024-07-25 13:05:54 -04:00
|
|
|
import { unblockDomain } from 'mastodon/actions/domain_blocks';
|
|
|
|
import { useAppDispatch } from 'mastodon/store';
|
2023-10-24 13:45:08 -04:00
|
|
|
|
2023-05-08 21:11:56 -04:00
|
|
|
import { IconButton } from './icon_button';
|
2023-05-08 09:12:12 -04:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
unblockDomain: {
|
|
|
|
id: 'account.unblock_domain',
|
|
|
|
defaultMessage: 'Unblock domain {domain}',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2024-07-25 13:05:54 -04:00
|
|
|
export const Domain: React.FC<{
|
2023-05-08 09:12:12 -04:00
|
|
|
domain: string;
|
2024-07-25 13:05:54 -04:00
|
|
|
}> = ({ domain }) => {
|
2023-05-31 17:43:39 -04:00
|
|
|
const intl = useIntl();
|
2024-07-25 13:05:54 -04:00
|
|
|
const dispatch = useAppDispatch();
|
2023-05-31 17:43:39 -04:00
|
|
|
|
2023-05-08 09:12:12 -04:00
|
|
|
const handleDomainUnblock = useCallback(() => {
|
2024-07-25 13:05:54 -04:00
|
|
|
dispatch(unblockDomain(domain));
|
|
|
|
}, [dispatch, domain]);
|
2023-05-08 09:12:12 -04:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='domain'>
|
|
|
|
<div className='domain__wrapper'>
|
|
|
|
<span className='domain__domain-name'>
|
|
|
|
<strong>{domain}</strong>
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<div className='domain__buttons'>
|
|
|
|
<IconButton
|
|
|
|
active
|
|
|
|
icon='unlock'
|
2023-10-24 13:45:08 -04:00
|
|
|
iconComponent={LockOpenIcon}
|
2023-05-08 09:12:12 -04:00
|
|
|
title={intl.formatMessage(messages.unblockDomain, { domain })}
|
|
|
|
onClick={handleDomainUnblock}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|