diff --git a/assets/components/search/DomainSearchBar.tsx b/assets/components/search/DomainSearchBar.tsx index ea82e29..035c7a5 100644 --- a/assets/components/search/DomainSearchBar.tsx +++ b/assets/components/search/DomainSearchBar.tsx @@ -1,19 +1,22 @@ import {Form, Input} from 'antd' import {t} from 'ttag' import {SearchOutlined} from '@ant-design/icons' -import React from 'react' +import React, {useState} from 'react' export interface FieldType { ldhName: string + isRefreshForced: boolean } export function DomainSearchBar({onFinish, initialValue}: { onFinish: (values: FieldType) => void, initialValue?: string }) { + const [isRefreshForced, setRefreshForced] = useState(false) + return (
onFinish({ldhName, isRefreshForced})} autoComplete='off' style={{width: '100%'}} > @@ -33,6 +36,8 @@ export function DomainSearchBar({onFinish, initialValue}: { setRefreshForced(e.shiftKey)} + onKeyUp={e => setRefreshForced(e.shiftKey)} prefix={} placeholder='example.com' autoComplete='off' diff --git a/assets/components/search/EntitiesList.tsx b/assets/components/search/EntitiesList.tsx index 0489f69..bf6e1fd 100644 --- a/assets/components/search/EntitiesList.tsx +++ b/assets/components/search/EntitiesList.tsx @@ -1,4 +1,4 @@ -import {Col, List, Tag, Tooltip, Typography} from 'antd' +import {List, Tag, Tooltip, Typography} from 'antd' import React from 'react' import type {Domain} from '../../utils/api' import {rdapRoleDetailTranslation, rdapRoleTranslation} from '../../utils/functions/rdapTranslation' @@ -29,19 +29,15 @@ export function EntitiesList({domain}: { domain: Domain }) { const details = extractDetailsFromJCard(e) return - - {e.entity.handle}} - description={<> - {details.fn &&
👤 {details.fn}
} - {details.organization &&
🏢 {details.organization}
} - } - /> - - - {e.roles.map(roleToTag)} - + {e.entity.handle}} + description={<> + {details.fn &&
👤 {details.fn}
} + {details.organization &&
🏢 {details.organization}
} + } + /> + {e.roles.map(roleToTag)}
}} /> diff --git a/assets/pages/search/DomainSearchPage.tsx b/assets/pages/search/DomainSearchPage.tsx index 7ac0119..deedd04 100644 --- a/assets/pages/search/DomainSearchPage.tsx +++ b/assets/pages/search/DomainSearchPage.tsx @@ -19,13 +19,15 @@ export default function DomainSearchPage() { const [messageApi, contextHolder] = message.useMessage() const navigate = useNavigate() + + const onFinish: FormProps['onFinish'] = (values) => { navigate('/search/domain/' + values.ldhName) if (loading) return setLoading(true) setDomain(null) - getDomain(values.ldhName).then(d => { + getDomain(values.ldhName, values.isRefreshForced).then(d => { setDomain(d) messageApi.success(t`Found !`) }).catch((e: AxiosError) => { @@ -36,7 +38,7 @@ export default function DomainSearchPage() { useEffect(() => { if (query === undefined) return - onFinish({ldhName: query}) + onFinish({ldhName: query, isRefreshForced: false}) }, []) return ( diff --git a/assets/utils/api/domain.ts b/assets/utils/api/domain.ts index 8171ad5..c93b843 100644 --- a/assets/utils/api/domain.ts +++ b/assets/utils/api/domain.ts @@ -1,9 +1,10 @@ import type {Domain} from '.' -import { request} from '.' +import {request} from '.' -export async function getDomain(ldhName: string): Promise { +export async function getDomain(ldhName: string, forced = false): Promise { const response = await request({ - url: 'domains/' + ldhName + url: 'domains/' + ldhName, + params: {forced} }) return response.data } diff --git a/src/Controller/DomainRefreshController.php b/src/Controller/DomainRefreshController.php index 0bb6adc..25ccdb1 100644 --- a/src/Controller/DomainRefreshController.php +++ b/src/Controller/DomainRefreshController.php @@ -10,6 +10,7 @@ use App\Service\RDAPService; use Psr\Log\LoggerInterface; use Random\Randomizer; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Messenger\Exception\ExceptionInterface; @@ -37,7 +38,7 @@ class DomainRefreshController extends AbstractController * @throws HttpExceptionInterface * @throws \Throwable */ - public function __invoke(string $ldhName, KernelInterface $kernel): Domain + public function __invoke(string $ldhName, KernelInterface $kernel, Request $request): Domain { $idnDomain = strtolower(idn_to_ascii($ldhName)); $userId = $this->getUser()->getUserIdentifier(); @@ -49,12 +50,12 @@ class DomainRefreshController extends AbstractController /** @var ?Domain $domain */ $domain = $this->domainRepository->findOneBy(['ldhName' => $idnDomain]); - // If the domain name exists in the database, recently updated and not important, we return the stored Domain if (null !== $domain && !$domain->getDeleted() && !$domain->isToBeUpdated() && !$this->kernel->isDebug() + && true !== filter_var($request->get('forced', false), FILTER_VALIDATE_BOOLEAN) ) { $this->logger->info('It is not necessary to update the information of the domain name {idnDomain} with the RDAP protocol.', [ 'idnDomain' => $idnDomain,