From 1bc475b915d4d442e4702060a1caf714a96a1707 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Thu, 18 Aug 2022 17:43:06 -0400 Subject: [PATCH] fix(striker-ui): check org prefix, host name on populate --- striker-ui/components/GeneralInitForm.tsx | 42 +++++++++-------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/striker-ui/components/GeneralInitForm.tsx b/striker-ui/components/GeneralInitForm.tsx index ec07bcff..2e68954b 100644 --- a/striker-ui/components/GeneralInitForm.tsx +++ b/striker-ui/components/GeneralInitForm.tsx @@ -373,9 +373,16 @@ const GeneralInitForm = forwardRef< organizationPrefix, ); + testInput({ + inputs: { [IT_IDS.organizationPrefix]: { value: organizationPrefix } }, + }); + testInputToToggleSubmitDisabled({ + excludeTestIds: [IT_IDS.organizationPrefix], + }); + return organizationPrefix; }, - [], + [testInput, testInputToToggleSubmitDisabled], ); const populateHostNameInput = useCallback( ({ @@ -393,9 +400,12 @@ const GeneralInitForm = forwardRef< hostNameInputRef.current.setValue?.call(null, hostName); + testInput({ inputs: { [IT_IDS.hostName]: { value: hostName } } }); + testInputToToggleSubmitDisabled({ excludeTestIds: [IT_IDS.hostName] }); + return hostName; }, - [], + [testInput, testInputToToggleSubmitDisabled], ); const isOrganizationPrefixPrereqFilled = useCallback( () => @@ -437,33 +447,13 @@ const GeneralInitForm = forwardRef< const handleOrganizationPrefixSuggest = useCallback(() => { const organizationPrefix = populateOrganizationPrefixInput(); - let hostName: string | undefined; - if (!hostNameInputRef.current.getIsChangedByUser?.call(null)) { - hostName = populateHostNameInput({ organizationPrefix }); + populateHostNameInput({ organizationPrefix }); } - - testInput({ - inputs: { - [IT_IDS.hostName]: { value: hostName }, - [IT_IDS.organizationPrefix]: { value: organizationPrefix }, - }, - }); - testInputToToggleSubmitDisabled({ - excludeTestIds: [IT_IDS.hostName, IT_IDS.organizationPrefix], - }); - }, [ - populateHostNameInput, - populateOrganizationPrefixInput, - testInput, - testInputToToggleSubmitDisabled, - ]); + }, [populateHostNameInput, populateOrganizationPrefixInput]); const handlerHostNameSuggest = useCallback(() => { - const hostName = populateHostNameInput(); - - testInput({ inputs: { [IT_IDS.hostName]: { value: hostName } } }); - testInputToToggleSubmitDisabled({ excludeTestIds: [IT_IDS.hostName] }); - }, [populateHostNameInput, testInput, testInputToToggleSubmitDisabled]); + populateHostNameInput(); + }, [populateHostNameInput]); const buildHelpMessage = useCallback( (text: string) => (previous?: string) => previous === text ? undefined : text,