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
2 changes: 2 additions & 0 deletions api/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export const HTTP_TEXTS = {
"You cannot proceed if the project is not in draft or if any Legacy CMS or Destination Stack or Content Mapping details are missing.",
CANNOT_PROCEED_TEST_MIGRATION:
"You cannot proceed if the project is not in draft or if any Legacy CMS or Destination Stack or Content Mapping or Test Migration details are missing.",
CANNOT_PROCEED_MIGRATION:
"You cannot proceed if the project is not in draft or if any Legacy CMS or Destination Stack or Content Mapping or Test Migration details are missing or Migration is not completed.",
CANNOT_UPDATE_CONTENT_MAPPING:
"Updating the content mapping is restricted. Please verify the status and review preceding actions.",
CANNOT_RESET_CONTENT_MAPPING:
Expand Down
4 changes: 2 additions & 2 deletions api/src/services/migration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const createTestStack = async (req: Request): Promise<LoginServiceType> => {
ProjectModelLowdb.update((data: any) => {
data.projects[index].current_step = STEPPER_STEPS['TESTING'];
data.projects[index].current_test_stack_id = res?.data?.stack?.api_key;
data.projects[index].test_stacks.push({ stackUid: res?.data?.stack?.api_key, isMigrated: false });
data.projects[index].test_stacks.push({ stackUid: res?.data?.stack?.api_key, stackName: res?.data?.stack?.name, isMigrated: false });
});
}
return {
Expand Down Expand Up @@ -169,7 +169,7 @@ const deleteTestStack = async (req: Request): Promise<LoginServiceType> => {
.get("projects")
.findIndex({ id: projectId })
.value();
console.info(index);
if (index > -1) {
ProjectModelLowdb.update((data: any) => {
data.projects[index].current_test_stack_id = "";
Expand Down
31 changes: 29 additions & 2 deletions api/src/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,35 @@ const updateCurrentStep = async (req: Request) => {
);
}

ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].current_step =
STEPPER_STEPS.MIGRATION;
data.projects[projectIndex].status = NEW_PROJECT_STATUS[5];
data.projects[projectIndex].updated_at = new Date().toISOString();
});
break;
}
case STEPPER_STEPS.MIGRATION: {
if (
project.status === NEW_PROJECT_STATUS[0] ||
!isStepCompleted ||
!project?.destination_stack_id ||
project?.content_mapper?.length === 0 ||
!project?.current_test_stack_id ||
!project?.isMigrationStarted
) {
logger.error(
getLogMessage(
srcFunc,
HTTP_TEXTS.CANNOT_PROCEED_MIGRATION,
token_payload
)
);
throw new BadRequestError(
HTTP_TEXTS.CANNOT_PROCEED_MIGRATION
);
}

ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].current_step =
STEPPER_STEPS.MIGRATION;
Expand Down Expand Up @@ -1050,8 +1079,6 @@ const updateStackDetails = async (req: Request) => {
* @throws ExceptionFunction if an error occurs during the update.
*/
const updateContentMapper = async (req: Request) => {
console.info("updateContentMapper", req.params, req.body);

const { orgId, projectId } = req.params;
const { token_payload, content_mapper } = req.body;
const srcFunc = "updateContentMapper";
Expand Down
39 changes: 39 additions & 0 deletions ui/src/components/Common/MigrationCompletionModal/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Libraries
import {
ModalBody,
ModalFooter,
Button,
Link
} from '@contentstack/venus-components';

interface Props {
closeModal: () => void;
data?: StackDetail;
isopen?: (flag: boolean) => void;
}
interface StackDetail {
value?: string;
label?: string;
}

const MigrationCompletionModal = (props: Props) => {
const stackLink = `https://app.contentstack.com/#!/stack/${props?.data?.value}/dashboard`;

return(
<>
<ModalBody>
Migration Execution process is completed. You can view in the selected stack
<Link href={stackLink} target='_blank' className='ml-4'>
<strong>{props?.data?.label}</strong>
</Link>
</ModalBody>
<ModalFooter>
<Button buttonType="light"version={"v2"} onClick={() => {props.closeModal(); props?.isopen?.(false);}}>
Close
</Button>
</ModalFooter>
</>
)
}

export default MigrationCompletionModal;
65 changes: 33 additions & 32 deletions ui/src/components/ContentMapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R


/** ALL HOOKS Here */
const { projectId = '' } = useParams();
const { projectId = '', stepId = '' } = useParams();
const navigate = useNavigate();

const filterRef = useRef<HTMLDivElement | null>(null);
Expand Down Expand Up @@ -894,11 +894,12 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
data?.otherCmsField === 'title' ||
data?.otherCmsField === 'url' ||
data?.otherCmsField === 'reference'||
data?.contentstackFieldType === "global_field"
data?.contentstackFieldType === "global_field" ||
newMigrationData?.project_current_step?.toString() !== stepId
}
/>
</div>
{!(
{!(
data?.otherCmsType === 'Group' ||
data?.otherCmsField === 'title' ||
data?.otherCmsField === 'url' ||
Expand All @@ -920,9 +921,10 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
onClick={() =>
handleAdvancedSetting(fieldLabel, data?.advanced || {}, data?.uid, data)
}
disabled={newMigrationData?.project_current_step?.toString() !== stepId}
/>
</Tooltip>
)}
)}
</div>
);
};
Expand Down Expand Up @@ -953,7 +955,6 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
else {
setIsFieldDeleted(false);
}


setExistingField((prevOptions: ExistingFieldType) => ({
...prevOptions,
Expand Down Expand Up @@ -1375,36 +1376,34 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
maxWidth="290px"
isClearable={selectedOptions?.includes(existingField?.[data?.uid]?.label ?? '')}
options={adjustedOptions}
isDisabled={OptionValue?.isDisabled}
isDisabled={OptionValue?.isDisabled || newMigrationData?.project_current_step?.toString() !== stepId}
/>
</div>
{!OptionValue?.isDisabled && (
<div className='advanced-setting-button'>
<Tooltip
content="Advanced properties"
position="top"
disabled={
data?.otherCmsField === 'title' ||
data?.otherCmsField === 'url'
}
>
<Button
buttonType="light"
disabled={contentTypeSchema && existingField[data?.uid] ? true : false}
<Tooltip
content="Advanced properties"
position="top"
disabled={
data?.otherCmsField === 'title' ||
data?.otherCmsField === 'url'
}
>
<Icon
version={'v2'}
icon="Sliders"
size="small"
onClick={() => {
handleAdvancedSetting(initialOption?.label, data?.advanced || {}, data?.uid, data);
}}
/>
</Button>
</Tooltip>

<Button
buttonType="light"
disabled={(contentTypeSchema && existingField[data?.uid] || newMigrationData?.project_current_step?.toString() !== stepId) ? true : false}
>
<Icon
version={'v2'}
icon="Sliders"
size="small"
onClick={() => {
handleAdvancedSetting(initialOption?.label, data?.advanced || {}, data?.uid, data);
}}
/>
</Button>
</Tooltip>
</div>

)}
</div>
);
Expand Down Expand Up @@ -1996,6 +1995,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
placeholder={otherContentType?.label}
isSearchable
version="v2"
isDisabled={newMigrationData?.project_current_step?.toString() !== stepId}
/>
</div>
)}
Expand All @@ -2012,9 +2012,10 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
/>
<div className='text-end my-2 mx-3 px-1 py-1'>
<Button
className="saveButton"
onClick={handleSaveContentType}
version="v2"
className="saveButton"
onClick={handleSaveContentType}
version="v2"
disabled={newMigrationData?.project_current_step?.toString() !== stepId}
>
Save
</Button>
Expand Down
Loading