Skip to content
Merged

Stage #381

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f99bb7b
Merge pull request #242 from contentstack/dev
RohitKini Aug 16, 2024
fd9ae14
Merge pull request #246 from contentstack/dev
v1shalpatel Aug 22, 2024
0bec97a
Merge pull request #250 from contentstack/dev
RohitKini Aug 27, 2024
39f94f0
Merge pull request #256 from contentstack/dev
RohitKini Aug 30, 2024
3096464
Merge pull request #262 from contentstack/dev
RohitKini Sep 5, 2024
c3dcd52
Merge pull request #268 from contentstack/dev
RohitKini Sep 11, 2024
5918b59
Merge pull request #273 from contentstack/dev
RohitKini Sep 13, 2024
366cdf8
Merge pull request #276 from contentstack/dev
RohitKini Sep 16, 2024
0c5dce9
Merge pull request #286 from contentstack/dev
RohitKini Sep 19, 2024
38bb979
Merge pull request #290 from contentstack/dev
RohitKini Sep 23, 2024
47eb7e0
Merge pull request #295 from contentstack/dev
RohitKini Sep 25, 2024
e7364d9
Merge pull request #305 from contentstack/dev
sayalijoshi27 Oct 4, 2024
f000e85
Merge pull request #308 from contentstack/dev
umeshmore45 Oct 7, 2024
9f365cd
Merge pull request #311 from contentstack/dev
v1shalpatel Oct 7, 2024
5ed8c6d
Merge pull request #313 from contentstack/dev
RohitKini Oct 8, 2024
c5d0a8c
Merge pull request #323 from contentstack/dev
v1shalpatel Oct 10, 2024
f0eb908
Merge pull request #326 from contentstack/dev
RohitKini Oct 11, 2024
f3b8a28
Merge pull request #337 from contentstack/dev
RohitKini Nov 5, 2024
0eb52d4
Merge pull request #340 from contentstack/dev
RohitKini Nov 6, 2024
7258e82
Merge pull request #343 from contentstack/dev
RohitKini Nov 19, 2024
8b4ffbe
Merge pull request #347 from contentstack/dev
RohitKini Dec 4, 2024
cce53a6
Merge pull request #361 from contentstack/dev
umeshmore45 Dec 5, 2024
3166dce
Merge pull request #365 from contentstack/dev
RohitKini Dec 6, 2024
9117021
Merge pull request #368 from contentstack/dev
umeshmore45 Dec 6, 2024
f3e850b
Merge pull request #370 from contentstack/dev
sayalijoshi27 Dec 7, 2024
0b527fd
Merge pull request #374 from contentstack/dev
RohitKini Dec 7, 2024
4d30047
Merge pull request #376 from contentstack/dev
umeshmore45 Dec 7, 2024
2a76d10
Merge pull request #379 from contentstack/dev
umeshmore45 Dec 8, 2024
fbc5923
added readme.md file
RohitKini Dec 9, 2024
cccb5a3
Update README.md
RohitKini Dec 9, 2024
fa40890
added readme.md
RohitKini Dec 9, 2024
27353b0
added readme.md file for upload api
RohitKini Dec 9, 2024
ef912a7
updated readme file
RohitKini Dec 9, 2024
591656d
refavtor:[CMG-429] and when migration is in-progress then handled dis…
AishDani Dec 9, 2024
382767d
Merge branch 'stage' of github.com:contentstack/migration-v2-node-ser…
AishDani Dec 9, 2024
0aa320b
updated readme file
RohitKini Dec 9, 2024
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
84 changes: 82 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,83 @@
# migration-v2
# Migration v2
## Overview
The migration-v2 project is designed to facilitate the migration of assets and related functionalities. This project includes multiple components such as API, UI, and upload API.

This is the migration V2 Code.
## Installation
Clone the repository:
```
git clone https://github.com/contentstack/migration-v2.git
cd migration-v2
```
Install dependencies:
```
npm install
```

Check for readme.md files and install dependencies for folders

1. go to api folder
```
cd api
npm install
```

2. go to ui folder
```
cd ui
npm install
```

3. go to upload-api folder
```
cd upload-api
npm install
```

## Scripts
- `npm start`: Starts the main server by running index.js.
- `npm run api`: Navigates to the api directory and runs the development server.
- `npm run upload`: Navigates to the upload-api directory and starts the upload API server.
- `npm run ui`: Navigates to the ui directory and starts the UI server.
- `npm run env`: Starts the main server by running npm start.
- `npm run postinstall`: Installs dependencies for the api, ui, and upload-api directories.
- `npm test`: Displays an error message indicating that no tests are specified.

## Repository
- Type: git
- URL: https://github.com/contentstack/migration-v2.git

## Bugs and Issues
- URL: https://github.com/contentstack/migration-v2/issues

## Homepage
- URL: https://github.com/contentstack/migration-v2#readme

## DevDependencies
- husky: ^4.3.8
- prettier: ^2.4.1
- rimraf: ^3.0.2
- validate-branch-name: ^1.3.0

## Husky Configuration
```
"husky": {
"hooks": {}
}
```

- Branch Name Validation
```
"validate-branch-name": {
"pattern": "^(feature|bugfix|hotfix)/[a-z0-9-]{5,30}$",
"errorMsg": "Please add valid branch name!"
}
```

## License
This project is licensed under the ISC License.

## Author
The author information is not specified.

## Contact
For further assistance, please contact the project maintainer through the issues page on GitHub.
20 changes: 14 additions & 6 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# migration-v2-node-server
# migration-v2 API

This is the TSO migration V2's node server.
This is the migration V2's node server.

## To start the server

1. Run `npm i`
2. Install & start MongoDB
3. To run dev server, create `./development.env` file and add env variables as per `./example.env`
4. To run prod server, create `./production.env` file and add env variables as per `./example.env`
1. Run `npm i`
2. Install and start MongoDB

### To start MongoDB

1. Install MongoDB on your system.
2. Start the MongoDB service.
3. Verify that MongoDB is running by opening a command prompt and running the command `mongo --version`.

3. To run the development server, create a `./development.env` file and add environment variables as per `./example.env`
4. To run the production server, create a `./production.env` file and add environment variables as per `./example.env`

1 change: 1 addition & 0 deletions api/src/models/project-lowdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ interface Project {
mapperKeys: {};
extract_path: string;
isMigrationStarted: boolean;
isMigrationCompleted:boolean;
migration_execution: boolean;
}

Expand Down
59 changes: 30 additions & 29 deletions api/src/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const createProject = async (req: Request) => {
},
mapperKeys: {},
isMigrationStarted: false,
isMigrationCompleted:false,
migration_execution:false,
};

Expand Down Expand Up @@ -825,35 +826,35 @@ const updateCurrentStep = async (req: Request) => {
});
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;
// 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?.isMigrationCompleted
) {
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;
data.projects[projectIndex].status = NEW_PROJECT_STATUS[5];
data.projects[projectIndex].updated_at = new Date().toISOString();
});
break;
}
}
logger.info(
getLogMessage(
Expand Down
5 changes: 5 additions & 0 deletions api/src/services/runCli.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export const runCli = async (rg: string, user_id: string, stack_uid: any, projec
ProjectModelLowdb.write();
}
await addCustomMessageInCliLogs(loggerPath, 'info', message);
!isTest && ProjectModelLowdb.update((data:any)=>{
data.projects[projectIndex].isMigrationCompleted = true;
data.projects[projectIndex].isMigrationStarted = false;

})
}
});

Expand Down
52 changes: 50 additions & 2 deletions ui/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
# migration-v2-ui
# Migration UI

This is the migration V2's UI.
Migration UI is a web application designed to facilitate the migration of content. It provides a user-friendly interface for managing and migrating content efficiently.

## Features
- User-friendly interface for content migration
- Integration with Contentstack
- State management with Redux Toolkit
- Comprehensive testing with Testing Library

## Installation

1. Clone the repository:
```sh
git clone https://github.com/contentstack/migration-v2
```

2. Navigate to the project directory:
```sh
cd ui
```

3. Install the dependencies:
```sh
npm install
```

## Usage
Start the development server:
```sh
npm start
```

Open your browser and navigate to http://localhost:3000.

## Dependencies
- @contentstack/json-rte-serializer: ^2.0.5
- @contentstack/venus-components: ^2.2.4
- @reduxjs/toolkit: ^2.2.5
- @testing-library/jest-dom: ^5.17.0
- @testing-library/react: ^13.4.0
- @testing-library/user-event: ^13.5.0
- @types/react: ^18.2.28
- @types/react-dom: ^18.2.13
- @types/react-redux: ^7.1.33

## Contributing
Contributions are welcome! Please open an issue or submit a pull request for any changes.

## License
This project is licensed under the MIT License.
27 changes: 23 additions & 4 deletions ui/src/components/LogScreen/MigrationLogViewer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Libraries
import React, { useEffect, useState, useRef } from 'react';
import { Icon, Notification, cbModal, Link } from '@contentstack/venus-components';
import { Icon, cbModal, Link } from '@contentstack/venus-components';
import io from 'socket.io-client';
import { useSelector, useDispatch } from 'react-redux';

Expand All @@ -20,6 +20,8 @@ import useBlockNavigation from '../../hooks/userNavigation';
import './index.scss';

import { MAGNIFY,DEMAGNIFY } from '../../common/assets';
import { updateCurrentStepData } from '../../services/api/migration.service';
import { useParams } from 'react-router';

const logStyles: { [key: string]: React.CSSProperties } = {
info: { backgroundColor: '#f1f1f1' },
Expand All @@ -30,6 +32,7 @@ const logStyles: { [key: string]: React.CSSProperties } = {

type LogsType = {
serverPath: string;
handleStepChange: (currentStep: number) => void;
}

/**
Expand All @@ -41,11 +44,21 @@ const MigrationLogViewer = ({ serverPath }: LogsType) => {
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);

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

const dispatch = useDispatch();

const { projectId = '' } = useParams();

useEffect(() => {
const socket = io(serverPath || ''); // Connect to the server
const socket = io(serverPath || '',{
reconnection:true,
}); // Connect to the server

socket.on('disconnect', () => {
console.warn('Disconnected from server. Retrying...');
setTimeout(() => socket.connect(), 3000); // Retry connection after 3 seconds
});

/**
* Event listener for 'logUpdate' event.
Expand Down Expand Up @@ -144,6 +157,13 @@ const MigrationLogViewer = ({ serverPath }: LogsType) => {

dispatch(updateNewMigrationData((newMigrationDataObj)));

/**
* Updates the Migration excution step as completed in backend if migration completes.
*/
updateCurrentStepData(selectedOrganisation.value, projectId);



return cbModal({
component: (props: ModalObj) => (
<MigrationCompletionModal
Expand Down Expand Up @@ -208,15 +228,14 @@ const MigrationLogViewer = ({ serverPath }: LogsType) => {
</div>
}
</div>
{(!newMigrationData?.migration_execution?.migrationStarted) && (
<div className='action-items'>
<Icon icon="ArrowUp" version='v2' onClick={handleScrollToTop} />
<Icon icon="ArrowDown" version='v2' onClick={handleScrollToBottom} />
<span onClick={handleZoomIn}>{MAGNIFY}</span>
<span onClick={handleZoomOut}>{DEMAGNIFY}</span>
<Icon icon="ZoomOut" version='v2' onClick={handleZoomOut} />
</div>
)}

</div>
);
};
Expand Down
7 changes: 5 additions & 2 deletions ui/src/components/MigrationExecution/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ import MigrationLogViewer from '../LogScreen/MigrationLogViewer';
//stylesheet
import './index.scss';

export type migrationWxecutionProps = {
handleStepChange: (currentStep: number) => void;
}

const MigrationExecution = () => {
const MigrationExecution = ({handleStepChange}: migrationWxecutionProps) => {
const dispatch = useDispatch();

const migrationData = useSelector((state:RootState)=>state?.migration?.migrationData);
Expand Down Expand Up @@ -113,7 +116,7 @@ const MigrationExecution = () => {
<div className='content-block'>
<div className='content-header'>Execution Logs</div>
<div>
<MigrationLogViewer serverPath={process.env.REACT_APP_BASE_API_URL ?? ''} />
<MigrationLogViewer serverPath={process.env.REACT_APP_BASE_API_URL ?? ''} handleStepChange={handleStepChange}/>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/MigrationFlowHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const MigrationFlowHeader = ({projectData, handleOnClick, isLoading, finalExecut

const isExecutionStarted =
finalExecutionStarted ||
newMigrationData?.migration_execution?.migrationStarted;
newMigrationData?.migration_execution?.migrationStarted || newMigrationData?.migration_execution?.migrationCompleted;

return (
<div className='d-flex align-items-center justify-content-between migration-flow-header'>
Expand Down
Loading