fix(striker-ui): check org prefix, host name on populate

main
Tsu-ba-me 2 years ago
parent f6cde6a903
commit 1bc475b915
  1. 42
      striker-ui/components/GeneralInitForm.tsx

@ -373,9 +373,16 @@ const GeneralInitForm = forwardRef<
organizationPrefix, organizationPrefix,
); );
testInput({
inputs: { [IT_IDS.organizationPrefix]: { value: organizationPrefix } },
});
testInputToToggleSubmitDisabled({
excludeTestIds: [IT_IDS.organizationPrefix],
});
return organizationPrefix; return organizationPrefix;
}, },
[], [testInput, testInputToToggleSubmitDisabled],
); );
const populateHostNameInput = useCallback( const populateHostNameInput = useCallback(
({ ({
@ -393,9 +400,12 @@ const GeneralInitForm = forwardRef<
hostNameInputRef.current.setValue?.call(null, hostName); hostNameInputRef.current.setValue?.call(null, hostName);
testInput({ inputs: { [IT_IDS.hostName]: { value: hostName } } });
testInputToToggleSubmitDisabled({ excludeTestIds: [IT_IDS.hostName] });
return hostName; return hostName;
}, },
[], [testInput, testInputToToggleSubmitDisabled],
); );
const isOrganizationPrefixPrereqFilled = useCallback( const isOrganizationPrefixPrereqFilled = useCallback(
() => () =>
@ -437,33 +447,13 @@ const GeneralInitForm = forwardRef<
const handleOrganizationPrefixSuggest = useCallback(() => { const handleOrganizationPrefixSuggest = useCallback(() => {
const organizationPrefix = populateOrganizationPrefixInput(); const organizationPrefix = populateOrganizationPrefixInput();
let hostName: string | undefined;
if (!hostNameInputRef.current.getIsChangedByUser?.call(null)) { if (!hostNameInputRef.current.getIsChangedByUser?.call(null)) {
hostName = populateHostNameInput({ organizationPrefix }); populateHostNameInput({ organizationPrefix });
} }
}, [populateHostNameInput, populateOrganizationPrefixInput]);
testInput({
inputs: {
[IT_IDS.hostName]: { value: hostName },
[IT_IDS.organizationPrefix]: { value: organizationPrefix },
},
});
testInputToToggleSubmitDisabled({
excludeTestIds: [IT_IDS.hostName, IT_IDS.organizationPrefix],
});
}, [
populateHostNameInput,
populateOrganizationPrefixInput,
testInput,
testInputToToggleSubmitDisabled,
]);
const handlerHostNameSuggest = useCallback(() => { const handlerHostNameSuggest = useCallback(() => {
const hostName = populateHostNameInput(); populateHostNameInput();
}, [populateHostNameInput]);
testInput({ inputs: { [IT_IDS.hostName]: { value: hostName } } });
testInputToToggleSubmitDisabled({ excludeTestIds: [IT_IDS.hostName] });
}, [populateHostNameInput, testInput, testInputToToggleSubmitDisabled]);
const buildHelpMessage = useCallback( const buildHelpMessage = useCallback(
(text: string) => (previous?: string) => (text: string) => (previous?: string) =>
previous === text ? undefined : text, previous === text ? undefined : text,

Loading…
Cancel
Save