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

main
Tsu-ba-me 9 months ago
parent c22bc3ed29
commit 48aa219d35
  1. 88
      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,42 +820,40 @@ const GeneralInitForm = forwardRef<
ref={adminPasswordInputRef} ref={adminPasswordInputRef}
/> />
</MUIGrid> </MUIGrid>
{isConfirmAdminPassword && ( <MUIGrid item xs={1}>
<MUIGrid item xs={1}> <InputWithRef
<InputWithRef input={
input={ <OutlinedInputWithLabel
<OutlinedInputWithLabel id="striker-init-general-confirm-admin-password"
id="striker-init-general-confirm-admin-password" inputProps={{
inputProps={{ inputProps: {
inputProps: { type: INPUT_TYPES.password,
type: INPUT_TYPES.password, },
}, onBlur: ({ target: { value } }) => {
onBlur: ({ target: { value } }) => { testInput({
testInput({
inputs: {
[IT_IDS.confirmAdminPassword]: { value },
},
});
},
}}
inputLabelProps={{
isNotifyRequired: isConfirmAdminPassword,
}}
label="Confirm password"
onChange={({ target: { value } }) => {
testInputToToggleSubmitDisabled({
inputs: { inputs: {
[IT_IDS.confirmAdminPassword]: { value }, [IT_IDS.confirmAdminPassword]: { value },
}, },
}); });
setConfirmAdminPasswordInputMessage(); },
}} }}
/> inputLabelProps={{
} isNotifyRequired: true,
ref={confirmAdminPasswordInputRef} }}
/> label="Confirm password"
</MUIGrid> onChange={({ target: { value } }) => {
)} testInputToToggleSubmitDisabled({
inputs: {
[IT_IDS.confirmAdminPassword]: { value },
},
});
setConfirmAdminPasswordInputMessage();
}}
/>
}
ref={confirmAdminPasswordInputRef}
/>
</MUIGrid>
</MUIGrid> </MUIGrid>
</MUIGrid> </MUIGrid>
</MUIGrid> </MUIGrid>

Loading…
Cancel
Save