fix(striker-ui): make confirm password always required in general init form

main
Tsu-ba-me 9 months ago
parent c22bc3ed29
commit 48aa219d35
  1. 30
      striker-ui/components/GeneralInitForm.tsx

@ -116,8 +116,6 @@ const GeneralInitForm = forwardRef<
] = useState<boolean>(false); ] = useState<boolean>(false);
const [isShowHostNameSuggest, setIsShowHostNameSuggest] = const [isShowHostNameSuggest, setIsShowHostNameSuggest] =
useState<boolean>(false); useState<boolean>(false);
const [isConfirmAdminPassword, setIsConfirmAdminPassword] =
useState<boolean>(true);
const [isValidateDomain, setIsValidateDomain] = useState<boolean>(true); const [isValidateDomain, setIsValidateDomain] = useState<boolean>(true);
const readHostDetailRef = useRef<boolean>(true); const readHostDetailRef = useRef<boolean>(true);
@ -378,17 +376,10 @@ const GeneralInitForm = forwardRef<
excludeTestIds = [], excludeTestIds = [],
inputs, inputs,
isContinueOnFailure, isContinueOnFailure,
isExcludeConfirmAdminPassword = !isConfirmAdminPassword,
}: Pick< }: Pick<
TestInputFunctionOptions, TestInputFunctionOptions,
'inputs' | 'excludeTestIds' | 'isContinueOnFailure' 'inputs' | 'excludeTestIds' | 'isContinueOnFailure'
> & { > = {}) => {
isExcludeConfirmAdminPassword?: boolean;
} = {}) => {
if (isExcludeConfirmAdminPassword) {
excludeTestIds.push(IT_IDS.confirmAdminPassword);
}
toggleSubmitDisabled?.call( toggleSubmitDisabled?.call(
null, null,
testInput({ testInput({
@ -400,7 +391,7 @@ const GeneralInitForm = forwardRef<
}), }),
); );
}, },
[isConfirmAdminPassword, testInput, toggleSubmitDisabled], [testInput, toggleSubmitDisabled],
); );
const populateOrganizationPrefixInput = useCallback( const populateOrganizationPrefixInput = useCallback(
({ ({
@ -808,19 +799,6 @@ const GeneralInitForm = forwardRef<
inputs: { [IT_IDS.adminPassword]: { value } }, inputs: { [IT_IDS.adminPassword]: { value } },
}); });
}, },
onPasswordVisibilityAppend: (inputType) => {
const localIsConfirmAdminPassword =
inputType === INPUT_TYPES.password;
testInputToToggleSubmitDisabled({
isExcludeConfirmAdminPassword:
!localIsConfirmAdminPassword,
});
setIsConfirmAdminPassword(
localIsConfirmAdminPassword,
);
setConfirmAdminPasswordInputMessage();
},
}} }}
inputLabelProps={{ isNotifyRequired: true }} inputLabelProps={{ isNotifyRequired: true }}
label="Admin password" label="Admin password"
@ -842,7 +820,6 @@ const GeneralInitForm = forwardRef<
ref={adminPasswordInputRef} ref={adminPasswordInputRef}
/> />
</MUIGrid> </MUIGrid>
{isConfirmAdminPassword && (
<MUIGrid item xs={1}> <MUIGrid item xs={1}>
<InputWithRef <InputWithRef
input={ input={
@ -861,7 +838,7 @@ const GeneralInitForm = forwardRef<
}, },
}} }}
inputLabelProps={{ inputLabelProps={{
isNotifyRequired: isConfirmAdminPassword, isNotifyRequired: true,
}} }}
label="Confirm password" label="Confirm password"
onChange={({ target: { value } }) => { onChange={({ target: { value } }) => {
@ -877,7 +854,6 @@ const GeneralInitForm = forwardRef<
ref={confirmAdminPasswordInputRef} ref={confirmAdminPasswordInputRef}
/> />
</MUIGrid> </MUIGrid>
)}
</MUIGrid> </MUIGrid>
</MUIGrid> </MUIGrid>
</MUIGrid> </MUIGrid>

Loading…
Cancel
Save