Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ui/src/components/Common/AddStack/addStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const AddStack = (props: any): JSX.Element => {
locale: formData?.locale?.value || props?.defaultValues?.locale
});

if (resp) {
if (resp === true) {
Notification({
notificationContent: { text: 'Stack created successfully' },
notificationProps: {
Expand All @@ -67,8 +67,9 @@ const AddStack = (props: any): JSX.Element => {
});
props?.closeModal();
} else {

Notification({
notificationContent: { text: 'Stack creation failed. Please try again.' },
notificationContent: { text: resp },
notificationProps: {
position: 'bottom-center',
hideProgressBar: true
Expand Down
32 changes: 30 additions & 2 deletions ui/src/components/DestinationStack/Actions/LoadStacks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ interface LoadFileFormatProps {
handleStepChange: (stepIndex: number, closeStep?: boolean) => void;
}

interface ErrorObject {
error_message?: string;
errors?: Errors;
}
interface Errors {
org_uid?: string[];
}


const defaultStack = {
description: 'Created from Migration Destination Stack Step',
locale: '',
Expand Down Expand Up @@ -108,6 +117,21 @@ const LoadStacks = (props: LoadFileFormatProps) => {
// setAllStack(newMigrationData?.destination_stack?.stackArray)
}, [newMigrationData?.destination_stack?.selectedStack]);

/**
* Function to format the error message
*/
const formatErrorMessage = (errorData: ErrorObject) => {
let message = errorData.error_message;

if (errorData.errors) {
Object.entries(errorData.errors).forEach(([key, value]) => {
message += `\n${key}: ${(value as string[]).join(", ")}`;
});
}

return message;
}

//Handle new stack details
const handleOnSave = async (data: Stack) => {
try {
Expand Down Expand Up @@ -159,8 +183,12 @@ const LoadStacks = (props: LoadFileFormatProps) => {
setIsStackLoading(false);
return true;
}
} catch (error) {
return error;
else {
const errorMessage = formatErrorMessage(resp?.data?.data);
return errorMessage;
}
} catch (error: any) {
return error?.response?.data;
}
};

Expand Down
22 changes: 2 additions & 20 deletions ui/src/components/LegacyCms/Actions/LoadPrefix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,7 @@ const LoadPreFix = (props: LoadSelectCmsProps) => {
}
});

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: 'cs',
isRestictedKeywordCheckboxChecked: isCheckedBoxChecked
}
};
dispatch(updateNewMigrationData(newMigrationDataObj));
}
};


/**** ALL USEEffects HERE ****/

Expand All @@ -144,9 +128,7 @@ const LoadPreFix = (props: LoadSelectCmsProps) => {
aria-label="affix"
disabled={newMigrationData?.legacy_cms?.uploadedFile?.isValidated}
isReadOnly={newMigrationData?.legacy_cms?.uploadedFile?.isValidated}
onBlur={(e: React.FocusEvent<HTMLInputElement>) => {
handleOnBlur(e.target.value);
}}

/>
{isError && <p className="errorMessage">{errorMessage}</p>}
</div>
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ const LoadUploadFile = ( props: LoadUploadFileProps ) =>
{
setValidationMessage( '' );
}
if ( !newMigrationData?.legacy_cms?.uploadedFile?.isValidated && !newMigrationData?.legacy_cms?.uploadedFile?.reValidate )
if (!isEmptyString(newMigrationData?.legacy_cms?.affix) && !newMigrationData?.legacy_cms?.uploadedFile?.isValidated && !newMigrationData?.legacy_cms?.uploadedFile?.reValidate )
{
setIsDisabled( false );
}
Expand Down Expand Up @@ -630,7 +630,7 @@ const LoadUploadFile = ( props: LoadUploadFileProps ) =>
isLoading={ isLoading }
loadingColor="#6c5ce7"
version="v2"
disabled={ !( reValidate || ( !isDisabled ) ) }
disabled={!(reValidate || (!isDisabled && !isEmptyString(newMigrationData?.legacy_cms?.affix)))}
>
{ fileFormat?.toLowerCase() === 'sql' ? 'Check Connection' : 'File Validate' }
</Button>
Expand Down
5 changes: 3 additions & 2 deletions ui/src/components/LegacyCms/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,12 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, isCompleted, handleOnAll
//Make Step 2 complete
if (
!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id)
&& !isEmptyString(newMigrationData?.legacy_cms?.affix)
) {
setInternalActiveStepIndex(1);
}

if(!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && newMigrationData?.legacy_cms?.uploadedFile?.isValidated){
if(!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && newMigrationData?.legacy_cms?.uploadedFile?.isValidated && !isEmptyString(newMigrationData?.legacy_cms?.affix)){
setInternalActiveStepIndex(3);
}
setisProjectMapped(newMigrationData?.isprojectMapped)
Expand All @@ -212,7 +213,7 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, isCompleted, handleOnAll
useEffect(()=>{
if( !isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.title) &&
! isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.title) &&
newMigrationData?.legacy_cms?.uploadedFile?.isValidated){
newMigrationData?.legacy_cms?.uploadedFile?.isValidated && !isEmptyString(newMigrationData?.legacy_cms?.affix) && !isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id)){
setIsAllStepsCompleted(true);
handleAllStepsComplete(true);
}
Expand Down
Loading