diff --git a/web/components/admin/TextField.tsx b/web/components/admin/TextField.tsx index 4536fea198..2c04f4a2db 100644 --- a/web/components/admin/TextField.tsx +++ b/web/components/admin/TextField.tsx @@ -54,18 +54,19 @@ export const TextField: FC = ({ useTrim, value, }) => { - const [hasChanged, setHasChanged] = useState(false); + const [hasPwdChanged, setHasPwdChanged] = useState(false); + const [showPwdButton, setShowPwdButton] = useState(false); const regex = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#$%^&*]).{8,192}$/; const [form] = Form.useForm(); const handleChange = (e: any) => { // if an extra onChange handler was sent in as a prop, let's run that too. if (onChange) { const val = type === TEXTFIELD_TYPE_NUMBER ? e : e.target.value; - + setShowPwdButton(true); if (fieldName === 'adminPassword' && regex.test(val)) { - setHasChanged(true); + setHasPwdChanged(true); } else { - setHasChanged(false); + setHasPwdChanged(false); } onChange({ fieldName, value: useTrim ? val.trim() : val }); @@ -143,7 +144,7 @@ export const TextField: FC = ({ ) : null} - {fieldName !== 'adminPassword' ? ( + {type !== TEXTFIELD_TYPE_PASSWORD ? (
= ({ = ({ value={value as number | (readonly string[] & number)} /> -
- -
+ {showPwdButton && ( +
+ +
+ )}

{tip}

diff --git a/web/components/admin/TextFieldWithSubmit.tsx b/web/components/admin/TextFieldWithSubmit.tsx index bf39ab9e97..67613ac555 100644 --- a/web/components/admin/TextFieldWithSubmit.tsx +++ b/web/components/admin/TextFieldWithSubmit.tsx @@ -118,6 +118,14 @@ export const TextFieldWithSubmit: FC = ({ 'textfield-with-submit-container': true, submittable: hasChanged, }); + + const isPasswordInput = () => { + if (fieldName === 'adminPassword') { + return false; + } + return true; + }; + return (
@@ -135,7 +143,7 @@ export const TextFieldWithSubmit: FC = ({
{tip}
- {fieldName !== 'adminPassword' && ( + {isPasswordInput() && (