diff --git a/ui/src/cmsData/legacyCms.json b/ui/src/cmsData/legacyCms.json index 38c23d588..c5c4c327e 100644 --- a/ui/src/cmsData/legacyCms.json +++ b/ui/src/cmsData/legacyCms.json @@ -338,7 +338,7 @@ "uid": "cs6c761d71844ac800" }, "title": "Add Source Affix", - "description": "Add a 2–5 character affix for the source name. Use only letters, no numbers or special characters", + "description": "Add a 2–5 letter-only affix for the source name. The affix will function as a prefix if the content type UID matches with restricted UIDs. The affix will function as a suffix for field UIDs. If left blank, \"cs\" will be used by default. Avoid numbers, special characters, and restricted keywords", "step_lock_text": "Editing this step is currently disabled. To make changes in Draft mode, please deactivate the migration", "lock": false, "active": false, diff --git a/ui/src/components/LegacyCms/Actions/LoadPrefix.tsx b/ui/src/components/LegacyCms/Actions/LoadPrefix.tsx index 0b0a736c2..84343f755 100644 --- a/ui/src/components/LegacyCms/Actions/LoadPrefix.tsx +++ b/ui/src/components/LegacyCms/Actions/LoadPrefix.tsx @@ -29,7 +29,7 @@ const LoadPreFix = (props: LoadSelectCmsProps) => { const dispatch = useDispatch(); - const [prefix, setPrefix] = useState(newMigrationData?.legacy_cms?.affix || ''); + const [prefix, setPrefix] = useState(newMigrationData?.legacy_cms?.affix || 'cs'); const [isError, setIsError] = useState(false); const [errorMessage, setErrorMessage] = useState(''); @@ -76,7 +76,6 @@ const LoadPreFix = (props: LoadSelectCmsProps) => { isRestictedKeywordCheckboxChecked: isCheckedBoxChecked } }; - dispatch(updateNewMigrationData(newMigrationDataObj)); } else { setPrefix(value); @@ -93,7 +92,6 @@ const LoadPreFix = (props: LoadSelectCmsProps) => { }; dispatch(updateNewMigrationData(newMigrationDataObj)); - setIsError(false); //call for Step Change @@ -101,20 +99,30 @@ const LoadPreFix = (props: LoadSelectCmsProps) => { return; } } else { - setIsError(true); - setErrorMessage('Please enter Affix'); + setIsError(false); + setErrorMessage(''); + setIsRestrictedKey(false); + setPrefix(''); + } + }); + + const handleOnBlur = (value: string) => { + if (isEmptyString(value?.trim())) { + setIsError(false); + setErrorMessage(''); + setIsRestrictedKey(false); + setPrefix('cs'); const newMigrationDataObj: INewMigration = { ...newMigrationData, legacy_cms: { ...newMigrationData?.legacy_cms, - affix: value, + affix: 'cs', isRestictedKeywordCheckboxChecked: isCheckedBoxChecked } }; - dispatch(updateNewMigrationData(newMigrationDataObj)); } - }); + } /**** ALL USEEffects HERE ****/ @@ -136,6 +144,11 @@ const LoadPreFix = (props: LoadSelectCmsProps) => { aria-label="affix" disabled={newMigrationData?.legacy_cms?.uploadedFile?.isValidated} isReadOnly={newMigrationData?.legacy_cms?.uploadedFile?.isValidated} + onBlur={(e: React.FocusEvent) => { + handleOnBlur(e.target.value); + + }} + /> {isError &&

{errorMessage}

} diff --git a/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx b/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx index d626a06b1..502728e03 100644 --- a/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx +++ b/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx @@ -154,7 +154,6 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { setIsDisabled(true); if ( - !isEmptyString(newMigrationData?.legacy_cms?.affix) && !isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && !isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id) ) { @@ -358,7 +357,6 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { setShowMessage(true); setValidationMessage('File validated successfully.'); setIsDisabled(true); - !isEmptyString(newMigrationData?.legacy_cms?.affix) || !isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) || (!isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id) && props.handleStepChange(props?.currentStep, true)); @@ -366,7 +364,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { if (newMigrationData?.legacy_cms?.uploadedFile?.reValidate) { setValidationMessage(''); } - if(!isEmptyString(newMigrationData?.legacy_cms?.affix) && !newMigrationData?.legacy_cms?.uploadedFile?.isValidated && !newMigrationData?.legacy_cms?.uploadedFile?.reValidate){ + if(!newMigrationData?.legacy_cms?.uploadedFile?.isValidated && !newMigrationData?.legacy_cms?.uploadedFile?.reValidate){ setIsDisabled(false); } setReValidate(newMigrationData?.legacy_cms?.uploadedFile?.reValidate || false); @@ -376,6 +374,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { // } }, [isValidated, newMigrationData]); + useEffect(() => { if (newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id) { setFileFormat(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id); @@ -448,7 +447,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { isLoading={isLoading} loadingColor="#6c5ce7" version="v2" - disabled={!(reValidate || (!isDisabled && !isEmptyString(newMigrationData?.legacy_cms?.affix)))} + disabled={!(reValidate || (!isDisabled))} > Validate File diff --git a/ui/src/components/LegacyCms/index.tsx b/ui/src/components/LegacyCms/index.tsx index ef300b931..448fab6b1 100644 --- a/ui/src/components/LegacyCms/index.tsx +++ b/ui/src/components/LegacyCms/index.tsx @@ -142,7 +142,7 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, isCompleted, handleOnAll } //Make Step 2 complete - if (!isEmptyString(selectedCmsData?.cms_id) && (!isEmptyString(legacyCMSData?.affix) || !isEmptyString(newMigrationData?.legacy_cms?.affix))) { + if (!isEmptyString(selectedCmsData?.cms_id) && (!isEmptyString(legacyCMSData?.affix) )) { setInternalActiveStepIndex(1); } @@ -197,13 +197,12 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, isCompleted, handleOnAll //Make Step 2 complete if ( - !isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && - !isEmptyString(newMigrationData?.legacy_cms?.affix) + !isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) ) { setInternalActiveStepIndex(1); } - if(!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && !isEmptyString(newMigrationData?.legacy_cms?.affix) && newMigrationData?.legacy_cms?.uploadedFile?.isValidated){ + if(!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && newMigrationData?.legacy_cms?.uploadedFile?.isValidated){ setInternalActiveStepIndex(3); } setisProjectMapped(newMigrationData?.isprojectMapped) @@ -211,8 +210,7 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, isCompleted, handleOnAll },[newMigrationData]); useEffect(()=>{ - if(! isEmptyString(newMigrationData?.legacy_cms?.affix) - && !isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.title) && + if( !isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.title) && ! isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.title) && newMigrationData?.legacy_cms?.uploadedFile?.isValidated){ setIsAllStepsCompleted(true); diff --git a/ui/src/components/Stepper/HorizontalStepper/HorizontalStepper.tsx b/ui/src/components/Stepper/HorizontalStepper/HorizontalStepper.tsx index 78db8e418..de67b07ab 100644 --- a/ui/src/components/Stepper/HorizontalStepper/HorizontalStepper.tsx +++ b/ui/src/components/Stepper/HorizontalStepper/HorizontalStepper.tsx @@ -163,7 +163,7 @@ const HorizontalStepper = forwardRef( -1 < newMigrationData?.legacy_cms?.currentStep && newMigrationData?.legacy_cms?.currentStep < 2 ) { - showNotification(newMigrationData?.legacy_cms?.currentStep + 1); + // showNotification(newMigrationData?.legacy_cms?.currentStep + 1); } else if ( newMigrationData?.destination_stack?.selectedStack === undefined || newMigrationData?.destination_stack?.selectedStack === null || diff --git a/ui/src/components/Stepper/VerticalStepper/AutoVerticalStepper.tsx b/ui/src/components/Stepper/VerticalStepper/AutoVerticalStepper.tsx index 6706bac6a..d9de0f8b1 100644 --- a/ui/src/components/Stepper/VerticalStepper/AutoVerticalStepper.tsx +++ b/ui/src/components/Stepper/VerticalStepper/AutoVerticalStepper.tsx @@ -93,7 +93,12 @@ const AutoVerticalStepper = React.forwardRef< ) : null} */} - {data.description &&
{data.description}
} + {data?.description && ( +
+ )} ); }; diff --git a/ui/src/services/api/upload.service.ts b/ui/src/services/api/upload.service.ts index 851866c5c..c1c9e092b 100644 --- a/ui/src/services/api/upload.service.ts +++ b/ui/src/services/api/upload.service.ts @@ -40,7 +40,7 @@ export const uploadFilePath = () => { return `${UPLOAD_FILE_RELATIVE_URL}upload`; }; -export const fileValidation = async (projectId: string, affix: string) => { +export const fileValidation = async (projectId: string, affix = 'cs') => { try { const options = { headers: {