mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-01-01 03:28:18 +03:00
update components to use react-hook-form
This commit is contained in:
parent
914affe0c0
commit
b538096ab0
2 changed files with 32 additions and 15 deletions
|
@ -45,7 +45,7 @@ type FormData = {
|
||||||
ratelimit_whitelist: string;
|
ratelimit_whitelist: string;
|
||||||
edns_cs_enabled: boolean;
|
edns_cs_enabled: boolean;
|
||||||
edns_cs_use_custom: boolean;
|
edns_cs_use_custom: boolean;
|
||||||
edns_cs_custom_ip?: string;
|
edns_cs_custom_ip?: boolean;
|
||||||
dnssec_enabled: boolean;
|
dnssec_enabled: boolean;
|
||||||
disable_ipv6: boolean;
|
disable_ipv6: boolean;
|
||||||
blocking_mode: string;
|
blocking_mode: string;
|
||||||
|
@ -67,7 +67,6 @@ const Form = ({ processing, initialValues, onSubmit }: Props) => {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
watch,
|
watch,
|
||||||
control,
|
|
||||||
formState: { errors, isSubmitting, isDirty },
|
formState: { errors, isSubmitting, isDirty },
|
||||||
} = useForm<FormData>({
|
} = useForm<FormData>({
|
||||||
mode: 'onChange',
|
mode: 'onChange',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import React, { useRef } from 'react';
|
import React, { useRef } from 'react';
|
||||||
import { Controller, useForm } from 'react-hook-form';
|
import { Controller, useForm } from 'react-hook-form';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { Trans, useTranslation } from 'react-i18next';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
|
||||||
import { testUpstreamWithFormValues } from '../../../../actions';
|
import { testUpstreamWithFormValues } from '../../../../actions';
|
||||||
|
@ -96,19 +96,37 @@ const Form = ({ initialValues, onSubmit }: FormProps) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit(onSubmit)} className="form--upstream">
|
<form onSubmit={handleSubmit(onSubmit)} className="form--upstream">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<label className="col form__label" htmlFor={UPSTREAM_DNS_NAME}>
|
<label className="col form__label" htmlFor={UPSTREAM_DNS_NAME}>
|
||||||
{t('upstream_dns_help', { a: (text: string) => <a href={UPSTREAM_CONFIGURATION_WIKI_LINK} target="_blank" rel="noopener noreferrer">{text}</a> })}
|
<Trans
|
||||||
|
components={{
|
||||||
|
a: <a
|
||||||
|
href={UPSTREAM_CONFIGURATION_WIKI_LINK}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
/>,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
upstream_dns_help
|
||||||
|
</Trans>
|
||||||
{' '}
|
{' '}
|
||||||
<a
|
<Trans
|
||||||
href="https://link.adtidy.org/forward.html?action=dns_kb_providers&from=ui&app=home"
|
components={[
|
||||||
target="_blank"
|
<a
|
||||||
rel="noopener noreferrer">
|
href="https://link.adtidy.org/forward.html?action=dns_kb_providers&from=ui&app=home"
|
||||||
{t('dns_providers', { 0: (text: string) => <a href={UPSTREAM_CONFIGURATION_WIKI_LINK} target="_blank" rel="noopener noreferrer">{text}</a> } )}
|
target="_blank"
|
||||||
</a>
|
rel="noopener noreferrer"
|
||||||
</label>
|
key="0"
|
||||||
|
>
|
||||||
<div className="col-12 mb-4">
|
DNS providers
|
||||||
|
</a>
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
dns_providers
|
||||||
|
</Trans>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div className="col-12 mb-4">
|
||||||
<div className="text-edit-container">
|
<div className="text-edit-container">
|
||||||
<Controller
|
<Controller
|
||||||
name="upstream_dns"
|
name="upstream_dns"
|
||||||
|
|
Loading…
Reference in a new issue