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
1 change: 1 addition & 0 deletions api/src/models/project-lowdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ interface Project {
stackDetails: [];
mapperKeys: {};
extract_path: string;
isMigrationStarted: boolean;
}

interface ProjectDocument {
Expand Down
8 changes: 8 additions & 0 deletions api/src/services/migration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ const startMigration = async (req: Request): Promise<any> => {
const { region, user_id } = req?.body?.token_payload ?? {};
await ProjectModelLowdb.read();
const project = ProjectModelLowdb.chain.get("projects").find({ id: projectId }).value();

const index = ProjectModelLowdb.chain.get("projects").findIndex({ id: projectId }).value();
if (index > -1) {
ProjectModelLowdb.update((data: any) => {
data.projects[index].isMigrationStarted = true;
});
}

const packagePath = project?.extract_path;
if (packagePath && project?.destination_stack_id) {
const loggerPath = path.join(process.cwd(), 'logs', projectId, `${project?.destination_stack_id}.log`);
Expand Down
3 changes: 2 additions & 1 deletion api/src/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ const createProject = async (req: Request) => {
created_at: '',
isNewStack: false
},
mapperKeys: {}
mapperKeys: {},
isMigrationStarted: false
};

try {
Expand Down
15 changes: 6 additions & 9 deletions ui/src/components/DestinationStack/Actions/LoadStacks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const LoadStacks = (props: LoadFileFormatProps) => {
updatedStackArray.sort(
(a: IDropDown, b: IDropDown) =>
new Date(b?.created_at)?.getTime() - new Date(a?.created_at)?.getTime()
);
);

setAllStack(updatedStackArray);

Expand Down Expand Up @@ -215,30 +215,27 @@ const LoadStacks = (props: LoadFileFormatProps) => {
setIsError(true);
setErrorMessage("Please create new stack there is no stack available");
}

if(selectedStackData){
setSelectedStack(selectedStackData);
setNewStackCreated(false);
const newMigrationDataObj: INewMigration = {
...newMigrationDataRef?.current,
// ...newMigrationDataRef?.current,
...newMigrationData,
destination_stack: {
...newMigrationDataRef?.current?.destination_stack,
...newMigrationData?.destination_stack,
selectedStack: selectedStackData,
stackArray: stackArray
}
};
// Dispatch the updated migration data to Redux
dispatch(updateNewMigrationData(newMigrationDataObj));

}
}

} catch (error) {
return error;

}

};


const handleCreateNewStack = () => {
cbModal({
Expand Down Expand Up @@ -288,7 +285,7 @@ const LoadStacks = (props: LoadFileFormatProps) => {
// placeholder='Select a stack'
placeholder={placeholder}

isClearable={newMigrationData?.destination_stack?.stackArray?.length > 0 && !emptyStackValue}
isClearable={allStack?.length > 0 && !emptyStackValue}
// hideSelectedOptions={true}
isDisabled={newMigrationData?.project_current_step > 2}
error={isLoading ? false : !!isError }
Expand Down
4 changes: 0 additions & 4 deletions ui/src/components/LogScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const logStyles: { [key: string]: React.CSSProperties } = {

type LogsType = {
serverPath: string;
isMigrationStarted?: boolean;
sendDataToParent?: (isMigrationStarted: boolean) => void | undefined;
}

Expand All @@ -35,7 +34,6 @@ type LogsType = {
*/
const LogViewer = ({ serverPath, sendDataToParent }: LogsType) => {
const [logs, setLogs] = useState(["Loading logs..."]);
const [isMigrationComplete, setIsMigrationComplete] = useState<boolean>(false);

const newMigrationData = useSelector((state: RootState) => state?.migration?.newMigrationData);

Expand Down Expand Up @@ -147,15 +145,13 @@ const LogViewer = ({ serverPath, sendDataToParent }: LogsType) => {
type: 'success'
});
sendDataToParent?.(false);
setIsMigrationComplete(true);

const newMigrationDataObj: INewMigration = {
...newMigrationData,
test_migration: { ...newMigrationData?.test_migration, isMigrationComplete: true }
};

dispatch(updateNewMigrationData((newMigrationDataObj)));

}
} catch (error) {
console.error('Invalid JSON string', error);
Expand Down
3 changes: 2 additions & 1 deletion ui/src/components/MigrationExecution/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getCMSDataFromFile } from '../../cmsData/cmsSelector';

// Redux
import { RootState } from '../../store';
import { setMigrationData, updateMigrationData } from '../../store/slice/migrationDataSlice';
import { updateMigrationData } from '../../store/slice/migrationDataSlice';

// Utilities
import { CS_ENTRIES } from '../../utilities/constants';
Expand All @@ -22,6 +22,7 @@ import LogViewer from '../LogScreen';
//stylesheet
import './index.scss';


const MigrationExecution = () => {
const dispatch = useDispatch();

Expand Down
11 changes: 6 additions & 5 deletions ui/src/components/MigrationFlowHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ type MigrationFlowHeaderProps = {
isLoading: boolean;
isCompleted: boolean;
legacyCMSRef: React.MutableRefObject<any>;
projectData:MigrationResponse
projectData:MigrationResponse;
finalExecutionStarted?: boolean;
};

const MigrationFlowHeader = ({projectData, handleOnClick, isLoading }: MigrationFlowHeaderProps) => {
const MigrationFlowHeader = ({projectData, handleOnClick, isLoading, finalExecutionStarted }: MigrationFlowHeaderProps) => {
const [projectName, setProjectName] = useState('');
const [currentStep, setCurrentStep] = useState<number>(0);

Expand Down Expand Up @@ -53,7 +54,7 @@ const MigrationFlowHeader = ({projectData, handleOnClick, isLoading }: Migration
} else {
stepValue = 'Save and Continue';
}

return (
<div className='d-flex align-items-center justify-content-between migration-flow-header'>
<div className='d-flex align-items-center'>
Expand All @@ -69,9 +70,9 @@ const MigrationFlowHeader = ({projectData, handleOnClick, isLoading }: Migration
onClick={handleOnClick}
version="v2"
aria-label='Save and Continue'
isLoading={isLoading}
isLoading={isLoading || newMigrationData?.isprojectMapped}
disabled={(params?.stepId === '4' && !newMigrationData?.test_migration?.isMigrationComplete) ||
(params?.stepId && params?.stepId <= '2' && currentStep.toString() !== params?.stepId)
(params?.stepId && params?.stepId <= '2' && newMigrationData?.project_current_step?.toString() !== params?.stepId) || finalExecutionStarted
}
>
{stepValue}
Expand Down
14 changes: 12 additions & 2 deletions ui/src/context/app/app.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export interface MigrationExecution {
width: string;
}
export interface IMigrationExecution {
migration_information: MigrationExecution[];
migration_information?: MigrationExecution[];
}

interface ActionCta {
Expand Down Expand Up @@ -189,7 +189,8 @@ export interface INewMigration {
test_migration: ITestMigration;
isprojectMapped: boolean;
stackDetails: IDropDown;
project_current_step:number;
migration_execution: IMigrationExecutionStep;
project_current_step: number;
}

export interface TestStacks {
Expand Down Expand Up @@ -225,6 +226,10 @@ export interface ITestMigration {
isMigrationStarted: boolean;
isMigrationComplete: boolean;
}

export interface IMigrationExecutionStep {
migrationStarted: boolean;
}
export interface IAppContext {
authToken: string;
setAuthToken: (token: string) => void;
Expand Down Expand Up @@ -340,6 +345,10 @@ export const DEFAULT_TEST_MIGRATION: ITestMigration = {
isMigrationComplete: false
};

export const DEFAULT_MIGRATION_EXECUTION_STEP: IMigrationExecutionStep = {
migrationStarted: false
}

export const DEFAULT_NEW_MIGRATION: INewMigration = {
mapperKeys: {},
legacy_cms: DEFAULT_LEGACY_CMS,
Expand All @@ -349,6 +358,7 @@ export const DEFAULT_NEW_MIGRATION: INewMigration = {
isprojectMapped: false,
stackDetails: DEFAULT_DROPDOWN,
testStacks: [],
migration_execution: DEFAULT_MIGRATION_EXECUTION_STEP,
project_current_step: 0,
};

Expand Down
41 changes: 39 additions & 2 deletions ui/src/pages/Migration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { RootState } from '../../store';
import { updateMigrationData, updateNewMigrationData } from '../../store/slice/migrationDataSlice';

// Services
import { getMigrationData, updateCurrentStepData, updateLegacyCMSData, updateDestinationStack, updateAffixData, fileformatConfirmation, updateFileFormatData, affixConfirmation, updateStackDetails, getExistingContentTypes, getExistingGlobalFields } from '../../services/api/migration.service';
import { getMigrationData, updateCurrentStepData, updateLegacyCMSData, updateDestinationStack, updateAffixData, fileformatConfirmation, updateFileFormatData, affixConfirmation, updateStackDetails, getExistingContentTypes, getExistingGlobalFields, startMigration } from '../../services/api/migration.service';
import { getCMSDataFromFile } from '../../cmsData/cmsSelector';

// Utilities
Expand Down Expand Up @@ -51,6 +51,8 @@ const Migration = () => {
const [isCompleted, setIsCompleted] = useState<boolean>(false);
const [isProjectMapper, setIsProjectMapper] = useState<boolean>(false);

const [migrationStarted, setMigrationStarted] = useState(false);

const params: Params<string> = useParams();
const { projectId = '' } = useParams();
const navigate = useNavigate();
Expand Down Expand Up @@ -237,6 +239,9 @@ const Migration = () => {
isMigrationStarted: false,
isMigrationComplete: false
},
migration_execution: {
migrationStarted: migrationStarted
},
stackDetails: projectData?.stackDetails,
testStacks: projectData?.test_stacks,
project_current_step: projectData?.current_step,
Expand Down Expand Up @@ -458,6 +463,37 @@ const Migration = () => {
handleStepChange(4);
}

const handleOnClickMigrationExecution = async () => {
setIsLoading(true);

try {
const migrationRes = await startMigration(newMigrationData?.destination_stack?.selectedOrg?.value, projectId);

console.log("migrationRes", migrationRes);

if (migrationRes?.status === 200) {
setIsLoading(false);
setMigrationStarted(true)
Notification({
notificationContent: { text: 'Migration Execution process started' },
notificationProps: {
position: 'bottom-center',
hideProgressBar: false
},
type: 'message'
});
}
} catch (error) {
return error;
}

const newMigrationDataObj: INewMigration = {
...newMigrationData,
migration_execution: {migrationStarted: true}
};
dispatch(updateNewMigrationData((newMigrationDataObj)));
}

const changeDropdownState = () =>{
const newMigrationDataObj: INewMigration = {
...newMigrationData,
Expand All @@ -471,7 +507,8 @@ const Migration = () => {
handleOnClickLegacyCms,
handleOnClickDestinationStack,
handleOnClickContentMapper,
handleOnClickTestMigration
handleOnClickTestMigration,
handleOnClickMigrationExecution
];

return (
Expand Down
2 changes: 1 addition & 1 deletion upload-api/src/controllers/sitecore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const createSitecoreMapper = async (filePath: string = "", projectId: string | s
fieldMapping.contentTypes.push(element);
}
}
console.log("🚀 ~ createSitecoreMapper ~ fieldMapping:", fieldMapping)
// console.log("🚀 ~ createSitecoreMapper ~ fieldMapping:", fieldMapping)
const config = {
method: 'post',
maxBodyLength: Infinity,
Expand Down